ATLAS Offline Software
Loading...
Searching...
No Matches
TrackStatHelper.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6// StatBox.h
7// Authors: Sven Vahsen
9
10// Private utility class used by IDTrackStat to do track counting
11// Since this StatBox is likely to change to without notification
12// as needed, I would not recommend anyone else to use it
13
14#ifndef INDETRECSTATISTICS_TrackStatHelper_H
15#define INDETRECSTATISTICS_TrackStatHelper_H
16
17#include "TrkTrack/TrackInfo.h"
18#include "TrkTrackSummary/TrackSummary.h" // needed by Trk::numberOfTrackSummaryTypes
24
25#include <vector>
26#include <string>
27#include <map>
28#include <atomic>
29
30// forward declarations:
31class PixelID;
32class SCT_ID;
33class AtlasDetectorID;
34class Track;
35
36namespace InDet {
37
40 TRACK_SECONDARY, //LT 06.21
73
82
83 struct cuts {
100 float minPt;
102 maxEtaBarrel =0;
104 maxEtaEndcap =0;
105 minEtaFORWARD = 2.5;
106 maxEtaFORWARD=4.2;
107 fakeTrackCut=0;
108 fakeTrackCut2 =0;
109 matchTrackCut =0;
110 maxRStartPrimary = 25.0;
111 maxRStartSecondary= 360.0;
112 maxZStartPrimary = 200.0;
113 maxZStartSecondary=2000.0;
114 minREndPrimary = 400.0;
115 minREndSecondary =1000.0;
116 minZEndPrimary =2300.0;
117 minZEndSecondary =3200.0;
118 minPt = 1000;
119 }
120
121
122
123 };
124
125
132
133 public:
136 TrackStatHelper (const std::string&, const std::string&, bool careAboutTruth = true);
138 void SetCuts(const struct cuts&);
140 void addEvent (const TrackCollection *,
141 std::vector<const Trk::Track *> &,
142 const std::vector <std::pair<HepMC::ConstGenParticlePtr,int> > &,
143 const TrackTruthCollection *,
144 const AtlasDetectorID * const,
145 const PixelID *,
146 const SCT_ID *,
148 bool,
149 const unsigned int *,
150 const unsigned int *) const;
152 void reset ();
154 void print (MsgStream &out) const;
156 void printRegion1(MsgStream &out, enum eta_region) const;
157 void printRegion2(MsgStream &out, enum eta_region, float denominator) const;
159 void printSecondary (MsgStream &out) const;
161 void printRegionSecondary(MsgStream &out, enum eta_region, float denominator) const;
162
163
165 bool printTrackSummaryRegion (MsgStream &out, enum track_types, enum eta_region) const;
167 void printTrackSummaryAverage(MsgStream &out, enum track_types, enum eta_region, int summary_type) const;
169 bool PassTrackCuts(const Trk::TrackParameters *para) const;
171 int ClassifyParticle( const HepMC::ConstGenParticlePtr& particle, const double prob) const;
172
173
174 static std::string getSummaryTypeHeader();
175
177 const std::string &key() const { return m_TrackCollectionKey; }
179 const std::string &Truthkey() const { return m_TrackTruthCollectionKey; }
180
181 private:
182
185
187 mutable std::atomic<long> m_events {} ;
188
189 template <int N_Categories, int N_Types, int N_Regions, typename T_Int=long>
190 struct Counter {
191 Counter() { reset(); }
192 void reset() {
193 for (unsigned int cat_i=0; cat_i < N_Categories; ++cat_i ) {
194 for (unsigned int type_i=0; type_i < N_Types; ++type_i) {
195 for (unsigned int eta_i=0; eta_i < N_Regions; ++eta_i) {
196 m_counter[cat_i][type_i][eta_i]=0;
197 }
198 }
199 }
200 }
201 template <typename T_IntB>
203 for (unsigned int cat_i=0; cat_i < N_Categories; ++cat_i ) {
204 for (unsigned int type_i=0; type_i < N_Types; ++type_i) {
205 for (unsigned int eta_i=0; eta_i < N_Regions; ++eta_i) {
206 m_counter[cat_i][type_i][eta_i] += a.m_counter[cat_i][type_i][eta_i];
207 }
208 }
209 }
210 return *this;
211 }
212 T_Int m_counter[N_Categories][N_Types][N_Regions];
213 };
214
215 template <int N_Categories, int N_Types, int N_Regions, int N_SubCategories, typename T_Int=long>
216 struct Counter4D {
218 void reset() {
219 for (unsigned int cat_i=0; cat_i < N_Categories; ++cat_i ) {
220 for (unsigned int type_i=0; type_i < N_Types; ++type_i) {
221 for (unsigned int eta_i=0; eta_i < N_Regions; ++eta_i) {
222 for (unsigned int sub_i=0; sub_i < N_SubCategories; ++sub_i) {
223 m_counter[cat_i][type_i][eta_i][sub_i]=0;
224 }
225 }
226 }
227 }
228 }
229 template <typename T_IntB>
231 for (unsigned int cat_i=0; cat_i < N_Categories; ++cat_i ) {
232 for (unsigned int type_i=0; type_i < N_Types; ++type_i) {
233 for (unsigned int eta_i=0; eta_i < N_Regions; ++eta_i) {
234 for (unsigned int sub_i=0; sub_i < N_SubCategories; ++sub_i) {
235 m_counter[cat_i][type_i][eta_i][sub_i] += a.m_counter[cat_i][type_i][eta_i][sub_i];
236 }
237 }
238 }
239 }
240 return *this;
241 }
242 T_Int m_counter[N_Categories][N_Types][N_Regions][N_SubCategories];
243 };
244
249
253
269
270 // The ETrackSummaryTypes should be synchronised with the arrays summaryTypes and
271 // summaryTypeName i.e. matching order and number of elements. Of these enums only
272 // two are used: kNSummaryTypes which defines the summary statistics array sizes;
273 // kNumberOfPixelHits, which is used to get counts for some denominators.
291 static const char *const s_summaryTypeName [kNSummaryTypes];
293
295 N_TRACKTYPES,
296 N_ETAREGIONS,
298 int>;
300 N_TRACKTYPES,
301 N_ETAREGIONS,
303 std::atomic<long> >;
305
306
307 void setSummaryStat(track_types track_i,
308 eta_region region_i,
309 const Trk::TrackSummary *summary,
310 TrackSummaryCounter &trackSummarySum) const
311 {
312 if (summary) {
313 for (int stype=0; stype < kNSummaryTypes; stype++) {
314 int value = summary->get(s_summaryTypes[stype]);
315 //value is -1 if undefined
316 if (value>0) {
317 trackSummarySum.m_counter[kTrackSummarySum][track_i][region_i][stype] += value;
318 trackSummarySum.m_counter[kNTrackSummaryOK][track_i][region_i][stype] ++;
319 }
320 else {
321 trackSummarySum.m_counter[kNTrackSummaryBAD][track_i][region_i][stype] ++;
322 }
323 }
324 }
325 }
326
327 mutable std::atomic<bool> m_truthMissing;
329 struct cuts m_cuts;
330
331 mutable std::mutex m_authorMutex;
332 mutable std::bitset<Trk::TrackInfo::NumberOfTrackRecoInfo> m_recoInfo ATLAS_THREAD_SAFE;
333 mutable std::bitset<Trk::TrackInfo::NumberOfTrackProperties> m_patternProperties ATLAS_THREAD_SAFE;
334
335 typedef std::multimap<HepMcParticleLink,float> recoToTruthMap;
336 };
337
338
339
340} // close of namespace
341
342#endif // INDETRECSTATISTICS_TrackStatHelper_H
static Double_t a
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
bool printTrackSummaryRegion(MsgStream &out, enum track_types, enum eta_region) const
Sets up detailed statistics part of table, calls printTrackSummaryRegion.
Counter4D< kNTrackSummaryCounter, N_TRACKTYPES, N_ETAREGIONS, kNSummaryTypes, int > TrackSummaryCounter
type statistics.
Counter4D< kNTrackSummaryCounter, N_TRACKTYPES, N_ETAREGIONS, kNSummaryTypes, std::atomic< long > > TrackSummaryCounterAtomic
bool PassTrackCuts(const Trk::TrackParameters *para) const
defines 'good' reco tracks
void printRegionSecondary(MsgStream &out, enum eta_region, float denominator) const
Prints ntracks per event,efficiencies,fake rates, and general hit information for given eta region.
void printRegion1(MsgStream &out, enum eta_region) const
Prints ntracks per event,efficiencies,fake rates, and general hit information for given eta region.
std::atomic< bool > m_author_found[Trk::TrackInfo::NumberOfTrackFitters]
Number of tracking authors found.
TrackStatHelper(const std::string &, const std::string &, bool careAboutTruth=true)
Constructor.
void addEvent(const TrackCollection *, std::vector< const Trk::Track * > &, const std::vector< std::pair< HepMC::ConstGenParticlePtr, int > > &, const TrackTruthCollection *, const AtlasDetectorID *const, const PixelID *, const SCT_ID *, const Trk::IExtendedTrackSummaryTool *, bool, const unsigned int *, const unsigned int *) const
Adds hit, track and matching information for each event.
void printSecondary(MsgStream &out) const
Prints all of the statistics information, calls printRegion, printTrackSummaryRegion,...
std::string m_TrackTruthCollectionKey
StoreGate Track Truth Collection Key.
std::string m_TrackCollectionKey
StoreGate Track Collection Key.
TracksCounterAtomic m_tracks ATLAS_THREAD_SAFE
void printTrackSummaryAverage(MsgStream &out, enum track_types, enum eta_region, int summary_type) const
Prints information from TrackSummaryTool.
static std::string getSummaryTypeHeader()
static const char *const s_summaryTypeName[kNSummaryTypes]
table column labels for summary
std::multimap< HepMcParticleLink, float > recoToTruthMap
map containing reco track and matched truth track barcode
const std::string & Truthkey() const
Returns Truth TrackCollection Key.
Counter< kNTracksCounter, N_TRACKTYPES, N_ETAREGIONS, int > TracksCounter
void print(MsgStream &out) const
Prints all of the statistics information, calls printRegion, printTrackSummaryRegion,...
@ kTracks_rec
number of reconstructed tracks for a given type and eta region
@ kTracks_gen
number of generated tracks for a given type and eta region, looping over genevents to include possibl...
@ kTracks_gen_signal
number of generated tracks for a given type and eta region, just from first genevent
Counter< kNTracksCounter, N_TRACKTYPES, N_ETAREGIONS, std::atomic< long > > TracksCounterAtomic
static const Trk::SummaryType s_summaryTypes[kNSummaryTypes]
summary types for which statistics are gathered
void reset()
Resets the track collection information, called in the constructor.
void setSummaryStat(track_types track_i, eta_region region_i, const Trk::TrackSummary *summary, TrackSummaryCounter &trackSummarySum) const
@ kNTrackSummaryBAD
Number of tracks with track summary bad for given type,eta,summary type.
@ kNTrackSummaryOK
Number of tracks with track summary OK for given type,eta,summary type.
@ kTrackSummarySum
Track Summary Values for each track type, region and summary type.
const std::string & key() const
Returns TrackCollection Key.
Counter< kNHitsCounter, N_HITTYPES, N_ETAREGIONS, std::atomic< long > > HitsCounterAtomic
@ kHits_sec
number of hits from secondary tracks for a given type and eta region
@ kHits_rec
number of reconstructed hits for a given type and eta region
@ kHits_pri
number of hits from primary tracks for a given type and eta region
int ClassifyParticle(const HepMC::ConstGenParticlePtr &particle, const double prob) const
classifies gen particle as primary, secondary or truncated
Counter< kNHitsCounter, N_HITTYPES, N_ETAREGIONS, int > HitsCounter
std::atomic< long > m_events
Number of events.
void printRegion2(MsgStream &out, enum eta_region, float denominator) const
std::atomic< bool > m_truthMissing
Flag for if track truth is missing.
void SetCuts(const struct cuts &)
Sets the cuts such as the eta regions (barrel, transition,endcap) and the hit fraction fake cuts and ...
@ TRACK_SECONDARY
@ TRACK_NOHEPMCPARTICLELINK
@ TRACK_LOWTRUTHPROB2_SIGNAL
@ TRACK_LOWTRUTHPROB2
@ TRACK_TRUNCATED
@ TRACK_MATCHED_PRIMARY
@ TRACK_LOWTRUTHPROB_SIGNAL
@ TRACK_MULTMATCH_SECONDARY
@ TRACK_MULTMATCH_PRIMARY
@ TRACK_MULTMATCH
@ TRACK_MATCHED_SIGNAL
@ TRACK_MATCHED_SECONDARY
@ TRACK_LOWTRUTHPROB
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:67
This is an Identifier helper class for the SCT subdetector.
Definition SCT_ID.h:68
Interface for condensing Trk::Track properties and associated hits to a (non-fittable) foot print,...
A summary of the information contained by a track.
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
Primary Vertex Finder.
ParametersBase< TrackParametersDim, Charged > TrackParameters
SummaryType
enumerates the different types of information stored in Summary.
Counter4D & operator+=(const Counter4D< N_Categories, N_Types, N_Regions, N_SubCategories, T_IntB > &a)
Counter & operator+=(const Counter< N_Categories, N_Types, N_Regions, T_IntB > &a)
float maxRStartSecondary
float minZEndSecondary
float fakeTrackCut
fraction of hits per track that come from single matched truth track.
float maxRStartPrimary
float matchTrackCut
Truth probability has to be greater than this for track to be considered matched.
float minREndSecondary
float maxEtaTransition
Maxiumu eta for transition region.
float maxZStartPrimary
float fakeTrackCut2
2nd value for fraction of hits per track that come from single matched truth track.
float maxEtaEndcap
Maximum eta for endcap.
float maxZStartSecondary