PandaRoot
PndTrackingQualityBarrelAnalysisNewLinks.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 
13 /*
14  * PndTrackingQualityBarrelAnalysisNewLinks.h
15  *
16  * Created on: Aug 23, 2013
17  * Author: stockman
18  */
19 
20 #ifndef PndTrackingQualityBarrelAnalysisNewLinks_H_
21 #define PndTrackingQualityBarrelAnalysisNewLinks_H_
22 
23 #include "FairMultiLinkedData.h"
24 #include "FairRootManager.h"
25 
26 #include "PndTrackCand.h"
28 
29 #include <TObject.h>
30 #include <TString.h>
31 #include <TClonesArray.h>
32 
33 #include <vector>
34 #include <map>
35 
36 #include <functional>
37 #include "PndTrackingQualityAnalysis.h"
38 
39 /*class PossibleTrackFunctor : public std::binary_function<FairMultiLinkedData* , Bool_t, Bool_t>
40 {
41  public :
42  virtual Bool_t operator() (FairMultiLinkedData* a, Bool_t primary) {return Call(a, primary);};
43  virtual Bool_t Call(FairMultiLinkedData* a, Bool_t primary) = 0;
44  virtual void Print() = 0;
45 
46  virtual ~PossibleTrackFunctor() {};
47 
48 };
49 
50 class StandardTrackFunctor : public PossibleTrackFunctor
51 {
52  Bool_t Call(FairMultiLinkedData* a, Bool_t primary){
53  FairRootManager* ioman = FairRootManager::Instance();
54  Bool_t possibleTrack = kFALSE;
55  possibleTrack = possibleTrack | (a->GetLinksWithType(ioman->GetBranchId("MVDHitsPixel")).GetNLinks() +
56  a->GetLinksWithType(ioman->GetBranchId("MVDHitsStrip")).GetNLinks() > 3);
57 
58  possibleTrack = possibleTrack | (a->GetLinksWithType(ioman->GetBranchId("MVDHitsPixel")).GetNLinks() +
59  a->GetLinksWithType(ioman->GetBranchId("MVDHitsStrip")).GetNLinks() +
60  a->GetLinksWithType(ioman->GetBranchId("STTHit")).GetNLinks() ) > 5;
61 
62  return possibleTrack;
63  }
64 
65  void Print(){
66  std::cout << "StandardTrackFunctor: > 3 Hits in MVD or > 5 Hits in (MVD+Stt)" << std::endl;
67  }
68 };
69 
70 class OnlySttFunctor : public PossibleTrackFunctor
71 {
72  Bool_t Call(FairMultiLinkedData* a, Bool_t primary){
73  FairRootManager* ioman = FairRootManager::Instance();
74  Bool_t possibleTrack = kFALSE;
75 
76  possibleTrack = possibleTrack | a->GetLinksWithType(ioman->GetBranchId("STTHit")).GetNLinks() > 5;
77 
78  return possibleTrack;
79  }
80  void Print(){
81  std::cout << "OnlySttFunctor: > 5 Hits in Stt" << std::endl;
82  }
83 };
84 
85 class RiemannMvdSttGemFunctor : public PossibleTrackFunctor
86 {
87  Bool_t Call(FairMultiLinkedData* a, Bool_t primary){
88  FairRootManager* ioman = FairRootManager::Instance();
89  Bool_t possibleTrack = kFALSE;
90  Bool_t mvdHits = ((a->GetLinksWithType(ioman->GetBranchId("MVDHitsPixel")).GetNLinks() +
91  a->GetLinksWithType(ioman->GetBranchId("MVDHitsStrip")).GetNLinks()) > 2);
92 
93  if (mvdHits){
94  possibleTrack = a->GetLinksWithType(ioman->GetBranchId("STTHit")).GetNLinks() > 1 | a->GetLinksWithType(ioman->GetBranchId("GEMHit")).GetNLinks() > 1;
95  }
96  return possibleTrack;
97  }
98  void Print(){
99  std::cout << "RiemannMvdSttGemFunctor: > 2 Hits in MVD and >0 Hits in (Stt+Gem)" << std::endl;
100  }
101 
102 };
103 
104 class CircleHoughTrackFunctor : public PossibleTrackFunctor
105 {
106  Bool_t Call(FairMultiLinkedData* a, Bool_t primary){
107  if (primary == kFALSE) return kFALSE;
108  FairRootManager* ioman = FairRootManager::Instance();
109  Bool_t possibleTrack = kFALSE;
110 
111  Int_t nHitsMvdPixel = a->GetLinksWithType(ioman->GetBranchId("MVDHitsPixel")).GetNLinks();
112  Int_t nHitsMvdStrip = a->GetLinksWithType(ioman->GetBranchId("MVDHitsStrip")).GetNLinks();
113  if (nHitsMvdPixel + nHitsMvdStrip > 2) { // First requirement: more than two MVD hits
114  Int_t nHitsStt = a->GetLinksWithType(ioman->GetBranchId("STTHit")).GetNLinks();
115  Int_t nHitsGem = a->GetLinksWithType(ioman->GetBranchId("GEMHit")).GetNLinks();
116  possibleTrack = (nHitsMvdPixel + nHitsMvdStrip + nHitsStt + nHitsGem > 6); // Second requirement: More than six hits total
117  }
118  return possibleTrack;
119  }
120  void Print(){
121  std::cout << "CircleHoughTrackFunctor: > 3 Hits in MVD and primary track" << std::endl;
122  }
123 
124 };
125 */
126 
137 /*
138 struct qualityNumbers {
139  static const int
140  // Following: Default statuses.
141  // Are the 'not found' tracks in the quality histogram of PndTrackingQualityTask.
142  kPossibleSec = -1, // possible: As defined through the possibleFunctor; secondary: a non-primary particle
143  kPossiblePrim = -2, // possible: As defined through the possibleFunctor; primary: coming directly from particle generator (e.g. EvtGen)
144  kAtLeastThreeSec = -3, // atLeastThree: min. 3 hit points in central tracking detectors (MVD, STT, GEM); secondary: a non-primary particle
145  kAtLeastThreePrim = -4, // atLeastThree: min. 3 hit points in central tracking detectors (MVD, STT, GEM); primary: coming directly from particle generator (e.g. EvtGen)
146  kLessThanThreePrim = -5, // LessThanThree: fewer than 3 hit points in central tracking detectors (MVD, STT, GEM); primar: coming directly from particle generator (e.g. EvtGen)
147 
148  // Following: MC statuses of all (found+notfound) tracks
149  kMcPossibleSec = -7, // see above
150  kMcPossiblePrim = -8,
151  kMcAtLeastThreeSec = -9,
152  kMcAtLeastThreePrim = -10,
153  kMcLessThanThreePrim = -11,
154 
155  // Following: Status of reconstructed tracks (= created PndTracks)
156  kSpuriousFound = 1, // spuriousFound: at least 70% of hits of reco'd track come from one MC track ('mostProbableTrack')
157  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
158  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
159 
160  kGhost = 5, // ghost: less than 70% of hits of reco'd track come from one MC track ('mostProbableTrack')
161 
162  kNotFound = 7, // notFound: total number of not reco'd tracks
163  kFound = 8; // found: total number of reco'd tracks; the sum of fullyFound, partiallyFound, spuriousFound
164 };
165 
166 */
167 
169  public:
170  PndTrackingQualityBarrelAnalysisNewLinks(TString trackBranchName, TString idealTrackName, Bool_t pndTrackData = kTRUE);
171  PndTrackingQualityBarrelAnalysisNewLinks(TString trackBranchName, TString idealTrackName, PossibleTrackFunctor *posTrack, Bool_t pndTrackData = kTRUE);
173 
174  virtual void Init();
175  void SetVerbose(Int_t val) { fVerbose = val; }
176 
178  void AddHitsBranchName(TString name) { fBranchNames.push_back(name); }
179  void SetHitsBranchNames(std::vector<TString> names) { fBranchNames = names; }
180 
181  void AnalyseEvent(TClonesArray *recoTrackInfo);
182 
183  // Int_t GetNIdealHits(Int_t trackId, TString branchName);
184  Int_t GetNIdealHits(FairMultiLinkedData &track, TString branchName);
185  std::map<Int_t, Int_t> GetMCTrackFound() { return fMCTrackFound; }
186  std::map<Int_t, Int_t> GetTrackQualification() { return fMapTrackQualification; }
187  std::map<Int_t, Int_t> GetTrackMCStatus() { return fMapTrackMCStatus; }
188  std::map<Int_t, std::map<TString, std::pair<Double_t, Int_t>>> GetEfficiencies() { return fMapEfficiencies; }
189  std::map<Int_t, Double_t> GetPResolution() { return fMapPResolution; }
190  std::map<Int_t, TVector3> GetP() { return fMapP; }
191  std::map<Int_t, Double_t> GetPtResolution() { return fMapPtResolution; }
192  std::map<Int_t, Double_t> GetPt() { return fMapPt; }
193  std::map<Int_t, Double_t> GetPResolutionRel() { return fMapPResolutionRel; }
194  std::map<Int_t, Double_t> GetPtResolutionRel() { return fMapPtResolutionRel; }
195  std::map<Int_t, Int_t> GetTrackIdMCId() { return fTrackIdMCId; }
196  Int_t GetNGhosts() { return fNGhosts; }
197 
198  void PrintTrackDataSummary(FairMultiLinkedData &trackData, Bool_t detailedInfo = kFALSE);
199 
203  void PrintTrackQualityMap(Bool_t detailedInfo = kFALSE);
204  void PrintTrackMCStatusMap();
205  void PrintTrackInfo(std::map<TString, FairMultiLinkedData> info);
206 
207  Int_t GetIdealTrackIdFromMCTrackId(int mctrackid) { return fMCIdIdealTrackId[mctrackid]; }
209  {
210  int mctrackid = fTrackIdMCId[trackid];
211  return fMCIdIdealTrackId[mctrackid];
212  }
213 
214  PndTrackingQualityRecoInfo GetRecoInfoFromRecoTrack(Int_t trackId, Int_t mctrackId);
215 
216  static Bool_t IsBarrelMVD(FairMultiLinkedData &links, int iHit);
217  static Int_t NBarrelMVD(FairMultiLinkedData &links);
218 
219  private:
220  virtual void FillMapTrackQualifikation();
221  Bool_t IsBetterTrackExisting(Int_t &mcIndex, int quality);
222  // virtual Bool_t PossibleTrack(FairMultiLinkedData& mcForward);
223  Int_t GetSumOfAllValidMCHits(FairMultiLinkedData *trackData);
224  virtual Int_t AnalyseTrackInfo(std::map<TString, FairMultiLinkedData> &trackInfo, Int_t trackId);
225  virtual void CalcEfficiencies(Int_t mostProbableTrack, std::map<TString, FairMultiLinkedData> &trackInfo);
226  FairMultiLinkedData GetMCInfoForBranch(TString branchName, PndTrackCand *trackCand);
227  std::map<TString, FairMultiLinkedData> AnalyseTrackCand(PndTrackCand *trackCand);
228 
229  // virtual Bool_t IsCorrectGemHit(FairLink& gemLink);
230 
231  Int_t fVerbose;
232  FairRootManager *ioman;
233  Int_t fNGhosts;
234 
235  TString fTrackBranchName;
236  TString fIdealTrackName;
237  Bool_t fPndTrackOrTrackCand; // kTRUE if track and kFALSE if track cand
238  PossibleTrackFunctor *fPossibleTrack;
239 
240  Bool_t fUseCorrectedSkewedHits;
241 
242  std::vector<TString> fBranchNames;
243  std::map<Int_t, Int_t> fTrackIdMCId;
244  std::map<Int_t, Int_t> fMCIdTrackId;
245  std::map<Int_t, Int_t> fMCIdIdealTrackId;
246 
247  std::map<Int_t, Int_t> fMCTrackFound;
248 
249  std::map<Int_t, Int_t> fMapTrackMCStatus;
250  std::map<Int_t, Int_t> fMapTrackQualification;
251  std::map<Int_t, std::map<TString, std::pair<Double_t, Int_t>>> fMapEfficiencies;
252  std::map<Int_t, Double_t> fMapPResolution;
253  std::map<Int_t, TVector3> fMapP;
254  std::map<Int_t, Double_t> fMapPtResolution;
255  std::map<Int_t, Double_t> fMapPt;
256  std::map<Int_t, Double_t> fMapPResolutionRel;
257  std::map<Int_t, Double_t> fMapPtResolutionRel;
258 
259  TClonesArray *fTrack;
260  TClonesArray *fMCTrack;
261  TClonesArray *fIdealTrack;
262  TClonesArray *fIdealTrackCand;
263 
265 };
266 
267 #endif /* PNDTRACKINGQUALITY_H_ */