Skip to content
Snippets Groups Projects
Commit 4b8674f9 authored by Sergey Gorbunov's avatar Sergey Gorbunov
Browse files

Ca: cleanup of algo/ca

parent 7b673dd0
No related branches found
Tags dev_2023_40
1 merge request!1348Ca: cleanup of algo/ca
Pipeline #24305 passed
Showing
with 294 additions and 282 deletions
......@@ -2,4 +2,9 @@
SPDX-License-Identifier: GPL-3.0-only
Authors: Sergei Zharko [committer] */
/// \file CaTrack.h
/// \brief source file for the ca::Track class
/// \since 02.06.2022
/// \author S.Zharko <s.zharko@gsi.de>
#include "CaTrack.h"
......@@ -2,66 +2,52 @@
SPDX-License-Identifier: GPL-3.0-only
Authors: Ivan Kisel, Sergey Gorbunov, Maksym Zyzak, Igor Kulakov [committer], Sergei Zharko */
/*
*====================================================================
*
* CBM Level 1 Reconstruction
*
* Authors: I.Kisel, S.Gorbunov
*
* e-mail : ikisel@kip.uni-heidelberg.de
*
*====================================================================
*
* L1 track class
*
*====================================================================
*/
/// \file CaTrack.h
/// \brief header file for the ca::Track class
/// \since 02.06.2022
/// \author S.Zharko <s.zharko@gsi.de>
#ifndef CBM_ALGO_CA_TRACK
#define CBM_ALGO_CA_TRACK 1
#include <boost/serialization/access.hpp>
#include <limits>
#include "CaConstants.h"
#include "CaSimd.h"
namespace cbm::algo::ca
{
/// @class cbm::algo::ca::Track
/// @brief Class representing a track in the L1 tracking algorithm
/// @brief Class representing an output track in the CA tracking algorithm
///
/// Track parameters vector: {x, y, tx, ty, q/p, z, t}
/// Track parameters vector: {x, y, tx, ty, q/p, z, t, vi}
/// Covariation matrix: C[20] (C55) corresponds to the time variance
///
class Track {
public:
static constexpr float kNaN {std::numeric_limits<float>::signaling_NaN()};
static constexpr int kNparTr {8};
static constexpr int kNparCov {28};
friend class boost::serialization::access;
// TODO: SZh. 14.09.2023: Replace with std::array
unsigned char fNofHits {0}; ///< Number of hits in track
fscal fParFirst[kNparTr] {kNaN}; ///< Track parameters on the first station
fscal fCovFirst[kNparCov] {kNaN}; ///< Track parameter covariation matrix elements on the first station
fscal fParLast[kNparTr] {kNaN}; ///< Track parameters on the last station
fscal fCovLast[kNparCov] {kNaN}; ///< Track parameter covariation matrix elements on the second station
fscal fParPV[kNparTr] {kNaN}; ///< Track parameters in the primary vertex
fscal fCovPV[kNparCov] {kNaN}; ///< Track parameter covariation matrix elements in the primary vertex
fscal fChi2 {kNaN}; ///< Track fit chi-square value
short int fNDF {0}; ///< Track fit NDF value
Track()
{
fParFirst.fill(constants::undef::Fscal);
fParLast.fill(constants::undef::Fscal);
fParPV.fill(constants::undef::Fscal);
fCovFirst.fill(constants::undef::Fscal);
fCovLast.fill(constants::undef::Fscal);
fCovPV.fill(constants::undef::Fscal);
}
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int /*version*/)
{
ar& fNofHits;
for (int i = 0; i < kNparTr; ++i) {
for (int i = 0; i < NparTr; ++i) {
ar& fParFirst[i];
ar& fParLast[i];
ar& fParPV[i];
}
for (int i = 0; i < kNparCov; ++i) {
for (int i = 0; i < NparCov; ++i) {
ar& fCovFirst[i];
ar& fCovLast[i];
ar& fCovPV[i];
......@@ -69,6 +55,21 @@ namespace cbm::algo::ca
ar& fChi2;
ar& fNDF;
}
public:
static constexpr int NparTr {8};
static constexpr int NparCov {28};
int fNofHits {constants::undef::Int}; ///< Number of hits in track
std::array<fscal, NparTr> fParFirst; ///< Track parameters on the first station
std::array<fscal, NparCov> fCovFirst; ///< Track parameter covariation matrix elements on the first station
std::array<fscal, NparTr> fParLast; ///< Track parameters on the last station
std::array<fscal, NparCov> fCovLast; ///< Track parameter covariation matrix elements on the second station
std::array<fscal, NparTr> fParPV; ///< Track parameters in the primary vertex
std::array<fscal, NparCov> fCovPV; ///< Track parameter covariation matrix elements in the primary vertex
fscal fChi2 {constants::undef::Fscal}; ///< Track fit chi-square value
int fNDF {constants::undef::Int}; ///< Track fit NDF value
};
} // namespace cbm::algo::ca
......
......@@ -2,48 +2,46 @@
SPDX-License-Identifier: GPL-3.0-only
Authors: Sergey Gorbunov, Sergei Zharko [committer] */
/************************************************************************************************************
* @file L1Constants.h
* @brief Compile-time constants definition for the L1 tracking algorithm
* @since 02.06.2022
* @author S.Zharko <s.zharko@gsi.de>
***********************************************************************************************************/
/// \file CaConstants.h
/// \brief Compile-time constants definition for the CA tracking algorithm
/// \since 02.06.2022
/// \author S.Zharko <s.zharko@gsi.de>
#ifndef CA_CORE_CONSTANTS
#define CA_CORE_CONSTANTS 1
#include <limits>
#include "CaSimd.h"
using cbm::algo::ca::fmask;
using cbm::algo::ca::fscal; // TODO: remove "using" from headers
using cbm::algo::ca::fvec; // TODO: remove "using" from headers
/// Namespace contains compile-time constants definition for the L1 tracking algorithm
/// Namespace contains compile-time constants definition for the CA tracking algorithm
///
namespace cbm::algo::ca::constants
{
using cbm::algo::ca::fvec;
/// Array sizes
namespace size
{
/// Amount of coefficients in field approximations
constexpr int kMaxNFieldApproxCoefficients {21}; // TODO: May be it is better to use the polynomial
// order instead of this?
/// Order of polynomial to approximate field in the vicinity of station plane
constexpr int kMaxFieldApproxPolynomialOrder {5};
constexpr int MaxFieldApproxPolynomialOrder {5};
/// Amount of bits to code a station, thread or triplet. This values determine the ma
constexpr unsigned int kStationBits = 6u; ///< Amount of bits to code one station
constexpr unsigned int kTripletBits = 32u - kStationBits; ///< Amount of bits to code one triplet
/// Amount of coefficients in field approximations
constexpr int MaxNFieldApproxCoefficients {(MaxFieldApproxPolynomialOrder + 1) * (MaxFieldApproxPolynomialOrder + 2)
/ 2};
constexpr int kMaxNdetectors = 5; ///< Max number of tracking detectors
constexpr int kMaxNstations = 1u << kStationBits; ///< Max number of stations, 2^6 = 64
constexpr int kMaxNtriplets = 1u << kTripletBits; ///< Max number of triplets, 2^26 = 67,108,864
/// Amount of bits to code a station or triplet. This values determine the maximum number of stations and tripülets
constexpr unsigned int StationBits = 6u; ///< Amount of bits to code one station
constexpr unsigned int TripletBits = 32u - StationBits; ///< Amount of bits to code one triplet
constexpr uint8_t kDetBits = 4u; // Max 16 detectors
constexpr int MaxNdetectors = 5; ///< Max number of tracking detectors
constexpr int MaxNstations = 1u << StationBits; ///< Max number of stations, 2^6 = 64
constexpr int MaxNtriplets = 1u << TripletBits; ///< Max number of triplets, 2^26 = 67,108,864
constexpr uint8_t DetBits = 4u; ///< Maximum 16 detector systems
/// Max number of track groups
/// NOTE: For a "track group" definition see L1Parameters.h, GetSearchWindow function
constexpr int kMaxNtrackGroups = 4;
/// NOTE: For a "track group" definition see CaParameters.h, GetSearchWindow function
constexpr int MaxNtrackGroups = 4;
} // namespace size
......@@ -51,149 +49,172 @@ namespace cbm::algo::ca::constants
/// Control flags
namespace control
{
/// Flag for calling the CAMergeClones procedure ... TODO
constexpr bool kIfMergeClones {true};
/// Flag: input data QA level
/// \brief Flag: input data QA level
/// - 0: no checks will be done
/// - 1: only number of hits and strips as well as validity of hits first and last indexes will be checked
/// - 2: hits sorting is checked
/// - 3: every hit is checked for consistency
/// \note The larger Level corresponds to more precise checks, but is followed by larger time penalty
constexpr int kInputDataQaLevel = 0; // WARNING: other options does not work properly, more tests are needed!
/// \warning other options than 0 do not work properly, more tests are needed!
constexpr int InputDataQaLevel = 0;
} // namespace control
// Physics constants
/// Physics constants
namespace phys
{
/* Particle masses used for track fit */
constexpr float kMuonMass = 0.10565800f; ///< Muon mass [GeV/c2] !! TODO: discrepancy in last two digits
constexpr float kPionMass = 0.13957039f; ///< Pion mass [GeV/c2]
constexpr float kKaonMass = 0.493677f; ///< Kaon mass [GeV/c2] (PDG 22.08.2023)
constexpr float kElectronMass = 0.000511f; ///< Electron mass [GeV/c2]
constexpr float kProtonMass = 0.93827209f; ///< Proton mass [GeV/c2] (0.93827208816 - PDG 11.08.2022)
constexpr double kSpeedOfLight = 29.9792458; ///< Speed of light [cm/ns]
constexpr float kSpeedOfLightF = 29.9792; ///< Speed of light [cm/ns] (single precision)
constexpr double kSpeedOfLightInv = 1 / kSpeedOfLight; ///< Inverse speed of light [cm/ns]
constexpr float kSpeedOfLightInvF = 1 / kSpeedOfLightF; ///< Inverse speed of light [cm/ns] (single precision)
} // namespace phys
// Math constants
/// Particle masses used for track fit
constexpr float MuonMass = 0.10565800f; ///< Muon mass [GeV/c2] !! TODO: discrepancy in last two digits
constexpr float PionMass = 0.13957039f; ///< Pion mass [GeV/c2]
constexpr float KaonMass = 0.493677f; ///< Kaon mass [GeV/c2] (PDG 22.08.2023)
constexpr float ElectronMass = 0.000511f; ///< Electron mass [GeV/c2]
constexpr float ProtonMass = 0.93827209f; ///< Proton mass [GeV/c2] (0.93827208816 - PDG 11.08.2022)
constexpr double SpeedOfLight = 29.9792458; ///< Speed of light [cm/ns]
constexpr float SpeedOfLightF = 29.9792; ///< Speed of light [cm/ns] (single precision)
constexpr double SpeedOfLightInv = 1 / SpeedOfLight; ///< Inverse speed of light [cm/ns]
constexpr float SpeedOfLightInvF = 1 / SpeedOfLightF; ///< Inverse speed of light [cm/ns] (single precision)
} // namespace phys
/// Math constants
namespace math
{
constexpr double kPi = 3.14159265358979323846; ///< Value of PI, used in ROOT TMath
}
constexpr double Pi = 3.14159265358979323846; ///< Value of PI, used in ROOT TMath
} // namespace math
// Miscellaneous constants
/// Miscellaneous constants
namespace misc
{
constexpr int kAssertionLevel = 0; ///< Assertion level
constexpr int kAlignment = 16; ///< Default alignment of data (bytes)
} // namespace misc
constexpr int AssertionLevel = 0; ///< Assertion level
constexpr int Alignment = 16; ///< Default alignment of data (bytes)
} // namespace misc
// Colors of terminal log
/// Undefined values for different types
namespace undef
{
constexpr int Int = std::numeric_limits<int>::min();
constexpr unsigned Uint = std::numeric_limits<unsigned>::max();
constexpr float Float = std::numeric_limits<float>::signaling_NaN();
constexpr double Double = std::numeric_limits<double>::signaling_NaN();
constexpr fscal Fscal = std::numeric_limits<fscal>::signaling_NaN();
/// Checks whether a variable of a particular type defined
template<typename T>
bool IsUndefined(T val)
{
if constexpr (std::is_same_v<T, int>) { return val == undef::Int; }
if constexpr (std::is_same_v<T, unsigned>) { return val == undef::Uint; }
if constexpr (std::is_same_v<T, float>) { return std::isnan(val); }
if constexpr (std::is_same_v<T, double>) { return std::isnan(val); }
if constexpr (std::is_same_v<T, fscal>) { return std::isnan(val); }
if constexpr (std::is_same_v<T, fvec>) { return isnan(val).isNotEmpty(); }
return true;
}
} // namespace undef
// Colors of terminal log
namespace clrs
{
// NOTE: To be used first, because different users may have different console bg and fg colors
constexpr char kCL[] = "\e[0m"; ///< clear
constexpr char kCLb[] = "\e[1m"; ///< clear bold
constexpr char kCLi[] = "\e[3m"; ///< clear italic
constexpr char kCLu[] = "\e[4m"; ///< clear underline
constexpr char kCLr[] = "\e[7m"; ///< clear reverse
constexpr char kCLbi[] = "\e[1;3m"; ///< clear bold-italic
constexpr char kCLbu[] = "\e[1;4m"; ///< clear bold-underline
constexpr char kCLbr[] = "\e[1;7m"; ///< clear bold-reverse
constexpr char CL[] = "\e[0m"; ///< clear
constexpr char CLb[] = "\e[1m"; ///< clear bold
constexpr char CLi[] = "\e[3m"; ///< clear italic
constexpr char CLu[] = "\e[4m"; ///< clear underline
constexpr char CLr[] = "\e[7m"; ///< clear reverse
constexpr char CLbi[] = "\e[1;3m"; ///< clear bold-italic
constexpr char CLbu[] = "\e[1;4m"; ///< clear bold-underline
constexpr char CLbr[] = "\e[1;7m"; ///< clear bold-reverse
// regular
constexpr char kBK[] = "\e[30m"; ///< normal black
constexpr char kRD[] = "\e[31m"; ///< normal red
constexpr char kGN[] = "\e[32m"; ///< normal green
constexpr char kYL[] = "\e[33m"; ///< normal yellow
constexpr char kBL[] = "\e[34m"; ///< normal blue
constexpr char kMG[] = "\e[35m"; ///< normal magenta
constexpr char kCY[] = "\e[36m"; ///< normal cyan
constexpr char kGY[] = "\e[37m"; ///< normal grey
constexpr char kWT[] = "\e[38m"; ///< normal white
constexpr char BK[] = "\e[30m"; ///< normal black
constexpr char RD[] = "\e[31m"; ///< normal red
constexpr char GN[] = "\e[32m"; ///< normal green
constexpr char YL[] = "\e[33m"; ///< normal yellow
constexpr char BL[] = "\e[34m"; ///< normal blue
constexpr char MG[] = "\e[35m"; ///< normal magenta
constexpr char CY[] = "\e[36m"; ///< normal cyan
constexpr char GY[] = "\e[37m"; ///< normal grey
constexpr char WT[] = "\e[38m"; ///< normal white
// bold
constexpr char kBKb[] = "\e[1;30m"; ///< bold black
constexpr char kRDb[] = "\e[1;31m"; ///< bold red
constexpr char kGNb[] = "\e[1;32m"; ///< bold green
constexpr char kYLb[] = "\e[1;33m"; ///< bold yellow
constexpr char kBLb[] = "\e[1;34m"; ///< bold blue
constexpr char kMGb[] = "\e[1;35m"; ///< bold magenta
constexpr char kCYb[] = "\e[1;36m"; ///< bold cyan
constexpr char kGYb[] = "\e[1;37m"; ///< bold grey
constexpr char kWTb[] = "\e[1;38m"; ///< bold white
constexpr char BKb[] = "\e[1;30m"; ///< bold black
constexpr char RDb[] = "\e[1;31m"; ///< bold red
constexpr char GNb[] = "\e[1;32m"; ///< bold green
constexpr char YLb[] = "\e[1;33m"; ///< bold yellow
constexpr char BLb[] = "\e[1;34m"; ///< bold blue
constexpr char MGb[] = "\e[1;35m"; ///< bold magenta
constexpr char CYb[] = "\e[1;36m"; ///< bold cyan
constexpr char GYb[] = "\e[1;37m"; ///< bold grey
constexpr char WTb[] = "\e[1;38m"; ///< bold white
// italic
constexpr char kBKi[] = "\e[3;30m"; ///< italic black
constexpr char kRDi[] = "\e[3;31m"; ///< italic red
constexpr char kGNi[] = "\e[3;32m"; ///< italic green
constexpr char kYLi[] = "\e[3;33m"; ///< italic yellow
constexpr char kBLi[] = "\e[3;34m"; ///< italic blue
constexpr char kMGi[] = "\e[3;35m"; ///< italic magenta
constexpr char kCYi[] = "\e[3;36m"; ///< italic cyan
constexpr char kGYi[] = "\e[3;37m"; ///< italic grey
constexpr char kWTi[] = "\e[3;38m"; ///< italic white
constexpr char BKi[] = "\e[3;30m"; ///< italic black
constexpr char RDi[] = "\e[3;31m"; ///< italic red
constexpr char GNi[] = "\e[3;32m"; ///< italic green
constexpr char YLi[] = "\e[3;33m"; ///< italic yellow
constexpr char BLi[] = "\e[3;34m"; ///< italic blue
constexpr char MGi[] = "\e[3;35m"; ///< italic magenta
constexpr char CYi[] = "\e[3;36m"; ///< italic cyan
constexpr char GYi[] = "\e[3;37m"; ///< italic grey
constexpr char WTi[] = "\e[3;38m"; ///< italic white
// underline
constexpr char kBKu[] = "\e[4;30m"; ///< underline black
constexpr char kRDu[] = "\e[4;31m"; ///< underline red
constexpr char kGNu[] = "\e[4;32m"; ///< underline green
constexpr char kYLu[] = "\e[4;33m"; ///< underline yellow
constexpr char kBLu[] = "\e[4;34m"; ///< underline blue
constexpr char kMGu[] = "\e[4;35m"; ///< underline magenta
constexpr char kCYu[] = "\e[4;36m"; ///< underline cyan
constexpr char kGYu[] = "\e[4;37m"; ///< underline grey
constexpr char kWTu[] = "\e[4;38m"; ///< underline white
constexpr char BKu[] = "\e[4;30m"; ///< underline black
constexpr char RDu[] = "\e[4;31m"; ///< underline red
constexpr char GNu[] = "\e[4;32m"; ///< underline green
constexpr char YLu[] = "\e[4;33m"; ///< underline yellow
constexpr char BLu[] = "\e[4;34m"; ///< underline blue
constexpr char MGu[] = "\e[4;35m"; ///< underline magenta
constexpr char CYu[] = "\e[4;36m"; ///< underline cyan
constexpr char GYu[] = "\e[4;37m"; ///< underline grey
constexpr char WTu[] = "\e[4;38m"; ///< underline white
// reverse
constexpr char kBKr[] = "\e[7;30m"; ///< reverse black
constexpr char kRDr[] = "\e[7;31m"; ///< reverse red
constexpr char kGNr[] = "\e[7;32m"; ///< reverse green
constexpr char kYLr[] = "\e[7;33m"; ///< reverse yellow
constexpr char kBLr[] = "\e[7;34m"; ///< reverse blue
constexpr char kMGr[] = "\e[7;35m"; ///< reverse magenta
constexpr char kCYr[] = "\e[7;36m"; ///< reverse cyan
constexpr char kGYr[] = "\e[7;37m"; ///< reverse grey
constexpr char kWTr[] = "\e[7;38m"; ///< reverse white
constexpr char BKr[] = "\e[7;30m"; ///< reverse black
constexpr char RDr[] = "\e[7;31m"; ///< reverse red
constexpr char GNr[] = "\e[7;32m"; ///< reverse green
constexpr char YLr[] = "\e[7;33m"; ///< reverse yellow
constexpr char BLr[] = "\e[7;34m"; ///< reverse blue
constexpr char MGr[] = "\e[7;35m"; ///< reverse magenta
constexpr char CYr[] = "\e[7;36m"; ///< reverse cyan
constexpr char GYr[] = "\e[7;37m"; ///< reverse grey
constexpr char WTr[] = "\e[7;38m"; ///< reverse white
// bold-underline
constexpr char kBKbu[] = "\e[1;4;30m"; ///< bold-underline black
constexpr char kRDbu[] = "\e[1;4;31m"; ///< bold-underline red
constexpr char kGNbu[] = "\e[1;4;32m"; ///< bold-underline green
constexpr char kYLbu[] = "\e[1;4;33m"; ///< bold-underline yellow
constexpr char kBLbu[] = "\e[1;4;34m"; ///< bold-underline blue
constexpr char kMGbu[] = "\e[1;4;35m"; ///< bold-underline magenta
constexpr char kCYbu[] = "\e[1;4;36m"; ///< bold-underline cyan
constexpr char kGYbu[] = "\e[1;4;37m"; ///< bold-underline grey
constexpr char kWTbu[] = "\e[1;4;38m"; ///< bold-underline white
constexpr char BKbu[] = "\e[1;4;30m"; ///< bold-underline black
constexpr char RDbu[] = "\e[1;4;31m"; ///< bold-underline red
constexpr char GNbu[] = "\e[1;4;32m"; ///< bold-underline green
constexpr char YLbu[] = "\e[1;4;33m"; ///< bold-underline yellow
constexpr char BLbu[] = "\e[1;4;34m"; ///< bold-underline blue
constexpr char MGbu[] = "\e[1;4;35m"; ///< bold-underline magenta
constexpr char CYbu[] = "\e[1;4;36m"; ///< bold-underline cyan
constexpr char GYbu[] = "\e[1;4;37m"; ///< bold-underline grey
constexpr char WTbu[] = "\e[1;4;38m"; ///< bold-underline white
// bold-italic
constexpr char kBKbi[] = "\e[1;3;30m"; ///< bold-italic black
constexpr char kRDbi[] = "\e[1;3;31m"; ///< bold-italic red
constexpr char kGNbi[] = "\e[1;3;32m"; ///< bold-italic green
constexpr char kYLbi[] = "\e[1;3;33m"; ///< bold-italic yellow
constexpr char kBLbi[] = "\e[1;3;34m"; ///< bold-italic blue
constexpr char kMGbi[] = "\e[1;3;35m"; ///< bold-italic magenta
constexpr char kCYbi[] = "\e[1;3;36m"; ///< bold-italic cyan
constexpr char kGYbi[] = "\e[1;3;37m"; ///< bold-italic grey
constexpr char kWTbi[] = "\e[1;3;38m"; ///< bold-italic white
constexpr char BKbi[] = "\e[1;3;30m"; ///< bold-italic black
constexpr char RDbi[] = "\e[1;3;31m"; ///< bold-italic red
constexpr char GNbi[] = "\e[1;3;32m"; ///< bold-italic green
constexpr char YLbi[] = "\e[1;3;33m"; ///< bold-italic yellow
constexpr char BLbi[] = "\e[1;3;34m"; ///< bold-italic blue
constexpr char MGbi[] = "\e[1;3;35m"; ///< bold-italic magenta
constexpr char CYbi[] = "\e[1;3;36m"; ///< bold-italic cyan
constexpr char GYbi[] = "\e[1;3;37m"; ///< bold-italic grey
constexpr char WTbi[] = "\e[1;3;38m"; ///< bold-italic white
// bold-reverse
constexpr char kBKbr[] = "\e[1;7;30m"; ///< bold-reverse black
constexpr char kRDbr[] = "\e[1;7;31m"; ///< bold-reverse red
constexpr char kGNbr[] = "\e[1;7;32m"; ///< bold-reverse green
constexpr char kYLbr[] = "\e[1;7;33m"; ///< bold-reverse yellow
constexpr char kBLbr[] = "\e[1;7;34m"; ///< bold-reverse blue
constexpr char kMGbr[] = "\e[1;7;35m"; ///< bold-reverse magenta
constexpr char kCYbr[] = "\e[1;7;36m"; ///< bold-reverse cyan
constexpr char kGYbr[] = "\e[1;7;37m"; ///< bold-reverse grey
constexpr char kWTbr[] = "\e[1;7;38m"; ///< bold-reverse white
} // namespace clrs
constexpr char BKbr[] = "\e[1;7;30m"; ///< bold-reverse black
constexpr char RDbr[] = "\e[1;7;31m"; ///< bold-reverse red
constexpr char GNbr[] = "\e[1;7;32m"; ///< bold-reverse green
constexpr char YLbr[] = "\e[1;7;33m"; ///< bold-reverse yellow
constexpr char BLbr[] = "\e[1;7;34m"; ///< bold-reverse blue
constexpr char MGbr[] = "\e[1;7;35m"; ///< bold-reverse magenta
constexpr char CYbr[] = "\e[1;7;36m"; ///< bold-reverse cyan
constexpr char GYbr[] = "\e[1;7;37m"; ///< bold-reverse grey
constexpr char WTbr[] = "\e[1;7;38m"; ///< bold-reverse white
} // namespace clrs
} // namespace cbm::algo::ca::constants
/// TEMPORARY !!!!
......
......@@ -112,7 +112,6 @@ set(HEADERS
L1Algo/L1Def.h
L1Algo/L1Vector.h
L1Algo/L1EArray.h
L1Algo/L1Undef.h
L1Algo/utils/CaUvConverter.h
L1Algo/utils/CaMonitor.h
catools/CaToolsWindowFinder.h
......
......@@ -45,8 +45,8 @@
// ** Action definition functions **
// *********************************
using cbm::algo::ca::constants::clrs::kCL; // clear log
using cbm::algo::ca::constants::clrs::kRDb; // red bold log
using cbm::algo::ca::constants::clrs::CL; // clear log
using cbm::algo::ca::constants::clrs::RDb; // red bold log
using cbm::ca::MCModule;
// ---------------------------------------------------------------------------------------------------------------------
......
......@@ -39,13 +39,11 @@
#include <string_view>
#include <type_traits>
#include "CaConstants.h"
#include "CaMonitor.h"
#include "CaToolsMCData.h"
#include "CaToolsMCPoint.h"
#include "L1InputData.h"
#include "L1Parameters.h"
#include "L1Undef.h"
class CbmEvent;
class CbmMCDataObject;
......@@ -56,6 +54,7 @@ enum class L1DetectorID;
namespace cbm::ca
{
/// @brief Class CbmCaPerformance is an interface to communicate between
///
class MCModule {
......@@ -124,7 +123,7 @@ namespace cbm::ca
/// @brief Sets first hit indexes container in different detectors
/// @param source Array of indexes
void RegisterFirstHitIndexes(const std::array<int, constants::size::kMaxNdetectors + 1>& source)
void RegisterFirstHitIndexes(const std::array<int, constants::size::MaxNdetectors + 1>& source)
{
fpvFstHitId = &source;
}
......@@ -261,7 +260,7 @@ namespace cbm::ca
/// @brief Pointer to array of first hit indexes in the detector subsystem
///
/// This array must be initialized in the run initialization function.
const std::array<int, constants::size::kMaxNdetectors + 1>* fpvFstHitId = nullptr;
const std::array<int, constants::size::MaxNdetectors + 1>* fpvFstHitId = nullptr;
};
} // namespace cbm::ca
......@@ -327,10 +326,10 @@ std::optional<::ca::tools::MCPoint> cbm::ca::MCModule::FillMCPoint(int iExtId, i
auto oPoint = std::make_optional<::ca::tools::MCPoint>();
// ----- Get positions, momenta, time and track ID
TVector3 posIn; // Position at entrance to station [cm]
TVector3 posOut; // Position at exist of station [cm]
TVector3 momIn; // 3-momentum at entrance to station [GeV/c]
TVector3 momOut; // 3-momentum at exit of station [GeV/c]
TVector3 posIn; // Position at entrance to station [cm]
TVector3 posOut; // Position at exist of station [cm]
TVector3 momIn; // 3-momentum at entrance to station [GeV/c]
TVector3 momOut; // 3-momentum at exit of station [GeV/c]
auto* pBrPoints = fvpBrPoints[DetID];
......
......@@ -27,9 +27,9 @@
#include "L1Parameters.h"
using ca::tools::HitRecord;
using cbm::algo::ca::constants::clrs::kCL; // clear log
using cbm::algo::ca::constants::clrs::kGNb; // green bold log
using cbm::algo::ca::constants::clrs::kRDb; // red bold log
using namespace cbm::algo::ca::constants;
using cbm::ca::TimeSliceReader;
// ---------------------------------------------------------------------------------------------------------------------
......@@ -155,11 +155,16 @@ try {
// Check initialization
this->CheckInit();
LOG(info) << "TimeSliceReader: initializing run ... " << kGNb << "done" << kCL;
//clrs::CL - clear log
//clrs::GNb - green bold log
//clrs::RDb - red bold log
LOG(info) << "TimeSliceReader: initializing run ... " << clrs::GNb << "done" << clrs::CL;
return true;
}
catch (const std::logic_error& error) {
LOG(info) << "TimeSliceReader: initializing run ... " << kRDb << "failed" << kCL << "\nReason: " << error.what();
LOG(info) << "TimeSliceReader: initializing run ... " << clrs::RDb << "failed" << clrs::CL
<< "\nReason: " << error.what();
return false;
}
......
......@@ -200,7 +200,7 @@ namespace cbm::ca
int fNofHitKeys = 0; ///< Recorded number of hit keys
int fFirstHitKey = 0; ///< First index of hit key for the detector subsystem
std::array<int, constants::size::kMaxNdetectors + 1> fvHitFirstIndexDet = {{0}}; ///< First hit index in detector
std::array<int, constants::size::MaxNdetectors + 1> fvHitFirstIndexDet = {{0}}; ///< First hit index in detector
};
} // namespace cbm::ca
......
......@@ -30,7 +30,7 @@
#include "L1Algo/L1Algo.h"
#include "L1Algo/L1Hit.h"
using cbm::algo::ca::constants::size::kMaxNstations;
using cbm::algo::ca::constants::size::MaxNstations;
CbmL1MCTrack::CbmL1MCTrack(double mass_, double q_, TVector3 vr, TLorentzVector vp, int _ID, int _mother_ID, int _pdg,
unsigned int _process_ID)
......@@ -111,7 +111,7 @@ void CbmL1MCTrack::CountHitStations()
{
CbmL1* L1 = CbmL1::Instance();
int stationNhits[kMaxNstations] {0};
int stationNhits[MaxNstations] {0};
for (unsigned int iH = 0; iH < Hits.size(); iH++) {
CbmL1HitDebugInfo& sh = L1->fvHitDebugInfo[Hits[iH]];
......
......@@ -1140,8 +1140,7 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitFa
void CbmL1::TrackFitPerformance()
{
const int Nh_fit = 17;
static TH1F *h_fit[Nh_fit], *h_fitL[Nh_fit], *h_fitSV[Nh_fit], *h_fitPV[Nh_fit], *h_fitTrd[Nh_fit], *h_fitTof[Nh_fit],
*h_fit_chi2; //, *h_smoothed[12][Nh_fit];
static TH1F *h_fit[Nh_fit], *h_fitL[Nh_fit], *h_fitSV[Nh_fit], *h_fitPV[Nh_fit], *h_fit_chi2;
static TH2F *PRes2D, *PRes2DPrim, *PRes2DSec;
......@@ -1272,26 +1271,6 @@ void CbmL1::TrackFitPerformance()
sprintf(t, "Primary vertex point %s", TableVertex[i].title);
h_fitPV[i] = new TH1F(n, t, TableVertex[i].n, TableVertex[i].l, TableVertex[i].r);
sprintf(n, "trd_%s", TableVertex[i].name);
sprintf(t, "Last Trd point %s", TableVertex[i].title);
if (i == 12) { h_fitTrd[i] = new TH1F(n, t, Table[i].n, -30., 30.); }
else if (i == 13) {
h_fitTrd[i] = new TH1F(n, t, Table[i].n, -5., 5.);
}
else {
h_fitTrd[i] = new TH1F(n, t, Table[i].n, Table[i].l, Table[i].r);
}
sprintf(n, "tof_%s", TableVertex[i].name);
sprintf(t, "Last Tof point %s", TableVertex[i].title);
if (i == 12) { h_fitTof[i] = new TH1F(n, t, Table[i].n, -30., 30.); }
else if (i == 13) {
h_fitTof[i] = new TH1F(n, t, Table[i].n, -5., 5.);
}
else {
h_fitTof[i] = new TH1F(n, t, Table[i].n, Table[i].l, Table[i].r);
}
for (int j = 0; j < 12; j++) {
sprintf(n, "smth_%s_sta_%i", Table[i].name, j);
sprintf(t, "Station %i %s", j, Table[i].title);
......
......@@ -156,11 +156,11 @@ public:
/// @param header If true, header will be printed
std::string ToString(int verbose = 10, bool header = false) const;
double Tpv[L1TrackPar::kNparTr]; ///< Track parameters at primary vertex
double Cpv[L1TrackPar::kNparCov]; ///< Track covariance matrix at primary vertex
std::array<double, L1TrackPar::kNparTr> Tpv; ///< Track parameters at primary vertex
std::array<double, L1TrackPar::kNparCov> Cpv; ///< Track covariance matrix at primary vertex
double TLast[L1TrackPar::kNparTr]; ///< Track parameters in the end of the track
double CLast[L1TrackPar::kNparCov]; ///< Track covariance matrix at the end of the track
std::array<double, L1TrackPar::kNparTr> TLast; ///< Track parameters in the end of the track
std::array<double, L1TrackPar::kNparCov> CLast; ///< Track covariance matrix at the end of the track
vector<int> Hits; ///< Indexes of hits of this track
int nStations; ///< Number of stations with hits of this track
......
......@@ -10,8 +10,8 @@
struct CbmL1TrackPar {
public:
CbmL1TrackPar() : chi2(0), NDF(0), mass(0), is_electron(0) {}
double* GetTrack() { return T; }
double* GetCovMatrix() { return C; }
std::array<double, L1TrackPar::kNparTr>& GetTrack() { return T; }
std::array<double, L1TrackPar::kNparCov>& GetCovMatrix() { return C; }
double& GetRefChi2() { return chi2; }
int& GetRefNDF() { return NDF; }
double GetMass() const { return mass; }
......@@ -24,8 +24,8 @@ public:
public:
int fId;
double T[L1TrackPar::kNparTr];
double C[L1TrackPar::kNparCov];
std::array<double, L1TrackPar::kNparTr> T;
std::array<double, L1TrackPar::kNparCov> C;
double chi2;
int NDF;
double mass; // mass hypothesis
......
......@@ -8,39 +8,41 @@
namespace cbm::L1Util
{
void CopyTC2TrackParam(FairTrackParam* par, Double_t T[], Double_t C[])
void CopyTrackParam2TC(const FairTrackParam* par, std::array<double, L1TrackPar::kNparTr>& T,
std::array<double, L1TrackPar::kNparCov>& C)
{
if (T) {
par->SetX(T[0]);
par->SetY(T[1]);
par->SetZ(T[5]);
par->SetTx(T[2]);
par->SetTy(T[3]);
par->SetQp(T[4]);
}
if (C) {
for (Int_t i = 0, iCov = 0; i < 5; i++)
for (Int_t j = 0; j <= i; j++, iCov++)
par->SetCovariance(i, j, C[iCov]);
T[0] = par->GetX();
T[1] = par->GetY();
T[2] = par->GetTx();
T[3] = par->GetTy();
T[4] = par->GetQp();
T[5] = par->GetZ();
for (Int_t i = 0, iCov = 0; i < 5; i++) {
for (Int_t j = 0; j <= i; j++, iCov++) {
C[iCov] = par->GetCovariance(i, j);
}
}
}
void CopyTrackParam2TC(const FairTrackParam* par, Double_t T[], Double_t C[])
void CopyTC2TrackParam(FairTrackParam* par, const std::array<double, L1TrackPar::kNparTr>& T,
const std::array<double, L1TrackPar::kNparCov>& C)
{
if (T) {
T[0] = par->GetX();
T[1] = par->GetY();
T[2] = par->GetTx();
T[3] = par->GetTy();
T[4] = par->GetQp();
T[5] = par->GetZ();
}
if (C) {
for (Int_t i = 0, iCov = 0; i < 5; i++)
for (Int_t j = 0; j <= i; j++, iCov++)
C[iCov] = par->GetCovariance(i, j);
par->SetX(T[0]);
par->SetY(T[1]);
par->SetZ(T[5]);
par->SetTx(T[2]);
par->SetTy(T[3]);
par->SetQp(T[4]);
for (Int_t i = 0, iCov = 0; i < 5; i++) {
for (Int_t j = 0; j <= i; j++, iCov++) {
par->SetCovariance(i, j, C[iCov]);
}
}
}
} // namespace cbm::L1Util
......@@ -7,6 +7,8 @@
#include "Rtypes.h"
#include "L1TrackPar.h"
class FairTrackParam;
///
......@@ -17,11 +19,13 @@ namespace cbm::L1Util
/// copy fair track param to arrays
// TODO: reorganize
void CopyTrackParam2TC(const FairTrackParam* par, Double_t T[], Double_t C[]);
void CopyTrackParam2TC(const FairTrackParam* par, std::array<double, L1TrackPar::kNparTr>& T,
std::array<double, L1TrackPar::kNparCov>& C);
/// copy arrays to fair track param
// TODO: reorganize
void CopyTC2TrackParam(FairTrackParam* par, Double_t T[], Double_t C[]);
void CopyTC2TrackParam(FairTrackParam* par, const std::array<double, L1TrackPar::kNparTr>& T,
const std::array<double, L1TrackPar::kNparCov>& C);
} // namespace cbm::L1Util
......
......@@ -12,7 +12,7 @@
L1Algo::L1Algo()
{
for (unsigned int i = 0; i < constants::size::kMaxNstations; i++) {
for (unsigned int i = 0; i < constants::size::MaxNstations; i++) {
vGridTime[i].AllocateMemory();
fTriplets[i].SetName(std::stringstream() << "L1Algo::fTriplets[" << i << "]");
}
......@@ -62,7 +62,7 @@ void L1Algo::ResetSliceData()
fTrackCandidates.clear();
fTrackCandidates.reserve(nHits / 10);
for (unsigned int iS = 0; iS < constants::size::kMaxNstations; iS++) {
for (unsigned int iS = 0; iS < constants::size::MaxNstations; iS++) {
int nHitsStation = fSliceHitIds[iS].size();
fTriplets[iS].clear();
fTriplets[iS].reserve(2 * nHitsStation);
......
......@@ -51,8 +51,8 @@ class CbmL1MCTrack;
// ** Types definition (global) **
// *******************************
using L1StationsArray_t = std::array<L1Station, constants::size::kMaxNstations>;
using L1MaterialArray_t = std::array<L1Material, constants::size::kMaxNstations>;
using L1StationsArray_t = std::array<L1Station, constants::size::MaxNstations>;
using L1MaterialArray_t = std::array<L1Material, constants::size::MaxNstations>;
using Tindex = int; // TODO: Replace with L1HitIndex_t, if suitable
#ifdef PULLS
......@@ -267,7 +267,7 @@ private:
int fNfieldStations {0}; ///< number of stations in the field region
//alignas(16) L1StationsArray_t fStations {}; ///< array of L1Station objects
//alignas(16) L1MaterialArray_t fRadThick {}; ///< material for each station
float fDefaultMass {constants::phys::kMuonMass}; ///< mass of the propagated particle [GeV/c2]
float fDefaultMass {constants::phys::MuonMass}; ///< mass of the propagated particle [GeV/c2]
// ***************************
......@@ -283,12 +283,12 @@ private:
public:
L1Vector<L1HitTimeInfo> fHitTimeInfo;
L1Grid vGrid[constants::size::kMaxNstations]; ///<
L1Grid vGridTime[constants::size::kMaxNstations]; ///<
L1Grid vGrid[constants::size::MaxNstations]; ///<
L1Grid vGridTime[constants::size::MaxNstations]; ///<
fscal fMaxRangeX[constants::size::kMaxNstations];
fscal fMaxRangeY[constants::size::kMaxNstations];
fscal fMaxRangeT[constants::size::kMaxNstations];
fscal fMaxRangeX[constants::size::MaxNstations];
fscal fMaxRangeY[constants::size::MaxNstations];
fscal fMaxRangeT[constants::size::MaxNstations];
double fCaRecoTime {0.}; // time of the track finder + fitter
......@@ -300,14 +300,14 @@ public:
L1Vector<L1HitIndex_t> fSliceRecoHits {"L1Algo::fSliceRecoHits"}; ///< packed hits of reconstructed tracks
/// Created triplets vs station index
L1Vector<L1Triplet> fTriplets[constants::size::kMaxNstations] {{"L1Algo::fTriplets"}};
L1Vector<L1Triplet> fTriplets[constants::size::MaxNstations] {{"L1Algo::fTriplets"}};
/// Track candidates created out of adjacent triplets before the final track selection.
/// The candidates may share any amount of hits.
L1Vector<L1Branch> fTrackCandidates {"L1Algo::fTrackCandidates"};
///< indices of the sub-slice hits
L1Vector<L1HitIndex_t> fSliceHitIds[constants::size::kMaxNstations] {"L1Algo::fSliceHitIds"};
L1Vector<L1HitIndex_t> fSliceHitIds[constants::size::MaxNstations] {"L1Algo::fSliceHitIds"};
L1Vector<L1Hit> fGridHits {"L1Algo::fGridHits"}; ///< hits, ordered with respect to their grid bins
L1Vector<L1Hit> fGridHitsBuf {"L1Algo::fGridHitsBuf"}; ///< hits, ordered with respect to their grid bins
......@@ -318,8 +318,8 @@ public:
L1Vector<L1HitPoint> fGridPoints {"L1Algo::fGridPoints"}; ///< grid points parallel to fGridHits
L1Vector<L1HitPoint> fGridPointsBuf {"L1Algo::fGridPointsBuf"};
L1HitIndex_t fGridHitStartIndex[constants::size::kMaxNstations + 1] {0};
L1HitIndex_t fGridHitStopIndex[constants::size::kMaxNstations + 1] {0};
L1HitIndex_t fGridHitStartIndex[constants::size::MaxNstations + 1] {0};
L1HitIndex_t fGridHitStopIndex[constants::size::MaxNstations + 1] {0};
L1Vector<int> fStripToTrack {"L1Algo::fStripToTrack"}; // strip to track pointers
......@@ -403,10 +403,10 @@ private:
[[gnu::always_inline]] inline unsigned int L1Algo::PackTripletId(unsigned int iStation, unsigned int iTriplet)
{
#ifndef FAST_CODE
assert(iStation < constants::size::kMaxNstations);
assert(iTriplet < constants::size::kMaxNtriplets);
assert(iStation < constants::size::MaxNstations);
assert(iTriplet < constants::size::MaxNtriplets);
#endif
constexpr unsigned int kMoveStation = constants::size::kTripletBits;
constexpr unsigned int kMoveStation = constants::size::TripletBits;
return (iStation << kMoveStation) + iTriplet;
}
......@@ -414,7 +414,7 @@ private:
//
[[gnu::always_inline]] inline unsigned int L1Algo::TripletId2Station(unsigned int id)
{
constexpr unsigned int kMoveStation = constants::size::kTripletBits;
constexpr unsigned int kMoveStation = constants::size::TripletBits;
return id >> kMoveStation;
}
......@@ -422,7 +422,7 @@ private:
//
[[gnu::always_inline]] inline unsigned int L1Algo::TripletId2Triplet(unsigned int id)
{
constexpr unsigned int kTripletMask = (1u << constants::size::kTripletBits) - 1u;
constexpr unsigned int kTripletMask = (1u << constants::size::TripletBits) - 1u;
return id & kTripletMask;
}
......
......@@ -139,8 +139,8 @@ void L1BaseStationInfo::SetFieldFunction(
L1MASSERT(0, fInitController.GetFlag(EInitKey::kYmax),
"Attempt to set magnetic field slice before Ymax size of the station");
// TODO: Change names of variables according to convention (S.Zh.)
constexpr int M = constants::size::kMaxFieldApproxPolynomialOrder;
constexpr int N = constants::size::kMaxNFieldApproxCoefficients;
constexpr int M = constants::size::MaxFieldApproxPolynomialOrder;
constexpr int N = constants::size::MaxNFieldApproxCoefficients;
constexpr int D = 3; ///> number of dimensions
// SLE initialization
......
......@@ -25,7 +25,7 @@ L1CAIteration::L1CAIteration(const std::string& name) : fName(name) {}
//
bool L1CAIteration::Check() const
{
using constants::size::kMaxNstations;
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
......@@ -40,9 +40,9 @@ bool L1CAIteration::Check() const
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, kMaxNstations) && res;
res = this->CheckValueLimits<int>("min_n_hits_sta_0", fMinNhitsStation0, 3, kMaxNstations) && res;
res = this->CheckValueLimits<int>("first_station_index", fFirstStationIndex, 0, kMaxNstations) && 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;
......
......@@ -165,9 +165,9 @@ void L1Algo::CaTrackFinderSlice()
// static Tindex stat_nDoublets[fNFindIterations] = {0};
static Tindex stat_nTriplets[fNFindIterations] = {0};
static Tindex stat_nLevels[constants::size::kMaxNstations - 2][fNFindIterations] = {{0}};
static Tindex stat_nCalls[fNFindIterations] = {0}; // n calls of CAFindTrack
static Tindex stat_nTrCandidates[fNFindIterations] = {0};
static Tindex stat_nLevels[constants::size::MaxNstations - 2][fNFindIterations] = {{0}};
static Tindex stat_nCalls[fNFindIterations] = {0}; // n calls of CAFindTrack
static Tindex stat_nTrCandidates[fNFindIterations] = {0};
for (int iS = 0; iS < fParameters.GetNstationsActive(); ++iS) {
stat_nStartHits += fSliceHitIds[iS].size();
......@@ -441,7 +441,7 @@ void L1Algo::CaTrackFinderSlice()
if (fpCurrentIteration->GetTrackFromTripletsFlag()) { min_level = 0; }
L1Branch curr_tr;
L1Branch new_tr[constants::size::kMaxNstations];
L1Branch new_tr[constants::size::MaxNstations];
L1Branch best_tr;
fscal curr_chi2 = 0;
......@@ -742,14 +742,11 @@ void L1Algo::CaTrackFinderSlice()
} // for (int isec
// ---- Loop over Track Finder iterations: END -----------------------------------------------------------//
if constexpr (constants::control::kIfMergeClones) {
//CAMergeClones();
// Fit tracks
this->L1KFTrackFitter();
// Fit tracks
this->L1KFTrackFitter();
// Merge clones
fCloneMerger.Exec(fSliceRecoTracks, fSliceRecoHits);
}
// Merge clones
fCloneMerger.Exec(fSliceRecoTracks, fSliceRecoHits);
//==================================
......
......@@ -214,7 +214,7 @@ std::vector<std::set<int>> L1ConfigRW::ReadInactiveStationMap()
if (node && node.size()) {
std::unordered_map<std::string, int> mDetNameToID;
for (int iDet = 0; iDet < constants::size::kMaxNdetectors; ++iDet) {
for (int iDet = 0; iDet < constants::size::MaxNdetectors; ++iDet) {
auto detName = boost::algorithm::to_lower_copy(fpInitManager->GetDetectorName(static_cast<L1DetectorID>(iDet)));
if (!detName.size()) { continue; }
mDetNameToID[detName] = iDet;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment