ATLAS Offline Software
TrackParametersPlots.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 "TrackParametersPlots.h"
12 #include "../TrackParametersHelper.h"
13 
14 
19  PlotMgr* pParent, const std::string& dirName,
20  const std::string& anaTag, const std::string& trackType ) :
21  PlotMgr( dirName, anaTag, pParent ),
22  m_trackType( trackType ) { }
23 
24 
29 {
30  StatusCode sc = bookPlots();
31  if( sc.isFailure() ) {
32  ATH_MSG_ERROR( "Failed to book track parameters plots" );
33  }
34 }
35 
36 
38 {
39  ATH_MSG_DEBUG( "Booking track parameters plots in " << getDirectory() );
40 
41  ATH_CHECK( retrieveAndBook( m_pt, m_trackType+"_pt" ) );
42  ATH_CHECK( retrieveAndBook( m_eta, m_trackType+"_eta" ) );
43  ATH_CHECK( retrieveAndBook( m_phi, m_trackType+"_phi" ) );
44  ATH_CHECK( retrieveAndBook( m_d0, m_trackType+"_d0" ) );
45  ATH_CHECK( retrieveAndBook( m_z0, m_trackType+"_z0" ) );
46  ATH_CHECK( retrieveAndBook( m_z0sin, m_trackType+"_z0sin" ) );
47  ATH_CHECK( retrieveAndBook( m_theta, m_trackType+"_theta" ) );
48  ATH_CHECK( retrieveAndBook( m_qoverp, m_trackType+"_qoverp" ) );
49  if( m_trackType == "truth" ) {
50  ATH_CHECK( retrieveAndBook( m_prodR, m_trackType+"_prodR" ) );
51  ATH_CHECK( retrieveAndBook( m_prodZ, m_trackType+"_prodZ" ) );
52  ATH_CHECK( retrieveAndBook( m_nSiHits, m_trackType+"_nSiHits" ) );
53  ATH_CHECK( retrieveAndBook( m_nSiHits_vs_eta, m_trackType+"_nSiHits_vs_eta" ) );
54  } else {
55  ATH_CHECK( retrieveAndBook( m_chi2, m_trackType+"_chi2" ) );
56  ATH_CHECK( retrieveAndBook( m_ndof, m_trackType+"_ndof" ) );
57  ATH_CHECK( retrieveAndBook( m_chi2OverNdof, m_trackType+"_chi2OverNdof" ) );
58  ATH_CHECK( retrieveAndBook( m_author, m_trackType+"_author" ) );
59  ATH_CHECK( retrieveAndBook( m_time, m_trackType+"_time" ) );
60  ATH_CHECK( retrieveAndBook( m_hasValidTime_eff_vs_eta, m_trackType+"_hasValidTime_eff_vs_eta" ) );
61  }
62  ATH_CHECK( retrieveAndBook( m_eta_vs_pt, m_trackType+"_eta_vs_pt" ) );
63  ATH_CHECK( retrieveAndBook( m_eta_vs_phi, m_trackType+"_eta_vs_phi" ) );
64  ATH_CHECK( retrieveAndBook( m_z0_vs_d0, m_trackType+"_z0_vs_d0" ) );
65  ATH_CHECK( retrieveAndBook( m_z0sin_vs_d0, m_trackType+"_z0sin_vs_d0" ) );
66 
67  return StatusCode::SUCCESS;
68 }
69 
70 
74 template< typename PARTICLE >
76  const PARTICLE& particle, float weight )
77 {
79  float ppt = pT( particle ) / Gaudi::Units::GeV;
80  float peta = eta( particle );
81  float pphi = phi( particle );
82  float pd0 = d0( particle );
83  float pz0 = z0( particle );
84  float pz0sin = z0SinTheta( particle );
85  float ptheta = theta( particle );
86  float pqoverp = qOverP( particle ); // in MeV^-1
87  float pprodR = prodR( particle );
88  float pprodZ = prodZ( particle );
89  float pnSiHits = nSiHits( particle );
90  float pchi2 = chiSquared( particle );
91  float pndof = ndof( particle );
92  float pchi2OverNdof = ( pndof > 0 ) ? pchi2 / pndof : 0.;
93  std::vector< unsigned int > pauthor = author( particle );
94 
96  ATH_CHECK( fill( m_pt, ppt, weight ) );
97  ATH_CHECK( fill( m_eta, peta, weight ) );
98  ATH_CHECK( fill( m_phi, pphi, weight ) );
99  ATH_CHECK( fill( m_d0, pd0, weight ) );
100  ATH_CHECK( fill( m_z0, pz0, weight ) );
101  ATH_CHECK( fill( m_z0sin, pz0sin, weight ) );
102  ATH_CHECK( fill( m_theta, ptheta, weight ) );
103  ATH_CHECK( fill( m_qoverp, pqoverp, weight ) );
104  if( m_trackType == "truth" ) {
105  ATH_CHECK( fill( m_prodR, pprodR, weight ) );
106  ATH_CHECK( fill( m_prodZ, pprodZ, weight ) );
107  ATH_CHECK( fill( m_nSiHits, pnSiHits, weight ) );
108  ATH_CHECK( fill( m_nSiHits_vs_eta, peta, pnSiHits, weight ) );
109  } else {
110  ATH_CHECK( fill( m_chi2, pchi2, weight ) );
111  ATH_CHECK( fill( m_ndof, pndof, weight ) );
112  ATH_CHECK( fill( m_chi2OverNdof, pchi2OverNdof, weight ) );
113  for( unsigned int i=0; i<pauthor.size(); i++ ) {
114  ATH_CHECK( fill( m_author, pauthor[i], weight ) );
115  }
116  static const SG::Accessor< uint8_t > accValidTime("hasValidTime");
117  static const SG::Accessor< float > accTime("time");
118  if( accValidTime.isAvailable( particle ) ) {
119  bool phasValidTime = hasValidTime( particle );
120  ATH_CHECK( fill( m_hasValidTime_eff_vs_eta, peta, phasValidTime, weight ) );
121  if( accTime.isAvailable( particle ) and phasValidTime ) {
122  ATH_CHECK( fill( m_time, time( particle ), weight ) );
123  }
124  }
125  }
126  ATH_CHECK( fill( m_eta_vs_pt, ppt, peta, weight ) );
127  ATH_CHECK( fill( m_eta_vs_phi, pphi, peta, weight ) );
128  ATH_CHECK( fill( m_z0_vs_d0, pd0, pz0, weight ) );
129  ATH_CHECK( fill( m_z0sin_vs_d0, pz0*std::sin(ptheta), pd0, weight ) );
130 
131  return StatusCode::SUCCESS;
132 }
133 
135  const xAOD::TrackParticle&, float weight );
136 
138  const xAOD::TruthParticle&, float weight );
139 
140 
145 {
146  ATH_MSG_DEBUG( "Finalising track parameters plots" );
148 }
IDTPM::ndof
float ndof(const U &p)
Definition: TrackParametersHelper.h:134
IDTPM::TrackParametersPlots::TrackParametersPlots
TrackParametersPlots(PlotMgr *pParent, const std::string &dirName, const std::string &anaTag, const std::string &trackType)
Constructor.
Definition: TrackParametersPlots.cxx:18
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
SG::Accessor< uint8_t >
IDTPM::z0
float z0(const U &p)
Definition: TrackParametersHelper.h:72
IDTPM::TrackParametersPlots::fillPlots
StatusCode fillPlots(const PARTICLE &particle, float weight)
Dedicated fill method (for tracks and/or truth particles)
Definition: TrackParametersPlots.cxx:75
IDTPM::TrackParametersPlots::initializePlots
void initializePlots()
Book the histograms.
Definition: TrackParametersPlots.cxx:28
IDTPM::time
float time(const U &p)
Definition: TrackParametersHelper.h:159
TrackParametersPlots.h
IDTPM::prodR
float prodR(const U &p)
Definition: TrackParametersHelper.h:93
IDTPM::phi
float phi(const U &p)
Definition: TrackParametersHelper.h:61
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
IDTPM::z0SinTheta
float z0SinTheta(const U &p)
Definition: TrackParametersHelper.h:75
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
IDTPM::theta
float theta(const U &p)
Definition: TrackParametersHelper.h:52
IDTPM::PlotMgr
Definition: PlotMgr.h:33
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
fillPlots< xAOD::TruthParticle >
template StatusCode IDTPM::TrackParametersPlots::fillPlots< xAOD::TruthParticle >(const xAOD::TruthParticle &, float weight)
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
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
fillPlots< xAOD::TrackParticle >
template StatusCode IDTPM::TrackParametersPlots::fillPlots< xAOD::TrackParticle >(const xAOD::TrackParticle &, float weight)
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
IDTPM::d0
float d0(const U &p)
Definition: TrackParametersHelper.h:84
IDTPM::TrackParametersPlots::finalizePlots
void finalizePlots()
Print out final stats on histograms.
Definition: TrackParametersPlots.cxx:144
IDTPM::pT
float pT(const U &p)
Accessor utility function for getting the value of pT.
Definition: TrackParametersHelper.h:33
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IDTPM::TrackParametersPlots::bookPlots
StatusCode bookPlots()
Definition: TrackParametersPlots.cxx:37
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
IDTPM::prodZ
float prodZ(const U &p)
Definition: TrackParametersHelper.h:102
IDTPM::qOverP
float qOverP(const U &p)
Definition: TrackParametersHelper.h:111
IDTPM::chiSquared
float chiSquared(const U &p)
Definition: TrackParametersHelper.h:128
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
IDTPM::hasValidTime
uint8_t hasValidTime(const U &p)
Definition: TrackParametersHelper.h:153
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
IDTPM::nSiHits
float nSiHits(const U &p)
Definition: TrackParametersHelper.h:427
IDTPM::author
std::vector< unsigned int > author(const U &p)
Definition: TrackParametersHelper.h:147