CbmRoot
Loading...
Searching...
No Matches
CbmRecoQaTask.h
Go to the documentation of this file.
1/* Copyright (C) 2024 Hulubei National Institute of Physics and Nuclear Engineering - Horia Hulubei, Bucharest
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Alexandru Bercuci [committer], Omveer Singh */
4
5#ifndef CBMRECOQATASK_H
6#define CBMRECOQATASK_H 1
7
8#include "CbmKfTrackFitter.h"
9#include "CbmTrack.h"
10
11#include <FairTask.h>
12
13#include <TDirectoryFile.h>
14#include <TGeoNode.h>
15
16#include <bitset>
17#include <map>
18#include <vector>
19
20class FairMCPoint;
21class CbmEvent;
22class CbmHit;
24class CbmMCDataArray;
25class CbmTimeSlice;
26class TClonesArray;
27class TH2;
28class TH2D;
29class TVector3;
30class CbmRecoQaTask : public FairTask {
31 public:
44 enum eSetup
45 {
49 };
50 enum class eViewType : int
51 {
52 kDetUnit = 0,
53 kTrkProj,
54 kPV
55 };
56
57#define kNtrkProjections 6
58 enum class eProjectionType : int
59 {
60 kXYa = 0,
61 kXYp,
62 kXdX,
63 kXdXMC,
64 kYdY,
65 kYdYMC,
66 kWdT,
68 kXpX,
69 kYpY,
70 kChdT,
71 kXYh,
72 kDmult,
73 kDmultMC,
74 kXYhMC,
75 kPullX,
76 kPullY,
81 kPVxy,
82 kPVxz,
83 kPVyz,
84 kPVmult,
85 kXYt0,
86 kXYt1,
87 kXYt2,
88 kXYt3,
89 kXYt4,
90 kXYt5
91 };
92
93 // Generic view definition
94 struct Detector;
95 struct View {
96 friend struct Detector;
97 friend class CbmRecoQaTask;
98
99 View() = default;
100 View(const char* n, const char* p, std::vector<int> set) : name(n), path(p), fSelector(set) { ; }
101 virtual ~View() = default;
102 bool SetProjection(eProjectionType prj, float range, const char* unit);
103 template<class Hit>
104 bool HasAddress(const CbmHit* h, double& x, double& y, double& dx, double& dy) const;
105 template<class Hit>
106 bool Load(const CbmHit* h, const FairMCPoint* point, const CbmEvent* ev);
107 bool Load(const CbmKfTrackFitter::TrajectoryNode* n, const FairMCPoint* point);
108 bool Load(TVector3* p);
109 std::string ToString() const;
110 static std::string ToString(eProjectionType prj);
111 void SetSetup(CbmRecoQaTask::eSetup setup) { fSetup = setup; }
113
114 std::string name = "";
115 std::string path = "";
116 double size[3] = {0.};
117 double pos[3] = {0.};
118 std::vector<int> fSelector = {};
119 std::map<eProjectionType, std::tuple<int, float, TH2*>> fProjection =
120 {};
123 int fMult = 0;
126
127 protected:
128 bool AddProjection(eProjectionType prj, float range = -1, const char* unit = "cm");
133 bool Init(const char* dname, bool mc = false);
136 uint Register(TDirectoryFile* f);
142 std::string makeTrange(const int scale, float& range);
143 std::string makeYrange(const int scale, float& range);
145 1); // Stand-alone detection set to which QA is applied
146 }; // QA View definition
147
148 // Detector unit definition
149 struct Detector {
150 struct Data {
151 Data() = default;
152 Data(ECbmDataType i, const char* n) : id(i), name(n) { ; }
154 std::string name = "nn";
155 }; // Identifier of data to be monitored
156
158 virtual ~Detector() = default;
159 View* AddView(const char* n, const char* p, std::vector<int> set);
160 View* GetView(const char* n);
161 View* FindView(double x, double y, double z);
166 bool Init(TDirectoryFile* f, bool mc = false);
167 void Print() const;
168
172 std::vector<View> fViews = {};
173
175 1); // QA representation of a detector unit
176 }; // Detection system agregate
177
178 struct TrackFilter {
179 enum class eTrackCut : int
180 {
181 kSts = 0,
182 kMuch,
183 kRich,
184 kTrd,
185 kTof,
186 kNone
187 };
189 virtual ~TrackFilter() = default;
190 bool Accept(const CbmGlobalTrack* ptr, const CbmRecoQaTask* lnk);
191 bool SetFilter(std::vector<float> cuts);
192 std::string ToString() const;
193
195
196 private:
197 // STS definition of track
198 int fNSts = -1;
199 std::vector<bool> fStsHits = {};
200 // TRD definition of track
201 int fNTrd = -1;
202 // ToF definition of track
203 int fNTof = -1;
204 ClassDef(CbmRecoQaTask::TrackFilter, 1); // Track cut implementation
205 }; // TrackFilter definition
206
207 struct EventFilter {
208 enum class eEventCut : int
209 {
210 kMultTrk = 0,
211 kMultHit,
212 kTrigger,
213 kVertex,
214 kNone
215 };
216 enum class eEventDef : int
217 {
218 kNofDetHit = 3
219 };
221 virtual ~EventFilter() = default;
222 bool Accept(const CbmEvent* ptr, const CbmRecoQaTask* lnk);
223 bool SetFilter(std::vector<float> cuts);
224 std::string ToString() const;
225
227
228 private:
229 // track multiplicity cut definition
230 int fMinTrack = 0;
231 int fMaxTrack = 0;
232 // hit multiplicity cut definition
234
236 void HelpMess() const;
237
238 ClassDef(CbmRecoQaTask::EventFilter, 1); // Event cut implementation
239 }; // EventFilter definition
240
241 public:
243 virtual ~CbmRecoQaTask() { ; }
246 virtual Detector* AddDetector(ECbmModuleId did);
247 virtual EventFilter* AddEventFilter(EventFilter::eEventCut cut);
248 virtual TrackFilter* AddTrackFilter(TrackFilter::eTrackCut cut);
249 virtual Detector* GetDetector(ECbmModuleId did);
255 virtual const CbmTrack* GetTrack(ECbmModuleId did, int id) const;
257 virtual InitStatus Init();
259 virtual void Exec(Option_t* option);
260
261 virtual void Finish();
262
263 // /** \brief Define the set of extra z positions where the track should be
264 // * projected in the x-y plane */
265 // void SetProjections(std::vector<double> vzpj);
267 TString GetGeoTagForDetector(const TString& detector);
268 std::vector<TString> GetPath(TGeoNode* node, TString, TString activeNodeName, int depth = 0,
269 const TString& path = "");
270 void UseMC(bool set = true)
271 {
272 if (set) fuRecoConfig.set(kUseMC);
273 }
274
275 protected:
276 static std::bitset<kRecoQaNConfigs> fuRecoConfig;
277
278 private:
281
286 virtual bool FilterEvent(const CbmEvent* ptr);
291 virtual bool FilterTrack(const CbmGlobalTrack* ptr);
293 int GetNviews(eViewType type) const;
295 void InitMcbm22();
296 void InitMcbm24();
297 void InitDefault();
298
300 TClonesArray* fGTracks = nullptr;
301 std::map<ECbmModuleId, TClonesArray*> fTracks = {};
302 TClonesArray* fTrackMatches = nullptr;
303 TClonesArray* fEvents = nullptr;
305 std::map<ECbmModuleId, TClonesArray*> fHits = {};
306 std::map<ECbmModuleId, CbmMCDataArray*> fPoints = {};
307 std::map<ECbmModuleId, TClonesArray*> fHitMatch = {};
308 std::vector<EventFilter> fFilterEv = {};
309 std::vector<TrackFilter> fFilterTrk = {};
311 TDirectoryFile fOutFolder = {"RecoQA", "CA track driven reco QA"};
313 std::map<ECbmModuleId, Detector> fDetQa = {};
314 std::map<const char*, View> fViews = {};
315 std::vector<TVector3> fPrjPlanes = {};
316
317 ClassDef(CbmRecoQaTask, 1); // Reconstruction QA analyzed from CA perspective
318};
319
320#endif // CBMRECOQATASK_H
ECbmDataType
Definition CbmDefs.h:90
ECbmModuleId
Definition CbmDefs.h:39
@ kNotExist
If not found.
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
Access to a MC data branch for time-based analysis.
Task class creating and managing CbmMCDataArray objects.
CbmMCDataManager * cbm_mc_manager
std::vector< TVector3 > fPrjPlanes
list of QA views
void UseMC(bool set=true)
ClassDef(CbmRecoQaTask, 1)
local storage for the z positions of track projection planes
virtual bool FilterEvent(const CbmEvent *ptr)
Filter events for QA use (e.g. event multiplicity)
std::map< ECbmModuleId, TClonesArray * > fHitMatch
mc points
int GetNviews(eViewType type) const
count views types registered with the task
virtual EventFilter * AddEventFilter(EventFilter::eEventCut cut)
virtual Detector * GetDetector(ECbmModuleId did)
std::map< ECbmModuleId, CbmMCDataArray * > fPoints
reconstructed hits
CbmRecoQaTask & operator=(const CbmRecoQaTask &)
CbmRecoQaTask(const CbmRecoQaTask &)
TClonesArray * fGTracks
TClonesArray * fEvents
MC info for the global tracks.
static std::bitset< kRecoQaNConfigs > fuRecoConfig
std::map< ECbmModuleId, Detector > fDetQa
virtual void Exec(Option_t *option)
Executed task.
std::map< ECbmModuleId, TClonesArray * > fHits
Time slice info.
std::vector< EventFilter > fFilterEv
reconstructed hits
std::vector< TrackFilter > fFilterTrk
@ kPVyz
x-z projection of the primary vertex:
@ kXYh
Time to EV residuals as function of coordinate in view.
@ kPVxy
Residual distribution T:
@ kResidualX
Pull distribution Y:
@ kDmult
X-Y hit coorelation in local view.
@ kXYt3
X-Y track projections on a random plane (value 2)
@ kXYt5
X-Y track projections on a random plane (value 4)
@ kXYhMC
local view MC point multiplicity
@ kYpY
X to TRK pulls as function of local X in view.
@ kXYt1
X-Y track projections on a random plane (value 0)
@ kYdYMC
Y to TRK residuals as function of local Y in view.
@ kResidualY
Residual distribution X: (x_RC - x_MC) in cm.
@ kPullX
X-Y MC point coorelation in local view (using HitMatch)
@ kResidualTX
Residual distribution Y:
@ kXYt0
y-z projection of the primary vertex:
@ kXYt2
X-Y track projections on a random plane (value 1)
@ kResidualTY
Residual distribution T:
@ kXdX
X-Y track projections on detection unit.
@ kPullY
Pull distribution X: (RC - MC) / dx_RC.
@ kXYp
X-Y hit coorelation in track filtered data.
@ kPVmult
y-z projection of the primary vertex:
@ kYdY
X to TRK residuals w.r.t MC points.
@ kXdXMC
X to TRK residuals as function of local X in view.
@ kWdT
Y to TRK residuals w.r.t MC points.
@ kPVxz
x-y projection of the primary vertex:
@ kXYt4
X-Y track projections on a random plane (value 3)
@ kDmultMC
local view hit multiplicity
@ kChdT
Y to TRK pulls as function of local Y in view.
CbmKfTrackFitter fFitter
CbmTimeSlice * fTimeSlice
reconstructed events
virtual bool FilterTrack(const CbmGlobalTrack *ptr)
Filter tracks for further use (e.g. track projections)
@ kTrdHits
has STS hits (StsHit branch)
@ kMuchHits
has Rich hits (RichHit branch)
@ kUseMC
has Much hits (MuchHit branch)
@ kRichHits
has ToF hits (TofHit branch)
@ kRecoQaNConfigs
use MC even if available
@ kStsHits
has tracks reconstructed (GlobalTrack branch)
@ kRecoTracks
has events reconstructed (CbmEvent branch)
@ kTofHits
has TRD` hits (TrdHit branch)
void SetSetupClass(CbmRecoQaTask::eSetup setup)
Define the set of extra z positions where the track should be projected in the x-y plane.
virtual InitStatus Init()
Perform initialization of data sources and projections.
std::map< ECbmModuleId, TClonesArray * > fTracks
reconstructed global tracks / event
TString GetGeoTagForDetector(const TString &detector)
std::vector< TString > GetPath(TGeoNode *node, TString, TString activeNodeName, int depth=0, const TString &path="")
@ kPV
set of track projection views
@ kTrkProj
detector view
virtual const CbmTrack * GetTrack(ECbmModuleId did, int id) const
Retrieve detector specific track by index.
virtual ~CbmRecoQaTask()
std::map< const char *, View > fViews
list of detector QA
TClonesArray * fTrackMatches
reconstructed global tracks / event
virtual TrackFilter * AddTrackFilter(TrackFilter::eTrackCut cut)
virtual Detector * AddDetector(ECbmModuleId did)
TDirectoryFile fOutFolder
virtual void Finish()
void InitMcbm22()
build QA plots for particular setups
Data class with information on a STS local track.
Bookkeeping of time-slice content.
Data(ECbmDataType i, const char *n)
View * GetView(const char *n)
Detector(ECbmModuleId did=ECbmModuleId::kNotExist)
View * FindView(double x, double y, double z)
std::vector< View > fViews
virtual ~Detector()=default
ClassDef(CbmRecoQaTask::Detector, 1)
View * AddView(const char *n, const char *p, std::vector< int > set)
void HelpMess() const
max no of hits/ev for the systems [STS TRD ToF]
std::string ToString() const
int fMultHit[(int) eEventDef::kNofDetHit]
ClassDef(CbmRecoQaTask::EventFilter, 1)
virtual ~EventFilter()=default
bool SetFilter(std::vector< float > cuts)
bool Accept(const CbmEvent *ptr, const CbmRecoQaTask *lnk)
EventFilter(eEventCut typ=eEventCut::kNone)
@ kNone
cut on vertex definition
@ kVertex
cut on trigger conditions
@ kMultHit
cut on track multiplicity
@ kTrigger
cut on hit multiplicity
std::vector< bool > fStsHits
virtual ~TrackFilter()=default
bool Accept(const CbmGlobalTrack *ptr, const CbmRecoQaTask *lnk)
std::string ToString() const
TrackFilter(eTrackCut typ=eTrackCut::kNone)
bool SetFilter(std::vector< float > cuts)
@ kNone
cut on no of Tof hits / track
@ kTrd
cut on no of Rich hits / track
@ kTof
cut on no of TRD hits / track
@ kMuch
cut on no of STS hits / track
@ kRich
cut on no of Much hits / track
ClassDef(CbmRecoQaTask::TrackFilter, 1)
bool AddProjection(eProjectionType prj, float range=-1, const char *unit="cm")
virtual ~View()=default
std::string makeYrange(const int scale, float &range)
bool Load(const CbmHit *h, const FairMCPoint *point, const CbmEvent *ev)
std::vector< int > fSelector
detection element center x0 y0 z0
ClassDef(CbmRecoQaTask::View, 1)
View(const char *n, const char *p, std::vector< int > set)
void SetSetup(CbmRecoQaTask::eSetup setup)
uint Register(TDirectoryFile *f)
build directory structure for all projections of current view.
void SetType(CbmRecoQaTask::eViewType type)
std::string makeTrange(const int scale, float &range)
helper functions to estimate the representation (y) axis
double pos[3]
detection element geometrical dx dy dz dimmensions
std::map< eProjectionType, std::tuple< int, float, TH2 * > > fProjection
defining subset of the address set for this view
bool HasAddress(const CbmHit *h, double &x, double &y, double &dx, double &dy) const
Hit classification on system and view.
eSetup fSetup
multiplicity between 2 reset signals
double size[3]
path to the geo volume describing the module
bool SetProjection(eProjectionType prj, float range, const char *unit)
std::string ToString() const