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 "CbmRecoSetupManager.h"
21
22#include <TMath.h>
23
24#include <set>
25#include <unordered_map>
26#include <vector>
27
28class CbmMatch;
29class CbmMCEventList;
30class CbmMCDataArray;
32class CbmMCTrack;
33class CbmStsHit;
34class CbmStsPoint;
35class CbmTimeSlice;
36class FairMCPoint;
37class TClonesArray;
38class TH1F;
39class TH2F;
40class TProfile;
41class TProfile2D;
42class CbmDigiManager;
43
44namespace
45{
49} // namespace
50
54template<EDetectorID DetID>
56 protected:
59
62 struct Config {
65 struct McTrackCuts {
66 double fMinMom = 0.1;
67 double fMaxTheta = 60.;
68 bool fbPrimary = true;
69 /* clang-format off */
71 Property(&McTrackCuts::fMinMom, "MinMom", "Minimal momentum at the exit of the station [GeV/c]"),
72 Property(&McTrackCuts::fMaxTheta, "MaxTheta", "Maximal theta at the exit of the station [grad]"),
73 Property(&McTrackCuts::fbPrimary, "IsPrimary", "Is track primary")
74 );
75 /* clang-format on */
76 };
77
79 double fPullMeanThrsh = 0.1;
80 double fPullWidthThrsh = 2.0;
81 double fEffThrsh = 0.5;
82 double fMaxDiffZStHit = 1.0;
83 /* clang-format off */
85 Property(&Config::fMcTrackCuts, "McTrackCuts", "MC track cuts"),
86 Property(&Config::fPullMeanThrsh, "PullMeanThrsh", "Pull mean threshold"),
87 Property(&Config::fPullWidthThrsh, "PullWidthThrsh", "Pull width threshold"),
88 Property(&Config::fEffThrsh, "EffThrsh", "Efficiency threshold"),
89 Property(&Config::fMaxDiffZStHit, "MaxDiffZStHit", "Max difference between station and hit z")
90 );
91 /* clang-format on */
92 };
93
94 public:
99 CbmCaInputQaBase(const char* name, int verbose, bool isMCUsed);
100
102 virtual ~CbmCaInputQaBase() = default;
103
104 protected:
105 // ********************************************
106 // ** Virtual method override from CbmQaTask **
107 // ********************************************
108
111 void Check() override;
112
114 void CreateSummary() override;
115
117 virtual void FillHistogramsPerHit() {}
118
120 virtual void FillHistogramsPerPoint() {}
121
123 void DeInit() override;
124
126 virtual void DefineParameters() = 0;
127
129 void ExecQa() override;
130
132 InitStatus InitQa() override;
133
136 std::pair<std::string, bool> CheckRangePull(TH1* h) const;
137
142 const cbm::ca::HitQaData& GetHitQaData() const { return fHitQaData; }
143
146 bool IsTrackSelected(const CbmMCTrack* track, const Point_t* point) const;
147
149 bool IsHitAcceptable(const CbmPixelHit* pHit) const;
150
154 double mean = 0;
155 double lo = 0;
156 double hi = 0;
157 };
158
171
173
174
175 // ----- Input data branches
176
177 const cbm::algo::RecoSetupUnit_t<ToCbmModuleId(DetID)>* fpDetInterface = nullptr;
178
179 static constexpr auto DetName = cbm::algo::RecoSetupUnit_t<ToCbmModuleId(DetID)>::GetDetectorName();
180
182
183 TClonesArray* fpHits = nullptr;
184 TClonesArray* fpClusters = nullptr;
185
190
191 TClonesArray* fpHitMatches = nullptr;
192
193 // ******************
194 // ** Parameters **
195 // ******************
196
197 static constexpr double kNAN = std::numeric_limits<double>::signaling_NaN();
198
199 // ----- Histogram binning parameters
200 int fNbins = 200;
201 int fNbinsZ = 800;
202
203 std::array<double, 2> fRHitDx = {kNAN, kNAN};
204 std::array<double, 2> fRHitDy = {kNAN, kNAN};
205 std::array<double, 2> fRHitDu = {kNAN, kNAN};
206 std::array<double, 2> fRHitDv = {kNAN, kNAN};
207 std::array<double, 2> fRHitDt = {kNAN, kNAN};
208
209 std::array<double, 2> fRResX = {kNAN, kNAN};
210 std::array<double, 2> fRResY = {kNAN, kNAN};
211 std::array<double, 2> fRResU = {kNAN, kNAN};
212 std::array<double, 2> fRResV = {kNAN, kNAN};
213 std::array<double, 2> fRResT = {kNAN, kNAN};
214
215 std::array<double, 2> fRangeDzHitPoint = {-0.05, 0.05};
216
217 // NOTE: Pull binning is fixed by convention, since it is used for hit finder calibrations. Please,
218 // do not modify!
219 // TODO: 29.05.2024 SZh: Put to a tuple <double, int, int>
220 static constexpr int kNbinsPull = 200;
221 static constexpr double kRPull[2] = {-10., 10.};
222
223 std::vector<double> frXmin;
224 std::vector<double> frXmax;
225 std::vector<double> frYmin;
226 std::vector<double> frYmax;
227 std::vector<double> frZmin;
228 std::vector<double> frZmax;
229
230
231 // ----- Histograms
232 //
233 // Hit occupancy
234 std::vector<TH2F*> fvph_hit_xy;
235 std::vector<TH2F*> fvph_hit_zx;
236 std::vector<TH2F*> fvph_hit_zy;
237
238 std::vector<TH1F*> fvph_hit_station_delta_z;
239
240 // Hit errors
241 std::vector<TH1F*> fvph_hit_dx;
242 std::vector<TH1F*> fvph_hit_dy;
243 std::vector<TH1F*> fvph_hit_du;
244 std::vector<TH1F*> fvph_hit_dv;
245 std::vector<TH1F*> fvph_hit_kuv;
246 std::vector<TH1F*> fvph_hit_dt;
247
248 // MC points occupancy
249 std::vector<TH1F*> fvph_n_points_per_hit;
250
251 std::vector<TH2F*> fvph_point_xy;
252 std::vector<TH2F*> fvph_point_zx;
253 std::vector<TH2F*> fvph_point_zy;
254
255 std::vector<TH1F*> fvph_point_hit_delta_z;
256
257 // Residuals
258 std::vector<TH1F*> fvph_res_x;
259 std::vector<TH1F*> fvph_res_y;
260 std::vector<TH1F*> fvph_res_u;
261 std::vector<TH1F*> fvph_res_v;
262 std::vector<TH1F*> fvph_res_t;
263
264 std::vector<TH2F*> fvph_res_x_vs_x;
265 std::vector<TH2F*> fvph_res_y_vs_y;
266 std::vector<TH2F*> fvph_res_u_vs_u;
267 std::vector<TH2F*> fvph_res_v_vs_v;
268 std::vector<TH2F*> fvph_res_t_vs_t;
269
270 // Pulls
271 std::vector<TH1F*> fvph_pull_x;
272 std::vector<TH1F*> fvph_pull_y;
273 std::vector<TH1F*> fvph_pull_u;
274 std::vector<TH1F*> fvph_pull_v;
275 std::vector<TH1F*> fvph_pull_t;
276
277 std::vector<TH2F*> fvph_pull_x_vs_x;
278 std::vector<TH2F*> fvph_pull_y_vs_y;
279 std::vector<TH2F*> fvph_pull_u_vs_u;
280 std::vector<TH2F*> fvph_pull_v_vs_v;
281 std::vector<TH2F*> fvph_pull_t_vs_t;
282
283 // Hit efficiencies
284 std::vector<TProfile2D*> fvpe_reco_eff_vs_xy;
285 std::vector<TH1F*> fvph_reco_eff;
286
288
289 // FIXME: change to private
290 protected:
292};
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 manager for setup representation in CBM reconstruction.
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
static constexpr auto DetName
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
CbmDigiManager * fDigiManager
Interface to digi branches.
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
const cbm::algo::RecoSetupUnit_t< ToCbmModuleId(DetID)> * fpDetInterface
Instance of detector interface.
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.
CbmDigiManager.
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.
CbmQaTask(const char *name, int verbose, bool isMCUsed, ECbmRecoMode recoMode=ECbmRecoMode::Timeslice)
Constructor from parameters.
Definition CbmQaTask.cxx:32
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.
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:216
typename detail::RecoSetupUnitMapper< ModuleId >::type RecoSetupUnit_t
Definition RecoSetup.h:50
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