PandaRoot
PndTrackingQARecoInfo.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
20 #pragma once
21 
23 
24 #include "TVector3.h"
25 #include "TString.h"
26 #include "TObject.h"
27 
28 #include "FairLink.h"
29 
30 #include <map>
31 #include <array>
32 #include <iostream>
33 #include <functional>
34 
36 
37 class PndTrackingQARecoInfo : public TObject {
38  public:
40  PndTrackingQARecoInfo(FairLink recoTrackID) : fRecoTrackID(recoTrackID) {}
41 
42  virtual ~PndTrackingQARecoInfo();
43 
45 
46  Int_t GetTrueHits();
47  Int_t GetTrueHits(TString branch) { return GetTrueHits(TrackingQA::StringToBranchEnum(branch)); }
49  {
50  if (branch == TrackingQA::branchEnum::STTHit) {
51  return (fTrueHitsCollection[TrackingQA::branchEnum::STTHitSkew] + fTrueHitsCollection[TrackingQA::branchEnum::STTHitParal]);
52  } else {
53  return fTrueHitsCollection[branch];
54  }
55  }
56  Int_t GetFalseHits();
57  Int_t GetFalseHits(TString branch) { return GetFalseHits(TrackingQA::StringToBranchEnum(branch)); }
59  {
60  if (branch == TrackingQA::branchEnum::STTHit) {
61  return (fFalseHitsCollection[TrackingQA::branchEnum::STTHitSkew] + fFalseHitsCollection[TrackingQA::branchEnum::STTHitParal]);
62  } else {
63  return fFalseHitsCollection[branch];
64  }
65  }
66  Int_t GetMissingHits();
67  Int_t GetMissingHits(TString branch) { return GetMCHits(branch) - GetTrueHits(branch); }
69  Int_t GetMCHits();
70  Int_t GetMCHits(TString branch)
71  {
72  if (branch == "STTHit") {
73  return fMCHitsCollection[TrackingQA::branchEnum::STTHitParal] + fMCHitsCollection[TrackingQA::branchEnum::STTHitSkew];
74  }
75  return fMCHitsCollection[TrackingQA::StringToBranchEnum(branch)];
76  }
77 
78  Int_t GetMCHits(TrackingQA::branchEnum branch);
79 
80  Int_t GetRecoHits() { return GetTrueHits() + GetFalseHits(); }
81  Int_t GetRecoHits(TString branch) { return GetTrueHits(branch) + GetFalseHits(branch); }
82 
83  double GetEfficiency()
84  {
85  if (GetMCHits() > 0) {
86  return (double)GetTrueHits() / GetMCHits();
87  } else
88  return -1.;
89  }
90 
91  double GetEfficiency(TString branch)
92  {
93  if (GetMCHits(branch) > 0) {
94  return (double)GetTrueHits(branch) / GetMCHits(branch);
95  } else
96  return -1.;
97  }
98 
100 
101  double GetPurity()
102  {
103  if (GetRecoHits() > 0) {
104  return (double)GetTrueHits() / GetRecoHits();
105  } else
106  return -1.;
107  }
108 
109  double GetPurity(TString branch)
110  {
111  if (GetRecoHits(branch) > 0) {
112  return (double)GetTrueHits(branch) / GetRecoHits(branch);
113  } else
114  return -1.;
115  }
116 
117  double GetPurity(TrackingQA::branchEnum branch);
118 
119  void SetQuality(int val) { fQuality = val; }
120  int GetQuality() const { return fQuality; }
121  int GetMCQuality() const { return fMCQuality; }
122 
123  void SetMCVertex(TVector3 pos) { fMCVertex = pos; }
124  void SetMCMomentum(TVector3 mom) { fMCMomentum = mom; }
125 
126  void SetPositionFirst(TVector3 pos) { fPosFirst = pos; }
127  void SetMomentumFirst(TVector3 mom) { fMomFirst = mom; }
128  void SetPositionLast(TVector3 pos) { fPosLast = pos; }
129  void SetMomentumLast(TVector3 mom) { fMomLast = mom; }
130 
131  TVector3 GetPositionFirst() const { return fPosFirst; }
132  TVector3 GetMomentumFirst() const { return fMomFirst; }
133  TVector3 GetPositionLast() const { return fPosLast; }
134  TVector3 GetMomentumLast() const { return fMomLast; }
135 
136  TVector3 GetMCPositionFirst() const { return fMCPosFirst; }
137  TVector3 GetMCMomentumFirst() const { return fMCMomFirst; }
138  TVector3 GetMCPositionLast() const { return fMCPosLast; }
139  TVector3 GetMCMomentumLast() const { return fMCMomLast; }
140 
141  void SetCharge(int ch) { fCharge = ch; }
142  Int_t GetCharge() const { return fCharge; }
143 
144  void SetMCCharge(int ch) { fMCCharge = ch; }
145  Int_t GetMCCharge() const { return fMCCharge; }
146 
147  void SetTrueHits(TString branch, int hits) { fTrueHitsCollection[TrackingQA::StringToBranchEnum(branch)] = hits; }
148  void SetFalseHits(TString branch, int hits) { fFalseHitsCollection[TrackingQA::StringToBranchEnum(branch)] = hits; }
149  void SetMCTrueHits(TString branch, int hits) { fMCHitsCollection[TrackingQA::StringToBranchEnum(branch)] = hits; }
150 
151  void SetIdealTrackId(FairLink idealid) { fIdealTrackId = idealid; }
152  FairLink GetIdealTrackId() const { return fIdealTrackId; }
153 
154  void SetMCTrackID(FairLink mctrackid) { fMCTrackID = mctrackid; }
155  FairLink GetMCTrackID() const { return fMCTrackID; }
156 
157  void SetFitStatusFlag(int flag) { fFitStatusFlag = flag; }
158  Int_t GetFitStatusFlag() const { return fFitStatusFlag; }
159 
160  void SetRecoTrackID(FairLink link) { fRecoTrackID = link; }
161  FairLink GetRecoTrackID() const { return fRecoTrackID; }
162 
163  void SetIsClone(Bool_t val) { fIsClone = val; }
164  Bool_t IsClone() { return fIsClone; }
165 
166  void SetNofMCTracks(Int_t val) { fNofMCTracks = val; }
167  Int_t GetNofMCTracks() const { return fNofMCTracks; }
168 
169  friend std::ostream &operator<<(std::ostream &os, PndTrackingQARecoInfo &recoInfo)
170  {
171  os << "RecoTrack: " << recoInfo.GetRecoTrackID() << " RecoQuality " << recoInfo.GetQuality() << " MCTrackID " << recoInfo.GetMCTrackID()
172  << " MCQuality: " << recoInfo.GetMCQuality() << std::endl;
173  os << "Purity: " << recoInfo.GetPurity() << " Efficiency: " << recoInfo.GetEfficiency() << std::endl;
174  std::cout << "BranchName : trueHits/falseHits/mcHits/missingHits : Efficiency/Purity" << std::endl;
175  for (auto tHits : recoInfo.fTrueHitsCollection) {
176  os << TrackingQA::BranchEnumToString(tHits.first) << " : " << tHits.second << "/" << recoInfo.GetFalseHits(tHits.first) << "/" << recoInfo.GetMCHits(tHits.first) << "/"
177  << recoInfo.GetMissingHits(tHits.first) << " ";
178  os << recoInfo.GetEfficiency(tHits.first) << "/" << recoInfo.GetPurity(tHits.first) << std::endl;
179  }
180  return os;
181  }
182 
183  private:
184  std::map<TrackingQA::branchEnum, Int_t> fTrueHitsCollection;
185  std::map<TrackingQA::branchEnum, Int_t> fFalseHitsCollection;
186  std::map<TrackingQA::branchEnum, Int_t> fMCHitsCollection;
187 
188  FairLink fRecoTrackID;
189  TVector3 fPosFirst, fMomFirst;
190  TVector3 fPosLast, fMomLast;
191 
192  Bool_t fIsClone = kFALSE;
193 
194  Int_t fNofMCTracks = 0;
195  FairLink fIdealTrackId;
196 
197  TVector3 fMCMomFirst;
198  TVector3 fMCMomLast;
199  TVector3 fMCPosFirst;
200  TVector3 fMCPosLast;
201  TVector3 fMCVertex;
202  TVector3 fMCMomentum;
203  Int_t fMCCharge = -100;
204  Int_t fMCPdg = 0;
205 
206  Bool_t fIsPrimary = kFALSE;
207  Int_t fQuality = -100;
208  Int_t fMCQuality = -100;
209  Int_t fCharge = -100;
210  FairLink fMCTrackID;
211 
212  Int_t fFitStatusFlag = 0;
213 
214  ClassDef(PndTrackingQARecoInfo, 7);
215 };
void SetTrueHits(TString branch, int hits)
Int_t GetTrueHits(TrackingQA::branchEnum branch)
void SetMomentumLast(TVector3 mom)
void SetMCVertex(TVector3 pos)
TVector3 GetMCPositionLast() const
void SetPositionFirst(TVector3 pos)
Int_t GetMCHits(TString branch)
Int_t GetFalseHits(TString branch)
TVector3 GetMomentumFirst() const
void SetMCTrueHits(TString branch, int hits)
void SetFalseHits(TString branch, int hits)
friend std::ostream & operator<<(std::ostream &os, PndTrackingQARecoInfo &recoInfo)
void SetMCMomentum(TVector3 mom)
TVector3 GetMCMomentumFirst() const
double GetPurity(TString branch)
double GetEfficiency(TString branch)
TVector3 GetMCPositionFirst() const
void SetPositionLast(TVector3 pos)
TVector3 GetPositionLast() const
TVector3 GetMomentumLast() const
virtual ~PndTrackingQARecoInfo()
PndTrackingQARecoInfo(FairLink recoTrackID)
void SetMCTrackInfo(PndTrackingQAMCInfo *info)
void SetMCTrackID(FairLink mctrackid)
TVector3 GetMCMomentumLast() const
FairLink GetIdealTrackId() const
Int_t GetTrueHits(TString branch)
branchEnum StringToBranchEnum(TString branchString)
Int_t GetFalseHits(TrackingQA::branchEnum branch)
Int_t GetRecoHits(TString branch)
void SetRecoTrackID(FairLink link)
void SetIdealTrackId(FairLink idealid)
TVector3 GetPositionFirst() const
void SetMomentumFirst(TVector3 mom)
FairLink GetRecoTrackID() const
Int_t GetMissingHits(TString branch)
TString BranchEnumToString(branchEnum branch)