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 do1D ) :
25  PlotMgr( dirName, anaTag, pParent ),
26  m_testType( testType ), m_refType( refType ),
27  m_isITk( isITk ), m_doGlobalPlots( doGlobalPlots ), m_do1D( do1D )
28 {
32 }
33 
34 
39  PlotMgr* pParent,
40  const std::string& dirName,
41  const std::string& anaTag,
42  const std::string& trackType,
43  bool isITk, bool doGlobalPlots ) :
44  PlotMgr( dirName, anaTag, pParent ),
45  m_testType( trackType ), m_refType( trackType ),
46  m_isITk( isITk ), m_doGlobalPlots( doGlobalPlots ), m_do1D( true )
47 {
51 }
52 
53 
58 {
59  StatusCode sc = bookPlots();
60  if( sc.isFailure() ) {
61  ATH_MSG_ERROR( "Failed to book hits on tracks plots" );
62  }
63 }
64 
65 
67 {
68  ATH_MSG_DEBUG( "Booking hits on tracks plots in " << getDirectory() );
69 
72  if( m_do1D ) {
73  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
74  ATH_CHECK( retrieveAndBook( m_hits[ih], m_testType+"_"+m_hitParamName[ih] ) );
75  }
76 
77  if( not m_isITk ) {
78  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
79  ATH_CHECK( retrieveAndBook( m_hitsRun3[ih], m_testType+"_"+m_run3HitParamName[ih] ) );
80  }
81  }
82  }
83 
84  for( unsigned int i=0; i<NPARAMS; i++ ) {
87  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
88  ATH_CHECK( retrieveAndBook( m_hits_vs[ih][i],
89  m_testType+"_"+m_hitParamName[ih]+"_vs_"+m_refType+"_"+m_paramName[i] ) );
90  }
91 
92  if( not m_isITk ) {
93  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
94  ATH_CHECK( retrieveAndBook( m_hitsRun3_vs[ih][i],
95  m_testType+"_"+m_run3HitParamName[ih]+"_vs_"+m_refType+"_"+m_paramName[i] ) );
96  }
97  }
98 
101  for( unsigned int j=i+1; j<NPARAMS; j++ ) {
102  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
103  ATH_CHECK( retrieveAndBook( m_hits_vs2D[ih][i][j],
104  m_testType+"_"+m_hitParamName[ih]+"_vs_"+m_refType+"_"+m_paramName[i]+"_vs_"+m_paramName[j] ) );
105  }
106 
107  if( not m_isITk ) {
108  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
109  ATH_CHECK( retrieveAndBook( m_hitsRun3_vs2D[ih][i][j],
110  m_testType+"_"+m_run3HitParamName[ih]+"_vs_"+m_refType+"_"+m_paramName[i]+"_vs_"+m_paramName[j] ) );
111  }
112  }
113  } // close j loop over NPARAMS
114  } // close i loop over NPARAMS
115 
116  if( m_doGlobalPlots ) {
117  for( unsigned int i=0; i<NPARAMSMU; i++ ) {
118  if( m_do1D ) {
121  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
122  ATH_CHECK( retrieveAndBook( m_hits_vsMu[ih][i],
123  m_testType+"_"+m_hitParamName[ih]+"_vs_"+m_paramMuName[i] ) );
124  }
125 
126  if( not m_isITk ) {
127  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
128  ATH_CHECK( retrieveAndBook( m_hitsRun3_vsMu[ih][i],
129  m_testType+"_"+m_run3HitParamName[ih]+"_vs_"+m_paramMuName[i] ) );
130  }
131  }
132  } // close if m_do1D
133 
136  for( unsigned int j=0; j<NPARAMS; j++ ) {
137  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
138  ATH_CHECK( retrieveAndBook( m_hits_vsMu_vs[ih][i][j],
139  m_testType+"_"+m_hitParamName[ih]+"_vs_"+m_paramMuName[i]+"_vs_"+m_refType+"_"+m_paramName[j] ) );
140  }
141 
142  if( not m_isITk ) {
143  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
144  ATH_CHECK( retrieveAndBook( m_hitsRun3_vsMu_vs[ih][i][j],
145  m_testType+"_"+m_run3HitParamName[ih]+"_vs_"+m_paramMuName[i]+"_vs_"+m_refType+"_"+m_paramName[j] ) );
146  }
147  }
148  } // close j loop over NPARAMS
149  } // close i loop over NPARAMSMU
150  } // end if m_doGlobalPlots
151 
152  return StatusCode::SUCCESS;
153 }
154 
155 
161 template< typename PTEST, typename PREF >
163  const PTEST& ptest, const PREF& pref, float truthMu, float actualMu, float weight )
164 {
166  float hitP[ NHITPARAMSTOT ];
167  hitP[ NInnerMostPixelHits ] = nInnerMostPixelHits( ptest );
168  hitP[ NInnerMostPixelEndcapHits ] = nInnerMostPixelEndcapHits( ptest );
169  hitP[ NNextToInnerMostPixelHits ] = nNextToInnerMostPixelHits( ptest );
170  hitP[ NNextToInnerMostPixelEndcapHits ] = nNextToInnerMostPixelEndcapHits( ptest );
171  hitP[ NInnerMostPixelSharedHits ] = nInnerMostPixelSharedHits( ptest );
172  hitP[ NInnerMostPixelSharedEndcapHits ] = nInnerMostPixelSharedEndcapHits( ptest );
173  hitP[ NPixelHits ] = nPixelHits( ptest );
174  hitP[ NPixelHoles ] = nPixelHoles( ptest );
175  hitP[ NPixelSharedHits ] = nPixelSharedHits( ptest );
176  hitP[ PixeldEdx ] = pixeldEdx( ptest );
177  hitP[ NSCTHits ] = nSCTHits( ptest );
178  hitP[ NSCTHoles ] = nSCTHoles( ptest );
179  hitP[ NSCTSharedHits ] = nSCTSharedHits( ptest );
180 
181  float hitRun3P[ NRUN3HITPARAMSTOT ];
182  hitRun3P[ NTRTHits ] = ( not m_isITk ) ? nTRTHits( ptest ) : -9999.;
183  hitRun3P[ NTRTHitsXe ] = ( not m_isITk ) ? nTRTHitsXe( ptest ) : -9999.;
184  hitRun3P[ NTRTHitsAr ] = ( not m_isITk ) ? nTRTHitsAr( ptest ) : -9999.;
185  hitRun3P[ NTRTHighThresholdHits ] = ( not m_isITk ) ? nTRTHighThresholdHits( ptest ) : -9999.;
186  hitRun3P[ NTRTHighThresholdHitsXe ] = ( not m_isITk ) ? nTRTHighThresholdHitsXe( ptest ) : -9999.;
187  hitRun3P[ NTRTHighThresholdHitsAr ] = ( not m_isITk ) ? nTRTHighThresholdHitsAr( ptest ) : -9999.;
188 
190  float refP[ NPARAMS ];
191  refP[ PT ] = pT( pref ) / Gaudi::Units::GeV;
192  refP[ ETA ] = eta( pref );
193  refP[ PHI ] = phi( pref );
194 
196  float muP[ NPARAMSMU ];
197  muP[ TRUTHMU ] = truthMu;
198  muP[ ACTUALMU ] = actualMu;
199 
201 
203  if( m_do1D ) {
204  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
205  ATH_CHECK( fill( m_hits[ih], hitP[ih], weight ) );
206  }
207 
208  if( not m_isITk ) {
209  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
210  ATH_CHECK( fill( m_hitsRun3[ih], hitRun3P[ih], weight ) );
211  }
212  }
213  }
214 
215  for( unsigned int i=0; i<NPARAMS; i++ ) {
217  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
218  ATH_CHECK( fill( m_hits_vs[ih][i], refP[i], hitP[ih], weight ) );
219  }
220 
221  if( not m_isITk ) {
222  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
223  ATH_CHECK( fill( m_hitsRun3_vs[ih][i], refP[i], hitRun3P[ih], weight ) );
224  }
225  }
226 
228  for( unsigned int j=i+1; j<NPARAMS; j++ ) {
229  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
230  ATH_CHECK( fill( m_hits_vs2D[ih][i][j], refP[i], refP[j], hitP[ih], weight ) );
231  }
232 
233  if( not m_isITk ) {
234  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
235  ATH_CHECK( fill( m_hitsRun3_vs2D[ih][i][j], refP[i], refP[j], hitRun3P[ih], weight ) );
236  }
237  }
238  } // close j loop over NPARAMS
239  } // close i loop over NPARAMS
240 
241  if( m_doGlobalPlots ) {
242  for( unsigned int i=0; i<NPARAMSMU; i++ ) {
243  if( m_do1D ) {
245  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
246  ATH_CHECK( fill( m_hits_vsMu[ih][i], muP[i], hitP[ih], weight ) );
247  }
248 
249  if( not m_isITk ) {
250  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
251  ATH_CHECK( fill( m_hitsRun3_vsMu[ih][i], muP[i], hitRun3P[ih], weight ) );
252  }
253  }
254  } // close if m_do1D
255 
257  for( unsigned int j=0; j<NPARAMS; j++ ) {
258  for( unsigned int ih=0; ih<m_NHITPARAMS; ih++ ) {
259  ATH_CHECK( fill( m_hits_vsMu_vs[ih][i][j], muP[i], refP[j], hitP[ih], weight ) );
260  }
261 
262  if( not m_isITk ) {
263  for( unsigned int ih=0; ih<m_NRUN3HITPARAMS; ih++ ) {
264  ATH_CHECK( fill( m_hitsRun3_vsMu_vs[ih][i][j], muP[i], refP[j], hitRun3P[ih], weight ) );
265  }
266  }
267  } // close j loop over NPARAMS
268  } // close i loop over NPARAMSMU
269  } // end if m_doGlobalPlots
270 
271  return StatusCode::SUCCESS;
272 }
273 
275  const xAOD::TrackParticle&, const xAOD::TrackParticle&, float, float, float );
276 
278  const xAOD::TruthParticle&, const xAOD::TruthParticle&, float, float, float );
279 
281  const xAOD::TrackParticle&, const xAOD::TruthParticle&, float, float, float );
282 
284  const xAOD::TruthParticle&, const xAOD::TrackParticle&, float, float, float );
285 
286 
292 template< typename PARTICLE >
294  const PARTICLE& particle, float truthMu, float actualMu, float weight )
295 {
296  ATH_CHECK( fillPlots< PARTICLE >( particle, particle, truthMu, actualMu, weight ) );
297  return StatusCode::SUCCESS;
298 }
299 
301  const xAOD::TrackParticle&, float, float, float );
302 
304  const xAOD::TruthParticle&, float, float, float );
305 
306 
311 {
312  ATH_MSG_DEBUG( "Finalising hits on tracks plots" );
314 }
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:17
IDTPM::nNextToInnerMostPixelEndcapHits
float nNextToInnerMostPixelEndcapHits(const U &p)
Definition: TrackParametersHelper.h:296
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
IDTPM::HitsOnTracksPlots::m_NHITPARAMS
unsigned int m_NHITPARAMS
Definition: HitsOnTracksPlots.h:112
IDTPM::pixeldEdx
float pixeldEdx(const U &p)
Definition: TrackParametersHelper.h:355
IDTPM::HitsOnTracksPlots::NRUN3HITPARAMSBASE
@ NRUN3HITPARAMSBASE
Definition: HitsOnTracksPlots.h:157
IDTPM::nPixelHoles
float nPixelHoles(const U &p)
Definition: TrackParametersHelper.h:336
IDTPM::nInnerMostPixelSharedHits
float nInnerMostPixelSharedHits(const U &p)
Definition: TrackParametersHelper.h:306
IDTPM::nTRTHitsAr
float nTRTHitsAr(const U &p)
Definition: TrackParametersHelper.h:430
RoiUtil::PHI
@ PHI
Definition: RoiSerialise.cxx:31
IDTPM::nPixelHits
float nPixelHits(const U &p)
Definition: TrackParametersHelper.h:326
IDTPM::phi
float phi(const U &p)
Definition: TrackParametersHelper.h:59
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
IDTPM::nTRTHighThresholdHitsXe
float nTRTHighThresholdHitsXe(const U &p)
Definition: TrackParametersHelper.h:450
IDTPM::nSCTSharedHits
float nSCTSharedHits(const U &p)
Definition: TrackParametersHelper.h:385
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
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:66
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:41
lumiFormat.i
int i
Definition: lumiFormat.py:85
IDTPM::nSCTHits
float nSCTHits(const U &p)
Definition: TrackParametersHelper.h:365
IDTPM::nTRTHits
float nTRTHits(const U &p)
Definition: TrackParametersHelper.h:409
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:419
IDTPM::pT
float pT(const U &p)
Accessor utility function for getting the value of pT.
Definition: TrackParametersHelper.h:31
IDTPM::HitsOnTracksPlots::initializePlots
void initializePlots()
Book the histograms.
Definition: HitsOnTracksPlots.cxx:57
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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 do1D=false)
Constructor A for test_Hits-vs-reference plots e.g.
Definition: HitsOnTracksPlots.cxx:18
IDTPM::nSCTHoles
float nSCTHoles(const U &p)
Definition: TrackParametersHelper.h:375
IDTPM::nTRTHighThresholdHitsAr
float nTRTHighThresholdHitsAr(const U &p)
Definition: TrackParametersHelper.h:461
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
IDTPM::HitsOnTracksPlots::NHITPARAMSBASE
@ NHITPARAMSBASE
Definition: HitsOnTracksPlots.h:110
IDTPM::nInnerMostPixelEndcapHits
float nInnerMostPixelEndcapHits(const U &p)
Definition: TrackParametersHelper.h:276
IDTPM::nInnerMostPixelSharedEndcapHits
float nInnerMostPixelSharedEndcapHits(const U &p)
Definition: TrackParametersHelper.h:316
RoiUtil::ETA
@ ETA
Definition: RoiSerialise.cxx:30
IDTPM::HitsOnTracksPlots::finalizePlots
void finalizePlots()
Print out final stats on histograms.
Definition: HitsOnTracksPlots.cxx:310
IDTPM::nPixelSharedHits
float nPixelSharedHits(const U &p)
Definition: TrackParametersHelper.h:346
fillPlots< xAOD::TruthParticle, xAOD::TrackParticle >
template StatusCode IDTPM::HitsOnTracksPlots::fillPlots< xAOD::TruthParticle, xAOD::TrackParticle >(const xAOD::TruthParticle &, const xAOD::TrackParticle &, float, float, float)
IDTPM::HitsOnTracksPlots::m_NRUN3HITPARAMS
unsigned int m_NRUN3HITPARAMS
Definition: HitsOnTracksPlots.h:159
IDTPM::nInnerMostPixelHits
float nInnerMostPixelHits(const U &p)
Definition: TrackParametersHelper.h:266
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
IDTPM::nTRTHighThresholdHits
float nTRTHighThresholdHits(const U &p)
Definition: TrackParametersHelper.h:440
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:162
H5Utils::internal::PT
H5::PredType PT
Definition: H5Traits.cxx:15
IDTPM::nNextToInnerMostPixelHits
float nNextToInnerMostPixelHits(const U &p)
Definition: TrackParametersHelper.h:286