diff --git a/algo/ca/core/CMakeLists.txt b/algo/ca/core/CMakeLists.txt index 8e43241baccbdc65a8a551fda1fe17449006fabc..020405c9d70aaa995e7404f18fa1c5e166e373ef 100644 --- a/algo/ca/core/CMakeLists.txt +++ b/algo/ca/core/CMakeLists.txt @@ -8,9 +8,10 @@ set(INCLUDE_DIRECTORIES set(SRCS ${CMAKE_CURRENT_SOURCE_DIR}/data/CaTrackParam.cxx ${CMAKE_CURRENT_SOURCE_DIR}/data/CaTrack.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/data/CaField.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/data/CaMaterialMap.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/data/CaStation.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/CaIteration.cxx ) add_library(CaCore SHARED ${SRCS}) @@ -41,10 +42,11 @@ install( data/CaTrackParam.h data/CaTrack.h data/CaHit.h - data/CaField.h - data/CaMaterialMap.h - data/CaStation.h + pars/CaField.h + pars/CaMaterialMap.h + pars/CaStation.h pars/CaConstants.h + pars/CaIteration.h utils/CaSimd.h utils/CaSimdVc.h utils/CaSimdPseudo.h diff --git a/algo/ca/core/data/CaField.cxx b/algo/ca/core/pars/CaField.cxx similarity index 100% rename from algo/ca/core/data/CaField.cxx rename to algo/ca/core/pars/CaField.cxx diff --git a/algo/ca/core/data/CaField.h b/algo/ca/core/pars/CaField.h similarity index 100% rename from algo/ca/core/data/CaField.h rename to algo/ca/core/pars/CaField.h diff --git a/algo/ca/core/pars/CaIteration.cxx b/algo/ca/core/pars/CaIteration.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4eb46afc61d5d532e8a36045dd2148adf5463fd0 --- /dev/null +++ b/algo/ca/core/pars/CaIteration.cxx @@ -0,0 +1,109 @@ +/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov, Sergei Zharko [committer] */ + +/// \file L1CAIteration.cxx +/// \brief Definition of the L1CAIteration class methods +/// \since 05.02.2022 +/// \author S.Zharko <s.zharko@gsi.de> + +#include "CaConstants.h" +#include "CaIteration.h" +#include "CaUtils.h" + +#include <limits> +#include <sstream> + +using cbm::algo::ca::Iteration; +using cbm::algo::ca::Vector; +using cbm::algo::ca::utils::CheckValueLimits; + +// --------------------------------------------------------------------------------------------------------------------- +// +Iteration::Iteration(const std::string& name) : fName(name) {} + +// --------------------------------------------------------------------------------------------------------------------- +// +bool Iteration::Check() const +{ + using constants::size::MaxNstations; + constexpr float kMaxFloat = std::numeric_limits<float>::max(); + bool res = true; + // TODO: SZh 06.10.2022: These values should be tuned. At the moment the std::numeric_limits<T>::max value is used for + // debug purposes. In future, these values will be strengthened. + res = CheckValueLimits<float>("track_chi2_cut", fTrackChi2Cut, 0.f, kMaxFloat) && res; + res = CheckValueLimits<float>("triplet_chi2_cut", fTripletChi2Cut, 0.f, kMaxFloat) && res; + res = CheckValueLimits<float>("triplet_final_chi2_cut", fTripletFinalChi2Cut, 0.f, kMaxFloat) && res; + res = CheckValueLimits<float>("doublet_chi2_cut", fDoubletChi2Cut, 0.f, kMaxFloat) && res; + res = CheckValueLimits<float>("pick_gather", fPickGather, 0.f, kMaxFloat) && res; + res = CheckValueLimits<float>("triplet_link_chi2", fTripletLinkChi2, 0.f, kMaxFloat) && res; + res = CheckValueLimits<float>("max_qp", fMaxQp, 0.001f, kMaxFloat) && res; + res = CheckValueLimits<float>("max_slope_pv", fMaxSlopePV, 0.f, kMaxFloat) && res; + res = CheckValueLimits<float>("max_slope", fMaxSlope, 0.f, kMaxFloat) && res; + res = CheckValueLimits<float>("max_dz", fMaxDZ, 0.f, kMaxFloat) && res; + res = CheckValueLimits<int>("min_n_hits", fMinNhits, 3, MaxNstations) && res; + res = CheckValueLimits<int>("min_n_hits_sta_0", fMinNhitsStation0, 3, MaxNstations) && res; + res = CheckValueLimits<int>("first_station_index", fFirstStationIndex, 0, MaxNstations) && res; + res = CheckValueLimits<float>("target_pos_sigma_x", fTargetPosSigmaX, 0.f, kMaxFloat) && res; + res = CheckValueLimits<float>("target_pos_sigma_y", fTargetPosSigmaY, 0.f, kMaxFloat) && res; + return res; +} + +// --------------------------------------------------------------------------------------------------------------------- +// +void Iteration::SetTargetPosSigmaXY(float sigmaX, float sigmaY) +{ + fTargetPosSigmaX = sigmaX; + fTargetPosSigmaY = sigmaY; +} + +// --------------------------------------------------------------------------------------------------------------------- +// +std::string Iteration::ToString(int) const +{ + std::vector<Iteration> vIter {*this}; + return Iteration::ToTableFromVector(vIter); +} + +// --------------------------------------------------------------------------------------------------------------------- +// +std::string Iteration::ToTableFromVector(const Vector<Iteration>& vIterations) +{ + std::stringstream msg; + msg << std::boolalpha; + + auto PutRow = [&](const std::string& name, std::function<void(const Iteration&)> fn) { + msg << std::setw(40) << std::setfill(' ') << name << ' '; + for (const auto& iter : vIterations) { + msg << std::setw(12) << std::setfill(' '); + fn(iter); + msg << ' '; + } + msg << '\n'; + }; + + PutRow(" ", [&](const Iteration& i) { msg << i.GetName(); }); + PutRow("Is primary ", [&](const Iteration& i) { msg << i.GetPrimaryFlag(); }); + PutRow("Is electron ", [&](const Iteration& i) { msg << i.GetElectronFlag(); }); + PutRow("If tracks created from triplets ", [&](const Iteration& i) { msg << i.GetTrackFromTripletsFlag(); }); + PutRow("If tracks extended with unused hits", [&](const Iteration& i) { msg << i.GetExtendTracksFlag(); }); + PutRow("If triplets jump over one station ", [&](const Iteration& i) { msg << i.GetJumpedFlag(); }); + PutRow("Min number of hits ", [&](const Iteration& i) { msg << i.GetMinNhits(); }); + PutRow("Min number of hits on station 0 ", [&](const Iteration& i) { msg << i.GetMinNhitsStation0(); }); + PutRow("Track chi2 cut ", [&](const Iteration& i) { msg << i.GetTrackChi2Cut(); }); + PutRow("Triplet chi2 cut ", [&](const Iteration& i) { msg << i.GetTripletChi2Cut(); }); + PutRow("Triplet final chi2 cut ", [&](const Iteration& i) { msg << i.GetTripletFinalChi2Cut(); }); + PutRow("Doublet chi2 cut ", [&](const Iteration& i) { msg << i.GetDoubletChi2Cut(); }); + PutRow("Pick gather ", [&](const Iteration& i) { msg << i.GetPickGather(); }); + PutRow("Triplet link chi2 ", [&](const Iteration& i) { msg << i.GetTripletLinkChi2(); }); + PutRow("Max q/p ", [&](const Iteration& i) { msg << i.GetMaxQp(); }); + PutRow("Max slope ", [&](const Iteration& i) { msg << i.GetMaxSlope(); }); + PutRow("Max slope at primary vertex ", [&](const Iteration& i) { msg << i.GetMaxSlopePV(); }); + PutRow("Max DZ ", [&](const Iteration& i) { msg << i.GetMaxDZ(); }); + PutRow("Target position sigma X [cm] ", [&](const Iteration& i) { msg << i.GetTargetPosSigmaX(); }); + PutRow("Target position sigma Y [cm] ", [&](const Iteration& i) { msg << i.GetTargetPosSigmaY(); }); + PutRow("First tracking station index ", [&](const Iteration& i) { msg << i.GetFirstStationIndex(); }); + + return msg.str(); +} + diff --git a/algo/ca/core/pars/CaIteration.h b/algo/ca/core/pars/CaIteration.h new file mode 100644 index 0000000000000000000000000000000000000000..2c1847aaaa16083660c614642f1bb02862cfb358 --- /dev/null +++ b/algo/ca/core/pars/CaIteration.h @@ -0,0 +1,288 @@ +/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov, Sergei Zharko [committer] */ + +/*************************************************************************************************** + * @file L1CAIteration.h + * @brief Declaration of the L1CAIteration class + * @since 05.02.2022 + * @author S.Zharko <s.zharko@gsi.de> + ***************************************************************************************************/ + +#ifndef CaIteration_h +#define CaIteration_h 1 + +#include <boost/serialization/access.hpp> +#include <boost/serialization/string.hpp> + +#include <bitset> +#include <iomanip> +#include <string> + +#include "CaVector.h" + +namespace cbm::algo::ca { + /// \class cbm::algo::ca::Iteration + /// \brief A set of parameters for the CA Track finder iteration + /// + /// Each iteration utilizes special physics cuts and run condition to find tracks of a particular + /// class (e.g., fast primary tracks or secondary electron tracks). Hits associated with tracks + /// reconstructed during current iteration are removed from the further iterations. + class Iteration { + public: + /// \brief Default constructor + Iteration() = default; + + /// \brief Copy constructor + Iteration(const Iteration& other) = default; + + /// \brief Copy constructor + Iteration(const Iteration& other, const std::string& name) : Iteration(other) { SetName(name); } + + /// \brief Move constructor + Iteration(Iteration&& other) noexcept = default; + + /// \brief Constructor from L1CAIteration type + Iteration(const std::string& name); + + /// \brief Destructor + ~Iteration() noexcept = default; + + /// \brief Copy assignment operator + Iteration& operator=(const Iteration& other) = default; + + /// \brief Move assignment operator + Iteration& operator=(Iteration&& other) = default; + + /// \brief Checks parameters consistency + bool Check() const; + + /// \brief Gets doublet chi2 upper cut + float GetDoubletChi2Cut() const { return fDoubletChi2Cut; } + + /// \brief flag check: electrons/positrons - true, heavy charged - false + bool GetElectronFlag() const { return fIsElectron; } + + /// \brief Sets flag: true - extends track candidates with unused hits + bool GetExtendTracksFlag() const { return fIsExtendTracks; } + + /// \brief Gets station index of the first station used in tracking + int GetFirstStationIndex() const { return fFirstStationIndex; } + + /// \brief Gets flag: true - triplets are built skipping one station + bool GetJumpedFlag() const { return fIsJumped; } + + /// \brief Gets correction for accounting overlaping and iff z + float GetMaxDZ() const { return fMaxDZ; } + + /// \brief Gets max considered q/p for tracks + float GetMaxQp() const { return fMaxQp; } + + /// \brief Gets max slope (tx\ty) in 3D hit position of a triplet + float GetMaxSlope() const { return fMaxSlope; } + + /// \brief Gets max slope (tx\ty) in primary vertex + float GetMaxSlopePV() const { return fMaxSlopePV; } + + /// \brief Gets min n hits + int GetMinNhits() const { return fMinNhits; } + + /// \brief Gets min n hits for tracks that start on station 0 + int GetMinNhitsStation0() const { return fMinNhitsStation0; } + + /// \brief Gets the name of the iteration + const std::string& GetName() const { return fName; } + + /// \brief Gets size of region [TODO: units??] to attach new hits to the created track + float GetPickGather() const { return fPickGather; } + + /// \brief Checks flag: true - only primary tracks are searched, false - [all or only secondary?] + bool GetPrimaryFlag() const { return fIsPrimary; } + + /// \brief Gets sigma target position in X direction [cm] + float GetTargetPosSigmaX() const { return fTargetPosSigmaX; } + + /// \brief Gets sigma target position in Y direction [cm] + float GetTargetPosSigmaY() const { return fTargetPosSigmaY; } + + /// \brief Gets track chi2 upper cut + float GetTrackChi2Cut() const { return fTrackChi2Cut; } + + /// (DEBUG!) Sets flag: + /// true: + /// all the triplets found on this iteration will be converted to tracks, + /// all the iterations following after this one will be rejected from the + /// iterations sequence; + /// false (default): + /// tracks are built from triplets, and the minimal amount of hits used in + /// each track equals four. In case of primary tracks the first measurement + /// is taken from the target, and the other three measurements are taken from + /// the triplet. + bool GetTrackFromTripletsFlag() const { return fIsTrackFromTriplets; } + + /// \brief Gets triplet chi2 upper cut + float GetTripletChi2Cut() const { return fTripletChi2Cut; } + + /// \brief Gets triplet chi2 upper cut + float GetTripletFinalChi2Cut() const { return fTripletFinalChi2Cut; } + + /// \brief Gets min value of dp/dp_error, for which two tiplets are neighbours + float GetTripletLinkChi2() const { return fTripletLinkChi2; } + + /// \brief Sets doublet chi2 upper cut + void SetDoubletChi2Cut(float input) { fDoubletChi2Cut = input; } + + /// \brief Sets flag: electron tracks - true, heavy ion tracks - false + void SetElectronFlag(bool flag) { fIsElectron = flag; } + + /// \brief Sets flag: true - extends track candidates with unused hits + void SetExtendTracksFlag(bool flag) { fIsExtendTracks = flag; } + + /// \brief Sets index of first station used in tracking + void SetFirstStationIndex(int index) { fFirstStationIndex = index; } + + /// \brief Sets flag: true - triplets are built from hits .... TODO + void SetJumpedFlag(bool flag) { fIsJumped = flag; } + + /// \brief Sets correction for accounting overlaping and iff z + void SetMaxDZ(float input) { fMaxDZ = input; } + + /// \brief Sets max considered q/p for tracks + void SetMaxQp(float input) { fMaxQp = input; } + + /// \brief Sets max slope (tx\ty) in 3D hit position of a triplet + void SetMaxSlope(float input) { fMaxSlope = input; } + + /// \brief Sets max slope (tx\ty) in primary vertex + void SetMaxSlopePV(float input) { fMaxSlopePV = input; } + + /// \brief Sets flag: true - skip track candidates with level = 0 + void SetMinNhits(int val) { fMinNhits = val; } + + /// \brief Sets min n hits for tracks that start on station 0 + void SetMinNhitsStation0(int val) { fMinNhitsStation0 = val; } + + /// \brief Sets name of the iteration + void SetName(const std::string& name) { fName = name; } + + /// \brief Sets size of region [TODO: units??] to attach new hits to the created track + void SetPickGather(float input) { fPickGather = input; } + + /// \brief Sets flag: primary tracks - true, secondary tracks - false + void SetPrimaryFlag(bool flag) { fIsPrimary = flag; } + + /// \brief Sets sigma of target positions in XY plane + /// \param sigmaX Sigma value in X direction [cm] + /// \param sigmaX Sigma value in Y direction [cm] + void SetTargetPosSigmaXY(float sigmaX, float sigmaY); + + /// \brief Sets track chi2 upper cut + void SetTrackChi2Cut(float input) { fTrackChi2Cut = input; } + + /// \brief Sets flag: + /// true: + /// all the triplets found on this iteration will be converted to tracks, + /// all the iterations following after this one will be rejected from the + /// iterations sequence; + /// false (default): + /// tracks are built from triplets, and the minimal amount of hits used in + /// each track equals four. In case of primary tracks the first measurement + /// is taken from the target, and the other three measurements are taken from + /// the triplet. + void SetTrackFromTripletsFlag(bool flag) { fIsTrackFromTriplets = flag; } + + /// \brief Sets triplet chi2 upper cut + void SetTripletChi2Cut(float input) { fTripletChi2Cut = input; } + + /// \brief Sets triplet chi2 upper cut + void SetTripletFinalChi2Cut(float input) { fTripletFinalChi2Cut = input; } + + /// \brief Sets min value of dp/dp_error, for which two tiplets are neighbours + void SetTripletLinkChi2(float input) { fTripletLinkChi2 = input; } + + /// \brief String representation of the class contents + /// \param indentLevel Level of indentation for the text (in terms of \t symbols) + std::string ToString(int indentLevel = 0) const; + + /// \brief Forms a string, representing a table of iterations from the vector of iterations + /// \param vIterations Vector of iterations + /// \return Iterations table represented with a string + static std::string ToTableFromVector(const Vector<Iteration>& vIterations); + + private: + /** Basic fields **/ + std::string fName {""}; ///< Iteration name + + /** Track finder dependent cuts **/ + // TODO: Iteratively change the literals to floats (S.Zharko) + // NOTE: For each new cut one should not forget to create a setter and a getter, insert the value + // initialization in the copy constructor and the Swap operator as well as a string repre- + // sentation to the ToString method (S.Zharko) + float fTrackChi2Cut = 10.f; ///< Track chi2 upper cut + float fTripletChi2Cut = 21.1075f; ///< Triplet chi2 upper cut + float fTripletFinalChi2Cut = 21.1075f; ///< Triplet chi2 upper cut + float fDoubletChi2Cut = 11.3449 * 2.f / 3.f; ///< Doublet chi2 upper cut + float fPickGather = 3.0; ///< Size of region to attach new hits to the created track + float fTripletLinkChi2 = 25.0; ///< Min value of dp^2/dp_error^2, for which two tiplets are neighbours + float fMaxQp = 1.0 / 0.5; ///< Max considered q/p for tracks + float fMaxSlopePV = 1.1; ///< Max slope (tx\ty) in primary vertex + float fMaxSlope = 2.748; ///< Max slope (tx\ty) in 3D hit position of a triplet + float fMaxDZ = 0.f; ///< Correction for accounting overlaping and iff z [cm] + float fTargetPosSigmaX = 0; ///< Constraint on target position in X direction [cm] + float fTargetPosSigmaY = 0; ///< Constraint on target position in Y direction [cm] + int fFirstStationIndex = 0; ///< First station, used for tracking + int fMinNhits = 3; ///< min n hits on the tracks + int fMinNhitsStation0 = 3; ///< min n hits for tracks that start on station 0 + bool fIsPrimary = false; ///< Flag: true - only primary tracks are searched for + bool fIsElectron = false; ///< Flag: true - only electrons are searched for + bool fIsExtendTracks = false; ///< Flag: true - extends track candidates with unused hits + bool fIsJumped = false; ///< Flag: true - find triplets with skip station + + + /// @brief Flag to select triplets on the iteration as tracks + /// In ordinary cases, the shortest track consists from four hits. For primary track the target is accounted as + /// the first hit, and the other three hits are taken from the stations. For secondary track all the hits are selected + /// from the stations only. + /// If the fIsTrackFromTriplets flag is turned on, all of the triplets found on this iterations will be considered + /// as tracks. + /// + /// @note The only one iteration with the fIsTrackFromTriplets flag turned on can exist in the tracking iterations + /// sequence and this iteration should be the last in the tracking sequence. + bool fIsTrackFromTriplets = false; + + /// Serialization method, used to save ca::Hit objects into binary or text file in a defined order + friend class boost::serialization::access; + template<class Archive> + void serialize(Archive& ar, const unsigned int /*version*/) + { + ar& fName; + ar& fTrackChi2Cut; + ar& fTripletChi2Cut; + ar& fTripletFinalChi2Cut; + ar& fDoubletChi2Cut; + ar& fPickGather; + ar& fTripletLinkChi2; + ar& fMaxQp; + ar& fMaxSlopePV; + ar& fMaxSlope; + ar& fMaxDZ; + ar& fTargetPosSigmaX; + ar& fTargetPosSigmaY; + ar& fFirstStationIndex; + ar& fMinNhits; + ar& fMinNhitsStation0; + ar& fIsPrimary; + ar& fIsElectron; + ar& fIsExtendTracks; + ar& fIsJumped; + ar& fIsTrackFromTriplets; + } + + + }; +} + + + + +#endif // L1CAIteration_h diff --git a/algo/ca/core/data/CaMaterialMap.cxx b/algo/ca/core/pars/CaMaterialMap.cxx similarity index 100% rename from algo/ca/core/data/CaMaterialMap.cxx rename to algo/ca/core/pars/CaMaterialMap.cxx diff --git a/algo/ca/core/data/CaMaterialMap.h b/algo/ca/core/pars/CaMaterialMap.h similarity index 50% rename from algo/ca/core/data/CaMaterialMap.h rename to algo/ca/core/pars/CaMaterialMap.h index 136875954c2f3336f9c5aa7ecf815daf715ca706..e7ed5e914171becc106f410dd4b734d80c9d926a 100644 --- a/algo/ca/core/data/CaMaterialMap.h +++ b/algo/ca/core/pars/CaMaterialMap.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +/* Copyright (C) 2007-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt SPDX-License-Identifier: GPL-3.0-only Authors: Igor Kulakov, Sergey Gorbunov [committer], Andrey Lebedev, Sergei Zharko */ @@ -17,104 +17,103 @@ namespace cbm::algo::ca { - - /// Class MaterialMap describes a map of station thickness in units of radiation length (X0) to the specific point in XY plane + /// \class MaterialMap + /// \brief A map of station thickness in units of radiation length (X0) to the specific point in XY plane class MaterialMap { public: - /// Constructor + /// \brief Default constructor MaterialMap() = default; - /// Copy constructor + /// \brief Copy constructor MaterialMap(const MaterialMap& other) = default; - /// Copy assignment operator + /// \brief Copy assignment operator MaterialMap& operator=(const MaterialMap& other) = default; - /// Move constructor + /// \brief Move constructor MaterialMap(MaterialMap&& other) noexcept; - /// Move assignment operator + /// \brief Move assignment operator MaterialMap& operator=(MaterialMap&& other) noexcept; - /// Destructor + /// \brief Destructor ~MaterialMap() noexcept = default; - /// Gets number of bins (rows or columns) of the material table + /// \brief Gets number of bins (rows or columns) of the material table int GetNbins() const { return fNbins; } - /// Gets radius in cm of the material table + /// \brief Gets radius in cm of the material table float GetXYmax() const { return fXYmax; } - /// Gets reference Z of the material in cm + /// \brief Gets reference Z of the material in cm float GetZref() const { return fZref; } - /// Gets minimal Z of the collected material in cm + /// \brief Gets minimal Z of the collected material in cm float GetZmin() const { return fZmin; } - /// Gets maximal Z of the collected material in cm + /// \brief Gets maximal Z of the collected material in cm float GetZmax() const { return fZmax; } - /// Gets value of X/X0 in a given cell of the material table by the indeces of the row and column + /// \brief Gets value of X/X0 in a given cell of the material table by the indeces of the row and column /// \param iBinX Index of table column /// \param iBinY Index of table row float GetRadThickBin(int iBinX, int iBinY) const { return fTable[iBinX + fNbins * iBinY]; } - /// Gets value of X/X0 in a given cell of the material table by the index of the bin + /// \brief Gets value of X/X0 in a given cell of the material table by the index of the bin /// \param iBin Index of the bin in 2d table float GetRadThickBin(int iBin) const { return fTable[iBin]; } - /// Gets material thickness in units of X0 in (x,y) point of the station + /// \brief Gets material thickness in units of X0 in (x,y) point of the station /// \param x X coordinate of the point [cm] /// \param y Y coordinate of the point [cm] float GetRadThickScal(float x, float y) const; - /// Gets material thickness in units of X0 in (x,y) point of the station + /// \brief Gets material thickness in units of X0 in (x,y) point of the station /// cbm::algo::ca::fvec type can be float, that is why "Vec" and "Scal" specifications /// \param x X coordinate of the point [cm] (SIMDized vector) /// \param y Y coordinate of the point [cm] (SIMDized veotor) fvec GetRadThickVec(fvec x, fvec y) const; - /// Checks, if the fields are NaN + /// \brief Checks, if the fields are NaN bool IsNaN() const { return utils::IsUndefined(fNbins) || utils::IsUndefined(fXYmax) || utils::IsUndefined(fFactor) || utils::IsUndefined(fZref) || utils::IsUndefined(fZmin) || utils::IsUndefined(fZmax); } - /// Verifies class invariant consistency + /// \brief Verifies class invariant consistency void CheckConsistency() const; - /// Sets value of material thickness in units of X0 for a given cell of the material table - /// WARNING: Indeces 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 carefull reading and storing the table from ROOT-file, because iBinX = 0 and iBinY = 0 in the - /// SetBinContent method of a ROOT histogram usually defines underflow bin + /// \brief Sets value of material thickness in units of X0 for a given cell of the material table /// \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, + /// 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; } - /// Sets properties of the material table -- number of rows or columnts and the size of station in XY plane - /// \param nBins Number of rows or columns - /// \param xyMax Size of station in x and y dimensions [cm] + /// \brief Sets properties of the material table -- number of rows or columnts and the size of station in XY plane + /// \param nBins Number of rows or columns + /// \param xyMax Size of station in x and y dimensions [cm] void Initialize(int nBins, float xyMax, float zRef, float zMin, float zMax); - /// Swap method + /// \brief Swap method void Swap(MaterialMap& other) noexcept; - /// Get bin index for (x,y). Returns -1 when outside of the map + /// \brief Get bin index for (x,y). Returns -1 when outside of the map int GetBin(float x, float y) const; private: - int fNbins = constants::Undef<int>; ///< Number of rows (== N columns) in the material budget table - float fXYmax = constants::Undef<float>; ///< Size of the station in x and y dimensions [cm] - float fFactor = - constants::Undef<float>; ///< Factor used in the recalculation of point coordinates to row/column id - float fZref = constants::Undef<float>; ///< Reference Z of the collected material [cm] - float fZmin = constants::Undef<float>; ///< Minimal Z of the collected material [cm] - float fZmax = constants::Undef<float>; ///< Minimal Z of the collected material [cm] - std::vector<float> fTable {}; ///< Material budget table - - /// Serialization function + int fNbins = constants::Undef<int>; ///< Number of rows (== N columns) in the material budget table + float fXYmax = constants::Undef<float>; ///< Size of the station in x and y dimensions [cm] + float fFactor = constants::Undef<float>; ///< Util. var. for the conversion of point coordinates to row/column id + float fZref = constants::Undef<float>; ///< Reference Z of the collected material [cm] + float fZmin = constants::Undef<float>; ///< Minimal Z of the collected material [cm] + float fZmax = constants::Undef<float>; ///< Minimal Z of the collected material [cm] + std::vector<float> fTable {}; ///< Material budget table + + /// \brief Serialization function friend class boost::serialization::access; template<class Archive> void serialize(Archive& ar, const unsigned int) diff --git a/algo/ca/core/data/CaStation.cxx b/algo/ca/core/pars/CaStation.cxx similarity index 100% rename from algo/ca/core/data/CaStation.cxx rename to algo/ca/core/pars/CaStation.cxx diff --git a/algo/ca/core/data/CaStation.h b/algo/ca/core/pars/CaStation.h similarity index 95% rename from algo/ca/core/data/CaStation.h rename to algo/ca/core/pars/CaStation.h index e3b5826d84d07e56498ce7eb77c2df32b27d0766..6f5bdc134cc194a95582b9e78d7aad93e1060f09 100644 --- a/algo/ca/core/data/CaStation.h +++ b/algo/ca/core/pars/CaStation.h @@ -13,7 +13,6 @@ namespace cbm::algo::ca { - /// Structure Station /// Contains a set of geometry parameters for a particular station /// @@ -22,7 +21,7 @@ namespace cbm::algo::ca // TODO: SZh 12.05.2022: Rewrite type into L1DetectorID, change detector indexing scheme // TODO: SZh 12.05.2022: Provide getters to stations - int type = constants::Undef<int>; // ? Detector type? + int type = constants::Undef<int>; // TODO: replace with L1DetectorID int timeInfo = constants::Undef<int>; ///< flag: if time information can be used int fieldStatus = constants::Undef<int>; ///< flag: 1 - station is INSIDE the field, 0 - station is OUTSIDE the field @@ -30,7 +29,7 @@ namespace cbm::algo::ca fvec Xmax = constants::Undef<fvec>; ///< min radius of the station [cm] fvec Ymax = constants::Undef<fvec>; ///< max radius of the station [cm] - FieldSlice fieldSlice {}; + FieldSlice fieldSlice {}; ///< Magnetic field near the station // Serialization block friend class boost::serialization::access; diff --git a/algo/ca/core/utils/CaUtils.h b/algo/ca/core/utils/CaUtils.h index a448de531b868ff2a99612d0ed83f94dafee9342..c71f515f83a5431054ae1946c6e8643cc79cc9c5 100644 --- a/algo/ca/core/utils/CaUtils.h +++ b/algo/ca/core/utils/CaUtils.h @@ -29,13 +29,15 @@ namespace cbm::algo::ca::utils return b ? t : f; } + template<typename T> inline T fabs(const T& v) { return std::fabs(v); } - /// Checks whether a variable of a particular type defined + /// \brief Checks whether a variable of a particular type defined + /// \param val Value to be checked template<typename T> inline bool IsUndefined(T val) { @@ -54,7 +56,8 @@ namespace cbm::algo::ca::utils } } - /// Checks whether a variable of a particular type is finite + /// \brief Checks whether a variable of a particular type is finite + /// \param val Value to check template<typename T> inline bool IsFinite(T val) { @@ -73,6 +76,8 @@ namespace cbm::algo::ca::utils } } + /// \brief Checks, if a SIMD vector horizontally equal + /// TODO: Find this method in the VC! [[gnu::always_inline]] inline void CheckSimdVectorEquality(fvec v, const char* name) { bool ok = true; @@ -86,6 +91,21 @@ namespace cbm::algo::ca::utils } } + /// \brief Checks, if a particular value lies within selected limits + /// \param name Name of parameters + /// \param value Value of parameter + /// \param lLimit Lower limit of parameter + /// \param uLimit Upper limit of parameter + template<typename T> + 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 << ']'; + return false; + } + return true; + } } // namespace cbm::algo::ca::utils diff --git a/algo/ca/core/utils/CaVector.h b/algo/ca/core/utils/CaVector.h index 0746c0d5b7aae7337112ebb6e082784984fd9cd7..321361c8dc56838237cb737b1832252f9a5dbdcb 100644 --- a/algo/ca/core/utils/CaVector.h +++ b/algo/ca/core/utils/CaVector.h @@ -11,7 +11,7 @@ #ifndef FAST_CODE -#include "Logger.h" +#include "AlgoFairloggerCompat.h" #endif #include <boost/serialization/access.hpp> #include <boost/serialization/base_object.hpp> diff --git a/reco/L1/CMakeLists.txt b/reco/L1/CMakeLists.txt index 3f4b0e51044d5f4e28f05b7e28bf48d07a1d7ada..77a14cbdfa9e4fe0be77ccb632d74fbac67fa37d 100644 --- a/reco/L1/CMakeLists.txt +++ b/reco/L1/CMakeLists.txt @@ -49,7 +49,6 @@ set(SRCS L1Algo/L1MaterialMonitor.cxx L1Algo/L1UMeasurementInfo.cxx L1Algo/L1XYMeasurementInfo.cxx - L1Algo/L1CAIteration.cxx L1Algo/L1BaseStationInfo.cxx L1Algo/L1InitManager.cxx L1Algo/L1Parameters.cxx diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index aa9c80344024d42f4238eca1d974b940bfc053a7..b9471123bda3ba8278882eef2ffabbca933dceb0 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -49,11 +49,12 @@ using namespace cbm::algo::ca; //TODO: remove class CbmL1MCTrack; -namespace -{ - using cbm::algo::ca::Track; // TMP - using cbm::algo::ca::Vector; // TMP -} // namespace +//namespace +//{ +// using cbm::algo::ca::Track; // TMP +// using cbm::algo::ca::Vector; // TMP +// using cbm::algo::ca::Iteration; // TMP +//} // namespace // ******************************* // ** Types definition (global) ** @@ -337,7 +338,7 @@ public: /// --- data used during finding iterations int isec {0}; // iteration TODO: to be dispatched (S.Zharko, 21.06.2022) - const L1CAIteration* 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/L1CAIteration.cxx b/reco/L1/L1Algo/L1CAIteration.cxx deleted file mode 100644 index fa4ae4f863a0cec493853b6d459c1fd679fb4cdc..0000000000000000000000000000000000000000 --- a/reco/L1/L1Algo/L1CAIteration.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Sergey Gorbunov, Sergei Zharko [committer] */ - -/*************************************************************************************************** - * @file L1CAIteration.cxx - * @brief Definition of the L1CAIteration class methods - * @since 05.02.2022 - * @author S.Zharko <s.zharko@gsi.de> - ***************************************************************************************************/ - -#include "L1CAIteration.h" - -#include <limits> -#include <sstream> - -#include "CaConstants.h" - -using namespace cbm::algo::ca; //TODO: remove - -// --------------------------------------------------------------------------------------------------------------------- -// -L1CAIteration::L1CAIteration(const std::string& name) : fName(name) {} - -// --------------------------------------------------------------------------------------------------------------------- -// -bool L1CAIteration::Check() const -{ - using constants::size::MaxNstations; - constexpr float kMaxFloat = std::numeric_limits<float>::max(); - bool res = true; - // TODO: SZh 06.10.2022: These values should be tuned. At the moment the std::numeric_limits<T>::max value is used for - // debug purposes. In future, these values will be strengthened. - res = this->CheckValueLimits<float>("track_chi2_cut", fTrackChi2Cut, 0.f, kMaxFloat) && res; - res = this->CheckValueLimits<float>("triplet_chi2_cut", fTripletChi2Cut, 0.f, kMaxFloat) && res; - res = this->CheckValueLimits<float>("triplet_final_chi2_cut", fTripletFinalChi2Cut, 0.f, kMaxFloat) && res; - res = this->CheckValueLimits<float>("doublet_chi2_cut", fDoubletChi2Cut, 0.f, kMaxFloat) && res; - res = this->CheckValueLimits<float>("pick_gather", fPickGather, 0.f, kMaxFloat) && res; - res = this->CheckValueLimits<float>("triplet_link_chi2", fTripletLinkChi2, 0.f, kMaxFloat) && res; - res = this->CheckValueLimits<float>("max_qp", fMaxQp, 0.001f, kMaxFloat) && res; - res = this->CheckValueLimits<float>("max_slope_pv", fMaxSlopePV, 0.f, kMaxFloat) && res; - res = this->CheckValueLimits<float>("max_slope", fMaxSlope, 0.f, kMaxFloat) && res; - res = this->CheckValueLimits<float>("max_dz", fMaxDZ, 0.f, kMaxFloat) && res; - res = this->CheckValueLimits<int>("min_n_hits", fMinNhits, 3, MaxNstations) && res; - res = this->CheckValueLimits<int>("min_n_hits_sta_0", fMinNhitsStation0, 3, MaxNstations) && res; - res = this->CheckValueLimits<int>("first_station_index", fFirstStationIndex, 0, MaxNstations) && res; - res = this->CheckValueLimits<float>("target_pos_sigma_x", fTargetPosSigmaX, 0.f, kMaxFloat) && res; - res = this->CheckValueLimits<float>("target_pos_sigma_y", fTargetPosSigmaY, 0.f, kMaxFloat) && res; - return res; -} - -// --------------------------------------------------------------------------------------------------------------------- -// -void L1CAIteration::Print(int verbosityLevel) const -{ - if (verbosityLevel == 0) { LOG(info) << " - " << fName; } - if (verbosityLevel > 0) { LOG(info) << ToString(0); } -} - -// --------------------------------------------------------------------------------------------------------------------- -// -void L1CAIteration::SetTargetPosSigmaXY(float sigmaX, float sigmaY) -{ - fTargetPosSigmaX = sigmaX; - fTargetPosSigmaY = sigmaY; -} - -// --------------------------------------------------------------------------------------------------------------------- -// -std::string L1CAIteration::ToString(int) const -{ - std::vector<L1CAIteration> vIter {*this}; - return L1CAIteration::ToTableFromVector(vIter); -} diff --git a/reco/L1/L1Algo/L1CAIteration.h b/reco/L1/L1Algo/L1CAIteration.h deleted file mode 100644 index 213c9d65ef7880e3992ffa0e4b15f095a4a1602a..0000000000000000000000000000000000000000 --- a/reco/L1/L1Algo/L1CAIteration.h +++ /dev/null @@ -1,351 +0,0 @@ -/* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Sergey Gorbunov, Sergei Zharko [committer] */ - -/*************************************************************************************************** - * @file L1CAIteration.h - * @brief Declaration of the L1CAIteration class - * @since 05.02.2022 - * @author S.Zharko <s.zharko@gsi.de> - ***************************************************************************************************/ - -#ifndef L1CAIteration_h -#define L1CAIteration_h 1 - -#include <Logger.h> - -#include <boost/serialization/access.hpp> -#include <boost/serialization/string.hpp> - -#include <bitset> -#include <iomanip> -#include <string> - -// TODO: discuss the border conditions for the parameters. Implement them (S.Zharko) -// Implementation: use tuples for boundary conditions of the parameters -/// Class L1CAIteration describes L1 Track finder iteration. -/// Each iteration utilizes special physics cuts and run condition to find tracks of a particular -/// class (e.g., fast primary tracks or secondary electron tracks). Hits associated with tracks -/// reconstructed during current iteration are removed from the further iterations. -/// -class L1CAIteration { -public: - /// Default constructor - L1CAIteration() = default; - - /// Copy constructor - L1CAIteration(const L1CAIteration& other) = default; - - /// Copy constructor - L1CAIteration(const L1CAIteration& other, const std::string& name) : L1CAIteration(other) { SetName(name); } - - /// Move constructor - L1CAIteration(L1CAIteration&& other) noexcept = default; - - /// Constructor from L1CAIteration type - L1CAIteration(const std::string& name); - - /// Destructor - ~L1CAIteration() noexcept = default; - - /// Copy assignment operator - L1CAIteration& operator=(const L1CAIteration& other) = default; - - /// Move assignment operator - L1CAIteration& operator=(L1CAIteration&& other) = default; - - /// Checks parameters consistency - bool Check() const; - - /// @brief Gets doublet chi2 upper cut - float GetDoubletChi2Cut() const { return fDoubletChi2Cut; } - - /// @brief flag check: electrons/positrons - true, heavy charged - false - bool GetElectronFlag() const { return fIsElectron; } - - /// @brief Sets flag: true - extends track candidates with unused hits - bool GetExtendTracksFlag() const { return fIsExtendTracks; } - - /// @brief Gets station index of the first station used in tracking - int GetFirstStationIndex() const { return fFirstStationIndex; } - - /// @brief Gets flag: true - triplets are built skipping one station - bool GetJumpedFlag() const { return fIsJumped; } - - /// @brief Gets correction for accounting overlaping and iff z - float GetMaxDZ() const { return fMaxDZ; } - - /// @brief Gets max considered q/p for tracks - float GetMaxQp() const { return fMaxQp; } - - /// @brief Gets max slope (tx\ty) in 3D hit position of a triplet - float GetMaxSlope() const { return fMaxSlope; } - - /// @brief Gets max slope (tx\ty) in primary vertex - float GetMaxSlopePV() const { return fMaxSlopePV; } - - /// @brief Gets min n hits - int GetMinNhits() const { return fMinNhits; } - - /// @brief Gets min n hits for tracks that start on station 0 - int GetMinNhitsStation0() const { return fMinNhitsStation0; } - - /// @brief Gets the name of the iteration - const std::string& GetName() const { return fName; } - - /// @brief Gets size of region [TODO: units??] to attach new hits to the created track - float GetPickGather() const { return fPickGather; } - - /// @brief Checks flag: true - only primary tracks are searched, false - [all or only secondary?] - bool GetPrimaryFlag() const { return fIsPrimary; } - - /// @brief Gets sigma target position in X direction [cm] - float GetTargetPosSigmaX() const { return fTargetPosSigmaX; } - - /// @brief Gets sigma target position in Y direction [cm] - float GetTargetPosSigmaY() const { return fTargetPosSigmaY; } - - /// @brief Gets track chi2 upper cut - float GetTrackChi2Cut() const { return fTrackChi2Cut; } - - /// (DEBUG!) Sets flag: - /// true: - /// all the triplets found on this iteration will be converted to tracks, - /// all the iterations following after this one will be rejected from the - /// iterations sequence; - /// false (default): - /// tracks are built from triplets, and the minimal amount of hits used in - /// each track equals four. In case of primary tracks the first measurement - /// is taken from the target, and the other three measurements are taken from - /// the triplet. - bool GetTrackFromTripletsFlag() const { return fIsTrackFromTriplets; } - - /// @brief Gets triplet chi2 upper cut - float GetTripletChi2Cut() const { return fTripletChi2Cut; } - - /// @brief Gets triplet chi2 upper cut - float GetTripletFinalChi2Cut() const { return fTripletFinalChi2Cut; } - - /// @brief Gets min value of dp/dp_error, for which two tiplets are neighbours - float GetTripletLinkChi2() const { return fTripletLinkChi2; } - - /// @brief Prints iteration options - void Print(int verbosityLevel = 0) const; - - /// @brief Sets doublet chi2 upper cut - void SetDoubletChi2Cut(float input) { fDoubletChi2Cut = input; } - - /// @brief Sets flag: electron tracks - true, heavy ion tracks - false - void SetElectronFlag(bool flag) { fIsElectron = flag; } - - /// @brief Sets flag: true - extends track candidates with unused hits - void SetExtendTracksFlag(bool flag) { fIsExtendTracks = flag; } - - /// @brief Sets index of first station used in tracking - void SetFirstStationIndex(int index) { fFirstStationIndex = index; } - - /// @brief Sets flag: true - triplets are built from hits .... TODO - void SetJumpedFlag(bool flag) { fIsJumped = flag; } - - /// @brief Sets correction for accounting overlaping and iff z - void SetMaxDZ(float input) { fMaxDZ = input; } - - /// @brief Sets max considered q/p for tracks - void SetMaxQp(float input) { fMaxQp = input; } - - /// @brief Sets max slope (tx\ty) in 3D hit position of a triplet - void SetMaxSlope(float input) { fMaxSlope = input; } - - /// @brief Sets max slope (tx\ty) in primary vertex - void SetMaxSlopePV(float input) { fMaxSlopePV = input; } - - /// @brief Sets flag: true - skip track candidates with level = 0 - void SetMinNhits(int val) { fMinNhits = val; } - - /// @brief Sets min n hits for tracks that start on station 0 - void SetMinNhitsStation0(int val) { fMinNhitsStation0 = val; } - - /// @brief Sets name of the iteration - void SetName(const std::string& name) { fName = name; } - - /// @brief Sets size of region [TODO: units??] to attach new hits to the created track - void SetPickGather(float input) { fPickGather = input; } - - /// @brief Sets flag: primary tracks - true, secondary tracks - false - void SetPrimaryFlag(bool flag) { fIsPrimary = flag; } - - /// @brief Sets sigma of target positions in XY plane - /// @param sigmaX Sigma value in X direction [cm] - /// @param sigmaX Sigma value in Y direction [cm] - void SetTargetPosSigmaXY(float sigmaX, float sigmaY); - - /// Sets track chi2 upper cut - void SetTrackChi2Cut(float input) { fTrackChi2Cut = input; } - - /// (DEBUG!) Sets flag: - /// true: - /// all the triplets found on this iteration will be converted to tracks, - /// all the iterations following after this one will be rejected from the - /// iterations sequence; - /// false (default): - /// tracks are built from triplets, and the minimal amount of hits used in - /// each track equals four. In case of primary tracks the first measurement - /// is taken from the target, and the other three measurements are taken from - /// the triplet. - void SetTrackFromTripletsFlag(bool flag) { fIsTrackFromTriplets = flag; } - - /// Sets triplet chi2 upper cut - void SetTripletChi2Cut(float input) { fTripletChi2Cut = input; } - - /// Sets triplet chi2 upper cut - void SetTripletFinalChi2Cut(float input) { fTripletFinalChi2Cut = input; } - - /// @brief Sets min value of dp/dp_error, for which two tiplets are neighbours - void SetTripletLinkChi2(float input) { fTripletLinkChi2 = input; } - - /// @brief String representation of the class contents - /// @param indentLevel Level of indentation for the text (in terms of \t symbols) - std::string ToString(int indentLevel = 0) const; - - /// @brief Formes a strings, representing a table of iterations from the vector of iterations - /// @param vIterations Vector of iterations - /// @return Iterations table represented with a string - template<typename T> - static std::string ToTableFromVector(const T& vIterations); - -private: - /** Basic fields **/ - std::string fName {""}; ///< Iteration name - - /** Track finder dependent cuts **/ - // TODO: Iteratively change the literals to floats (S.Zharko) - // NOTE: For each new cut one should not forget to create a setter and a getter, insert the value - // initialization in the copy constructor and the Swap operator as well as a string repre- - // sentation to the ToString method (S.Zharko) - float fTrackChi2Cut = 10.f; ///< Track chi2 upper cut - float fTripletChi2Cut = 21.1075f; ///< Triplet chi2 upper cut - float fTripletFinalChi2Cut = 21.1075f; ///< Triplet chi2 upper cut - float fDoubletChi2Cut = 11.3449 * 2.f / 3.f; ///< Doublet chi2 upper cut - float fPickGather = 3.0; ///< Size of region to attach new hits to the created track - float fTripletLinkChi2 = 25.0; ///< Min value of dp^2/dp_error^2, for which two tiplets are neighbours - float fMaxQp = 1.0 / 0.5; ///< Max considered q/p for tracks - float fMaxSlopePV = 1.1; ///< Max slope (tx\ty) in primary vertex - float fMaxSlope = 2.748; ///< Max slope (tx\ty) in 3D hit position of a triplet - float fMaxDZ = 0.f; ///< Correction for accounting overlaping and iff z [cm] - float fTargetPosSigmaX = 0; ///< Constraint on target position in X direction [cm] - float fTargetPosSigmaY = 0; ///< Constraint on target position in Y direction [cm] - int fFirstStationIndex = 0; ///< First station, used for tracking - int fMinNhits = 3; ///< min n hits on the tracks - int fMinNhitsStation0 = 3; ///< min n hits for tracks that start on station 0 - bool fIsPrimary = false; ///< Flag: true - only primary tracks are searched for - bool fIsElectron = false; ///< Flag: true - only electrons are searched for - bool fIsExtendTracks = false; ///< Flag: true - extends track candidates with unused hits - bool fIsJumped = false; ///< Flag: true - find triplets with skip station - - - /// @brief Flag to select triplets on the iteration as tracks - /// In ordinary cases, the shortest track consists from four hits. For primary track the target is accounted as - /// the first hit, and the other three hits are taken from the stations. For secondary track all the hits are selected - /// from the stations only. - /// If the fIsTrackFromTriplets flag is turned on, all of the triplets found on this iterations will be considered - /// as tracks. - /// - /// @note The only one iteration with the fIsTrackFromTriplets flag turned on can exist in the tracking iterations - /// sequence and this iteration should be the last in the tracking sequence. - bool fIsTrackFromTriplets = false; - - /// Serialization method, used to save ca::Hit objects into binary or text file in a defined order - friend class boost::serialization::access; - template<class Archive> - void serialize(Archive& ar, const unsigned int /*version*/) - { - ar& fName; - ar& fTrackChi2Cut; - ar& fTripletChi2Cut; - ar& fTripletFinalChi2Cut; - ar& fDoubletChi2Cut; - ar& fPickGather; - ar& fTripletLinkChi2; - ar& fMaxQp; - ar& fMaxSlopePV; - ar& fMaxSlope; - ar& fMaxDZ; - ar& fTargetPosSigmaX; - ar& fTargetPosSigmaY; - ar& fFirstStationIndex; - ar& fMinNhits; - ar& fMinNhitsStation0; - ar& fIsPrimary; - ar& fIsElectron; - ar& fIsExtendTracks; - ar& fIsJumped; - ar& fIsTrackFromTriplets; - } - - /// @brief Checks, if a particular value lies within selected limits. In case of fail throws std::logic_error - /// @param name Name of parameters - /// @param value Value of parameter - /// @param lLimit Lower limit of parameter - /// @param uLimit Upper limit of parameter - template<typename T> - static bool CheckValueLimits(const std::string& name, T value, T lLimit, T uLimit); -}; - -// --------------------------------------------------------------------------------------------------------------------- -// -template<typename T> -std::string L1CAIteration::ToTableFromVector(const T& vIterations) -{ - std::stringstream msg; - msg << std::boolalpha; - - auto PutRow = [&](const std::string& name, std::function<void(const L1CAIteration&)> fn) { - msg << std::setw(40) << std::setfill(' ') << name << ' '; - for (const auto& iter : vIterations) { - msg << std::setw(12) << std::setfill(' '); - fn(iter); - msg << ' '; - } - msg << '\n'; - }; - - PutRow(" ", [&](const L1CAIteration& i) { msg << i.GetName(); }); - PutRow("Is primary ", [&](const L1CAIteration& i) { msg << i.GetPrimaryFlag(); }); - PutRow("Is electron ", [&](const L1CAIteration& i) { msg << i.GetElectronFlag(); }); - PutRow("If tracks created from triplets ", [&](const L1CAIteration& i) { msg << i.GetTrackFromTripletsFlag(); }); - PutRow("If tracks extended with unused hits", [&](const L1CAIteration& i) { msg << i.GetExtendTracksFlag(); }); - PutRow("If triplets jump over one station ", [&](const L1CAIteration& i) { msg << i.GetJumpedFlag(); }); - PutRow("Min number of hits ", [&](const L1CAIteration& i) { msg << i.GetMinNhits(); }); - PutRow("Min number of hits on station 0 ", [&](const L1CAIteration& i) { msg << i.GetMinNhitsStation0(); }); - PutRow("Track chi2 cut ", [&](const L1CAIteration& i) { msg << i.GetTrackChi2Cut(); }); - PutRow("Triplet chi2 cut ", [&](const L1CAIteration& i) { msg << i.GetTripletChi2Cut(); }); - PutRow("Triplet final chi2 cut ", [&](const L1CAIteration& i) { msg << i.GetTripletFinalChi2Cut(); }); - PutRow("Doublet chi2 cut ", [&](const L1CAIteration& i) { msg << i.GetDoubletChi2Cut(); }); - PutRow("Pick gather ", [&](const L1CAIteration& i) { msg << i.GetPickGather(); }); - PutRow("Triplet link chi2 ", [&](const L1CAIteration& i) { msg << i.GetTripletLinkChi2(); }); - PutRow("Max q/p ", [&](const L1CAIteration& i) { msg << i.GetMaxQp(); }); - PutRow("Max slope ", [&](const L1CAIteration& i) { msg << i.GetMaxSlope(); }); - PutRow("Max slope at primary vertex ", [&](const L1CAIteration& i) { msg << i.GetMaxSlopePV(); }); - PutRow("Max DZ ", [&](const L1CAIteration& i) { msg << i.GetMaxDZ(); }); - PutRow("Target position sigma X [cm] ", [&](const L1CAIteration& i) { msg << i.GetTargetPosSigmaX(); }); - PutRow("Target position sigma Y [cm] ", [&](const L1CAIteration& i) { msg << i.GetTargetPosSigmaY(); }); - PutRow("First tracking station index ", [&](const L1CAIteration& i) { msg << i.GetFirstStationIndex(); }); - - return msg.str(); -} - -// --------------------------------------------------------------------------------------------------------------------- -// TODO: SZh. 06.10.2022: Probably, this method should be replaced to L1Utils -template<typename T> -bool L1CAIteration::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 << ']'; - return false; - } - return true; -} - - -#endif // L1CAIteration_h diff --git a/reco/L1/L1Algo/L1ConfigRW.cxx b/reco/L1/L1Algo/L1ConfigRW.cxx index b4450b2dd516e0370a379aabe392c8c04f5164a0..4d9cee0c86968db199cfe49cf2b0f5a47c0f8584 100644 --- a/reco/L1/L1Algo/L1ConfigRW.cxx +++ b/reco/L1/L1Algo/L1ConfigRW.cxx @@ -122,12 +122,12 @@ void L1ConfigRW::Read() // --------------------------------------------------------------------------------------------------------------------- // -std::vector<L1CAIteration> L1ConfigRW::ReadCAIterationVector() +std::vector<Iteration> L1ConfigRW::ReadCAIterationVector() { - std::vector<L1CAIteration> res; + std::vector<Iteration> res; // Read iterations store - std::unordered_map<std::string, L1CAIteration> mPossibleIterations; + std::unordered_map<std::string, Iteration> mPossibleIterations; { auto currentNode = fMainConfigNode["possible_iterations"]; assert(currentNode); @@ -146,7 +146,7 @@ std::vector<L1CAIteration> L1ConfigRW::ReadCAIterationVector() mPossibleIterations[thisIterName] = ReadSingleCAIteration(iterNode, mPossibleIterations.at(baseIterName)); } else { - mPossibleIterations[thisIterName] = ReadSingleCAIteration(iterNode, L1CAIteration()); + mPossibleIterations[thisIterName] = ReadSingleCAIteration(iterNode, Iteration()); } } } @@ -181,7 +181,7 @@ std::vector<L1CAIteration> L1ConfigRW::ReadCAIterationVector() } else { if (fVerbose >= 2) { LOG(info) << "- Select D"; } - res.push_back(ReadSingleCAIteration(iterNode, L1CAIteration())); + res.push_back(ReadSingleCAIteration(iterNode, Iteration())); } } } @@ -299,9 +299,9 @@ std::vector<std::set<int>> L1ConfigRW::ReadInactiveStationMap() // --------------------------------------------------------------------------------------------------------------------- // -L1CAIteration L1ConfigRW::ReadSingleCAIteration(const YAML::Node& node, const L1CAIteration& defaultIter) const +Iteration L1ConfigRW::ReadSingleCAIteration(const YAML::Node& node, const Iteration& defaultIter) const { - auto iter = L1CAIteration(); + auto iter = Iteration(); try { iter.SetName(node["name"].as<std::string>()); iter.SetTrackChi2Cut(node["track_chi2_cut"].as<float>(defaultIter.GetTrackChi2Cut())); diff --git a/reco/L1/L1Algo/L1ConfigRW.h b/reco/L1/L1Algo/L1ConfigRW.h index d6f1096a756c84e368038a7449db5f28dab1f108..ff5313fbf6a140d2e111da726234d612eb77c5c3 100644 --- a/reco/L1/L1Algo/L1ConfigRW.h +++ b/reco/L1/L1Algo/L1ConfigRW.h @@ -16,7 +16,9 @@ #include <yaml-cpp/yaml.h> -#include "L1CAIteration.h" +#include "CaIteration.h" + +using namespace cbm::algo::ca; namespace YAML { @@ -40,7 +42,7 @@ public: /// @brief Reads CA track finder iterations from YAML node /// @return A vector of iterations - std::vector<L1CAIteration> ReadCAIterationVector(); + std::vector<Iteration> ReadCAIterationVector(); /// @brief Sets main config file /// @param path Path to the file @@ -75,7 +77,7 @@ private: /// @param node YAML node containing an iteration /// @param defaultIter Default iteration /// @return A CA-iteration object - L1CAIteration ReadSingleCAIteration(const YAML::Node& node, const L1CAIteration& defaultIter) const; + Iteration ReadSingleCAIteration(const YAML::Node& node, const Iteration& defaultIter) const; /// @brief Gets parameters content of the node /// @param node YAML node diff --git a/reco/L1/L1Algo/L1InitManager.cxx b/reco/L1/L1Algo/L1InitManager.cxx index 93ed5c670a5365b901b41eb8a039e8b2109ec14c..966a48b6ec04ac72083611fc57af869f3d58d6a5 100644 --- a/reco/L1/L1Algo/L1InitManager.cxx +++ b/reco/L1/L1Algo/L1InitManager.cxx @@ -278,7 +278,7 @@ void L1InitManager::InitTargetField(double zStep) // ---------------------------------------------------------------------------------------------------------------------- // -void L1InitManager::PushBackCAIteration(const L1CAIteration& iteration) +void L1InitManager::PushBackCAIteration(const Iteration& iteration) { // TODO: probably some checks must be inserted here (S.Zharko) bool control = fInitController.GetFlag(EInitKey::kCAIterationsNumberCrosscheck); diff --git a/reco/L1/L1Algo/L1InitManager.h b/reco/L1/L1Algo/L1InitManager.h index a95e175cf84699cbf7141897fb5ef964bc4114d8..42b99f940cd1020e10c2f87827dc558b96802444 100644 --- a/reco/L1/L1Algo/L1InitManager.h +++ b/reco/L1/L1Algo/L1InitManager.h @@ -190,13 +190,13 @@ public: void InitTargetField(double zStep); /// Pushes an CA track finder iteration into a sequence of iteration using reference - void PushBackCAIteration(const L1CAIteration& iteration); + void PushBackCAIteration(const Iteration& iteration); /// Pushes an CA track finder iteration into a sequence of iteration using raw pointer - void PushBackCAIteration(const L1CAIteration* pIteration) { PushBackCAIteration(*pIteration); } + 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<L1CAIteration>& puIteration) { PushBackCAIteration(*puIteration); } + void PushBackCAIteration(const std::unique_ptr<Iteration>& puIteration) { PushBackCAIteration(*puIteration); } /// @brief Reads main and user parameters configs void ReadInputConfigs(); diff --git a/reco/L1/L1Algo/L1Parameters.cxx b/reco/L1/L1Algo/L1Parameters.cxx index 793e0c05b5282bbd7e1c61b1cee1b6f1a872ae1f..1bb017024b044b7c81cb0c40b1406b72c28278b9 100644 --- a/reco/L1/L1Algo/L1Parameters.cxx +++ b/reco/L1/L1Algo/L1Parameters.cxx @@ -159,7 +159,7 @@ void L1Parameters::CheckConsistency() const } nIterations = std::count_if(fCAIterations.begin(), fCAIterations.end(), - [=](const L1CAIteration& it) { return it.GetTrackFromTripletsFlag(); }); + [=](const Iteration& it) { return it.GetTrackFromTripletsFlag(); }); if (nIterations > 1) { std::stringstream msg; msg << "L1Parameters: found " << nIterations << " iterations with GetTrackFromTripletsFlag() == true:\n"; @@ -231,7 +231,7 @@ std::string L1Parameters::ToString(int verbosity, int indentLevel) const msg << indent << indentCh << "Max number of triplets per doublet: " << fMaxTripletPerDoublets << '\n'; msg << indent << indentCh << "Ghost suppresion: " << fGhostSuppression << '\n'; msg << indent << clrs::CLb << "CA TRACK FINDER ITERATIONS:\n" << clrs::CL; - msg << L1CAIteration::ToTableFromVector(fCAIterations); + msg << Iteration::ToTableFromVector(fCAIterations); msg << indent << clrs::CLb << "GEOMETRY:\n" << clrs::CL; msg << indent << indentCh << clrs::CLb << "TARGET:\n" << clrs::CL; msg << indent << indentCh << indentCh << "Position:\n"; diff --git a/reco/L1/L1Algo/L1Parameters.h b/reco/L1/L1Algo/L1Parameters.h index 9fd1405b5f451fae5f496a1ae198b8706192617f..657539968aaa64b3f9df4ad798b3e3a4e88eacc5 100644 --- a/reco/L1/L1Algo/L1Parameters.h +++ b/reco/L1/L1Algo/L1Parameters.h @@ -23,7 +23,7 @@ #include "CaMaterialMap.h" #include "CaStation.h" #include "CaVector.h" -#include "L1CAIteration.h" +#include "CaIteration.h" #include "L1SearchWindow.h" #include "L1Utils.h" // IS DEPRECATED? @@ -34,7 +34,7 @@ class L1InitManager; enum class L1DetectorID; /// Type definitions for used containers -using L1IterationsContainer_t = cbm::algo::ca::Vector<L1CAIteration>; +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>; diff --git a/reco/L1/catools/CaToolsWindowFinder.cxx b/reco/L1/catools/CaToolsWindowFinder.cxx index f8a5d998f09d120c277b6c33a96b435855e5925f..1e2491ff2adaa5eb5a79f8a5dc55b81abd136e11 100644 --- a/reco/L1/catools/CaToolsWindowFinder.cxx +++ b/reco/L1/catools/CaToolsWindowFinder.cxx @@ -32,6 +32,8 @@ using namespace cbm::ca::tools; using namespace cbm::algo::ca::constants; // for colored logs +using cbm::algo::ca::Iteration; + ClassImp(cbm::ca::tools::WindowFinder); // --------------------------------------------------------------------------------------------------------------------- @@ -55,7 +57,7 @@ void WindowFinder::AddInputFile(const char* filename) // --------------------------------------------------------------------------------------------------------------------- // -L1SearchWindow WindowFinder::CreateSW(int iStation, const L1CAIteration& caIter) +L1SearchWindow WindowFinder::CreateSW(int iStation, const ca::Iteration& caIter) { // Get a cut @@ -185,7 +187,7 @@ const char* WindowFinder::GetDistExpr(EExpr expr) const // --------------------------------------------------------------------------------------------------------------------- // TODO: SZh 10.11.2022: Should it be a static function?? -TCut WindowFinder::GetTrackSelectionCut(int iStation, const L1CAIteration& caIter) const +TCut WindowFinder::GetTrackSelectionCut(int iStation, const ca::Iteration& caIter) const { TCut cut; @@ -208,7 +210,7 @@ TCut WindowFinder::GetTrackSelectionCut(int iStation, const L1CAIteration& caIte // --------------------------------------------------------------------------------------------------------------------- // -void WindowFinder::PrintCaseInformation(TPad* pPad, int iStation, const L1CAIteration& caIter) const +void WindowFinder::PrintCaseInformation(TPad* pPad, int iStation, const ca::Iteration& caIter) const { pPad->cd(); diff --git a/reco/L1/catools/CaToolsWindowFinder.h b/reco/L1/catools/CaToolsWindowFinder.h index aad528d84ab13bdc6e4f55afce62819b64bb9a4f..695098ce0469e703c13e22944d6d9968e09ee492 100644 --- a/reco/L1/catools/CaToolsWindowFinder.h +++ b/reco/L1/catools/CaToolsWindowFinder.h @@ -16,7 +16,7 @@ #include <array> #include <vector> -#include "L1CAIteration.h" +#include "CaIteration.h" // TODO: Replace tmp asserts with exceptions @@ -27,6 +27,8 @@ class TCanvas; namespace cbm::ca::tools { + namespace ca = cbm::algo::ca; + /// Enumeration to handle processed expressions enum EExpr { @@ -108,7 +110,7 @@ namespace cbm::ca::tools private: /// Creates a search window for a selected station and iteration - L1SearchWindow CreateSW(int iStation, const L1CAIteration& caIter); + L1SearchWindow 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; @@ -116,13 +118,13 @@ namespace cbm::ca::tools /// Gets a cut for doublets/triplets defined by station and a tracking iteration /// \param iStation Global index of an active station /// \param caIter CA track finder iteration object - TCut GetTrackSelectionCut(int iStation, const L1CAIteration& caIter) const; + TCut GetTrackSelectionCut(int iStation, const ca::Iteration& caIter) const; /// Prints information on the dx and dy expression as well as used cuts on the pad /// \param pPad A pad to print the information /// \param iStation Global index of an active station /// \param caIter CA track finder iteration object - void PrintCaseInformation(TPad* pPad, int iStation, const L1CAIteration& caIter) const; + void PrintCaseInformation(TPad* pPad, int iStation, const ca::Iteration& caIter) const; // ********************* @@ -133,7 +135,7 @@ namespace cbm::ca::tools std::string fsOutputName = "SearchWindows.dat"; ///< Name for output file with estimated search windows // ----- Input parameters (iterations and stations) - std::vector<L1CAIteration> fvCaIters = {}; ///< Tracking iterations + std::vector<ca::Iteration> fvCaIters = {}; ///< Tracking iterations std::vector<int> fvStationIndexes = {}; ///< Global indexes of active stations to find the windows std::array<double, 3> fTargetPos = {0}; ///< Target position {x, y, z} [cm] diff --git a/reco/L1/qa/CbmCaInputQaSetup.cxx b/reco/L1/qa/CbmCaInputQaSetup.cxx index 2fb7f88ad992dae29d0c1d955cf7144ae0241dc6..250b8055ff178194290698afff374236e3a99cc6 100644 --- a/reco/L1/qa/CbmCaInputQaSetup.cxx +++ b/reco/L1/qa/CbmCaInputQaSetup.cxx @@ -16,6 +16,7 @@ #include "TAxis.h" #include "L1InitManager.h" +#include "AlgoFairloggerCompat.h" using cbm::ca::InputQaSetup; @@ -200,8 +201,8 @@ try { LOG(error) << fName << ": initializing... \033[1;32mDone\033[0m"; return kSUCCESS; } -catch (const std::logic_error& error) { - LOG(error) << fName << ": initializing... \033[1;31mFailed\033[0m\nReason: " << error.what(); +catch (const std::logic_error& e) { + LOG(error) << fName << ": initializing... \033[1;31mFailed\033[0m\nReason: " << e.what(); return kFATAL; }