CbmRoot
Loading...
Searching...
No Matches
CbmCaInputQaBase.h
Go to the documentation of this file.
1/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10
11#pragma once
12
13#include "CaMonitor.h"
14#include "CbmCaHitQaData.h"
15#include "CbmCaInputQaBase.h"
16#include "CbmL1DetectorID.h"
17#include "CbmMCDataManager.h"
18#include "CbmPixelHit.h"
19#include "CbmQaTask.h"
20#include "TMath.h"
21
22#include <set>
23#include <unordered_map>
24#include <vector>
25
26class CbmMatch;
27class CbmMCEventList;
28class CbmMCDataArray;
30class CbmMCTrack;
31class CbmStsHit;
32class CbmStsPoint;
34class CbmTimeSlice;
35class FairMCPoint;
36class TClonesArray;
37class TH1F;
38class TH2F;
39class TProfile;
40class TProfile2D;
41
42namespace
43{
47} // namespace
48
52template<EDetectorID DetID>
54 protected:
57
60 struct Config {
63 struct McTrackCuts {
64 double fMinMom = 0.1;
65 double fMaxTheta = 60.;
66 bool fbPrimary = true;
67 /* clang-format off */
69 Property(&McTrackCuts::fMinMom, "MinMom", "Minimal momentum at the exit of the station [GeV/c]"),
70 Property(&McTrackCuts::fMaxTheta, "MaxTheta", "Maximal theta at the exit of the station [grad]"),
71 Property(&McTrackCuts::fbPrimary, "IsPrimary", "Is track primary")
72 );
73 /* clang-format on */
74 };
75
77 double fPullMeanThrsh = 0.1;
78 double fPullWidthThrsh = 2.0;
79 double fEffThrsh = 0.5;
80 double fMaxDiffZStHit = 1.0;
81 /* clang-format off */
83 Property(&Config::fMcTrackCuts, "McTrackCuts", "MC track cuts"),
84 Property(&Config::fPullMeanThrsh, "PullMeanThrsh", "Pull mean threshold"),
85 Property(&Config::fPullWidthThrsh, "PullWidthThrsh", "Pull width threshold"),
86 Property(&Config::fEffThrsh, "EffThrsh", "Efficiency threshold"),
87 Property(&Config::fMaxDiffZStHit, "MaxDiffZStHit", "Max difference between station and hit z")
88 );
89 /* clang-format on */
90 };
91
92 public:
97 CbmCaInputQaBase(const char* name, int verbose, bool isMCUsed);
98
100 virtual ~CbmCaInputQaBase() = default;
101
102 protected:
103 // ********************************************
104 // ** Virtual method override from CbmQaTask **
105 // ********************************************
106
109 void Check() override;
110
112 void CreateSummary() override;
113
115 virtual void FillHistogramsPerHit() {}
116
118 virtual void FillHistogramsPerPoint() {}
119
121 void DeInit() override;
122
124 virtual void DefineParameters() = 0;
125
127 void ExecQa() override;
128
130 InitStatus InitQa() override;
131
134 std::pair<std::string, bool> CheckRangePull(TH1* h) const;
135
140 const cbm::ca::HitQaData& GetHitQaData() const { return fHitQaData; }
141
144 bool IsTrackSelected(const CbmMCTrack* track, const Point_t* point) const;
145
147 bool IsHitAcceptable(const CbmPixelHit* pHit) const;
148
152 double mean = 0;
153 double lo = 0;
154 double hi = 0;
155 };
156
159 enum class EMonitorKey
160 {
161 kEvent,
162 kHit,
164 kMcPoint,
166 END
167 };
169
171
172
173 // ----- Input data branches
174
176
178
179 TClonesArray* fpHits = nullptr;
180 TClonesArray* fpClusters = nullptr;
181
186
187 TClonesArray* fpHitMatches = nullptr;
188
189 // ******************
190 // ** Parameters **
191 // ******************
192
193 static constexpr double kNAN = std::numeric_limits<double>::signaling_NaN();
194
195 // ----- Histogram binning parameters
196 int fNbins = 200;
197 int fNbinsZ = 800;
198
199 std::array<double, 2> fRHitDx = {kNAN, kNAN};
200 std::array<double, 2> fRHitDy = {kNAN, kNAN};
201 std::array<double, 2> fRHitDu = {kNAN, kNAN};
202 std::array<double, 2> fRHitDv = {kNAN, kNAN};
203 std::array<double, 2> fRHitDt = {kNAN, kNAN};
204
205 std::array<double, 2> fRResX = {kNAN, kNAN};
206 std::array<double, 2> fRResY = {kNAN, kNAN};
207 std::array<double, 2> fRResU = {kNAN, kNAN};
208 std::array<double, 2> fRResV = {kNAN, kNAN};
209 std::array<double, 2> fRResT = {kNAN, kNAN};
210
211 std::array<double, 2> fRangeDzHitPoint = {-0.05, 0.05};
212
213 // NOTE: Pull binning is fixed by convention, since it is used for hit finder calibrations. Please,
214 // do not modify!
215 // TODO: 29.05.2024 SZh: Put to a tuple <double, int, int>
216 static constexpr int kNbinsPull = 200;
217 static constexpr double kRPull[2] = {-10., 10.};
218
219 std::vector<double> frXmin;
220 std::vector<double> frXmax;
221 std::vector<double> frYmin;
222 std::vector<double> frYmax;
223 std::vector<double> frZmin;
224 std::vector<double> frZmax;
225
226
227 // ----- Histograms
228 //
229 // Hit occupancy
230 std::vector<TH2F*> fvph_hit_xy;
231 std::vector<TH2F*> fvph_hit_zx;
232 std::vector<TH2F*> fvph_hit_zy;
233
234 std::vector<TH1F*> fvph_hit_station_delta_z;
235
236 // Hit errors
237 std::vector<TH1F*> fvph_hit_dx;
238 std::vector<TH1F*> fvph_hit_dy;
239 std::vector<TH1F*> fvph_hit_du;
240 std::vector<TH1F*> fvph_hit_dv;
241 std::vector<TH1F*> fvph_hit_kuv;
242 std::vector<TH1F*> fvph_hit_dt;
243
244 // MC points occupancy
245 std::vector<TH1F*> fvph_n_points_per_hit;
246
247 std::vector<TH2F*> fvph_point_xy;
248 std::vector<TH2F*> fvph_point_zx;
249 std::vector<TH2F*> fvph_point_zy;
250
251 std::vector<TH1F*> fvph_point_hit_delta_z;
252
253 // Residuals
254 std::vector<TH1F*> fvph_res_x;
255 std::vector<TH1F*> fvph_res_y;
256 std::vector<TH1F*> fvph_res_u;
257 std::vector<TH1F*> fvph_res_v;
258 std::vector<TH1F*> fvph_res_t;
259
260 std::vector<TH2F*> fvph_res_x_vs_x;
261 std::vector<TH2F*> fvph_res_y_vs_y;
262 std::vector<TH2F*> fvph_res_u_vs_u;
263 std::vector<TH2F*> fvph_res_v_vs_v;
264 std::vector<TH2F*> fvph_res_t_vs_t;
265
266 // Pulls
267 std::vector<TH1F*> fvph_pull_x;
268 std::vector<TH1F*> fvph_pull_y;
269 std::vector<TH1F*> fvph_pull_u;
270 std::vector<TH1F*> fvph_pull_v;
271 std::vector<TH1F*> fvph_pull_t;
272
273 std::vector<TH2F*> fvph_pull_x_vs_x;
274 std::vector<TH2F*> fvph_pull_y_vs_y;
275 std::vector<TH2F*> fvph_pull_u_vs_u;
276 std::vector<TH2F*> fvph_pull_v_vs_v;
277 std::vector<TH2F*> fvph_pull_t_vs_t;
278
279 // Hit efficiencies
280 std::vector<TProfile2D*> fvpe_reco_eff_vs_xy;
281 std::vector<TH1F*> fvph_reco_eff;
282
283
284 // FIXME: change to private
285 protected:
287};
CA Tracking monitor class.
A helper class to store hit and MC-point parameter and calculate related quantities (header)
Class providing basic functionality for CA input QA-tasks.
Implementation of L1DetectorID enum class for CBM.
A base class for CBM QA task logic.
A QA-task class, which provides assurance of MuCh hits and geometry.
std::vector< TH1F * > fvph_point_hit_delta_z
difference between z of hit and MC point in different stations
std::array< double, 2 > fRangeDzHitPoint
Range for z-pos difference of the hit and point [cm].
virtual void DefineParameters()=0
Defines parameter for a derived class.
cbm::ca::HitQaData fHitQaData
Current hit QA data object.
std::vector< TH1F * > fvph_hit_du
std::vector< TH2F * > fvph_res_v_vs_v
residual for v coordinate in different stations
CbmTrackingDetectorInterfaceBase * fpDetInterface
Instance of detector interface.
std::vector< double > frYmin
Range for hit y coordinate [cm].
EMonitorKey
QA monitor counters.
virtual void FillHistogramsPerPoint()
Fills histograms per MC point.
TClonesArray * fpHits
Array of hits.
std::vector< TH2F * > fvph_res_u_vs_u
residual for u coordinate in different stations
std::vector< TH1F * > fvph_res_u
residual for u coordinate in different stations
std::vector< double > frXmax
Range for hit x coordinate [cm].
std::vector< TH1F * > fvph_pull_t
pull for t coordinate in different stations
void CreateSummary() override
Creates summary cavases, tables etc.
std::vector< TH1F * > fvph_n_points_per_hit
number of points per one hit in different stations
std::vector< TH2F * > fvph_hit_xy
hit y vs x in different stations
std::vector< double > frZmin
Range for hit z coordinate [cm].
std::vector< TH2F * > fvph_res_t_vs_t
residual for t coordinate in different stations
std::vector< TH1F * > fvph_hit_dt
std::vector< TH1F * > fvph_pull_y
pull for y coordinate in different stations
void ExecQa() override
Fills histograms per event or time-slice.
virtual ~CbmCaInputQaBase()=default
Destructor.
std::vector< TH1F * > fvph_hit_station_delta_z
Difference between station and hit z positions [cm].
std::vector< TH1F * > fvph_res_x
residual for x coordinate in different stations
std::vector< double > frXmin
Range for hit x coordinate [cm].
TClonesArray * fpClusters
Array of hit clusters.
std::pair< std::string, bool > CheckRangePull(TH1 *h) const
Checks ranges for mean and standard deviation.
std::vector< TH2F * > fvph_point_xy
point y vs x in different stations
std::vector< TH1F * > fvph_pull_v
pull for v coordinate in different stations
std::vector< TProfile2D * > fvpe_reco_eff_vs_xy
Efficiency of hit reconstruction vs. x and y coordinates of MC.
static constexpr int kNbinsPull
cbm::ca::PointTypes_t::at< DetID > Point_t
Point type for a given detector ID.
std::vector< TH2F * > fvph_hit_zx
hit x vs z in different stations
std::array< double, 2 > fRHitDt
Range for hit time error [ns].
std::vector< TH2F * > fvph_point_zy
point y vs z in different stations
std::array< double, 2 > fRHitDv
Range for hit v coordinate error [cm].
cbm::ca::HitTypes_t::at< DetID > Hit_t
Hit type for a given detector ID.
std::vector< double > frYmax
Range for hit y coordinate [cm].
CbmMCDataArray * fpMCPoints
Array of MC points.
std::vector< TH1F * > fvph_pull_u
pull for u coordinate in different stations
std::array< double, 2 > fRHitDy
Range for hit y coordinate error [cm].
CbmMCDataArray * fpMCTracks
Array of MC tracks.
std::vector< TH2F * > fvph_point_zx
point x vs z in different stations
std::vector< TH1F * > fvph_hit_dx
void Check() override
Method to check, if the QA results are acceptable.
cbm::algo::ca::Monitor< EMonitorKey > fMonitor
Monitor for the input QA.
std::vector< TH1F * > fvph_res_y
residual for y coordinate in different stations
const cbm::ca::HitQaData & GetHitQaData() const
Returns a pointer to current hit QA data object.
int fNbins
General number of bins.
TClonesArray * fpHitMatches
Array of hit matches.
std::array< double, 2 > fRResU
Range for residual of u coordinate [cm].
CbmMCDataManager * fpMCDataManager
MC data manager.
std::vector< TH2F * > fvph_pull_y_vs_y
pull for y coordinate in different stations
CbmMCEventList * fpMCEventList
MC event list.
std::vector< TH1F * > fvph_res_v
residual for v coordinate in different stations
std::vector< double > frZmax
Range for hit z coordinate [cm].
std::vector< TH1F * > fvph_res_t
residual for t coordinate in different stations
bool IsHitAcceptable(const CbmPixelHit *pHit) const
Checks, if the hit is acceptable (has reasonable parameters)
static constexpr double kRPull[2]
Range for pull histograms coordinate.
std::vector< TH1F * > fvph_reco_eff
Distribution of hit reconstruction efficiency in bins of fvpe_reco_eff_vs_xy.
CbmCaInputQaBase(const char *name, int verbose, bool isMCUsed)
Constructor from parameters.
std::vector< TH2F * > fvph_pull_v_vs_v
pull for v coordinate in different stations
int fNbinsZ
Number of bins for z axis in overall views.
std::vector< TH2F * > fvph_res_y_vs_y
residual for y coordinate in different stations
std::array< double, 2 > fRResY
Range for residual of y coordinate [cm].
std::vector< TH2F * > fvph_res_x_vs_x
residual for x coordinate in different stations
static constexpr double kNAN
std::array< double, 2 > fRHitDu
Range for hit u coordinate error [cm].
Config fConfig
Task specific configuration parameters.
std::array< double, 2 > fRResT
Range for residual of time [ns].
std::vector< TH2F * > fvph_hit_zy
hit y vs z in different stations
bool IsTrackSelected(const CbmMCTrack *track, const Point_t *point) const
checks if the track at mc point passes the track selection cuts
InitStatus InitQa() override
Initializes QA task.
std::vector< TH2F * > fvph_pull_u_vs_u
pull for u coordinate in different stations
std::vector< TH1F * > fvph_hit_kuv
std::vector< TH2F * > fvph_pull_x_vs_x
pull for x coordinate in different stations
std::vector< TH2F * > fvph_pull_t_vs_t
pull for t coordinate in different stations
std::vector< TH1F * > fvph_hit_dv
std::array< double, 2 > fRHitDx
Range for hit x coordinate error [cm].
std::vector< TH1F * > fvph_pull_x
pull for x coordinate in different stations
virtual void FillHistogramsPerHit()
Fills histograms per hit.
std::vector< TH1F * > fvph_hit_dy
CbmTimeSlice * fpTimeSlice
Pointer to current time-slice.
std::array< double, 2 > fRResX
Range for residual of x coordinate [cm].
std::array< double, 2 > fRResV
Range for residual of v coordinate [cm].
void DeInit() override
De-initializes histograms.
Access to a MC data branch for time-based analysis.
Task class creating and managing CbmMCDataArray objects.
Container class for MC events with number, file and start time.
data class for a reconstructed 3-d hit in the STS
Definition CbmStsHit.h:35
Data class with information on a STS local track.
Bookkeeping of time-slice content.
Abstract class, which should be inherited by every detecting subsystem tracking interface class.
Monitor class for the CA tracking.
Definition CaMonitor.h:35
Contains necessary data to calculate hit residuals and pulls.
EDetectorID
Enumeration for the tracking detector subsystems in CBM-CA.
Definition CbmDefs.h:176
CBM_YAML_PROPERTIES(Property(&McTrackCuts::fMinMom, "MinMom", "Minimal momentum at the exit of the station [GeV/c]"), Property(&McTrackCuts::fMaxTheta, "MaxTheta", "Maximal theta at the exit of the station [grad]"), Property(&McTrackCuts::fbPrimary, "IsPrimary", "Is track primary"))
bool fbPrimary
Must the track come from the primary vertex.
double fMinMom
Track momentum on the exit of the station [GeV/c].
double fMaxTheta
Track theta on the exit of the station [grad].
Specific configuration for the CA input QA task.
double fMaxDiffZStHit
Maximum allowed difference between z-position of hit and station [cm].
double fPullWidthThrsh
Maximum allowed deviation of pull width from unity.
double fPullMeanThrsh
Maximum allowed deviation of pull mean from zero.
CBM_YAML_PROPERTIES(Property(&Config::fMcTrackCuts, "McTrackCuts", "MC track cuts"), Property(&Config::fPullMeanThrsh, "PullMeanThrsh", "Pull mean threshold"), Property(&Config::fPullWidthThrsh, "PullWidthThrsh", "Pull width threshold"), Property(&Config::fEffThrsh, "EffThrsh", "Efficiency threshold"), Property(&Config::fMaxDiffZStHit, "MaxDiffZStHit", "Max difference between station and hit z"))
McTrackCuts fMcTrackCuts
MC-track selection cuts.
double fEffThrsh
Threshold for hit efficiency in the selected range.
Stores fit residuals result.
double mean
mean of the distribution
double hi
higher limit for the mean
double lo
lower limit for the mean
std::tuple_element_t< static_cast< std::size_t >(DetID), std::tuple< Types... > > at