ATLAS Offline Software
HitsOnTracksPlots.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 #include "HitsOnTracksPlots.h"
12 #include "../TrackParametersHelper.h"
13 
14 
19  PlotMgr* pParent,
20  const std::string& dirName,
21  const std::string& anaTag,
22  const std::string& testType,
23  const std::string& refType,
24  bool isITk, bool doGlobalPlots, bool doTruthMuPlots, bool do1D, bool doExpert ) :
25  PlotMgr( dirName, anaTag, pParent ),
26  m_testType( testType ), m_refType( refType ),
27  m_isITk( isITk ), m_doGlobalPlots( doGlobalPlots ),
28  m_doTruthMuPlots( doTruthMuPlots ), m_do1D( do1D ), m_doExpert( doExpert )
29 {
33 }
34 
35 
40  PlotMgr* pParent,
41  const std::string& dirName,
42  const std::string& anaTag,
43  const std::string& trackType,
44  bool isITk, bool doGlobalPlots, bool doTruthMuPlots, bool doExpert ) :
45  PlotMgr( dirName, anaTag, pParent ),
46  m_testType( trackType ), m_refType( trackType ),
47  m_isITk( isITk ), m_doGlobalPlots( doGlobalPlots ),
48  m_doTruthMuPlots( doTruthMuPlots ), m_do1D( true ), m_doExpert( doExpert )
49 {
53 }
54 
55 
60 {
61  StatusCode sc = bookPlots();
62  if( sc.isFailure() ) {
63  ATH_MSG_ERROR( "Failed to book hits on tracks plots" );
64  }
65 }
66 
67 
69 {
70  ATH_MSG_DEBUG( "Booking hits on tracks plots in " << getDirectory() );
71 
74  if( m_do1D ) {
75  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
76  ATH_CHECK( retrieveAndBook( m_hits[ih], m_testType+"_"+m_hitParamName[ih] ) );
77  }
78 
79  if( not m_isITk ) {
80  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
81  ATH_CHECK( retrieveAndBook( m_hitsRun3[ih], m_testType+"_"+m_run3HitParamName[ih] ) );
82  }
83  }
84  }
85 
86  for( unsigned int i=0; i<NPARAMS; i++ ) {
89  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
90  ATH_CHECK( retrieveAndBook( m_hits_vs[ih][i],
91  m_testType+"_"+m_hitParamName[ih]+"_vs_"+m_refType+"_"+m_paramName[i] ) );
92  }
93 
94  if( not m_isITk ) {
95  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
96  ATH_CHECK( retrieveAndBook( m_hitsRun3_vs[ih][i],
97  m_testType+"_"+m_run3HitParamName[ih]+"_vs_"+m_refType+"_"+m_paramName[i] ) );
98  }
99  }
100 
103  for( unsigned int j=i+1; j<NPARAMS; j++ ) {
104  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
105  ATH_CHECK( retrieveAndBook( m_hits_vs2D[ih][i][j],
106  m_testType+"_"+m_hitParamName[ih]+"_vs_"+m_refType+"_"+m_paramName[i]+"_vs_"+m_paramName[j] ) );
107  }
108 
109  if( not m_isITk ) {
110  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
111  ATH_CHECK( retrieveAndBook( m_hitsRun3_vs2D[ih][i][j],
112  m_testType+"_"+m_run3HitParamName[ih]+"_vs_"+m_refType+"_"+m_paramName[i]+"_vs_"+m_paramName[j] ) );
113  }
114  }
115  } // close j loop over NPARAMS
116  } // close i loop over NPARAMS
117 
118  if( m_doGlobalPlots ) {
119  for( unsigned int i=0; i<NPARAMSMU; i++ ) {
120  if( not m_doTruthMuPlots and i==TRUTHMU ) continue;
121  if( m_do1D ) {
124  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
125  ATH_CHECK( retrieveAndBook( m_hits_vsMu[ih][i],
126  m_testType+"_"+m_hitParamName[ih]+"_vs_"+m_paramMuName[i] ) );
127  }
128 
129  if( not m_isITk ) {
130  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
131  ATH_CHECK( retrieveAndBook( m_hitsRun3_vsMu[ih][i],
132  m_testType+"_"+m_run3HitParamName[ih]+"_vs_"+m_paramMuName[i] ) );
133  }
134  }
135  } // close if m_do1D
136 
139  for( unsigned int j=0; j<NPARAMS; j++ ) {
140  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
141  ATH_CHECK( retrieveAndBook( m_hits_vsMu_vs[ih][i][j],
142  m_testType+"_"+m_hitParamName[ih]+"_vs_"+m_paramMuName[i]+"_vs_"+m_refType+"_"+m_paramName[j] ) );
143  }
144 
145  if( not m_isITk ) {
146  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
147  ATH_CHECK( retrieveAndBook( m_hitsRun3_vsMu_vs[ih][i][j],
148  m_testType+"_"+m_run3HitParamName[ih]+"_vs_"+m_paramMuName[i]+"_vs_"+m_refType+"_"+m_paramName[j] ) );
149  }
150  }
151  } // close j loop over NPARAMS
152  } // close i loop over NPARAMSMU
153  } // end if m_doGlobalPlots
154 
155  return StatusCode::SUCCESS;
156 }
157 
158 
164 template< typename PTEST, typename PREF >
166  const PTEST& ptest, const PREF& pref, float truthMu, float actualMu, float weight )
167 {
169  float hitP[ NHITPARAMSTOT ];
170  hitP[ NInnerMostPixelHits ] = nInnerMostPixelHits( ptest );
171  hitP[ NInnerMostPixelEndcapHits ] = nInnerMostPixelEndcapHits( ptest );
172  hitP[ NNextToInnerMostPixelHits ] = nNextToInnerMostPixelHits( ptest );
173  hitP[ NNextToInnerMostPixelEndcapHits ] = nNextToInnerMostPixelEndcapHits( ptest );
174  hitP[ NInnerMostPixelSharedHits ] = nInnerMostPixelSharedHits( ptest );
175  hitP[ NInnerMostPixelSharedEndcapHits ] = nInnerMostPixelSharedEndcapHits( ptest );
176  hitP[ NPixelHits ] = nPixelHits( ptest );
177  hitP[ NPixelHoles ] = nPixelHoles( ptest );
178  hitP[ NPixelSharedHits ] = nPixelSharedHits( ptest );
179  hitP[ PixeldEdx ] = pixeldEdx( ptest );
180  hitP[ NSCTHits ] = nSCTHits( ptest );
181  hitP[ NSCTHoles ] = nSCTHoles( ptest );
182  hitP[ NSCTSharedHits ] = nSCTSharedHits( ptest );
183  hitP[ NInnerMostPixelOutliers ] = nInnerMostPixelOutliers( ptest );
184  hitP[ NInnerMostPixelEndcapOutliers ] = nInnerMostPixelEndcapOutliers( ptest );
185  hitP[ NInnerMostPixelSplitHits ] = nInnerMostPixelSplitHits( ptest );
186  hitP[ NInnerMostPixelSplitEndcapHits ] = nInnerMostPixelSplitEndcapHits( ptest );
187  hitP[ NExpectedInnerMostPixelHits ] = nExpectedInnerMostPixelHits( ptest );
188  hitP[ NExpectedNextToInnerMostPixelHits ] = nExpectedNextToInnerMostPixelHits( ptest );
189  hitP[ NPixelOutliers ] = nPixelOutliers( ptest );
190  hitP[ NPixelContribLayers ] = nPixelContribLayers( ptest );
191  hitP[ NPixelSplitHits ] = nPixelSplitHits( ptest );
192  hitP[ NPixelGangedHits ] = nPixelGangedHits( ptest );
193  hitP[ NPixelGangedHitsFlaggedFakes ] = nPixelGangedHitsFlaggedFakes( ptest );
194  hitP[ NPixelDeadSensors ] = nPixelDeadSensors( ptest );
195  hitP[ NSCTOutliers ] = nSCTOutliers( ptest );
196  hitP[ NSCTDoubleHoles ] = nSCTDoubleHoles( ptest );
197  hitP[ NSCTDeadSensors ] = nSCTDeadSensors( ptest );
198 
199  float hitRun3P[ NRUN3HITPARAMSTOT ];
200  hitRun3P[ NTRTHits ] = ( not m_isITk ) ? nTRTHits( ptest ) : -9999.;
201  hitRun3P[ NTRTHitsXe ] = ( not m_isITk ) ? nTRTHitsXe( ptest ) : -9999.;
202  hitRun3P[ NTRTHitsAr ] = ( not m_isITk ) ? nTRTHitsAr( ptest ) : -9999.;
203  hitRun3P[ NTRTHighThresholdHits ] = ( not m_isITk ) ? nTRTHighThresholdHits( ptest ) : -9999.;
204  hitRun3P[ NTRTHighThresholdHitsXe ] = ( not m_isITk ) ? nTRTHighThresholdHitsXe( ptest ) : -9999.;
205  hitRun3P[ NTRTHighThresholdHitsAr ] = ( not m_isITk ) ? nTRTHighThresholdHitsAr( ptest ) : -9999.;
206 
208  float refP[ NPARAMS ];
209  refP[ PT ] = pT( pref ) / Gaudi::Units::GeV;
210  refP[ ETA ] = eta( pref );
211  refP[ PHI ] = phi( pref );
212 
214  float muP[ NPARAMSMU ];
215  muP[ TRUTHMU ] = truthMu;
216  muP[ ACTUALMU ] = actualMu;
217 
219 
221  if( m_do1D ) {
222  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
223  ATH_CHECK( fill( m_hits[ih], hitP[ih], weight ) );
224  }
225 
226  if( not m_isITk ) {
227  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
228  ATH_CHECK( fill( m_hitsRun3[ih], hitRun3P[ih], weight ) );
229  }
230  }
231  }
232 
233  for( unsigned int i=0; i<NPARAMS; i++ ) {
235  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
236  ATH_CHECK( fill( m_hits_vs[ih][i], refP[i], hitP[ih], weight ) );
237  }
238 
239  if( not m_isITk ) {
240  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
241  ATH_CHECK( fill( m_hitsRun3_vs[ih][i], refP[i], hitRun3P[ih], weight ) );
242  }
243  }
244 
246  for( unsigned int j=i+1; j<NPARAMS; j++ ) {
247  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
248  ATH_CHECK( fill( m_hits_vs2D[ih][i][j], refP[i], refP[j], hitP[ih], weight ) );
249  }
250 
251  if( not m_isITk ) {
252  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
253  ATH_CHECK( fill( m_hitsRun3_vs2D[ih][i][j], refP[i], refP[j], hitRun3P[ih], weight ) );
254  }
255  }
256  } // close j loop over NPARAMS
257  } // close i loop over NPARAMS
258 
259  if( m_doGlobalPlots ) {
260  for( unsigned int i=0; i<NPARAMSMU; i++ ) {
261  if( not m_doTruthMuPlots and i==TRUTHMU ) continue;
262  if( m_do1D ) {
264  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
265  ATH_CHECK( fill( m_hits_vsMu[ih][i], muP[i], hitP[ih], weight ) );
266  }
267 
268  if( not m_isITk ) {
269  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
270  ATH_CHECK( fill( m_hitsRun3_vsMu[ih][i], muP[i], hitRun3P[ih], weight ) );
271  }
272  }
273  } // close if m_do1D
274 
276  for( unsigned int j=0; j<NPARAMS; j++ ) {
277  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
278  ATH_CHECK( fill( m_hits_vsMu_vs[ih][i][j], muP[i], refP[j], hitP[ih], weight ) );
279  }
280 
281  if( not m_isITk ) {
282  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
283  ATH_CHECK( fill( m_hitsRun3_vsMu_vs[ih][i][j], muP[i], refP[j], hitRun3P[ih], weight ) );
284  }
285  }
286  } // close j loop over NPARAMS
287  } // close i loop over NPARAMSMU
288  } // end if m_doGlobalPlots
289 
290  return StatusCode::SUCCESS;
291 }
292 
294  const xAOD::TrackParticle&, const xAOD::TrackParticle&, float, float, float );
295 
297  const xAOD::TruthParticle&, const xAOD::TruthParticle&, float, float, float );
298 
300  const xAOD::TrackParticle&, const xAOD::TruthParticle&, float, float, float );
301 
303  const xAOD::TruthParticle&, const xAOD::TrackParticle&, float, float, float );
304 
305 
311 template< typename PARTICLE >
313  const PARTICLE& particle, float truthMu, float actualMu, float weight )
314 {
315  ATH_CHECK( fillPlots< PARTICLE >( particle, particle, truthMu, actualMu, weight ) );
316  return StatusCode::SUCCESS;
317 }
318 
320  const xAOD::TrackParticle&, float, float, float );
321 
323  const xAOD::TruthParticle&, float, float, float );
324 
325 
330 {
331  ATH_MSG_DEBUG( "Finalising hits on tracks plots" );
333 }
fillPlots< xAOD::TrackParticle >
template StatusCode IDTPM::HitsOnTracksPlots::fillPlots< xAOD::TrackParticle >(const xAOD::TrackParticle &, const xAOD::TrackParticle &, float, float, float)
IDTPM::nPixelDeadSensors
float nPixelDeadSensors(const U &p)
Definition: TrackParametersHelper.h:642
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
IDTPM::nNextToInnerMostPixelEndcapHits
float nNextToInnerMostPixelEndcapHits(const U &p)
Definition: TrackParametersHelper.h:324
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:79
IDTPM::HitsOnTracksPlots::m_NHITPARAMS
unsigned int m_NHITPARAMS
Definition: HitsOnTracksPlots.h:118
IDTPM::pixeldEdx
float pixeldEdx(const U &p)
Definition: TrackParametersHelper.h:383
IDTPM::HitsOnTracksPlots::NRUN3HITPARAMSBASE
@ NRUN3HITPARAMSBASE
Definition: HitsOnTracksPlots.h:163
IDTPM::nPixelHoles
float nPixelHoles(const U &p)
Definition: TrackParametersHelper.h:364
IDTPM::nPixelOutliers
float nPixelOutliers(const U &p)
Definition: TrackParametersHelper.h:582
IDTPM::nPixelGangedHitsFlaggedFakes
float nPixelGangedHitsFlaggedFakes(const U &p)
Definition: TrackParametersHelper.h:630
IDTPM::HitsOnTracksPlots::NHITPARAMSTOT
@ NHITPARAMSTOT
Definition: HitsOnTracksPlots.h:115
IDTPM::nInnerMostPixelSharedHits
float nInnerMostPixelSharedHits(const U &p)
Definition: TrackParametersHelper.h:334
IDTPM::nTRTHitsAr
float nTRTHitsAr(const U &p)
Definition: TrackParametersHelper.h:467
PrintTrkAnaSummary.dirName
dirName
Definition: PrintTrkAnaSummary.py:275
RoiUtil::PHI
@ PHI
Definition: RoiSerialise.cxx:31
IDTPM::nInnerMostPixelEndcapOutliers
float nInnerMostPixelEndcapOutliers(const U &p)
Definition: TrackParametersHelper.h:522
IDTPM::nPixelHits
float nPixelHits(const U &p)
Definition: TrackParametersHelper.h:354
IDTPM::phi
float phi(const U &p)
Definition: TrackParametersHelper.h:61
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
IDTPM::nTRTHighThresholdHitsXe
float nTRTHighThresholdHitsXe(const U &p)
Definition: TrackParametersHelper.h:487
IDTPM::nSCTSharedHits
float nSCTSharedHits(const U &p)
Definition: TrackParametersHelper.h:413
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:190
fillPlots< xAOD::TruthParticle >
template StatusCode IDTPM::HitsOnTracksPlots::fillPlots< xAOD::TruthParticle >(const xAOD::TruthParticle &, const xAOD::TruthParticle &, float, float, float)
IDTPM::nExpectedNextToInnerMostPixelHits
float nExpectedNextToInnerMostPixelHits(const U &p)
Definition: TrackParametersHelper.h:570
IDTPM::HitsOnTracksPlots::bookPlots
StatusCode bookPlots()
Definition: HitsOnTracksPlots.cxx:68
IDTPM::nExpectedInnerMostPixelHits
float nExpectedInnerMostPixelHits(const U &p)
Definition: TrackParametersHelper.h:558
fillPlots< xAOD::TrackParticle, xAOD::TruthParticle >
template StatusCode IDTPM::HitsOnTracksPlots::fillPlots< xAOD::TrackParticle, xAOD::TruthParticle >(const xAOD::TrackParticle &, const xAOD::TruthParticle &, float, float, float)
IDTPM::PlotMgr
Definition: PlotMgr.h:33
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
IDTPM::eta
float eta(const U &p)
Accessor utility function for getting the value of eta.
Definition: TrackParametersHelper.h:43
lumiFormat.i
int i
Definition: lumiFormat.py:85
IDTPM::nPixelSplitHits
float nPixelSplitHits(const U &p)
Definition: TrackParametersHelper.h:606
IDTPM::nSCTHits
float nSCTHits(const U &p)
Definition: TrackParametersHelper.h:393
IDTPM::nTRTHits
float nTRTHits(const U &p)
Definition: TrackParametersHelper.h:446
IDTPM::nSCTOutliers
float nSCTOutliers(const U &p)
Definition: TrackParametersHelper.h:654
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
HitsOnTracksPlots.h
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
IDTPM::nTRTHitsXe
float nTRTHitsXe(const U &p)
Definition: TrackParametersHelper.h:456
IDTPM::HitsOnTracksPlots::HitsOnTracksPlots
HitsOnTracksPlots(PlotMgr *pParent, const std::string &dirName, const std::string &anaTag, const std::string &testType, const std::string &refType, bool isITk, bool doGlobalPlots=false, bool doTruthMuPlots=false, bool do1D=false, bool doExpert=false)
Constructor A for test_Hits-vs-reference plots e.g.
Definition: HitsOnTracksPlots.cxx:18
IDTPM::nPixelGangedHits
float nPixelGangedHits(const U &p)
Definition: TrackParametersHelper.h:618
IDTPM::pT
float pT(const U &p)
Accessor utility function for getting the value of pT.
Definition: TrackParametersHelper.h:33
IDTPM::HitsOnTracksPlots::initializePlots
void initializePlots()
Book the histograms.
Definition: HitsOnTracksPlots.cxx:59
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IDTPM::nSCTHoles
float nSCTHoles(const U &p)
Definition: TrackParametersHelper.h:403
IDTPM::nTRTHighThresholdHitsAr
float nTRTHighThresholdHitsAr(const U &p)
Definition: TrackParametersHelper.h:498
IDTPM::nInnerMostPixelSplitEndcapHits
float nInnerMostPixelSplitEndcapHits(const U &p)
Definition: TrackParametersHelper.h:546
IDTPM::HitsOnTracksPlots::NHITPARAMSBASE
@ NHITPARAMSBASE
Definition: HitsOnTracksPlots.h:116
IDTPM::nInnerMostPixelEndcapHits
float nInnerMostPixelEndcapHits(const U &p)
Definition: TrackParametersHelper.h:304
IDTPM::nInnerMostPixelSharedEndcapHits
float nInnerMostPixelSharedEndcapHits(const U &p)
Definition: TrackParametersHelper.h:344
RoiUtil::ETA
@ ETA
Definition: RoiSerialise.cxx:30
IDTPM::nInnerMostPixelOutliers
float nInnerMostPixelOutliers(const U &p)
Definition: TrackParametersHelper.h:510
IDTPM::HitsOnTracksPlots::finalizePlots
void finalizePlots()
Print out final stats on histograms.
Definition: HitsOnTracksPlots.cxx:329
IDTPM::nInnerMostPixelSplitHits
float nInnerMostPixelSplitHits(const U &p)
Definition: TrackParametersHelper.h:534
IDTPM::nPixelSharedHits
float nPixelSharedHits(const U &p)
Definition: TrackParametersHelper.h:374
fillPlots< xAOD::TruthParticle, xAOD::TrackParticle >
template StatusCode IDTPM::HitsOnTracksPlots::fillPlots< xAOD::TruthParticle, xAOD::TrackParticle >(const xAOD::TruthParticle &, const xAOD::TrackParticle &, float, float, float)
lumiFormat.fill
fill
Definition: lumiFormat.py:104
IDTPM::HitsOnTracksPlots::m_NRUN3HITPARAMS
unsigned int m_NRUN3HITPARAMS
Definition: HitsOnTracksPlots.h:165
GlobalMonitoring.doExpert
doExpert
Definition: GlobalMonitoring.py:437
IDTPM::nInnerMostPixelHits
float nInnerMostPixelHits(const U &p)
Definition: TrackParametersHelper.h:294
IDTPM::HitsOnTracksPlots::m_doExpert
bool m_doExpert
Definition: HitsOnTracksPlots.h:83
IDTPM::nSCTDeadSensors
float nSCTDeadSensors(const U &p)
Definition: TrackParametersHelper.h:678
IDTPM::nSCTDoubleHoles
float nSCTDoubleHoles(const U &p)
Definition: TrackParametersHelper.h:666
IDTPM::nPixelContribLayers
float nPixelContribLayers(const U &p)
Definition: TrackParametersHelper.h:594
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:44
IDTPM::nTRTHighThresholdHits
float nTRTHighThresholdHits(const U &p)
Definition: TrackParametersHelper.h:477
IDTPM::HitsOnTracksPlots::fillPlots
StatusCode fillPlots(const PTEST &ptest, const PREF &pref, float truthMu, float actualMu, float weight)
Dedicated fill method A (for tracks and/or truth particles) for test_Hits-vs-reference plots.
Definition: HitsOnTracksPlots.cxx:165
H5Utils::internal::PT
H5::PredType PT
Definition: H5Traits.cxx:15
IDTPM::nNextToInnerMostPixelHits
float nNextToInnerMostPixelHits(const U &p)
Definition: TrackParametersHelper.h:314