ATLAS Offline Software
Loading...
Searching...
No Matches
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
9
14
15
20 PlotMgr* pParent, const std::string& dirName,
21 const std::string& anaTag, const std::string& trackType,
22 bool plotErrors, bool recomputeIP ) :
23 PlotMgr( dirName, anaTag, pParent ),
24 m_trackType( trackType ),
25 m_plotErrors( plotErrors ), m_recomputeIP( recomputeIP ) { }
26
27
32{
33 StatusCode sc = bookPlots();
34 if( sc.isFailure() ) {
35 ATH_MSG_ERROR( "Failed to book track parameters plots" );
36 }
37}
38
39
41{
42 ATH_MSG_DEBUG( "Booking track parameters plots in " << getDirectory() );
43
52 if( m_trackType == "truth" ) {
57 } else {
63 ATH_CHECK( retrieveAndBook( m_hasValidTime_eff_vs_eta, m_trackType+"_hasValidTime_eff_vs_eta" ) );
64 }
69
70 if( m_plotErrors ) {
72 ATH_CHECK( retrieveAndBook( m_sigma_pt, "sigma_"+m_trackType+"_pt" ) );
73 ATH_CHECK( retrieveAndBook( m_sigma_eta, "sigma_"+m_trackType+"_eta" ) );
74 ATH_CHECK( retrieveAndBook( m_sigma_phi, "sigma_"+m_trackType+"_phi" ) );
75 ATH_CHECK( retrieveAndBook( m_sigma_d0, "sigma_"+m_trackType+"_d0" ) );
76 ATH_CHECK( retrieveAndBook( m_sigma_z0, "sigma_"+m_trackType+"_z0" ) );
77 ATH_CHECK( retrieveAndBook( m_sigma_z0sin, "sigma_"+m_trackType+"_z0sin" ) );
78 ATH_CHECK( retrieveAndBook( m_sigma_theta, "sigma_"+m_trackType+"_theta" ) );
79
81 ATH_CHECK( retrieveAndBook( m_significance_pt, "significance_"+m_trackType+"_pt" ) );
82 ATH_CHECK( retrieveAndBook( m_significance_eta, "significance_"+m_trackType+"_eta" ) );
83 ATH_CHECK( retrieveAndBook( m_significance_phi, "significance_"+m_trackType+"_phi" ) );
84 ATH_CHECK( retrieveAndBook( m_significance_d0, "significance_"+m_trackType+"_d0" ) );
85 ATH_CHECK( retrieveAndBook( m_significance_z0, "significance_"+m_trackType+"_z0" ) );
86 ATH_CHECK( retrieveAndBook( m_significance_z0sin, "significance_"+m_trackType+"_z0sin" ) );
87 ATH_CHECK( retrieveAndBook( m_significance_theta, "significance_"+m_trackType+"_theta" ) );
88 }
89
90 return StatusCode::SUCCESS;
91}
92
93
97template< typename PARTICLE >
99 const PARTICLE& particle, float weight )
100{
102 float ppt = pT( particle ) / Gaudi::Units::GeV;
103 float peta = eta( particle );
104 float pphi = phi( particle );
105 float pd0 = d0( particle );
106 if( m_recomputeIP ) pd0 = getD0TrackInJet( particle );
107 float pz0 = z0( particle );
108 float pz0sin = z0SinTheta( particle );
109 float ptheta = theta( particle );
110 float pqoverp = qOverP( particle ); // in MeV^-1
111 float pprodR = prodR( particle );
112 float pprodZ = prodZ( particle );
113 float pnSiHits = nSiHits( particle );
114 float pchi2 = chiSquared( particle );
115 float pndof = ndof( particle );
116 float pchi2OverNdof = ( pndof > 0 ) ? pchi2 / pndof : 0.;
117 std::vector< unsigned int > pauthor = author( particle );
118
120 ATH_CHECK( fill( m_pt, ppt, weight ) );
121 ATH_CHECK( fill( m_eta, peta, weight ) );
122 ATH_CHECK( fill( m_phi, pphi, weight ) );
123 ATH_CHECK( fill( m_d0, pd0, weight ) );
124 ATH_CHECK( fill( m_z0, pz0, weight ) );
125 ATH_CHECK( fill( m_z0sin, pz0sin, weight ) );
126 ATH_CHECK( fill( m_theta, ptheta, weight ) );
127 ATH_CHECK( fill( m_qoverp, pqoverp, weight ) );
128 if( m_trackType == "truth" ) {
129 ATH_CHECK( fill( m_prodR, pprodR, weight ) );
130 ATH_CHECK( fill( m_prodZ, pprodZ, weight ) );
131 ATH_CHECK( fill( m_nSiHits, pnSiHits, weight ) );
132 ATH_CHECK( fill( m_nSiHits_vs_eta, peta, pnSiHits, weight ) );
133 } else {
134 ATH_CHECK( fill( m_chi2, pchi2, weight ) );
135 ATH_CHECK( fill( m_ndof, pndof, weight ) );
136 ATH_CHECK( fill( m_chi2OverNdof, pchi2OverNdof, weight ) );
137 for( unsigned int i=0; i<pauthor.size(); i++ ) {
138 ATH_CHECK( fill( m_author, pauthor[i], weight ) );
139 }
140 static const SG::Accessor< uint8_t > accValidTime("hasValidTime");
141 static const SG::Accessor< float > accTime("time");
142 if( accValidTime.isAvailable( particle ) ) {
143 bool phasValidTime = hasValidTime( particle );
144 ATH_CHECK( fill( m_hasValidTime_eff_vs_eta, peta, phasValidTime, weight ) );
145 if( accTime.isAvailable( particle ) and phasValidTime ) {
146 ATH_CHECK( fill( m_time, time( particle ), weight ) );
147 }
148 }
149 }
150 ATH_CHECK( fill( m_eta_vs_pt, ppt, peta, weight ) );
151 ATH_CHECK( fill( m_eta_vs_phi, pphi, peta, weight ) );
152 ATH_CHECK( fill( m_z0_vs_d0, pd0, pz0, weight ) );
153 ATH_CHECK( fill( m_z0sin_vs_d0, pz0*std::sin(ptheta), pd0, weight ) );
154
155 if( m_plotErrors ) {
156 float ppt_err = pTError( particle ) / Gaudi::Units::GeV;
157 float peta_err = etaError( particle );
158 float pphi_err = error( particle, Trk::phi );
159 float pd0_err = error( particle, Trk::d0 );
160 float pz0_err = error( particle, Trk::z0 );
161 float pz0sin_err = z0SinThetaError( particle );
162 float ptheta_err = error( particle, Trk::theta );
163
164 ATH_CHECK( fill( m_sigma_pt, ppt_err, weight ) );
165 ATH_CHECK( fill( m_sigma_eta, peta_err, weight ) );
166 ATH_CHECK( fill( m_sigma_phi, pphi_err, weight ) );
167 ATH_CHECK( fill( m_sigma_d0, pd0_err, weight ) );
168 ATH_CHECK( fill( m_sigma_z0, pz0_err, weight ) );
169 ATH_CHECK( fill( m_sigma_z0sin, pz0sin_err, weight ) );
170 ATH_CHECK( fill( m_sigma_theta, ptheta_err, weight ) );
171
172 float ppt_sig = ppt_err > 0. ? ppt / ppt_err : -9999.;
173 float peta_sig = peta_err > 0. ? peta / peta_err : -9999.;
174 float pphi_sig = pphi_err > 0. ? pphi / pphi_err : -9999.;
175 float pd0_sig = pd0_err > 0. ? pd0 / pd0_err : -9999.;
176 float pz0_sig = pz0_err > 0. ? pz0 / pz0_err : -9999.;
177 float pz0sin_sig = pz0sin_err > 0. ? pz0sin / pz0sin_err : -9999.;
178 float ptheta_sig = ptheta_err > 0. ? ptheta / ptheta_err : -9999.;
179
180 ATH_CHECK( fill( m_significance_pt, ppt_sig, weight ) );
181 ATH_CHECK( fill( m_significance_eta, peta_sig, weight ) );
182 ATH_CHECK( fill( m_significance_phi, pphi_sig, weight ) );
183 ATH_CHECK( fill( m_significance_d0, pd0_sig, weight ) );
184 ATH_CHECK( fill( m_significance_z0, pz0_sig, weight ) );
185 ATH_CHECK( fill( m_significance_z0sin, pz0sin_sig, weight ) );
186 ATH_CHECK( fill( m_significance_theta, ptheta_sig, weight ) );
187 }
188
189 return StatusCode::SUCCESS;
190}
191
193 const xAOD::TrackParticle&, float weight );
194
196 const xAOD::TruthParticle&, float weight );
197
198
203{
204 ATH_MSG_DEBUG( "Finalising track parameters plots" );
206}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
Utility methods to access offline object decorations.
Utility methods to access track/truth particles parmeters in a consitent way in this package.
StatusCode retrieveAndBook(P *&pHisto, const std::string &identifier, const std::string &folderOverride="", const std::string &nameOverride="")
Definition PlotMgr.h:64
PlotMgr(const std::string &dirName, const std::string &anaTag, PlotMgr *pParent=nullptr)
Constructor taking parent node and directory name for plots pParent = nullptr by default to book plot...
Definition PlotMgr.cxx:25
TrackParametersPlots(PlotMgr *pParent, const std::string &dirName, const std::string &anaTag, const std::string &trackType, bool plotErrors=false, bool recomputeIP=false)
Constructor.
TH1 * m_significance_pt
significance plots
StatusCode fillPlots(const PARTICLE &particle, float weight)
Dedicated fill method (for tracks and/or truth particles)
void initializePlots()
Book the histograms.
void finalizePlots()
Print out final stats on histograms.
const std::string & getDirectory()
Definition PlotBase.h:88
Helper class to provide type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
float getD0TrackInJet(const xAOD::TrackParticle &track, const std::string &quality)
recompute d0 projecting in jet direction w.r.t. origin
float pT(const U &p)
Accessor utility function for getting the value of pT.
float z0SinTheta(const U &p)
float prodZ(const U &p)
float qOverP(const U &p)
float chiSquared(const U &p)
float pTError(const U &p)
float z0(const U &p)
float d0(const U &p)
float prodR(const U &p)
float ndof(const U &p)
float time(const U &p)
float nSiHits(const U &p)
std::vector< unsigned int > author(const U &p)
float etaError(const U &p)
float z0SinThetaError(const U &p)
uint8_t hasValidTime(const U &p)
@ theta
Definition ParamDefs.h:66
@ phi
Definition ParamDefs.h:75
@ d0
Definition ParamDefs.h:63
@ z0
Definition ParamDefs.h:64
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
void fill(H5::Group &out_file, size_t iterations)