CbmRoot
Loading...
Searching...
No Matches
CaIteration.cxx
Go to the documentation of this file.
1/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov, Sergei Zharko [committer] */
4
9
10#include "CaIteration.h"
11
12#include "CaDefs.h"
13
14#include <limits>
15#include <sstream>
16#include <string_view>
17
20
21// ---------------------------------------------------------------------------------------------------------------------
22//
23Iteration::Iteration(const std::string& name) : fName(name) {}
24
25// ---------------------------------------------------------------------------------------------------------------------
26//
27bool Iteration::Check() const
28{
30 constexpr float kMaxFloat = std::numeric_limits<float>::max();
31 bool res = true;
32
33 auto CheckValueLimits = [&](std::string_view name, auto value, auto min, auto max) -> bool {
34 if (value > max || value < min) {
35 LOG(info) << "cbm::algo::ca::Iteration: parameter " << name << " = " << value << " runs out of range " << min
36 << ", " << max;
37 return false;
38 }
39 return true;
40 };
41
42 // TODO: SZh 06.10.2022: These values should be tuned. At the moment the std::numeric_limits<T>::max value is used for
43 // debug purposes. In future, these values will be strengthened.
44 res = CheckValueLimits("track_chi2_cut", fTrackChi2Cut, 0.f, kMaxFloat) && res;
45 res = CheckValueLimits("triplet_chi2_cut", fTripletChi2Cut, 0.f, kMaxFloat) && res;
46 res = CheckValueLimits("triplet_final_chi2_cut", fTripletFinalChi2Cut, 0.f, kMaxFloat) && res;
47 res = CheckValueLimits("doublet_chi2_cut", fDoubletChi2Cut, 0.f, kMaxFloat) && res;
48 res = CheckValueLimits("pick_gather", fPickGather, 0.f, kMaxFloat) && res;
49 res = CheckValueLimits("triplet_link_chi2", fTripletLinkChi2, 0.f, kMaxFloat) && res;
50 res = CheckValueLimits("max_qp", fMaxQp, 0.001f, kMaxFloat) && res;
51 res = CheckValueLimits("max_slope_pv", fMaxSlopePV, 0.f, kMaxFloat) && res;
52 res = CheckValueLimits("max_slope", fMaxSlope, 0.f, kMaxFloat) && res;
53 res = CheckValueLimits("max_dz", fMaxDZ, 0.f, kMaxFloat) && res;
54 res = CheckValueLimits("min_n_hits", fMinNhits, 3, MaxNstations) && res;
55 res = CheckValueLimits("min_n_hits_sta_0", fMinNhitsStation0, 3, MaxNstations) && res;
56 res = CheckValueLimits("first_station_index", fFirstStationIndex, 0, MaxNstations) && res;
57 res = CheckValueLimits("target_pos_sigma_x", fTargetPosSigmaX, 0.f, kMaxFloat) && res;
58 res = CheckValueLimits("target_pos_sigma_y", fTargetPosSigmaY, 0.f, kMaxFloat) && res;
59 return res;
60}
61
62// ---------------------------------------------------------------------------------------------------------------------
63//
64void Iteration::SetTargetPosSigmaXY(float sigmaX, float sigmaY)
65{
66 fTargetPosSigmaX = sigmaX;
67 fTargetPosSigmaY = sigmaY;
68}
69
70// ---------------------------------------------------------------------------------------------------------------------
71//
72std::string Iteration::ToString(int) const
73{
74 std::vector<Iteration> vIter{*this};
75 return Iteration::ToTableFromVector(vIter);
76}
77
78// ---------------------------------------------------------------------------------------------------------------------
79//
80std::string Iteration::ToTableFromVector(const Vector<Iteration>& vIterations)
81{
82 std::stringstream msg;
83 msg << std::boolalpha;
84
85 auto PutRow = [&](const std::string& name, std::function<void(const Iteration&)> fn) {
86 msg << std::setw(40) << std::setfill(' ') << name << ' ';
87 for (const auto& iter : vIterations) {
88 msg << std::setw(12) << std::setfill(' ');
89 fn(iter);
90 msg << ' ';
91 }
92 msg << '\n';
93 };
94
95 PutRow(" ", [&](const Iteration& i) { msg << i.GetName(); });
96 PutRow("Is primary ", [&](const Iteration& i) { msg << i.GetPrimaryFlag(); });
97 PutRow("Is electron ", [&](const Iteration& i) { msg << i.GetElectronFlag(); });
98 PutRow("If tracks created from triplets ", [&](const Iteration& i) { msg << i.GetTrackFromTripletsFlag(); });
99 PutRow("If tracks extended with unused hits", [&](const Iteration& i) { msg << i.GetExtendTracksFlag(); });
100 PutRow("Triplets can jump over <=n stations", [&](const Iteration& i) { msg << i.GetMaxStationGap(); });
101 PutRow("Min number of hits ", [&](const Iteration& i) { msg << i.GetMinNhits(); });
102 PutRow("Min number of hits on station 0 ", [&](const Iteration& i) { msg << i.GetMinNhitsStation0(); });
103 PutRow("Track chi2 cut ", [&](const Iteration& i) { msg << i.GetTrackChi2Cut(); });
104 PutRow("Triplet chi2 cut ", [&](const Iteration& i) { msg << i.GetTripletChi2Cut(); });
105 PutRow("Triplet final chi2 cut ", [&](const Iteration& i) { msg << i.GetTripletFinalChi2Cut(); });
106 PutRow("Doublet chi2 cut ", [&](const Iteration& i) { msg << i.GetDoubletChi2Cut(); });
107 PutRow("Pick gather ", [&](const Iteration& i) { msg << i.GetPickGather(); });
108 PutRow("Triplet link chi2 ", [&](const Iteration& i) { msg << i.GetTripletLinkChi2(); });
109 PutRow("Max q/p ", [&](const Iteration& i) { msg << i.GetMaxQp(); });
110 PutRow("Max slope ", [&](const Iteration& i) { msg << i.GetMaxSlope(); });
111 PutRow("Max slope at primary vertex ", [&](const Iteration& i) { msg << i.GetMaxSlopePV(); });
112 PutRow("Max DZ ", [&](const Iteration& i) { msg << i.GetMaxDZ(); });
113 PutRow("Target position sigma X [cm] ", [&](const Iteration& i) { msg << i.GetTargetPosSigmaX(); });
114 PutRow("Target position sigma Y [cm] ", [&](const Iteration& i) { msg << i.GetTargetPosSigmaY(); });
115 PutRow("First tracking station index ", [&](const Iteration& i) { msg << i.GetFirstStationIndex(); });
116
117 return msg.str();
118}
Compile-time constants definition for the CA tracking algorithm.
friend fscal max(fscal x, fscal y)
friend fscal min(fscal x, fscal y)
A set of parameters for the CA Track finder iteration.
float fTripletLinkChi2
Min value of dp^2/dp_error^2, for which two tiplets are neighbours.
float fDoubletChi2Cut
Doublet chi2 upper cut.
int GetMinNhits() const
Gets min n hits.
Definition CaIteration.h:88
float GetTripletChi2Cut() const
Gets triplet chi2 upper cut.
int fFirstStationIndex
First station, used for tracking.
int fMinNhitsStation0
min n hits for tracks that start on station 0
float fMaxDZ
Correction for accounting overlaping and iff z [cm].
bool Check() const
Checks parameters consistency.
float fTargetPosSigmaY
Constraint on target position in Y direction [cm].
float fMaxSlope
Max slope (tx\ty) in 3D hit position of a triplet.
float GetMaxSlope() const
Gets max slope (tx\ty) in 3D hit position of a triplet.
Definition CaIteration.h:82
float GetPickGather() const
Gets size of region [TODO: units??] to attach new hits to the created track.
Definition CaIteration.h:97
float GetTrackChi2Cut() const
Gets track chi2 upper cut.
bool GetElectronFlag() const
flag check: electrons/positrons - true, heavy charged - false
Definition CaIteration.h:64
float GetDoubletChi2Cut() const
Gets doublet chi2 upper cut.
Definition CaIteration.h:61
float fTargetPosSigmaX
Constraint on target position in X direction [cm].
float GetTripletFinalChi2Cut() const
Gets triplet chi2 upper cut.
int GetMaxStationGap() const
Gets flag: true - triplets are also built with skipping <= GetMaxStationGap stations.
Definition CaIteration.h:73
void SetTargetPosSigmaXY(float sigmaX, float sigmaY)
Sets sigma of target positions in XY plane.
std::string ToString(int indentLevel=0) const
String representation of the class contents.
static std::string ToTableFromVector(const Vector< Iteration > &vIterations)
Forms a string, representing a table of iterations from the vector of iterations.
int GetMinNhitsStation0() const
Gets min n hits for tracks that start on station 0.
Definition CaIteration.h:91
float fMaxQp
Max considered q/p for tracks.
float fMaxSlopePV
Max slope (tx\ty) in primary vertex.
float GetTargetPosSigmaX() const
Gets sigma target position in X direction [cm].
bool GetTrackFromTripletsFlag() const
float fPickGather
Size of region to attach new hits to the created track.
float GetTripletLinkChi2() const
Gets min value of dp/dp_error, for which two tiplets are neighbours.
float GetMaxQp() const
Gets max considered q/p for tracks.
Definition CaIteration.h:79
float GetMaxDZ() const
Gets correction for accounting overlaping and iff z.
Definition CaIteration.h:76
float fTripletChi2Cut
Triplet chi2 upper cut.
bool GetPrimaryFlag() const
Checks flag: true - only primary tracks are searched, false - [all or only secondary?...
float fTrackChi2Cut
Track chi2 upper cut.
float fTripletFinalChi2Cut
Triplet chi2 upper cut.
const std::string & GetName() const
Gets the name of the iteration.
Definition CaIteration.h:94
float GetTargetPosSigmaY() const
Gets sigma target position in Y direction [cm].
Iteration()=default
Default constructor.
int GetFirstStationIndex() const
Gets station index of the first station used in tracking.
Definition CaIteration.h:70
bool GetExtendTracksFlag() const
Sets flag: true - extends track candidates with unused hits.
Definition CaIteration.h:67
int fMinNhits
min n hits on the tracks
float GetMaxSlopePV() const
Gets max slope (tx\ty) in primary vertex.
Definition CaIteration.h:85
constexpr int MaxNstations
Max number of stations, 2^6 = 64.
Definition CaDefs.h:44