From d98e0159a5b5a193bf505bfefe95cf831d0406ec Mon Sep 17 00:00:00 2001 From: "s.zharko@gsi.de" <s.zharko@gsi.de> Date: Sun, 8 Oct 2023 01:44:53 +0200 Subject: [PATCH] CA: moved L1Parameters, L1SearchWindow and CaMonitor to cbm::algo::ca --- algo/ca/core/CMakeLists.txt | 6 + algo/ca/core/pars/CaIteration.cxx | 6 +- algo/ca/core/pars/CaIteration.h | 9 +- algo/ca/core/pars/CaMaterialMap.h | 4 +- .../ca/core/pars/CaParameters.cxx | 37 +- algo/ca/core/pars/CaParameters.h | 347 ++++++++++++++++++ .../ca/core/pars/CaSearchWindow.cxx | 47 +-- algo/ca/core/pars/CaSearchWindow.h | 178 +++++++++ algo/ca/core/utils/CaEnumArray.h | 53 +++ .../L1Algo => algo/ca/core}/utils/CaMonitor.h | 4 +- algo/ca/core/utils/CaUtils.h | 5 +- algo/ca/core/utils/CaVector.h | 6 +- algo/log/AlgoFairloggerCompat.h | 3 +- reco/L1/CMakeLists.txt | 6 - reco/L1/CbmCaMCModule.h | 8 +- reco/L1/CbmCaTimeSliceReader.cxx | 2 +- reco/L1/CbmCaTimeSliceReader.h | 10 +- reco/L1/CbmL1.cxx | 7 +- reco/L1/CbmL1.h | 2 +- reco/L1/CbmL1DetectorID.h | 4 +- reco/L1/L1Algo/L1Algo.cxx | 2 +- reco/L1/L1Algo/L1Algo.h | 14 +- reco/L1/L1Algo/L1CloneMerger.cxx | 2 +- reco/L1/L1Algo/L1EArray.h | 48 --- reco/L1/L1Algo/L1InitManager.cxx | 5 +- reco/L1/L1Algo/L1InitManager.h | 17 +- reco/L1/L1Algo/L1Parameters.h | 344 ----------------- reco/L1/L1Algo/L1SearchWindow.h | 172 --------- reco/L1/L1Algo/L1Utils.h | 3 +- reco/L1/L1Algo/utils/CaAlgoRandom.h | 4 +- reco/L1/catools/CaToolsMCData.h | 1 - reco/L1/catools/CaToolsWindowFinder.cxx | 7 +- reco/L1/catools/CaToolsWindowFinder.h | 8 +- reco/L1/qa/CbmCaInputQaSetup.cxx | 5 +- reco/L1/qa/CbmCaInputQaSetup.h | 4 +- reco/L1/qa/CbmCaOutputQa.cxx | 2 +- reco/L1/qa/CbmCaOutputQa.h | 4 +- reco/L1/qa/CbmCaTrackFitQa.h | 5 +- reco/L1/qa/CbmCaTrackTypeQa.h | 6 +- reco/L1/utils/CbmCaIdealHitProducerDet.h | 2 +- 40 files changed, 714 insertions(+), 685 deletions(-) rename reco/L1/L1Algo/L1Parameters.cxx => algo/ca/core/pars/CaParameters.cxx (93%) create mode 100644 algo/ca/core/pars/CaParameters.h rename reco/L1/L1Algo/L1SearchWindow.cxx => algo/ca/core/pars/CaSearchWindow.cxx (66%) create mode 100644 algo/ca/core/pars/CaSearchWindow.h create mode 100644 algo/ca/core/utils/CaEnumArray.h rename {reco/L1/L1Algo => algo/ca/core}/utils/CaMonitor.h (97%) delete mode 100644 reco/L1/L1Algo/L1EArray.h delete mode 100644 reco/L1/L1Algo/L1Parameters.h delete mode 100644 reco/L1/L1Algo/L1SearchWindow.h diff --git a/algo/ca/core/CMakeLists.txt b/algo/ca/core/CMakeLists.txt index 020405c9d7..ec9048169b 100644 --- a/algo/ca/core/CMakeLists.txt +++ b/algo/ca/core/CMakeLists.txt @@ -12,6 +12,8 @@ set(SRCS ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaMaterialMap.cxx ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaStation.cxx ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaIteration.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaParameters.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaSearchWindow.cxx ) add_library(CaCore SHARED ${SRCS}) @@ -47,6 +49,10 @@ install( pars/CaStation.h pars/CaConstants.h pars/CaIteration.h + pars/CaParameters.h + pars/CaSearchWindow.h + utils/CaEnumArray.h + utils/CaMonitor.h utils/CaSimd.h utils/CaSimdVc.h utils/CaSimdPseudo.h diff --git a/algo/ca/core/pars/CaIteration.cxx b/algo/ca/core/pars/CaIteration.cxx index 4eb46afc61..1412441600 100644 --- a/algo/ca/core/pars/CaIteration.cxx +++ b/algo/ca/core/pars/CaIteration.cxx @@ -7,13 +7,14 @@ /// \since 05.02.2022 /// \author S.Zharko <s.zharko@gsi.de> -#include "CaConstants.h" #include "CaIteration.h" -#include "CaUtils.h" #include <limits> #include <sstream> +#include "CaConstants.h" +#include "CaUtils.h" + using cbm::algo::ca::Iteration; using cbm::algo::ca::Vector; using cbm::algo::ca::utils::CheckValueLimits; @@ -106,4 +107,3 @@ std::string Iteration::ToTableFromVector(const Vector<Iteration>& vIterations) return msg.str(); } - diff --git a/algo/ca/core/pars/CaIteration.h b/algo/ca/core/pars/CaIteration.h index 2c1847aaaa..5198ecff6f 100644 --- a/algo/ca/core/pars/CaIteration.h +++ b/algo/ca/core/pars/CaIteration.h @@ -21,7 +21,8 @@ #include "CaVector.h" -namespace cbm::algo::ca { +namespace cbm::algo::ca +{ /// \class cbm::algo::ca::Iteration /// \brief A set of parameters for the CA Track finder iteration /// @@ -277,12 +278,8 @@ namespace cbm::algo::ca { ar& fIsJumped; ar& fIsTrackFromTriplets; } - - }; -} - - +} // namespace cbm::algo::ca #endif // L1CAIteration_h diff --git a/algo/ca/core/pars/CaMaterialMap.h b/algo/ca/core/pars/CaMaterialMap.h index e7ed5e9141..e12c6a2d8d 100644 --- a/algo/ca/core/pars/CaMaterialMap.h +++ b/algo/ca/core/pars/CaMaterialMap.h @@ -88,8 +88,8 @@ namespace cbm::algo::ca /// \param iBinX Index of table column /// \param iBinY Index of table row /// \param thickness Thickness of the material in units of X0 - /// \note Indices of rows and columns in the table runs from 0 to nBins-1 inclusively, where nBins is the number - /// both of rows and columns. One should be careful while reading and storing the table from ROOT-file, + /// \note Indices of rows and columns in the table runs from 0 to nBins-1 inclusively, where nBins is the number + /// both of rows and columns. One should be careful while reading and storing the table from ROOT-file, /// because iBinX = 0 and iBinY = 0 in the TH1::SetBinContent method of usually defines the underflow bin. void SetRadThickBin(int iBinX, int iBinY, float thickness) { fTable[iBinX + fNbins * iBinY] = thickness; } diff --git a/reco/L1/L1Algo/L1Parameters.cxx b/algo/ca/core/pars/CaParameters.cxx similarity index 93% rename from reco/L1/L1Algo/L1Parameters.cxx rename to algo/ca/core/pars/CaParameters.cxx index 1bb017024b..357c2a1c73 100644 --- a/reco/L1/L1Algo/L1Parameters.cxx +++ b/algo/ca/core/pars/CaParameters.cxx @@ -1,28 +1,33 @@ -/* 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: Sergey Gorbunov, Sergei Zharko [committer] */ -/// @file L1Parameters.cxx -/// @brief Parameter container for the L1Algo library -/// @since 10.02.2022 -/// @author S.Zharko <s.zharko@gsi.de> +/// \file L1Parameters.cxx +/// \brief Parameter container for the L1Algo library +/// \since 10.02.2022 +/// \author S.Zharko <s.zharko@gsi.de> -#include "L1Parameters.h" - -#include <Logger.h> +#include "CaParameters.h" #include <iomanip> +#include "AlgoFairloggerCompat.h" + +using cbm::algo::ca::Iteration; +using cbm::algo::ca::MaterialMap; +using cbm::algo::ca::Parameters; +using cbm::algo::ca::utils::CheckSimdVectorEquality; + // --------------------------------------------------------------------------------------------------------------------- // -L1Parameters::L1Parameters() +Parameters::Parameters() { fvGeoToActiveMap.fill(-1); // by default, all stations are inactive, thus all the IDs must be -1 } // --------------------------------------------------------------------------------------------------------------------- // -void L1Parameters::CheckConsistency() const +void Parameters::CheckConsistency() const { LOG(info) << "Consistency test for L1 parameters object... "; /* @@ -90,9 +95,9 @@ void L1Parameters::CheckConsistency() const * Check target position SIMD vector */ - L1Utils::CheckSimdVectorEquality(fTargetPos[0], "L1Parameters: target position x"); - L1Utils::CheckSimdVectorEquality(fTargetPos[1], "L1Parameters: target position y"); - L1Utils::CheckSimdVectorEquality(fTargetPos[2], "L1Parameters: target position z"); + utils::CheckSimdVectorEquality(fTargetPos[0], "L1Parameters: target position x"); + utils::CheckSimdVectorEquality(fTargetPos[1], "L1Parameters: target position y"); + utils::CheckSimdVectorEquality(fTargetPos[2], "L1Parameters: target position z"); /* * Check vertex field region and value objects at primary vertex @@ -188,7 +193,7 @@ void L1Parameters::CheckConsistency() const // --------------------------------------------------------------------------------------------------------------------- // -int L1Parameters::GetNstationsActive(L1DetectorID detectorID) const +int Parameters::GetNstationsActive(L1DetectorID detectorID) const { int nStations = 0; for (int iStLoc = 0; iStLoc < this->GetNstationsGeometry(detectorID); ++iStLoc) { @@ -200,11 +205,11 @@ int L1Parameters::GetNstationsActive(L1DetectorID detectorID) const // --------------------------------------------------------------------------------------------------------------------- // -void L1Parameters::Print(int /*verbosityLevel*/) const { LOG(info) << ToString(); } +void Parameters::Print(int /*verbosityLevel*/) const { LOG(info) << ToString(); } // --------------------------------------------------------------------------------------------------------------------- // -std::string L1Parameters::ToString(int verbosity, int indentLevel) const +std::string Parameters::ToString(int verbosity, int indentLevel) const { using namespace constants; using std::setfill; diff --git a/algo/ca/core/pars/CaParameters.h b/algo/ca/core/pars/CaParameters.h new file mode 100644 index 0000000000..28d6c94e73 --- /dev/null +++ b/algo/ca/core/pars/CaParameters.h @@ -0,0 +1,347 @@ +/* Copyright (C) 2021-2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov, Sergei Zharko [committer] */ + +/// @file L1Parameters.h +/// @brief Parameter container for the L1Algo library +/// @since 19.12.2021 +/// @author S.Zharko <s.zharko@gsi.de> + +#ifndef L1Parameters_h +#define L1Parameters_h 1 + +#include <boost/serialization/array.hpp> +#include <boost/serialization/utility.hpp> + +#include <array> +#include <numeric> +#include <type_traits> +#include <utility> + +#include "CaConstants.h" +#include "CaField.h" +#include "CaIteration.h" +#include "CaMaterialMap.h" +#include "CaSearchWindow.h" +#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 +{ + using constants::Undef; + + /// Type definitions for used containers + using IterationsContainer_t = cbm::algo::ca::Vector<cbm::algo::ca::Iteration>; + using StationsContainer_t = std::array<ca::Station, constants::size::MaxNstations>; + using MaterialContainer_t = std::array<ca::MaterialMap, constants::size::MaxNstations>; + + /// \class cbm::algo::ca::Parameters + /// \brief A container for all external parameters of the CA tracking algorithm + /// + /// The class includes geometry parameters and physics cuts. The instance of the Parameters is constructed inside + /// the InitManager class and then moved to the L1Algo instance. + /// + class alignas(constants::misc::Alignment) Parameters { + /// \note The init manager is responsible for the formation of the Parameters block + friend class ::L1InitManager; + + using DetectorID_t = std::underlying_type_t<L1DetectorID>; + template<typename T> + using StationArray_t = std::array<T, constants::size::MaxNstations>; + + public: + /// \brief Default constructor + Parameters(); + + /// \brief Destructor + ~Parameters() noexcept = default; + + /// \brief Copy constructor + Parameters(const Parameters& other) = default; + + /// \brief Copy assignment operator + Parameters& operator=(const Parameters& other) = default; + + /// \brief Move constructor + Parameters(Parameters&& other) noexcept = default; + + /// \brief Move assignment operator + Parameters& operator=(Parameters&& other) = default; + + /// \brief Prints configuration + void Print(int verbosityLevel = 0) const; + + /// \brief String representation of the class contents + /// \param verbosity A verbose level for output + /// \param indentLevel Indent level of the string output + std::string ToString(int verbosity = 0, int indentLevel = 0) const; + + /// \brief Gets upper-bound cut on max number of doublets per one singlet + unsigned int GetMaxDoubletsPerSinglet() const { return fMaxDoubletsPerSinglet; } + + /// \brief Gets upper-bound cut on max number of triplets per one doublet + unsigned int GetMaxTripletPerDoublets() const { return fMaxTripletPerDoublets; } + + /// \brief Gets total number of active stations + int GetNstationsActive() const { return fNstationsActiveTotal; } + + /// \brief Gets number of active stations for given detector ID + int GetNstationsActive(L1DetectorID 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 + { + return fvFirstGeoId[static_cast<int>(detectorID) + 1] - fvFirstGeoId[static_cast<int>(detectorID)]; + } + + /// \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 + { + return fvGeoToLocalIdMap[geoIndex]; + } + + /// \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 + { + return fvLocalToGeoIdMap[fvFirstGeoId[static_cast<int>(detectorID)] + localIndex]; + } + + /// \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 + { + return fvGeoToActiveMap[GetStationIndexGeometry(localIndex, detectorID)]; + } + + /// \brief Provides access to L1CAIteration vector (const) + const IterationsContainer_t& GetCAIterations() const { return fCAIterations; } + + /// \brief Provides number of iterations + int GetNcaIterations() const { return fCAIterations.size(); } + + /// \brief Provides access to L1Stations container (const) + const StationsContainer_t& GetStations() const { return fStations; } + + /// \brief Gets reference to the particular station + /// \param iStation Index of station in the active stations container + const Station& GetStation(int iStation) const { return fStations[iStation]; } + + /// \brief Gets a search window for a selected station and track group + /// \note For a particular track finder iteration one can select a track group, which is defined by the minimal + /// momentum of tracks (fast tracks, all tracks), their vertex (primary or secondary tracks), or by particle + /// (electrons, muons, hadrons, etc.) + /// \param iStation Global index of active station + /// \param iTrackGr Index of a track group + const SearchWindow& GetSearchWindow(int iStation, int iTrackGr) const + { + assert(iStation < fNstationsActiveTotal && iStation > 0); + assert(iTrackGr < int(fCAIterations.size())); + return fSearchWindows[iTrackGr * constants::size::MaxNstations + iStation]; + } + + /// \brief Gets reference to the array of station thickness map + const MaterialContainer_t& GetThicknessMaps() const { return fThickMap; } + + /// \brief Gets material thickness in units of radiation length in a point on the XY plane for a selected station + /// \param iStActive Global index of an active station + /// \param xPos Position of the point in X dimension [cm] + /// \param yPos Position of the point in Y dimension [cm] + float GetMaterialThicknessScal(int iStActive, float xPos, float yPos) const + { + return fThickMap[iStActive].GetRadThickScal(xPos, yPos); + } + + /// \brief Gets material thickness in units of radiation length in a point on the XY plane for a selected station + /// \param iStActive Global index of an active station + /// \param xPos Position of the point in X dimension [cm] (SIMDized vector) + /// \param yPos Position of the point in Y dimension [cm] (SIMDized vector) + fvec GetMaterialThickness(int iStActive, fvec xPos, fvec yPos) const + { + return fThickMap[iStActive].GetRadThickVec(xPos, yPos); + } + + /// \brief Gets X component of target position + fvec GetTargetPositionX() const { return fTargetPos[0]; } + + /// \brief Gets Y component of target position + fvec GetTargetPositionY() const { return fTargetPos[1]; } + + /// \brief Gets Z component of target position + fvec GetTargetPositionZ() const { return fTargetPos[2]; } + + /// \brief Gets ca::FieldRegion object at primary vertex + const FieldRegion& GetVertexFieldRegion() const { return fVertexFieldRegion; } + + /// \brief Gets ca::FieldValue object at primary vertex + const FieldValue& GetVertexFieldValue() const { return fVertexFieldValue; } + + /// \brief Gets random seed + /// + /// If random seed is zero, std::random_device is used to seed the random number generator. + int GetRandomSeed() const { return fRandomSeed; } + + + /// \brief Gets ghost suppression flag + int GetGhostSuppression() const { return fGhostSuppression; } + + /// \brief Class invariant checker + void CheckConsistency() const; + + // *************************** + // ** Flags for development ** + // *************************** + + /// \brief Are the hit search areas ignored + bool DevIsIgnoreHitSearchAreas() const { return fDevIsIgnoreHitSearchAreas; } + + /// \brief Is original field must be used instead of the approximated one + bool DevIsUseOfOriginalField() const { return fDevIsUseOfOriginalField; } + + /// \brief Flag to match doublets using MC information + bool DevIsMatchDoubletsViaMc() const { return fDevIsMatchDoubletsViaMc; } + + /// \brief Flag to match triplets using Mc information + bool DevIsMatchTripletsViaMc() const { return fDevIsMatchTripletsViaMc; } + + /// \brief Flag to extend tracks using Mc information + bool DevIsExtendTracksViaMc() const { return fDevIsExtendTracksViaMc; } + + /// \brief Flag to match hits in overlaps using Mc information + bool DevIsSuppressOverlapHitsViaMc() const { return fDevIsSuppressOverlapHitsViaMc; } + + private: + unsigned int fMaxDoubletsPerSinglet {150}; ///< Upper-bound cut on max number of doublets per one singlet + unsigned int fMaxTripletPerDoublets {15}; ///< Upper-bound cut on max number of triplets per one doublet + + alignas(constants::misc::Alignment) IterationsContainer_t fCAIterations {}; ///< L1 tracking iterations vector + + /************************* + ** Geometry parameters ** + *************************/ + /// \brief Target position + alignas(constants::misc::Alignment) std::array<fvec, 3> fTargetPos {Undef<float>, Undef<float>, Undef<float>}; + + /// Field value object at primary vertex (between target and the first station) + alignas(constants::misc::Alignment) ca::FieldValue fVertexFieldValue {}; + + /// Field region object at primary vertex (between target and the first station) + alignas(constants::misc::Alignment) ca::FieldRegion fVertexFieldRegion {}; + + /// Array of stations + alignas(constants::misc::Alignment) StationsContainer_t fStations {}; + + /// Array of station thickness map + alignas(constants::misc::Alignment) MaterialContainer_t fThickMap {}; + + // ** Station layout arrays ** + /// \brief First index of the station on the particular detector + /// + /// The last element of the array corresponds to the total number of geometry stations + alignas(constants::misc::Alignment) std::array<int, constants::size::MaxNdetectors + 1> fvFirstGeoId {}; + + /// \brief Map of (local, det) to geo indices + /// + /// Usage: + /// iStGeo = fvLocaToGeoIdMap[fvFirstGeoId[iDet] + iStLocal]; + /// geo index. + 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 {}; + + /// \brief Map of geo to active indices + /// + /// The vector maps actual station index (which is defined by ) to the index of station in tracking. If the station + /// is inactive, its index is equal to -1. + /// \example Let stations 1 and 4 be inactive. Then: + /// geometry index: 0 1 2 3 4 5 6 7 8 9 0 0 0 0 + /// active index: 0 -1 1 2 -1 3 4 5 6 7 0 0 0 0 + alignas(constants::misc::Alignment) StationArray_t<int> fvGeoToActiveMap {}; + + /// \brief Map of active to geo indices + alignas(constants::misc::Alignment) StationArray_t<int> fvActiveToGeoMap {}; + + + alignas(constants::misc::Alignment) int fNstationsActiveTotal = -1; ///< total number of active tracking stations + + + /// \brief Map of search windows vs. active station global index and tracks group + /// + /// The tracks group can be defined by minimum momentum (fast/all tracks), origin (primary/secondary) and particle + /// type (electron, muon, all). Other options also can be added + alignas(constants::misc::Alignment) + std::array<SearchWindow, constants::size::MaxNstations* constants::size::MaxNtrackGroups> fSearchWindows = {}; + + int fGhostSuppression = 0; ///< flag: if true, ghost tracks are suppressed + int fRandomSeed = 1; ///< random seed + float fDefaultMass = constants::phys::MuonMass; + + // *************************** + // ** Flags for development ** + // *************************** + + bool fDevIsIgnoreHitSearchAreas {false}; ///< Process all hits on the station ignoring hit search area + bool fDevIsUseOfOriginalField {false}; ///< Force use of original field + bool fDevIsMatchDoubletsViaMc {false}; ///< Flag to match doublets using MC information + bool fDevIsMatchTripletsViaMc {false}; ///< Flag to match triplets using Mc information + bool fDevIsExtendTracksViaMc {false}; ///< Flag to extend tracks using Mc information + bool fDevIsSuppressOverlapHitsViaMc {false}; ///< Flag to match hits in overlaps using Mc information + + bool fDevIsParSearchWUsed = false; ///< Flag: when true, the parametrized search windows are used in track + ///< finder; when false, the Kalman filter is used instead + + /// \brief Serialization function + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive& ar, const unsigned int) + { + ar& fMaxDoubletsPerSinglet; + ar& fMaxTripletPerDoublets; + + ar& fCAIterations; + ar& fTargetPos; + + ar& fVertexFieldValue; + ar& fVertexFieldRegion; + + ar& fStations; + ar& fThickMap; + + ar& fvFirstGeoId; + ar& fvLocalToGeoIdMap; + ar& fvGeoToLocalIdMap; + ar& fvGeoToActiveMap; + ar& fvActiveToGeoMap; + ar& fNstationsActiveTotal; + + ar& fSearchWindows; + + ar& fGhostSuppression; + ar& fRandomSeed; + ar& fDefaultMass; + + ar& fDevIsIgnoreHitSearchAreas; + ar& fDevIsUseOfOriginalField; + ar& fDevIsMatchDoubletsViaMc; + ar& fDevIsMatchTripletsViaMc; + ar& fDevIsExtendTracksViaMc; + ar& fDevIsSuppressOverlapHitsViaMc; + } + }; +} // namespace cbm::algo::ca + +#endif // L1Parameters_h diff --git a/reco/L1/L1Algo/L1SearchWindow.cxx b/algo/ca/core/pars/CaSearchWindow.cxx similarity index 66% rename from reco/L1/L1Algo/L1SearchWindow.cxx rename to algo/ca/core/pars/CaSearchWindow.cxx index ee92ae19ec..3fc8fe95d6 100644 --- a/reco/L1/L1Algo/L1SearchWindow.cxx +++ b/algo/ca/core/pars/CaSearchWindow.cxx @@ -2,15 +2,17 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Sergey Gorbunov, Sergei Zharko [committer] */ -#include "L1SearchWindow.h" +#include "CaSearchWindow.h" #include <cassert> #include <iomanip> #include <sstream> +using cbm::algo::ca::SearchWindow; + // --------------------------------------------------------------------------------------------------------------------- // -L1SearchWindow::L1SearchWindow(int stationID, int trackGrID) : fStationID(stationID), fTrackGroupID(trackGrID) +SearchWindow::SearchWindow(int stationID, int trackGrID) : fStationID(stationID), fTrackGroupID(trackGrID) { assert(stationID > -1); assert(trackGrID > -1); @@ -23,7 +25,7 @@ L1SearchWindow::L1SearchWindow(int stationID, int trackGrID) : fStationID(statio // this class is supposed to be used inside the algorithm core // --------------------------------------------------------------------------------------------------------------------- // -void L1SearchWindow::SetParamDxMaxVsX0(int id, float val) +void SearchWindow::SetParamDxMaxVsX0(int id, float val) { assert(id > -1 && id < kNpars); fvParams[kDxMaxVsX0 * kNpars + id] = val; @@ -31,7 +33,7 @@ void L1SearchWindow::SetParamDxMaxVsX0(int id, float val) // --------------------------------------------------------------------------------------------------------------------- // -void L1SearchWindow::SetParamDxMinVsX0(int id, float val) +void SearchWindow::SetParamDxMinVsX0(int id, float val) { assert(id > -1 && id < kNpars); fvParams[kDxMinVsX0 * kNpars + id] = val; @@ -39,7 +41,7 @@ void L1SearchWindow::SetParamDxMinVsX0(int id, float val) // --------------------------------------------------------------------------------------------------------------------- // -void L1SearchWindow::SetParamDxMaxVsY0(int id, float val) +void SearchWindow::SetParamDxMaxVsY0(int id, float val) { assert(id > -1 && id < kNpars); fvParams[kDxMaxVsY0 * kNpars + id] = val; @@ -47,7 +49,7 @@ void L1SearchWindow::SetParamDxMaxVsY0(int id, float val) // --------------------------------------------------------------------------------------------------------------------- // -void L1SearchWindow::SetParamDxMinVsY0(int id, float val) +void SearchWindow::SetParamDxMinVsY0(int id, float val) { assert(id > -1 && id < kNpars); fvParams[kDxMinVsY0 * kNpars + id] = val; @@ -55,7 +57,7 @@ void L1SearchWindow::SetParamDxMinVsY0(int id, float val) // --------------------------------------------------------------------------------------------------------------------- // -void L1SearchWindow::SetParamDyMaxVsX0(int id, float val) +void SearchWindow::SetParamDyMaxVsX0(int id, float val) { assert(id > -1 && id < kNpars); fvParams[kDyMaxVsX0 * kNpars + id] = val; @@ -63,7 +65,7 @@ void L1SearchWindow::SetParamDyMaxVsX0(int id, float val) // --------------------------------------------------------------------------------------------------------------------- // -void L1SearchWindow::SetParamDyMinVsX0(int id, float val) +void SearchWindow::SetParamDyMinVsX0(int id, float val) { assert(id > -1 && id < kNpars); fvParams[kDyMinVsX0 * kNpars + id] = val; @@ -71,7 +73,7 @@ void L1SearchWindow::SetParamDyMinVsX0(int id, float val) // --------------------------------------------------------------------------------------------------------------------- // -void L1SearchWindow::SetParamDyMaxVsY0(int id, float val) +void SearchWindow::SetParamDyMaxVsY0(int id, float val) { assert(id > -1 && id < kNpars); fvParams[kDyMaxVsY0 * kNpars + id] = val; @@ -79,7 +81,7 @@ void L1SearchWindow::SetParamDyMaxVsY0(int id, float val) // --------------------------------------------------------------------------------------------------------------------- // -void L1SearchWindow::SetParamDyMinVsY0(int id, float val) +void SearchWindow::SetParamDyMinVsY0(int id, float val) { assert(id > -1 && id < kNpars); fvParams[kDyMinVsY0 * kNpars + id] = val; @@ -87,26 +89,27 @@ void L1SearchWindow::SetParamDyMinVsY0(int id, float val) // --------------------------------------------------------------------------------------------------------------------- // -std::string L1SearchWindow::ToString() const +std::string SearchWindow::ToString() const { + using std::setw; std::stringstream msg; msg << "----- CA hits search window: \n"; msg << "\tstation ID: " << fStationID << '\n'; msg << "\ttracks group ID: " << fTrackGroupID << '\n'; msg << "\tparameters:\n"; - msg << "\t\t" << std::setw(6) << std::setfill(' ') << "No." << ' '; - msg << std::setw(12) << std::setfill(' ') << "dx_max(x0)" << ' '; - msg << std::setw(12) << std::setfill(' ') << "dx_min(x0)" << ' '; - msg << std::setw(12) << std::setfill(' ') << "dx_max(y0)" << ' '; - msg << std::setw(12) << std::setfill(' ') << "dx_min(y0)" << ' '; - msg << std::setw(12) << std::setfill(' ') << "dy_max(x0)" << ' '; - msg << std::setw(12) << std::setfill(' ') << "dy_min(x0)" << ' '; - msg << std::setw(12) << std::setfill(' ') << "dy_max(y0)" << ' '; - msg << std::setw(12) << std::setfill(' ') << "dy_min(y0)" << '\n'; + msg << "\t\t" << setw(6) << "No." << ' '; + msg << setw(12) << "dx_max(x0)" << ' '; + msg << setw(12) << "dx_min(x0)" << ' '; + msg << setw(12) << "dx_max(y0)" << ' '; + msg << setw(12) << "dx_min(y0)" << ' '; + msg << setw(12) << "dy_max(x0)" << ' '; + msg << setw(12) << "dy_min(x0)" << ' '; + msg << setw(12) << "dy_max(y0)" << ' '; + msg << setw(12) << "dy_min(y0)" << '\n'; for (int iPar = 0; iPar < kNpars; ++iPar) { - msg << "\t\t" << std::setw(6) << std::setfill(' ') << iPar << ' '; + msg << "\t\t" << setw(6) << iPar << ' '; for (int iDep = 0; iDep < kNdeps; ++iDep) { - msg << std::setw(12) << std::setfill(' ') << fvParams[iDep * kNpars + iPar] << ' '; + msg << setw(12) << fvParams[iDep * kNpars + iPar] << ' '; } } return msg.str(); diff --git a/algo/ca/core/pars/CaSearchWindow.h b/algo/ca/core/pars/CaSearchWindow.h new file mode 100644 index 0000000000..3fe43fcb6d --- /dev/null +++ b/algo/ca/core/pars/CaSearchWindow.h @@ -0,0 +1,178 @@ +/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov, Sergei Zharko [committer] */ + +/// \file L1SearchWindow.h +/// \brief Provides parameterisation for hits searching window in the CA tracking (header) +/// \date 08.11.2022 +/// \author S.Zharko <s.zharko@gsi.de> + +#ifndef CaSearchWindow_h +#define CaSearchWindow_h 1 + +#include <boost/serialization/array.hpp> +#include <boost/serialization/string.hpp> + +#include <array> +#include <string> + + +/// TODO: SZh 8.11.2022: add selection of parameterisation + +namespace cbm::algo::ca +{ + /// \class cbm::algo::ca::SearchWindow + /// \brief Class L1SearchWindow defines a parameterisation of hits search window for CA tracking algorithm + /// TODO: SZh 8.11.2022: add description + class SearchWindow { + public: + /// \brief Constructor + /// \param stationID Global index of active station + /// \param trackGrID Track group ID + SearchWindow(int stationID, int trackGrID); + + /// \brief Default constructor + SearchWindow() = default; + + /// \brief Destructor + ~SearchWindow() = default; + + /// \brief Copy constructor + SearchWindow(const SearchWindow& other) = default; + + /// \brief Copy assignment operator + SearchWindow& operator=(const SearchWindow& other) = default; + + /// \brief Move constructor + SearchWindow(SearchWindow&& other) noexcept = default; + + /// \brief Move assignment operator + SearchWindow& operator=(SearchWindow&& other) = default; + + /// \brief Parameterisation function for dx_max(x0) + float DxMaxVsX0(float /*x*/) const { return fvParams[kDxMaxVsX0 /*+ 0*/]; } + + /// \brief Parameterisation function for dx_min(x0) + float DxMinVsX0(float /*x*/) const { return fvParams[kDxMinVsX0 /*+ 0*/]; } + + /// \brief Parameterisation function for dx_max(y0) + float DxMaxVsY0(float /*x*/) const { return fvParams[kDxMaxVsY0 /*+ 0*/]; } + + /// \brief Parameterisation function for dx_min(y0) + float DxMinVsY0(float /*x*/) const { return fvParams[kDxMinVsY0 /*+ 0*/]; } + + /// \brief Parameterisation function for dy_max(x0) + float DyMaxVsX0(float /*x*/) const { return fvParams[kDyMaxVsX0 /*+ 0*/]; } + + /// \brief Parameterisation function for dy_min(x0) + float DyMinVsX0(float /*x*/) const { return fvParams[kDyMinVsX0 /*+ 0*/]; } + + /// \brief Parameterisation function for dy_max(y0) + float DyMaxVsY0(float /*y*/) const { return fvParams[kDyMaxVsY0 /*+ 0*/]; } + + /// \brief Parameterisation function for dy_min(y0) + float DyMinVsY0(float /*y*/) const { return fvParams[kDyMinVsY0 /*+ 0*/]; } + + + /// \brief Gets station id + int GetStationID() const { return fStationID; } + + /// \brief Gets track group id + int GetTrackGroupID() const { return fTrackGroupID; } + + /// \brief Sets tag + /// + /// A tag can be used for insurance, if this search window corresponds to a desired track finder iteration + void SetTag(const char* name) { fsTag = name; } + + // TODO: SZh 08.11.2022: Implement variadic template function + // TODO: SZh 08.11.2022: Try to reduce number of functions + /// \brief Sets parameters for dx_max(x0) + /// \param id Parameter index + /// \param val Parameter value + void SetParamDxMaxVsX0(int id, float val); + + /// \brief Sets parameters for dx_min(x0) + /// \param id Parameter index + /// \param val Parameter value + void SetParamDxMinVsX0(int id, float val); + + /// \brief Sets parameters for dx_max(y0) + /// \param id Parameter index + /// \param val Parameter value + void SetParamDxMaxVsY0(int id, float val); + + /// \brief Sets parameters for dx_min(y0) + /// \param id Parameter index + /// \param val Parameter value + void SetParamDxMinVsY0(int id, float val); + + /// \brief Sets parameters for dy_max(x0) + /// \param id Parameter index + /// \param val Parameter value + void SetParamDyMaxVsX0(int id, float val); + + /// \brief Sets parameters for dy_min(x0) + /// \param id Parameter index + /// \param val Parameter value + void SetParamDyMinVsX0(int id, float val); + + /// \brief Sets parameters for dy_max(y0) + /// \param id Parameter index + /// \param val Parameter value + void SetParamDyMaxVsY0(int id, float val); + + /// \brief Sets parameters for dy_min(y0) + /// \param id Parameter index + /// \param val Parameter value + void SetParamDyMinVsY0(int id, float val); + + /// \brief String representation of the contents + std::string ToString() const; + + private: + static constexpr unsigned char kNpars = 1; ///< Max number of parameters for one dependency + static constexpr unsigned char kNdeps = 8; ///< Number of the dependencies + + /// \brief Enumeration for dependencies stored + enum EDependency + { + kDxMaxVsX0, + kDxMinVsX0, + kDxMaxVsY0, + kDxMinVsY0, + kDyMaxVsX0, + kDyMinVsX0, + kDyMaxVsY0, + kDyMinVsY0 + }; + + /// \brief Search window parameter array containing parameters from + /// - dx_max vs x0 - indexes [0 .. kNpars - 1] + /// - dx_min vs x0 - indexes [kNpars .. (2 * kNpars - 1)] + /// - dx_max vs y0 - indexes [2 * kNpars .. (3 * kNpars - 1)] + /// - dx_min vs y0 - indexes [3 * kNpars .. (4 * kNpars - 1)] + /// - dy_max vs y0 - indexes [4 * kNpars .. (5 * kNpars - 1)] + /// - dy_min vs y0 - indexes [5 * kNpars .. (6 * kNpars - 1)] + /// - dy_max vs y0 - indexes [6 * kNpars .. (7 * kNpars - 1)] + /// - dy_min vs y0 - indexes [7 * kNpars .. (8 * kNpars - 1)] + std::array<float, kNdeps* kNpars> fvParams = {0}; + + int fStationID = -1; ///< Global index of active tracking station + int fTrackGroupID = -1; ///< Index of tracks group + std::string fsTag = ""; ///< Tag, containing information on the tracks group (TODO: can be omitted?) + + /// \brief Serialization function + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive& ar, const unsigned int) + { + ar& fvParams; + ar& fStationID; + ar& fTrackGroupID; + ar& fsTag; + } + }; +} // namespace cbm::algo::ca + +#endif // L1SearchWindow_h diff --git a/algo/ca/core/utils/CaEnumArray.h b/algo/ca/core/utils/CaEnumArray.h new file mode 100644 index 0000000000..25ec11a725 --- /dev/null +++ b/algo/ca/core/utils/CaEnumArray.h @@ -0,0 +1,53 @@ +/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergei Zharko [committer] */ + +/// @file CaEnumArray.h +/// @brief Implementation of cbm::algo::ca::EnumArray class +/// @since 02.05.2023 +/// @author Sergei Zharko <s.zharko@gsi.de> + +#ifndef CaEnumArray_h +#define CaEnumArray_h 1 + +#include <array> + +namespace cbm::algo::ca +{ + /// \class cbm::algo::ca::EnumArray + /// \brief Class of arrays, which can be accessed by an enum class entry as an index + /// \note The enum-array must contain an entry kEND, which represents the number of the enumeration entries and + /// is used, as an array size + /// \tparam E The enum class type + /// \tparam T Type of data in the underlying array + template<class E, class T> + class EnumArray : public std::array<T, static_cast<std::size_t>(E::kEND)> { + using U = typename std::underlying_type<E>::type; ///< Underlying type of enumeration + using Arr = std::array<T, static_cast<std::size_t>(E::kEND)>; + + public: + /// \brief Mutable access operator, indexed by enum entry + T& operator[](const E& entry) + { + return std::array<T, static_cast<std::size_t>(E::kEND)>::operator[](static_cast<U>(entry)); + } + + /// \brief Mutable access operator, indexed by underlying index type + T& operator[](U index) { return std::array<T, static_cast<std::size_t>(E::kEND)>::operator[](index); } + + /// \brief Constant access operator, indexed by enum entry + const T& operator[](const E& entry) const + { + return std::array<T, static_cast<std::size_t>(E::kEND)>::operator[](static_cast<U>(entry)); + } + + /// \brief Constant access operator, indexed by underlying index type + /// \param index Index of the element + const T& operator[](U index) const { return std::array<T, static_cast<std::size_t>(E::kEND)>::operator[](index); } + + /// \brief Convertion operator to the base array class + operator Arr&() const { return *this; } + }; +} // namespace cbm::algo::ca + +#endif // L1EArray_h diff --git a/reco/L1/L1Algo/utils/CaMonitor.h b/algo/ca/core/utils/CaMonitor.h similarity index 97% rename from reco/L1/L1Algo/utils/CaMonitor.h rename to algo/ca/core/utils/CaMonitor.h index f205f9d251..39d3209b75 100644 --- a/reco/L1/L1Algo/utils/CaMonitor.h +++ b/algo/ca/core/utils/CaMonitor.h @@ -14,7 +14,7 @@ #include <sstream> #include <string> -#include "L1EArray.h" +#include "CaEnumArray.h" namespace cbm::algo::ca { @@ -27,7 +27,7 @@ namespace cbm::algo::ca public: /// @brief Alias to array, indexed by Monitorable enumeration template<typename T> - using MonitorableArr_t = L1EArray<EMonitorKey, T>; + using MonitorableArr_t = EnumArray<EMonitorKey, T>; /// @brief Constructor /// @param name Name of monitor diff --git a/algo/ca/core/utils/CaUtils.h b/algo/ca/core/utils/CaUtils.h index c71f515f83..4e697f0da3 100644 --- a/algo/ca/core/utils/CaUtils.h +++ b/algo/ca/core/utils/CaUtils.h @@ -12,6 +12,7 @@ #include <sstream> +#include "AlgoFairloggerCompat.h" #include "CaConstants.h" #include "CaSimd.h" @@ -100,8 +101,8 @@ namespace cbm::algo::ca::utils bool CheckValueLimits(const std::string& name, T value, T lLimit, T uLimit) { if (value < lLimit || value > uLimit) { - //LOG(error) << "parameter\033[1;32m" << name << "\033[0m (" << value << ") runs out of range: [" << lLimit << ',' - // << uLimit << ']'; + LOG(error) << "parameter\033[1;32m" << name << "\033[0m (" << value << ") runs out of range: [" << lLimit << ',' + << uLimit << ']'; return false; } return true; diff --git a/algo/ca/core/utils/CaVector.h b/algo/ca/core/utils/CaVector.h index 321361c8dc..8fa8245a6b 100644 --- a/algo/ca/core/utils/CaVector.h +++ b/algo/ca/core/utils/CaVector.h @@ -2,9 +2,9 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Sergey Gorbunov [committer], Sergei Zharko */ -/// @file CaVector.h -/// @author Sergey Gorbunov -/// @date 2021-06-16 +/// \file CaVector.h +/// \author Sergey Gorbunov +/// \date 2021-06-16 #ifndef Ca_CaVector_H #define Ca_CaVector_H diff --git a/algo/log/AlgoFairloggerCompat.h b/algo/log/AlgoFairloggerCompat.h index 6075890ed7..86438bfcdd 100644 --- a/algo/log/AlgoFairloggerCompat.h +++ b/algo/log/AlgoFairloggerCompat.h @@ -8,7 +8,7 @@ #include <fairlogger/Logger.h> -#else // defined NO_ROOT +#else #ifndef LOG @@ -21,3 +21,4 @@ static constexpr severity_level warn = severity_level::warning; #endif // NO_ROOT #endif // CBM_ALGO_BASE_COMPAT_ONLINEDATALOG_H + diff --git a/reco/L1/CMakeLists.txt b/reco/L1/CMakeLists.txt index 77a14cbdfa..d8c1548916 100644 --- a/reco/L1/CMakeLists.txt +++ b/reco/L1/CMakeLists.txt @@ -51,12 +51,10 @@ set(SRCS L1Algo/L1XYMeasurementInfo.cxx L1Algo/L1BaseStationInfo.cxx L1Algo/L1InitManager.cxx - L1Algo/L1Parameters.cxx L1Algo/L1InputData.cxx L1Algo/L1IODataManager.cxx L1Algo/L1CloneMerger.cxx L1Algo/L1ConfigRW.cxx - L1Algo/L1SearchWindow.cxx L1Algo/utils/L1AlgoDraw.cxx L1Algo/utils/L1AlgoEfficiencyPerformance.cxx L1Algo/utils/L1AlgoPulls.cxx @@ -102,9 +100,7 @@ set(HEADERS CbmL1Track.h CbmL1Vtx.h L1Algo/L1Def.h - L1Algo/L1EArray.h L1Algo/utils/CaUvConverter.h - L1Algo/utils/CaMonitor.h catools/CaToolsWindowFinder.h catools/CaToolsLinkKey.h catools/CaToolsHitRecord.h @@ -205,13 +201,11 @@ install(FILES CbmL1Counters.h utils/CbmCaIdealHitProducer.h utils/CbmCaIdealHitProducerDet.h L1Algo/utils/CaUvConverter.h - L1Algo/utils/CaMonitor.h qa/CbmCaInputQaBase.h DESTINATION include ) install(FILES L1Algo/L1Algo.h L1Algo/L1Branch.h - L1Algo/L1EArray.h DESTINATION include/L1Algo ) diff --git a/reco/L1/CbmCaMCModule.h b/reco/L1/CbmCaMCModule.h index 910c99ced3..d594821301 100644 --- a/reco/L1/CbmCaMCModule.h +++ b/reco/L1/CbmCaMCModule.h @@ -40,11 +40,11 @@ #include <type_traits> #include "CaMonitor.h" +#include "CaParameters.h" #include "CaToolsMCData.h" #include "CaToolsMCPoint.h" #include "CaVector.h" #include "L1InputData.h" -#include "L1Parameters.h" class CbmEvent; class CbmMCDataObject; @@ -154,7 +154,7 @@ namespace cbm::ca /// @brief Registers CA parameters object /// @param pParameters A shared pointer to the parameters object - void RegisterParameters(std::shared_ptr<L1Parameters>& pParameters) { fpParameters = pParameters; } + void RegisterParameters(std::shared_ptr<ca::Parameters>& pParameters) { fpParameters = pParameters; } /// @brief Registers debug hit container /// @param vQaHits Reference to debug hit container @@ -236,7 +236,7 @@ namespace cbm::ca int fVerbose = 1; ///< Verbosity level int fPerformanceMode = -1; ///< Mode of performance - std::shared_ptr<L1Parameters> fpParameters = nullptr; ///< Pointer to tracking parameters object + std::shared_ptr<ca::Parameters> fpParameters = nullptr; ///< Pointer to tracking parameters object // ------ Input data branches const CbmTimeSlice* fpTimeSlice = nullptr; ///< Current time slice CbmMCEventList* fpMCEventList = nullptr; ///< MC event list @@ -444,7 +444,7 @@ namespace cbm::ca oPoint->SetStationId(stationID); oPoint->SetDetectorId(DetID); - auto* pExtTrk = L1_DYNAMIC_CAST<CbmMCTrack*>(fpMCTracks->Get(iFile, iEvent, iTmcExt)); + auto* pExtTrk = dynamic_cast<CbmMCTrack*>(fpMCTracks->Get(iFile, iEvent, iTmcExt)); if (!pExtTrk) { LOG(warn) << "CbmCaMCModule: MC track with iTmcExt = " << iTmcExt << ", iEvent = " << iEvent << ", iFile = " << iFile << " MC track is undefined (nullptr)"; diff --git a/reco/L1/CbmCaTimeSliceReader.cxx b/reco/L1/CbmCaTimeSliceReader.cxx index 2a2bc919d1..1c252993d1 100644 --- a/reco/L1/CbmCaTimeSliceReader.cxx +++ b/reco/L1/CbmCaTimeSliceReader.cxx @@ -23,8 +23,8 @@ #include <numeric> #include "CaConstants.h" +#include "CaParameters.h" #include "L1InputData.h" -#include "L1Parameters.h" using cbm::ca::tools::HitRecord; diff --git a/reco/L1/CbmCaTimeSliceReader.h b/reco/L1/CbmCaTimeSliceReader.h index ec9df62fe6..ef1129f955 100644 --- a/reco/L1/CbmCaTimeSliceReader.h +++ b/reco/L1/CbmCaTimeSliceReader.h @@ -36,11 +36,13 @@ class CbmTimeSlice; class L1IODataManager; -class L1Parameters; +namespace cbm::algo::ca +{ + class Parameters; +} namespace cbm::ca { - namespace ca = cbm::algo::ca; /// @brief A reader of time slice for CA tracker /// @@ -109,7 +111,7 @@ namespace cbm::ca /// @brief Registers CA parameters object /// @param pParameters A shared pointer to the parameters object - void RegisterParameters(std::shared_ptr<L1Parameters>& pParameters) { fpParameters = pParameters; } + void RegisterParameters(std::shared_ptr<ca::Parameters>& pParameters) { fpParameters = pParameters; } /// @brief Registers the CA IO data manager instance /// @param pIODataManager Shared pointer to the IO data manager instance @@ -181,7 +183,7 @@ namespace cbm::ca ca::Vector<CbmL1HitDebugInfo>* fpvQaHits = nullptr; ///< Pointer to array of debug hits ca::Vector<CbmL1Track>* fpvTracks = nullptr; ///< Pointer to array of reconstructed tracks std::shared_ptr<L1IODataManager> fpIODataManager = nullptr; ///< Pointer to input data manager - std::shared_ptr<L1Parameters> fpParameters = nullptr; ///< Pointer to tracking parameters object + std::shared_ptr<ca::Parameters> fpParameters = nullptr; ///< Pointer to tracking parameters object // Maps of hit indexes: ext -> int DetIdArr_t<ca::Vector<int>> fvvHitExtToIntIndexMap; ///< Hit index map ext -> int diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index f8129c4642..6170ab02b6 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -77,6 +77,7 @@ using std::cout; using std::endl; using std::ios; using CaTrack = cbm::algo::ca::Track; +using cbm::algo::ca::Parameters; using cbm::ca::tools::MaterialHelper; ClassImp(CbmL1); @@ -1263,11 +1264,11 @@ void CbmL1::DumpMaterialToFile(TString fileName) { TFile* f = new TFile(fileName, "RECREATE"); f->cd(); - const L1Parameters& param = *fpAlgo->GetParameters(); - const L1MaterialContainer_t& map = param.GetThicknessMaps(); + const auto& param = *fpAlgo->GetParameters(); + const auto& map = param.GetThicknessMaps(); for (int ist = 0; ist < param.GetNstationsActive(); ist++) { //const ca::Station& st = param.GetStation(ist); - const ca::MaterialMap& mat = map[ist]; + const auto& mat = map[ist]; TString name = Form("tracking_station%d", ist); TString title = Form("Tracking station %d: Rad. thickness in [%s]. Z region [%.2f,%.2f] cm.", ist, "%", diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index 378aee5992..04db5f3127 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -37,7 +37,6 @@ #include "FairDetector.h" #include "FairRootManager.h" #include "FairTask.h" -#include "Logger.h" #include "TClonesArray.h" #include "TH1.h" @@ -53,6 +52,7 @@ #include <unordered_map> #include <utility> +#include "AlgoFairloggerCompat.h" #include "CaMonitor.h" #include "CaVector.h" #include "L1Algo/L1Algo.h" diff --git a/reco/L1/CbmL1DetectorID.h b/reco/L1/CbmL1DetectorID.h index c5b006e1a0..2442de508b 100644 --- a/reco/L1/CbmL1DetectorID.h +++ b/reco/L1/CbmL1DetectorID.h @@ -13,7 +13,7 @@ #include <string> #include "CaConstants.h" -#include "L1EArray.h" +#include "CaEnumArray.h" namespace cbm::ca { @@ -61,7 +61,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 = L1EArray<L1DetectorID, T>; + using DetIdArr_t = ca::EnumArray<L1DetectorID, T>; /// @brief List of diff --git a/reco/L1/L1Algo/L1Algo.cxx b/reco/L1/L1Algo/L1Algo.cxx index e9b200c874..6edf880704 100644 --- a/reco/L1/L1Algo/L1Algo.cxx +++ b/reco/L1/L1Algo/L1Algo.cxx @@ -73,7 +73,7 @@ void L1Algo::ResetSliceData() // --------------------------------------------------------------------------------------------------------------------- // -void L1Algo::ReceiveParameters(L1Parameters&& parameters) +void L1Algo::ReceiveParameters(Parameters&& parameters) { fParameters = std::move(parameters); diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index b9471123bd..b7871ae0fc 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -31,6 +31,7 @@ class L1AlgoDraw; #include "CaConstants.h" #include "CaField.h" #include "CaHit.h" +#include "CaParameters.h" #include "CaStation.h" #include "CaTrack.h" #include "CaTrackParam.h" @@ -41,7 +42,6 @@ class L1AlgoDraw; #include "L1Grid.h" #include "L1HitPoint.h" #include "L1InputData.h" -#include "L1Parameters.h" #include "L1Triplet.h" #include "L1Utils.h" // ? DEPRECATED ? @@ -141,18 +141,18 @@ public: /// Sets L1Algo parameters object - /// \param other - reference to the L1Parameters object - void SetParameters(const L1Parameters& other) { fParameters = other; } + /// \param other - reference to the Parameters object + void SetParameters(const Parameters& other) { fParameters = other; } // TODO: remove it (S.Zharko) /// Gets a pointer to the L1Algo parameters object - const L1Parameters* GetParameters() const { return &fParameters; } + const Parameters* GetParameters() const { return &fParameters; } /// Receives input data void ReceiveInputData(L1InputData&& inputData); /// Receives tracking parameters - void ReceiveParameters(L1Parameters&& parameters); + void ReceiveParameters(Parameters&& parameters); /// Gets pointer to input data object for external access const L1InputData& GetInputData() const { return fInputData; } @@ -283,7 +283,7 @@ private: // ** Member variables list ** // *************************** - L1Parameters fParameters; ///< Object of L1Algo parameters class + Parameters fParameters; ///< Object of L1Algo parameters class L1InputData fInputData; ///< Tracking input data Vector<unsigned char> fvHitKeyFlags { @@ -338,7 +338,7 @@ public: /// --- data used during finding iterations int isec {0}; // iteration TODO: to be dispatched (S.Zharko, 21.06.2022) - const Iteration* fpCurrentIteration = nullptr; ///< pointer to the current CA track finder iteration + const Iteration* fpCurrentIteration = nullptr; ///< pointer to the current CA track finder iteration Vector<int> fHitFirstTriplet {"L1Algo::fHitFirstTriplet"}; /// link hit -> first triplet { hit, *, *} Vector<int> fHitNtriplets {"L1Algo::fHitNtriplets"}; /// link hit ->n triplets { hit, *, *} diff --git a/reco/L1/L1Algo/L1CloneMerger.cxx b/reco/L1/L1Algo/L1CloneMerger.cxx index 1d5b9f44e4..977f25c64a 100644 --- a/reco/L1/L1Algo/L1CloneMerger.cxx +++ b/reco/L1/L1Algo/L1CloneMerger.cxx @@ -11,11 +11,11 @@ #include <iostream> +#include "CaParameters.h" #include "CaTrack.h" #include "CaVector.h" #include "L1Algo.h" #include "L1Fit.h" -#include "L1Parameters.h" using cbm::algo::ca::Track; // TMP using cbm::algo::ca::Vector; // TMP diff --git a/reco/L1/L1Algo/L1EArray.h b/reco/L1/L1Algo/L1EArray.h deleted file mode 100644 index cf4ba2b31c..0000000000 --- a/reco/L1/L1Algo/L1EArray.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Sergei Zharko [committer] */ - -/// @file L1EArray.h -/// @brief Implementation of L1EArray class -/// @since 02.05.2023 -/// @author Sergei Zharko <s.zharko@gsi.de> - -#ifndef L1EArray_h -#define L1EArray_h 1 - -#include <array> - -/// @brief Class of arrays, which can be accessed by an enum class entry as an index -/// @note The enum-array must contain an entry kEND, which represents the number of the enumeration entries and -/// is used, as an array size -/// @tparam E The enum class type -/// @tparam T Type of data in the underlying array -template<class E, class T> -class L1EArray : public std::array<T, static_cast<std::size_t>(E::kEND)> { - using U = typename std::underlying_type<E>::type; ///< Underlying type of enumeration - using Arr = std::array<T, static_cast<std::size_t>(E::kEND)>; - -public: - /// @brief Mutable access operator, indexed by enum entry - T& operator[](const E& entry) - { - return std::array<T, static_cast<std::size_t>(E::kEND)>::operator[](static_cast<U>(entry)); - } - - /// @brief Mutable access operator, indexed by underlying index type - T& operator[](U index) { return std::array<T, static_cast<std::size_t>(E::kEND)>::operator[](index); } - - /// @brief Constant access operator, indexed by enum entry - const T& operator[](const E& entry) const - { - return std::array<T, static_cast<std::size_t>(E::kEND)>::operator[](static_cast<U>(entry)); - } - - /// @brief Constant access operator, indexed by underlying index type - const T& operator[](U index) const { return std::array<T, static_cast<std::size_t>(E::kEND)>::operator[](index); } - - /// @brief Convertion operator to the base array class - operator Arr&() const { return *this; } -}; - -#endif // L1EArray_h diff --git a/reco/L1/L1Algo/L1InitManager.cxx b/reco/L1/L1Algo/L1InitManager.cxx index 966a48b6ec..5f9e9ba1f7 100644 --- a/reco/L1/L1Algo/L1InitManager.cxx +++ b/reco/L1/L1Algo/L1InitManager.cxx @@ -21,6 +21,7 @@ #include "L1ConfigRW.h" using namespace constants; +using namespace cbm::algo::ca; // ---------------------------------------------------------------------------------------------------------------------- // @@ -340,7 +341,7 @@ void L1InitManager::ReadSearchWindows(const std::string& fileName) ia >> nWindows; std::stringstream errMsg; for (int iW = 0; iW < nWindows; ++iW) { - L1SearchWindow swBuffer; + SearchWindow swBuffer; ia >> swBuffer; int iStationID = swBuffer.GetStationID(); int iTrackGrID = swBuffer.GetTrackGroupID(); @@ -378,7 +379,7 @@ bool L1InitManager::SendParameters(L1Algo* pAlgo) // --------------------------------------------------------------------------------------------------------------------- // -bool L1InitManager::SendParameters(L1Parameters& destination) +bool L1InitManager::SendParameters(Parameters& destination) { destination = std::move(fParameters); LOG(info) << "L1InitManager: parameters object was sent to an external destination"; diff --git a/reco/L1/L1Algo/L1InitManager.h b/reco/L1/L1Algo/L1InitManager.h index 42b99f940c..9c71707c9f 100644 --- a/reco/L1/L1Algo/L1InitManager.h +++ b/reco/L1/L1Algo/L1InitManager.h @@ -19,12 +19,11 @@ #include "CaConstants.h" #include "CaField.h" +#include "CaIteration.h" #include "CaObjectInitController.h" +#include "CaParameters.h" #include "CaSimd.h" #include "L1BaseStationInfo.h" -#include "L1CAIteration.h" -#include "L1EArray.h" -#include "L1Parameters.h" #include "L1Utils.h" @@ -97,7 +96,7 @@ private: 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 = ca::ObjectInitController<static_cast<int>(EInitKey::kEnd), EInitKey>; + using InitController_t = ObjectInitController<static_cast<int>(EInitKey::kEnd), EInitKey>; template<typename T> using L1DetectorIDArr_t = std::array<T, constants::size::MaxNdetectors>; @@ -123,7 +122,7 @@ public: /// @brief Adds a tracking station to the geometry /// - /// @note The added station stays uninitialized until the L1Parameters object is formed + /// @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, @@ -218,7 +217,7 @@ public: /// @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 L1Parameters file. + /// beforehand created Parameters file. void SetConfigMain(const std::string& mainConfig) { fsConfigInputMain = mainConfig; } /// @brief Sets user configuration file @@ -244,7 +243,7 @@ public: void SetGhostSuppression(int ghostSuppression); /// Sets a name of the output configuration file. The output file is created from the fields, saved in the resulted - /// L1Parameters object + /// Parameters object /// \param filename Name of the output L1 parameters configuration void SetOutputConfigName(const std::string& filename) { fConfigOutputName = filename; } @@ -273,7 +272,7 @@ public: /// @brief Sends (moves) parameters object to an external destination /// @param destination Reference to the parameters object of destination /// @return Success flag - bool SendParameters(L1Parameters& destination); + bool SendParameters(Parameters& destination); /// Writes parameters object from boost-serialized binary file /// \param fileName Name of input file @@ -350,7 +349,7 @@ private: int fCAIterationsNumberCrosscheck {-1}; ///< Number of iterations to be passed (must be used for cross-checks) - L1Parameters fParameters {}; ///< L1Algo parameters object + Parameters fParameters {}; ///< L1Algo parameters object // * Configuration related * std::string fsConfigInputMain = ""; ///< name for the input configuration file diff --git a/reco/L1/L1Algo/L1Parameters.h b/reco/L1/L1Algo/L1Parameters.h deleted file mode 100644 index 657539968a..0000000000 --- a/reco/L1/L1Algo/L1Parameters.h +++ /dev/null @@ -1,344 +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 L1Parameters.h -/// @brief Parameter container for the L1Algo library -/// @since 19.12.2021 -/// @author S.Zharko <s.zharko@gsi.de> - -#ifndef L1Parameters_h -#define L1Parameters_h 1 - -#include <boost/serialization/array.hpp> -#include <boost/serialization/utility.hpp> - -#include <array> -#include <numeric> -#include <type_traits> -#include <utility> - -#include "CaConstants.h" -#include "CaField.h" -#include "CaMaterialMap.h" -#include "CaStation.h" -#include "CaVector.h" -#include "CaIteration.h" -#include "L1SearchWindow.h" -#include "L1Utils.h" // IS DEPRECATED? - -using namespace cbm::algo; // TODO: remove -using namespace cbm::algo::ca; // TODO: remove - -class L1InitManager; -enum class L1DetectorID; - -/// Type definitions for used containers -using L1IterationsContainer_t = cbm::algo::ca::Vector<cbm::algo::ca::Iteration>; -using L1StationsContainer_t = std::array<ca::Station, constants::size::MaxNstations>; -using L1MaterialContainer_t = std::array<ca::MaterialMap, constants::size::MaxNstations>; - - -/// Class L1Parameters represents a container for all external parameters of the L1 tracking algorithm, -/// including geometry parameters and physics cuts. The instance of the L1Parameters is constructed inside -/// L1InitManager class and then moved to the L1Algo instance. -/// -class alignas(constants::misc::Alignment) L1Parameters { - - // ******************************** - // ** Friend classes declaration ** - // ******************************** - - friend class L1InitManager; - - using L1DetectorID_t = std::underlying_type_t<L1DetectorID>; - template<typename T> - using StationArray_t = std::array<T, constants::size::MaxNstations>; - -public: - /// Default constructor - L1Parameters(); - - /// Destructor - ~L1Parameters() noexcept = default; - - /// Copy constructor - L1Parameters(const L1Parameters& other) = default; - - /// Copy assignment operator - L1Parameters& operator=(const L1Parameters& other) = default; - - /// Move constructor - L1Parameters(L1Parameters&& other) noexcept = default; - - /// Move assignment operator - L1Parameters& operator=(L1Parameters&& other) = default; - - /// Prints configuration - void Print(int verbosityLevel = 0) const; - - /// String representation of the class contents - std::string ToString(int verbosity = 0, int indentLevel = 0) const; - - /// Gets upper-bound cut on max number of doublets per one singlet - unsigned int GetMaxDoubletsPerSinglet() const { return fMaxDoubletsPerSinglet; } - - /// Gets upper-bound cut on max number of triplets per one doublet - unsigned int GetMaxTripletPerDoublets() const { return fMaxTripletPerDoublets; } - - /// Gets total number of active stations - int GetNstationsActive() const { return fNstationsActiveTotal; } - - /// Gets number of active stations for given detector ID - int GetNstationsActive(L1DetectorID 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 - { - return fvFirstGeoId[static_cast<int>(detectorID) + 1] - fvFirstGeoId[static_cast<int>(detectorID)]; - } - - /// @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 - { - return fvGeoToLocalIdMap[geoIndex]; - } - - /// @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 - { - return fvLocalToGeoIdMap[fvFirstGeoId[static_cast<int>(detectorID)] + localIndex]; - } - - /// @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 - { - return fvGeoToActiveMap[GetStationIndexGeometry(localIndex, detectorID)]; - } - - /// @brief Provides access to L1CAIteration vector (const) - const L1IterationsContainer_t& GetCAIterations() const { return fCAIterations; } - - /// @brief Provides number of iterations - int GetNcaIterations() const { return fCAIterations.size(); } - - /// @brief Provides access to L1Stations container (const) - const L1StationsContainer_t& GetStations() const { return fStations; } - - /// @brief Gets reference to the particular station - /// @param iStation Index of station in the active stations container - const ca::Station& GetStation(int iStation) const { return fStations[iStation]; } - - /// @brief Gets a search window for a selected station and track group - /// @note For a particular track finder iteration one can select a track group, which is defined by the minimal - /// momentum of tracks (fast tracks, all tracks), their vertex (primary or secondary tracks), or by particle - /// (electrons, muons, hadrons, etc.) - /// @param iStation Global index of active station - /// @param iTrackGr Index of a track group - const L1SearchWindow& GetSearchWindow(int iStation, int iTrackGr) const - { - assert(iStation < fNstationsActiveTotal && iStation > 0); - assert(iTrackGr < int(fCAIterations.size())); - return fSearchWindows[iTrackGr * constants::size::MaxNstations + iStation]; - } - - /// @brief Gets reference to the array of station thickness map - const L1MaterialContainer_t& GetThicknessMaps() const { return fThickMap; } - - /// @brief Gets material thickness in units of radiation length in a point on the XY plane for a selected station - /// @param iStActive Global index of an active station - /// @param xPos Position of the point in X dimension [cm] - /// @param yPos Position of the point in Y dimension [cm] - float GetMaterialThicknessScal(int iStActive, float xPos, float yPos) const - { - return fThickMap[iStActive].GetRadThickScal(xPos, yPos); - } - - /// Gets material thickness in units of radiation length in a point on the XY plane for a selected station - /// \param iStActive Global index of an active station - /// \param xPos Position of the point in X dimension [cm] (SIMDized vector) - /// \param yPos Position of the point in Y dimension [cm] (SIMDized vector) - fvec GetMaterialThickness(int iStActive, fvec xPos, fvec yPos) const - { - return fThickMap[iStActive].GetRadThickVec(xPos, yPos); - } - - /// Gets X component of target position - fvec GetTargetPositionX() const { return fTargetPos[0]; } - - /// Gets Y component of target position - fvec GetTargetPositionY() const { return fTargetPos[1]; } - - /// Gets Z component of target position - fvec GetTargetPositionZ() const { return fTargetPos[2]; } - - /// Gets ca::FieldRegion object at primary vertex - const ca::FieldRegion& GetVertexFieldRegion() const { return fVertexFieldRegion; } - - /// Gets ca::FieldValue object at primary vertex - const ca::FieldValue& GetVertexFieldValue() const { return fVertexFieldValue; } - - /// @brief Gets random seed - /// - /// If random seed is zero, std::random_device is used to seed the random number generator. - int GetRandomSeed() const { return fRandomSeed; } - - - /// Gets ghost suppression flag - int GetGhostSuppression() const { return fGhostSuppression; } - - /// Class invariant checker - void CheckConsistency() const; - - // *************************** - // ** Flags for development ** - // *************************** - - /// Are the hit search areas ignored - bool DevIsIgnoreHitSearchAreas() const { return fDevIsIgnoreHitSearchAreas; } - - /// Is original field must be used instead of the approximated one - bool DevIsUseOfOriginalField() const { return fDevIsUseOfOriginalField; } - - /// Flag to match doublets using MC information - bool DevIsMatchDoubletsViaMc() const { return fDevIsMatchDoubletsViaMc; } - - /// Flag to match triplets using Mc information - bool DevIsMatchTripletsViaMc() const { return fDevIsMatchTripletsViaMc; } - - /// Flag to extend tracks using Mc information - bool DevIsExtendTracksViaMc() const { return fDevIsExtendTracksViaMc; } - - /// Flag to match hits in overlaps using Mc information - bool DevIsSuppressOverlapHitsViaMc() const { return fDevIsSuppressOverlapHitsViaMc; } - -private: - unsigned int fMaxDoubletsPerSinglet {150}; ///< Upper-bound cut on max number of doublets per one singlet - unsigned int fMaxTripletPerDoublets {15}; ///< Upper-bound cut on max number of triplets per one doublet - - alignas(constants::misc::Alignment) L1IterationsContainer_t fCAIterations {}; ///< L1 tracking iterations vector - - /************************* - ** Geometry parameters ** - *************************/ - /// Target position - alignas(constants::misc::Alignment) std::array<fvec, /*nDimensions*/ 3> fTargetPos {L1Utils::kNaN, L1Utils::kNaN, - L1Utils::kNaN}; - - /// Field value object at primary vertex (between target and the first station) - alignas(constants::misc::Alignment) ca::FieldValue fVertexFieldValue {}; - - /// Field region object at primary vertex (between target and the first station) - alignas(constants::misc::Alignment) ca::FieldRegion fVertexFieldRegion {}; - - /// Array of stations - alignas(constants::misc::Alignment) L1StationsContainer_t fStations {}; - - /// Array of station thickness map - alignas(constants::misc::Alignment) L1MaterialContainer_t fThickMap {}; - - // ** Station layout arrays ** - /// @brief First index of the station on the particular detector - /// The last element of the array corresponds to the total number of geometry stations - alignas(constants::misc::Alignment) std::array<int, constants::size::MaxNdetectors + 1> fvFirstGeoId {}; - - /// @brief Map of (local, det) to geo indices - /// - /// @note Usage: - /// iStGeo = fvLocaToGeoIdMap[fvFirstGeoId[iDet] + iStLocal]; - /// geo index. - 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 {}; - - /// @brief Map of geo to active indices - /// - /// The vector maps actual station index (which is defined by ) to the index of station in tracking. If the station - /// is inactive, its index is equal to -1. - /// @example Let stations 1 and 4 be inactive. Then: - /// geometry index: 0 1 2 3 4 5 6 7 8 9 0 0 0 0 - /// active index: 0 -1 1 2 -1 3 4 5 6 7 0 0 0 0 - alignas(constants::misc::Alignment) StationArray_t<int> fvGeoToActiveMap {}; - - /// @brief Map of active to geo indices - alignas(constants::misc::Alignment) StationArray_t<int> fvActiveToGeoMap {}; - - - alignas(constants::misc::Alignment) int fNstationsActiveTotal = -1; ///< total number of active tracking stations - - - /// @brief Map of search windows vs. active station global index and tracks group - /// - /// The tracks group can be defined by minimum momentum (fast/all tracks), origin (primary/secondary) and particle - /// type (electron, muon, all). Other options also can be added - alignas(constants::misc::Alignment) - std::array<L1SearchWindow, constants::size::MaxNstations* constants::size::MaxNtrackGroups> fSearchWindows = {}; - - int fGhostSuppression = 0; ///< flag: if true, ghost tracks are suppressed - int fRandomSeed = 1; ///< random seed - float fDefaultMass = constants::phys::MuonMass; - - // *************************** - // ** Flags for development ** - // *************************** - - bool fDevIsIgnoreHitSearchAreas {false}; ///< Process all hits on the station ignoring hit search area - bool fDevIsUseOfOriginalField {false}; ///< Force use of original field - bool fDevIsMatchDoubletsViaMc {false}; ///< Flag to match doublets using MC information - bool fDevIsMatchTripletsViaMc {false}; ///< Flag to match triplets using Mc information - bool fDevIsExtendTracksViaMc {false}; ///< Flag to extend tracks using Mc information - bool fDevIsSuppressOverlapHitsViaMc {false}; ///< Flag to match hits in overlaps using Mc information - - bool fDevIsParSearchWUsed = false; ///< Flag: when true, the parametrized search windows are used in track - ///< finder; when false, the Kalman filter is used instead - - /// Serialization function - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive& ar, const unsigned int) - { - ar& fMaxDoubletsPerSinglet; - ar& fMaxTripletPerDoublets; - - ar& fCAIterations; - ar& fTargetPos; - - ar& fVertexFieldValue; - ar& fVertexFieldRegion; - - ar& fStations; - ar& fThickMap; - - ar& fvFirstGeoId; - ar& fvLocalToGeoIdMap; - ar& fvGeoToLocalIdMap; - ar& fvGeoToActiveMap; - ar& fvActiveToGeoMap; - ar& fNstationsActiveTotal; - - ar& fSearchWindows; - - ar& fGhostSuppression; - ar& fRandomSeed; - ar& fDefaultMass; - - ar& fDevIsIgnoreHitSearchAreas; - ar& fDevIsUseOfOriginalField; - ar& fDevIsMatchDoubletsViaMc; - ar& fDevIsMatchTripletsViaMc; - ar& fDevIsExtendTracksViaMc; - ar& fDevIsSuppressOverlapHitsViaMc; - } -}; - -#endif // L1Parameters_h diff --git a/reco/L1/L1Algo/L1SearchWindow.h b/reco/L1/L1Algo/L1SearchWindow.h deleted file mode 100644 index 98899d9ce4..0000000000 --- a/reco/L1/L1Algo/L1SearchWindow.h +++ /dev/null @@ -1,172 +0,0 @@ -/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Sergey Gorbunov, Sergei Zharko [committer] */ - -/// \file L1SearchWindow.h -/// \brief Provides parameterisation for hits searching window in the CA tracking (header) -/// \date 08.11.2022 -/// \author S.Zharko <s.zharko@gsi.de> - -#ifndef L1SearchWindow_h -#define L1SearchWindow_h 1 - -#include <boost/serialization/array.hpp> -#include <boost/serialization/string.hpp> - -#include <array> -#include <string> - -/// TODO: SZh 8.11.2022: add selection of parameterisation - -/// \brief Class L1SearchWindow defines a parameterisation of hits search window for CA tracking algorithm -/// TODO: SZh 8.11.2022: add description -class L1SearchWindow { -public: - /// Constructor - /// \param stationID Global index of active station - /// \param trackGrID Track group ID - L1SearchWindow(int stationID, int trackGrID); - - /// Default constructor - L1SearchWindow() = default; - - /// Destructor - ~L1SearchWindow() = default; - - /// Copy constructor - L1SearchWindow(const L1SearchWindow& other) = default; - - /// Copy assignment operator - L1SearchWindow& operator=(const L1SearchWindow& other) = default; - - /// Move constructor - L1SearchWindow(L1SearchWindow&& other) noexcept = default; - - /// Move assignment operator - L1SearchWindow& operator=(L1SearchWindow&& other) = default; - - /// Parameterisation function for dx_max(x0) - float DxMaxVsX0(float /*x*/) const { return fvParams[kDxMaxVsX0 /*+ 0*/]; } - - /// Parameterisation function for dx_min(x0) - float DxMinVsX0(float /*x*/) const { return fvParams[kDxMinVsX0 /*+ 0*/]; } - - /// Parameterisation function for dx_max(y0) - float DxMaxVsY0(float /*x*/) const { return fvParams[kDxMaxVsY0 /*+ 0*/]; } - - /// Parameterisation function for dx_min(y0) - float DxMinVsY0(float /*x*/) const { return fvParams[kDxMinVsY0 /*+ 0*/]; } - - /// Parameterisation function for dy_max(x0) - float DyMaxVsX0(float /*x*/) const { return fvParams[kDyMaxVsX0 /*+ 0*/]; } - - /// Parameterisation function for dy_min(x0) - float DyMinVsX0(float /*x*/) const { return fvParams[kDyMinVsX0 /*+ 0*/]; } - - /// Parameterisation function for dy_max(y0) - float DyMaxVsY0(float /*y*/) const { return fvParams[kDyMaxVsY0 /*+ 0*/]; } - - /// Parameterisation function for dy_min(y0) - float DyMinVsY0(float /*y*/) const { return fvParams[kDyMinVsY0 /*+ 0*/]; } - - - /// Gets station id - int GetStationID() const { return fStationID; } - - /// Gets track group id - int GetTrackGroupID() const { return fTrackGroupID; } - - /// Sets tag - /// A tag can be used for insurance, if this search window corresponds to a desired track finder iteration - void SetTag(const char* name) { fsTag = name; } - - /// TODO: SZh 08.11.2022: Implement variadic template function - /// TODO: SZh 08.11.2022: Try to reduce number of functions - /// Sets parameters for dx_max(x0) - /// \param id Parameter index - /// \param val Parameter value - void SetParamDxMaxVsX0(int id, float val); - - /// Sets parameters for dx_min(x0) - /// \param id Parameter index - /// \param val Parameter value - void SetParamDxMinVsX0(int id, float val); - - /// Sets parameters for dx_max(y0) - /// \param id Parameter index - /// \param val Parameter value - void SetParamDxMaxVsY0(int id, float val); - - /// Sets parameters for dx_min(y0) - /// \param id Parameter index - /// \param val Parameter value - void SetParamDxMinVsY0(int id, float val); - - /// Sets parameters for dy_max(x0) - /// \param id Parameter index - /// \param val Parameter value - void SetParamDyMaxVsX0(int id, float val); - - /// Sets parameters for dy_min(x0) - /// \param id Parameter index - /// \param val Parameter value - void SetParamDyMinVsX0(int id, float val); - - /// Sets parameters for dy_max(y0) - /// \param id Parameter index - /// \param val Parameter value - void SetParamDyMaxVsY0(int id, float val); - - /// Sets parameters for dy_min(y0) - /// \param id Parameter index - /// \param val Parameter value - void SetParamDyMinVsY0(int id, float val); - - /// String representation of the contents - std::string ToString() const; - -private: - static constexpr unsigned char kNpars = 1; ///< Max number of parameters for one dependency - static constexpr unsigned char kNdeps = 8; ///< Number of the dependencies - - /// Enumeration for dependencies stored - enum EDependency - { - kDxMaxVsX0, - kDxMinVsX0, - kDxMaxVsY0, - kDxMinVsY0, - kDyMaxVsX0, - kDyMinVsX0, - kDyMaxVsY0, - kDyMinVsY0 - }; - - /// Search window parameter array containing parameters from - /// - dx_max vs x0 - indexes [0 .. kNpars - 1] - /// - dx_min vs x0 - indexes [kNpars .. (2 * kNpars - 1)] - /// - dx_max vs y0 - indexes [2 * kNpars .. (3 * kNpars - 1)] - /// - dx_min vs y0 - indexes [3 * kNpars .. (4 * kNpars - 1)] - /// - dy_max vs y0 - indexes [4 * kNpars .. (5 * kNpars - 1)] - /// - dy_min vs y0 - indexes [5 * kNpars .. (6 * kNpars - 1)] - /// - dy_max vs y0 - indexes [6 * kNpars .. (7 * kNpars - 1)] - /// - dy_min vs y0 - indexes [7 * kNpars .. (8 * kNpars - 1)] - std::array<float, kNdeps* kNpars> fvParams = {0}; - - int fStationID = -1; ///< Global index of active tracking station - int fTrackGroupID = -1; ///< Index of tracks group - std::string fsTag = ""; ///< Tag, containing information on the tracks group (TODO: can be omitted?) - - /// Serialization function - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive& ar, const unsigned int) - { - ar& fvParams; - ar& fStationID; - ar& fTrackGroupID; - ar& fsTag; - } -}; - -#endif // L1SearchWindow_h diff --git a/reco/L1/L1Algo/L1Utils.h b/reco/L1/L1Algo/L1Utils.h index 9764c4133a..cfd3f0c5c0 100644 --- a/reco/L1/L1Algo/L1Utils.h +++ b/reco/L1/L1Algo/L1Utils.h @@ -10,8 +10,6 @@ #ifndef L1Utils_h #define L1Utils_h 1 -#include <Logger.h> - #include <chrono> #include <iomanip> #include <limits> @@ -23,6 +21,7 @@ #include <cmath> +#include "AlgoFairloggerCompat.h" #include "CaSimd.h" #include "CaUtils.h" #include "L1Def.h" diff --git a/reco/L1/L1Algo/utils/CaAlgoRandom.h b/reco/L1/L1Algo/utils/CaAlgoRandom.h index f203c6d60d..7b70cdf7be 100644 --- a/reco/L1/L1Algo/utils/CaAlgoRandom.h +++ b/reco/L1/L1Algo/utils/CaAlgoRandom.h @@ -10,12 +10,12 @@ #ifndef CaAlgoRandom_h #define CaAlgoRandom_h 1 -#include <Logger.h> - #include <cstdint> #include <random> #include <type_traits> +#include "AlgoFairloggerCompat.h" + namespace cbm::algo::ca { /// @brief A class, providing ROOT-free access to randomly generated variables diff --git a/reco/L1/catools/CaToolsMCData.h b/reco/L1/catools/CaToolsMCData.h index d871dc6757..b0cf492010 100644 --- a/reco/L1/catools/CaToolsMCData.h +++ b/reco/L1/catools/CaToolsMCData.h @@ -18,7 +18,6 @@ #include "CaToolsMCPoint.h" #include "CaToolsMCTrack.h" #include "CaVector.h" -#include "L1EArray.h" enum class L1DetectorID; diff --git a/reco/L1/catools/CaToolsWindowFinder.cxx b/reco/L1/catools/CaToolsWindowFinder.cxx index 1e2491ff2a..935b590349 100644 --- a/reco/L1/catools/CaToolsWindowFinder.cxx +++ b/reco/L1/catools/CaToolsWindowFinder.cxx @@ -25,14 +25,15 @@ #include <yaml-cpp/yaml.h> #include "CaConstants.h" +#include "CaSearchWindow.h" #include "CaToolsWFExpression.h" #include "L1ConfigRW.h" -#include "L1SearchWindow.h" using namespace cbm::ca::tools; using namespace cbm::algo::ca::constants; // for colored logs using cbm::algo::ca::Iteration; +using cbm::algo::ca::SearchWindow; ClassImp(cbm::ca::tools::WindowFinder); @@ -57,7 +58,7 @@ void WindowFinder::AddInputFile(const char* filename) // --------------------------------------------------------------------------------------------------------------------- // -L1SearchWindow WindowFinder::CreateSW(int iStation, const ca::Iteration& caIter) +ca::SearchWindow WindowFinder::CreateSW(int iStation, const ca::Iteration& caIter) { // Get a cut @@ -144,7 +145,7 @@ L1SearchWindow WindowFinder::CreateSW(int iStation, const ca::Iteration& caIter) // Prepare a searching window int iCaIter = &caIter - &fvCaIters[0]; - L1SearchWindow sw(iStation, iCaIter); + ca::SearchWindow sw(iStation, iCaIter); sw.SetTag(caIter.GetName().c_str()); assert(fNparams == 1); // TMP: At the moment only constant windows available for (int iP = 0; iP < fNparams; ++iP) { diff --git a/reco/L1/catools/CaToolsWindowFinder.h b/reco/L1/catools/CaToolsWindowFinder.h index 695098ce04..eea45f3fa7 100644 --- a/reco/L1/catools/CaToolsWindowFinder.h +++ b/reco/L1/catools/CaToolsWindowFinder.h @@ -21,10 +21,14 @@ // TODO: Replace tmp asserts with exceptions class TChain; -class L1SearchWindow; class TPad; class TCanvas; +namespace cbm::algo::ca +{ + class SearchWindow; +} + namespace cbm::ca::tools { namespace ca = cbm::algo::ca; @@ -110,7 +114,7 @@ namespace cbm::ca::tools private: /// Creates a search window for a selected station and iteration - L1SearchWindow CreateSW(int iStation, const ca::Iteration& caIter); + ca::SearchWindow CreateSW(int iStation, const ca::Iteration& caIter); /// Returns expression for dx or dy to be drawn in a tree const char* GetDistExpr(EExpr expr) const; diff --git a/reco/L1/qa/CbmCaInputQaSetup.cxx b/reco/L1/qa/CbmCaInputQaSetup.cxx index 250b8055ff..0a884a8164 100644 --- a/reco/L1/qa/CbmCaInputQaSetup.cxx +++ b/reco/L1/qa/CbmCaInputQaSetup.cxx @@ -15,9 +15,10 @@ #include "TAxis.h" -#include "L1InitManager.h" #include "AlgoFairloggerCompat.h" +#include "L1InitManager.h" +using cbm::algo::ca::Parameters; using cbm::ca::InputQaSetup; // --------------------------------------------------------------------------------------------------------------------- @@ -140,7 +141,7 @@ try { LOG(info) << fName << ": initializing... "; // Tracking parameters { - fpParameters = std::make_unique<L1Parameters>(); + fpParameters = std::make_unique<ca::Parameters>(); L1InitManager manager; manager.ReadParametersObject(fsParametersFilename.c_str()); diff --git a/reco/L1/qa/CbmCaInputQaSetup.h b/reco/L1/qa/CbmCaInputQaSetup.h index 4a344f36cb..2c22fb81a9 100644 --- a/reco/L1/qa/CbmCaInputQaSetup.h +++ b/reco/L1/qa/CbmCaInputQaSetup.h @@ -33,7 +33,7 @@ #include "TClonesArray.h" -#include "L1Parameters.h" +#include "CaParameters.h" namespace cbm::ca { @@ -92,7 +92,7 @@ namespace cbm::ca DetIdArr_t<CbmMCDataArray*> fvpBrPoints = {{nullptr}}; ///< Input branch for MC points CbmMCDataObject* fpMCEventHeader = nullptr; ///< Pointer to MC event header - std::unique_ptr<L1Parameters> fpParameters = nullptr; ///< Pointer to CA parameters object + std::unique_ptr<ca::Parameters> fpParameters = nullptr; ///< Pointer to CA parameters object std::string fsParametersFilename = ""; ///< Filename for the tracking parameters DetIdArr_t<std::vector<double>> fvXmin; diff --git a/reco/L1/qa/CbmCaOutputQa.cxx b/reco/L1/qa/CbmCaOutputQa.cxx index 61d9694bb7..407430a171 100644 --- a/reco/L1/qa/CbmCaOutputQa.cxx +++ b/reco/L1/qa/CbmCaOutputQa.cxx @@ -971,7 +971,7 @@ InitStatus OutputQa::InitTimeSlice() // void OutputQa::ReadParameters(const char* filename) { - fpParameters = std::make_shared<L1Parameters>(); + fpParameters = std::make_shared<ca::Parameters>(); L1InitManager manager; manager.ReadParametersObject(filename); diff --git a/reco/L1/qa/CbmCaOutputQa.h b/reco/L1/qa/CbmCaOutputQa.h index 3e3921cabc..c8bf506a13 100644 --- a/reco/L1/qa/CbmCaOutputQa.h +++ b/reco/L1/qa/CbmCaOutputQa.h @@ -22,9 +22,9 @@ #include <memory> #include "CaMonitor.h" +#include "CaParameters.h" #include "CaToolsDebugger.h" #include "CaVector.h" -#include "L1Parameters.h" namespace cbm::ca { @@ -267,7 +267,7 @@ namespace cbm::ca std::shared_ptr<MCModule> fpMCModule = nullptr; ///< MC module std::shared_ptr<L1IODataManager> fpDataManager = nullptr; ///< Data manager std::shared_ptr<tools::Debugger> fpDebugger = nullptr; ///< Debugger - std::shared_ptr<L1Parameters> fpParameters = nullptr; ///< Tracking parameters object + std::shared_ptr<ca::Parameters> fpParameters = nullptr; ///< Tracking parameters object ca::Vector<CbmL1HitId> fvHitIds {"CbmCaOutputQa::fvHitIds"}; ca::Vector<CbmL1HitDebugInfo> fvHits {"CbmCaOutputQa::fvHits"}; diff --git a/reco/L1/qa/CbmCaTrackFitQa.h b/reco/L1/qa/CbmCaTrackFitQa.h index ba3e2b901b..c681fc5e1c 100644 --- a/reco/L1/qa/CbmCaTrackFitQa.h +++ b/reco/L1/qa/CbmCaTrackFitQa.h @@ -10,13 +10,14 @@ #ifndef CbmCaTrackFitQa_h #define CbmCaTrackFitQa_h 1 +#include "CbmL1DetectorID.h" #include "CbmQaIO.h" #include <array> #include "CaConstants.h" +#include "CaEnumArray.h" #include "CaField.h" -#include "L1EArray.h" #include "L1Fit.h" // Forward declarations @@ -59,7 +60,7 @@ namespace cbm::ca /// @brief Alias to array, indexed with ETrackParType enumeration template<typename T> - using TrackParArray_t = L1EArray<ETrackParType, T>; + using TrackParArray_t = ca::EnumArray<ETrackParType, T>; /// @brief Set of histograms to monitor track parameters /// diff --git a/reco/L1/qa/CbmCaTrackTypeQa.h b/reco/L1/qa/CbmCaTrackTypeQa.h index b3b9bbeefa..470cbb5a01 100644 --- a/reco/L1/qa/CbmCaTrackTypeQa.h +++ b/reco/L1/qa/CbmCaTrackTypeQa.h @@ -18,7 +18,7 @@ #include <map> #include <string> -#include "L1Parameters.h" +#include "CaParameters.h" // Forward declarations namespace cbm::ca::tools @@ -159,7 +159,7 @@ namespace cbm::ca /// @brief Registers CA parameters object /// @param pParameters A shared pointer to the parameters object - void RegisterParameters(std::shared_ptr<L1Parameters>& pParameters) { fpParameters = pParameters; } + void RegisterParameters(std::shared_ptr<ca::Parameters>& pParameters) { fpParameters = pParameters; } /// @brief Sets drawing attributes for histograms /// @param markerCol Marker color @@ -289,7 +289,7 @@ namespace cbm::ca ca::Vector<CbmL1Track>* fpvRecoTracks = nullptr; ///< Pointer to vector of reconstructed tracks ca::Vector<CbmL1HitDebugInfo>* fpvHits = nullptr; ///< Pointer to vector of reconstructed hits tools::MCData* fpMCData = nullptr; ///< Pointer to MC data object - std::shared_ptr<L1Parameters> fpParameters = nullptr; ///< Pointer to parameters object + std::shared_ptr<ca::Parameters> fpParameters = nullptr; ///< Pointer to parameters object // ** Cuts on tracks for a given track class ** diff --git a/reco/L1/utils/CbmCaIdealHitProducerDet.h b/reco/L1/utils/CbmCaIdealHitProducerDet.h index 4eae7c1852..555714bba5 100644 --- a/reco/L1/utils/CbmCaIdealHitProducerDet.h +++ b/reco/L1/utils/CbmCaIdealHitProducerDet.h @@ -39,7 +39,6 @@ #include "FairRootManager.h" #include "FairTask.h" -#include "Logger.h" #include "TClonesArray.h" #include "TVector3.h" @@ -53,6 +52,7 @@ #include <yaml-cpp/yaml.h> +#include "AlgoFairloggerCompat.h" #include "CaAlgoRandom.h" #include "CaConstants.h" #include "CaUvConverter.h" -- GitLab