diff --git a/algo/ca/TrackingChain.cxx b/algo/ca/TrackingChain.cxx index 50c8d9de1e5578012bfc9da0573048823221043b..8dfbbf258b8074a349494b06332796484b780936 100644 --- a/algo/ca/TrackingChain.cxx +++ b/algo/ca/TrackingChain.cxx @@ -265,7 +265,7 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi iStLocal = (extHitAddress >> 4) & 0xF; } if constexpr (IsTof) { - iStLocal = fpSetup->GetTrackingStation<DetID>(extHitAddress); + iStLocal = fpSetup->GetTrackingStation<ca::ToFlesSubsystem<DetID>()>(extHitAddress); } int iStActive = (iStLocal != -1) ? fCaFramework.GetParameters().GetStationIndexActive(iStLocal, DetID) : -1; @@ -279,7 +279,7 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi continue; } double lastTime = -1e9; - double prevTime = -1; + //double prevTime = -1; ca::HitKeyIndex_t firstHitKey = fNofHitKeys; for (size_t iPartHit = 0; iPartHit < vHits.size(); ++iPartHit) { const auto& hit = vHits[iPartHit]; @@ -348,7 +348,7 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi fCaMonitorData.IncrementCounter(ca::ECounter::UndefinedTofHit); } } - prevTime = caHit.T(); + //prevTime = caHit.T(); // ---- Update number of hit keys } // iPartHit } // iPartition diff --git a/algo/ca/TrackingDefs.h b/algo/ca/TrackingDefs.h index a20c95b9c45d64852f12ae5669cfba3407775263..e388167b8e0fb3711e61ffc82c698032e6af86c7 100644 --- a/algo/ca/TrackingDefs.h +++ b/algo/ca/TrackingDefs.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2023-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Sergei Zharko [committer] */ @@ -10,6 +10,7 @@ #pragma once #include "CaEnumArray.h" +#include "MicrosliceDescriptor.hpp" // For fles::Subsystem #include <tuple> @@ -52,6 +53,52 @@ namespace cbm::algo kEND ///< End of enumeration }; + template<fles::Subsystem subsys> + constexpr EDetectorID FromFlesSubsystem() + { + if constexpr (subsys == fles::Subsystem::STS) { + return EDetectorID::Sts; + } + else if constexpr (subsys == fles::Subsystem::MVD) { + return EDetectorID::Mvd; + } + else if constexpr (subsys == fles::Subsystem::MUCH) { + return EDetectorID::Much; + } + else if constexpr (subsys == fles::Subsystem::TRD) { + return EDetectorID::Trd; + } + if constexpr (subsys == fles::Subsystem::TOF) { + return EDetectorID::Tof; + } + else { + return EDetectorID::kEND; + } + } + + template<EDetectorID detID> + constexpr fles::Subsystem ToFlesSubsystem() + { + if constexpr (detID == EDetectorID::Mvd) { + return fles::Subsystem::MVD; + } + else if constexpr (detID == EDetectorID::Sts) { + return fles::Subsystem::STS; + } + else if constexpr (detID == EDetectorID::Much) { + return fles::Subsystem::MUCH; + } + else if constexpr (detID == EDetectorID::Trd) { + return fles::Subsystem::TRD; + } + else if constexpr (detID == EDetectorID::Tof) { + return fles::Subsystem::TOF; + } + else if constexpr (detID == EDetectorID::kEND) { + return fles::Subsystem::FLES; // Default () + } + } + /// \brief Alias to array, indexed by the EDetectorID enum /// \note To be used only in CBM-specific code template<typename T> diff --git a/algo/ca/TrackingSetup.cxx b/algo/ca/TrackingSetup.cxx index 168b93f23c7f81dade61b91d1d0d37da0680828e..32631da4883594bcaf8ec9754f33a36ecae1b59c 100644 --- a/algo/ca/TrackingSetup.cxx +++ b/algo/ca/TrackingSetup.cxx @@ -18,8 +18,8 @@ using fles::Subsystem; // void TrackingSetup::Init() { - if (Opts().Has(Subsystem::TOF)) { - fTof.SetContext(this->GetContext()); + if (fbUseTof) { + fTof.SetContext(this->GetContext()); // can be nullptr fTof.Init(); } } diff --git a/algo/ca/TrackingSetup.h b/algo/ca/TrackingSetup.h index 3e090dc0064a36c58938213e35a23e068471d588..c728191cc20ae83aca2f58d93749de0996b28ca1 100644 --- a/algo/ca/TrackingSetup.h +++ b/algo/ca/TrackingSetup.h @@ -10,7 +10,6 @@ #pragma once #include "SubChain.h" -#include "TrackingDefs.h" #include "tof/TrackingInterface.h" #include <type_traits> @@ -24,10 +23,10 @@ namespace cbm::algo class TrackingSetup : public SubChain { private: /// \brief A helper temporary function to enable a method for a given detector subsystem - template<ca::EDetectorID DetID> + template<fles::Subsystem DetID> static constexpr bool EnableDet() { - return DetID == ca::EDetectorID::Tof; + return DetID == fles::Subsystem::TOF; } public: @@ -46,20 +45,37 @@ namespace cbm::algo /// \brief Initializer function void Init(); + /// \brief Returns tracking station index by the TOF address /// \param address Unique address of a TOF element /// \return Local index of tracking station - template<ca::EDetectorID DetID, std::enable_if_t<EnableDet<DetID>(), bool> = true> + template<fles::Subsystem DetID, std::enable_if_t<EnableDet<DetID>(), bool> = true> int GetTrackingStation(uint32_t address) const { - if constexpr (DetID == ca::EDetectorID::Tof) { + if constexpr (DetID == fles::Subsystem::TOF) { return fTof.GetTrackingStation(address); } return -1; } + /// \brief Set detector subsystem usage + /// \param det Detector ID (fles::Subsystem) + /// \param flag (not) use the subsystem + void Use(fles::Subsystem det, bool flag = true) + { + using fles::Subsystem; + switch (det) { + case Subsystem::STS: break; + case Subsystem::MVD: break; + case Subsystem::MUCH: break; + case Subsystem::TRD: break; + case Subsystem::TOF: fbUseTof = flag; break; + default: break; + } + } private: tof::TrackingInterface fTof; ///< TOF tracking interface + bool fbUseTof = false; }; } // namespace cbm::algo diff --git a/algo/detectors/tof/TrackingInterface.cxx b/algo/detectors/tof/TrackingInterface.cxx index 87d65119d5f10640fa70fcf4022e4f755530b64c..7e98e648b1c9aa3273d6880cd7fc10f60926a890 100644 --- a/algo/detectors/tof/TrackingInterface.cxx +++ b/algo/detectors/tof/TrackingInterface.cxx @@ -21,23 +21,59 @@ using cbm::algo::tof::TrackingInterface; // void TrackingInterface::Init() { + L_(info) << "TOF: TrackingInterface initialization"; + // Read NbSm, NbRpc and tracking station ids from the config - auto setup = yaml::ReadFromFile<HitfindSetup>(Opts().ParamsDir() / "TofHitfinderPar.yaml"); - fvNofSm = std::move(setup.NbSm); - fvNofRpc = std::move(setup.NbRpc); - assert(fvNofSm.size() == fvNofRpc.size()); - int nSmTypes = fvNofSm.size(); - fvTrackingStationId.resize(nSmTypes); - for (int iSmType = 0; iSmType < nSmTypes; ++iSmType) { - int nSm = fvNofSm[iSmType]; - int nRpc = fvNofRpc[iSmType]; - auto& vStaIds = fvTrackingStationId[iSmType]; - auto& vRpcPars = setup.rpcs[iSmType]; - vStaIds.resize(nSm * nRpc); - for (int iSm = 0; iSm < nSm; ++iSm) { - for (int iRpc = 0; iRpc < nRpc; ++iRpc) { - int iGlobRpc = iSm * nRpc + iRpc; - vStaIds[iGlobRpc] = vRpcPars[iGlobRpc].trackingStationId; + if (!this->GetContext()) { // Default parameters for tests + L_(info) << "TOF: TrackingInterface: no context found, using default setup"; + // Par: tof_v21j_mcbm.digibdf.par + fvNofSm = {5, 0, 1, 0, 0, 1, 1, 1, 0, 1}; + fvNofRpc = {5, 3, 5, 1, 1, 1, 2, 2, 1, 2}; + fvTrackingStationId.resize(fvNofSm.size()); + fvTrackingStationId[0] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3}; + fvTrackingStationId[1] = {}; + fvTrackingStationId[2] = {2, 2, 2, 2, 2}; + fvTrackingStationId[3] = {}; + fvTrackingStationId[4] = {}; + fvTrackingStationId[5] = {0}; // BMON + fvTrackingStationId[6] = {1, 1}; + fvTrackingStationId[7] = {1, 1}; + fvTrackingStationId[8] = {}; + fvTrackingStationId[9] = {2, 2}; + } + else if (Opts().RunId() >= 2901) { // mcbm_beam_2024_03_22_gold + fvNofSm = {5, 0, 1, 0, 0, 1, 1, 0, 0, 2}; + fvNofRpc = {5, 3, 5, 1, 1, 1, 2, 2, 1, 2}; + fvTrackingStationId.resize(fvNofSm.size()); + fvTrackingStationId[0] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + fvTrackingStationId[1] = {}; + fvTrackingStationId[2] = {5, 5, 5, 5, 5}; + fvTrackingStationId[3] = {}; + fvTrackingStationId[4] = {}; + fvTrackingStationId[5] = {-1}; + fvTrackingStationId[6] = {1, 2}; + fvTrackingStationId[7] = {}; + fvTrackingStationId[8] = {}; + fvTrackingStationId[9] = {1, 2, 3, 4}; + } + else { + auto setup = yaml::ReadFromFile<HitfindSetup>(Opts().ParamsDir() / "TofHitfinderPar.yaml"); + fvNofSm = std::move(setup.NbSm); + fvNofRpc = std::move(setup.NbRpc); + assert(fvNofSm.size() == fvNofRpc.size()); + int nSmTypes = fvNofSm.size(); + fvTrackingStationId.resize(nSmTypes); + for (int iSmType = 0; iSmType < nSmTypes; ++iSmType) { + int nSm = fvNofSm[iSmType]; + int nRpc = fvNofRpc[iSmType]; + auto& vStaIds = fvTrackingStationId[iSmType]; + auto& vRpcPars = setup.rpcs[iSmType]; + vStaIds.resize(nSm * nRpc); + for (int iSm = 0; iSm < nSm; ++iSm) { + for (int iRpc = 0; iRpc < nRpc; ++iRpc) { + int iGlobRpc = iSm * nRpc + iRpc; + vStaIds[iGlobRpc] = vRpcPars[iGlobRpc].trackingStationId; + } } } } @@ -54,13 +90,13 @@ int TrackingInterface::GetTrackingStation(uint32_t address) const int iSm = CbmTofAddress::GetSmId(address); int iRpc = CbmTofAddress::GetRpcId(address); - if (iSmType < fvNofSm.size()) { + if (iSmType < int(fvNofSm.size())) { if (iSm < fvNofSm[iSmType] && iRpc < fvNofRpc[iSmType]) { return fvTrackingStationId[iSmType][iSm * fvNofRpc[iSmType] + iRpc]; } } - L_(error) << "Undefined RPC address " << fmt::format("{#x}", address) << " (iSmType = " << iSmType - << ", iSm = " << iSm << ", iRpc = " << iRpc << ')'; + L_(error) << "Undefined RPC address " << address << " (iSmType = " << iSmType << ", iSm = " << iSm + << ", iRpc = " << iRpc << ')'; return -1; // iSmType, iSm or iRpc are out of range } diff --git a/algo/evselector/DigiEventSelector.cxx b/algo/evselector/DigiEventSelector.cxx index a8626aac73a80008b0d191868ad7702ba3ed679b..bae8b3e2cf4be404206848facf74f594f0ea2c14 100644 --- a/algo/evselector/DigiEventSelector.cxx +++ b/algo/evselector/DigiEventSelector.cxx @@ -108,7 +108,7 @@ namespace cbm::algo::evbuild if (digi.GetSide() != strip->second) { // Found other end => full strip, insert into counter set const int32_t rpcAddr = CbmTofAddress::GetRpcFullId(digiAddr); if (rpcs.count(rpcAddr) == 0) { // new RPC activated - const int32_t TofStationId = fpTrackingSetup->GetTrackingStation<ca::EDetectorID::Tof>(digiAddr); + const int32_t TofStationId = fpTrackingSetup->GetTrackingStation<fles::Subsystem::TOF>(digiAddr); if (TofStationId < 0) { continue; } // unused tracking station (BMON) diff --git a/algo/global/Reco.cxx b/algo/global/Reco.cxx index 56865335c7ac901cb87312a5b569e0a45dc33d01..76900a35a046cd04cfa45e035d92e6f39767f773 100644 --- a/algo/global/Reco.cxx +++ b/algo/global/Reco.cxx @@ -155,6 +155,7 @@ void Reco::Init(const Options& opts) // --- Tracking setup auto pTrackingSetup = std::make_shared<TrackingSetup>(); pTrackingSetup->SetContext(&fContext); + pTrackingSetup->Use(Subsystem::TOF, Opts().Has(Subsystem::TOF)); pTrackingSetup->Init(); // --- Event building diff --git a/algo/test/_GTestDigiEventSelector.cxx b/algo/test/_GTestDigiEventSelector.cxx index ebe68eabde37569bb35aa3996c7dae40859fc7d7..c199ab5e1826d61fba4a5037ec3515a45fc31af7 100644 --- a/algo/test/_GTestDigiEventSelector.cxx +++ b/algo/test/_GTestDigiEventSelector.cxx @@ -4,6 +4,7 @@ #include "DigiEventSelector.h" #include "DigiEventSelectorConfig.h" +#include "MicrosliceDescriptor.hpp" #include "gtest/gtest-spi.h" #include "gtest/gtest.h" @@ -49,6 +50,11 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) for (size_t i = 0; i < nFsd; i++) event.fFsd.push_back(CbmFsdDigi()); + // Tracking setup + auto trackingSetup = std::make_shared<cbm::algo::TrackingSetup>(); + trackingSetup->Use(fles::Subsystem::TOF); // Init TOF withot a context + trackingSetup->Init(); + YAML::Node node; node["minDigis"][ToString(ECbmModuleId::kBmon)] = nBmon; @@ -65,6 +71,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) // --- Check with created numbers of digis - should pass cbm::algo::evbuild::DigiEventSelectorConfig config(node); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(event), true); } @@ -73,6 +80,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) node["minDigis"][ToString(ECbmModuleId::kBmon)] = nBmon + 1; cbm::algo::evbuild::DigiEventSelectorConfig config(node); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(event), false); } @@ -81,6 +89,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) node["minDigis"][ToString(ECbmModuleId::kSts)] = nSts + 1; cbm::algo::evbuild::DigiEventSelectorConfig config(node); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(event), false); } @@ -89,6 +98,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) node["minDigis"][ToString(ECbmModuleId::kMuch)] = nMuch + 1; cbm::algo::evbuild::DigiEventSelectorConfig config(node); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(event), false); } @@ -97,6 +107,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) node["minDigis"][ToString(ECbmModuleId::kRich)] = nRich + 1; cbm::algo::evbuild::DigiEventSelectorConfig config(node); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(event), false); } @@ -105,6 +116,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) node["minDigis"][ToString(ECbmModuleId::kTrd)] = nTrd + 1; cbm::algo::evbuild::DigiEventSelectorConfig config(node); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(event), false); } @@ -113,6 +125,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) node["minDigis"][ToString(ECbmModuleId::kTrd2d)] = nTrd2d + 1; cbm::algo::evbuild::DigiEventSelectorConfig config(node); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(event), false); } @@ -121,6 +134,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) node["minDigis"][ToString(ECbmModuleId::kTof)] = nTof + 1; cbm::algo::evbuild::DigiEventSelectorConfig config(node); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(event), false); } @@ -129,6 +143,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) node["minDigis"][ToString(ECbmModuleId::kPsd)] = nPsd + 1; cbm::algo::evbuild::DigiEventSelectorConfig config(node); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(event), false); } @@ -137,6 +152,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) node["minDigis"][ToString(ECbmModuleId::kFsd)] = nFsd + 1; cbm::algo::evbuild::DigiEventSelectorConfig config(node); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(event), false); } @@ -169,11 +185,12 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) } YAML::Node node2; - + //L_(info) << "tof min layers: " << numStations; { // Test correct number of stations - should pass node2["minLayers"][ToString(ECbmModuleId::kSts)] = numStations; cbm::algo::evbuild::DigiEventSelectorConfig config(node2); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(eventIn), true); } @@ -182,6 +199,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) node2["minLayers"][ToString(ECbmModuleId::kSts)] = numStations + 1; cbm::algo::evbuild::DigiEventSelectorConfig config(node2); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(eventIn), false); } } @@ -194,19 +212,19 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) DigiEvent eventIn; const uint8_t numSmTypes = 10; + const uint8_t numSm[numSmTypes] = {5, 0, 1, 0, 0, 1, 1, 1, 0, 1}; const uint8_t numRpc[numSmTypes] = {5, 3, 5, 1, 1, 1, 2, 2, 1, 2}; - const uint8_t numSm[numSmTypes] = {5, 0, 1, 0, 0, 1, 1, 1, 2, 1}; - std::vector<std::vector<uint8_t>> trkStationId = { + std::vector<std::vector<int>> trkStationId = { {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3}, - {0, 0, 0, 0, 0}, + {}, {2, 2, 2, 2, 2}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {1, 1, 0, 0, 0}, - {1, 1, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {2, 2, 2, 2, 0}}; + {}, + {}, + {0}, + {1, 1}, + {1, 1}, + {}, + {2, 2}}; std::unordered_set<int32_t> setTofStation; for (uint smType = 0; smType < numSmTypes; smType++) { @@ -232,6 +250,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) node2["minLayers"][ToString(ECbmModuleId::kTof)] = setTofStation.size(); cbm::algo::evbuild::DigiEventSelectorConfig config(node2); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(eventIn), true); } @@ -239,6 +258,7 @@ TEST(_GTestDigiEventSelector, CheckDigiEventSelectorAlgorithmSimple) node2["minLayers"][ToString(ECbmModuleId::kTof)] = setTofStation.size() + 1; cbm::algo::evbuild::DigiEventSelectorConfig config(node2); cbm::algo::evbuild::DigiEventSelector select(config); + select.RegisterTrackingSetup(trackingSetup); EXPECT_EQ(select(eventIn), false); } }