diff --git a/algo/CMakeLists.txt b/algo/CMakeLists.txt index f7c26cbbd1622700b77d404ccfca871a6acc8931..7992e1d36aa2f969fce915b7a9cdb518a0974bf7 100644 --- a/algo/CMakeLists.txt +++ b/algo/CMakeLists.txt @@ -100,6 +100,7 @@ set(SRCS detectors/sts/ReadoutConfig.cxx detectors/sts/ReadoutConfig_mCBM2022.cxx detectors/sts/HitfinderChain.cxx + detectors/sts/TrackingInterface.cxx detectors/sts/Unpack.cxx detectors/sts/UnpackMS.cxx detectors/sts/WalkMap.cxx @@ -133,6 +134,7 @@ set(SRCS detectors/trd/HitFinder.cxx detectors/trd/HitFinder2D.cxx detectors/trd/ReadoutConfig.cxx + detectors/trd/TrackingInterface.cxx detectors/trd/Unpack.cxx detectors/trd/UnpackMS.cxx detectors/trd2d/ReadoutConfig.cxx diff --git a/algo/ca/TrackingChain.cxx b/algo/ca/TrackingChain.cxx index c5213d0b85f5fd8c8035cd29f077ac5ffa747dea..b5899b3163f7363d3f86dbfcc816a0e681fc5dee 100644 --- a/algo/ca/TrackingChain.cxx +++ b/algo/ca/TrackingChain.cxx @@ -24,6 +24,7 @@ #include <fmt/format.h> #include <xpu/host.h> +#include <set> using namespace cbm::algo; @@ -152,12 +153,12 @@ void TrackingChain::PrepareInput(Input_t recoResults) if (fbDetUsed[EDetectorID::Sts]) { ReadHits<EDetectorID::Sts>(recoResults.stsHits); } - if (fbDetUsed[EDetectorID::Tof]) { - ReadHits<EDetectorID::Tof>(recoResults.tofHits); - } if (fbDetUsed[EDetectorID::Trd]) { ReadHits<EDetectorID::Trd>(recoResults.trdHits); } + if (fbDetUsed[EDetectorID::Tof]) { + ReadHits<EDetectorID::Tof>(recoResults.tofHits); + } faHitExternalIndices.shrink_to_fit(); fCaDataManager.SetNhitKeys(fNofHitKeys); L_(info) << "Tracking chain: " << fCaDataManager.GetNofHits() << " hits will be passed to the ca::Framework"; @@ -250,11 +251,6 @@ TrackingChain::Output_t TrackingChain::PrepareOutput() template<EDetectorID DetID> void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hits) { - //std::ofstream out; - //if constexpr (kDEBUG) { - // out.open(std::string("./Debug_hits_") + ca::kDetName[DetID] + ".txt"); - //} - int nSt = fCaFramework.GetParameters().GetNstationsActive(); using Hit_t = ca::HitTypes_t::at<DetID>; @@ -272,21 +268,13 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi const auto& [vHits, extHitAddress] = hits.Partition(iPartition); // ---- Define data stream and station index //int64_t dataStream = dataStreamDet | extHitAddress; - int iStLocal = -1; - // FIXME: This definition of the station index works only for STS, and there is no any guaranty, that it will - // work for other mCBM setups. - if constexpr (IsSts) { - iStLocal = (extHitAddress >> 4) & 0xF; - } - if constexpr (IsTof) { - iStLocal = fpSetup->GetTrackingStation<ca::ToFlesSubsystem<DetID>()>(extHitAddress); - } - if constexpr (IsTrd) { - // TODO: is TRD Layer == station? - iStLocal = CbmTrdAddress::GetLayerId(extHitAddress); + int iStLocal = fpSetup->GetTrackingStation<ca::ToFlesSubsystem<DetID>()>(extHitAddress); + if (iStLocal < 0) { + continue; // Station is not used for tracking (e.g. TOF SMtype 5) } - int iStActive = (iStLocal != -1) ? fCaFramework.GetParameters().GetStationIndexActive(iStLocal, DetID) : -1; + int iStActive = fCaFramework.GetParameters().GetStationIndexActive(iStLocal, DetID); + //size_t iOffset = hits.Offsets()[iPartition]; if (iStActive < 0) { continue; // legit @@ -301,6 +289,28 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi ca::HitKeyIndex_t firstHitKey = fNofHitKeys; for (size_t iPartHit = 0; iPartHit < vHits.size(); ++iPartHit) { const auto& hit = vHits[iPartHit]; + + //if constexpr (IsTrd) { + // switch (extHitAddress) { + // case 0x5: + // if (!(fabs(hit.Z() - 116.77) < 10)) { + // L_(info) << "AAAAAA!!!!!!!!! " << extHitAddress << ' ' << hit.Z(); + // } + // break; + // case 0x15: + // if (!(fabs(hit.Z() - 163.8) < 10)) { + // L_(info) << "AAAAAA!!!!!!!!! " << extHitAddress << ' ' << hit.Z(); + // } + // break; + // case 0x25: + // if (!(fabs(hit.Z() - 190.8) < 10)) { + // L_(info) << "AAAAAA!!!!!!!!! " << extHitAddress << ' ' << hit.Z(); + // } + // break; + // } + //} + + //int iHitExt = iOffset + iPartHit; // ---- Fill ca::Hit ca::Hit caHit; @@ -322,6 +332,7 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi if constexpr (IsSts) caHit.SetDxy(hit.fDxy); caHit.SetDt2(hit.TimeError() * hit.TimeError() + fCaFramework.GetParameters().GetMisalignmentTsq(DetID)); /// FIXME: Define ranges from the hit, when will be available + //out << iStLocal << " " << extHitAddress << " " << hit.Z() << '\n'; caHit.SetRangeX(3.5 * hit.Dx()); caHit.SetRangeY(3.5 * hit.Dy()); caHit.SetRangeT(3.5 * hit.TimeError()); @@ -338,7 +349,6 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi caHit.SetRangeX(sqrt(3.) * hit.Dx()); } } - //L_(info) << ">>>>>>>>>>>> " << iStActive; caHit.SetStation(iStActive); caHit.SetId(fCaDataManager.GetNofHits()); if (caHit.Check()) { @@ -348,13 +358,6 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi lastTime = caHit.T(); fCaDataManager.PushBackHit(caHit, dataStreamDet | dataStream); faHitExternalIndices.push_back(std::make_tuple(DetID, iPartition, iPartHit)); - //if constexpr (kDEBUG) { - // out << (dataStreamDet | dataStream) << " ----- " << caHit.ToString() << '\n'; - // if (prevTime > caHit.T()) { - // out << "TIME IS UNSORTED\n"; - // } - //} - if (fNofHitKeys <= caHit.FrontKey()) { fNofHitKeys = caHit.FrontKey() + 1; } @@ -384,5 +387,3 @@ void TrackingChain::ReadHits(PartitionedSpan<const ca::HitTypes_t::at<DetID>> hi } // iPartHit } // iPartition } - -// template void TrackingChain::ReadHits<EDetectorID::Sts>(const PartitionedPODVector<HitTypes_t::at<EDetectorID::Sts>>&); diff --git a/algo/ca/TrackingSetup.cxx b/algo/ca/TrackingSetup.cxx index 32631da4883594bcaf8ec9754f33a36ecae1b59c..109390a1f2b1b31c9e600fe2d7c05d1c6b5334f5 100644 --- a/algo/ca/TrackingSetup.cxx +++ b/algo/ca/TrackingSetup.cxx @@ -18,6 +18,14 @@ using fles::Subsystem; // void TrackingSetup::Init() { + if (fbUseSts) { + fSts.SetContext(this->GetContext()); + fSts.Init(); + } + if (fbUseTrd) { + fTrd.SetContext(this->GetContext()); + fTrd.Init(); + } if (fbUseTof) { fTof.SetContext(this->GetContext()); // can be nullptr fTof.Init(); diff --git a/algo/ca/TrackingSetup.h b/algo/ca/TrackingSetup.h index c728191cc20ae83aca2f58d93749de0996b28ca1..a5f9abf75d7bb7e582c42ec78745f1676e420b04 100644 --- a/algo/ca/TrackingSetup.h +++ b/algo/ca/TrackingSetup.h @@ -10,7 +10,9 @@ #pragma once #include "SubChain.h" +#include "sts/TrackingInterface.h" #include "tof/TrackingInterface.h" +#include "trd/TrackingInterface.h" #include <type_traits> @@ -21,14 +23,6 @@ namespace cbm::algo /// \class TrackingSetup /// \brief A detector setup interface class for tracking input data initialization class TrackingSetup : public SubChain { - private: - /// \brief A helper temporary function to enable a method for a given detector subsystem - template<fles::Subsystem DetID> - static constexpr bool EnableDet() - { - return DetID == fles::Subsystem::TOF; - } - public: /// \brief Default constructor TrackingSetup() = default; @@ -45,17 +39,22 @@ 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 + /// \brief Returns tracking station index by the detector element address + /// \param address Unique address of an element /// \return Local index of tracking station - template<fles::Subsystem DetID, std::enable_if_t<EnableDet<DetID>(), bool> = true> + template<fles::Subsystem DetID> int GetTrackingStation(uint32_t address) const { - if constexpr (DetID == fles::Subsystem::TOF) { + if constexpr (DetID == fles::Subsystem::STS) { + return fSts.GetTrackingStation(address); + } + else if constexpr (DetID == fles::Subsystem::TRD) { + return fTrd.GetTrackingStation(address); + } + else if constexpr (DetID == fles::Subsystem::TOF) { return fTof.GetTrackingStation(address); } - return -1; + return -1; // Default: no station is assigned, hit will be skept ! } /// \brief Set detector subsystem usage @@ -65,17 +64,21 @@ namespace cbm::algo { using fles::Subsystem; switch (det) { - case Subsystem::STS: break; + case Subsystem::STS: fbUseSts = flag; break; case Subsystem::MVD: break; case Subsystem::MUCH: break; - case Subsystem::TRD: break; + case Subsystem::TRD: fbUseTrd = flag; break; case Subsystem::TOF: fbUseTof = flag; break; default: break; } } private: + sts::TrackingInterface fSts; ///< STS tracking interface + trd::TrackingInterface fTrd; ///< TRD tracking interface tof::TrackingInterface fTof; ///< TOF tracking interface + bool fbUseSts = false; + bool fbUseTrd = false; bool fbUseTof = false; }; } // namespace cbm::algo diff --git a/algo/ca/qa/CaInputQa.cxx b/algo/ca/qa/CaInputQa.cxx index dc50101d0f863db301b020d4112562d1fbb364c1..b0c40e0489a0c2b920bdc68110e1508bc0becea8 100644 --- a/algo/ca/qa/CaInputQa.cxx +++ b/algo/ca/qa/CaInputQa.cxx @@ -15,6 +15,7 @@ #include "TrackingDefs.h" #include <algorithm> +#include <fstream> #include <limits> #include <fmt/format.h> diff --git a/algo/detectors/sts/TrackingInterface.cxx b/algo/detectors/sts/TrackingInterface.cxx new file mode 100644 index 0000000000000000000000000000000000000000..fa667fdecf5c88d789b2609b7cbfc295ae00c274 --- /dev/null +++ b/algo/detectors/sts/TrackingInterface.cxx @@ -0,0 +1,32 @@ +/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file TrackingInterface.cxx +/// \date 19.04.2024 +/// \brief A TOF-parameter and geometry interface used for tracking input data initialization (source) +/// \author Sergei Zharko <s.zharko@gsi.de> + +#include "TrackingInterface.h" + +#include "CbmStsAddress.h" +#include "log.hpp" + +using cbm::algo::sts::TrackingInterface; + +// --------------------------------------------------------------------------------------------------------------------- +// +void TrackingInterface::Init() +{ + L_(info) << "STS: TrackingInterface initialization"; +} + +// --------------------------------------------------------------------------------------------------------------------- +// +int TrackingInterface::GetTrackingStation(uint32_t address) const +{ + // NOTE: SZh 30.04.2024: + // This returns the valid STS station index at least for mCBM at beamtimes 2022 and 2024. There is no + // guarantie, that it will work for other setups, should be cross-checked. + return CbmStsAddress::GetElementId(address, kStsUnit); +} diff --git a/algo/detectors/sts/TrackingInterface.h b/algo/detectors/sts/TrackingInterface.h new file mode 100644 index 0000000000000000000000000000000000000000..a037cd2fbc567d03b4d43e42c45bef0291e72dcc --- /dev/null +++ b/algo/detectors/sts/TrackingInterface.h @@ -0,0 +1,38 @@ +/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file TrackingInterface.h +/// \date 30.04.2024 +/// \brief A STS-parameter and geometry interface used for tracking input data initialization (header) +/// \author Sergei Zharko <s.zharko@gsi.de> + +#pragma once + +#include "SubChain.h" + +namespace cbm::algo::sts +{ + class TrackingInterface : public SubChain { + public: + /// \brief Default constructor + TrackingInterface() = default; + + /// \brief Copy constructor + TrackingInterface(const TrackingInterface&) = delete; + + /// \brief Move constructor + TrackingInterface(TrackingInterface&&) = delete; + + /// \brief Destructor + ~TrackingInterface() = default; + + /// \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 + int GetTrackingStation(uint32_t address) const; + }; +} // namespace cbm::algo::tof diff --git a/algo/detectors/trd/TrackingInterface.cxx b/algo/detectors/trd/TrackingInterface.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7ad681daa4cf197807ea0b41294a7e383b3dcb4a --- /dev/null +++ b/algo/detectors/trd/TrackingInterface.cxx @@ -0,0 +1,29 @@ +/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file TrackingInterface.cxx +/// \date 30.04.2024 +/// \brief A TRD-parameter and geometry interface used for tracking input data initialization (source) +/// \author Sergei Zharko <s.zharko@gsi.de> + +#include "TrackingInterface.h" + +#include "CbmTrdAddress.h" +#include "log.hpp" + +using cbm::algo::trd::TrackingInterface; + +// --------------------------------------------------------------------------------------------------------------------- +// +void TrackingInterface::Init() +{ + L_(info) << "TRD: TrackingInterface initialization"; +} + +// --------------------------------------------------------------------------------------------------------------------- +// +int TrackingInterface::GetTrackingStation(uint32_t address) const +{ + return CbmTrdAddress::GetLayerId(address); +} diff --git a/algo/detectors/trd/TrackingInterface.h b/algo/detectors/trd/TrackingInterface.h new file mode 100644 index 0000000000000000000000000000000000000000..16eedf721d408d015914503a0f6a8ccb04804233 --- /dev/null +++ b/algo/detectors/trd/TrackingInterface.h @@ -0,0 +1,38 @@ +/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file TrackingInterface.h +/// \date 30.04.2024 +/// \brief A TRD-parameter and geometry interface used for tracking input data initialization (header) +/// \author Sergei Zharko <s.zharko@gsi.de> + +#pragma once + +#include "SubChain.h" + +namespace cbm::algo::trd +{ + class TrackingInterface : public SubChain { + public: + /// \brief Default constructor + TrackingInterface() = default; + + /// \brief Copy constructor + TrackingInterface(const TrackingInterface&) = delete; + + /// \brief Move constructor + TrackingInterface(TrackingInterface&&) = delete; + + /// \brief Destructor + ~TrackingInterface() = default; + + /// \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 + int GetTrackingStation(uint32_t address) const; + }; +} // namespace cbm::algo::tof diff --git a/algo/global/Reco.cxx b/algo/global/Reco.cxx index 6eabeac03e0fc40be2411cf6a98c9bb340be601b..3d5d594361c26e73a8ba81b52daf31ab08741e6d 100644 --- a/algo/global/Reco.cxx +++ b/algo/global/Reco.cxx @@ -153,6 +153,8 @@ void Reco::Init(const Options& opts) // --- Tracking setup auto pTrackingSetup = std::make_shared<TrackingSetup>(); pTrackingSetup->SetContext(&fContext); + pTrackingSetup->Use(Subsystem::STS, Opts().Has(Subsystem::STS)); + pTrackingSetup->Use(Subsystem::TRD, Opts().Has(Subsystem::TRD)); pTrackingSetup->Use(Subsystem::TOF, Opts().Has(Subsystem::TOF)); pTrackingSetup->Init(); diff --git a/macro/beamtime/CMakeLists.txt b/macro/beamtime/CMakeLists.txt index fac2f19e4243a6efe83dd7d6802c1c4e929a81fa..6f5c5649214f13359a95e3c588e19c35ddef21c6 100644 --- a/macro/beamtime/CMakeLists.txt +++ b/macro/beamtime/CMakeLists.txt @@ -3,6 +3,8 @@ add_subdirectory(mcbm2021) # mCBM 2022: install parameter files + macro + online scripts to allow execution of unpacking on mFLES add_subdirectory(mcbm2022) +# mCBM 2024: install parameter files +add_subdirectory(mcbm2024) ################################################################################ #--- Deprecated (not running)