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 ) :
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 )
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 ) :
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 )
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 
184  float hitRun3P[ NRUN3HITPARAMSTOT ];
185  hitRun3P[ NTRTHits ] = ( not m_isITk ) ? nTRTHits( ptest ) : -9999.;
186  hitRun3P[ NTRTHitsXe ] = ( not m_isITk ) ? nTRTHitsXe( ptest ) : -9999.;
187  hitRun3P[ NTRTHitsAr ] = ( not m_isITk ) ? nTRTHitsAr( ptest ) : -9999.;
188  hitRun3P[ NTRTHighThresholdHits ] = ( not m_isITk ) ? nTRTHighThresholdHits( ptest ) : -9999.;
189  hitRun3P[ NTRTHighThresholdHitsXe ] = ( not m_isITk ) ? nTRTHighThresholdHitsXe( ptest ) : -9999.;
190  hitRun3P[ NTRTHighThresholdHitsAr ] = ( not m_isITk ) ? nTRTHighThresholdHitsAr( ptest ) : -9999.;
191 
193  float refP[ NPARAMS ];
194  refP[ PT ] = pT( pref ) / Gaudi::Units::GeV;
195  refP[ ETA ] = eta( pref );
196  refP[ PHI ] = phi( pref );
197 
199  float muP[ NPARAMSMU ];
200  muP[ TRUTHMU ] = truthMu;
201  muP[ ACTUALMU ] = actualMu;
202 
204 
206  if( m_do1D ) {
207  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
208  ATH_CHECK( fill( m_hits[ih], hitP[ih], weight ) );
209  }
210 
211  if( not m_isITk ) {
212  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
213  ATH_CHECK( fill( m_hitsRun3[ih], hitRun3P[ih], weight ) );
214  }
215  }
216  }
217 
218  for( unsigned int i=0; i<NPARAMS; i++ ) {
220  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
221  ATH_CHECK( fill( m_hits_vs[ih][i], refP[i], hitP[ih], weight ) );
222  }
223 
224  if( not m_isITk ) {
225  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
226  ATH_CHECK( fill( m_hitsRun3_vs[ih][i], refP[i], hitRun3P[ih], weight ) );
227  }
228  }
229 
231  for( unsigned int j=i+1; j<NPARAMS; j++ ) {
232  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
233  ATH_CHECK( fill( m_hits_vs2D[ih][i][j], refP[i], refP[j], hitP[ih], weight ) );
234  }
235 
236  if( not m_isITk ) {
237  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
238  ATH_CHECK( fill( m_hitsRun3_vs2D[ih][i][j], refP[i], refP[j], hitRun3P[ih], weight ) );
239  }
240  }
241  } // close j loop over NPARAMS
242  } // close i loop over NPARAMS
243 
244  if( m_doGlobalPlots ) {
245  for( unsigned int i=0; i<NPARAMSMU; i++ ) {
246  if( not m_doTruthMuPlots and i==TRUTHMU ) continue;
247  if( m_do1D ) {
249  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
250  ATH_CHECK( fill( m_hits_vsMu[ih][i], muP[i], hitP[ih], weight ) );
251  }
252 
253  if( not m_isITk ) {
254  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
255  ATH_CHECK( fill( m_hitsRun3_vsMu[ih][i], muP[i], hitRun3P[ih], weight ) );
256  }
257  }
258  } // close if m_do1D
259 
261  for( unsigned int j=0; j<NPARAMS; j++ ) {
262  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
263  ATH_CHECK( fill( m_hits_vsMu_vs[ih][i][j], muP[i], refP[j], hitP[ih], weight ) );
264  }
265 
266  if( not m_isITk ) {
267  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
268  ATH_CHECK( fill( m_hitsRun3_vsMu_vs[ih][i][j], muP[i], refP[j], hitRun3P[ih], weight ) );
269  }
270  }
271  } // close j loop over NPARAMS
272  } // close i loop over NPARAMSMU
273  } // end if m_doGlobalPlots
274 
275  return StatusCode::SUCCESS;
276 }
277 
279  const xAOD::TrackParticle&, const xAOD::TrackParticle&, float, float, float );
280 
282  const xAOD::TruthParticle&, const xAOD::TruthParticle&, float, float, float );
283 
285  const xAOD::TrackParticle&, const xAOD::TruthParticle&, float, float, float );
286 
288  const xAOD::TruthParticle&, const xAOD::TrackParticle&, float, float, float );
289 
290 
296 template< typename PARTICLE >
298  const PARTICLE& particle, float truthMu, float actualMu, float weight )
299 {
300  ATH_CHECK( fillPlots< PARTICLE >( particle, particle, truthMu, actualMu, weight ) );
301  return StatusCode::SUCCESS;
302 }
303 
305  const xAOD::TrackParticle&, float, float, float );
306 
308  const xAOD::TruthParticle&, float, float, float );
309 
310 
315 {
316  ATH_MSG_DEBUG( "Finalising hits on tracks plots" );
318 }
fillPlots< xAOD::TrackParticle >
template StatusCode IDTPM::HitsOnTracksPlots::fillPlots< xAOD::TrackParticle >(const xAOD::TrackParticle &, const xAOD::TrackParticle &, float, float, float)
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:18
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:115
IDTPM::pixeldEdx
float pixeldEdx(const U &p)
Definition: TrackParametersHelper.h:383
IDTPM::HitsOnTracksPlots::NRUN3HITPARAMSBASE
@ NRUN3HITPARAMSBASE
Definition: HitsOnTracksPlots.h:160
IDTPM::nPixelHoles
float nPixelHoles(const U &p)
Definition: TrackParametersHelper.h:364
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::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::HitsOnTracksPlots::bookPlots
StatusCode bookPlots()
Definition: HitsOnTracksPlots.cxx:68
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::nSCTHits
float nSCTHits(const U &p)
Definition: TrackParametersHelper.h:393
IDTPM::nTRTHits
float nTRTHits(const U &p)
Definition: TrackParametersHelper.h:446
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::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::HitsOnTracksPlots::NHITPARAMSBASE
@ NHITPARAMSBASE
Definition: HitsOnTracksPlots.h:113
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::HitsOnTracksPlots::finalizePlots
void finalizePlots()
Print out final stats on histograms.
Definition: HitsOnTracksPlots.cxx:314
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:162
IDTPM::nInnerMostPixelHits
float nInnerMostPixelHits(const U &p)
Definition: TrackParametersHelper.h:294
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
IDTPM::nTRTHighThresholdHits
float nTRTHighThresholdHits(const U &p)
Definition: TrackParametersHelper.h:477
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)
Constructor A for test_Hits-vs-reference plots e.g.
Definition: HitsOnTracksPlots.cxx:18
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