ATLAS Offline Software
Loading...
Searching...
No Matches
TrackStatHelper.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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 <bitset>
29#include <atomic>
30
31// forward declarations:
32class PixelID;
33class SCT_ID;
34class AtlasDetectorID;
35class Track;
36
37namespace InDet {
38
41 TRACK_SECONDARY, //LT 06.21
74
83
84 struct cuts {
101 float minPt;
103 maxEtaBarrel =0;
105 maxEtaEndcap =0;
106 minEtaFORWARD = 2.5;
107 maxEtaFORWARD=4.2;
108 fakeTrackCut=0;
109 fakeTrackCut2 =0;
110 matchTrackCut =0;
111 maxRStartPrimary = 25.0;
112 maxRStartSecondary= 360.0;
113 maxZStartPrimary = 200.0;
114 maxZStartSecondary=2000.0;
115 minREndPrimary = 400.0;
116 minREndSecondary =1000.0;
117 minZEndPrimary =2300.0;
118 minZEndSecondary =3200.0;
119 minPt = 1000;
120 }
121
122
123
124 };
125
126
133
134 public:
137 TrackStatHelper (const std::string&, const std::string&, bool careAboutTruth = true);
139 void SetCuts(const struct cuts&);
141 void addEvent (const EventContext& ctx,
142 const TrackCollection *,
143 std::vector<const Trk::Track *> &,
144 const std::vector <std::pair<HepMC::ConstGenParticlePtr,int> > &,
145 const TrackTruthCollection *,
146 const AtlasDetectorID * const,
147 const PixelID *,
148 const SCT_ID *,
150 bool,
151 const unsigned int *,
152 const unsigned int *) const;
154 void reset ();
156 void print (MsgStream &out) const;
158 void printRegion1(MsgStream &out, enum eta_region) const;
159 void printRegion2(MsgStream &out, enum eta_region, float denominator) const;
161 void printSecondary (MsgStream &out) const;
163 void printRegionSecondary(MsgStream &out, enum eta_region, float denominator) const;
164
165
167 bool printTrackSummaryRegion (MsgStream &out, enum track_types, enum eta_region) const;
169 void printTrackSummaryAverage(MsgStream &out, enum track_types, enum eta_region, int summary_type) const;
171 bool PassTrackCuts(const Trk::TrackParameters *para) const;
173 int ClassifyParticle( const HepMC::ConstGenParticlePtr& particle, const double prob) const;
174
175
176 static std::string getSummaryTypeHeader();
177
179 const std::string &key() const { return m_TrackCollectionKey; }
181 const std::string &Truthkey() const { return m_TrackTruthCollectionKey; }
182
183 private:
184
187
189 mutable std::atomic<long> m_events {} ;
190
191 template <int N_Categories, int N_Types, int N_Regions, typename T_Int=long>
192 struct Counter {
193 Counter() { reset(); }
194 void reset() {
195 for (unsigned int cat_i=0; cat_i < N_Categories; ++cat_i ) {
196 for (unsigned int type_i=0; type_i < N_Types; ++type_i) {
197 for (unsigned int eta_i=0; eta_i < N_Regions; ++eta_i) {
198 m_counter[cat_i][type_i][eta_i]=0;
199 }
200 }
201 }
202 }
203 template <typename T_IntB>
205 for (unsigned int cat_i=0; cat_i < N_Categories; ++cat_i ) {
206 for (unsigned int type_i=0; type_i < N_Types; ++type_i) {
207 for (unsigned int eta_i=0; eta_i < N_Regions; ++eta_i) {
208 m_counter[cat_i][type_i][eta_i] += a.m_counter[cat_i][type_i][eta_i];
209 }
210 }
211 }
212 return *this;
213 }
214 T_Int m_counter[N_Categories][N_Types][N_Regions];
215 };
216
217 template <int N_Categories, int N_Types, int N_Regions, int N_SubCategories, typename T_Int=long>
218 struct Counter4D {
220 void reset() {
221 for (unsigned int cat_i=0; cat_i < N_Categories; ++cat_i ) {
222 for (unsigned int type_i=0; type_i < N_Types; ++type_i) {
223 for (unsigned int eta_i=0; eta_i < N_Regions; ++eta_i) {
224 for (unsigned int sub_i=0; sub_i < N_SubCategories; ++sub_i) {
225 m_counter[cat_i][type_i][eta_i][sub_i]=0;
226 }
227 }
228 }
229 }
230 }
231 template <typename T_IntB>
233 for (unsigned int cat_i=0; cat_i < N_Categories; ++cat_i ) {
234 for (unsigned int type_i=0; type_i < N_Types; ++type_i) {
235 for (unsigned int eta_i=0; eta_i < N_Regions; ++eta_i) {
236 for (unsigned int sub_i=0; sub_i < N_SubCategories; ++sub_i) {
237 m_counter[cat_i][type_i][eta_i][sub_i] += a.m_counter[cat_i][type_i][eta_i][sub_i];
238 }
239 }
240 }
241 }
242 return *this;
243 }
244 T_Int m_counter[N_Categories][N_Types][N_Regions][N_SubCategories];
245 };
246
251
255
271
272 // The ETrackSummaryTypes should be synchronised with the arrays summaryTypes and
273 // summaryTypeName i.e. matching order and number of elements. Of these enums only
274 // two are used: kNSummaryTypes which defines the summary statistics array sizes;
275 // kNumberOfPixelHits, which is used to get counts for some denominators.
293 static const char *const s_summaryTypeName [kNSummaryTypes];
295
297 N_TRACKTYPES,
298 N_ETAREGIONS,
300 int>;
302 N_TRACKTYPES,
303 N_ETAREGIONS,
305 std::atomic<long> >;
307
308
309 void setSummaryStat(track_types track_i,
310 eta_region region_i,
311 const Trk::TrackSummary *summary,
312 TrackSummaryCounter &trackSummarySum) const
313 {
314 if (summary) {
315 for (int stype=0; stype < kNSummaryTypes; stype++) {
316 int value = summary->get(s_summaryTypes[stype]);
317 //value is -1 if undefined
318 if (value>0) {
319 trackSummarySum.m_counter[kTrackSummarySum][track_i][region_i][stype] += value;
320 trackSummarySum.m_counter[kNTrackSummaryOK][track_i][region_i][stype] ++;
321 }
322 else {
323 trackSummarySum.m_counter[kNTrackSummaryBAD][track_i][region_i][stype] ++;
324 }
325 }
326 }
327 }
328
329 mutable std::atomic<bool> m_truthMissing;
331 struct cuts m_cuts;
332
333 mutable std::mutex m_authorMutex;
334 mutable std::bitset<Trk::TrackInfo::NumberOfTrackRecoInfo> m_recoInfo ATLAS_THREAD_SAFE;
335 mutable std::bitset<Trk::TrackInfo::NumberOfTrackProperties> m_patternProperties ATLAS_THREAD_SAFE;
336
337 typedef std::multimap<HepMcParticleLink,float> recoToTruthMap;
338 };
339
340
341
342} // close of namespace
343
344#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.
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.
Counter4D< kNTrackSummaryCounter, N_TRACKTYPES, N_ETAREGIONS, kNSummaryTypes, int > TrackSummaryCounter
type statistics.
TrackStatHelper(const std::string &, const std::string &, bool careAboutTruth=true)
Constructor.
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
void addEvent(const EventContext &ctx, 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.
@ 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
Counter4D< kNTrackSummaryCounter, N_TRACKTYPES, N_ETAREGIONS, kNSummaryTypes, std::atomic< long > > TrackSummaryCounterAtomic
@ 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_ALL_SIGNAL
@ TRACK_MATCHED_PRIMARY
@ TRACK_LOWTRUTHPROB_SIGNAL
@ TRACK_MULTMATCH_SECONDARY
@ TRACK_MULTMATCH
@ TRACK_MATCHED_SIGNAL
@ TRACK_MATCHED_SECONDARY
@ TRACK_LOWTRUTHPROB
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:69
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.
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
Definition GenParticle.h:20
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 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