From 5615db6fa240565d118f5001722731bdb1b80c93 Mon Sep 17 00:00:00 2001 From: "s.zharko@gsi.de" <s.zharko@gsi.de> Date: Mon, 28 Aug 2023 09:10:22 +0200 Subject: [PATCH] CA: detectorID-dependent array types are moved to the cbm::ca namespace --- reco/L1/CbmCaMCModule.cxx | 2 +- reco/L1/CbmCaMCModule.h | 6 ++-- reco/L1/CbmCaTimeSliceReader.h | 12 ++++---- reco/L1/CbmL1.h | 2 +- reco/L1/CbmL1DetectorID.h | 44 ++++++++++++++------------- reco/L1/utils/CbmCaIdealHitProducer.h | 2 +- 6 files changed, 35 insertions(+), 33 deletions(-) diff --git a/reco/L1/CbmCaMCModule.cxx b/reco/L1/CbmCaMCModule.cxx index 2e65dc8449..25632feb4c 100644 --- a/reco/L1/CbmCaMCModule.cxx +++ b/reco/L1/CbmCaMCModule.cxx @@ -407,7 +407,7 @@ void MCModule::ReadMCPoints() int nPointsEstimated = 5 * fpMCData->GetNofTracks() * fpParameters->GetNstationsActive(); fpMCData->ReserveNofPoints(nPointsEstimated); - CbmCaDetIdArr_t<int> vNofPointsDet = {0}; + DetIdArr_t<int> vNofPointsDet = {0}; for (const auto& [iFile, iEvent] : fFileEventIDs) { for (int iD = 0; iD < static_cast<int>(vNofPointsDet.size()); ++iD) { if (fvbUseDet[iD]) { vNofPointsDet[iD] = fvpBrPoints[iD]->Size(iFile, iEvent); } diff --git a/reco/L1/CbmCaMCModule.h b/reco/L1/CbmCaMCModule.h index e51f7ed6ef..d02e0339cf 100644 --- a/reco/L1/CbmCaMCModule.h +++ b/reco/L1/CbmCaMCModule.h @@ -221,7 +221,7 @@ namespace cbm::ca ::ca::Monitor<EMonitorKey> fMonitor {"CA MC Module"}; ///< Monitor // ------ Flags - CbmCaDetIdArr_t<bool> fvbUseDet = {{false}}; ///< Flag: is detector subsystem used + DetIdArr_t<bool> fvbUseDet = {{false}}; ///< Flag: is detector subsystem used bool fbLegacyEventMode = false; ///< if tracking uses events instead of time-slices (back compatibility) int fVerbose = 0; ///< Verbosity level int fPerformanceMode = -1; ///< Mode of performance @@ -233,8 +233,8 @@ namespace cbm::ca CbmMCDataObject* fpMCEventHeader = nullptr; ///< MC event header CbmMCDataArray* fpMCTracks = nullptr; ///< MC tracks input - CbmCaDetIdArr_t<CbmMCDataArray*> fvpBrPoints = {{nullptr}}; ///< Array of points vs. detector - CbmCaDetIdArr_t<TClonesArray*> fvpBrHitMatches = {{nullptr}}; ///< Array of hit match branches vs. detector + DetIdArr_t<CbmMCDataArray*> fvpBrPoints = {{nullptr}}; ///< Array of points vs. detector + DetIdArr_t<TClonesArray*> fvpBrHitMatches = {{nullptr}}; ///< Array of hit match branches vs. detector // Matching information std::set<std::pair<int, int>> fFileEventIDs; ///< Set of file and event indexes: first - iFile, second - iEvent diff --git a/reco/L1/CbmCaTimeSliceReader.h b/reco/L1/CbmCaTimeSliceReader.h index 06c2c374db..81eb53e4c2 100644 --- a/reco/L1/CbmCaTimeSliceReader.h +++ b/reco/L1/CbmCaTimeSliceReader.h @@ -163,11 +163,11 @@ namespace cbm::ca bool fbReadTracks = true; ///< flag to read reconstructed tracks from reco.root /// @brief Pointers to the tracking detector interfaces for each subsystem - CbmCaDetIdArr_t<const CbmTrackingDetectorInterfaceBase*> fvpDetInterface = {{nullptr}}; + DetIdArr_t<const CbmTrackingDetectorInterfaceBase*> fvpDetInterface = {{nullptr}}; // Input data branches CbmTimeSlice* fpBrTimeSlice = nullptr; ///< Pointer to the TS object - CbmCaDetIdArr_t<TClonesArray*> fvpBrHits = {{nullptr}}; ///< Input branch for hits + DetIdArr_t<TClonesArray*> fvpBrHits = {{nullptr}}; ///< Input branch for hits // Branches for reconstructed tracks. The input at the moment (as for 27.02.2023) depends on the selected // tracking mode. For simulations in CBM, the CA tracking is used only in STS + MVD detectors. In this case @@ -187,11 +187,11 @@ namespace cbm::ca std::shared_ptr<L1Parameters> fpParameters = nullptr; ///< Pointer to tracking parameters object // Maps of hit indexes: ext -> int - CbmCaDetIdArr_t<L1Vector<int>> fvvHitExtToIntIndexMap; ///< Hit index map ext -> int + DetIdArr_t<L1Vector<int>> fvvHitExtToIntIndexMap; ///< Hit index map ext -> int - CbmCaDetIdArr_t<int> fvNofHitsTotal = {{0}}; ///< Total hit number in detector - CbmCaDetIdArr_t<int> fvNofHitsUsed = {{0}}; ///< Number of used hits in detector - CbmCaDetIdArr_t<bool> fvbUseDet = {{false}}; ///< Flag: is detector subsystem used + DetIdArr_t<int> fvNofHitsTotal = {{0}}; ///< Total hit number in detector + DetIdArr_t<int> fvNofHitsUsed = {{0}}; ///< Number of used hits in detector + DetIdArr_t<bool> fvbUseDet = {{false}}; ///< Flag: is detector subsystem used ECbmCaTrackingMode fTrackingMode = ECbmCaTrackingMode::kSTS; ///< Tracking mode diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index 82358e36ef..ce0b0b4f4d 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -645,7 +645,7 @@ private: std::unordered_map<CbmL1LinkKey, int> fmMCPointsLinksMap = {}; /// Internal MC point index vs. link std::unordered_map<CbmL1LinkKey, int> fmMCTracksLinksMap = {}; /// Internal MC track index vs. link - CbmCaDetIdArr_t<std::set<int>> fvmDisabledStationIDs; /// Array of local indices of disabled tracking stations + cbm::ca::DetIdArr_t<std::set<int>> fvmDisabledStationIDs; /// Array of local indices of disabled tracking stations // ***************************** // ** Tracking performance QA ** diff --git a/reco/L1/CbmL1DetectorID.h b/reco/L1/CbmL1DetectorID.h index 7378892418..7c21822acf 100644 --- a/reco/L1/CbmL1DetectorID.h +++ b/reco/L1/CbmL1DetectorID.h @@ -30,24 +30,6 @@ enum class L1DetectorID kEND ///< End of enumeration }; -/// @brief Alias to array, indexed by L1DetectorID enum -/// @note To be used only in CBM-specific code -template<typename T> -using CbmCaDetIdArr_t = L1EArray<L1DetectorID, T>; - -/// @brief Array of types, indexed by L1DetectorID enum -/// -/// The array of types allows to treat different types of detector in a uniform manner -/// Example: -/// using HitTypes_t = CbmCaDetIdTypeArr_t<CbmMvdHit, CbmStsHit, CbmMuchPixelHit, CbmTrdHit, CbmTofHit>; -/// ... -/// HitTypes_t::at<L1DetectorID::kSts> hit; // Sts hit -template<class... Types> -struct CbmCaDetIdTypeArr_t { - template<L1DetectorID DetID> - using at = std::tuple_element_t<static_cast<std::size_t>(DetID), std::tuple<Types...>>; - static constexpr std::size_t size = sizeof...(Types); -}; /// ************************************************* /// ** Detector-dependent common definitions ** @@ -67,16 +49,36 @@ class CbmTofHit; namespace cbm::ca { + /// @brief Alias to array, indexed by L1DetectorID enum + /// @note To be used only in CBM-specific code + template<typename T> + using DetIdArr_t = L1EArray<L1DetectorID, T>; + + /// @struct DetIdTypeArr_t + /// @brief Array of types, indexed by L1DetectorID enum + /// + /// The array of types allows to treat different types of detector in a uniform manner + /// Example: + /// using HitTypes_t = DetIdTypeArr_t<CbmMvdHit, CbmStsHit, CbmMuchPixelHit, CbmTrdHit, CbmTofHit>; + /// ... + /// HitTypes_t::at<L1DetectorID::kSts> hit; // Sts hit + template<class... Types> + struct DetIdTypeArr_t { + template<L1DetectorID DetID> + using at = std::tuple_element_t<static_cast<std::size_t>(DetID), std::tuple<Types...>>; + static constexpr std::size_t size = sizeof...(Types); + }; + /// @brief Names of detector subsystems /// @note These names are used for data branches IO, thus any modification can lead to the /// read-out corruption. - constexpr CbmCaDetIdArr_t<const char*> kDetName = {{"MVD", "STS", "MUCH", "TRD", "TOF"}}; + constexpr DetIdArr_t<const char*> kDetName = {{"MVD", "STS", "MUCH", "TRD", "TOF"}}; /// @brief Types of MC point objects for each detector - using PointTypes_t = CbmCaDetIdTypeArr_t<CbmMvdPoint, CbmStsPoint, CbmMuchPoint, CbmTrdPoint, CbmTofPoint>; + using PointTypes_t = DetIdTypeArr_t<CbmMvdPoint, CbmStsPoint, CbmMuchPoint, CbmTrdPoint, CbmTofPoint>; /// @brief Types of hit objects for each detector - using HitTypes_t = CbmCaDetIdTypeArr_t<CbmMvdHit, CbmStsHit, CbmMuchPixelHit, CbmTrdHit, CbmTofHit>; + using HitTypes_t = DetIdTypeArr_t<CbmMvdHit, CbmStsHit, CbmMuchPixelHit, CbmTrdHit, CbmTofHit>; } // namespace cbm::ca diff --git a/reco/L1/utils/CbmCaIdealHitProducer.h b/reco/L1/utils/CbmCaIdealHitProducer.h index 0b5e175317..ee11f309d2 100644 --- a/reco/L1/utils/CbmCaIdealHitProducer.h +++ b/reco/L1/utils/CbmCaIdealHitProducer.h @@ -64,7 +64,7 @@ namespace cbm::ca IdealHitProducerDet<L1DetectorID::kTrd> fHitProducerTrd; ///< Instance of hit producer for TRD IdealHitProducerDet<L1DetectorID::kTof> fHitProducerTof; ///< Instance of hit producer for TOF - CbmCaDetIdArr_t<bool> fbUseDet = {{false}}; ///< Usage flag of different detectors + DetIdArr_t<bool> fbUseDet = {{false}}; ///< Usage flag of different detectors }; } // namespace cbm::ca -- GitLab