From c9ea1cb0d77c6f86b95ce8dc34ece4f095c48b5f Mon Sep 17 00:00:00 2001 From: "s.zharko@gsi.de" <s.zharko@gsi.de> Date: Sun, 8 Oct 2023 14:51:12 +0200 Subject: [PATCH] CA: move parameter and init manager to the libCaCore --- algo/ca/core/CMakeLists.txt | 19 +- .../ca/core/pars/CaConfigReader.cxx | 57 +-- algo/ca/core/pars/CaConfigReader.h | 104 +++++ .../ca/core/pars/CaInitManager.cxx | 205 +++++---- algo/ca/core/pars/CaInitManager.h | 308 ++++++++++++++ algo/ca/core/pars/CaParameters.cxx | 7 +- algo/ca/core/pars/CaParameters.h | 25 +- algo/ca/core/pars/CaStationInitializer.cxx | 366 ++++++++++++++++ algo/ca/core/pars/CaStationInitializer.h | 220 ++++++++++ algo/ca/core/utils/CaUtils.h | 10 + algo/log/AlgoFairloggerCompat.h | 1 - macro/mcbm/mcbm_qa.C | 8 +- reco/KF/ParticleFitter/CbmL1PFFitter.cxx | 11 +- reco/L1/CMakeLists.txt | 3 - reco/L1/CbmCaMCModule.cxx | 80 ++-- reco/L1/CbmCaMCModule.h | 40 +- reco/L1/CbmCaTimeSliceReader.cxx | 84 ++-- reco/L1/CbmCaTimeSliceReader.h | 20 +- reco/L1/CbmL1.cxx | 77 ++-- reco/L1/CbmL1.h | 38 +- reco/L1/CbmL1DetectorID.h | 35 +- reco/L1/CbmL1ReadEvent.cxx | 56 +-- reco/L1/L1Algo/L1Algo.cxx | 3 +- reco/L1/L1Algo/L1BaseStationInfo.cxx | 401 ------------------ reco/L1/L1Algo/L1BaseStationInfo.h | 234 ---------- reco/L1/L1Algo/L1ConfigRW.h | 97 ----- reco/L1/L1Algo/L1InitManager.h | 361 ---------------- reco/L1/L1LinkDef.h | 2 +- reco/L1/catools/CaToolsMCData.h | 23 +- reco/L1/catools/CaToolsMCPoint.h | 11 +- reco/L1/catools/CaToolsWindowFinder.cxx | 5 +- reco/L1/qa/CbmCaInputQaBase.cxx | 42 +- reco/L1/qa/CbmCaInputQaBase.h | 6 +- reco/L1/qa/CbmCaInputQaMuch.h | 2 +- reco/L1/qa/CbmCaInputQaMvd.h | 2 +- reco/L1/qa/CbmCaInputQaSetup.cxx | 60 +-- reco/L1/qa/CbmCaInputQaSetup.h | 82 ++-- reco/L1/qa/CbmCaInputQaSts.h | 2 +- reco/L1/qa/CbmCaInputQaTof.h | 2 +- reco/L1/qa/CbmCaInputQaTrd.h | 2 +- reco/L1/qa/CbmCaOutputQa.cxx | 32 +- reco/L1/utils/CbmCaIdealHitProducer.cxx | 30 +- reco/L1/utils/CbmCaIdealHitProducer.h | 10 +- reco/L1/utils/CbmCaIdealHitProducerDet.h | 70 +-- 44 files changed, 1603 insertions(+), 1650 deletions(-) rename reco/L1/L1Algo/L1ConfigRW.cxx => algo/ca/core/pars/CaConfigReader.cxx (89%) create mode 100644 algo/ca/core/pars/CaConfigReader.h rename reco/L1/L1Algo/L1InitManager.cxx => algo/ca/core/pars/CaInitManager.cxx (69%) create mode 100644 algo/ca/core/pars/CaInitManager.h create mode 100644 algo/ca/core/pars/CaStationInitializer.cxx create mode 100644 algo/ca/core/pars/CaStationInitializer.h delete mode 100644 reco/L1/L1Algo/L1BaseStationInfo.cxx delete mode 100644 reco/L1/L1Algo/L1BaseStationInfo.h delete mode 100644 reco/L1/L1Algo/L1ConfigRW.h delete mode 100644 reco/L1/L1Algo/L1InitManager.h diff --git a/algo/ca/core/CMakeLists.txt b/algo/ca/core/CMakeLists.txt index ec9048169b..c149823141 100644 --- a/algo/ca/core/CMakeLists.txt +++ b/algo/ca/core/CMakeLists.txt @@ -6,14 +6,17 @@ set(INCLUDE_DIRECTORIES ) set(SRCS - ${CMAKE_CURRENT_SOURCE_DIR}/data/CaTrackParam.cxx ${CMAKE_CURRENT_SOURCE_DIR}/data/CaTrack.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/data/CaTrackParam.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaConfigReader.cxx ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaField.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaMaterialMap.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaStation.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaInitManager.cxx ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaIteration.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaMaterialMap.cxx ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaParameters.cxx ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaSearchWindow.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaStation.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaStationInitializer.cxx ) add_library(CaCore SHARED ${SRCS}) @@ -32,6 +35,7 @@ target_link_libraries(CaCore OnlineDataLog # needed for the logger external::fles_logging # needed for the logger external::fles_ipc # needed for the logger + external::yaml-cpp ) install(TARGETS CaCore DESTINATION lib) @@ -44,13 +48,16 @@ install( data/CaTrackParam.h data/CaTrack.h data/CaHit.h - pars/CaField.h - pars/CaMaterialMap.h - pars/CaStation.h + pars/CaConfigReader.h pars/CaConstants.h + pars/CaField.h + pars/CaInitManager.h pars/CaIteration.h + pars/CaMaterialMap.h pars/CaParameters.h pars/CaSearchWindow.h + pars/CaStation.h + pars/CaStationInitializer.h utils/CaEnumArray.h utils/CaMonitor.h utils/CaSimd.h diff --git a/reco/L1/L1Algo/L1ConfigRW.cxx b/algo/ca/core/pars/CaConfigReader.cxx similarity index 89% rename from reco/L1/L1Algo/L1ConfigRW.cxx rename to algo/ca/core/pars/CaConfigReader.cxx index 4d9cee0c86..a2bde49621 100644 --- a/reco/L1/L1Algo/L1ConfigRW.cxx +++ b/algo/ca/core/pars/CaConfigReader.cxx @@ -1,13 +1,13 @@ -/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Sergei Zharko [committer] */ -/// @file L1ConfigRW.h -/// @brief Configuration parameter file reader/writer for L1 tracking algorithm (implementation) -/// @author S.Zharko <s.zharko@gsi.de> -/// @since 18.07.2022 +/// \file ConfigReader.h +/// \brief Configuration parameter file reader/writer for L1 tracking algorithm (implementation) +/// \author S.Zharko <s.zharko@gsi.de> +/// \since 18.07.2022 -#include "L1ConfigRW.h" +#include "CaConfigReader.h" #include <boost/algorithm/string.hpp> @@ -19,17 +19,21 @@ #include <yaml-cpp/yaml.h> #include "CaConstants.h" -#include "L1InitManager.h" +#include "CaInitManager.h" + using namespace std::string_literals; +using cbm::algo::ca::ConfigReader; +using cbm::algo::ca::EDetectorID; +using cbm::algo::ca::InitManager; // --------------------------------------------------------------------------------------------------------------------- // -L1ConfigRW::L1ConfigRW(L1InitManager* pInitManager, int verbose) : fpInitManager(pInitManager), fVerbose(verbose) {} +ConfigReader::ConfigReader(InitManager* pInitManager, int verbose) : fpInitManager(pInitManager), fVerbose(verbose) {} // --------------------------------------------------------------------------------------------------------------------- // -YAML::Node L1ConfigRW::GetNode(std::function<YAML::Node(YAML::Node)> fn) const +YAML::Node ConfigReader::GetNode(std::function<YAML::Node(YAML::Node)> fn) const { auto node = YAML::Node(YAML::NodeType::Undefined); if (fUserConfigNode) { node = fn(fUserConfigNode); } @@ -46,7 +50,7 @@ YAML::Node L1ConfigRW::GetNode(std::function<YAML::Node(YAML::Node)> fn) const // --------------------------------------------------------------------------------------------------------------------- // -std::vector<std::string> L1ConfigRW::GetNodeKeys(const YAML::Node& node) const +std::vector<std::string> ConfigReader::GetNodeKeys(const YAML::Node& node) const { std::vector<std::string> res; res.reserve(node.size()); @@ -56,8 +60,9 @@ std::vector<std::string> L1ConfigRW::GetNodeKeys(const YAML::Node& node) const } } catch (const YAML::InvalidNode& exc) { - LOG(warn) << "L1 config: attempt to call L1ConfigRW::GetNodeKeys for node, keys of which could not be represented " - << "with strings. An empty vector will be returned"; + LOG(warn) + << "L1 config: attempt to call ConfigReader::GetNodeKeys for node, keys of which could not be represented " + << "with strings. An empty vector will be returned"; std::vector<std::string>().swap(res); } return res; @@ -65,7 +70,7 @@ std::vector<std::string> L1ConfigRW::GetNodeKeys(const YAML::Node& node) const // --------------------------------------------------------------------------------------------------------------------- // -void L1ConfigRW::Read() +void ConfigReader::Read() { { // Init CA iterations in L1InitManager if (fVerbose >= 1) { LOG(info) << "- reading track finder iterations"; } @@ -122,7 +127,7 @@ void L1ConfigRW::Read() // --------------------------------------------------------------------------------------------------------------------- // -std::vector<Iteration> L1ConfigRW::ReadCAIterationVector() +std::vector<Iteration> ConfigReader::ReadCAIterationVector() { std::vector<Iteration> res; @@ -208,7 +213,7 @@ std::vector<Iteration> L1ConfigRW::ReadCAIterationVector() // --------------------------------------------------------------------------------------------------------------------- // -std::vector<std::set<int>> L1ConfigRW::ReadInactiveStationMap() +std::vector<std::set<int>> ConfigReader::ReadInactiveStationMap() { // Check, if the "skip_stations" branch exists either in the user config or in the main config std::string sNodePath = "ca/core/common/inactive_stations"; @@ -220,7 +225,7 @@ std::vector<std::set<int>> L1ConfigRW::ReadInactiveStationMap() if (node && node.size()) { std::unordered_map<std::string, int> mDetNameToID; for (int iDet = 0; iDet < constants::size::MaxNdetectors; ++iDet) { - auto detName = boost::algorithm::to_lower_copy(fpInitManager->GetDetectorName(static_cast<L1DetectorID>(iDet))); + auto detName = boost::algorithm::to_lower_copy(fpInitManager->GetDetectorName(static_cast<EDetectorID>(iDet))); if (!detName.size()) { continue; } mDetNameToID[detName] = iDet; } @@ -251,13 +256,13 @@ std::vector<std::set<int>> L1ConfigRW::ReadInactiveStationMap() auto it = mDetNameToID.find(detName); if (it == mDetNameToID.end()) { std::stringstream msg; - msg << "L1ConfigRW: legal but undefined name of the detector \"" << detName << "\" (originally \"" << stName + msg << "ConfigReader: legal but undefined name of the detector \"" << detName << "\" (originally \"" << stName << "\") was passed to the " << sNodePath << " config " << "branch"; throw std::runtime_error(msg.str()); } - int nStations = fpInitManager->GetNstationsGeometry(static_cast<L1DetectorID>(it->second)); + int nStations = fpInitManager->GetNstationsGeometry(static_cast<EDetectorID>(it->second)); if (vNames.size() == 2) { // Disable one particular station try { int iStLoc = std::stoi(vNames.back()); @@ -280,10 +285,10 @@ std::vector<std::set<int>> L1ConfigRW::ReadInactiveStationMap() } std::stringstream msg; - msg << "\033[1;31m L1ConfigRW: the next tracking stations will be disabled from the configuration file:\n"; + msg << "\033[1;31m ConfigReader: the next tracking stations will be disabled from the configuration file:\n"; for (int iDet = 0; iDet < static_cast<int>(mDetNameToID.size()); ++iDet) { - const auto& detName = fpInitManager->GetDetectorName(static_cast<L1DetectorID>(iDet)); - int nStations = fpInitManager->GetNstationsGeometry(static_cast<L1DetectorID>(iDet)); + const auto& detName = fpInitManager->GetDetectorName(static_cast<EDetectorID>(iDet)); + int nStations = fpInitManager->GetNstationsGeometry(static_cast<EDetectorID>(iDet)); for (int iStLoc = 0; iStLoc < nStations; ++iStLoc) { if (vGeoIdToTrackingStatus[iDet].find(iStLoc) != vGeoIdToTrackingStatus[iDet].end()) { msg << "\t- " << detName << iStLoc << '\n'; @@ -299,7 +304,7 @@ std::vector<std::set<int>> L1ConfigRW::ReadInactiveStationMap() // --------------------------------------------------------------------------------------------------------------------- // -Iteration L1ConfigRW::ReadSingleCAIteration(const YAML::Node& node, const Iteration& defaultIter) const +Iteration ConfigReader::ReadSingleCAIteration(const YAML::Node& node, const Iteration& defaultIter) const { auto iter = Iteration(); try { @@ -338,14 +343,14 @@ Iteration L1ConfigRW::ReadSingleCAIteration(const YAML::Node& node, const Iterat // --------------------------------------------------------------------------------------------------------------------- // -void L1ConfigRW::SetMainConfigPath(const std::string& path) +void ConfigReader::SetMainConfigPath(const std::string& path) { if (path.size()) { try { fsMainConfigPath = path; fMainConfigNode = YAML::LoadFile(fsMainConfigPath)["ca"]; if (fVerbose >= 1) { - LOG(info) << "L1ConfigRW: Registering main configuraiton file: \"\033[1;32m" << path << "\033[0m\""; + LOG(info) << "ConfigReader: Registering main configuraiton file: \"\033[1;32m" << path << "\033[0m\""; } } catch (const std::exception& err) { @@ -356,14 +361,14 @@ void L1ConfigRW::SetMainConfigPath(const std::string& path) // --------------------------------------------------------------------------------------------------------------------- // -void L1ConfigRW::SetUserConfigPath(const std::string& path) +void ConfigReader::SetUserConfigPath(const std::string& path) { if (path.size()) { try { fsUserConfigPath = path; fUserConfigNode = YAML::LoadFile(fsUserConfigPath)["ca"]; if (fVerbose >= 1) { - LOG(info) << "L1ConfigRW: Registering user configuraiton file: \"\033[1;32m" << path << "\033[0m\""; + LOG(info) << "ConfigReader: Registering user configuraiton file: \"\033[1;32m" << path << "\033[0m\""; } } catch (const std::exception& err) { diff --git a/algo/ca/core/pars/CaConfigReader.h b/algo/ca/core/pars/CaConfigReader.h new file mode 100644 index 0000000000..2bbba170d2 --- /dev/null +++ b/algo/ca/core/pars/CaConfigReader.h @@ -0,0 +1,104 @@ +/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// \file CaConfigReader.h +/// \brief Configuration parameter file reader for the CA tracking algorithm (header) +/// \author S.Zharko <s.zharko@gsi.de> +/// \since 18.07.2022 + +#ifndef CaConfigRW_h +#define CaConfigRW_h 1 + +#include <string> +#include <unordered_map> +#include <vector> + +#include <yaml-cpp/yaml.h> + +#include "CaIteration.h" + +using namespace cbm::algo::ca; + +namespace YAML +{ + class Node; +} + +namespace cbm::algo::ca +{ + class InitManager; + enum class DetectorID; + + /// \class cbm::algo::ca::ConfigReader + /// \brief A reader for the CA parameters from the YAML configuration files + /// + /// TODO: Describe configuration procedure here... (main config, user config etc...) + /// + class ConfigReader { + public: + /// \brief Constructor + /// \param pInitManager Pointer to the L1InitManager instance + ConfigReader(InitManager* pInitManager, int verbose = 1); + + /// \brief Destructor + ~ConfigReader() = default; + + /// \brief Reads configuration from files + void Read(); + + /// \brief Reads CA track finder iterations from YAML node + /// \return A vector of iterations + std::vector<Iteration> ReadCAIterationVector(); + + /// \brief Sets main config file + /// \param path Path to the file + void SetMainConfigPath(const std::string& path); + + /// \brief Sets user config file + /// \param path Path to user config file + void SetUserConfigPath(const std::string& path); + + /// \brief Sets verbosity level + void SetVerbosity(int verbose) { fVerbose = verbose; } + + /// \brief Gets verbosity level + int GetVerbosity() const { return fVerbose; } + + private: + /// \brief Reads inactive tracking station map + /// \return A vector of sets of disabled station local indexes vs. the the detector index + std::vector<std::set<int>> ReadInactiveStationMap(); + + /// \brief Accesses a node either from user config or from main config + /// \param fn A function, which returns a YAML::Node reference object + /// \note If the node is not found in both configs + /// \throw std::runtime_error, if the path does not exist in the config + /// + /// This function is to be used, if the desired node should exist either in main or in user config. Firstly, + /// the user config is checked, if it is provided. If the node is not found in user config, the main config + /// is checked. If the node does not exist in the main config as well, an exception will be thrown. + YAML::Node GetNode(std::function<YAML::Node(YAML::Node)> fn) const; + + /// \brief Reads iteration from config file + /// \param node YAML node containing an iteration + /// \param defaultIter Default iteration + /// \return A CA-iteration object + Iteration ReadSingleCAIteration(const YAML::Node& node, const Iteration& defaultIter) const; + + /// \brief Gets parameters content of the node + /// \param node YAML node + /// \return Vector of key names + std::vector<std::string> GetNodeKeys(const YAML::Node& node) const; + + InitManager* fpInitManager = nullptr; ///< Pointer to the L1InitManager instance + int fVerbose = 1; ///< Verbosity level + + std::string fsMainConfigPath = ""; ///< Path to the main config file (mandatory) + std::string fsUserConfigPath = ""; ///< Path to the user config file (optional) + + YAML::Node fMainConfigNode {YAML::NodeType::Undefined}; ///< Main configuration node + YAML::Node fUserConfigNode {YAML::NodeType::Undefined}; ///< User configuration node + }; +} // namespace cbm::algo::ca +#endif // CaConfigRW_h diff --git a/reco/L1/L1Algo/L1InitManager.cxx b/algo/ca/core/pars/CaInitManager.cxx similarity index 69% rename from reco/L1/L1Algo/L1InitManager.cxx rename to algo/ca/core/pars/CaInitManager.cxx index 5f9e9ba1f7..9463491dae 100644 --- a/reco/L1/L1Algo/L1InitManager.cxx +++ b/algo/ca/core/pars/CaInitManager.cxx @@ -2,11 +2,12 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Sergey Gorbunov, Sergei Zharko [committer] */ -/// \file L1InitManager.cxx -/// \brief Input parameters management class for L1Algo -/// \since 19.01.2022 +/// \file CaInitManager.cxx +/// \brief Input data management class for the CA tracking algorithm (implementation) +/// \since 19.01.2022 +/// \author Sergei Zharko <s.zharko@gsi.de> -#include "L1InitManager.h" +#include "CaInitManager.h" #include <boost/archive/binary_iarchive.hpp> #include <boost/archive/binary_oarchive.hpp> @@ -16,20 +17,23 @@ #include <fstream> #include <sstream> -#include "L1Algo.h" -#include "L1Assert.h" -#include "L1ConfigRW.h" +#include "CaConfigReader.h" using namespace constants; -using namespace cbm::algo::ca; + +using cbm::algo::ca::InitManager; +using cbm::algo::ca::MaterialMap; +using cbm::algo::ca::Station; +using cbm::algo::ca::StationInitializer; // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::AddStation(const L1BaseStationInfo& inStation) +void InitManager::AddStation(const StationInitializer& inStation) { // TODO: SZh 15.08.2023: Replace L1MASSERT with throw logic_error - L1MASSERT(0, fInitController.GetFlag(EInitKey::kActiveDetectorIDs), - "Attempt to add a station info before the active detectors set had been initialized"); + if (!fInitController.GetFlag(EInitKey::kActiveDetectorIDs)) { + LOG(fatal) << "Attempt to add a station info before the active detectors set had been initialized"; + } // Check, if the detector subsystem for this station is active if (fActiveDetectorIDs.find(inStation.GetDetectorID()) != fActiveDetectorIDs.end()) { @@ -39,7 +43,7 @@ void L1InitManager::AddStation(const L1BaseStationInfo& inStation) // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::CheckInit() +void InitManager::CheckInit() { this->CheckCAIterationsInit(); this->CheckStationsInfoInit(); @@ -47,7 +51,7 @@ void L1InitManager::CheckInit() // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::ClearSetupInfo() +void InitManager::ClearSetupInfo() { // Clear stations set and a thickness map fvStationInfo.clear(); @@ -67,12 +71,12 @@ void L1InitManager::ClearSetupInfo() fInitController.SetFlag(EInitKey::kPrimaryVertexField, false); // Clear target position - fParameters.fTargetPos.fill(L1Utils::kNaN); + fParameters.fTargetPos.fill(Undef<float>); fTargetZ = 0.; fInitController.SetFlag(EInitKey::kTargetPos, false); // Clear field function - fFieldFunction = L1FieldFunction_t([](const double(&)[3], double(&)[3]) {}); + fFieldFunction = FieldFunction_t([](const double(&)[3], double(&)[3]) {}); fInitController.SetFlag(EInitKey::kFieldFunction, false); // Clear other flags @@ -91,7 +95,7 @@ void L1InitManager::ClearSetupInfo() // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::ClearCAIterations() +void InitManager::ClearCAIterations() { fParameters.fCAIterations.clear(); fCAIterationsNumberCrosscheck = -1; @@ -101,16 +105,16 @@ void L1InitManager::ClearCAIterations() // ---------------------------------------------------------------------------------------------------------------------- // NOTE: this function should be called once in the SendParameters -bool L1InitManager::FormParametersContainer() +bool InitManager::FormParametersContainer() { // Read configuration files - LOG(info) << "L1InitManager: reading parameter configuration ..."; + LOG(info) << "InitManager: reading parameter configuration ..."; try { this->ReadInputConfigs(); - LOG(info) << "L1InitManager: reading parameter configuration ... \033[1;32mdone\033[0m"; + LOG(info) << "InitManager: reading parameter configuration ... \033[1;32mdone\033[0m"; } catch (const std::runtime_error& err) { - LOG(error) << "L1InitManager: reading parameter configuration ... \033[1;31mfail\033[0m. Reason: " << err.what(); + LOG(error) << "InitManager: reading parameter configuration ... \033[1;31mfail\033[0m. Reason: " << err.what(); return false; } @@ -123,7 +127,7 @@ bool L1InitManager::FormParametersContainer() this->CheckInit(); if (!fInitController.IsFinalized()) { - LOG(error) << "L1InitManager: Attempt to form parameters container before all necessary fields were initialized" + LOG(error) << "InitManager: Attempt to form parameters container before all necessary fields were initialized" << fInitController.ToString(); return false; } @@ -132,7 +136,7 @@ bool L1InitManager::FormParametersContainer() auto destIt = fParameters.fStations.begin(); for (const auto& station : fvStationInfo) { if (!station.GetTrackingStatus()) { continue; } - *destIt = station.GetL1Station(); + *destIt = station.GetStation(); ++destIt; } } @@ -151,7 +155,7 @@ bool L1InitManager::FormParametersContainer() fParameters.CheckConsistency(); } catch (const std::logic_error& err) { - LOG(error) << "L1InitManager: parameters container consistency check failed. Reason: " << err.what(); + LOG(error) << "InitManager: parameters container consistency check failed. Reason: " << err.what(); return false; } @@ -160,53 +164,58 @@ bool L1InitManager::FormParametersContainer() // ---------------------------------------------------------------------------------------------------------------------- // -int L1InitManager::GetNstationsActive() const +int InitManager::GetNstationsActive() const { - LOG_IF(fatal, !fInitController.GetFlag(EInitKey::kStationLayoutInitialized)) - << "L1InitManager: number of active stations cannot be accessed until the station layout is initialized"; + if (!fInitController.GetFlag(EInitKey::kStationLayoutInitialized)) { + LOG(fatal) << "InitManager: number of active stations cannot be accessed until the station layout is initialized"; + } return fParameters.GetNstationsActive(); } // ---------------------------------------------------------------------------------------------------------------------- // -int L1InitManager::GetNstationsActive(L1DetectorID detectorID) const +int InitManager::GetNstationsActive(EDetectorID detectorID) const { - LOG_IF(fatal, !fInitController.GetFlag(EInitKey::kStationLayoutInitialized)) - << "L1InitManager: number of active stations cannot be accessed until the station layout is initialized"; + if (!fInitController.GetFlag(EInitKey::kStationLayoutInitialized)) { + LOG(fatal) << "InitManager: number of active stations cannot be accessed until the station layout is initialized"; + } return fParameters.GetNstationsActive(detectorID); } // ---------------------------------------------------------------------------------------------------------------------- // -int L1InitManager::GetNstationsGeometry() const +int InitManager::GetNstationsGeometry() const { - LOG_IF(fatal, !fInitController.GetFlag(EInitKey::kStationLayoutInitialized)) - << "L1InitManager: number of geometry stations cannot be accessed until the station layout is initialized"; + if (!fInitController.GetFlag(EInitKey::kStationLayoutInitialized)) { + LOG(fatal) << "InitManager: number of geometry stations cannot be accessed until the station layout is initialized"; + } return fParameters.GetNstationsGeometry(); } // ---------------------------------------------------------------------------------------------------------------------- // -int L1InitManager::GetNstationsGeometry(L1DetectorID detectorID) const +int InitManager::GetNstationsGeometry(EDetectorID detectorID) const { - LOG_IF(fatal, !fInitController.GetFlag(EInitKey::kStationLayoutInitialized)) - << "L1InitManager: number of geometry stations cannot be accessed until the station layout is initialized"; + if (!fInitController.GetFlag(EInitKey::kStationLayoutInitialized)) { + LOG(fatal) << "InitManager: number of geometry stations cannot be accessed until the station layout is initialized"; + } return fParameters.GetNstationsGeometry(detectorID); } // ---------------------------------------------------------------------------------------------------------------------- // -std::vector<L1BaseStationInfo>& L1InitManager::GetStationInfo() +std::vector<StationInitializer>& InitManager::GetStationInfo() { - LOG_IF(fatal, !fInitController.GetFlag(EInitKey::kStationLayoutInitialized)) - << "L1InitManager: station info container cannot be accessed until the station layout is initialized"; + if (!fInitController.GetFlag(EInitKey::kStationLayoutInitialized)) { + LOG(fatal) << "InitManager: station info container cannot be accessed until the station layout is initialized"; + } return fvStationInfo; } // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::InitStationLayout() +void InitManager::InitStationLayout() { this->ClearStationLayout(); std::sort(fvStationInfo.begin(), fvStationInfo.end()); @@ -238,23 +247,24 @@ void L1InitManager::InitStationLayout() // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::InitTargetField(double zStep) +void InitManager::InitTargetField(double zStep) { if (fInitController.GetFlag(EInitKey::kPrimaryVertexField)) { - LOG(warn) << "L1InitManager::InitTargetField: attempt to reinitialize the field value and field region " + LOG(warn) << "InitManager::InitTargetField: attempt to reinitialize the field value and field region " << "near target. Ignore"; return; } // Check for field function - L1MASSERT(0, fInitController.GetFlag(EInitKey::kFieldFunction), - "Attempt to initialize the field value and field region near target before initializing field function"); - + if (!fInitController.GetFlag(EInitKey::kFieldFunction)) { + LOG(fatal) + << "Attempt to initialize the field value and field region near target before initializing field function"; + } // Check for target defined - L1MASSERT( - 0, fInitController.GetFlag(EInitKey::kTargetPos), - "Attempt to initialize the field value and field region near target before the target position initialization"); - + if (!fInitController.GetFlag(EInitKey::kTargetPos)) { + LOG(fatal) << "Attempt to initialize the field value and field region near target before the target position" + << "initialization"; + } constexpr int nDimensions {3}; constexpr int nPointsNodal {3}; @@ -279,29 +289,28 @@ void L1InitManager::InitTargetField(double zStep) // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::PushBackCAIteration(const Iteration& iteration) +void InitManager::PushBackCAIteration(const Iteration& iteration) { // TODO: probably some checks must be inserted here (S.Zharko) - bool control = fInitController.GetFlag(EInitKey::kCAIterationsNumberCrosscheck); - L1MASSERT(0, control, //fInitController.GetFlag(EInitKey::kCAIterationsNumberCrosscheck), - "Attempt to push back a CA track finder iteration before the number of iterations was defined"); - + if (!fInitController.GetFlag(EInitKey::kCAIterationsNumberCrosscheck)) { + LOG(fatal) << "Attempt to push back a CA track finder iteration before the number of iterations was defined"; + } fParameters.fCAIterations.push_back(iteration); } // --------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::ReadInputConfigs() +void InitManager::ReadInputConfigs() { - L1ConfigRW configRW = L1ConfigRW(this, 4); - configRW.SetMainConfigPath(fsConfigInputMain); - configRW.SetUserConfigPath(fsConfigInputUser); - configRW.Read(); + auto configReader = ConfigReader(this, 4); + configReader.SetMainConfigPath(fsConfigInputMain); + configReader.SetUserConfigPath(fsConfigInputUser); + configReader.Read(); } // --------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::ReadParametersObject(const std::string& fileName) +void InitManager::ReadParametersObject(const std::string& fileName) { // clrs::CL - end colored log // clrs::GNb - bold green log @@ -310,7 +319,7 @@ void L1InitManager::ReadParametersObject(const std::string& fileName) // Open input binary file std::ifstream ifs(fileName, std::ios::binary); if (!ifs) { - LOG(fatal) << "L1InitManager: parameters data file \"" << clrs::GNb << fileName << clrs::CL << "\" was not found"; + LOG(fatal) << "InitManager: parameters data file \"" << clrs::GNb << fileName << clrs::CL << "\" was not found"; } // Get L1InputData object @@ -319,18 +328,18 @@ void L1InitManager::ReadParametersObject(const std::string& fileName) ia >> fParameters; } catch (const std::exception&) { - LOG(fatal) << "L1InitManager: parameters file \"" << clrs::GNb << fileName << clrs::CL + LOG(fatal) << "InitManager: parameters file \"" << clrs::GNb << fileName << clrs::CL << "\" has incorrect data format or was corrupted"; } } // --------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::ReadSearchWindows(const std::string& fileName) +void InitManager::ReadSearchWindows(const std::string& fileName) { // Open input binary file std::ifstream ifs(fileName); - if (!ifs) { LOG(fatal) << "L1InitManager: search window file \"" << fileName << "\" was not found"; } + if (!ifs) { LOG(fatal) << "InitManager: search window file \"" << fileName << "\" was not found"; } try { boost::archive::text_iarchive ia(ifs); @@ -356,39 +365,19 @@ void L1InitManager::ReadSearchWindows(const std::string& fileName) fParameters.fSearchWindows[iTrackGrID * constants::size::MaxNstations + iStationID] = swBuffer; } if (errMsg.str().size()) { - LOG(fatal) << "L1InitManager: some errors occurred while reading search windows: " << errMsg.str(); + LOG(fatal) << "InitManager: some errors occurred while reading search windows: " << errMsg.str(); } } catch (const std::exception&) { - LOG(fatal) << "L1InitManager: search windows file \"" << fileName - << "\" has incorrect data format or was corrupted"; + LOG(fatal) << "InitManager: search windows file \"" << fileName << "\" has incorrect data format or was corrupted"; } fInitController.SetFlag(EInitKey::kSearchWindows, true); } -// --------------------------------------------------------------------------------------------------------------------- -// -bool L1InitManager::SendParameters(L1Algo* pAlgo) -{ - assert(pAlgo); - pAlgo->ReceiveParameters(std::move(fParameters)); - LOG(info) << "L1InitManager: parameters object was sent to the tracking algorithm"; - return true; -} - -// --------------------------------------------------------------------------------------------------------------------- -// -bool L1InitManager::SendParameters(Parameters& destination) -{ - destination = std::move(fParameters); - LOG(info) << "L1InitManager: parameters object was sent to an external destination"; - return true; -} - // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::SetActiveDetectorIDs(const L1DetectorIDSet_t& detectorIDs) +void InitManager::SetActiveDetectorIDs(const DetectorIDSet_t& detectorIDs) { // TODO: To think about redefinition possibilities: should it be allowed or not? (S.Zh.) fActiveDetectorIDs = detectorIDs; @@ -397,7 +386,7 @@ void L1InitManager::SetActiveDetectorIDs(const L1DetectorIDSet_t& detectorIDs) // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::SetCAIterationsNumberCrosscheck(int nIterations) +void InitManager::SetCAIterationsNumberCrosscheck(int nIterations) { fCAIterationsNumberCrosscheck = nIterations; auto& iterationsContainer = fParameters.fCAIterations; @@ -409,23 +398,23 @@ void L1InitManager::SetCAIterationsNumberCrosscheck(int nIterations) // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::SetFieldFunction(const L1FieldFunction_t& fieldFunction) +void InitManager::SetFieldFunction(const FieldFunction_t& fieldFunction) { if (!fInitController.GetFlag(EInitKey::kFieldFunction)) { fFieldFunction = fieldFunction; fInitController.SetFlag(EInitKey::kFieldFunction); } else { - LOG(warn) << "L1InitManager::SetFieldFunction: attempt to reinitialize the field function. Ignored"; + LOG(warn) << "InitManager::SetFieldFunction: attempt to reinitialize the field function. Ignored"; } } // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::SetGhostSuppression(int ghostSuppression) +void InitManager::SetGhostSuppression(int ghostSuppression) { if (fInitController.GetFlag(EInitKey::kGhostSuppression)) { - LOG(warn) << "L1InitManager::SetGhostSuppression: attempt of reinitializating the ghost suppresion flag. Ignore"; + LOG(warn) << "InitManager::SetGhostSuppression: attempt of reinitializating the ghost suppresion flag. Ignore"; return; } fParameters.fGhostSuppression = ghostSuppression; @@ -434,10 +423,10 @@ void L1InitManager::SetGhostSuppression(int ghostSuppression) // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::SetRandomSeed(unsigned int seed) +void InitManager::SetRandomSeed(unsigned int seed) { if (fInitController.GetFlag(EInitKey::kRandomSeed)) { - LOG(warn) << "L1InitManager::SetRandomSeed: attempt of reinitializating the random seed. Ignore"; + LOG(warn) << "InitManager::SetRandomSeed: attempt of reinitializating the random seed. Ignore"; return; } fParameters.fRandomSeed = seed; @@ -446,10 +435,10 @@ void L1InitManager::SetRandomSeed(unsigned int seed) // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::SetTargetPosition(double x, double y, double z) +void InitManager::SetTargetPosition(double x, double y, double z) { if (fInitController.GetFlag(EInitKey::kTargetPos)) { - LOG(warn) << "L1InitManager::SetTargetPosition: attempt to reinitialize the target position. Ignore"; + LOG(warn) << "InitManager::SetTargetPosition: attempt to reinitialize the target position. Ignore"; return; } @@ -464,37 +453,37 @@ void L1InitManager::SetTargetPosition(double x, double y, double z) // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::WriteParametersObject(const std::string& fileName) const +Parameters&& InitManager::TakeParameters() { return std::move(fParameters); } + +// ---------------------------------------------------------------------------------------------------------------------- +// +void InitManager::WriteParametersObject(const std::string& fileName) const { // Open output binary file std::ofstream ofs(fileName, std::ios::binary); if (!ofs) { - LOG(error) << "L1InitManager: failed opening file \"" << clrs::GNb << fileName << clrs::CL + LOG(error) << "InitManager: failed opening file \"" << clrs::GNb << fileName << clrs::CL << "\" to write parameters object"; return; } - LOG(info) << "L1InitManager: writing CA parameters object to file \"" << clrs::GNb << fileName << '\"' << clrs::CL; + LOG(info) << "InitManager: writing CA parameters object to file \"" << clrs::GNb << fileName << '\"' << clrs::CL; // Serialize L1Parameters object and write boost::archive::binary_oarchive oa(ofs); oa << fParameters; } -// -// INIT CHECKERS -// - // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::CheckCAIterationsInit() +void InitManager::CheckCAIterationsInit() { bool ifInitPassed = true; if (!fInitController.GetFlag(EInitKey::kCAIterations)) { int nIterationsActual = fParameters.fCAIterations.size(); int nIterationsExpected = fCAIterationsNumberCrosscheck; if (nIterationsActual != nIterationsExpected) { - LOG(warn) << "L1InitManager::CheckCAIterations: incorrect number of iterations registered: " << nIterationsActual + LOG(warn) << "InitManager::CheckCAIterations: incorrect number of iterations registered: " << nIterationsActual << " of " << nIterationsExpected << " expected"; ifInitPassed = false; } @@ -504,14 +493,14 @@ void L1InitManager::CheckCAIterationsInit() // ---------------------------------------------------------------------------------------------------------------------- // TODO: REWRITE! and add const qualifier (S.Zharko) -void L1InitManager::CheckStationsInfoInit() +void InitManager::CheckStationsInfoInit() { bool ifInitPassed = true; if (!fInitController.GetFlag(EInitKey::kStationsInfo)) { // (1) Check the stations themselves bool bStationsFinalized = std::all_of(fvStationInfo.begin(), fvStationInfo.end(), [](const auto& st) { return st.GetInitController().IsFinalized(); }); - if (!bStationsFinalized) { LOG(fatal) << "At least one of the L1BaseStationInfo objects is not finalized"; } + if (!bStationsFinalized) { LOG(fatal) << "At least one of the StationInitializer objects is not finalized"; } // (2) Check for maximum allowed number of stations if (fParameters.GetNstationsGeometry() > constants::size::MaxNstations) { @@ -526,11 +515,11 @@ void L1InitManager::CheckStationsInfoInit() // --------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::ClearStationLayout() +void InitManager::ClearStationLayout() { fParameters.fvFirstGeoId.fill(0); fParameters.fvLocalToGeoIdMap.fill(0); - fParameters.fvGeoToLocalIdMap.fill(std::make_pair(static_cast<L1DetectorID>(0), -1)); + fParameters.fvGeoToLocalIdMap.fill(std::make_pair(static_cast<EDetectorID>(0), -1)); fParameters.fvGeoToActiveMap.fill(-1); // Note: by default all the stations are inactive fParameters.fvActiveToGeoMap.fill(0); fParameters.fNstationsActiveTotal = -1; diff --git a/algo/ca/core/pars/CaInitManager.h b/algo/ca/core/pars/CaInitManager.h new file mode 100644 index 0000000000..76fcea8b06 --- /dev/null +++ b/algo/ca/core/pars/CaInitManager.h @@ -0,0 +1,308 @@ +/* Copyright (C) 2021-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov, Sergei Zharko [committer] */ + +/// \file CaInitManager.h +/// \brief Input data management class for the CA tracking algorithm (header) +/// \since 24.12.2021 +/// \author Sergei Zharko <s.zharko@gsi.de> + +#ifndef CaInitManager_h +#define CaInitManager_h 1 + +#include <array> +#include <bitset> +#include <memory> //unique_ptr +#include <numeric> +#include <set> +#include <string> +#include <type_traits> +#include <unordered_map> + +#include "CaConstants.h" +#include "CaField.h" +#include "CaIteration.h" +#include "CaObjectInitController.h" +#include "CaParameters.h" +#include "CaSimd.h" +#include "CaStationInitializer.h" +#include "CaUtils.h" + +namespace cbm::algo::ca +{ + /// \enum cbm::algo::ca::EDetectorID + /// \brief Forward declaration of the tracking detectors scoped enumeration + /// + /// Concrete realization of this enumeration must be determined in the concrete setup class (i.e. CbmL1) + enum class EDetectorID; + + /// \brief Underlying integer type for the DetectorID + using DetectorID_t = std::underlying_type_t<EDetectorID>; + + /// \class cbm::algo::ca::InitManager + /// \brief A CA Parameters object initialization class + /// + /// This class provides an interface to form a solid Parameters object, which is used by the CA algorithm and + /// the related routines. The initialization can be performed either from the detector-specific interfaces or by + /// reading the already prepared binary wile with extention ca.par TODO:.... continue + /// + class InitManager { + private: + /// \brief Init-controller key set + enum class EInitKey + { + // NOTE: Please, keep the numbers of the enumeration items in the existing order: it helps to debug the + // initialization with this->GetObjectInitController().ToString() method call (S.Zharko) + kActiveDetectorIDs, ///< 0) If the detector sequence is set + kFieldFunction, ///< 1) If magnetic field getter function is set + kTargetPos, ///< 2) If target position was defined + kPrimaryVertexField, ///< 3) If magnetic field value and region defined at primary vertex + kStationsInfo, ///< 4) If all the planned stations were added to the manager + kCAIterationsNumberCrosscheck, ///< 5) If the number of CA track finder is initialized + kCAIterations, ///< 6) If the CA track finder iterations were initialized + kSearchWindows, ///< 7) If the hit search windows were initialized + 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 + }; + + using DetectorIDIntMap_t = std::unordered_map<EDetectorID, int, utils::EnumClassHash>; + using DetectorIDSet_t = std::set<EDetectorID>; + using FieldFunction_t = std::function<void(const double (&xyz)[3], double (&B)[3])>; + using InitController_t = ObjectInitController<static_cast<int>(EInitKey::kEnd), EInitKey>; + template<typename T> + using DetectorIDArr_t = std::array<T, constants::size::MaxNdetectors>; + + public: + /// \brief Default constructor + InitManager() = default; + + /// \brief Destructor + ~InitManager() = default; + + /// \brief Copy constructor is forbidden + InitManager(const InitManager& /*other*/) = delete; + + /// \brief Move constructor is forbidden + InitManager(InitManager&& /*other*/) = delete; + + /// \brief Copy assignment operator is forbidden + InitManager& operator=(const InitManager& /*other*/) = delete; + + /// \brief Move assignment operator is forbidden + InitManager& operator=(InitManager&& /*other*/) = delete; + + /// \brief Adds a tracking station to the geometry + /// + /// \note The added station stays uninitialized until the Parameters object is formed + void AddStation(const StationInitializer& station); + + /// \brief Provides final checks of the parameters object + void CheckInit(); + + /// \brief Clears vector of CA track finder iterations + void ClearCAIterations(); + + /// \brief Clears vector of base setup + void ClearSetupInfo(); + + /// \brief Forms parameters container + /// \return Success flag: true - the container is formed, false - error while forming the container occured + bool FormParametersContainer(); + + /// \brief Gets name of the detector + /// \param detId Index of the detector + /// \return Name of the detector + const std::string& GetDetectorName(EDetectorID detId) const { return fvDetectorNames[static_cast<int>(detId)]; } + + /// \brief Gets ghost suppression flag + int GetGhostSuppression() const { return fParameters.fGhostSuppression; } + + /// \brief Gets a name of the main input configuration file + const std::string& GetInputConfigMain() const { return fsConfigInputMain; } + + /// \brief Gets a name of the user input configuration file + const std::string& GetInputConfigUser() const { return fsConfigInputMain; } + + /// \brief Gets a const reference to ca::ObjectInitController + const InitController_t& GetInitController() const { return fInitController; } + + /// \brief Gets total number of active stations + int GetNstationsActive() const; + + /// \brief Gets number of active stations for given detector ID + int GetNstationsActive(EDetectorID detectorID) const; + + /// \brief Gets total number of stations, provided by setup geometry + int GetNstationsGeometry() const; + + /// \brief Gets number of stations, provided by setup geometry for given detector ID + int GetNstationsGeometry(EDetectorID detectorID) const; + + /// \brief Gets a name of the output configuration file + const std::string& GetOutputConfigName() const { return fConfigOutputName; } + + /// \brief Gets a reference to the stations array + std::vector<StationInitializer>& GetStationInfo(); + + /// \brief Initializes station layout + /// + /// This function is to be called after all the tracking stations (StationInitializer objects) are added to the + /// InitManager instance. After the initialization the vector of the tracking stations is sorted by z-positions + /// and is available for modifications. + void InitStationLayout(); + + /// \brief Calculates ca::FieldValue and L1FieldReference values for a selected step in z-axis from the target position + /// \param zStep step between nodal points + void InitTargetField(double zStep); + + /// \brief Pushes an CA track finder iteration into a sequence of iteration using reference + void PushBackCAIteration(const Iteration& iteration); + + /// \brief Pushes an CA track finder iteration into a sequence of iteration using raw pointer + void PushBackCAIteration(const Iteration* pIteration) { PushBackCAIteration(*pIteration); } + + /// \brief Pushes an CA track finder iteration into a sequence of iteration using std::unique_ptr + void PushBackCAIteration(const std::unique_ptr<Iteration>& puIteration) { PushBackCAIteration(*puIteration); } + + /// \brief Reads main and user parameters configs + void ReadInputConfigs(); + + /// \brief Reads parameters object from boost-serialized binary file + /// \param fileName Name of input file + void ReadParametersObject(const std::string& fileName); + + /// \brief Reads search windows from file + /// \param fileName Name of input file + void ReadSearchWindows(const std::string& fileName); + + /// \brief Sets a set of active tracking detector IDs + /// \param detectorIDs A set of the used EDetectorID + void SetActiveDetectorIDs(const DetectorIDSet_t& detectorIDs); + + /// \brief Sets a number of CA track finder iterations to provide initialization cross-check + [[deprecated]] void SetCAIterationsNumberCrosscheck(int nIterations); + + /// \brief Sets base configuration file + /// \param mainConfig Path to main configuration file + /// \note The base configuraiton file is mandatory until the tracking configuration is initialized from + /// beforehand created Parameters file. + void SetConfigMain(const std::string& mainConfig) { fsConfigInputMain = mainConfig; } + + /// \brief Sets user configuration file + /// \param userConfig Path to user configuration file + /// \note The user configuraiton file is optional + void SetConfigUser(const std::string& userConfig) { fsConfigInputUser = userConfig; } + + /// \brief Sets detector names + /// \param container Container of the detector names + template<size_t Size> + void SetDetectorNames(const std::array<const char*, Size>& container) + { + static_assert(Size <= constants::size::MaxNdetectors, + "Please, be ensured that the constants::size::MaxNdetectors is not lower then the " + "EDetectorID::kEND value, provided by your setup"); + std::copy(container.begin(), container.end(), fvDetectorNames.begin()); + } + + /// Sets a magnetic field function, which will be applied for all the stations + void SetFieldFunction(const FieldFunction_t& fieldFcn); + + /// \brief Sets the flag to enable/disable the ghost suppression routine + void SetGhostSuppression(int ghostSuppression); + + /// \brief Sets a name of the output configuration file + /// \param filename Name of the output CA parameters configuration + /// + /// The output file is created from the fields, saved in the resulted Parameters object. + void SetOutputConfigName(const std::string& filename) { fConfigOutputName = filename; } + + /// \brief Sets pseudo-random numbers generator seed + /// \param seed Seed value + /// \note The default seed is 1 + void SetRandomSeed(unsigned int seed); + + /// \brief Sets target position + /// \param x Position X component [cm] + /// \param y Position Y component [cm] + /// \param z Position Z component [cm] + void SetTargetPosition(double x, double y, double z); + + /// \brief Sets upper-bound cut on max number of doublets per one singlet + void SetMaxDoubletsPerSinglet(unsigned int value) { fParameters.fMaxDoubletsPerSinglet = value; } + + /// \brief Sets upper-bound cut on max number of triplets per one doublet + void SetMaxTripletPerDoublets(unsigned int value) { fParameters.fMaxTripletPerDoublets = value; } + + /// \brief Takes parameters object from the init-manager instance + /// \return A parameter object + Parameters&& TakeParameters(); + + /// \brief Writes parameters object from boost-serialized binary file + /// \param fileName Name of input file + void WriteParametersObject(const std::string& fileName) const; + + // *************************** + // ** Flags for development ** + // *************************** + + /// \brief Ignore hit search areas + void DevSetIgnoreHitSearchAreas(bool value = true) { fParameters.fDevIsIgnoreHitSearchAreas = value; } + + /// \brief Force use of the original field (not approximated) + void DevSetUseOfOriginalField(bool value = true) { fParameters.fDevIsUseOfOriginalField = value; } + + /// \brief Flag to match doublets using MC information + void DevSetIsMatchDoubletsViaMc(bool value = true) { fParameters.fDevIsMatchDoubletsViaMc = value; } + + /// \brief Flag to match triplets using Mc information + void DevSetIsMatchTripletsViaMc(bool value = true) { fParameters.fDevIsMatchTripletsViaMc = value; } + + /// \brief Flag to match triplets using Mc information + void DevSetIsExtendTracksViaMc(bool value = true) { fParameters.fDevIsExtendTracksViaMc = value; } + + /// \brief Flag to match triplets using Mc information + void DevSetIsSuppressOverlapHitsViaMc(bool value = true) { fParameters.fDevIsSuppressOverlapHitsViaMc = value; } + + /// \brief Flag to use estimated hit search windows + /// \param true estimated search windows will be used in track finder + /// \param false the Kalman filter is be used in track finder + void DevSetIsParSearchWUsed(bool value = true) { fParameters.fDevIsParSearchWUsed = value; } + + private: + /// \brief Checker for Iteration container initialization (sets EInitKey::kCAIterations) + /// \return true If all Iteration objects were initialized properly + void CheckCAIterationsInit(); + + /// \brief Checker for StationInitializer set initialization (sets EInitKey::kStationsInfo) + /// \return true If all StationInitializer objects were initialized properly. Similar effect can be achieved by + void CheckStationsInfoInit(); + + /// \brief Returns station layout into undefined condition + void ClearStationLayout(); + + InitController_t fInitController {}; ///< Initialization flags + DetectorIDSet_t fActiveDetectorIDs {}; ///< Set of tracking detectors, active during the run + DetectorIDArr_t<std::string> fvDetectorNames {}; ///< Names of the detectors + + double fTargetZ {0.}; ///< Target position z component in double precision + + std::vector<StationInitializer> fvStationInfo {}; ///< Vector of StationInitializer objects (active + inactive) + + /// A function which returns magnetic field vector B in a radius-vector xyz + FieldFunction_t fFieldFunction {[](const double (&)[3], double (&)[3]) {}}; + // NOTE: Stations of the detectors which are not assigned as active, are not included in the tracking! + + [[deprecated]] int fCAIterationsNumberCrosscheck { + -1}; ///< Number of iterations to be passed (must be used for cross-checks) + + Parameters fParameters {}; ///< CA parameters object + + std::string fsConfigInputMain = ""; ///< name for the input configuration file + std::string fsConfigInputUser = ""; ///< name for the input configuration file + std::string fConfigOutputName = ""; ///< name for the output configuration file + }; +} // namespace cbm::algo::ca + +#endif diff --git a/algo/ca/core/pars/CaParameters.cxx b/algo/ca/core/pars/CaParameters.cxx index 357c2a1c73..a0b046caf9 100644 --- a/algo/ca/core/pars/CaParameters.cxx +++ b/algo/ca/core/pars/CaParameters.cxx @@ -13,6 +13,7 @@ #include "AlgoFairloggerCompat.h" +using cbm::algo::ca::EDetectorID; using cbm::algo::ca::Iteration; using cbm::algo::ca::MaterialMap; using cbm::algo::ca::Parameters; @@ -193,7 +194,7 @@ void Parameters::CheckConsistency() const // --------------------------------------------------------------------------------------------------------------------- // -int Parameters::GetNstationsActive(L1DetectorID detectorID) const +int Parameters::GetNstationsActive(EDetectorID detectorID) const { int nStations = 0; for (int iStLoc = 0; iStLoc < this->GetNstationsGeometry(detectorID); ++iStLoc) { @@ -246,13 +247,13 @@ std::string Parameters::ToString(int verbosity, int indentLevel) const msg << indent << indentCh << clrs::CLb << "NUMBER OF STATIONS:\n" << clrs::CL; msg << indent << indentCh << indentCh << "Number of stations (Geometry): "; for (int iDet = 0; iDet < constants::size::MaxNdetectors; ++iDet) { - msg << setw(2) << setfill(' ') << this->GetNstationsGeometry(static_cast<L1DetectorID>(iDet)) << ' '; + msg << setw(2) << setfill(' ') << this->GetNstationsGeometry(static_cast<EDetectorID>(iDet)) << ' '; } msg << " | total = " << setw(2) << setfill(' ') << this->GetNstationsGeometry(); msg << '\n'; msg << indent << indentCh << indentCh << "Number of stations (Active): "; for (int iDet = 0; iDet < constants::size::MaxNdetectors; ++iDet) { - msg << setw(2) << setfill(' ') << this->GetNstationsActive(static_cast<L1DetectorID>(iDet)) << ' '; + msg << setw(2) << setfill(' ') << this->GetNstationsActive(static_cast<EDetectorID>(iDet)) << ' '; } msg << " | total = " << setw(2) << setfill(' ') << this->GetNstationsActive(); msg << '\n' << indent << indentCh << indentCh << clrs::CL << "Geometry station indices: "; diff --git a/algo/ca/core/pars/CaParameters.h b/algo/ca/core/pars/CaParameters.h index 28d6c94e73..f4faf7d6ec 100644 --- a/algo/ca/core/pars/CaParameters.h +++ b/algo/ca/core/pars/CaParameters.h @@ -26,14 +26,11 @@ #include "CaStation.h" #include "CaVector.h" -using namespace cbm::algo; // TODO: remove -using namespace cbm::algo::ca; // TODO: remove - -class L1InitManager; -enum class L1DetectorID; - namespace cbm::algo::ca { + class InitManager; + enum class EDetectorID; + using constants::Undef; /// Type definitions for used containers @@ -49,9 +46,9 @@ namespace cbm::algo::ca /// class alignas(constants::misc::Alignment) Parameters { /// \note The init manager is responsible for the formation of the Parameters block - friend class ::L1InitManager; + friend class InitManager; - using DetectorID_t = std::underlying_type_t<L1DetectorID>; + using DetectorID_t = std::underlying_type_t<EDetectorID>; template<typename T> using StationArray_t = std::array<T, constants::size::MaxNstations>; @@ -92,13 +89,13 @@ namespace cbm::algo::ca int GetNstationsActive() const { return fNstationsActiveTotal; } /// \brief Gets number of active stations for given detector ID - int GetNstationsActive(L1DetectorID detectorID) const; + int GetNstationsActive(EDetectorID detectorID) const; /// \brief Gets total number of stations, provided by setup geometry int GetNstationsGeometry() const { return fvFirstGeoId.back(); } /// \brief Gets number of stations, provided by setup geometry for given detector ID - int GetNstationsGeometry(L1DetectorID detectorID) const + int GetNstationsGeometry(EDetectorID detectorID) const { return fvFirstGeoId[static_cast<int>(detectorID) + 1] - fvFirstGeoId[static_cast<int>(detectorID)]; } @@ -106,7 +103,7 @@ namespace cbm::algo::ca /// \brief Gets local index of station /// \param geoIndex geometry index of the tracking station /// \return A pair (detectorID, local index of the tracking station) - [[gnu::always_inline]] std::pair<L1DetectorID, int> GetStationIndexLocal(int geoIndex) const + [[gnu::always_inline]] std::pair<EDetectorID, int> GetStationIndexLocal(int geoIndex) const { return fvGeoToLocalIdMap[geoIndex]; } @@ -114,7 +111,7 @@ namespace cbm::algo::ca /// \brief Calculates global index of station among geometry (accounts for inactive stations) /// \param localIndex local index of the tracking station (for a particular detector) /// \param detectorID ID of the detector subsystem - [[gnu::always_inline]] int GetStationIndexGeometry(int localIndex, L1DetectorID detectorID) const + [[gnu::always_inline]] int GetStationIndexGeometry(int localIndex, EDetectorID detectorID) const { return fvLocalToGeoIdMap[fvFirstGeoId[static_cast<int>(detectorID)] + localIndex]; } @@ -122,7 +119,7 @@ namespace cbm::algo::ca /// \brief Calculates global index of station used by track finder /// \param localIndex local index of the tracking station (for a particular detector) /// \param detectorID ID of the detector subsystem - [[gnu::always_inline]] int GetStationIndexActive(int localIndex, L1DetectorID detectorID) const + [[gnu::always_inline]] int GetStationIndexActive(int localIndex, EDetectorID detectorID) const { return fvGeoToActiveMap[GetStationIndexGeometry(localIndex, detectorID)]; } @@ -261,7 +258,7 @@ namespace cbm::algo::ca alignas(constants::misc::Alignment) StationArray_t<int> fvLocalToGeoIdMap {}; /// \brief Map of geo to (local, det) indices - alignas(constants::misc::Alignment) StationArray_t<std::pair<L1DetectorID, int>> fvGeoToLocalIdMap {}; + alignas(constants::misc::Alignment) StationArray_t<std::pair<EDetectorID, int>> fvGeoToLocalIdMap {}; /// \brief Map of geo to active indices /// diff --git a/algo/ca/core/pars/CaStationInitializer.cxx b/algo/ca/core/pars/CaStationInitializer.cxx new file mode 100644 index 0000000000..1483c22f38 --- /dev/null +++ b/algo/ca/core/pars/CaStationInitializer.cxx @@ -0,0 +1,366 @@ +/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov, Sergei Zharko [committer] */ + +/// \file CaStationInitializer.cxx +/// \brief +/// \author S.Zharko <s.zharko@gsi.de> +/// \since 18.01.2022 +/// + +#include "CaStationInitializer.h" + +#include <iomanip> +#include <sstream> +#include <utility> + +#include "AlgoFairloggerCompat.h" +#include "CaConstants.h" + +using cbm::algo::ca::EDetectorID; +using cbm::algo::ca::MaterialMap; +using cbm::algo::ca::Station; +using cbm::algo::ca::StationInitializer; + +// --------------------------------------------------------------------------------------------------------------------- +// +StationInitializer::StationInitializer(EDetectorID detectorID, int stationID) noexcept + : fDetectorID(detectorID) + , fStationID(stationID) +{ + fInitController.SetFlag(EInitKey::kDetectorID); + fInitController.SetFlag(EInitKey::kStationID); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::Reset() +{ + StationInitializer other; + this->Swap(other); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +const Station& StationInitializer::GetStation() const +{ + if (!fInitController.IsFinalized()) { + std::stringstream msg; + msg << "StationInitializer::GetStation: attempt to get a Station object from uninitialized L1BaseStation with " + << "stationID = " << fStationID << " and detectorID = " << static_cast<int>(fDetectorID); + LOG(fatal) << msg.str(); + } + return fStation; +} + +// --------------------------------------------------------------------------------------------------------------------- +// +const MaterialMap& StationInitializer::GetMaterialMap() const +{ + if (!fInitController.IsFinalized()) { + LOG(fatal) << "StationInitializer::GetMaterialMap: attempt of getting the material map object from uninitialized " + "L1BaseStation class (detectorID = " + << static_cast<int>(fDetectorID) << ", stationID = " << fStationID << ")"; + } + + if (fManagementFlags[static_cast<int>(EManagementFlag::kThicknessMapMoved)]) { + LOG(fatal) << "StationInitializer::GetMaterialMap: attempt of getting the material map, which has been moved. The " + "thickness map instance have been " + << "already took from the StationInitializer object (detectorID = " << static_cast<int>(fDetectorID) + << ", stationID = " << fStationID << ")"; + } + + return fThicknessMap; +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetDetectorID(EDetectorID inID) +{ + if (!fInitController.GetFlag(EInitKey::kDetectorID)) { + fDetectorID = inID; + fInitController.SetFlag(EInitKey::kDetectorID); + } + else { + LOG(warn) << "StationInitializer::SetDetectorID: Attempt of detector ID redifinition"; + } +} + + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetFieldFunction( + const std::function<void(const double (&xyz)[3], double (&B)[3])>& getFieldValue) +{ + if (fInitController.GetFlag(EInitKey::kFieldSlice)) { + LOG(warn) << "StationInitializer::SetFieldSlice: Attempt to redifine field slice for station with detectorID = " + << static_cast<int>(fDetectorID) << " and stationID = " << fStationID << ". Redifinition ignored"; + return; + } + + if (!fInitController.GetFlag(EInitKey::kZref)) { + LOG(fatal) << "Attempt to set magnetic field slice before setting z position of the station"; + } + if (!fInitController.GetFlag(EInitKey::kXmax)) { + LOG(fatal) << "Attempt to set magnetic field slice before Xmax size of the station"; + } + if (!fInitController.GetFlag(EInitKey::kYmax)) { + LOG(fatal) << "Attempt to set magnetic field slice before Ymax size of the station"; + } + // TODO: Change names of variables according to convention (S.Zh.) + constexpr int M = constants::size::MaxFieldApproxPolynomialOrder; + constexpr int N = constants::size::MaxNFieldApproxCoefficients; + constexpr int D = 3; ///> number of dimensions + + // SLE initialization + double A[N][N + D] = {}; // augmented matrix + double dx = (fXmax / N / 2 < 1.) ? fXmax / N / 4. : 1.; + double dy = (fYmax / N / 2 < 1.) ? fYmax / N / 4. : 1.; + + for (double x = -fXmax; x <= fXmax; x += dx) { + for (double y = -fYmax; y <= fYmax; y += dy) { + double r = sqrt(fabs(x * x / fXmax / fXmax + y / fYmax * y / fYmax)); + if (r > 1.) { continue; } + double p[D] = {x, y, fZref}; + double B[D] = {}; + getFieldValue(p, B); + + double m[N] = {1}; + m[0] = 1; + for (int i = 1; i <= M; ++i) { + int k = (i - 1) * i / 2; + int l = i * (i + 1) / 2; + for (int j = 0; j < i; ++j) { + m[l + j] = x * m[k + j]; + } + m[l + i] = y * m[k + i - 1]; + } + + double w = 1. / (r * r + 1); + for (int i = 0; i < N; ++i) { + // fill the left part of the matrix + for (int j = 0; j < N; ++j) { + A[i][j] += w * m[i] * m[j]; + } + // fill the right part of the matrix + for (int j = 0; j < D; ++j) { + A[i][N + j] += w * B[j] * m[i]; + } + } + } + } + + // SLE solution (Gaussian elimination) + // + for (int kCol = 0; kCol < N - 1; ++kCol) { + for (int jRow = kCol + 1; jRow < N; ++jRow) { + double factor = A[jRow][kCol] / A[kCol][kCol]; + for (int iCol = kCol; iCol < N + D; ++iCol) { + A[jRow][iCol] -= factor * A[kCol][iCol]; + } + } + } + for (int kCol = N - 1; kCol > 0; --kCol) { + for (int jRow = kCol - 1; jRow >= 0; --jRow) { + double factor = A[jRow][kCol] / A[kCol][kCol]; + for (int iCol = kCol; iCol < N + D; ++iCol) { + A[jRow][iCol] -= factor * A[kCol][iCol]; + } + } + } + + for (int j = 0; j < N; ++j) { + fStation.fieldSlice.cx[j] = A[j][N + 0] / A[j][j]; + fStation.fieldSlice.cy[j] = A[j][N + 1] / A[j][j]; + fStation.fieldSlice.cz[j] = A[j][N + 2] / A[j][j]; + } + fStation.fieldSlice.z = fZref; + + fInitController.SetFlag(EInitKey::kFieldSlice); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetFieldStatus(int fieldStatus) +{ + fStation.fieldStatus = fieldStatus; + fInitController.SetFlag(EInitKey::kFieldStatus); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetMaterialMap(const MaterialMap& thicknessMap) +{ + if (!fInitController.GetFlag(EInitKey::kThicknessMap)) { + fThicknessMap = thicknessMap; + fInitController.SetFlag(EInitKey::kThicknessMap); + } + else { + LOG(warn) << "StationInitializer::SetMaterialMap: attempt to reinitialize the material map"; + } +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetMaterialMap(MaterialMap&& thicknessMap) noexcept +{ + if (!fInitController.GetFlag(EInitKey::kThicknessMap)) { + fThicknessMap = std::move(thicknessMap); + fInitController.SetFlag(EInitKey::kThicknessMap); + } + else { + LOG(warn) << "StationInitializer::SetMaterialMap: attempt to reinitialize the material map"; + } +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetStationID(int inID) +{ + if (!fInitController.GetFlag(EInitKey::kStationID)) { + fStationID = inID; + fInitController.SetFlag(EInitKey::kStationID); + } + else { + LOG(warn) << "StationInitializer::SetStationID: Attempt of station ID redifinition"; + } +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetStationType(int inType) +{ + if (!fInitController.GetFlag(EInitKey::kType)) { + fStation.type = inType; + fInitController.SetFlag(EInitKey::kType); + } + else { + LOG(warn) << "StationInitializer::SetStationType: Attempt of station type redifinition"; + } +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetXmax(double aSize) +{ + fXmax = aSize; + fStation.Xmax = aSize; + fInitController.SetFlag(EInitKey::kXmax); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetYmax(double aSize) +{ + fYmax = aSize; + fStation.Ymax = aSize; + fInitController.SetFlag(EInitKey::kYmax); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetTimeInfo(int inTimeInfo) +{ + fStation.timeInfo = inTimeInfo; + fInitController.SetFlag(EInitKey::kTimeInfo); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetTrackingStatus(bool flag) +{ + fTrackingStatus = flag; + fInitController.SetFlag(EInitKey::kTrackingStatus); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetZref(double inZ) +{ + fStation.fZ = inZ; // setting simd vector of single-precision floats, which is passed to high performanced L1Algo + fZref = inZ; // setting precised value to use in field approximation etc + fInitController.SetFlag(EInitKey::kZref); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetZmin(double inZ) +{ + fZmin = inZ; // setting precised value to use in field approximation etc + fInitController.SetFlag(EInitKey::kZmin); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::SetZmax(double inZ) +{ + fZmax = inZ; // setting precised value to use in field approximation etc + fInitController.SetFlag(EInitKey::kZmax); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void StationInitializer::Swap(StationInitializer& other) noexcept +{ + std::swap(fDetectorID, other.fDetectorID); + std::swap(fStationID, other.fStationID); + std::swap(fTrackingStatus, other.fTrackingStatus); + std::swap(fXmax, other.fXmax); + std::swap(fYmax, other.fYmax); + std::swap(fZref, other.fZref); + std::swap(fZmin, other.fZmin); + std::swap(fZmax, other.fZmax); + std::swap(fStation, other.fStation); + std::swap(fThicknessMap, other.fThicknessMap); + std::swap(fInitController, other.fInitController); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +MaterialMap&& StationInitializer::TakeMaterialMap() +{ + if (!fInitController.IsFinalized()) { + LOG(fatal) << "StationInitializer::GetMaterialMap: attempt of getting the material map object from uninitialized " + "L1BaseStation class (detectorID = " + << static_cast<int>(fDetectorID) << ", stationID = " << fStationID << ")"; + } + + if (fManagementFlags[static_cast<int>(EManagementFlag::kThicknessMapMoved)]) { + LOG(fatal) << "StationInitializer::GetMaterialMap: attempt of taking the material map, which has been moved. The " + "thickness map instance have been " + << "already took from the StationInitializer object (detectorID = " << static_cast<int>(fDetectorID) + << ", stationID = " << fStationID << ")"; + } + else { + fManagementFlags[static_cast<int>(EManagementFlag::kThicknessMapMoved)] = true; + } + + return std::move(fThicknessMap); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +std::string StationInitializer::ToString(int verbosityLevel, int indentLevel) const +{ + std::stringstream aStream {}; + constexpr char indentChar = '\t'; + std::string indent(indentLevel, indentChar); + + if (verbosityLevel == 0) { + aStream << indent << "StationInitializer object: {stationID, detectorID, z, address} = {" << fStationID << ", " + << static_cast<int>(fDetectorID) << ", " << fZref << ", " << this << '}'; + } + else if (verbosityLevel > 0) { + aStream << indent << "StationInitializer object: at " << this << '\n'; + aStream << indent << indentChar << "Station ID: " << fStationID << '\n'; + aStream << indent << indentChar << "Detector ID: " << static_cast<int>(fDetectorID) << '\n'; + aStream << indent << indentChar << "ca::Station object:" << '\n'; + aStream << fStation.ToString(verbosityLevel - 1, indentLevel + 1) << '\n'; + aStream << indent << indentChar << "Additional fields:\n"; + aStream << indent << indentChar << indentChar << "Zmin: " << fZmin << '\n'; + aStream << indent << indentChar << indentChar << "Zmax: " << fZmax << '\n'; + aStream << indent << indentChar << indentChar << "Xmax: " << fXmax << '\n'; + aStream << indent << indentChar << indentChar << "Ymax: " << fYmax << '\n'; + } + return aStream.str(); +} diff --git a/algo/ca/core/pars/CaStationInitializer.h b/algo/ca/core/pars/CaStationInitializer.h new file mode 100644 index 0000000000..221438ed0e --- /dev/null +++ b/algo/ca/core/pars/CaStationInitializer.h @@ -0,0 +1,220 @@ +/* Copyright (C) 2021-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov, Sergei Zharko [committer] */ + +/// \file CaStationInitializer.h +/// \brief An interface for the CA Station object initialization +/// \since 18.12.2021 +/// \author S.Zharko <s.zharko@gsi.de> + +#ifndef CaStationInitializer_h +#define CaStationInitializer_h 1 + +#include <bitset> +#include <functional> +#include <string> + +#include "CaMaterialMap.h" +#include "CaObjectInitController.h" +#include "CaSimd.h" +#include "CaStation.h" + +namespace cbm::algo::ca +{ + enum class EDetectorID; + + /// A base class which provides interface to L1Algo station geometry + class StationInitializer { + /// Enumeration for internal logic control + enum class EManagementFlag + { + kThicknessMapMoved, ///< if the thickness map was moved from the StationInitializer instance + kEnd + }; + using ManagementFlags_t = std::bitset<static_cast<int>(EManagementFlag::kEnd)>; + + public: + /// \enum EInitKey + /// \brief Enumeration of fields, which must be initialized so the object can pass the threshold + enum class EInitKey + { + // Basic fields initialization + kDetectorID, ///< detector ID + kStationID, ///< station ID + kTrackingStatus, ///< flag, if station is used in tracking or not + kXmax, ///< max size in X direction + kYmax, ///< max size in Y direction + // ca::Station initialization + kType, ///< station type + kTimeInfo, ///< if time info is used (flag) + kFieldStatus, ///< if station is placed in field (flag) + kZref, ///< reference z of the station + kZmin, ///< min z of the station + kZmax, ///< max z of the station + kThicknessMap, ///< thickness map of the station (optional?) + kFieldSlice, ///< ca::Station.ca::FieldSlice object initialization + // The last item is equal to the number of bits in fInitFlags + kEnd + }; + using InitController_t = ca::ObjectInitController<static_cast<int>(EInitKey::kEnd), EInitKey>; + + /// \brief Default constructor + StationInitializer() = default; + + /// \brief Constructor from stationID and detectorID + StationInitializer(EDetectorID detetorID, int stationID) noexcept; + + /// \brief Destructor + ~StationInitializer() noexcept = default; + + /// \brief Copy constructor + StationInitializer(const StationInitializer& other) = default; + + /// \brief Less operator for StationInitializer object to sort stations in Z + bool operator<(const StationInitializer& right) const { return (GetZref() < right.GetZref()); } + + /// \brief Gets detector ID + EDetectorID GetDetectorID() const { return fDetectorID; } + + /// \brief Gets a coefficient with idx for the field x-component approximation + fvec GetFieldSliceCx(int idx) const { return fStation.fieldSlice.cx[idx]; } + + /// \brief Gets a coefficient with idx for the field y-component approximation + fvec GetFieldSliceCy(int idx) const { return fStation.fieldSlice.cy[idx]; } + + /// \brief Gets a coefficient with idx for the field z-component approximation + fvec GetFieldSliceCz(int idx) const { return fStation.fieldSlice.cz[idx]; } + + /// \brief Gets array of the coefficients for the field x-component approximation + const fvec* GetFieldSliceCx() const { return fStation.fieldSlice.cx; } + + /// \brief Gets array of the coefficients for the field y-component approximation + const fvec* GetFieldSliceCy() const { return fStation.fieldSlice.cy; } + + /// \brief Gets array of the coefficients for the field z-component approximation + const fvec* GetFieldSliceCz() const { return fStation.fieldSlice.cz; } + + + /// \brief Gets field status: 0 - station is outside the field, 1 - station is inside the field + int GetFieldStatus() const { return fStation.fieldStatus; } + + /// \brief Gets a const reference to the ca::ObjectInitController object + const InitController_t& GetInitController() const { return fInitController; } + + /// \brief Gets a reference to ca::Station info field of the L1BaseStation info + const Station& GetStation() const; + + /// \brief Gets a reference to ca::MaterialMap map + const MaterialMap& GetMaterialMap() const; + + /// \brief Gets station ID + int GetStationID() const { return fStationID; } + + /// \brief Gets station type + int GetStationType() const { return fStation.type; } + + /// \brief Gets tracking status: true - station is active for tracking, false - station exists, but not used in tracking + bool GetTrackingStatus() const { return fTrackingStatus; } + + /// \brief Gets maximum distance between station center and its edge in x direction + double GetXmax() const { return fXmax; } + + /// \brief Gets maximum distance between station center and its edge in y direction + double GetYmax() const { return fYmax; } + + /// \brief Gets double precised z position of the station [cm] + double GetZref() const { return fZref; } + + /// \brief Gets min z of the station [cm] + double GetZmin() const { return fZmin; } + + /// \brief Gets max z of the station [cm] + double GetZmax() const { return fZmax; } + + /// \brief Gets SIMD vectorized z position of the station [cm] + fvec GetZsimdVec() const { return fStation.fZ; } + + /// \brief Resets fields to the default values + void Reset(); + + /// \brief Sets detector ID + void SetDetectorID(EDetectorID inID); + + /// \brief Sets flag: true - station is placed in field, false - station is placed outside the field + void SetFieldStatus(int fieldStatus); + + /// \brief Sets arrays of the approcimation + /// \param getField A user function, which gets a xyz array of position coordinates and fills B array + /// of magnetic field components in position + void SetFieldFunction(const std::function<void(const double (&xyz)[3], double (&B)[3])>& getFieldValue); + + /// \brief Sets station thickness in units of radiation length mapped vs. position in XY plane (copy semantics) + /// \param thicknessMap Map of station thickness in units of radiation length + void SetMaterialMap(const MaterialMap& thicknessMap); + + /// \brief Sets station thickness in units of radiation length mapped vs. position in XY plane (move semantics) + /// \param thicknessMap Map of station thickness in units of radiation length + void SetMaterialMap(MaterialMap&& thicknessMap) noexcept; + + /// \brief Sets station ID + [[deprecated("Please, use constructor to set station ID")]] void SetStationID(int inID); + + /// \brief Sets type of station + void SetStationType(int inType); // TODO: this is a temporary solution (S.Zh.) + + /// \brief Sets flag: 0 - time information is not provided by this detector type + /// 1 - time information is provided by the detector and can be used in tracking + void SetTimeInfo(int inTimeInfo); + + /// \brief Sets tracking status: true - station is active for tracking, false - station exists, but not used in tracking + void SetTrackingStatus(bool flag); + + /// \brief Sets maximum distance between station center and its edge in x direction + void SetXmax(double aSize); + + /// \brief Sets maximum distance between station center and its edge in y direction + void SetYmax(double aSize); + + /// \brief Sets reference z position of the station + void SetZref(double inZ); + + /// \brief Sets min z of the station + void SetZmin(double inZ); + + /// \brief Sets max z of the station + void SetZmax(double inZ); + + /// \brief Swap method for easy implementation of move constructor and copy and move assignment operator + void Swap(StationInitializer& other) noexcept; + + /// \brief Takes an instance of ca::MaterialMap map + /// + /// \note This method can be called only once. It will catch the content of ca::MaterialMap map (using move + /// semantics), and after the warning will be generated both for the GetMaterialMap and the TakeMaterialMap + /// functions. + ca::MaterialMap&& TakeMaterialMap(); + + /// \brief String representation of class contents + /// \param indentLevel Number of indent characters in the output + std::string ToString(int verbosityLevel = 0, int indentLevel = 0) const; + + private: + EDetectorID fDetectorID {static_cast<EDetectorID>(0)}; ///< Detector ID + int fStationID {-1}; ///< Local ID of a station + bool fTrackingStatus {false}; ///< Tracking status: true - station is used for tracking + double fXmax {0}; ///< Maximum distance between station center and its edge in x direction + double fYmax {0}; ///< Maximum distance between station center and its edge in y direction + double fZref {0}; ///< reference z + double fZmin {0}; ///< min z + double fZmax {0}; ///< max z + Station fStation {}; ///< ca::Station structure, describes a station in L1Algo + MaterialMap fThicknessMap {}; ///< Map of station thickness in units of radiation length + InitController_t fInitController {}; ///< Class fileds initialization flags + ManagementFlags_t fManagementFlags {}; ///< bitset flags to manage internal behaviour of the class + }; + + /// swap function for two StationInitializer objects, expected to be used instead of std::swap + inline void swap(StationInitializer& a, StationInitializer& b) noexcept { a.Swap(b); } +} // namespace cbm::algo::ca + +#endif // CaStationInitializer_h diff --git a/algo/ca/core/utils/CaUtils.h b/algo/ca/core/utils/CaUtils.h index 4e697f0da3..45fa539e23 100644 --- a/algo/ca/core/utils/CaUtils.h +++ b/algo/ca/core/utils/CaUtils.h @@ -107,6 +107,16 @@ namespace cbm::algo::ca::utils } return true; } + + /// \struct EnumClassHash + /// \brief Hash for unordered_map with enum class keys + struct EnumClassHash { + template<typename T> + int operator()(T t) const + { + return static_cast<int>(t); + } + }; } // namespace cbm::algo::ca::utils diff --git a/algo/log/AlgoFairloggerCompat.h b/algo/log/AlgoFairloggerCompat.h index 86438bfcdd..941012523d 100644 --- a/algo/log/AlgoFairloggerCompat.h +++ b/algo/log/AlgoFairloggerCompat.h @@ -21,4 +21,3 @@ static constexpr severity_level warn = severity_level::warning; #endif // NO_ROOT #endif // CBM_ALGO_BASE_COMPAT_ONLINEDATALOG_H - diff --git a/macro/mcbm/mcbm_qa.C b/macro/mcbm/mcbm_qa.C index 1e1274db87..36d8fdf517 100644 --- a/macro/mcbm/mcbm_qa.C +++ b/macro/mcbm/mcbm_qa.C @@ -246,10 +246,10 @@ void mcbm_qa(Int_t nEvents = 0, TString dataset = "data/mcbm_beam_2020_03_test", caParFile.ReplaceAll(".root", ".L1Parameters.dat"); auto* pCaInputQaSetup = new cbm::ca::InputQaSetup(verbose, bUseMC); - pCaInputQaSetup->SetDetectorFlag(L1DetectorID::kSts, bUseSts); - pCaInputQaSetup->SetDetectorFlag(L1DetectorID::kMuch, bUseMuch); - pCaInputQaSetup->SetDetectorFlag(L1DetectorID::kTrd, bUseTrd); - pCaInputQaSetup->SetDetectorFlag(L1DetectorID::kTof, bUseTof); + pCaInputQaSetup->SetDetectorFlag(cbm::algo::ca::EDetectorID::kSts, bUseSts); + pCaInputQaSetup->SetDetectorFlag(cbm::algo::ca::EDetectorID::kMuch, bUseMuch); + pCaInputQaSetup->SetDetectorFlag(cbm::algo::ca::EDetectorID::kTrd, bUseTrd); + pCaInputQaSetup->SetDetectorFlag(cbm::algo::ca::EDetectorID::kTof, bUseTof); pCaInputQaSetup->ReadParameters(caParFile.Data()); pCaInputQaSetup->SetSetupName(setupName.Data()); run->AddTask(pCaInputQaSetup); diff --git a/reco/KF/ParticleFitter/CbmL1PFFitter.cxx b/reco/KF/ParticleFitter/CbmL1PFFitter.cxx index 751d296567..8b13196a4d 100644 --- a/reco/KF/ParticleFitter/CbmL1PFFitter.cxx +++ b/reco/KF/ParticleFitter/CbmL1PFFitter.cxx @@ -115,8 +115,9 @@ inline void CbmL1PFFitter::Initialize() LOG(fatal) << "CbmL1PFFitter: no CbmL1 task initialised "; } - fNmvdStationsActive = CbmL1::Instance()->fpAlgo->GetParameters()->GetNstationsActive(L1DetectorID::kMvd); - fNstsStationsActive = CbmL1::Instance()->fpAlgo->GetParameters()->GetNstationsActive(L1DetectorID::kSts); + using cbm::algo::ca::EDetectorID; + fNmvdStationsActive = CbmL1::Instance()->fpAlgo->GetParameters()->GetNstationsActive(EDetectorID::kMvd); + fNstsStationsActive = CbmL1::Instance()->fpAlgo->GetParameters()->GetNstationsActive(EDetectorID::kSts); if (fNmvdStationsActive > 0) { fMvdHitArray = static_cast<TClonesArray*>(manager->GetObject("MvdHit")); } if (fNstsStationsActive > 0) { fStsHitArray = static_cast<TClonesArray*>(manager->GetObject("StsHit")); } @@ -126,13 +127,15 @@ inline void CbmL1PFFitter::Initialize() inline int CbmL1PFFitter::GetMvdStationIndex(const CbmMvdHit* hit) { - return CbmL1::Instance()->fpAlgo->GetParameters()->GetStationIndexActive(hit->GetStationNr(), L1DetectorID::kMvd); + using cbm::algo::ca::EDetectorID; + return CbmL1::Instance()->fpAlgo->GetParameters()->GetStationIndexActive(hit->GetStationNr(), EDetectorID::kMvd); } inline int CbmL1PFFitter::GetStsStationIndex(const CbmStsHit* hit) { + using cbm::algo::ca::EDetectorID; return CbmL1::Instance()->fpAlgo->GetParameters()->GetStationIndexActive( - CbmStsSetup::Instance()->GetStationNumber(hit->GetAddress()), L1DetectorID::kSts); + CbmStsSetup::Instance()->GetStationNumber(hit->GetAddress()), EDetectorID::kSts); } diff --git a/reco/L1/CMakeLists.txt b/reco/L1/CMakeLists.txt index d8c1548916..c2cee597fc 100644 --- a/reco/L1/CMakeLists.txt +++ b/reco/L1/CMakeLists.txt @@ -49,12 +49,9 @@ set(SRCS L1Algo/L1MaterialMonitor.cxx L1Algo/L1UMeasurementInfo.cxx L1Algo/L1XYMeasurementInfo.cxx - L1Algo/L1BaseStationInfo.cxx - L1Algo/L1InitManager.cxx L1Algo/L1InputData.cxx L1Algo/L1IODataManager.cxx L1Algo/L1CloneMerger.cxx - L1Algo/L1ConfigRW.cxx L1Algo/utils/L1AlgoDraw.cxx L1Algo/utils/L1AlgoEfficiencyPerformance.cxx L1Algo/utils/L1AlgoPulls.cxx diff --git a/reco/L1/CbmCaMCModule.cxx b/reco/L1/CbmCaMCModule.cxx index 47e7d3e5fa..eeb8fc81c5 100644 --- a/reco/L1/CbmCaMCModule.cxx +++ b/reco/L1/CbmCaMCModule.cxx @@ -58,11 +58,21 @@ try { if (fVerbose > 0) { LOG(info) << "CA MC Module: initializing CA tracking Monte-Carlo module... "; } // Detector interfaces - if (fvbUseDet[L1DetectorID::kMvd]) { fvpDetInterface[L1DetectorID::kMvd] = CbmMvdTrackingInterface::Instance(); } - if (fvbUseDet[L1DetectorID::kSts]) { fvpDetInterface[L1DetectorID::kSts] = CbmStsTrackingInterface::Instance(); } - if (fvbUseDet[L1DetectorID::kMuch]) { fvpDetInterface[L1DetectorID::kMuch] = CbmMuchTrackingInterface::Instance(); } - if (fvbUseDet[L1DetectorID::kTrd]) { fvpDetInterface[L1DetectorID::kTrd] = CbmTrdTrackingInterface::Instance(); } - if (fvbUseDet[L1DetectorID::kTof]) { fvpDetInterface[L1DetectorID::kTof] = CbmTofTrackingInterface::Instance(); } + if (fvbUseDet[ca::EDetectorID::kMvd]) { + fvpDetInterface[ca::EDetectorID::kMvd] = CbmMvdTrackingInterface::Instance(); + } + if (fvbUseDet[ca::EDetectorID::kSts]) { + fvpDetInterface[ca::EDetectorID::kSts] = CbmStsTrackingInterface::Instance(); + } + if (fvbUseDet[ca::EDetectorID::kMuch]) { + fvpDetInterface[ca::EDetectorID::kMuch] = CbmMuchTrackingInterface::Instance(); + } + if (fvbUseDet[ca::EDetectorID::kTrd]) { + fvpDetInterface[ca::EDetectorID::kTrd] = CbmTrdTrackingInterface::Instance(); + } + if (fvbUseDet[ca::EDetectorID::kTof]) { + fvpDetInterface[ca::EDetectorID::kTof] = CbmTofTrackingInterface::Instance(); + } auto fairManager = FairRootManager::Instance(); assert(fairManager); @@ -83,25 +93,25 @@ try { fFileEventIDs.clear(); - auto InitPointBranch = [&](const char* brName, L1DetectorID detID) { + auto InitPointBranch = [&](const char* brName, ca::EDetectorID detID) { if (fvbUseDet[detID]) { fvpBrPoints[detID] = mcManager->InitBranch(brName); } }; - auto InitMatchesBranch = [&](const char* brName, L1DetectorID detID) { + auto InitMatchesBranch = [&](const char* brName, ca::EDetectorID detID) { if (fvbUseDet[detID]) { fvpBrHitMatches[detID] = dynamic_cast<TClonesArray*>(fairManager->GetObject(brName)); } }; - InitPointBranch("MvdPoint", L1DetectorID::kMvd); - InitPointBranch("StsPoint", L1DetectorID::kSts); - InitPointBranch("MuchPoint", L1DetectorID::kMuch); - InitPointBranch("TrdPoint", L1DetectorID::kTrd); - InitPointBranch("TofPoint", L1DetectorID::kTof); + InitPointBranch("MvdPoint", ca::EDetectorID::kMvd); + InitPointBranch("StsPoint", ca::EDetectorID::kSts); + InitPointBranch("MuchPoint", ca::EDetectorID::kMuch); + InitPointBranch("TrdPoint", ca::EDetectorID::kTrd); + InitPointBranch("TofPoint", ca::EDetectorID::kTof); - InitMatchesBranch("MvdHitMatch", L1DetectorID::kMvd); - InitMatchesBranch("StsHitMatch", L1DetectorID::kSts); - InitMatchesBranch("MuchPixelHitMatch", L1DetectorID::kMuch); - InitMatchesBranch("TrdHitMatch", L1DetectorID::kTrd); - InitMatchesBranch("TofHitMatch", L1DetectorID::kTof); + InitMatchesBranch("MvdHitMatch", ca::EDetectorID::kMvd); + InitMatchesBranch("StsHitMatch", ca::EDetectorID::kSts); + InitMatchesBranch("MuchPixelHitMatch", ca::EDetectorID::kMuch); + InitMatchesBranch("TrdHitMatch", ca::EDetectorID::kTrd); + InitMatchesBranch("TofHitMatch", ca::EDetectorID::kTof); // Check initialization @@ -228,11 +238,11 @@ void MCModule::Finish() { LOG(info) << '\n' << fMonitor.ToString(); } // void MCModule::MatchRecoAndMC() { - this->MatchPointsAndHits<L1DetectorID::kMvd>(); - this->MatchPointsAndHits<L1DetectorID::kSts>(); - this->MatchPointsAndHits<L1DetectorID::kMuch>(); - this->MatchPointsAndHits<L1DetectorID::kTrd>(); - this->MatchPointsAndHits<L1DetectorID::kTof>(); + this->MatchPointsAndHits<ca::EDetectorID::kMvd>(); + this->MatchPointsAndHits<ca::EDetectorID::kSts>(); + this->MatchPointsAndHits<ca::EDetectorID::kMuch>(); + this->MatchPointsAndHits<ca::EDetectorID::kTrd>(); + this->MatchPointsAndHits<ca::EDetectorID::kTof>(); this->MatchRecoAndMCTracks(); this->InitTrackInfo(); for (const auto& trkMC : fpMCData->GetTrackContainer()) { @@ -321,7 +331,7 @@ void MCModule::CheckInit() const if (!fpMCEventHeader) { throw std::logic_error("MC event header is unavailable"); } // Check detectors initialization - for (int iD = 0; iD < static_cast<int>(L1DetectorID::kEND); ++iD) { + for (int iD = 0; iD < static_cast<int>(ca::EDetectorID::kEND); ++iD) { if (fvbUseDet[iD]) { if (!fvpBrPoints[iD]) { throw std::logic_error(Form("MC points are unavailable for %s", kDetName[iD])); } if (!fvpBrHitMatches[iD]) { throw std::logic_error(Form("Hit matches are unavailable for %s", kDetName[iD])); } @@ -332,10 +342,10 @@ void MCModule::CheckInit() const // --------------------------------------------------------------------------------------------------------------------- // template<> -void MCModule::ReadMCPointsForDetector<L1DetectorID::kTof>() +void MCModule::ReadMCPointsForDetector<ca::EDetectorID::kTof>() { - auto* pBrHitMatches = fvpBrHitMatches[L1DetectorID::kTof]; - auto* pBrPoints = fvpBrPoints[L1DetectorID::kTof]; + auto* pBrHitMatches = fvpBrHitMatches[ca::EDetectorID::kTof]; + auto* pBrPoints = fvpBrPoints[ca::EDetectorID::kTof]; // FIXME: Use mask from CbmTofAddress (but test before!!) constexpr int kNofBitsRpcAddress = 11; @@ -386,7 +396,7 @@ void MCModule::ReadMCPointsForDetector<L1DetectorID::kTof>() // New point if (rpcAddrCurr != rpcAddr || iTmcCurr != iTmc) { // The new interaction of the MC track with the TOF RPC if (iPointSelected != -1) { - auto oPoint = FillMCPoint<L1DetectorID::kTof>(iPointSelected, iEvent, iFile); + auto oPoint = FillMCPoint<ca::EDetectorID::kTof>(iPointSelected, iEvent, iFile); if (oPoint) { fpMCData->AddPoint(*oPoint); } } iTmcCurr = iTmc; @@ -397,7 +407,7 @@ void MCModule::ReadMCPointsForDetector<L1DetectorID::kTof>() if (bTrkHasHits) { iPointSelected = found->second; } else { // First iteration - zCell = fvpDetInterface[L1DetectorID::kTof]->GetZrefModule(pExtPoint->GetDetectorID()); + zCell = fvpDetInterface[ca::EDetectorID::kTof]->GetZrefModule(pExtPoint->GetDetectorID()); zDist = std::fabs(zCell - pExtPoint->GetZ()); iPointSelected = iP; } @@ -414,7 +424,7 @@ void MCModule::ReadMCPointsForDetector<L1DetectorID::kTof>() } // Add the last point if (iPointSelected != -1) { - auto oPoint = FillMCPoint<L1DetectorID::kTof>(iPointSelected, iEvent, iFile); + auto oPoint = FillMCPoint<ca::EDetectorID::kTof>(iPointSelected, iEvent, iFile); if (oPoint) { fpMCData->AddPoint(*oPoint); } } } @@ -432,16 +442,16 @@ void MCModule::ReadMCPoints() 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); } - fpMCData->SetNofPointsOrig(static_cast<L1DetectorID>(iD), vNofPointsDet[iD]); + fpMCData->SetNofPointsOrig(static_cast<ca::EDetectorID>(iD), vNofPointsDet[iD]); } } // ----- Read MC points in MVD, STS, MuCh, TRD and TOF - if (fvbUseDet[L1DetectorID::kMvd]) { this->ReadMCPointsForDetector<L1DetectorID::kMvd>(); } - if (fvbUseDet[L1DetectorID::kSts]) { this->ReadMCPointsForDetector<L1DetectorID::kSts>(); } - if (fvbUseDet[L1DetectorID::kMuch]) { this->ReadMCPointsForDetector<L1DetectorID::kMuch>(); } - if (fvbUseDet[L1DetectorID::kTrd]) { this->ReadMCPointsForDetector<L1DetectorID::kTrd>(); } - if (fvbUseDet[L1DetectorID::kTof]) { this->ReadMCPointsForDetector<L1DetectorID::kTof>(); } + if (fvbUseDet[ca::EDetectorID::kMvd]) { this->ReadMCPointsForDetector<ca::EDetectorID::kMvd>(); } + if (fvbUseDet[ca::EDetectorID::kSts]) { this->ReadMCPointsForDetector<ca::EDetectorID::kSts>(); } + if (fvbUseDet[ca::EDetectorID::kMuch]) { this->ReadMCPointsForDetector<ca::EDetectorID::kMuch>(); } + if (fvbUseDet[ca::EDetectorID::kTrd]) { this->ReadMCPointsForDetector<ca::EDetectorID::kTrd>(); } + if (fvbUseDet[ca::EDetectorID::kTof]) { this->ReadMCPointsForDetector<ca::EDetectorID::kTof>(); } } // --------------------------------------------------------------------------------------------------------------------- diff --git a/reco/L1/CbmCaMCModule.h b/reco/L1/CbmCaMCModule.h index d594821301..7885be82cf 100644 --- a/reco/L1/CbmCaMCModule.h +++ b/reco/L1/CbmCaMCModule.h @@ -107,7 +107,7 @@ namespace cbm::ca /// /// This method finds a match for a given hit or matches for hits clusters (in case of STS), finds the best /// link in the match and returns the corresponding global ID of the MC points. - template<L1DetectorID DetId> + template<ca::EDetectorID DetId> std::tuple<int, std::vector<int>> MatchHitWithMc(int iHitExt); /// @brief Match reconstructed and MC data @@ -132,7 +132,7 @@ namespace cbm::ca /// @param detID Id of detector /// @param flag Flag: true - detector is used /// @note Should be called before this->Init() - void SetDetector(L1DetectorID detID, bool flag) { fvbUseDet[detID] = flag; } + void SetDetector(ca::EDetectorID detID, bool flag) { fvbUseDet[detID] = flag; } /// @brief Sets legacy event mode: /// @param flag Flag: @@ -179,7 +179,7 @@ namespace cbm::ca /// @tparam DetID Index of the detector /// /// Writes indexes of MC points to each hit and indexes of hits to each MC point. - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> void MatchPointsAndHits(); /// @brief Matches reconstructed tracks with MC tracks @@ -199,7 +199,7 @@ namespace cbm::ca void ReadMCPoints(); /// @brief Reads MC points in particular detector - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> void ReadMCPointsForDetector(); /// @brief Fills a single detector-specific MC point @@ -210,7 +210,7 @@ namespace cbm::ca /// @param[out] intMCPoint Reference to the internal tracking MC point object (ca::tools::MCData) /// @return true Point is correct and is to be saved to the MCData object /// @return false Point is incorrect and will be ignored - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> std::optional<tools::MCPoint> FillMCPoint(int iExtId, int iEvent, int iFile); /// @enum EMonitorKey @@ -273,7 +273,7 @@ namespace cbm::ca // ------------------------------------------------------------------------------------------------------------------- // - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> std::tuple<int, std::vector<int>> MCModule::MatchHitWithMc(int iHitExt) { int iPoint = -1; @@ -281,17 +281,17 @@ namespace cbm::ca const auto* pHitMatch = dynamic_cast<CbmMatch*>(fvpBrHitMatches[DetID]->At(iHitExt)); if (!pHitMatch) { LOG(warn) << "Hit match with index " << iHitExt << " is missing for " << kDetName[DetID]; - if constexpr (L1DetectorID::kMvd == DetID) { fMonitor.Increment(EMonitorKey::kMissedMatchesMvd); } - else if constexpr (L1DetectorID::kSts == DetID) { + if constexpr (ca::EDetectorID::kMvd == DetID) { fMonitor.Increment(EMonitorKey::kMissedMatchesMvd); } + else if constexpr (ca::EDetectorID::kSts == DetID) { fMonitor.Increment(EMonitorKey::kMissedMatchesSts); } - else if constexpr (L1DetectorID::kMuch == DetID) { + else if constexpr (ca::EDetectorID::kMuch == DetID) { fMonitor.Increment(EMonitorKey::kMissedMatchesMuch); } - else if constexpr (L1DetectorID::kTrd == DetID) { + else if constexpr (ca::EDetectorID::kTrd == DetID) { fMonitor.Increment(EMonitorKey::kMissedMatchesTrd); } - else if constexpr (L1DetectorID::kTof == DetID) { + else if constexpr (ca::EDetectorID::kTof == DetID) { fMonitor.Increment(EMonitorKey::kMissedMatchesTof); } return std::tuple(iPoint, vPoints); @@ -322,7 +322,7 @@ namespace cbm::ca // ------------------------------------------------------------------------------------------------------------------- // - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> std::optional<tools::MCPoint> MCModule::FillMCPoint(int iExtId, int iEvent, int iFile) { auto oPoint = std::make_optional<tools::MCPoint>(); @@ -341,35 +341,35 @@ namespace cbm::ca << ", iEvent = " << iEvent << ", iFile = " << iFile << " does not exist"; return std::nullopt; } - if constexpr (L1DetectorID::kMvd == DetID) { + if constexpr (ca::EDetectorID::kMvd == DetID) { pExtPoint->Position(posIn); pExtPoint->PositionOut(posOut); pExtPoint->Momentum(momIn); pExtPoint->MomentumOut(momOut); } // STS - else if constexpr (L1DetectorID::kSts == DetID) { + else if constexpr (ca::EDetectorID::kSts == DetID) { pExtPoint->Position(posIn); pExtPoint->PositionOut(posOut); pExtPoint->Momentum(momIn); pExtPoint->MomentumOut(momOut); } // MuCh - else if constexpr (L1DetectorID::kMuch == DetID) { + else if constexpr (ca::EDetectorID::kMuch == DetID) { pExtPoint->Position(posIn); pExtPoint->PositionOut(posOut); pExtPoint->Momentum(momIn); pExtPoint->Momentum(momOut); } // TRD - else if constexpr (L1DetectorID::kTrd == DetID) { + else if constexpr (ca::EDetectorID::kTrd == DetID) { pExtPoint->Position(posIn); pExtPoint->PositionOut(posOut); pExtPoint->Momentum(momIn); pExtPoint->MomentumOut(momOut); } // TOF - else if constexpr (L1DetectorID::kTof == DetID) { + else if constexpr (ca::EDetectorID::kTof == DetID) { pExtPoint->Position(posIn); pExtPoint->Position(posOut); pExtPoint->Momentum(momIn); @@ -396,7 +396,7 @@ namespace cbm::ca // ----- Reject MC points falling out of the time slice // STS, MuCh, TRD, TOF - if constexpr (DetID != L1DetectorID::kMvd) { + if constexpr (DetID != ca::EDetectorID::kMvd) { double startT = fpTimeSlice->GetStartTime(); double endT = fpTimeSlice->GetEndTime(); @@ -462,7 +462,7 @@ namespace cbm::ca // ------------------------------------------------------------------------------------------------------------------- // - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> void MCModule::MatchPointsAndHits() { if (!fvbUseDet[DetID]) { return; } @@ -481,7 +481,7 @@ namespace cbm::ca } // ------------------------------------------------------------------------------------------------------------------- // NOTE: template is used, because another template function FillMCPoint is used inside - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> void MCModule::ReadMCPointsForDetector() { for (const auto& [iFile, iEvent] : fFileEventIDs) { diff --git a/reco/L1/CbmCaTimeSliceReader.cxx b/reco/L1/CbmCaTimeSliceReader.cxx index 1c252993d1..1dc4b5cbde 100644 --- a/reco/L1/CbmCaTimeSliceReader.cxx +++ b/reco/L1/CbmCaTimeSliceReader.cxx @@ -74,7 +74,7 @@ void TimeSliceReader::CheckInit() const if (!fpBrTimeSlice) { throw std::logic_error("Time slice branch is unavailable"); } - for (int iDet = 0; iDet < static_cast<int>(L1DetectorID::kEND); ++iDet) { + for (int iDet = 0; iDet < static_cast<int>(ca::EDetectorID::kEND); ++iDet) { if (fvbUseDet[iDet] && !fvpBrHits[iDet]) { throw std::logic_error(std::string(kDetName[iDet]) + " hits branch is not found"); } @@ -86,12 +86,18 @@ void TimeSliceReader::CheckInit() const } else if (ECbmCaTrackingMode::kMCBM == fTrackingMode) { if (!fpBrRecoTracks) { throw std::logic_error("GlobalTrack branch is unavailable"); } - if (fvbUseDet[L1DetectorID::kSts] && !fpBrStsTracks) { throw std::logic_error("StsTrack branch is not found"); } - if (fvbUseDet[L1DetectorID::kMuch] && !fpBrMuchTracks) { + if (fvbUseDet[ca::EDetectorID::kSts] && !fpBrStsTracks) { + throw std::logic_error("StsTrack branch is not found"); + } + if (fvbUseDet[ca::EDetectorID::kMuch] && !fpBrMuchTracks) { throw std::logic_error("MuchTrack branch is not found"); } - if (fvbUseDet[L1DetectorID::kTrd] && !fpBrRecoTracks) { throw std::logic_error("TrdTrack branch is not found"); } - if (fvbUseDet[L1DetectorID::kTof] && !fpBrRecoTracks) { throw std::logic_error("TofTrack branch is not found"); } + if (fvbUseDet[ca::EDetectorID::kTrd] && !fpBrRecoTracks) { + throw std::logic_error("TrdTrack branch is not found"); + } + if (fvbUseDet[ca::EDetectorID::kTof] && !fpBrRecoTracks) { + throw std::logic_error("TofTrack branch is not found"); + } } } } @@ -103,11 +109,11 @@ try { LOG(info) << "TimeSliceReader: initializing run ... "; // Init tracking detector interfaces - fvpDetInterface[L1DetectorID::kMvd] = CbmMvdTrackingInterface::Instance(); - fvpDetInterface[L1DetectorID::kSts] = CbmStsTrackingInterface::Instance(); - fvpDetInterface[L1DetectorID::kMuch] = CbmMuchTrackingInterface::Instance(); - fvpDetInterface[L1DetectorID::kTrd] = CbmTrdTrackingInterface::Instance(); - fvpDetInterface[L1DetectorID::kTof] = CbmTofTrackingInterface::Instance(); + fvpDetInterface[ca::EDetectorID::kMvd] = CbmMvdTrackingInterface::Instance(); + fvpDetInterface[ca::EDetectorID::kSts] = CbmStsTrackingInterface::Instance(); + fvpDetInterface[ca::EDetectorID::kMuch] = CbmMuchTrackingInterface::Instance(); + fvpDetInterface[ca::EDetectorID::kTrd] = CbmTrdTrackingInterface::Instance(); + fvpDetInterface[ca::EDetectorID::kTof] = CbmTofTrackingInterface::Instance(); // ** Init data branches ** @@ -117,15 +123,15 @@ try { fpBrTimeSlice = dynamic_cast<CbmTimeSlice*>(pFairManager->GetObject("TimeSlice.")); // Init branches - auto InitHitBranch = [&](L1DetectorID detID, const char* branchName) { + auto InitHitBranch = [&](ca::EDetectorID detID, const char* branchName) { if (fvbUseDet[detID]) { fvpBrHits[detID] = dynamic_cast<TClonesArray*>(pFairManager->GetObject(branchName)); } }; - InitHitBranch(L1DetectorID::kMvd, "MvdHit"); - InitHitBranch(L1DetectorID::kSts, "StsHit"); - InitHitBranch(L1DetectorID::kMuch, "MuchPixelHit"); - InitHitBranch(L1DetectorID::kTrd, "TrdHit"); - InitHitBranch(L1DetectorID::kTof, "TofHit"); + InitHitBranch(ca::EDetectorID::kMvd, "MvdHit"); + InitHitBranch(ca::EDetectorID::kSts, "StsHit"); + InitHitBranch(ca::EDetectorID::kMuch, "MuchPixelHit"); + InitHitBranch(ca::EDetectorID::kTrd, "TrdHit"); + InitHitBranch(ca::EDetectorID::kTof, "TofHit"); // Init track branches @@ -136,16 +142,16 @@ try { break; case ECbmCaTrackingMode::kMCBM: fpBrRecoTracks = dynamic_cast<TClonesArray*>(pFairManager->GetObject("GlobalTrack")); - if (fvbUseDet[L1DetectorID::kSts]) { + if (fvbUseDet[ca::EDetectorID::kSts]) { fpBrStsTracks = dynamic_cast<TClonesArray*>(pFairManager->GetObject("StsTrack")); } - if (fvbUseDet[L1DetectorID::kMuch]) { + if (fvbUseDet[ca::EDetectorID::kMuch]) { fpBrMuchTracks = dynamic_cast<TClonesArray*>(pFairManager->GetObject("MuchTrack")); } - if (fvbUseDet[L1DetectorID::kTrd]) { + if (fvbUseDet[ca::EDetectorID::kTrd]) { fpBrTrdTracks = dynamic_cast<TClonesArray*>(pFairManager->GetObject("TrdTrack")); } - if (fvbUseDet[L1DetectorID::kTof]) { + if (fvbUseDet[ca::EDetectorID::kTof]) { fpBrTofTracks = dynamic_cast<TClonesArray*>(pFairManager->GetObject("TofTrack")); } break; @@ -210,12 +216,12 @@ void TimeSliceReader::ReadRecoTracks() track.Hits.reserve(pInputTrack->GetNofHits()); for (int iH = 0; iH < pInputTrack->GetNofMvdHits(); ++iH) { int iHext = pInputTrack->GetMvdHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[L1DetectorID::kMvd][iHext]; + int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kMvd][iHext]; track.Hits.push_back(iHint); } // iH for (int iH = 0; iH < pInputTrack->GetNofStsHits(); ++iH) { int iHext = pInputTrack->GetStsHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[L1DetectorID::kSts][iHext]; + int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kSts][iHext]; track.Hits.push_back(iHint); } // iH } // iT @@ -234,63 +240,63 @@ void TimeSliceReader::ReadRecoTracks() // ** Fill information from local tracks ** // STS tracks (+ MVD) - if (fvbUseDet[L1DetectorID::kSts]) { + if (fvbUseDet[ca::EDetectorID::kSts]) { int iStsTrkId = pInputTrack->GetStsTrackIndex(); if (iStsTrkId > -1) { auto* pStsTrack = static_cast<CbmStsTrack*>(fpBrStsTracks->At(iStsTrkId)); - if (fvbUseDet[L1DetectorID::kMvd]) { + if (fvbUseDet[ca::EDetectorID::kMvd]) { for (int iH = 0; iH < pStsTrack->GetNofMvdHits(); ++iH) { int iHext = pStsTrack->GetMvdHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[L1DetectorID::kMvd][iHext]; + int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kMvd][iHext]; track.Hits.push_back(iHint); } } for (int iH = 0; iH < pStsTrack->GetNofStsHits(); ++iH) { int iHext = pStsTrack->GetStsHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[L1DetectorID::kSts][iHext]; + int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kSts][iHext]; track.Hits.push_back(iHint); } } } // MUCH tracks - if (fvbUseDet[L1DetectorID::kMuch]) { + if (fvbUseDet[ca::EDetectorID::kMuch]) { int iMuchTrkId = pInputTrack->GetMuchTrackIndex(); if (iMuchTrkId > -1) { auto* pMuchTrack = static_cast<CbmMuchTrack*>(fpBrMuchTracks->At(iMuchTrkId)); for (int iH = 0; iH < pMuchTrack->GetNofHits(); ++iH) { int iHext = pMuchTrack->GetHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[L1DetectorID::kMuch][iHext]; + int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kMuch][iHext]; track.Hits.push_back(iHint); } } } // TRD tracks - if (fvbUseDet[L1DetectorID::kTrd]) { + if (fvbUseDet[ca::EDetectorID::kTrd]) { int iTrdTrkId = pInputTrack->GetTrdTrackIndex(); if (iTrdTrkId > -1) { const auto* pTrdTrack = static_cast<const CbmTrdTrack*>(fpBrTrdTracks->At(iTrdTrkId)); for (int iH = 0; iH < pTrdTrack->GetNofHits(); ++iH) { int iHext = pTrdTrack->GetHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[L1DetectorID::kTrd][iHext]; + int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kTrd][iHext]; track.Hits.push_back(iHint); } // iH } } // TOF tracks - if (fvbUseDet[L1DetectorID::kTof]) { + if (fvbUseDet[ca::EDetectorID::kTof]) { int iTofTrkId = pInputTrack->GetTofTrackIndex(); if (iTofTrkId > -1) { const auto* pTofTrack = static_cast<const CbmTofTrack*>(fpBrTofTracks->At(iTofTrkId)); for (int iH = 0; iH < pTofTrack->GetNofHits(); ++iH) { int iHext = pTofTrack->GetHitIndex(iH); - int iHint = fvvHitExtToIntIndexMap[L1DetectorID::kTof][iHext]; + int iHint = fvvHitExtToIntIndexMap[ca::EDetectorID::kTof][iHext]; track.Hits.push_back(iHint); } // iH } // if iTofTrkId > -1 - } // if fvbUseDet[L1DetectorID::kTof] + } // if fvbUseDet[ca::EDetectorID::kTof] } // iT break; } @@ -337,7 +343,7 @@ void TimeSliceReader::ReadHits() fFirstHitKey = 0; // TODO: Address case with CbmEvent != nullptr - for (int iDet = 0; iDet < static_cast<int>(L1DetectorID::kEND); ++iDet) { + for (int iDet = 0; iDet < static_cast<int>(ca::EDetectorID::kEND); ++iDet) { if (fvbUseDet[iDet]) { fvNofHitsTotal[iDet] = fvpBrHits[iDet]->GetEntriesFast(); } } @@ -357,11 +363,11 @@ void TimeSliceReader::ReadHits() std::fill(fvHitFirstIndexDet.begin(), fvHitFirstIndexDet.end(), 0); // Read hits for different detectors - fvNofHitsUsed[L1DetectorID::kMvd] = ReadHitsForDetector<L1DetectorID::kMvd>(); - fvNofHitsUsed[L1DetectorID::kSts] = ReadHitsForDetector<L1DetectorID::kSts>(); - fvNofHitsUsed[L1DetectorID::kMuch] = ReadHitsForDetector<L1DetectorID::kMuch>(); - fvNofHitsUsed[L1DetectorID::kTrd] = ReadHitsForDetector<L1DetectorID::kTrd>(); - fvNofHitsUsed[L1DetectorID::kTof] = ReadHitsForDetector<L1DetectorID::kTof>(); + fvNofHitsUsed[ca::EDetectorID::kMvd] = ReadHitsForDetector<ca::EDetectorID::kMvd>(); + fvNofHitsUsed[ca::EDetectorID::kSts] = ReadHitsForDetector<ca::EDetectorID::kSts>(); + fvNofHitsUsed[ca::EDetectorID::kMuch] = ReadHitsForDetector<ca::EDetectorID::kMuch>(); + fvNofHitsUsed[ca::EDetectorID::kTrd] = ReadHitsForDetector<ca::EDetectorID::kTrd>(); + fvNofHitsUsed[ca::EDetectorID::kTof] = ReadHitsForDetector<ca::EDetectorID::kTof>(); // Save first hit index for different detector subsystems for (uint32_t iDet = 0; iDet < fvNofHitsUsed.size(); ++iDet) { diff --git a/reco/L1/CbmCaTimeSliceReader.h b/reco/L1/CbmCaTimeSliceReader.h index ef1129f955..beccd07282 100644 --- a/reco/L1/CbmCaTimeSliceReader.h +++ b/reco/L1/CbmCaTimeSliceReader.h @@ -80,7 +80,7 @@ namespace cbm::ca /// @brief Gets number of hits stored for a given detector /// @param iDet Detector ID /// @return Number of hits - int GetNofHits(L1DetectorID iDet) const + int GetNofHits(ca::EDetectorID iDet) const { return fvHitFirstIndexDet[int(iDet) + 1] - fvHitFirstIndexDet[int(iDet)]; } @@ -127,7 +127,7 @@ namespace cbm::ca /// @param detID Id of detector /// @param flag Flag: true - detector is used /// @note Should be called before this->Init() - void SetDetector(L1DetectorID detID, bool flag = true) { fvbUseDet[detID] = flag; } + void SetDetector(ca::EDetectorID detID, bool flag = true) { fvbUseDet[detID] = flag; } /// @brief Sets the tracking mode /// @param mode Tracking mode (from ECbmTrackingMode) @@ -149,7 +149,7 @@ namespace cbm::ca /// @tparam Detector ID /// @return Number of stored hits /// @note The function modifies fNofHitKey and fFirstHitKey counters - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> int ReadHitsForDetector(); /// @brief Sorts QA hit objects by stations @@ -210,7 +210,7 @@ namespace cbm::ca // --------------------------------------------------------------------------------------------------------------------- // -template<L1DetectorID DetID> +template<ca::EDetectorID DetID> int cbm::ca::TimeSliceReader::ReadHitsForDetector() { if (!fvbUseDet[DetID]) { return 0; } // Detector is entirelly not used @@ -228,29 +228,29 @@ int cbm::ca::TimeSliceReader::ReadHitsForDetector() int iStGeom = -1; // Geometry station number // Fill out detector specific data - if constexpr (L1DetectorID::kMvd == DetID) { + if constexpr (ca::EDetectorID::kMvd == DetID) { CbmMvdHit* pMvdHit = static_cast<CbmMvdHit*>(fvpBrHits[DetID]->At(iHext)); pPixelHit = static_cast<CbmPixelHit*>(pMvdHit); iStGeom = pDetInterface->GetTrackingStationIndex(pMvdHit); } - else if constexpr (L1DetectorID::kSts == DetID) { + else if constexpr (ca::EDetectorID::kSts == DetID) { CbmStsHit* pStsHit = static_cast<CbmStsHit*>(fvpBrHits[DetID]->At(iHext)); pPixelHit = static_cast<CbmPixelHit*>(pStsHit); iStGeom = pDetInterface->GetTrackingStationIndex(pStsHit->GetAddress()); hitRecord.fStripF = fFirstHitKey + pStsHit->GetFrontClusterId(); hitRecord.fStripB = fFirstHitKey + pStsHit->GetBackClusterId(); } - else if constexpr (L1DetectorID::kMuch == DetID) { + else if constexpr (ca::EDetectorID::kMuch == DetID) { CbmMuchPixelHit* pMuchHit = static_cast<CbmMuchPixelHit*>(fvpBrHits[DetID]->At(iHext)); pPixelHit = static_cast<CbmPixelHit*>(pMuchHit); iStGeom = pDetInterface->GetTrackingStationIndex(pMuchHit->GetAddress()); } - else if constexpr (L1DetectorID::kTrd == DetID) { + else if constexpr (ca::EDetectorID::kTrd == DetID) { CbmTrdHit* pTrdHit = static_cast<CbmTrdHit*>(fvpBrHits[DetID]->At(iHext)); pPixelHit = static_cast<CbmPixelHit*>(pTrdHit); iStGeom = pDetInterface->GetTrackingStationIndex(pTrdHit->GetAddress()); } - else if constexpr (L1DetectorID::kTof == DetID) { + else if constexpr (ca::EDetectorID::kTof == DetID) { CbmTofHit* pTofHit = static_cast<CbmTofHit*>(fvpBrHits[DetID]->At(iHext)); pPixelHit = static_cast<CbmPixelHit*>(pTofHit); // NOTE: In TOF we can take station index only from hit, because the function needs information on x and z @@ -287,7 +287,7 @@ int cbm::ca::TimeSliceReader::ReadHitsForDetector() hitRecord.fExtId = iHext; // Update number of hit keys - if constexpr (L1DetectorID::kSts == DetID) { + if constexpr (ca::EDetectorID::kSts == DetID) { if (fNofHitKeys <= hitRecord.fStripF) { fNofHitKeys += hitRecord.fStripF; } if (fNofHitKeys <= hitRecord.fStripB) { fNofHitKeys += hitRecord.fStripB; } } diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 6170ab02b6..4853609d44 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -140,9 +140,9 @@ void CbmL1::CheckDetectorPresence() // --------------------------------------------------------------------------------------------------------------------- // -void CbmL1::DisableTrackingStation(L1DetectorID detID, int iSt) +void CbmL1::DisableTrackingStation(ca::EDetectorID detID, int iSt) { - if (L1DetectorID::kEND != detID) { fvmDisabledStationIDs[detID].insert(iSt); } + if (ca::EDetectorID::kEND != detID) { fvmDisabledStationIDs[detID].insert(iSt); } } // --------------------------------------------------------------------------------------------------------------------- @@ -361,11 +361,11 @@ InitStatus CbmL1::Init() if (2 == fSTAPDataMode) { this->ReadSTAPParamObject(); - fNMvdStationsGeom = fInitManager.GetNstationsGeometry(L1DetectorID::kMvd); - fNStsStationsGeom = fInitManager.GetNstationsGeometry(L1DetectorID::kSts); - fNTrdStationsGeom = fInitManager.GetNstationsGeometry(L1DetectorID::kTrd); - fNMuchStationsGeom = fInitManager.GetNstationsGeometry(L1DetectorID::kMuch); - fNTofStationsGeom = fInitManager.GetNstationsGeometry(L1DetectorID::kTof); + fNMvdStationsGeom = fInitManager.GetNstationsGeometry(ca::EDetectorID::kMvd); + fNStsStationsGeom = fInitManager.GetNstationsGeometry(ca::EDetectorID::kSts); + fNTrdStationsGeom = fInitManager.GetNstationsGeometry(ca::EDetectorID::kTrd); + fNMuchStationsGeom = fInitManager.GetNstationsGeometry(ca::EDetectorID::kMuch); + fNTofStationsGeom = fInitManager.GetNstationsGeometry(ca::EDetectorID::kTof); fNStationsGeom = fInitManager.GetNstationsGeometry(); } // Parameters initialization, based on the FairRunAna chain @@ -391,7 +391,7 @@ InitStatus CbmL1::Init() } fInitManager.SetDetectorNames(cbm::ca::kDetName); - L1_SHOW(fInitManager.GetDetectorName(L1DetectorID::kSts)); + L1_SHOW(fInitManager.GetDetectorName(ca::EDetectorID::kSts)); auto mvdInterface = CbmMvdTrackingInterface::Instance(); auto stsInterface = CbmStsTrackingInterface::Instance(); @@ -450,27 +450,27 @@ InitStatus CbmL1::Init() // ** Active tracking detector subsystems selection ** // *************************************************** - std::set<L1DetectorID> vActiveTrackingDetectorIDs {}; // Set of detectors active in tracking + std::set<ca::EDetectorID> vActiveTrackingDetectorIDs {}; // Set of detectors active in tracking - if (fUseMVD) { vActiveTrackingDetectorIDs.insert(L1DetectorID::kMvd); } - if (fUseSTS) { vActiveTrackingDetectorIDs.insert(L1DetectorID::kSts); } - if (fUseMUCH) { vActiveTrackingDetectorIDs.insert(L1DetectorID::kMuch); } - if (fUseTRD) { vActiveTrackingDetectorIDs.insert(L1DetectorID::kTrd); } - if (fUseTOF) { vActiveTrackingDetectorIDs.insert(L1DetectorID::kTof); } + if (fUseMVD) { vActiveTrackingDetectorIDs.insert(ca::EDetectorID::kMvd); } + if (fUseSTS) { vActiveTrackingDetectorIDs.insert(ca::EDetectorID::kSts); } + if (fUseMUCH) { vActiveTrackingDetectorIDs.insert(ca::EDetectorID::kMuch); } + if (fUseTRD) { vActiveTrackingDetectorIDs.insert(ca::EDetectorID::kTrd); } + if (fUseTOF) { vActiveTrackingDetectorIDs.insert(ca::EDetectorID::kTof); } fInitManager.SetActiveDetectorIDs(vActiveTrackingDetectorIDs); // ************************************* // ** Stations layout initialization ** // ************************************* - std::vector<L1BaseStationInfo> vStations; + std::vector<ca::StationInitializer> vStations; vStations.reserve(100); // *** MVD stations info *** if (fUseMVD) { for (int iSt = 0; iSt < fNMvdStationsGeom; ++iSt) { - auto stationInfo = L1BaseStationInfo(L1DetectorID::kMvd, iSt); - // TODO: SZh 15.08.2022: Replace station type with L1DetectorID + auto stationInfo = ca::StationInitializer(ca::EDetectorID::kMvd, iSt); + // TODO: SZh 15.08.2022: Replace station type with ca::EDetectorID stationInfo.SetStationType(1); // MVD stationInfo.SetTimeInfo(mvdInterface->IsTimeInfoProvided(iSt)); stationInfo.SetFieldStatus(fTrackingMode == L1Algo::TrackingMode::kMcbm ? 0 : 1); @@ -480,7 +480,8 @@ InitStatus CbmL1::Init() stationInfo.SetXmax(mvdInterface->GetXmax(iSt)); stationInfo.SetYmax(mvdInterface->GetYmax(iSt)); stationInfo.SetTrackingStatus(true); - if (fvmDisabledStationIDs[L1DetectorID::kMvd].find(iSt) != fvmDisabledStationIDs[L1DetectorID::kMvd].cend()) { + if (fvmDisabledStationIDs[ca::EDetectorID::kMvd].find(iSt) + != fvmDisabledStationIDs[ca::EDetectorID::kMvd].cend()) { stationInfo.SetTrackingStatus(false); } fInitManager.AddStation(stationInfo); @@ -491,8 +492,8 @@ InitStatus CbmL1::Init() // *** STS stations info *** if (fUseSTS) { for (int iSt = 0; iSt < fNStsStationsGeom; ++iSt) { - auto stationInfo = L1BaseStationInfo(L1DetectorID::kSts, iSt); - // TODO: SZh 15.08.2022: Replace station type with L1DetectorID + auto stationInfo = ca::StationInitializer(ca::EDetectorID::kSts, iSt); + // TODO: SZh 15.08.2022: Replace station type with ca::EDetectorID stationInfo.SetStationType(0); // STS stationInfo.SetTimeInfo(stsInterface->IsTimeInfoProvided(iSt)); stationInfo.SetTimeInfo(L1Algo::TrackingMode::kMcbm != fTrackingMode ? stsInterface->IsTimeInfoProvided(iSt) @@ -505,7 +506,8 @@ InitStatus CbmL1::Init() stationInfo.SetYmax(stsInterface->GetYmax(iSt)); stationInfo.SetTrackingStatus(true); - if (fvmDisabledStationIDs[L1DetectorID::kSts].find(iSt) != fvmDisabledStationIDs[L1DetectorID::kSts].cend()) { + if (fvmDisabledStationIDs[ca::EDetectorID::kSts].find(iSt) + != fvmDisabledStationIDs[ca::EDetectorID::kSts].cend()) { stationInfo.SetTrackingStatus(false); } fInitManager.AddStation(stationInfo); @@ -516,8 +518,8 @@ InitStatus CbmL1::Init() // *** MuCh stations info *** if (fUseMUCH) { for (int iSt = 0; iSt < fNMuchStationsGeom; ++iSt) { - auto stationInfo = L1BaseStationInfo(L1DetectorID::kMuch, iSt); - // TODO: SZh 15.08.2022: Replace station type with L1DetectorID + auto stationInfo = ca::StationInitializer(ca::EDetectorID::kMuch, iSt); + // TODO: SZh 15.08.2022: Replace station type with ca::EDetectorID stationInfo.SetStationType(2); // MuCh stationInfo.SetTimeInfo(muchInterface->IsTimeInfoProvided(iSt)); stationInfo.SetTimeInfo(L1Algo::TrackingMode::kMcbm != fTrackingMode ? stsInterface->IsTimeInfoProvided(iSt) @@ -530,7 +532,8 @@ InitStatus CbmL1::Init() stationInfo.SetYmax(muchInterface->GetYmax(iSt)); stationInfo.SetTrackingStatus(true); - if (fvmDisabledStationIDs[L1DetectorID::kMuch].find(iSt) != fvmDisabledStationIDs[L1DetectorID::kMuch].cend()) { + if (fvmDisabledStationIDs[ca::EDetectorID::kMuch].find(iSt) + != fvmDisabledStationIDs[ca::EDetectorID::kMuch].cend()) { stationInfo.SetTrackingStatus(false); } fInitManager.AddStation(stationInfo); @@ -541,8 +544,8 @@ InitStatus CbmL1::Init() // *** TRD stations info *** if (fUseTRD) { for (int iSt = 0; iSt < fNTrdStationsGeom; ++iSt) { - auto stationInfo = L1BaseStationInfo(L1DetectorID::kTrd, iSt); - // TODO: SZh 15.08.2022: Replace station type with L1DetectorID + auto stationInfo = ca::StationInitializer(ca::EDetectorID::kTrd, iSt); + // TODO: SZh 15.08.2022: Replace station type with ca::EDetectorID stationInfo.SetStationType((iSt == 1 || iSt == 3) ? 6 : 3); // MuCh stationInfo.SetTimeInfo(trdInterface->IsTimeInfoProvided(iSt)); stationInfo.SetTimeInfo(L1Algo::TrackingMode::kMcbm != fTrackingMode ? stsInterface->IsTimeInfoProvided(iSt) @@ -556,7 +559,8 @@ InitStatus CbmL1::Init() if (L1Algo::TrackingMode::kGlobal == fTrackingMode) { stationInfo.SetTimeInfo(false); } stationInfo.SetTrackingStatus(true); - if (fvmDisabledStationIDs[L1DetectorID::kTrd].find(iSt) != fvmDisabledStationIDs[L1DetectorID::kTrd].cend()) { + if (fvmDisabledStationIDs[ca::EDetectorID::kTrd].find(iSt) + != fvmDisabledStationIDs[ca::EDetectorID::kTrd].cend()) { stationInfo.SetTrackingStatus(false); } fInitManager.AddStation(stationInfo); @@ -567,8 +571,8 @@ InitStatus CbmL1::Init() // *** TOF stations info *** if (fUseTOF) { for (int iSt = 0; iSt < fNTofStationsGeom; ++iSt) { - auto stationInfo = L1BaseStationInfo(L1DetectorID::kTof, iSt); - // TODO: SZh 15.08.2022: Replace station type with L1DetectorID + auto stationInfo = ca::StationInitializer(ca::EDetectorID::kTof, iSt); + // TODO: SZh 15.08.2022: Replace station type with ca::EDetectorID stationInfo.SetStationType(4); stationInfo.SetTimeInfo(tofInterface->IsTimeInfoProvided(iSt)); stationInfo.SetTimeInfo(L1Algo::TrackingMode::kMcbm != fTrackingMode ? stsInterface->IsTimeInfoProvided(iSt) @@ -581,7 +585,8 @@ InitStatus CbmL1::Init() stationInfo.SetYmax(tofInterface->GetYmax(iSt)); stationInfo.SetTrackingStatus(true); - if (fvmDisabledStationIDs[L1DetectorID::kTof].find(iSt) != fvmDisabledStationIDs[L1DetectorID::kTof].cend()) { + if (fvmDisabledStationIDs[ca::EDetectorID::kTof].find(iSt) + != fvmDisabledStationIDs[ca::EDetectorID::kTof].cend()) { stationInfo.SetTrackingStatus(false); } fInitManager.AddStation(stationInfo); @@ -643,15 +648,15 @@ InitStatus CbmL1::Init() // // ** Send formed parameters object to L1Algo instance ** // - fInitManager.SendParameters(fpAlgo); + fpAlgo->ReceiveParameters(fInitManager.TakeParameters()); /*** Get numbers of active stations ***/ - fNMvdStations = fpAlgo->GetParameters()->GetNstationsActive(L1DetectorID::kMvd); - fNStsStations = fpAlgo->GetParameters()->GetNstationsActive(L1DetectorID::kSts); - fNTrdStations = fpAlgo->GetParameters()->GetNstationsActive(L1DetectorID::kTrd); - fNMuchStations = fpAlgo->GetParameters()->GetNstationsActive(L1DetectorID::kMuch); - fNTofStations = fpAlgo->GetParameters()->GetNstationsActive(L1DetectorID::kTof); + fNMvdStations = fpAlgo->GetParameters()->GetNstationsActive(ca::EDetectorID::kMvd); + fNStsStations = fpAlgo->GetParameters()->GetNstationsActive(ca::EDetectorID::kSts); + fNTrdStations = fpAlgo->GetParameters()->GetNstationsActive(ca::EDetectorID::kTrd); + fNMuchStations = fpAlgo->GetParameters()->GetNstationsActive(ca::EDetectorID::kMuch); + fNTofStations = fpAlgo->GetParameters()->GetNstationsActive(ca::EDetectorID::kTof); fNStations = fpAlgo->GetParameters()->GetNstationsActive(); LOG(info) << fpAlgo->GetParameters()->ToString(1); diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index 04db5f3127..447a8ebaf8 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -53,12 +53,12 @@ #include <utility> #include "AlgoFairloggerCompat.h" +#include "CaInitManager.h" #include "CaMonitor.h" #include "CaVector.h" #include "L1Algo/L1Algo.h" #include "L1EventEfficiencies.h" #include "L1IODataManager.h" -#include "L1InitManager.h" #include "L1MaterialMonitor.h" class L1Algo; @@ -198,7 +198,7 @@ public: /// @param iSt Index of station in tracking station interface /// /// Possible entries of Detector ID are listed in CbmL1DetectorID.h. - void DisableTrackingStation(L1DetectorID detID, int iSt); + void DisableTrackingStation(ca::EDetectorID detID, int iSt); /// Sets safe but slow material initialisation to get around potential problems in TGeoVoxelFinder /// (use it only in case of a crash at the initialisation of material maps) @@ -244,15 +244,15 @@ public: bool GetCorrectHitsOnMC() const { return fIfCorrectHitsOnMC; } /// Utility to map the L1DetectorID items into detector names - static constexpr const char* GetDetectorName(L1DetectorID detectorID) + static constexpr const char* GetDetectorName(ca::EDetectorID detectorID) { switch (detectorID) { - case L1DetectorID::kMvd: return "MVD"; - case L1DetectorID::kSts: return "STS"; - case L1DetectorID::kMuch: return "MuCh"; - case L1DetectorID::kTrd: return "TRD"; - case L1DetectorID::kTof: return "TOF"; - case L1DetectorID::kEND: break; + case ca::EDetectorID::kMvd: return "MVD"; + case ca::EDetectorID::kSts: return "STS"; + case ca::EDetectorID::kMuch: return "MuCh"; + case ca::EDetectorID::kTrd: return "TRD"; + case ca::EDetectorID::kTof: return "TOF"; + case ca::EDetectorID::kEND: break; } return ""; } @@ -364,7 +364,7 @@ private: /// \param file Index of the input file /// \param event Index of the input event /// \param iPoint Index of the point into the input MC points CbmMCDataArray object for the particular detector - void ReadMCPoint(L1DetectorID det, int iPoint, int file, int event); + void ReadMCPoint(ca::EDetectorID det, int iPoint, int file, int event); // static bool compareZ(const int &a, const int &b ); // bool compareZ(const int &a, const int &b ); @@ -380,7 +380,7 @@ private: /// \tparam DetId Detector ID /// \param iHit External index of hit /// \return MC-point index in fvMCPoints array - template<L1DetectorID DetId> + template<ca::EDetectorID DetId> std::tuple<int, std::vector<int>> MatchHitWithMc(int iHit) const; /// Procedure for match hits and MCPoints. @@ -458,7 +458,7 @@ private: void WriteSIMDKFData(); /// Gets a pointer to L1InitManager (for an access in run_reco.C) - L1InitManager* GetInitManager() { return &fInitManager; } + ca::InitManager* GetInitManager() { return &fInitManager; } /// Get the target information void GetTargetInfo(); @@ -483,7 +483,7 @@ private: // *************************** - L1InitManager fInitManager; ///< Tracking parameters data manager + ca::InitManager fInitManager; ///< Tracking parameters data manager std::shared_ptr<L1IODataManager> fpIODataManager = nullptr; ///< Input-output data manager //std::unique_ptr<CbmCaMCModule> fpMCModule = nullptr; ///< MC-module for tracking @@ -695,28 +695,28 @@ private: // --------------------------------------------------------------------------------------------------------------------- // -template<L1DetectorID DetID> +template<ca::EDetectorID DetID> std::tuple<int, std::vector<int>> CbmL1::MatchHitWithMc(int iHitExt) const { const CbmMatch* pHitMatch = nullptr; int indexShift = 0; // Number of points in detectors, standing in front - if constexpr (L1DetectorID::kMvd == DetID) { + if constexpr (ca::EDetectorID::kMvd == DetID) { pHitMatch = dynamic_cast<CbmMatch*>(fpMvdHitMatches->At(iHitExt)); indexShift = 0; } - else if constexpr (L1DetectorID::kSts == DetID) { + else if constexpr (ca::EDetectorID::kSts == DetID) { pHitMatch = dynamic_cast<CbmMatch*>(fpStsHitMatches->At(iHitExt)); indexShift = fNpointsMvdAll; } - else if constexpr (L1DetectorID::kMuch == DetID) { + else if constexpr (ca::EDetectorID::kMuch == DetID) { pHitMatch = dynamic_cast<CbmMatch*>(fpMuchHitMatches->At(iHitExt)); indexShift = fNpointsMvdAll + fNpointsStsAll; } - else if constexpr (L1DetectorID::kTrd == DetID) { + else if constexpr (ca::EDetectorID::kTrd == DetID) { pHitMatch = dynamic_cast<CbmMatch*>(fpTrdHitMatches->At(iHitExt)); indexShift = fNpointsMvdAll + fNpointsStsAll + fNpointsMuchAll; } - else if constexpr (L1DetectorID::kTof == DetID) { + else if constexpr (ca::EDetectorID::kTof == DetID) { pHitMatch = dynamic_cast<CbmMatch*>(fpTofHitMatches->At(iHitExt)); indexShift = fNpointsMvdAll + fNpointsStsAll + fNpointsMuchAll + fNpointsTrdAll; } diff --git a/reco/L1/CbmL1DetectorID.h b/reco/L1/CbmL1DetectorID.h index 2442de508b..526698b95d 100644 --- a/reco/L1/CbmL1DetectorID.h +++ b/reco/L1/CbmL1DetectorID.h @@ -23,22 +23,23 @@ namespace cbm::ca namespace ca = cbm::algo::ca; ///< CA core namespace (TO BE USED IN CBM-specific interfaces) } // namespace cbm::ca -/// Enumeration for the detector subsystems used in L1 tracking -/// It is important for the subsystems to be specified in the actual order. The order is used -/// for the ca::Station array filling. -/// Note: L1DetectorID has a forward declaration in L1InitManager.h and L1BaseStationInfo.h -/// TODO: Probably, we need to move everything into a single CbmCaConst.h header -/// NOTE: The enumeration must not contain jumps in ordering and the first entry must be equal 0 -enum class L1DetectorID +namespace cbm::algo::ca { - kMvd = 0, - kSts, - kMuch, - kTrd, - kTof, - kEND ///< End of enumeration -}; - + /// \enum cbm::algo::ca::EDetectorID + /// \brief Enumeration for the detector subsystems used in L1 tracking + /// It is important for the subsystems to be specified in the actual order. The order is used + /// for the ca::Station array filling. + /// \note The enumeration must not contain jumps in the ordering and the first entry must be equal 0 + enum class EDetectorID + { + kMvd = 0, + kSts, + kMuch, + kTrd, + kTof, + kEND ///< End of enumeration + }; +} // namespace cbm::algo::ca /// ************************************************* /// ** Detector-dependent common definitions ** @@ -61,7 +62,7 @@ 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 = ca::EnumArray<L1DetectorID, T>; + using DetIdArr_t = ca::EnumArray<ca::EDetectorID, T>; /// @brief List of @@ -75,7 +76,7 @@ namespace cbm::ca /// HitTypes_t::at<L1DetectorID::kSts> hit; // Sts hit template<class... Types> struct DetIdTypeArr_t { - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> using at = std::tuple_element_t<static_cast<std::size_t>(DetID), std::tuple<Types...>>; static constexpr std::size_t size = sizeof...(Types); }; diff --git a/reco/L1/CbmL1ReadEvent.cxx b/reco/L1/CbmL1ReadEvent.cxx index e9f2394170..241bec19da 100644 --- a/reco/L1/CbmL1ReadEvent.cxx +++ b/reco/L1/CbmL1ReadEvent.cxx @@ -228,27 +228,27 @@ void CbmL1::ReadEvent(CbmEvent* event) if (fUseMVD && fpMvdPoints) { Int_t nMC = fpMvdPoints->Size(iFile, iEvent); for (Int_t iMC = 0; iMC < nMC; iMC++) { - ReadMCPoint(L1DetectorID::kMvd, iFile, iEvent, iMC); + ReadMCPoint(ca::EDetectorID::kMvd, iFile, iEvent, iMC); } } if (fUseSTS && fpStsPoints) { Int_t nMC = fpStsPoints->Size(iFile, iEvent); for (Int_t iMC = 0; iMC < nMC; iMC++) { - ReadMCPoint(L1DetectorID::kSts, iFile, iEvent, iMC); + ReadMCPoint(ca::EDetectorID::kSts, iFile, iEvent, iMC); } } if (fUseMUCH && fpMuchPoints) { Int_t nMC = fpMuchPoints->Size(iFile, iEvent); for (Int_t iMC = 0; iMC < nMC; iMC++) { - ReadMCPoint(L1DetectorID::kMuch, iFile, iEvent, iMC); + ReadMCPoint(ca::EDetectorID::kMuch, iFile, iEvent, iMC); } } if (fUseTRD && fpTrdPoints) { for (Int_t iMC = 0; iMC < fpTrdPoints->Size(iFile, iEvent); iMC++) { - ReadMCPoint(L1DetectorID::kTrd, iFile, iEvent, iMC); + ReadMCPoint(ca::EDetectorID::kTrd, iFile, iEvent, iMC); } } @@ -302,7 +302,7 @@ void CbmL1::ReadEvent(CbmEvent* event) int rpcAddr = pExtPoint->GetDetectorID() << kNofBitsRpcAddress; // New point if (rpcAddrCurr != rpcAddr || iTmcCurr != iTmc) { - if (iPointSelected != -1) { ReadMCPoint(L1DetectorID::kTof, iFile, iEvent, iPointSelected); } + if (iPointSelected != -1) { ReadMCPoint(ca::EDetectorID::kTof, iFile, iEvent, iPointSelected); } iTmcCurr = iTmc; rpcAddrCurr = rpcAddr; auto key = std::make_pair(iTmc, rpcAddr); @@ -327,7 +327,7 @@ void CbmL1::ReadEvent(CbmEvent* event) } } // Add the last point - if (iPointSelected != -1) { ReadMCPoint(L1DetectorID::kTof, iFile, iEvent, iPointSelected); } + if (iPointSelected != -1) { ReadMCPoint(ca::EDetectorID::kTof, iFile, iEvent, iPointSelected); } } // iP } } //time_slice @@ -384,7 +384,7 @@ void CbmL1::ReadEvent(CbmEvent* event) { th.ExtIndex = hitIndex; th.iStation = fpAlgo->GetParameters()->GetStationIndexActive( - CbmMvdTrackingInterface::Instance()->GetTrackingStationIndex(h), L1DetectorID::kMvd); + CbmMvdTrackingInterface::Instance()->GetTrackingStationIndex(h), ca::EDetectorID::kMvd); if (th.iStation < 0) continue; @@ -411,7 +411,7 @@ void CbmL1::ReadEvent(CbmEvent* event) std::tie(th.rangeX, th.rangeY, th.rangeT) = CbmMvdTrackingInterface::Instance()->GetHitRanges(*h); } th.Det = 0; - if (fPerformance) { std::tie(th.iBestMc, th.vMc) = MatchHitWithMc<L1DetectorID::kMvd>(hitIndex); } + if (fPerformance) { std::tie(th.iBestMc, th.vMc) = MatchHitWithMc<ca::EDetectorID::kMvd>(hitIndex); } th.fDataStream = (static_cast<int64_t>(th.Det) << 60) | h->GetAddress(); //if( th.iMC >=0 ) // DEBUG !!!! if (th.IfAccept()) { @@ -450,7 +450,7 @@ void CbmL1::ReadEvent(CbmEvent* event) th.Det = 1; th.iStation = fpAlgo->GetParameters()->GetStationIndexActive( - CbmStsTrackingInterface::Instance()->GetTrackingStationIndex(h), L1DetectorID::kSts); + CbmStsTrackingInterface::Instance()->GetTrackingStationIndex(h), ca::EDetectorID::kSts); if (th.iStation < 0) continue; @@ -479,7 +479,7 @@ void CbmL1::ReadEvent(CbmEvent* event) std::tie(th.rangeX, th.rangeY, th.rangeT) = CbmStsTrackingInterface::Instance()->GetHitRanges(*h); } - if (fPerformance) { std::tie(th.iBestMc, th.vMc) = MatchHitWithMc<L1DetectorID::kSts>(hitIndex); } + if (fPerformance) { std::tie(th.iBestMc, th.vMc) = MatchHitWithMc<ca::EDetectorID::kSts>(hitIndex); } th.fDataStream = (static_cast<int64_t>(th.Det) << 60) | h->GetAddress(); if (th.IfAccept()) { @@ -512,7 +512,7 @@ void CbmL1::ReadEvent(CbmEvent* event) th.Det = 2; th.iStation = fpAlgo->GetParameters()->GetStationIndexActive( - CbmMuchTrackingInterface::Instance()->GetTrackingStationIndex(h), L1DetectorID::kMuch); + CbmMuchTrackingInterface::Instance()->GetTrackingStationIndex(h), ca::EDetectorID::kMuch); if (th.iStation < 0) continue; @@ -535,7 +535,7 @@ void CbmL1::ReadEvent(CbmEvent* event) std::tie(th.rangeX, th.rangeY, th.rangeT) = CbmMuchTrackingInterface::Instance()->GetHitRanges(*h); } - if (fPerformance) { std::tie(th.iBestMc, th.vMc) = MatchHitWithMc<L1DetectorID::kMuch>(hitIndex); } + if (fPerformance) { std::tie(th.iBestMc, th.vMc) = MatchHitWithMc<ca::EDetectorID::kMuch>(hitIndex); } th.fDataStream = (static_cast<int64_t>(th.Det) << 60) | h->GetAddress(); if (th.IfAccept()) { tmpHits.push_back(th); @@ -576,7 +576,7 @@ void CbmL1::ReadEvent(CbmEvent* event) th.Det = 3; th.iStation = fpAlgo->GetParameters()->GetStationIndexActive( - CbmTrdTrackingInterface::Instance()->GetTrackingStationIndex(h), L1DetectorID::kTrd); + CbmTrdTrackingInterface::Instance()->GetTrackingStationIndex(h), ca::EDetectorID::kTrd); if (th.iStation < 0) continue; @@ -607,7 +607,7 @@ void CbmL1::ReadEvent(CbmEvent* event) std::tie(th.rangeX, th.rangeY, th.rangeT) = CbmTrdTrackingInterface::Instance()->GetHitRanges(*h); - if (fPerformance) { std::tie(th.iBestMc, th.vMc) = MatchHitWithMc<L1DetectorID::kTrd>(hitIndex); } + if (fPerformance) { std::tie(th.iBestMc, th.vMc) = MatchHitWithMc<ca::EDetectorID::kTrd>(hitIndex); } th.fDataStream = (static_cast<int64_t>(th.Det) << 60) | h->GetAddress(); if (th.IfAccept()) { @@ -646,7 +646,7 @@ void CbmL1::ReadEvent(CbmEvent* event) if (5 == CbmTofAddress::GetSmType(h->GetAddress())) continue; // Skip T0 hits from TOF th.iStation = fpAlgo->GetParameters()->GetStationIndexActive( - CbmTofTrackingInterface::Instance()->GetTrackingStationIndex(h), L1DetectorID::kTof); + CbmTofTrackingInterface::Instance()->GetTrackingStationIndex(h), ca::EDetectorID::kTof); if (th.iStation < 0) continue; @@ -675,7 +675,7 @@ void CbmL1::ReadEvent(CbmEvent* event) //TODO: is it still needed here? (S.Zharko) if (L1Algo::TrackingMode::kMcbm == fTrackingMode && th.z > 400) continue; - if (fPerformance) { std::tie(th.iBestMc, th.vMc) = MatchHitWithMc<L1DetectorID::kTof>(hitIndex); } + if (fPerformance) { std::tie(th.iBestMc, th.vMc) = MatchHitWithMc<ca::EDetectorID::kTof>(hitIndex); } th.fDataStream = (static_cast<int64_t>(th.Det) << 60) | h->GetAddress(); if (th.IfAccept()) { @@ -877,13 +877,13 @@ void CbmL1::Fill_vMCTracks() //-------------------------------------------------------------------------------------------------- // // TODO: Probably, we should reduce code here, rewriting this funciton as a template from CbmMvdPoint (S.Zharko) -void CbmL1::ReadMCPoint(L1DetectorID iDet, int file, int event, int iPoint) +void CbmL1::ReadMCPoint(ca::EDetectorID iDet, int file, int event, int iPoint) { FairMCPoint* fairPoint = nullptr; TVector3 xyzO, PO; int iStLoc = -1; - if (L1DetectorID::kMvd == iDet) { + if (ca::EDetectorID::kMvd == iDet) { CbmMvdPoint* pt = L1_DYNAMIC_CAST<CbmMvdPoint*>(fpMvdPoints->Get(file, event, iPoint)); assert(pt); fairPoint = pt; @@ -892,7 +892,7 @@ void CbmL1::ReadMCPoint(L1DetectorID iDet, int file, int event, int iPoint) iStLoc = CbmMvdTrackingInterface::Instance()->GetTrackingStationIndex(pt); } - if (L1DetectorID::kSts == iDet) { + if (ca::EDetectorID::kSts == iDet) { CbmStsPoint* pt = L1_DYNAMIC_CAST<CbmStsPoint*>(fpStsPoints->Get(file, event, iPoint)); assert(pt); fairPoint = pt; @@ -902,7 +902,7 @@ void CbmL1::ReadMCPoint(L1DetectorID iDet, int file, int event, int iPoint) } - if (L1DetectorID::kMuch == iDet) { + if (ca::EDetectorID::kMuch == iDet) { CbmMuchPoint* pt = L1_DYNAMIC_CAST<CbmMuchPoint*>(fpMuchPoints->Get(file, event, iPoint)); assert(pt); fairPoint = pt; @@ -912,7 +912,7 @@ void CbmL1::ReadMCPoint(L1DetectorID iDet, int file, int event, int iPoint) } - if (L1DetectorID::kTrd == iDet) { + if (ca::EDetectorID::kTrd == iDet) { CbmTrdPoint* pt = L1_DYNAMIC_CAST<CbmTrdPoint*>(fpTrdPoints->Get(file, event, iPoint)); assert(pt); fairPoint = pt; @@ -921,7 +921,7 @@ void CbmL1::ReadMCPoint(L1DetectorID iDet, int file, int event, int iPoint) iStLoc = CbmTrdTrackingInterface::Instance()->GetTrackingStationIndex(pt); } - if (L1DetectorID::kTof == iDet) { + if (ca::EDetectorID::kTof == iDet) { CbmTofPoint* pt = L1_DYNAMIC_CAST<CbmTofPoint*>(fpTofPoints->Get(file, event, iPoint)); assert(pt); fairPoint = pt; @@ -991,27 +991,27 @@ void CbmL1::ReadMCPoint(L1DetectorID iDet, int file, int event, int iPoint) int iPointInt = iPoint; switch (iDet) { - case L1DetectorID::kMvd: { + case ca::EDetectorID::kMvd: { ++fNpointsMvd; break; } - case L1DetectorID::kSts: + case ca::EDetectorID::kSts: iPointInt += fNpointsMvdAll; ++fNpointsSts; break; - case L1DetectorID::kMuch: + case ca::EDetectorID::kMuch: iPointInt += fNpointsMvdAll + fNpointsStsAll; ++fNpointsMuch; break; - case L1DetectorID::kTrd: + case ca::EDetectorID::kTrd: iPointInt += fNpointsMvdAll + fNpointsStsAll + fNpointsMuchAll; ++fNpointsTrd; break; - case L1DetectorID::kTof: + case ca::EDetectorID::kTof: iPointInt += fNpointsMvdAll + fNpointsStsAll + fNpointsMuchAll + fNpointsTrdAll; ++fNpointsTof; break; - case L1DetectorID::kEND: break; + case ca::EDetectorID::kEND: break; } fmMCPointsLinksMap[CbmL1LinkKey(iPointInt, event, file)] = fvMCPoints.size(); diff --git a/reco/L1/L1Algo/L1Algo.cxx b/reco/L1/L1Algo/L1Algo.cxx index 6edf880704..de5bf70e93 100644 --- a/reco/L1/L1Algo/L1Algo.cxx +++ b/reco/L1/L1Algo/L1Algo.cxx @@ -18,6 +18,7 @@ L1Algo::L1Algo() } } +using cbm::algo::ca::EDetectorID; using cbm::ca::tools::Debugger; void L1Algo::Init(const TrackingMode mode) { fTrackingMode = mode; } @@ -77,7 +78,7 @@ void L1Algo::ReceiveParameters(Parameters&& parameters) { fParameters = std::move(parameters); - fNstationsBeforePipe = fParameters.GetNstationsActive(static_cast<L1DetectorID>(0)); + fNstationsBeforePipe = fParameters.GetNstationsActive(static_cast<EDetectorID>(0)); // FIXME: SZh 24.08.2022 // This approach is suitable only for a case, when all the stations inside a magnetic field come right before diff --git a/reco/L1/L1Algo/L1BaseStationInfo.cxx b/reco/L1/L1Algo/L1BaseStationInfo.cxx deleted file mode 100644 index 1421d3b7b6..0000000000 --- a/reco/L1/L1Algo/L1BaseStationInfo.cxx +++ /dev/null @@ -1,401 +0,0 @@ -/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Sergey Gorbunov, Sergei Zharko [committer] */ - -/************************************************************************************************************ - * @file L1BaseStationInfo.cxx - * @brief Realization of L1BaseStationInfo class large methods - * @since 18.01.2022 - * - * The class is implemented to connect concrete experimental setup (CBM or BMN in CbmL1 - * or BmnL1) with general L1Tracking algorithm. Each derived class must contain general - * algorithms sutable for the particular station type. - * - ***********************************************************************************************************/ - -// FairRoot -#include <Logger.h> - -// L1Algo core -#include "CaConstants.h" -#include "L1Assert.h" -#include "L1BaseStationInfo.h" -#include "L1Def.h" -// C++ STL -#include <iomanip> -#include <sstream> -#include <utility> - -// -// CONSTRUCTORS AND DESTRUCTOR -// - -//------------------------------------------------------------------------------------------------------------------------ -// -L1BaseStationInfo::L1BaseStationInfo(L1DetectorID detectorID, int stationID) noexcept - : fDetectorID(detectorID) - , fStationID(stationID) -{ - LOG(debug) << "L1BaseStationInfo: Constructor (detectorID, stationID) called for " << this << '\n'; // Temporary - fInitController.SetFlag(EInitKey::kDetectorID); - fInitController.SetFlag(EInitKey::kStationID); -} - - -// -// BASIC METHODS -// - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::Print(int verbosity) const -{ - if (verbosity == 0) { - LOG(info) << "L1BaseStationInfo object: {stationID, detectorID, address} = {" << fStationID << ", " - << static_cast<int>(fDetectorID) << ", " << this << '}'; - } - else if (verbosity > 0) { - LOG(info) << "L1BaseStationInfo object: at " << this; - LOG(info) << "\tStation ID: " << fStationID; - LOG(info) << "\tDetector ID: " << static_cast<int>(fDetectorID); - LOG(info) << "\tStation z position: " << fZref; - LOG(info) << "\tTracking status: " << fTrackingStatus; - LOG(info) << "\tL1Staiton: " << fL1Station.ToString(1); - LOG(info) << "\tAdditional fields:"; - LOG(info) << "\t\tXmax: " << fXmax; - LOG(info) << "\t\tYmax: " << fYmax; - } -} - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::Reset() -{ - L1BaseStationInfo other; - this->Swap(other); -} - -//------------------------------------------------------------------------------------------------------------------------ -// -const ca::Station& L1BaseStationInfo::GetL1Station() const -{ - // TODO: replace L1MASSERT with throw std::logic_error - std::stringstream aStream; - aStream << "L1BaseStationInfo::GetL1Station: attempt to get an L1Staion object from uninitialized L1BaseStation with " - << "stationID = " << fStationID << " and detectorID = " << static_cast<int>(fDetectorID); - L1MASSERT(0, fInitController.IsFinalized(), aStream.str().c_str()); - return fL1Station; -} - -//------------------------------------------------------------------------------------------------------------------------ -// -const ca::MaterialMap& L1BaseStationInfo::GetMaterialMap() const -{ - if (!fInitController.IsFinalized()) { - LOG(fatal) << "L1BaseStationInfo::GetMaterialMap: attempt of getting the material map object from uninitialized " - "L1BaseStation class (detectorID = " - << static_cast<int>(fDetectorID) << ", stationID = " << fStationID << ")"; - } - - if (fManagementFlags[static_cast<int>(EManagementFlag::kThicknessMapMoved)]) { - LOG(fatal) << "L1BaseStationInfo::GetMaterialMap: attempt of getting the material map, which has been moved. The " - "thickness map instance have been " - << "already took from the L1BaseStationInfo object (detectorID = " << static_cast<int>(fDetectorID) - << ", stationID = " << fStationID << ")"; - } - - return fThicknessMap; -} - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetDetectorID(L1DetectorID inID) -{ - if (!fInitController.GetFlag(EInitKey::kDetectorID)) { - fDetectorID = inID; - fInitController.SetFlag(EInitKey::kDetectorID); - } - else { - LOG(warn) << "L1BaseStationInfo::SetDetectorID: Attempt of detector ID redifinition"; - } -} - - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetFieldFunction( - const std::function<void(const double (&xyz)[3], double (&B)[3])>& getFieldValue) -{ - if (fInitController.GetFlag(EInitKey::kFieldSlice)) { - LOG(warn) << "L1BaseStationInfo::SetFieldSlice: Attempt to redifine field slice for station with detectorID = " - << static_cast<int>(fDetectorID) << " and stationID = " << fStationID << ". Redifinition ignored"; - return; - } - - L1MASSERT(0, fInitController.GetFlag(EInitKey::kZref), - "Attempt to set magnetic field slice before setting z position of the station"); - L1MASSERT(0, fInitController.GetFlag(EInitKey::kXmax), - "Attempt to set magnetic field slice before Xmax size of the station"); - L1MASSERT(0, fInitController.GetFlag(EInitKey::kYmax), - "Attempt to set magnetic field slice before Ymax size of the station"); - // TODO: Change names of variables according to convention (S.Zh.) - constexpr int M = constants::size::MaxFieldApproxPolynomialOrder; - constexpr int N = constants::size::MaxNFieldApproxCoefficients; - constexpr int D = 3; ///> number of dimensions - - // SLE initialization - double A[N][N + D] = {}; // augmented matrix - double dx = (fXmax / N / 2 < 1.) ? fXmax / N / 4. : 1.; - double dy = (fYmax / N / 2 < 1.) ? fYmax / N / 4. : 1.; - - for (double x = -fXmax; x <= fXmax; x += dx) { - for (double y = -fYmax; y <= fYmax; y += dy) { - double r = sqrt(fabs(x * x / fXmax / fXmax + y / fYmax * y / fYmax)); - if (r > 1.) { continue; } - double p[D] = {x, y, fZref}; - double B[D] = {}; - getFieldValue(p, B); - - double m[N] = {1}; - m[0] = 1; - for (int i = 1; i <= M; ++i) { - int k = (i - 1) * i / 2; - int l = i * (i + 1) / 2; - for (int j = 0; j < i; ++j) { - m[l + j] = x * m[k + j]; - } - m[l + i] = y * m[k + i - 1]; - } - - double w = 1. / (r * r + 1); - for (int i = 0; i < N; ++i) { - // fill the left part of the matrix - for (int j = 0; j < N; ++j) { - A[i][j] += w * m[i] * m[j]; - } - // fill the right part of the matrix - for (int j = 0; j < D; ++j) { - A[i][N + j] += w * B[j] * m[i]; - } - } - } - } - - // SLE solution (Gaussian elimination) - // - for (int kCol = 0; kCol < N - 1; ++kCol) { - for (int jRow = kCol + 1; jRow < N; ++jRow) { - double factor = A[jRow][kCol] / A[kCol][kCol]; - for (int iCol = kCol; iCol < N + D; ++iCol) { - A[jRow][iCol] -= factor * A[kCol][iCol]; - } - } - } - for (int kCol = N - 1; kCol > 0; --kCol) { - for (int jRow = kCol - 1; jRow >= 0; --jRow) { - double factor = A[jRow][kCol] / A[kCol][kCol]; - for (int iCol = kCol; iCol < N + D; ++iCol) { - A[jRow][iCol] -= factor * A[kCol][iCol]; - } - } - } - - for (int j = 0; j < N; ++j) { - fL1Station.fieldSlice.cx[j] = A[j][N + 0] / A[j][j]; - fL1Station.fieldSlice.cy[j] = A[j][N + 1] / A[j][j]; - fL1Station.fieldSlice.cz[j] = A[j][N + 2] / A[j][j]; - } - fL1Station.fieldSlice.z = fZref; - - fInitController.SetFlag(EInitKey::kFieldSlice); -} - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetFieldStatus(int fieldStatus) -{ - fL1Station.fieldStatus = fieldStatus; - fInitController.SetFlag(EInitKey::kFieldStatus); -} - - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetMaterialMap(const ca::MaterialMap& thicknessMap) -{ - if (!fInitController.GetFlag(EInitKey::kThicknessMap)) { - fThicknessMap = thicknessMap; - fInitController.SetFlag(EInitKey::kThicknessMap); - } - else { - LOG(warn) << "L1BaseStationInfo::SetMaterialMap: attempt to reinitialize the material map"; - } -} - - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetMaterialMap(ca::MaterialMap&& thicknessMap) noexcept -{ - if (!fInitController.GetFlag(EInitKey::kThicknessMap)) { - fThicknessMap = std::move(thicknessMap); - fInitController.SetFlag(EInitKey::kThicknessMap); - } - else { - LOG(warn) << "L1BaseStationInfo::SetMaterialMap: attempt to reinitialize the material map"; - } -} - - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetStationID(int inID) -{ - if (!fInitController.GetFlag(EInitKey::kStationID)) { - fStationID = inID; - fInitController.SetFlag(EInitKey::kStationID); - } - else { - LOG(warn) << "L1BaseStationInfo::SetStationID: Attempt of station ID redifinition"; - } -} - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetStationType(int inType) -{ - if (!fInitController.GetFlag(EInitKey::kType)) { - fL1Station.type = inType; - fInitController.SetFlag(EInitKey::kType); - } - else { - LOG(warn) << "L1BaseStationInfo::SetStationType: Attempt of station type redifinition"; - } -} - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetXmax(double aSize) -{ - fXmax = aSize; - fL1Station.Xmax = aSize; - fInitController.SetFlag(EInitKey::kXmax); -} - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetYmax(double aSize) -{ - fYmax = aSize; - fL1Station.Ymax = aSize; - fInitController.SetFlag(EInitKey::kYmax); -} - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetTimeInfo(int inTimeInfo) -{ - fL1Station.timeInfo = inTimeInfo; - fInitController.SetFlag(EInitKey::kTimeInfo); -} - - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetTrackingStatus(bool flag) -{ - fTrackingStatus = flag; - fInitController.SetFlag(EInitKey::kTrackingStatus); -} - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetZref(double inZ) -{ - fL1Station.fZ = inZ; // setting simd vector of single-precision floats, which is passed to high performanced L1Algo - fZref = inZ; // setting precised value to use in field approximation etc - fInitController.SetFlag(EInitKey::kZref); -} - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetZmin(double inZ) -{ - fZmin = inZ; // setting precised value to use in field approximation etc - fInitController.SetFlag(EInitKey::kZmin); -} - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::SetZmax(double inZ) -{ - fZmax = inZ; // setting precised value to use in field approximation etc - fInitController.SetFlag(EInitKey::kZmax); -} - -//------------------------------------------------------------------------------------------------------------------------ -// -void L1BaseStationInfo::Swap(L1BaseStationInfo& other) noexcept -{ - std::swap(fDetectorID, other.fDetectorID); - std::swap(fStationID, other.fStationID); - std::swap(fTrackingStatus, other.fTrackingStatus); - std::swap(fXmax, other.fXmax); - std::swap(fYmax, other.fYmax); - std::swap(fZref, other.fZref); - std::swap(fZmin, other.fZmin); - std::swap(fZmax, other.fZmax); - std::swap(fL1Station, other.fL1Station); - std::swap(fThicknessMap, other.fThicknessMap); - std::swap(fInitController, other.fInitController); -} - -//------------------------------------------------------------------------------------------------------------------------ -// -ca::MaterialMap&& L1BaseStationInfo::TakeMaterialMap() -{ - if (!fInitController.IsFinalized()) { - LOG(fatal) << "L1BaseStationInfo::GetMaterialMap: attempt of getting the material map object from uninitialized " - "L1BaseStation class (detectorID = " - << static_cast<int>(fDetectorID) << ", stationID = " << fStationID << ")"; - } - - if (fManagementFlags[static_cast<int>(EManagementFlag::kThicknessMapMoved)]) { - LOG(fatal) << "L1BaseStationInfo::GetMaterialMap: attempt of taking the material map, which has been moved. The " - "thickness map instance have been " - << "already took from the L1BaseStationInfo object (detectorID = " << static_cast<int>(fDetectorID) - << ", stationID = " << fStationID << ")"; - } - else { - fManagementFlags[static_cast<int>(EManagementFlag::kThicknessMapMoved)] = true; - } - - return std::move(fThicknessMap); -} - -//------------------------------------------------------------------------------------------------------------------------ -// -std::string L1BaseStationInfo::ToString(int verbosityLevel, int indentLevel) const -{ - std::stringstream aStream {}; - constexpr char indentChar = '\t'; - std::string indent(indentLevel, indentChar); - - if (verbosityLevel == 0) { - aStream << indent << "L1BaseStationInfo object: {stationID, detectorID, z, address} = {" << fStationID << ", " - << static_cast<int>(fDetectorID) << ", " << fZref << ", " << this << '}'; - } - else if (verbosityLevel > 0) { - aStream << indent << "L1BaseStationInfo object: at " << this << '\n'; - aStream << indent << indentChar << "Station ID: " << fStationID << '\n'; - aStream << indent << indentChar << "Detector ID: " << static_cast<int>(fDetectorID) << '\n'; - aStream << indent << indentChar << "ca::Station object:" << '\n'; - aStream << fL1Station.ToString(verbosityLevel - 1, indentLevel + 1) << '\n'; - aStream << indent << indentChar << "Additional fields:\n"; - aStream << indent << indentChar << indentChar << "Zmin: " << fZmin << '\n'; - aStream << indent << indentChar << indentChar << "Zmax: " << fZmax << '\n'; - aStream << indent << indentChar << indentChar << "Xmax: " << fXmax << '\n'; - aStream << indent << indentChar << indentChar << "Ymax: " << fYmax << '\n'; - } - return aStream.str(); -} diff --git a/reco/L1/L1Algo/L1BaseStationInfo.h b/reco/L1/L1Algo/L1BaseStationInfo.h deleted file mode 100644 index 4d1e7eb5c6..0000000000 --- a/reco/L1/L1Algo/L1BaseStationInfo.h +++ /dev/null @@ -1,234 +0,0 @@ -/* Copyright (C) 2021-2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Sergey Gorbunov, Sergei Zharko [committer] */ - -/************************************************************************************************************ - * @file L1BaseStationInfo.h - * @brief A base class for a L1 station interface - * @since 18.12.2021 - * - * The class is implemented to connect concrete experimental setup (CBM or BMN in CbmL1 - * or BmnL1) with general L1Algo tracking. - * - ***********************************************************************************************************/ - -#ifndef L1BaseStationInfo_h -#define L1BaseStationInfo_h 1 - -// L1 Core -#include "CaMaterialMap.h" -#include "CaObjectInitController.h" -#include "CaSimd.h" -#include "CaStation.h" - -// C++ std -#include <bitset> -#include <functional> -#include <string> - -using namespace cbm::algo; // TODO: remove this line -using namespace cbm::algo::ca; // TODO: remove this line - -enum class L1DetectorID; - -/// A base class which provides interface to L1Algo station geometry -class L1BaseStationInfo { - /// Enumeration for internal logic control - enum class EManagementFlag - { - kThicknessMapMoved, ///< if the thickness map was moved from the L1BaseStationInfo instance - kEnd - }; - using ManagementFlags_t = std::bitset<static_cast<int>(EManagementFlag::kEnd)>; - -public: - /// Enumeration of fields, which must be initialized so the object can pass the threshold - enum class EInitKey - { - // Basic fields initialization - kDetectorID, ///< detector ID - kStationID, ///< station ID - kTrackingStatus, ///< flag, if station is used in tracking or not - kXmax, ///< max size in X direction - kYmax, ///< max size in Y direction - // ca::Station initialization - kType, ///< station type - kTimeInfo, ///< if time info is used (flag) - kFieldStatus, ///< if station is placed in field (flag) - kZref, ///< reference z of the station - kZmin, ///< min z of the station - kZmax, ///< max z of the station - kThicknessMap, ///< thickness map of the station (optional?) - kFieldSlice, ///< ca::Station.ca::FieldSlice object initialization - // The last item is equal to the number of bits in fInitFlags - kEnd - }; - - using InitController_t = ca::ObjectInitController<static_cast<int>(EInitKey::kEnd), EInitKey>; - - // - // CONSTRUCTORS AND DESTRUCTORS - // - /// Default constructor - L1BaseStationInfo() = default; - - /// Constructor from stationID and detectorID - L1BaseStationInfo(L1DetectorID detetorID, int stationID) noexcept; - - /// Destructor - ~L1BaseStationInfo() noexcept = default; - - /// Copy constructor - L1BaseStationInfo(const L1BaseStationInfo& other) = default; - - /// Less operator for L1BaseStationInfo object to sort stations in Z - bool operator<(const L1BaseStationInfo& right) const { return (GetZref() < right.GetZref()); } - - /// Gets detector ID - L1DetectorID GetDetectorID() const { return fDetectorID; } - - /// Gets a coefficient with idx for the field x-component approximation - fvec GetFieldSliceCx(int idx) const { return fL1Station.fieldSlice.cx[idx]; } - - /// Gets a coefficient with idx for the field y-component approximation - fvec GetFieldSliceCy(int idx) const { return fL1Station.fieldSlice.cy[idx]; } - - /// Gets a coefficient with idx for the field z-component approximation - fvec GetFieldSliceCz(int idx) const { return fL1Station.fieldSlice.cz[idx]; } - - /// Gets array of the coefficients for the field x-component approximation - const fvec* GetFieldSliceCx() const { return fL1Station.fieldSlice.cx; } - - /// Gets array of the coefficients for the field y-component approximation - const fvec* GetFieldSliceCy() const { return fL1Station.fieldSlice.cy; } - - /// Gets array of the coefficients for the field z-component approximation - const fvec* GetFieldSliceCz() const { return fL1Station.fieldSlice.cz; } - - - /// Gets field status: 0 - station is outside the field, 1 - station is inside the field - int GetFieldStatus() const { return fL1Station.fieldStatus; } - - /// Gets a const reference to the ca::ObjectInitController object - const InitController_t& GetInitController() const { return fInitController; } - - /// Gets a reference to ca::Station info field of the L1BaseStation info - const ca::Station& GetL1Station() const; - - /// Gets a reference to ca::MaterialMap map - const ca::MaterialMap& GetMaterialMap() const; - - /// Gets station ID - int GetStationID() const { return fStationID; } - - /// Gets station type - int GetStationType() const { return fL1Station.type; } - - /// Gets tracking status: true - station is active for tracking, false - station exists, but not used in tracking - bool GetTrackingStatus() const { return fTrackingStatus; } - - /// Gets maximum distance between station center and its edge in x direction - double GetXmax() const { return fXmax; } - - /// Gets maximum distance between station center and its edge in y direction - double GetYmax() const { return fYmax; } - - /// Gets double precised z position of the station [cm] - double GetZref() const { return fZref; } - - /// Gets min z of the station [cm] - double GetZmin() const { return fZmin; } - - /// Gets max z of the station [cm] - double GetZmax() const { return fZmax; } - - /// Gets SIMD vectorized z position of the station [cm] - fvec GetZsimdVec() const { return fL1Station.fZ; } - - /// Prints registered fields - /// verbosity = 0: print only station id, detector id and address in one line - /// verbosity = 1: print basic ca::Station fields - /// verbosity = 2: print all L1Staion fields - void Print(int verbosity = 0) const; - - /// Resets fields to the default values - void Reset(); - - /// Sets detector ID - void SetDetectorID(L1DetectorID inID); - - /// Sets flag: true - station is placed in field, false - station is placed outside the field - void SetFieldStatus(int fieldStatus); - - /// Sets arrays of the approcimation - /// \param getField A user function, which gets a xyz array of position coordinates and fills B array - /// of magnetic field components in position - void SetFieldFunction(const std::function<void(const double (&xyz)[3], double (&B)[3])>& getFieldValue); - - /// Sets station thickness in units of radiation length mapped vs. position in XY plane (copy semantics) - /// \param thicknessMap Map of station thickness in units of radiation length - void SetMaterialMap(const ca::MaterialMap& thicknessMap); - - /// Sets station thickness in units of radiation length mapped vs. position in XY plane (move semantics) - /// \param thicknessMap Map of station thickness in units of radiation length - void SetMaterialMap(ca::MaterialMap&& thicknessMap) noexcept; - - /// Sets station ID - [[deprecated("Please, use constructor to set station ID")]] void SetStationID(int inID); - - /// Sets type of station - void SetStationType(int inType); // TODO: this is a temporary solution (S.Zh.) - - /// Sets flag: 0 - time information is not provided by this detector type - /// 1 - time information is provided by the detector and can be used in tracking - void SetTimeInfo(int inTimeInfo); - - /// Sets tracking status: true - station is active for tracking, false - station exists, but not used in tracking - void SetTrackingStatus(bool flag); - - /// Sets maximum distance between station center and its edge in x direction - void SetXmax(double aSize); - - /// Sets maximum distance between station center and its edge in y direction - void SetYmax(double aSize); - - /// Sets reference z position of the station - void SetZref(double inZ); - - /// Sets min z of the station - void SetZmin(double inZ); - - /// Sets max z of the station - void SetZmax(double inZ); - - /// Swap method for easy implementation of move constructor and copy and move assignment operator - void Swap(L1BaseStationInfo& other) noexcept; - - /// Takes an instance of ca::MaterialMap map - /// This method can be called only once. It will catch the content of ca::MaterialMap map (using move semantics), and after the warning will be generated - /// both for GetMaterialMap and TakeMaterialMap - ca::MaterialMap&& TakeMaterialMap(); - - /// String representation of class contents - /// \param indentLevel Number of indent characters in the output - std::string ToString(int verbosityLevel = 0, int indentLevel = 0) const; - -private: - L1DetectorID fDetectorID {static_cast<L1DetectorID>(0)}; ///< Detector ID - int fStationID {-1}; ///< Local ID of a station - bool fTrackingStatus {false}; ///< Tracking status: true - station is used for tracking - double fXmax {0}; ///< Maximum distance between station center and its edge in x direction - double fYmax {0}; ///< Maximum distance between station center and its edge in y direction - double fZref {0}; ///< reference z - double fZmin {0}; ///< min z - double fZmax {0}; ///< max z - ca::Station fL1Station {}; ///< ca::Station structure, describes a station in L1Algo - ca::MaterialMap fThicknessMap {}; ///< Map of station thickness in units of radiation length - InitController_t fInitController {}; ///< Class fileds initialization flags - ManagementFlags_t fManagementFlags {}; ///< bitset flags to manage internal behaviour of the class -}; - -/// swap function for two L1BaseStationInfo objects, expected to be used instead of std::swap -inline void swap(L1BaseStationInfo& a, L1BaseStationInfo& b) noexcept { a.Swap(b); } - -#endif // L1BaseStationInfo_h diff --git a/reco/L1/L1Algo/L1ConfigRW.h b/reco/L1/L1Algo/L1ConfigRW.h deleted file mode 100644 index ff5313fbf6..0000000000 --- a/reco/L1/L1Algo/L1ConfigRW.h +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Sergei Zharko [committer] */ - -/// @file L1ConfigRW.h -/// @brief Configuration parameter file reader/writer for L1 tracking algorithm (declaration) -/// @author S.Zharko <s.zharko@gsi.de> -/// @since 18.07.2022 - -#ifndef L1ConfigRW_h -#define L1ConfigRW_h 1 - -#include <string> -#include <unordered_map> -#include <vector> - -#include <yaml-cpp/yaml.h> - -#include "CaIteration.h" - -using namespace cbm::algo::ca; - -namespace YAML -{ - class Node; -} -class L1InitManager; -enum class L1DetectorID; - -/// Class L1ConfigRW provides internal read and write methods for L1 tracking algorithm parameters -class L1ConfigRW { -public: - /// @brief Constructor - /// @param pInitManager Pointer to the L1InitManager instance - L1ConfigRW(L1InitManager* pInitManager, int verbose = 1); - - /// @brief Destructor - ~L1ConfigRW() = default; - - /// @brief Reads configuration from files - void Read(); - - /// @brief Reads CA track finder iterations from YAML node - /// @return A vector of iterations - std::vector<Iteration> ReadCAIterationVector(); - - /// @brief Sets main config file - /// @param path Path to the file - void SetMainConfigPath(const std::string& path); - - /// @brief Sets user config file - /// @param path Path to user config file - void SetUserConfigPath(const std::string& path); - - /// @brief Sets verbosity level - void SetVerbosity(int verbose) { fVerbose = verbose; } - - /// @brief Gets verbosity level - int GetVerbosity() const { return fVerbose; } - -private: - /// @brief Reads inactive tracking station map - /// @return A vector of sets of disabled station local indexes vs. the the detector index - std::vector<std::set<int>> ReadInactiveStationMap(); - - /// @brief Accesses a node either from user config or from main config - /// @param fn A function, which returns a YAML::Node reference object - /// @note If the node is not found in both configs - /// @throw std::runtime_error, if the path does not exist in the config - /// - /// This function is to be used, if the desired node should exist either in main or in user config. Firstly, - /// the user config is checked, if it is provided. If the node is not found in user config, the main config - /// is checked. If the node does not exist in the main config as well, an exception will be thrown. - YAML::Node GetNode(std::function<YAML::Node(YAML::Node)> fn) const; - - /// @brief Reads iteration from config file - /// @param node YAML node containing an iteration - /// @param defaultIter Default iteration - /// @return A CA-iteration object - Iteration ReadSingleCAIteration(const YAML::Node& node, const Iteration& defaultIter) const; - - /// @brief Gets parameters content of the node - /// @param node YAML node - /// @return Vector of key names - std::vector<std::string> GetNodeKeys(const YAML::Node& node) const; - - L1InitManager* fpInitManager = nullptr; ///< Pointer to the L1InitManager instance - int fVerbose = 1; ///< Verbosity level - - std::string fsMainConfigPath = ""; ///< Path to the main config file (mandatory) - std::string fsUserConfigPath = ""; ///< Path to the user config file (optional) - - YAML::Node fMainConfigNode {YAML::NodeType::Undefined}; ///< Main configuration node - YAML::Node fUserConfigNode {YAML::NodeType::Undefined}; ///< User configuration node -}; - -#endif // L1ConfigRW_h diff --git a/reco/L1/L1Algo/L1InitManager.h b/reco/L1/L1Algo/L1InitManager.h deleted file mode 100644 index 9c71707c9f..0000000000 --- a/reco/L1/L1Algo/L1InitManager.h +++ /dev/null @@ -1,361 +0,0 @@ -/* Copyright (C) 2021-2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Sergey Gorbunov, Sergei Zharko [committer] */ - -/// \file L1InitManager.h -/// \brief Input data management class for L1Algo -/// \since 24.12.2021 -#ifndef L1InitManager_h -#define L1InitManager_h 1 - -#include <array> -#include <bitset> -#include <memory> //unique_ptr -#include <numeric> -#include <set> -#include <string> -#include <type_traits> -#include <unordered_map> - -#include "CaConstants.h" -#include "CaField.h" -#include "CaIteration.h" -#include "CaObjectInitController.h" -#include "CaParameters.h" -#include "CaSimd.h" -#include "L1BaseStationInfo.h" -#include "L1Utils.h" - - -using namespace cbm::algo::ca; //TODO: remove -using namespace cbm::algo; //TODO: remove - -class L1ConfigRW; -class L1Algo; - -/// Forward declaration of the tracking detectors scoped enumeration. Concrete realization of this enumeration must be -/// determined in the concrete setup class (i.e. CbmL1/BmnL1) -enum class L1DetectorID; - -/// Underlying -using L1DetectorID_t = std::underlying_type_t<L1DetectorID>; - -/// Initialization manager for L1Algo -/// -/// ==== Expected initialization steps ==== (TODO: keep this instruction up-to-date) -/// -/// 0. Implement your enum class L1DetectorID with detector systems used for tracking: -/// IMPORTANT!!! Detectors must be sorted in the beam direction -/// /// Concrete L1DetectorID implementation for CBM -/// enum class L1DetectorID { -/// kMvd, -/// kSts, -/// kMuch, -/// kTof, -/// kTrd -/// }; -/// For CBM see implementation in CbmL1DetectorID.h -/// -/// 1. Get a pointer to the :L1InitManager field of L1Algo: -/// -/// L1InitManager * initMan = algo->GetL1InitManager(); -/// -/// 2. Initialize a set of L1DetectorID's for detectors active in tracking: -/// -/// std::set<L1DetectorID> activeTrackingDetectors { L1Detector::kMvd, L1Detector::kSts }; -/// initMan->SetActiveDetectorIDs(activeTrackingDetectors); -/// -/// 3. Initialize number of stations for each detector: -/// -/// initMan->SetNstationsCrosscheck(L1DetectorID::kMvd, fNMvdStations) -/// initMan->SetNstationsCrosscheck(L1DetectorID::kSts, fNStsStations); -/// -/// 4. Initialize each station using L1BaseStationInfo: -/// -// TODO: Implement mechanism of reinitialization (S.Zharko) -class L1InitManager { -private: - enum class EInitKey - { - // NOTE: Please, keep the numbers of the enumeration items in the existing order: it helps to debug the - // initialization with this->GetObjectInitController().ToString() method call (S.Zharko) - kActiveDetectorIDs, ///< 0) If the detector sequence is set - kFieldFunction, ///< 1) If magnetic field getter function is set - kTargetPos, ///< 2) If target position was defined - kPrimaryVertexField, ///< 3) If magnetic field value and region defined at primary vertex - kStationsInfo, ///< 4) If all the planned stations were added to the manager - kCAIterationsNumberCrosscheck, ///< 5) If the number of CA track finder is initialized - kCAIterations, ///< 6) If the CA track finder iterations were initialized - kSearchWindows, ///< 7) If the hit search windows were initialized - 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 - }; - - using L1DetectorIDIntMap_t = std::unordered_map<L1DetectorID, int, L1Utils::EnumClassHash>; - using L1DetectorIDSet_t = std::set<L1DetectorID>; - using L1FieldFunction_t = std::function<void(const double (&xyz)[3], double (&B)[3])>; - using InitController_t = ObjectInitController<static_cast<int>(EInitKey::kEnd), EInitKey>; - template<typename T> - using L1DetectorIDArr_t = std::array<T, constants::size::MaxNdetectors>; - -public: - /// Default constructor - L1InitManager() = default; - - /// Destructor - ~L1InitManager() = default; - - /// Copy constructor is forbidden - L1InitManager(const L1InitManager& /*other*/) = delete; - - /// Move constructor is forbidden - L1InitManager(L1InitManager&& /*other*/) = delete; - - /// Copy assignment operator is forbidden - L1InitManager& operator=(const L1InitManager& /*other*/) = delete; - - /// Move assignment operator is forbidden - L1InitManager& operator=(L1InitManager&& /*other*/) = delete; - - - /// @brief Adds a tracking station to the geometry - /// - /// @note The added station stays uninitialized until the Parameters object is formed - void AddStation(const L1BaseStationInfo& station); - - /// Provides final checks of large fields initialization calling Check"Object"Init() private methods, - /// must be called in the beginning of L1Algo::Init() - void CheckInit(); - // NOTE: This method calls checkers of large fields initializations like a station or an iteration. The method must be - // called in the L1Algo class. (S.Zharko) - - /// Clears vector of CA track finder iterations - void ClearCAIterations(); - - /// Clears vector of base setup - void ClearSetupInfo(); - - /// Forms parameters container - /// \return Success flag - bool FormParametersContainer(); - - /// @brief Gets name of the detector - /// @param detId Index of the detector - /// @return Name of the detector - const std::string& GetDetectorName(L1DetectorID detId) const { return fvDetectorNames[static_cast<int>(detId)]; } - - /// Gets ghost suppression flag - int GetGhostSuppression() const { return fParameters.fGhostSuppression; } - - /// @brief Gets a name of the main input configuration file - const std::string& GetInputConfigMain() const { return fsConfigInputMain; } - - /// @brief Gets a name of the user input configuration file - const std::string& GetInputConfigUser() const { return fsConfigInputMain; } - - /// Gets a const reference to ca::ObjectInitController - const InitController_t& GetInitController() const { return fInitController; } - - /// Gets total number of active stations - int GetNstationsActive() const; - - /// Gets number of active stations for given detector ID - int GetNstationsActive(L1DetectorID detectorID) const; - - /// Gets total number of stations, provided by setup geometry - int GetNstationsGeometry() const; - - /// Gets number of stations, provided by setup geometry for given detector ID - int GetNstationsGeometry(L1DetectorID detectorID) const; - - /// Gets a name of the output configuration file - const std::string& GetOutputConfigName() const { return fConfigOutputName; } - - /// @brief Gets a reference to the stations array - std::vector<L1BaseStationInfo>& GetStationInfo(); - - /// @brief Initializes station layout - /// - /// This function is to be called after all the tracking stations (L1BaseStationInfo objects) are added to the - /// L1InitManager instance. After the initialization a vector of the tracking stations sorted by z-positions is - /// available for modifications. - void InitStationLayout(); - - /// @brief Calculates ca::FieldValue and L1FieldReference values for a selected step in z-axis from the target position - /// \param zStep step between nodal points - // TODO: Consider possibility for linear approximation (S.Zh.) - void InitTargetField(double zStep); - - /// Pushes an CA track finder iteration into a sequence of iteration using reference - void PushBackCAIteration(const Iteration& iteration); - - /// Pushes an CA track finder iteration into a sequence of iteration using raw pointer - void PushBackCAIteration(const Iteration* pIteration) { PushBackCAIteration(*pIteration); } - - /// Pushes an CA track finder iteration into a sequence of iteration using std::unique_ptr - void PushBackCAIteration(const std::unique_ptr<Iteration>& puIteration) { PushBackCAIteration(*puIteration); } - - /// @brief Reads main and user parameters configs - void ReadInputConfigs(); - - /// Reads parameters object from boost-serialized binary file - /// \param fileName Name of input file - void ReadParametersObject(const std::string& fileName); - - /// Reads search windows from file - /// \param fileName Name of input file - void ReadSearchWindows(const std::string& fileName); - - /// Sets a set of active tracking detector IDs - void SetActiveDetectorIDs(const L1DetectorIDSet_t& detectorIDs); - - /// Sets a number of CA track finder iterations to provide initialization cross-check - void SetCAIterationsNumberCrosscheck(int nIterations); - - /// @brief Sets base configuration file - /// @param mainConfig Path to main configuration file - /// @note The base configuraiton file is mandatory until the tracking configuration is initialized from - /// beforehand created Parameters file. - void SetConfigMain(const std::string& mainConfig) { fsConfigInputMain = mainConfig; } - - /// @brief Sets user configuration file - /// @param userConfig Path to user configuration file - /// @note The user configuraiton file is optional - void SetConfigUser(const std::string& userConfig) { fsConfigInputUser = userConfig; } - - /// @brief Sets detector names - /// @param container Container of the detector names - template<size_t Size> - void SetDetectorNames(const std::array<const char*, Size>& container) - { - static_assert(Size <= constants::size::MaxNdetectors, - "Please, be ensured that the constants::size::MaxNdetectors is not lower then the " - "L1DetectorID::kEND value, provided by your setup"); - std::copy(container.begin(), container.end(), fvDetectorNames.begin()); - } - - /// Sets a magnetic field function, which will be applied for all the stations - void SetFieldFunction(const L1FieldFunction_t& fieldFcn); - - /// FIXME: ... - void SetGhostSuppression(int ghostSuppression); - - /// Sets a name of the output configuration file. The output file is created from the fields, saved in the resulted - /// Parameters object - /// \param filename Name of the output L1 parameters configuration - void SetOutputConfigName(const std::string& filename) { fConfigOutputName = filename; } - - /// @brief Sets pseudo-random numbers generator seed - /// @param seed Seed value - /// @note The default seed is 1 - void SetRandomSeed(unsigned int seed); - - /// Sets target position - /// \param x Position X component [cm] - /// \param y Position Y component [cm] - /// \param z Position Z component [cm] - void SetTargetPosition(double x, double y, double z); - - /// Sets upper-bound cut on max number of doublets per one singlet - void SetMaxDoubletsPerSinglet(unsigned int value) { fParameters.fMaxDoubletsPerSinglet = value; } - - /// Sets upper-bound cut on max number of triplets per one doublet - void SetMaxTripletPerDoublets(unsigned int value) { fParameters.fMaxTripletPerDoublets = value; } - - /// Sends (moves) parameters object to the destination reference - /// \param pAlgo Pointer to the L1 tracking algorithm main class - /// \return Success flag - bool SendParameters(L1Algo* pAlgo); - - /// @brief Sends (moves) parameters object to an external destination - /// @param destination Reference to the parameters object of destination - /// @return Success flag - bool SendParameters(Parameters& destination); - - /// Writes parameters object from boost-serialized binary file - /// \param fileName Name of input file - void WriteParametersObject(const std::string& fileName) const; - - - // *************************** - // ** Flags for development ** - // *************************** - - /// Ignore hit search areas - void DevSetIgnoreHitSearchAreas(bool value = true) { fParameters.fDevIsIgnoreHitSearchAreas = value; } - - /// Force use of the original field (not approximated) - void DevSetUseOfOriginalField(bool value = true) { fParameters.fDevIsUseOfOriginalField = value; } - - /// Flag to match doublets using MC information - void DevSetIsMatchDoubletsViaMc(bool value = true) { fParameters.fDevIsMatchDoubletsViaMc = value; } - - /// Flag to match triplets using Mc information - void DevSetIsMatchTripletsViaMc(bool value = true) { fParameters.fDevIsMatchTripletsViaMc = value; } - - /// Flag to match triplets using Mc information - void DevSetIsExtendTracksViaMc(bool value = true) { fParameters.fDevIsExtendTracksViaMc = value; } - - /// Flag to match triplets using Mc information - void DevSetIsSuppressOverlapHitsViaMc(bool value = true) { fParameters.fDevIsSuppressOverlapHitsViaMc = value; } - - /// Flag to use estimated hit search windows - /// true: estimated search windows will be used in track finder - /// false: Kalman filter will be used in track finder - void DevSetIsParSearchWUsed(bool value = true) { fParameters.fDevIsParSearchWUsed = value; } - -private: - // ********************* - // ** Private methods ** - // ********************* - - /// Checker for L1CAIteration container initialization (sets EInitKey::kCAIterations) - /// \return true If all L1CAIteration objects were initialized properly - void CheckCAIterationsInit(); - - /// Checker for L1BaseStationInfo set initialization (sets EInitKey::kStationsInfo) - /// \return true If all L1BaseStationInfo objects were initialized properly. Similar effect can be achieved by - void CheckStationsInfoInit(); - - /// @brief Returns station layout into undefined condition - void ClearStationLayout(); - - - // ***************** - // ** Data fields ** - // ***************** - - // * Basic fields * - - InitController_t fInitController {}; ///< Initialization flags - L1DetectorIDSet_t fActiveDetectorIDs {}; ///< Set of tracking detectors, active during the run - L1DetectorIDArr_t<std::string> fvDetectorNames {}; ///< Names of the detectors - - // * Target fields * - - double fTargetZ {0.}; ///< Target position z component in double precision - - // * Stations related fields * - - std::vector<L1BaseStationInfo> fvStationInfo {}; ///< Vector of L1BaseStationInfo objects (active + inactive) - - /// A function which returns magnetic field vector B in a radius-vector xyz - L1FieldFunction_t fFieldFunction {[](const double (&)[3], double (&)[3]) {}}; - // NOTE: Stations of detectors which will not be assigned as active, will not be included in the tracking! - - // * CA track finder iterations related * - - int fCAIterationsNumberCrosscheck {-1}; ///< Number of iterations to be passed (must be used for cross-checks) - - Parameters fParameters {}; ///< L1Algo parameters object - - // * Configuration related * - std::string fsConfigInputMain = ""; ///< name for the input configuration file - std::string fsConfigInputUser = ""; ///< name for the input configuration file - std::string fConfigOutputName = ""; ///< name for the output configuration file - //L1ConfigRW fConfigRW {this, /*verbose = */ 4}; ///< configuration file reader and writer -}; - -#endif diff --git a/reco/L1/L1LinkDef.h b/reco/L1/L1LinkDef.h index b915e9a647..34a671499a 100644 --- a/reco/L1/L1LinkDef.h +++ b/reco/L1/L1LinkDef.h @@ -30,7 +30,7 @@ #pragma link C++ class CbmCaInputQaTrd + ; #pragma link C++ class CbmCaInputQaTof + ; #pragma link C++ enum cbm::ca::ETrackType; -#pragma link C++ enum class L1DetectorID; +#pragma link C++ enum class cbm::algo::ca::EDetectorID; #pragma link C++ class cbm::ca::OutputQa + ; #pragma link C++ class cbm::ca::tools::WindowFinder + ; //#pragma link C++ class cbm::ca::IdealHitProducer < L1DetectorID::kMvd > + ; diff --git a/reco/L1/catools/CaToolsMCData.h b/reco/L1/catools/CaToolsMCData.h index b0cf492010..9f4014c282 100644 --- a/reco/L1/catools/CaToolsMCData.h +++ b/reco/L1/catools/CaToolsMCData.h @@ -12,16 +12,19 @@ #include <numeric> #include <string> +#include <unordered_map> +#include "CaSimd.h" #include "CaToolsDef.h" #include "CaToolsLinkKey.h" #include "CaToolsMCPoint.h" #include "CaToolsMCTrack.h" #include "CaVector.h" -enum class L1DetectorID; - -#include "CaSimd.h" +namespace cbm::algo::ca +{ + enum class EDetectorID; +} using namespace cbm::algo::ca; //TODO: remove @@ -73,7 +76,7 @@ namespace cbm::ca::tools /// @param file Index of MC file /// @return Index of MC point in internal point container within event/TS /// If the point is not found the function returns -1 - int FindInternalPointIndex(L1DetectorID detID, int index, int event, int file) const + int FindInternalPointIndex(ca::EDetectorID detID, int index, int event, int file) const { int indexGlob = GetPointGlobExtIndex(detID, index); auto it = fmPointLinkMap.find(LinkKey(indexGlob, event, file)); @@ -94,14 +97,14 @@ namespace cbm::ca::tools /// @brief Gets the first point index for a given detector subsystem /// @param detID Detector ID - int GetFirstPointIndex(L1DetectorID detID) const + int GetFirstPointIndex(ca::EDetectorID detID) const { return std::accumulate(fvNofPointsUsed.cbegin(), fvNofPointsUsed.cbegin() + static_cast<int>(detID), 0); } /// @brief Gets the next index of point, which is expected being after the last one for a given detector /// @param detID Detector ID - int GetLastPointIndex(L1DetectorID detID) const + int GetLastPointIndex(ca::EDetectorID detID) const { return std::accumulate(fvNofPointsUsed.cbegin(), fvNofPointsUsed.cbegin() + static_cast<int>(detID) + 1, 0); } @@ -112,7 +115,7 @@ namespace cbm::ca::tools /// /// The function calculates global external index of MC point as a sum of a given local index and total provided /// number of points in previous detector subsystem. - int GetPointGlobExtIndex(L1DetectorID detID, int iPointLocal) const + int GetPointGlobExtIndex(ca::EDetectorID detID, int iPointLocal) const { return iPointLocal + std::accumulate(fvNofPointsOrig.cbegin(), fvNofPointsOrig.cbegin() + int(detID), 0); } @@ -125,11 +128,11 @@ namespace cbm::ca::tools /// @brief Gets original number of MC points in different detectors /// @param detID Detector ID - int GetNofPointsOrig(L1DetectorID detID) const { return fvNofPointsOrig[static_cast<int>(detID)]; } + int GetNofPointsOrig(ca::EDetectorID detID) const { return fvNofPointsOrig[static_cast<int>(detID)]; } /// @brief Gets used number of MC points in different detectors /// @param detID Detector ID - int GetNofPointsUsed(L1DetectorID detID) const { return fvNofPointsUsed[static_cast<int>(detID)]; } + int GetNofPointsUsed(ca::EDetectorID detID) const { return fvNofPointsUsed[static_cast<int>(detID)]; } /// Gets a reference to MC point by its index const auto& GetPoint(int idx) const { return fvPoints[idx]; } @@ -170,7 +173,7 @@ namespace cbm::ca::tools /// @brief Sets original number of MC points in different detectors /// @param detID Detector ID /// @param nPoints Number of points - void SetNofPointsOrig(L1DetectorID detID, int nPoints) { fvNofPointsOrig[static_cast<int>(detID)] = nPoints; } + void SetNofPointsOrig(ca::EDetectorID detID, int nPoints) { fvNofPointsOrig[static_cast<int>(detID)] = nPoints; } /// Prints an example of tracks and points /// \param verbose Verbose level: diff --git a/reco/L1/catools/CaToolsMCPoint.h b/reco/L1/catools/CaToolsMCPoint.h index ecaf567af5..8a8b668668 100644 --- a/reco/L1/catools/CaToolsMCPoint.h +++ b/reco/L1/catools/CaToolsMCPoint.h @@ -18,7 +18,10 @@ using namespace cbm::algo::ca; //TODO: remove -enum class L1DetectorID; +namespace cbm::algo::ca +{ + enum class EDetectorID; +} namespace cbm::ca::tools { @@ -61,7 +64,7 @@ namespace cbm::ca::tools double GetCharge() const { return fCharge; } /// @brief Gets detector ID - L1DetectorID GetDetectorId() const { return fDetectorId; } + ca::EDetectorID GetDetectorId() const { return fDetectorId; } /// @brief Gets MC event ID int GetEventId() const { return fLinkKey.fEvent; } @@ -235,7 +238,7 @@ namespace cbm::ca::tools void SetCharge(double charge) { fCharge = charge; } /// @brief Sets detector ID - void SetDetectorId(L1DetectorID detId) { fDetectorId = detId; } + void SetDetectorId(ca::EDetectorID detId) { fDetectorId = detId; } /// @brief Sets index of MC event containing this point void SetEventId(int eventId) { fLinkKey.fEvent = eventId; } @@ -361,7 +364,7 @@ namespace cbm::ca::tools int fMotherId = constants::Undef<int>; ///< Index of mother track in CA internal data structures (within event/TS) int fStationId = constants::Undef<int>; ///< Global index of active tracking station - L1DetectorID fDetectorId; ///< Detector ID of MC point + ca::EDetectorID fDetectorId; ///< Detector ID of MC point // TODO: SZh 17.05.2023: Check, if there are more then one index can be added ca::Vector<int> fvHitIndexes {"ca::tools::MCPoint::fvHitIndexes"}; ///< Indexes of hits, assigned to this point diff --git a/reco/L1/catools/CaToolsWindowFinder.cxx b/reco/L1/catools/CaToolsWindowFinder.cxx index 935b590349..5ecdbf1e0a 100644 --- a/reco/L1/catools/CaToolsWindowFinder.cxx +++ b/reco/L1/catools/CaToolsWindowFinder.cxx @@ -24,14 +24,15 @@ #include <yaml-cpp/yaml.h> +#include "CaConfigReader.h" #include "CaConstants.h" #include "CaSearchWindow.h" #include "CaToolsWFExpression.h" -#include "L1ConfigRW.h" using namespace cbm::ca::tools; using namespace cbm::algo::ca::constants; // for colored logs +using cbm::algo::ca::ConfigReader; using cbm::algo::ca::Iteration; using cbm::algo::ca::SearchWindow; @@ -269,7 +270,7 @@ void WindowFinder::Process(Option_t* /*opt*/) // void WindowFinder::ReadTrackingIterationsFromYAML(const char* filename) { - L1ConfigRW reader(/*pInitManager = */ nullptr, 0); + ca::ConfigReader reader(/*pInitManager = */ nullptr, 0); reader.SetMainConfigPath(filename); // Get iterations diff --git a/reco/L1/qa/CbmCaInputQaBase.cxx b/reco/L1/qa/CbmCaInputQaBase.cxx index dea0fb1c17..d7e4ded129 100644 --- a/reco/L1/qa/CbmCaInputQaBase.cxx +++ b/reco/L1/qa/CbmCaInputQaBase.cxx @@ -10,6 +10,7 @@ #include "CbmCaInputQaBase.h" #include "CbmAddress.h" +#include "CbmL1DetectorID.h" #include "CbmMCDataArray.h" #include "CbmMCEventList.h" #include "CbmMCTrack.h" @@ -59,9 +60,14 @@ using namespace cbm::algo::ca::constants; +namespace +{ + namespace ca = cbm::algo::ca; +} + // --------------------------------------------------------------------------------------------------------------------- // -template<L1DetectorID DetID> +template<ca::EDetectorID DetID> CbmCaInputQaBase<DetID>::CbmCaInputQaBase(const char* name, int verbose, bool isMCUsed) : CbmQaTask(name, verbose, isMCUsed) { @@ -69,7 +75,7 @@ CbmCaInputQaBase<DetID>::CbmCaInputQaBase(const char* name, int verbose, bool is // --------------------------------------------------------------------------------------------------------------------- // -template<L1DetectorID DetID> +template<ca::EDetectorID DetID> bool CbmCaInputQaBase<DetID>::Check() { bool res = true; @@ -231,7 +237,7 @@ bool CbmCaInputQaBase<DetID>::Check() // --------------------------------------------------------------------------------------------------------------------- // -template<L1DetectorID DetID> +template<ca::EDetectorID DetID> void CbmCaInputQaBase<DetID>::DeInit() { // Vectors with pointers to histograms @@ -286,7 +292,7 @@ void CbmCaInputQaBase<DetID>::DeInit() // --------------------------------------------------------------------------------------------------------------------- // -template<L1DetectorID DetID> +template<ca::EDetectorID DetID> void CbmCaInputQaBase<DetID>::FillHistograms() { int nSt = fpDetInterface->GetNtrackingStations(); @@ -318,7 +324,7 @@ void CbmCaInputQaBase<DetID>::FillHistograms() const auto* pHit = dynamic_cast<const CbmPixelHit*>(fpHits->At(iH)); LOG_IF(fatal, !pHit) << fName << ": hit with iH = " << iH << " is not an CbmStsHit (dynamic cast failed)"; - if constexpr (L1DetectorID::kTof == DetID) { + if constexpr (ca::EDetectorID::kTof == DetID) { auto address = pHit->GetAddress(); if (0x00202806 == address || 0x00002806 == address) { continue; } // TEST if (5 == CbmTofAddress::GetSmType(address)) { continue; } // Skip T0 hits @@ -495,7 +501,7 @@ void CbmCaInputQaBase<DetID>::FillHistograms() fHitQaData.SetPointZ(fHitQaData.GetHitZ()); double zRes = kNAN; - if constexpr (L1DetectorID::kTof == DetID) { zRes = fHitQaData.GetHitZ() - pMCPoint->GetZ(); } + if constexpr (ca::EDetectorID::kTof == DetID) { zRes = fHitQaData.GetHitZ() - pMCPoint->GetZ(); } else { zRes = fHitQaData.GetHitZ() - 0.5 * (pMCPoint->GetZ() + pMCPoint->GetZOut()); } @@ -643,7 +649,7 @@ void CbmCaInputQaBase<DetID>::FillHistograms() // --------------------------------------------------------------------------------------------------------------------- // -template<L1DetectorID DetID> +template<ca::EDetectorID DetID> InitStatus CbmCaInputQaBase<DetID>::InitDataBranches() { LOG_IF(fatal, !fpDetInterface) << "\033[1;31m" << fName << ": tracking detector interface is undefined\033[0m"; @@ -735,7 +741,7 @@ InitStatus CbmCaInputQaBase<DetID>::InitDataBranches() frYmin[i] -= dy; frYmax[i] += dy; - if constexpr (L1DetectorID::kMuch == DetID) { + if constexpr (ca::EDetectorID::kMuch == DetID) { frZmin[i] -= 40; frZmax[i] += 40; } @@ -752,7 +758,7 @@ InitStatus CbmCaInputQaBase<DetID>::InitDataBranches() // --------------------------------------------------------------------------------------------------------------------- // -template<L1DetectorID DetID> +template<ca::EDetectorID DetID> InitStatus CbmCaInputQaBase<DetID>::InitHistograms() { int nSt = fpDetInterface->GetNtrackingStations(); @@ -763,7 +769,7 @@ InitStatus CbmCaInputQaBase<DetID>::InitHistograms() // ----- Subdirectories MakeQaDirectory("Summary"); MakeQaDirectory("Summary/vs Station"); - if constexpr (L1DetectorID::kSts == DetID) { MakeQaDirectory("Summary/vs N digi"); } + if constexpr (ca::EDetectorID::kSts == DetID) { MakeQaDirectory("Summary/vs N digi"); } MakeQaDirectory("All stations"); // ----- Histograms initialization @@ -1020,7 +1026,7 @@ InitStatus CbmCaInputQaBase<DetID>::InitHistograms() // // TODO: rename the method to Finish or Finalise or MakeSummary, since it does more than just canvases // -template<L1DetectorID DetID> +template<ca::EDetectorID DetID> InitStatus CbmCaInputQaBase<DetID>::InitCanvases() { gStyle->SetOptFit(1); @@ -1389,7 +1395,7 @@ InitStatus CbmCaInputQaBase<DetID>::InitCanvases() // --------------------------------------------------------------------------------------------------------------------- // -template<L1DetectorID DetID> +template<ca::EDetectorID DetID> bool CbmCaInputQaBase<DetID>::IsTrackSelected(const CbmMCTrack* track, const Point_t* point) const { assert(point); @@ -1399,7 +1405,7 @@ bool CbmCaInputQaBase<DetID>::IsTrackSelected(const CbmMCTrack* track, const Poi double px = std::numeric_limits<double>::signaling_NaN(); double py = std::numeric_limits<double>::signaling_NaN(); double pz = std::numeric_limits<double>::signaling_NaN(); - if constexpr (L1DetectorID::kTof == DetID) { + if constexpr (ca::EDetectorID::kTof == DetID) { px = point->GetPx(); py = point->GetPy(); pz = point->GetPz(); @@ -1420,8 +1426,8 @@ bool CbmCaInputQaBase<DetID>::IsTrackSelected(const CbmMCTrack* track, const Poi return true; } -template class CbmCaInputQaBase<L1DetectorID::kMvd>; -template class CbmCaInputQaBase<L1DetectorID::kSts>; -template class CbmCaInputQaBase<L1DetectorID::kMuch>; -template class CbmCaInputQaBase<L1DetectorID::kTrd>; -template class CbmCaInputQaBase<L1DetectorID::kTof>; +template class CbmCaInputQaBase<ca::EDetectorID::kMvd>; +template class CbmCaInputQaBase<ca::EDetectorID::kSts>; +template class CbmCaInputQaBase<ca::EDetectorID::kMuch>; +template class CbmCaInputQaBase<ca::EDetectorID::kTrd>; +template class CbmCaInputQaBase<ca::EDetectorID::kTof>; diff --git a/reco/L1/qa/CbmCaInputQaBase.h b/reco/L1/qa/CbmCaInputQaBase.h index d3a8292d89..44a9cc377a 100644 --- a/reco/L1/qa/CbmCaInputQaBase.h +++ b/reco/L1/qa/CbmCaInputQaBase.h @@ -38,9 +38,13 @@ class TH2F; class TProfile; class TProfile2D; +namespace +{ + using cbm::algo::ca::EDetectorID; +} /// A QA-task class, which provides assurance of MuCh hits and geometry -template<L1DetectorID DetID> +template<EDetectorID DetID> class CbmCaInputQaBase : public CbmQaTask { protected: using Point_t = cbm::ca::PointTypes_t::at<DetID>; ///< Point type for detector ID diff --git a/reco/L1/qa/CbmCaInputQaMuch.h b/reco/L1/qa/CbmCaInputQaMuch.h index 8909114439..8839c8b2b0 100644 --- a/reco/L1/qa/CbmCaInputQaMuch.h +++ b/reco/L1/qa/CbmCaInputQaMuch.h @@ -15,7 +15,7 @@ /// A QA-task class, which provides assurance of TOF hits and geometry /// -class CbmCaInputQaMuch : public CbmCaInputQaBase<L1DetectorID::kMuch> { +class CbmCaInputQaMuch : public CbmCaInputQaBase<cbm::algo::ca::EDetectorID::kMuch> { public: /// @brief Constructor from parameters /// @param verbose Verbose level diff --git a/reco/L1/qa/CbmCaInputQaMvd.h b/reco/L1/qa/CbmCaInputQaMvd.h index 3c5c0daa71..2209f66278 100644 --- a/reco/L1/qa/CbmCaInputQaMvd.h +++ b/reco/L1/qa/CbmCaInputQaMvd.h @@ -15,7 +15,7 @@ /// A QA-task class, which provides assurance of TOF hits and geometry /// -class CbmCaInputQaMvd : public CbmCaInputQaBase<L1DetectorID::kTrd> { +class CbmCaInputQaMvd : public CbmCaInputQaBase<cbm::algo::ca::EDetectorID::kTrd> { public: /// @brief Constructor from parameters /// @param verbose Verbose level diff --git a/reco/L1/qa/CbmCaInputQaSetup.cxx b/reco/L1/qa/CbmCaInputQaSetup.cxx index 0a884a8164..73c80cb5a7 100644 --- a/reco/L1/qa/CbmCaInputQaSetup.cxx +++ b/reco/L1/qa/CbmCaInputQaSetup.cxx @@ -16,8 +16,9 @@ #include "TAxis.h" #include "AlgoFairloggerCompat.h" -#include "L1InitManager.h" +#include "CaInitManager.h" +using cbm::algo::ca::InitManager; using cbm::algo::ca::Parameters; using cbm::ca::InputQaSetup; @@ -35,7 +36,7 @@ bool InputQaSetup::Check() { return true; } void InputQaSetup::CheckInit() const { if (IsMCUsed() && !fpMCEventHeader) { throw std::logic_error("MC event header branch is unavailable"); } - for (int iD = 0; iD < static_cast<int>(L1DetectorID::kEND); ++iD) { + for (int iD = 0; iD < static_cast<int>(ca::EDetectorID::kEND); ++iD) { if (fvbUseDet[iD]) { if (!fvpBrHits[iD]) { throw std::logic_error(Form("Hit branch is unavailable for %s", kDetName[iD])); } if (IsMCUsed() && !fvpBrPoints[iD]) { @@ -49,11 +50,11 @@ void InputQaSetup::CheckInit() const // void InputQaSetup::FillHistograms() { - if (fvbUseDet[L1DetectorID::kMvd]) { this->FillHistogramsDet<L1DetectorID::kMvd>(); } - if (fvbUseDet[L1DetectorID::kSts]) { this->FillHistogramsDet<L1DetectorID::kSts>(); } - if (fvbUseDet[L1DetectorID::kMuch]) { this->FillHistogramsDet<L1DetectorID::kMuch>(); } - if (fvbUseDet[L1DetectorID::kTrd]) { this->FillHistogramsDet<L1DetectorID::kTrd>(); } - if (fvbUseDet[L1DetectorID::kTof]) { this->FillHistogramsDet<L1DetectorID::kTof>(); } + if (fvbUseDet[ca::EDetectorID::kMvd]) { this->FillHistogramsDet<ca::EDetectorID::kMvd>(); } + if (fvbUseDet[ca::EDetectorID::kSts]) { this->FillHistogramsDet<ca::EDetectorID::kSts>(); } + if (fvbUseDet[ca::EDetectorID::kMuch]) { this->FillHistogramsDet<ca::EDetectorID::kMuch>(); } + if (fvbUseDet[ca::EDetectorID::kTrd]) { this->FillHistogramsDet<ca::EDetectorID::kTrd>(); } + if (fvbUseDet[ca::EDetectorID::kTof]) { this->FillHistogramsDet<ca::EDetectorID::kTof>(); } } // --------------------------------------------------------------------------------------------------------------------- @@ -91,7 +92,7 @@ InitStatus InputQaSetup::InitCanvases() if (!fvbUseDet[iDet]) { continue; } int nSt = fvpDetInterface[iDet]->GetNtrackingStations(); for (int iSt = 0; iSt < nSt; ++iSt) { - int iStActive = fpParameters->GetStationIndexActive(iSt, static_cast<L1DetectorID>(iDet)); + int iStActive = fpParameters->GetStationIndexActive(iSt, static_cast<ca::EDetectorID>(iDet)); Color_t boxColor = (iStActive == -1) ? kGray + 1 : kOrange + 2; const char* detName = Form("%s-%d", fvpDetInterface[iDet]->GetDetectorName().c_str(), iSt); { @@ -141,11 +142,10 @@ try { LOG(info) << fName << ": initializing... "; // Tracking parameters { - fpParameters = std::make_unique<ca::Parameters>(); - L1InitManager manager; + ca::InitManager manager; manager.ReadParametersObject(fsParametersFilename.c_str()); - manager.SendParameters(*fpParameters); + fpParameters = std::make_unique<ca::Parameters>(manager.TakeParameters()); LOG(info) << "CA tracking parameters object: " << fsParametersFilename << '\n' << fpParameters->ToString(1); } @@ -158,7 +158,7 @@ try { fvpBrPoints.fill(nullptr); fvpBrHits.fill(nullptr); - auto InitDetInterface = [&](CbmTrackingDetectorInterfaceBase* ifs, L1DetectorID detID) { + auto InitDetInterface = [&](CbmTrackingDetectorInterfaceBase* ifs, ca::EDetectorID detID) { if (fvbUseDet[detID]) { fvpDetInterface[detID] = ifs; int nSt = ifs->GetNtrackingStations(); @@ -171,31 +171,31 @@ try { } }; - auto InitHitBranch = [&](const char* brName, L1DetectorID detID) { + auto InitHitBranch = [&](const char* brName, ca::EDetectorID detID) { if (fvbUseDet[detID]) { fvpBrHits[detID] = dynamic_cast<TClonesArray*>(pFairManager->GetObject(brName)); } }; - auto InitPointBranch = [&](const char* brName, L1DetectorID detID) { + auto InitPointBranch = [&](const char* brName, ca::EDetectorID detID) { if (IsMCUsed() && fvbUseDet[detID]) { fvpBrPoints[detID] = pMcManager->InitBranch(brName); } }; - InitDetInterface(CbmMvdTrackingInterface::Instance(), L1DetectorID::kMvd); - InitDetInterface(CbmStsTrackingInterface::Instance(), L1DetectorID::kSts); - InitDetInterface(CbmMuchTrackingInterface::Instance(), L1DetectorID::kMuch); - InitDetInterface(CbmTrdTrackingInterface::Instance(), L1DetectorID::kTrd); - InitDetInterface(CbmTofTrackingInterface::Instance(), L1DetectorID::kTof); + InitDetInterface(CbmMvdTrackingInterface::Instance(), ca::EDetectorID::kMvd); + InitDetInterface(CbmStsTrackingInterface::Instance(), ca::EDetectorID::kSts); + InitDetInterface(CbmMuchTrackingInterface::Instance(), ca::EDetectorID::kMuch); + InitDetInterface(CbmTrdTrackingInterface::Instance(), ca::EDetectorID::kTrd); + InitDetInterface(CbmTofTrackingInterface::Instance(), ca::EDetectorID::kTof); - InitHitBranch("MvdHit", L1DetectorID::kMvd); - InitHitBranch("StsHit", L1DetectorID::kSts); - InitHitBranch("MuchPixelHit", L1DetectorID::kMuch); - InitHitBranch("TrdHit", L1DetectorID::kTrd); - InitHitBranch("TofHit", L1DetectorID::kTof); + InitHitBranch("MvdHit", ca::EDetectorID::kMvd); + InitHitBranch("StsHit", ca::EDetectorID::kSts); + InitHitBranch("MuchPixelHit", ca::EDetectorID::kMuch); + InitHitBranch("TrdHit", ca::EDetectorID::kTrd); + InitHitBranch("TofHit", ca::EDetectorID::kTof); - InitPointBranch("MvdPoint", L1DetectorID::kMvd); - InitPointBranch("StsPoint", L1DetectorID::kSts); - InitPointBranch("MuchPoint", L1DetectorID::kMuch); - InitPointBranch("TrdPoint", L1DetectorID::kTrd); - InitPointBranch("TofPoint", L1DetectorID::kTof); + InitPointBranch("MvdPoint", ca::EDetectorID::kMvd); + InitPointBranch("StsPoint", ca::EDetectorID::kSts); + InitPointBranch("MuchPoint", ca::EDetectorID::kMuch); + InitPointBranch("TrdPoint", ca::EDetectorID::kTrd); + InitPointBranch("TofPoint", ca::EDetectorID::kTof); this->CheckInit(); @@ -214,7 +214,7 @@ InitStatus InputQaSetup::InitHistograms() int nStGeo = fpParameters->GetNstationsGeometry(); MakeQaDirectory("hit_occupancy"); - for (int iD = 0; iD < static_cast<int>(L1DetectorID::kEND); ++iD) { + for (int iD = 0; iD < static_cast<int>(ca::EDetectorID::kEND); ++iD) { if (fvbUseDet[iD]) { MakeQaDirectory(Form("hit_occupancy/%s", kDetName[iD])); } } diff --git a/reco/L1/qa/CbmCaInputQaSetup.h b/reco/L1/qa/CbmCaInputQaSetup.h index 2c22fb81a9..e98e56ca33 100644 --- a/reco/L1/qa/CbmCaInputQaSetup.h +++ b/reco/L1/qa/CbmCaInputQaSetup.h @@ -52,7 +52,7 @@ namespace cbm::ca void ReadParameters(const char* filename) { fsParametersFilename = filename; } /// @brief Sets detector flag - void SetDetectorFlag(L1DetectorID detID, bool flag = true) { fvbUseDet[detID] = flag; } + void SetDetectorFlag(ca::EDetectorID detID, bool flag = true) { fvbUseDet[detID] = flag; } /// @brief Checks results of the QA and returns a success flag bool Check(); @@ -77,7 +77,7 @@ namespace cbm::ca void CheckInit() const; /// @brief Fill histograms for a given detector type - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> void FillHistogramsDet(); @@ -111,45 +111,45 @@ namespace cbm::ca std::vector<TH2F*> fph_point_xz = {}; ///< MC point occupancy in x-z plane vs. station std::vector<TH2F*> fph_point_yz = {}; ///< MC point occupancy in y-z plane vs. station }; -} // namespace cbm::ca -// ------------------------------------------------------------------------------------------------------------------- -// -template<L1DetectorID DetID> -void cbm::ca::InputQaSetup::FillHistogramsDet() -{ - using Hit_t = HitTypes_t::at<DetID>; - int nHits = fvpBrHits[DetID]->GetEntriesFast(); - - for (int iH = 0; iH < nHits; ++iH) { - const auto* pHit = dynamic_cast<const Hit_t*>(fvpBrHits[DetID]->At(iH)); - if (!pHit) { - LOG(warn) << fName << ": hit with iH = " << iH << " for detector " << kDetName[DetID] << " is not found"; - } - auto address = pHit->GetAddress(); - - // skip T0 hits - if constexpr (L1DetectorID::kTof == DetID) { - if (5 == CbmTofAddress::GetSmType(address)) { continue; } - } - - int iStLoc = fvpDetInterface[DetID]->GetTrackingStationIndex(address); - int iStGeo = fpParameters->GetStationIndexGeometry(iStLoc, DetID); - auto xHit = pHit->GetX(); - auto yHit = pHit->GetY(); - auto zHit = pHit->GetZ(); - if (fvXmin[DetID][iStLoc] > xHit) { fvXmin[DetID][iStLoc] = xHit; } - if (fvXmax[DetID][iStLoc] < xHit) { fvXmax[DetID][iStLoc] = xHit; } - if (fvYmin[DetID][iStLoc] > yHit) { fvYmin[DetID][iStLoc] = yHit; } - if (fvYmax[DetID][iStLoc] < yHit) { fvYmax[DetID][iStLoc] = yHit; } - if (fvZmin[DetID][iStLoc] > zHit) { fvZmin[DetID][iStLoc] = zHit; } - if (fvZmax[DetID][iStLoc] < zHit) { fvZmax[DetID][iStLoc] = zHit; } - - fph_hit_xz[iStGeo]->Fill(zHit, xHit); - fph_hit_yz[iStGeo]->Fill(zHit, yHit); - fph_hit_xz.back()->Fill(zHit, xHit); - fph_hit_yz.back()->Fill(zHit, yHit); - } // iH -} + // ----------------------------------------------------------------------------------------------------------------- + // + template<ca::EDetectorID DetID> + void InputQaSetup::FillHistogramsDet() + { + using Hit_t = HitTypes_t::at<DetID>; + int nHits = fvpBrHits[DetID]->GetEntriesFast(); + + for (int iH = 0; iH < nHits; ++iH) { + const auto* pHit = dynamic_cast<const Hit_t*>(fvpBrHits[DetID]->At(iH)); + if (!pHit) { + LOG(warn) << fName << ": hit with iH = " << iH << " for detector " << kDetName[DetID] << " is not found"; + } + auto address = pHit->GetAddress(); + + // skip T0 hits + if constexpr (ca::EDetectorID::kTof == DetID) { + if (5 == CbmTofAddress::GetSmType(address)) { continue; } + } + + int iStLoc = fvpDetInterface[DetID]->GetTrackingStationIndex(address); + int iStGeo = fpParameters->GetStationIndexGeometry(iStLoc, DetID); + auto xHit = pHit->GetX(); + auto yHit = pHit->GetY(); + auto zHit = pHit->GetZ(); + if (fvXmin[DetID][iStLoc] > xHit) { fvXmin[DetID][iStLoc] = xHit; } + if (fvXmax[DetID][iStLoc] < xHit) { fvXmax[DetID][iStLoc] = xHit; } + if (fvYmin[DetID][iStLoc] > yHit) { fvYmin[DetID][iStLoc] = yHit; } + if (fvYmax[DetID][iStLoc] < yHit) { fvYmax[DetID][iStLoc] = yHit; } + if (fvZmin[DetID][iStLoc] > zHit) { fvZmin[DetID][iStLoc] = zHit; } + if (fvZmax[DetID][iStLoc] < zHit) { fvZmax[DetID][iStLoc] = zHit; } + + fph_hit_xz[iStGeo]->Fill(zHit, xHit); + fph_hit_yz[iStGeo]->Fill(zHit, yHit); + fph_hit_xz.back()->Fill(zHit, xHit); + fph_hit_yz.back()->Fill(zHit, yHit); + } // iH + } +} // namespace cbm::ca #endif // CbmCaInputQaSetup_h diff --git a/reco/L1/qa/CbmCaInputQaSts.h b/reco/L1/qa/CbmCaInputQaSts.h index 404c86c1f5..7c71d12b52 100644 --- a/reco/L1/qa/CbmCaInputQaSts.h +++ b/reco/L1/qa/CbmCaInputQaSts.h @@ -37,7 +37,7 @@ class TProfile; class TProfile2D; /// A QA-task class, which provides assurance of MuCh hits and geometry -class CbmCaInputQaSts : public CbmCaInputQaBase<L1DetectorID::kSts> { +class CbmCaInputQaSts : public CbmCaInputQaBase<cbm::algo::ca::EDetectorID::kSts> { public: /// Constructor from parameters /// \param verbose Verbose level diff --git a/reco/L1/qa/CbmCaInputQaTof.h b/reco/L1/qa/CbmCaInputQaTof.h index 7ea55a0318..49a99189b0 100644 --- a/reco/L1/qa/CbmCaInputQaTof.h +++ b/reco/L1/qa/CbmCaInputQaTof.h @@ -42,7 +42,7 @@ class CbmTofDigiBdfPar; /// A QA-task class, which provides assurance of TOF hits and geometry /// -class CbmCaInputQaTof : public CbmCaInputQaBase<L1DetectorID::kTof> { +class CbmCaInputQaTof : public CbmCaInputQaBase<cbm::algo::ca::EDetectorID::kTof> { public: /// @brief Constructor from parameters /// @param verbose Verbose level diff --git a/reco/L1/qa/CbmCaInputQaTrd.h b/reco/L1/qa/CbmCaInputQaTrd.h index 4d5c498260..c6080bd087 100644 --- a/reco/L1/qa/CbmCaInputQaTrd.h +++ b/reco/L1/qa/CbmCaInputQaTrd.h @@ -15,7 +15,7 @@ /// A QA-task class, which provides assurance of TOF hits and geometry /// -class CbmCaInputQaTrd : public CbmCaInputQaBase<L1DetectorID::kTrd> { +class CbmCaInputQaTrd : public CbmCaInputQaBase<cbm::algo::ca::EDetectorID::kTrd> { public: /// @brief Constructor from parameters /// @param verbose Verbose level diff --git a/reco/L1/qa/CbmCaOutputQa.cxx b/reco/L1/qa/CbmCaOutputQa.cxx index 407430a171..75152fdbe4 100644 --- a/reco/L1/qa/CbmCaOutputQa.cxx +++ b/reco/L1/qa/CbmCaOutputQa.cxx @@ -21,8 +21,10 @@ #include "TPad.h" #include "TText.h" -#include "L1InitManager.h" +#include "CaInitManager.h" +using cbm::algo::ca::InitManager; +using cbm::algo::ca::Parameters; using cbm::ca::MCModule; using cbm::ca::OutputQa; using cbm::ca::tools::Debugger; @@ -433,11 +435,11 @@ InitStatus OutputQa::InitDataBranches() // Initialize time slice reader instance fpTSReader->SetTrackingMode(fTrackingMode); - fpTSReader->SetDetector(L1DetectorID::kMvd, fbUseMvd); - fpTSReader->SetDetector(L1DetectorID::kSts, fbUseSts); - fpTSReader->SetDetector(L1DetectorID::kMuch, fbUseMuch); - fpTSReader->SetDetector(L1DetectorID::kTrd, fbUseTrd); - fpTSReader->SetDetector(L1DetectorID::kTof, fbUseTof); + fpTSReader->SetDetector(ca::EDetectorID::kMvd, fbUseMvd); + fpTSReader->SetDetector(ca::EDetectorID::kSts, fbUseSts); + fpTSReader->SetDetector(ca::EDetectorID::kMuch, fbUseMuch); + fpTSReader->SetDetector(ca::EDetectorID::kTrd, fbUseTrd); + fpTSReader->SetDetector(ca::EDetectorID::kTof, fbUseTof); fpTSReader->RegisterParameters(fpParameters); fpTSReader->RegisterTracksContainer(fvRecoTracks); @@ -448,11 +450,11 @@ InitStatus OutputQa::InitDataBranches() // Initialize MC module if (IsMCUsed()) { fpMCModule = std::make_shared<MCModule>(fVerbose, fPerformanceMode); - fpMCModule->SetDetector(L1DetectorID::kMvd, fbUseMvd); - fpMCModule->SetDetector(L1DetectorID::kSts, fbUseSts); - fpMCModule->SetDetector(L1DetectorID::kMuch, fbUseMuch); - fpMCModule->SetDetector(L1DetectorID::kTrd, fbUseTrd); - fpMCModule->SetDetector(L1DetectorID::kTof, fbUseTof); + fpMCModule->SetDetector(ca::EDetectorID::kMvd, fbUseMvd); + fpMCModule->SetDetector(ca::EDetectorID::kSts, fbUseSts); + fpMCModule->SetDetector(ca::EDetectorID::kMuch, fbUseMuch); + fpMCModule->SetDetector(ca::EDetectorID::kTrd, fbUseTrd); + fpMCModule->SetDetector(ca::EDetectorID::kTof, fbUseTof); fpMCModule->RegisterMCData(fMCData); fpMCModule->RegisterRecoTrackContainer(fvRecoTracks); @@ -971,13 +973,11 @@ InitStatus OutputQa::InitTimeSlice() // void OutputQa::ReadParameters(const char* filename) { - fpParameters = std::make_shared<ca::Parameters>(); - - L1InitManager manager; + ca::InitManager manager; manager.ReadParametersObject(filename); - manager.SendParameters(*fpParameters); + fpParameters = std::make_shared<ca::Parameters>(manager.TakeParameters()); - LOG(info) << fpParameters->ToString(1); + LOG(info) << '\n' << fpParameters->ToString(1); } // --------------------------------------------------------------------------------------------------------------------- diff --git a/reco/L1/utils/CbmCaIdealHitProducer.cxx b/reco/L1/utils/CbmCaIdealHitProducer.cxx index 441dc328b2..896ea94fe1 100644 --- a/reco/L1/utils/CbmCaIdealHitProducer.cxx +++ b/reco/L1/utils/CbmCaIdealHitProducer.cxx @@ -20,19 +20,19 @@ ClassImp(cbm::ca::IdealHitProducer); // InitStatus IdealHitProducer::Init() { - fbUseDet[L1DetectorID::kMvd] = false; //CbmSetup::Instance()->IsActive(ECbmModuleId::kMvd); - fbUseDet[L1DetectorID::kSts] = CbmSetup::Instance()->IsActive(ECbmModuleId::kSts); - fbUseDet[L1DetectorID::kMuch] = CbmSetup::Instance()->IsActive(ECbmModuleId::kMuch); - fbUseDet[L1DetectorID::kTrd] = CbmSetup::Instance()->IsActive(ECbmModuleId::kTrd); - fbUseDet[L1DetectorID::kTof] = false; //CbmSetup::Instance()->IsActive(ECbmModuleId::kTof); + fbUseDet[ca::EDetectorID::kMvd] = false; //CbmSetup::Instance()->IsActive(ECbmModuleId::kMvd); + fbUseDet[ca::EDetectorID::kSts] = CbmSetup::Instance()->IsActive(ECbmModuleId::kSts); + fbUseDet[ca::EDetectorID::kMuch] = CbmSetup::Instance()->IsActive(ECbmModuleId::kMuch); + fbUseDet[ca::EDetectorID::kTrd] = CbmSetup::Instance()->IsActive(ECbmModuleId::kTrd); + fbUseDet[ca::EDetectorID::kTof] = false; //CbmSetup::Instance()->IsActive(ECbmModuleId::kTof); InitStatus ret = kSUCCESS; - if (fbUseDet[L1DetectorID::kMvd]) { ret = std::max(fHitProducerMvd.Init(), ret); } - if (fbUseDet[L1DetectorID::kSts]) { ret = std::max(fHitProducerSts.Init(), ret); } - if (fbUseDet[L1DetectorID::kMuch]) { ret = std::max(fHitProducerMuch.Init(), ret); } - if (fbUseDet[L1DetectorID::kTrd]) { ret = std::max(fHitProducerTrd.Init(), ret); } - if (fbUseDet[L1DetectorID::kTof]) { ret = std::max(fHitProducerTof.Init(), ret); } + if (fbUseDet[ca::EDetectorID::kMvd]) { ret = std::max(fHitProducerMvd.Init(), ret); } + if (fbUseDet[ca::EDetectorID::kSts]) { ret = std::max(fHitProducerSts.Init(), ret); } + if (fbUseDet[ca::EDetectorID::kMuch]) { ret = std::max(fHitProducerMuch.Init(), ret); } + if (fbUseDet[ca::EDetectorID::kTrd]) { ret = std::max(fHitProducerTrd.Init(), ret); } + if (fbUseDet[ca::EDetectorID::kTof]) { ret = std::max(fHitProducerTof.Init(), ret); } return kSUCCESS; } @@ -40,11 +40,11 @@ InitStatus IdealHitProducer::Init() // void IdealHitProducer::Exec(Option_t* option) { - if (fbUseDet[L1DetectorID::kMvd]) { fHitProducerMvd.Exec(option); } - if (fbUseDet[L1DetectorID::kSts]) { fHitProducerSts.Exec(option); } - if (fbUseDet[L1DetectorID::kMuch]) { fHitProducerMuch.Exec(option); } - if (fbUseDet[L1DetectorID::kTrd]) { fHitProducerTrd.Exec(option); } - if (fbUseDet[L1DetectorID::kTof]) { fHitProducerTof.Exec(option); } + if (fbUseDet[ca::EDetectorID::kMvd]) { fHitProducerMvd.Exec(option); } + if (fbUseDet[ca::EDetectorID::kSts]) { fHitProducerSts.Exec(option); } + if (fbUseDet[ca::EDetectorID::kMuch]) { fHitProducerMuch.Exec(option); } + if (fbUseDet[ca::EDetectorID::kTrd]) { fHitProducerTrd.Exec(option); } + if (fbUseDet[ca::EDetectorID::kTof]) { fHitProducerTof.Exec(option); } } // --------------------------------------------------------------------------------------------------------------------- diff --git a/reco/L1/utils/CbmCaIdealHitProducer.h b/reco/L1/utils/CbmCaIdealHitProducer.h index ee11f309d2..736ad0755e 100644 --- a/reco/L1/utils/CbmCaIdealHitProducer.h +++ b/reco/L1/utils/CbmCaIdealHitProducer.h @@ -58,11 +58,11 @@ namespace cbm::ca ClassDef(IdealHitProducer, 1); private: - IdealHitProducerDet<L1DetectorID::kMvd> fHitProducerMvd; ///< Instance of hit producer for MVD - IdealHitProducerDet<L1DetectorID::kSts> fHitProducerSts; ///< Instance of hit producer for STS - IdealHitProducerDet<L1DetectorID::kMuch> fHitProducerMuch; ///< Instance of hit producer for MuCh - IdealHitProducerDet<L1DetectorID::kTrd> fHitProducerTrd; ///< Instance of hit producer for TRD - IdealHitProducerDet<L1DetectorID::kTof> fHitProducerTof; ///< Instance of hit producer for TOF + IdealHitProducerDet<ca::EDetectorID::kMvd> fHitProducerMvd; ///< Instance of hit producer for MVD + IdealHitProducerDet<ca::EDetectorID::kSts> fHitProducerSts; ///< Instance of hit producer for STS + IdealHitProducerDet<ca::EDetectorID::kMuch> fHitProducerMuch; ///< Instance of hit producer for MuCh + IdealHitProducerDet<ca::EDetectorID::kTrd> fHitProducerTrd; ///< Instance of hit producer for TRD + IdealHitProducerDet<ca::EDetectorID::kTof> fHitProducerTof; ///< Instance of hit producer for TOF DetIdArr_t<bool> fbUseDet = {{false}}; ///< Usage flag of different detectors }; diff --git a/reco/L1/utils/CbmCaIdealHitProducerDet.h b/reco/L1/utils/CbmCaIdealHitProducerDet.h index 555714bba5..0673146101 100644 --- a/reco/L1/utils/CbmCaIdealHitProducerDet.h +++ b/reco/L1/utils/CbmCaIdealHitProducerDet.h @@ -65,7 +65,7 @@ namespace cbm::ca /// @brief Ideal hit producer class /// /// - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> class IdealHitProducerDet { public: using Hit_t = HitTypes_t::at<DetID>; @@ -193,7 +193,7 @@ namespace cbm::ca // ------------------------------------------------------------------------------------------------------------------ // - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> IdealHitProducerDet<DetID>::~IdealHitProducerDet() { if (fpBrHitsTmp) { @@ -211,7 +211,7 @@ namespace cbm::ca // ------------------------------------------------------------------------------------------------------------------ // - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> InitStatus IdealHitProducerDet<DetID>::Init() try { auto CheckBranch = [](auto pBranch, const char* brName) { @@ -231,7 +231,7 @@ namespace cbm::ca fpMCEventHeader = pMcManager->GetObject("MCEventHeader."); switch (DetID) { - case L1DetectorID::kMvd: + case ca::EDetectorID::kMvd: fpDetInterface = CbmMvdTrackingInterface::Instance(); fpBrPoints = pMcManager->InitBranch("MvdPoint"); fpBrHits = dynamic_cast<TClonesArray*>(pFairManager->GetObject("MvdHit")); @@ -241,7 +241,7 @@ namespace cbm::ca CheckBranch(fpBrHits, "MvdHit"); CheckBranch(fpBrHitMatches, "MvdHitMatch"); break; - case L1DetectorID::kSts: + case ca::EDetectorID::kSts: fpDetInterface = CbmStsTrackingInterface::Instance(); fpBrPoints = pMcManager->InitBranch("StsPoint"); fpBrHits = dynamic_cast<TClonesArray*>(pFairManager->GetObject("StsHit")); @@ -251,7 +251,7 @@ namespace cbm::ca CheckBranch(fpBrHits, "StsHit"); CheckBranch(fpBrHitMatches, "StsHitMatch"); break; - case L1DetectorID::kMuch: + case ca::EDetectorID::kMuch: fpDetInterface = CbmMuchTrackingInterface::Instance(); fpBrPoints = pMcManager->InitBranch("MuchPoint"); fpBrHits = dynamic_cast<TClonesArray*>(pFairManager->GetObject("MuchPixelHit")); @@ -261,7 +261,7 @@ namespace cbm::ca CheckBranch(fpBrHits, "MuchPixelHit"); CheckBranch(fpBrHitMatches, "MuchPixelHitMatch"); break; - case L1DetectorID::kTrd: + case ca::EDetectorID::kTrd: fpDetInterface = CbmTrdTrackingInterface::Instance(); fpBrPoints = pMcManager->InitBranch("TrdPoint"); fpBrHits = dynamic_cast<TClonesArray*>(pFairManager->GetObject("TrdHit")); @@ -271,7 +271,7 @@ namespace cbm::ca CheckBranch(fpBrHits, "TrdHit"); CheckBranch(fpBrHitMatches, "TrdHitMatch"); break; - case L1DetectorID::kTof: + case ca::EDetectorID::kTof: fpDetInterface = CbmTofTrackingInterface::Instance(); fpBrPoints = pMcManager->InitBranch("TofPoint"); fpBrHits = dynamic_cast<TClonesArray*>(pFairManager->GetObject("TofHit")); @@ -281,9 +281,9 @@ namespace cbm::ca CheckBranch(fpBrHits, "TofHit"); CheckBranch(fpBrHitMatches, "TofHitMatch"); break; - case L1DetectorID::kEND: + case ca::EDetectorID::kEND: LOG(fatal) << "CA ideal hit producer for " << kDetName[DetID] - << ": Wrong template argument is used: L1DetectorID::kEND"; + << ": Wrong template argument is used: ca::EDetectorID::kEND"; break; } @@ -313,7 +313,7 @@ namespace cbm::ca // ------------------------------------------------------------------------------------------------------------------- // - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> void IdealHitProducerDet<DetID>::ParseConfig() { int nStations = fpDetInterface->GetNtrackingStations(); @@ -326,17 +326,17 @@ namespace cbm::ca config = YAML::LoadFile(fsConfigName)["ideal_hit_producer"]; std::string detBranchName = ""; - if constexpr (L1DetectorID::kMvd == DetID) { detBranchName = "mvd"; } - else if constexpr (L1DetectorID::kSts == DetID) { + if constexpr (ca::EDetectorID::kMvd == DetID) { detBranchName = "mvd"; } + else if constexpr (ca::EDetectorID::kSts == DetID) { detBranchName = "sts"; } - else if constexpr (L1DetectorID::kMuch == DetID) { + else if constexpr (ca::EDetectorID::kMuch == DetID) { detBranchName = "much"; } - else if constexpr (L1DetectorID::kTrd == DetID) { + else if constexpr (ca::EDetectorID::kTrd == DetID) { detBranchName = "trd"; } - else if constexpr (L1DetectorID::kTof == DetID) { + else if constexpr (ca::EDetectorID::kTof == DetID) { detBranchName = "tof"; } @@ -403,7 +403,7 @@ namespace cbm::ca // ------------------------------------------------------------------------------------------------------------------- // - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> void IdealHitProducerDet<DetID>::PushBackHit(const HitTypes_t::at<DetID>* pHit) { // Common fields for all the subsystems @@ -413,7 +413,7 @@ namespace cbm::ca pHit->PositionError(dpos); // Fields specific to each detector type - if constexpr (L1DetectorID::kMvd == DetID) { + if constexpr (ca::EDetectorID::kMvd == DetID) { auto statNr = pHit->GetStationNr(); auto iCentrX = pHit->GetIndexCentralX(); auto iCentrY = pHit->GetIndexCentralY(); @@ -425,7 +425,7 @@ namespace cbm::ca auto address = pHit->GetAddress(); auto time = pHit->GetTime(); auto dtime = pHit->GetTimeError(); - if constexpr (L1DetectorID::kSts == DetID) { + if constexpr (ca::EDetectorID::kSts == DetID) { auto dxy = pHit->GetDxy(); auto iClustF = pHit->GetFrontClusterId(); auto iClustB = pHit->GetBackClusterId(); @@ -433,20 +433,20 @@ namespace cbm::ca auto dv = pHit->GetDv(); new ((*fpBrHits)[fHitCounter]) CbmStsHit(address, pos, dpos, dxy, iClustF, iClustB, time, dtime, du, dv); } - else if constexpr (L1DetectorID::kMuch == DetID) { + else if constexpr (ca::EDetectorID::kMuch == DetID) { auto dxy = pHit->GetDxy(); auto refId = pHit->GetRefId(); auto planeId = pHit->GetPlaneId(); LOG(info) << "MUCH: " << pHit->GetRefId() << ' ' << pHit->GetPlaneId(); new ((*fpBrHits)[fHitCounter]) CbmMuchPixelHit(address, pos, dpos, dxy, refId, planeId, time, dtime); } - else if constexpr (L1DetectorID::kTrd == DetID) { + else if constexpr (ca::EDetectorID::kTrd == DetID) { auto dxy = pHit->GetDxy(); auto refId = pHit->GetRefId(); auto eLoss = pHit->GetELoss(); new ((*fpBrHits)[fHitCounter]) CbmTrdHit(address, pos, dpos, dxy, refId, eLoss, time, dtime); } - else if constexpr (L1DetectorID::kTof == DetID) { + else if constexpr (ca::EDetectorID::kTof == DetID) { auto refId = -1; // pHit->GetRefId(); // -> deprecated auto flag = pHit->GetFlag(); auto channel = pHit->GetCh(); @@ -457,11 +457,11 @@ namespace cbm::ca // ------------------------------------------------------------------------------------------------------------------- // - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> std::optional<CbmLink> IdealHitProducerDet<DetID>::GetMatchedPointLink(int iH) { const auto* pHitMatch = dynamic_cast<CbmMatch*>(fpBrHitMatchesTmp->At(iH)); - if constexpr (L1DetectorID::kTof == DetID) { + if constexpr (ca::EDetectorID::kTof == DetID) { LOG(fatal) << "IdealHitFinder: TOF cannot be used until the new MC points scheme will be introduced"; } @@ -475,7 +475,7 @@ namespace cbm::ca // ------------------------------------------------------------------------------------------------------------------- // - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> void IdealHitProducerDet<DetID>::SmearValue(double& value, double sigma, int opt) { switch (opt) { @@ -487,10 +487,10 @@ namespace cbm::ca // ------------------------------------------------------------------------------------------------------------------- // - template<L1DetectorID DetID> + template<ca::EDetectorID DetID> void IdealHitProducerDet<DetID>::Exec(Option_t*) { - assert(L1DetectorID::kTof != DetID); + assert(ca::EDetectorID::kTof != DetID); // ------ Check, if there are any requirement to run the routine for this detector if (!fbRunTheRoutine) { return; } @@ -542,7 +542,7 @@ namespace cbm::ca auto posIn = TVector3 {}; auto posOut = TVector3 {}; - if constexpr (L1DetectorID::kTof == DetID) { + if constexpr (ca::EDetectorID::kTof == DetID) { pPoint->Position(posIn); pPoint->Position(posOut); } @@ -581,7 +581,7 @@ namespace cbm::ca } // IF setting.fMode == 1 // Check out the index of cluster - if constexpr (L1DetectorID::kSts == DetID) { + if constexpr (ca::EDetectorID::kSts == DetID) { iCluster = std::max(pHit->GetFrontClusterId(), iCluster); iCluster = std::max(pHit->GetBackClusterId(), iCluster); } @@ -619,7 +619,7 @@ namespace cbm::ca auto posIn = TVector3 {}; auto posOut = TVector3 {}; - if constexpr (L1DetectorID::kTof == DetID) { + if constexpr (ca::EDetectorID::kTof == DetID) { pPoint->Position(posIn); pPoint->Position(posOut); } @@ -648,27 +648,27 @@ namespace cbm::ca auto dpos = TVector3 {std::sqrt(dx2), std::sqrt(dy2), dz}; // Push back a new artificial hit - if constexpr (L1DetectorID::kMvd == DetID) { new ((*fpBrHits)[fHitCounter]) CbmMvdHit(); } + if constexpr (ca::EDetectorID::kMvd == DetID) { new ((*fpBrHits)[fHitCounter]) CbmMvdHit(); } else { auto address = pPoint->GetDetectorID(); - if constexpr (L1DetectorID::kSts == DetID) { + if constexpr (ca::EDetectorID::kSts == DetID) { int32_t iClustF = iCluster; int32_t iClustB = iCluster + 1; new ((*fpBrHits)[fHitCounter]) CbmStsHit(address, pos, dpos, dxy, iClustF, iClustB, t, dt, du, dv); iCluster += 2; } - else if constexpr (L1DetectorID::kMuch == DetID) { + else if constexpr (ca::EDetectorID::kMuch == DetID) { // TODO: What is planeID in MuCh? int32_t refId = -1; int32_t planeId = -1; new ((*fpBrHits)[fHitCounter]) CbmMuchPixelHit(address, pos, dpos, dxy, refId, planeId, t, dt); } - else if constexpr (L1DetectorID::kTrd == DetID) { + else if constexpr (ca::EDetectorID::kTrd == DetID) { int32_t refId = -1; auto eLoss = pPoint->GetEnergyLoss(); new ((*fpBrHits)[fHitCounter]) CbmTrdHit(address, pos, dpos, dxy, refId, eLoss, t, dt); } - else if constexpr (L1DetectorID::kTof == DetID) { + else if constexpr (ca::EDetectorID::kTof == DetID) { int32_t refId = 0; int32_t flag = 0; int32_t channel = 0; -- GitLab