FairRoot/PandaRoot
PndTrackingQA.h
Go to the documentation of this file.
1 /*
2  * PndTrackingQA.h
3  *
4  * Created on: Aug 23, 2013
5  * Author: stockman
6  */
7 
8 #ifndef PndTrackingQA_H_
9 #define PndTrackingQA_H_
10 
11 #include "FairMultiLinkedData.h"
12 #include "FairRootManager.h"
13 
14 #include "PndTrackCand.h"
16 
17 #include <TObject.h>
18 #include <TString.h>
19 #include <TClonesArray.h>
20 
21 #include <vector>
22 #include <map>
23 
24 #include <functional>
25 #include "PndTrackFunctor.h"
26 
27 
40  static const int
41  // Following: Default statuses.
42  // Are the 'not found' tracks in the quality histogram of PndTrackingQualityTask.
43  kPossibleSec = -1, // possible: As defined through the possibleFunctor; secondary: a non-primary particle
44  kPossiblePrim = -2, // possible: As defined through the possibleFunctor; primary: coming directly from particle generator (e.g. EvtGen)
45  kAtLeastThreeSec = -3, // atLeastThree: min. 3 hit points in central tracking detectors (MVD, STT, GEM); secondary: a non-primary particle
46  kAtLeastThreePrim = -4, // atLeastThree: min. 3 hit points in central tracking detectors (MVD, STT, GEM); primary: coming directly from particle generator (e.g. EvtGen)
47  kLessThanThreePrim = -5, // LessThanThree: fewer than 3 hit points in central tracking detectors (MVD, STT, GEM); primar: coming directly from particle generator (e.g. EvtGen)
48 
49  // Following: MC statuses of all (found+notfound) tracks
50  kMcPossibleSec = -7, // see above
55  kMcAllTracksWithHits = -12, // sum of -7 - -10
56  kMcAllTracks = -13, // sum of -11 and -12
57 
58  // Following: Status of reconstructed tracks (= created PndTracks)
59  kSpuriousFound = 1, // spuriousFound: at least 70% of hits of reco'd track come from one MC track ('mostProbableTrack')
60  kPartiallyFound = 2, // partiallyFound: all hits of reco'd track come from one single MC track; at least 70% of hits of MC track have been found in reco'd track
61  kFullyFound = 3, // fullyFound: all hits of reco'd track come from one single MC track; all hits of MC track have been found in reco'd track
62 
63  kGhost = 5, // ghost: less than 70% of hits of reco'd track come from one MC track ('mostProbableTrack')
64 
65  kNotFound = 7, // notFound: total number of not reco'd tracks
66  kFound = 8; // found: total number of reco'd tracks; the sum of fullyFound, partiallyFound, spuriousFound
67 
68  static std::string QualityNumberToString(int qNumber)
69  {
70  if (qNumber == kPossiblePrim) return "PossiblePrimary";
71  if (qNumber == kPossibleSec) return "PossibleSec";
72  if (qNumber == kAtLeastThreeSec) return "AtLeastThreeSec";
73  if (qNumber == kAtLeastThreePrim) return "AtLeastThreePrim";
74  if (qNumber == kLessThanThreePrim) return "LessThanThreePrim";
75  if (qNumber == kMcPossibleSec) return "McPossibleSec";
76  if (qNumber == kMcAtLeastThreeSec) return "McAtLeastThreeSec";
77  if (qNumber == kMcAtLeastThreePrim) return "McAtLeastThreePrim";
78  if (qNumber == kMcLessThanThreePrim) return "McLessThanThreePrim";
79  if (qNumber == kMcAllTracksWithHits) return "McAllTracksWithHits";
80  if (qNumber == kMcAllTracks) return "McAllTracks";
81  if (qNumber == kSpuriousFound) return "SpuriousFound";
82  if (qNumber == kPartiallyFound) return "PartiallyFound";
83  if (qNumber == kFullyFound) return "FullyFound";
84  if (qNumber == kGhost) return "Ghost";
85  if (qNumber == kNotFound) return "NotFound";
86  if (qNumber == kFound) return "Found";
87  return std::to_string(qNumber);
88  };
89 };
90 
91 class PndTrackingQA : public TObject
92 {
93 public:
94  PndTrackingQA(TString trackBranchName, TString idealTrackName, Bool_t pndTrackData = kTRUE);
95  PndTrackingQA(TString trackBranchName, TString idealTrackName, PndTrackFunctor* posTrack, Bool_t pndTrackData = kTRUE);
96  virtual ~PndTrackingQA();
97 
98  virtual void Init();
99  void SetVerbose(Int_t val){fVerbose = val;}
100 
102  void AddHitsBranchName(TString name){ fBranchNames.push_back(name);}
103  void SetHitsBranchNames(std::vector<TString> names){ fBranchNames = names;}
104 
105  void AnalyseEvent(TClonesArray *recoTrackInfo);
106 
107 // Int_t GetNIdealHits(Int_t trackId, TString branchName);
108  Int_t GetNIdealHits(FairMultiLinkedData& track, TString branchName);
109  std::map<Int_t, Int_t> GetMCTrackFound() {return fMCTrackFound;}
110  std::map<Int_t, Int_t> GetTrackQualification() {return fMapTrackQualification;}
111  std::map<Int_t, Int_t> GetTrackMCStatus() {return fMapTrackMCStatus;}
112  std::map<Int_t, std::map<TString, std::pair<Double_t, Int_t > > > GetEfficiencies() {return fMapEfficiencies;}
113  std::map<Int_t, Double_t> GetPResolution() {return fMapPResolution;}
114  std::map<Int_t, TVector3> GetP() {return fMapP;}
115  std::map<Int_t, Double_t> GetPtResolution() {return fMapPtResolution;}
116  std::map<Int_t, Double_t> GetPt() {return fMapPt;}
117  std::map<Int_t, Double_t> GetPlResolution() {return fMapPlResolution;}
118  std::map<Int_t, Double_t> GetPl() {return fMapPl;}
119  std::map<Int_t, Double_t> GetPResolutionRel() {return fMapPResolutionRel;}
120  std::map<Int_t, Double_t> GetPtResolutionRel() {return fMapPtResolutionRel;}
121  std::map<Int_t, Double_t> GetPlResolutionRel() {return fMapPlResolutionRel;}
122  std::map<Int_t, Int_t> GetTrackIdMCId() {return fTrackIdMCId;}
123  Int_t GetNGhosts() {return fNGhosts;}
124 
125 
126 
127  void PrintTrackDataSummary(FairMultiLinkedData& trackData, Bool_t detailedInfo = kFALSE);
128  void PrintTrackDataSummaryCompare(FairMultiLinkedData& recoTrackData, FairMultiLinkedData& idealTrackData);
129 
133  void PrintTrackQualityMap(Bool_t detailedInfo = kFALSE);
134  void PrintTrackMCStatusMap();
135  void PrintTrackInfo(std::map<TString, FairMultiLinkedData> info);
136 
137  Int_t GetIdealTrackIdFromMCTrackId(int mctrackid) {
138  if (fMCIdIdealTrackId.count(mctrackid) == 0) return -1;
139  return fMCIdIdealTrackId[mctrackid];
140  }
141  Int_t GetIdealTrackIdFromRecoTrackId(int trackid) {
142  int mctrackid = fTrackIdMCId[trackid];
143  if (fMCIdIdealTrackId.count(mctrackid) == 0) return -1;
144  return fMCIdIdealTrackId[mctrackid];
145  }
146 
147  PndTrackingQualityRecoInfo GetRecoInfoFromRecoTrack(Int_t trackId, Int_t mctrackId);
148 
149 private:
150 
151 
152  virtual void FillMapTrackQualifikation();
153  Bool_t IsBetterTrackExisting(Int_t& mcIndex, int quality);
154 // virtual Bool_t PossibleTrack(FairMultiLinkedData& mcForward);
155  Int_t GetSumOfAllValidMCHits(FairMultiLinkedData* trackData);
156  virtual Int_t AnalyseTrackInfo(std::map<TString, FairMultiLinkedData>& trackInfo, Int_t trackId);
157  virtual void CalcEfficiencies(Int_t mostProbableTrack, std::map<TString, FairMultiLinkedData>& trackInfo);
158  FairMultiLinkedData GetMCInfoForBranch(TString branchName, PndTrackCand* trackCand);
159  std::map<TString, FairMultiLinkedData> AnalyseTrackCand(PndTrackCand* trackCand);
160 
161 // virtual Bool_t IsCorrectGemHit(FairLink& gemLink);
162 
163  FairRootManager* ioman;
164 
167  Bool_t fPndTrackOrTrackCand; //kTRUE if track and kFALSE if track cand
168  std::string fPossibleTrackName;
171  Int_t fNGhosts;
172 
174  Int_t fVerbose;
175 
176  std::vector<TString> fBranchNames;
177  std::map<Int_t, Int_t> fTrackIdMCId;
178  std::map<Int_t, Int_t> fMCIdTrackId;
179  std::map<Int_t, Int_t> fMCIdIdealTrackId;
180 
181  std::map<Int_t, Int_t> fMCTrackFound;
182 
183 
184 
185  std::map<Int_t, Int_t> fMapTrackMCStatus;
186  std::map<Int_t, Int_t> fMapTrackQualification;
187  std::map<Int_t, std::map<TString, std::pair<Double_t, Int_t> > > fMapEfficiencies;
188  std::map<Int_t, Double_t> fMapPResolution;
189  std::map<Int_t, TVector3> fMapP;
190  std::map<Int_t, Double_t> fMapPtResolution;
191  std::map<Int_t, Double_t> fMapPt;
192  std::map<Int_t, Double_t> fMapPResolutionRel;
193  std::map<Int_t, Double_t> fMapPtResolutionRel;
194  std::map<Int_t, Double_t> fMapPlResolution;
195  std::map<Int_t, Double_t> fMapPl;
196  std::map<Int_t, Double_t> fMapPlResolutionRel;
197 
198  TClonesArray* fTrack;
199  TClonesArray* fMCTrack;
200  TClonesArray* fIdealTrack;
201  TClonesArray* fIdealTrackCand;
202 
203 
204  ClassDef(PndTrackingQA, 1)
205 };
206 
207 #endif /* PNDTRACKINGQUALITY_H_ */
void PrintTrackDataSummary(FairMultiLinkedData &trackData, Bool_t detailedInfo=kFALSE)
std::map< Int_t, Int_t > GetMCTrackFound()
std::map< Int_t, Int_t > fMapTrackQualification
! TrackId vs TrackStatus after analysis of track finding
std::map< Int_t, Double_t > fMapPt
virtual Int_t AnalyseTrackInfo(std::map< TString, FairMultiLinkedData > &trackInfo, Int_t trackId)
Bool_t IsBetterTrackExisting(Int_t &mcIndex, int quality)
std::string fPossibleTrackName
Int_t GetNGhosts()
static const int kMcAtLeastThreeSec
Definition: PndTrackingQA.h:52
Bool_t fPndTrackOrTrackCand
std::map< Int_t, Double_t > fMapPlResolution
std::map< Int_t, Double_t > GetPlResolution()
void AnalyseEvent(TClonesArray *recoTrackInfo)
static const int kGhost
Definition: PndTrackingQA.h:63
Bool_t fUseCorrectedSkewedHits
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
virtual void Init()
static const int kLessThanThreePrim
Definition: PndTrackingQA.h:47
void SetHitsBranchNames(std::vector< TString > names)
static const int kPossiblePrim
Definition: PndTrackingQA.h:44
static const int kAtLeastThreeSec
Definition: PndTrackingQA.h:45
std::map< Int_t, Double_t > GetPResolution()
std::map< Int_t, Double_t > GetPResolutionRel()
std::map< Int_t, Int_t > fMCIdIdealTrackId
! map between MC id and ideal track id
TClonesArray * fIdealTrackCand
FairMultiLinkedData GetMCInfoForBranch(TString branchName, PndTrackCand *trackCand)
returns which MCTracks and how often (marked by a FairLink) they were seen by the hits of a PndTrackC...
PndTrackFunctor * fPossibleTrack
static const int kPartiallyFound
Definition: PndTrackingQA.h:60
static const int kMcPossibleSec
Definition: PndTrackingQA.h:50
std::vector< TString > fBranchNames
! branch names of hits taken into account in the analysis (e.g. MVDHitsPixel, STTHit, ...)
std::map< Int_t, TVector3 > fMapP
std::map< Int_t, Double_t > fMapPl
void AddHitsBranchName(TString name)
Adds branch names of detector data which should be taken into account in the analysis.
TClonesArray * fIdealTrack
std::map< Int_t, Double_t > fMapPlResolutionRel
void PrintTrackMCStatusMap()
Int_t GetSumOfAllValidMCHits(FairMultiLinkedData *trackData)
virtual void CalcEfficiencies(Int_t mostProbableTrack, std::map< TString, FairMultiLinkedData > &trackInfo)
FairRootManager * ioman
static std::string QualityNumberToString(int qNumber)
Definition: PndTrackingQA.h:68
static const int kPossibleSec
Definition: PndTrackingQA.h:43
Bool_t fCleanFunctor
std::map< TString, FairMultiLinkedData > AnalyseTrackCand(PndTrackCand *trackCand)
returns a map&lt;BranchNameOfHits, MCTrackLinks&gt; which returns the FairLinks to MCTracks grouped by hit ...
TClonesArray * fMCTrack
std::map< Int_t, Int_t > GetTrackMCStatus()
std::map< Int_t, Int_t > fMCTrackFound
! How often was a MC Track (key) found
void PrintTrackDataSummaryCompare(FairMultiLinkedData &recoTrackData, FairMultiLinkedData &idealTrackData)
void PrintTrackInfo(std::map< TString, FairMultiLinkedData > info)
PndMCTrack * track
Definition: anaLmdCluster.C:89
static const int kAtLeastThreePrim
Definition: PndTrackingQA.h:46
std::map< Int_t, TVector3 > GetP()
std::map< Int_t, std::map< TString, std::pair< Double_t, Int_t > > > GetEfficiencies()
virtual void FillMapTrackQualifikation()
std::map< Int_t, Double_t > GetPt()
std::map< Int_t, Double_t > fMapPResolution
std::map< Int_t, Double_t > fMapPResolutionRel
Holding statically callable quality numbers.
Definition: PndTrackingQA.h:39
std::map< Int_t, Double_t > GetPlResolutionRel()
std::map< Int_t, Double_t > GetPtResolution()
void SetVerbose(Int_t val)
Definition: PndTrackingQA.h:99
static const int kMcLessThanThreePrim
Definition: PndTrackingQA.h:54
TString name
PndTrackingQA(TString trackBranchName, TString idealTrackName, Bool_t pndTrackData=kTRUE)
PndTrackingQualityRecoInfo GetRecoInfoFromRecoTrack(Int_t trackId, Int_t mctrackId)
TString fIdealTrackName
static const int kMcAllTracksWithHits
Definition: PndTrackingQA.h:55
std::map< Int_t, Int_t > GetTrackQualification()
std::map< Int_t, Int_t > fMapTrackMCStatus
! TrackId vs TrackStatus from MC
static const int kFullyFound
Definition: PndTrackingQA.h:61
std::map< Int_t, Double_t > fMapPtResolutionRel
static const int kFound
Definition: PndTrackingQA.h:66
std::map< Int_t, Int_t > fTrackIdMCId
! map between track id and most probable MC track id
static const int kMcAllTracks
Definition: PndTrackingQA.h:56
std::map< Int_t, Int_t > fMCIdTrackId
! map between MC id and track id
virtual ~PndTrackingQA()
Int_t GetIdealTrackIdFromMCTrackId(int mctrackid)
std::map< Int_t, std::map< TString, std::pair< Double_t, Int_t > > > fMapEfficiencies
! MostProbable TrackId, BranchName, Efficiency (#FoundHits / #MCHits), #MCHits
static const int kMcAtLeastThreePrim
Definition: PndTrackingQA.h:53
Int_t GetNIdealHits(FairMultiLinkedData &track, TString branchName)
std::map< Int_t, Double_t > GetPtResolutionRel()
TClonesArray * fTrack
void PrintTrackQualityMap(Bool_t detailedInfo=kFALSE)
std::map< Int_t, Double_t > GetPl()
std::map< Int_t, Double_t > fMapPtResolution
static const int kMcPossiblePrim
Definition: PndTrackingQA.h:51
TString fTrackBranchName
static const int kSpuriousFound
Definition: PndTrackingQA.h:59
static const int kNotFound
Definition: PndTrackingQA.h:65
Int_t GetIdealTrackIdFromRecoTrackId(int trackid)
std::map< Int_t, Int_t > GetTrackIdMCId()