diff --git a/algo/ca/core/pars/CaInitManager.cxx b/algo/ca/core/pars/CaInitManager.cxx index 703ca675404b98fb4ae9f7793c3618c98263e651..c02199999cbca27f31934e4fa51aac70b50a4331 100644 --- a/algo/ca/core/pars/CaInitManager.cxx +++ b/algo/ca/core/pars/CaInitManager.cxx @@ -160,6 +160,15 @@ bool InitManager::FormParametersContainer() } } + // Create an instance for active setup + { + fParameters.fActiveSetup = fParameters.fGeometrySetup; + for (const auto& station : fvStationInfo) { + fParameters.fActiveSetup.DisableLayer(station.GetDetectorID(), station.GetStationID()); + } + } + + // Check the consistency of the parameters object. If object inconsistent, it throws std::logic_error try { fParameters.CheckConsistency(); diff --git a/algo/ca/core/pars/CaInitManager.h b/algo/ca/core/pars/CaInitManager.h index 699c1117aeda76cf7c5fa02aa35e67a944874ff3..b2b141a803e2e44a14e2822babf06f428fd8ceda 100644 --- a/algo/ca/core/pars/CaInitManager.h +++ b/algo/ca/core/pars/CaInitManager.h @@ -71,7 +71,8 @@ namespace cbm::algo::ca kGhostSuppression, ///< 9) kRandomSeed, ///< 10) If the random seed is provided kStationLayoutInitialized, ///< 11) If stations layout is initialized - kEnd ///< 12) [technical] number of entries in the enumeration + kSetupInitialized, ///< 12) If KF-setup initialized + kEnd ///< 13) [technical] number of entries in the enumeration }; using DetectorIDIntMap_t = std::unordered_map<EDetectorID, int>; @@ -243,6 +244,15 @@ namespace cbm::algo::ca /// \brief Sets upper-bound cut on max number of triplets per one doublet void SetMaxTripletPerDoublets(unsigned int value) { fParameters.fMaxTripletPerDoublets = value; } + /// \brief Sets setup + /// \tparam Underlying type of the setup + template<typename DataT> + void SetGeometrySetup(const cbm::algo::kf::Setup<DataT>& setup) + { + fParameters.fGeometrySetup = kf::Setup<fvec>(setup); + fInitController.SetFlag(EInitKey::kSetupInitialized, true); + } + /// \brief Sets misalignment parameters in X direction /// \param detectorId Index of the detector system /// \param x Misalignment tolerance in x [cm] @@ -336,4 +346,6 @@ namespace cbm::algo::ca bool fbConfigIsRead = false; ///< Flag, if configuration file was read bool fbGeometryConfigLock = false; ///< Lock geometry initialization }; + + } // namespace cbm::algo::ca diff --git a/algo/ca/core/pars/CaParameters.h b/algo/ca/core/pars/CaParameters.h index 1c4d13876521afd3076be536bedda5c542d8490e..de9c472588c1963e2be56ee923d730fb0400882c 100644 --- a/algo/ca/core/pars/CaParameters.h +++ b/algo/ca/core/pars/CaParameters.h @@ -16,6 +16,7 @@ #include "CaStation.h" #include "CaVector.h" #include "KfFieldRegion.h" +#include "KfSetup.h" #include <boost/serialization/array.hpp> #include <boost/serialization/utility.hpp> @@ -275,6 +276,11 @@ namespace cbm::algo::ca /// If random seed is zero, std::random_device is used to seed the random number generator. int GetRandomSeed() const { return fRandomSeed; } + /// \brief Gets active setup + const auto& GetActiveSetup() const { return fActiveSetup; } + + /// \brief Gets active setup + const auto& GetGeometrySetup() const { return fGeometrySetup; } /// \brief Gets ghost suppression flag int GetGhostSuppression() const { return fGhostSuppression; } @@ -344,6 +350,12 @@ namespace cbm::algo::ca bool DevIsParSearchWUsed() const { return fDevIsParSearchWUsed; } private: + /// \brief Geometrical KF-setup (including inactive stations) + kf::Setup<DataT> fGeometrySetup{kf::EFieldMode::Intrpl}; + + /// \brief Active KF-setup (every layer is an active tracking station) + kf::Setup<DataT> fActiveSetup{kf::EFieldMode::Intrpl}; + unsigned int fMaxDoubletsPerSinglet{150}; ///< Upper-bound cut on max number of doublets per one singlet unsigned int fMaxTripletPerDoublets{15}; ///< Upper-bound cut on max number of triplets per one doublet diff --git a/algo/kf/core/geo/KfFieldValue.h b/algo/kf/core/geo/KfFieldValue.h index d9898579adaa832efda09797298a4751cb288123..5f12ccba46090de7dbba9590d622d64366f1ef54 100644 --- a/algo/kf/core/geo/KfFieldValue.h +++ b/algo/kf/core/geo/KfFieldValue.h @@ -29,6 +29,9 @@ namespace cbm::algo::kf /// \tparam T Underlying data-type (float, double, fvec) template<typename T> class alignas(VcMemAlign) FieldValue { + template<typename> + friend class FieldValue; + public: /// \brief Default constructor /// \note By default field is zero diff --git a/algo/kf/core/geo/KfModuleIndexMap.cxx b/algo/kf/core/geo/KfModuleIndexMap.cxx index bdb3a1d724cb233d7b24138f9fbe344bfc94cccd..20754d86702686815d77870411c5af7565c63361 100644 --- a/algo/kf/core/geo/KfModuleIndexMap.cxx +++ b/algo/kf/core/geo/KfModuleIndexMap.cxx @@ -30,25 +30,32 @@ namespace cbm::algo::kf constexpr char IndentCh = '\t'; std::string indent(indentLevel, IndentCh); std::stringstream msg; - msg << '\n' << indent << format("{:<50} ", "Detector internal to external index map: "); - for (auto id : fvDetIntToExt) { - msg << format("{:>8} ", id); - } - msg << '\n' << indent << format("{:<50} ", "Detector external to internal index map: "); - for (auto id : fvDetExtToInt) { - msg << format("{:>8} ", id); - } - msg << '\n' << indent << format("{:<50} ", "First global ID vs. internal detector: "); - for (auto id : fvDetLocOffset) { - msg << format("{:>8} ", id); - } - msg << '\n' << indent << format("{:<50} ", "Local ID to global ID: "); - for (auto id : fvLocToGlb) { - msg << format("{:>8} ", id); + if constexpr (0) { + msg << '\n' << indent << format("{:<50} ", "Detector internal to external index map: "); + for (auto id : fvDetIntToExt) { + msg << format("{:>8} ", id); + } + msg << '\n' << indent << format("{:<50} ", "Detector external to internal index map: "); + for (auto id : fvDetExtToInt) { + msg << format("{:>8} ", id); + } + msg << '\n' << indent << format("{:<50} ", "First global ID vs. internal detector: "); + for (auto id : fvDetLocOffset) { + msg << format("{:>8} ", id); + } + msg << '\n' << indent << format("{:<50} ", "Local ID to global ID: "); + for (auto id : fvLocToGlb) { + msg << format("{:>8} ", id); + } + msg << '\n' << indent << format("{:<50} ", "Geo ID to (detID:locID): "); + for (const auto& [iDetExt, iLoc] : fvGlbToLoc) { + msg << format("{:>3}:{:<3}", iDetExt, iLoc); + } } - msg << '\n' << indent << format("{:<50} ", "Geo ID to (detID:locID): "); - for (const auto& [iDetExt, iLoc] : fvGlbToLoc) { - msg << format("{:>3}:{:<3}", iDetExt, iLoc); + + for (int iGlb = 0; iGlb < GetNofLayers(); ++iGlb) { + const auto& [iDetExt, iLoc] = fvGlbToLoc[iGlb]; + msg << indent << format("- ({:>3}, {:>3}) -- {:>3}\n", iDetExt, iLoc, iGlb); } return msg.str(); diff --git a/algo/kf/core/geo/KfModuleIndexMap.h b/algo/kf/core/geo/KfModuleIndexMap.h index 4e4ff0696b08bfd4700e9fb18c3273a86e10afe7..ad7d5a446deed3aa5465a7a07999d113141f0393 100644 --- a/algo/kf/core/geo/KfModuleIndexMap.h +++ b/algo/kf/core/geo/KfModuleIndexMap.h @@ -52,20 +52,7 @@ namespace cbm::algo::kf public: /// \brief Gets total number of components - int GetNofLayers() const { return fvDetLocOffset.back(); } - - /// \brief Gets number of layers for a particular detector subsystem - /// \tparam EDetID concrete index type of the det ID (can be either an enum, or an integral type) - /// \param detId Detector ID of the component - /// - /// \note The maximum possible number of components in the subset is returned. It accounts for - /// inactive/unused components. - template<class EDetID> - int GetNofLayers(EDetID detId) const - { - return fvDetLocOffset[fvDetExtToInt[static_cast<int>(detId)] + 1] - - fvDetLocOffset[fvDetExtToInt[static_cast<int>(detId)]]; - } + int GetNofLayers() const { return fvGlbToLoc.size(); } /// \brief Converts internal layer index to pair (detID, locID) /// \tparam EDetID concrete index type of the det ID (can be either an enum, or an integral type) @@ -87,10 +74,11 @@ namespace cbm::algo::kf } /// \brief Disables a component - /// - /// + /// \tparam EDetID concrete index type of the det ID (can be either an enum, or an integral type) + /// \param locId Local ID of the layer + /// \param detId Detector ID of the component template<class EDetID> - void Disable(int locId, EDetID detId); + void Disable(EDetID detId, int locId); /// \brief Resets the instance void Reset(); @@ -152,11 +140,11 @@ namespace cbm::algo::kf // ------------------------------------------------------------------------------------------------------------------- // template<class EDetID> - void ModuleIndexMap::Disable(int locIdDisable, EDetID detIdDisable) + void ModuleIndexMap::Disable(EDetID detIdDisable, int locIdDisable) { // Check, if the detector id is there auto iDetExtDsbl{static_cast<int>(detIdDisable)}; - if (iDetExtDsbl >= fvDetExtToInt.size()) { + if (iDetExtDsbl >= static_cast<int>(fvDetExtToInt.size())) { return; // Nothing to disable, detector is already not in the map } diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index a66a0741ff37da11bfb4d062e4f8d0a49adb7b67..0cfd9c1d121e0f54e7cb8f064cf947e8e9cf8b3e 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -493,6 +493,19 @@ try { // **************************************** this->GenerateMaterialMaps(); + // ************************* + // ** Initialize KF-setup ** + // ************************* + { + auto pSetupInitializer = std::make_unique<TrackingSetupInitializer>(); + pSetupInitializer->Use(fUseMVD, fUseSTS, fUseMUCH, fUseTRD, fUseTOF); + pSetupInitializer->Init(cbm::algo::kf::EFieldMode::Intrpl); + auto trackerSetup = pSetupInitializer->MakeSetup<float>(); + TString outputFile = fSTAPDataDir + "/" + fSTAPDataPrefix + "." + TString(kSTAPSetupSuffix.data()); + cbm::algo::kf::SetupBuilder::Store(trackerSetup, outputFile.Data()); + fInitManager.SetGeometrySetup(trackerSetup); + } + // ******************************* // ** Initialize search windows ** // ******************************* @@ -539,6 +552,7 @@ try { } fpAlgo->Init(fTrackingMode); + if constexpr (1) { // **** FEATURE: KF-SETUP INITIALIZATION ***** // Creating a setup @@ -553,87 +567,6 @@ try { cbm::algo::kf::SetupBuilder::Store(trackerSetup, "./trackerSetup.geo.kf.bin"); // Reading setup (now in fvec): - auto trackerSetupVec = cbm::algo::kf::SetupBuilder::Load<fvec>("./trackerSetup.geo.kf.bin"); - LOG(info) << "!!!!\n!!!!\n!!!!\n!!!! KF SETUP (from file):\n" - << trackerSetupVec.ToString(1) << "\nsize:" << sizeof(trackerSetupVec) << "\n!!!!\n!!!!\n!!!!"; - - - { - // TEST: magnetic field - const auto& fld = trackerSetupVec.GetField(); - struct Node { - int iSt; - fvec x; - fvec y; - }; - - { - Node n{.iSt = 1, .x = 2.3, .y = 1.2}; - auto kfFldValue = fld.GetFieldValue(n.iSt, n.x, n.y); - auto caFldValue = fpParameters->GetStation(n.iSt).fieldSlice.GetFieldValue(n.x, n.y); - LOG(info) << "A: " << kfFldValue.ToString() << " --- " << caFldValue.ToString(); - } - { - Node n{.iSt = 2, .x = -2.1, .y = 2.2}; - auto kfFldValue = fld.GetFieldValue(n.iSt, n.x, n.y); - auto caFldValue = fpParameters->GetStation(n.iSt).fieldSlice.GetFieldValue(n.x, n.y); - LOG(info) << "B: " << kfFldValue.ToString() << " --- " << caFldValue.ToString(); - } - { - Node n{.iSt = 5, .x = -2.1, .y = 2.2}; - auto kfFldValue = fld.GetFieldValue(n.iSt, n.x, n.y); - auto caFldValue = fpParameters->GetStation(n.iSt).fieldSlice.GetFieldValue(n.x, n.y); - LOG(info) << "B: " << kfFldValue.ToString() << " --- " << caFldValue.ToString(); - } - - // TEST: field region building - { - using cbm::algo::kf::EFieldType; - fvec x = 1.2; - fvec y = 1.3; - fvec z0 = -32.; - fvec z1 = -28.; - fvec z2 = -24.; - auto kfFldVal_0 = fld.GetFieldValue(0, x, y); - auto kfFldVal_1 = fld.GetFieldValue(1, x, y); - auto kfFldVal_2 = fld.GetFieldValue(2, x, y); - auto kfFldReg = fld.GetFieldRegion(kfFldVal_0, z0, kfFldVal_1, z1, kfFldVal_2, z2); - auto caFldVal_0 = fpParameters->GetStation(0).fieldSlice.GetFieldValue(x, y); - auto caFldVal_1 = fpParameters->GetStation(1).fieldSlice.GetFieldValue(x, y); - auto caFldVal_2 = fpParameters->GetStation(2).fieldSlice.GetFieldValue(x, y); - auto caFldReg = cbm::algo::kf::FieldRegion<fvec>{}; - caFldReg.Set(caFldVal_0, z0, caFldVal_1, z1, caFldVal_2, z2); - LOG(info) << "CA ----> " << caFldReg.ToString(); - LOG(info) << "KF ----> " << kfFldReg.ToString(); - } - - // TEST: material maps - { - Node n{.iSt = 1, .x = 2.3, .y = 1.2}; - LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThicknessX0(n.x, n.y) << " -- " - << fpParameters->GetMaterialThickness(n.iSt, n.x, n.y); - } - { - Node n{.iSt = 1, .x = -2.3, .y = -1.2}; - LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThicknessX0(n.x, n.y) << " -- " - << fpParameters->GetMaterialThickness(n.iSt, n.x, n.y); - } - { - Node n{.iSt = 1, .x = 2.5, .y = 0.2}; - LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThicknessX0(n.x, n.y) << " -- " - << fpParameters->GetMaterialThickness(n.iSt, n.x, n.y); - } - { - Node n{.iSt = 4, .x = 5.3, .y = -2.2}; - LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThicknessX0(n.x, n.y) << " -- " - << fpParameters->GetMaterialThickness(n.iSt, n.x, n.y); - } - { - Node n{.iSt = 4, .x = 0, .y = -1.2}; - LOG(info) << trackerSetupVec.GetMaterial(n.iSt).GetThicknessX0(n.x, n.y) << " -- " - << fpParameters->GetMaterialThickness(n.iSt, n.x, n.y); - } - } } @@ -707,7 +640,8 @@ catch (const std::exception& err) { return kFATAL; } - +// --------------------------------------------------------------------------------------------------------------------- +// void CbmL1::Reconstruct(CbmEvent* event) { ca::TrackingMonitorData monitorData; diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index 8c88c7f4059a09746d75b2a8f64a49e6f7da750a..5c8c015c45d429c11c07439ff8726ae68f326489 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -475,6 +475,7 @@ class CbmL1 : public FairTask { /// Extension for IO of the L1Parameters object static constexpr std::string_view kSTAPParamSuffix = "ca.par"; + static constexpr std::string_view kSTAPSetupSuffix = "kf.setup"; /// Extension for IO of the ca::InputData object /// \note IO of the ca::InputData object is called inside every launch of CbmL1::ReadEvent function. Inside the function diff --git a/reco/kfnew/CbmKfTrackingSetupInitializer.cxx b/reco/kfnew/CbmKfTrackingSetupInitializer.cxx index bfb13b1c3f7f52baba7d35c0f4bda9e50812318b..f2cd0fe495d1ec34b94e22fb5946d1b76be492f6 100644 --- a/reco/kfnew/CbmKfTrackingSetupInitializer.cxx +++ b/reco/kfnew/CbmKfTrackingSetupInitializer.cxx @@ -57,9 +57,6 @@ try { return; } for (int iSt = 0; iSt < pIfs->GetNtrackingStations(); ++iSt) { - if (iSt == 1 && detID == ETrackingDetID::Mvd || iSt == 2 && detID == ETrackingDetID::Sts) { - continue; // !!!!!!!!!!!!! TEST - } fBuilder.AddLayer( GeoLayer<ETrackingDetID>{.fDetID = detID, // ca::Tracking detector id scheme .fLocID = iSt, // ca::Tracking station indexing diff --git a/reco/kfnew/CbmKfTrackingSetupInitializer.h b/reco/kfnew/CbmKfTrackingSetupInitializer.h index 73fc04f2a37385194ac46ff192b15c1b82d72cf9..66e5838d6b80204ba2891ab0620ce43e0578b35c 100644 --- a/reco/kfnew/CbmKfTrackingSetupInitializer.h +++ b/reco/kfnew/CbmKfTrackingSetupInitializer.h @@ -11,6 +11,7 @@ #include "KfSetupBuilder.h" +#include <mutex> #include <tuple> namespace cbm::kf @@ -71,4 +72,6 @@ namespace cbm::kf bool fbUseTrd{false}; ///< Are TRD stations included in the tracking setup bool fbUseTof{false}; ///< Are TOF stations included in the tracking setup }; + + } // namespace cbm::kf