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