73 m_mc_truthTreeIndex{},
79 declareInterface<ITrackValidationNtupleTool>(
this);
80 declareProperty(
"ExtrapolatorTool", m_extrapolator,
"Extrapolator, eg for tracks without Perigee");
81 declareProperty(
"DoTruth", m_doTruth,
"Toggle if to Write truth data");
95 return StatusCode::SUCCESS;
104 return StatusCode::SUCCESS;
108 if (!
tree)
return StatusCode::FAILURE;
113 tree->Branch(
"RecD0", &m_Rec_d0 );
114 tree->Branch(
"RecZ0", &m_Rec_z0 );
115 tree->Branch(
"RecPhi0", &m_Rec_phi0 );
116 tree->Branch(
"RecTheta", &m_Rec_theta );
117 tree->Branch(
"RecEta", &m_Rec_eta );
118 tree->Branch(
"RecQoverP", &m_Rec_qOverP );
121 tree->Branch(
"RecErrD0", &m_errord0 );
122 tree->Branch(
"RecErrZ0", &m_errorz0 );
123 tree->Branch(
"RecErrPhi0", &m_errorphi0 );
124 tree->Branch(
"RecErrTheta", &m_errortheta0 );
125 tree->Branch(
"RecErrQoverP", &m_errorqoverp );
129 tree->Branch(
"trk_Mc_d0", &m_mc_d0 );
130 tree->Branch(
"trk_Mc_z0", &m_mc_z0 );
131 tree->Branch(
"trk_Mc_phi0", &m_mc_phi0 );
132 tree->Branch(
"trk_Mc_theta", &m_mc_theta );
133 tree->Branch(
"trk_Mc_qOverP", &m_mc_qOverP );
134 tree->Branch(
"trk_Mc_qOverPt", &m_mc_qOverPt );
135 tree->Branch(
"trk_Mc_eta", &m_mc_eta );
137 tree->Branch(
"trk_Mc_diff_d0", &m_mc_diff_d0 );
138 tree->Branch(
"trk_Mc_diff_z0", &m_mc_diff_z0 );
139 tree->Branch(
"trk_Mc_diff_phi0", &m_mc_diff_phi0 );
140 tree->Branch(
"trk_Mc_diff_theta", &m_mc_diff_theta );
141 tree->Branch(
"trk_Mc_diff_qOverP", &m_mc_diff_qOverP );
143 tree->Branch(
"trk_Mc_pull_d0", &m_mc_pull_d0 );
144 tree->Branch(
"trk_Mc_pull_z0", &m_mc_pull_z0 );
145 tree->Branch(
"trk_Mc_pull_phi0", &m_mc_pull_phi0 );
146 tree->Branch(
"trk_Mc_pull_theta", &m_mc_pull_theta );
147 tree->Branch(
"trk_Mc_pull_qOverP", &m_mc_pull_qOverP );
149 tree->Branch(
"trk_Mc_particleID", &m_mc_particleID );
150 tree->Branch(
"trk_Mc_barcode", &m_mc_uniqueID );
151 tree->Branch(
"trk_Mc_energy", &m_mc_energy );
152 tree->Branch(
"trk_Mc_prob", &m_mc_prob );
153 tree->Branch(
"trk_Mc_truthTreeIndex",&m_mc_truthTreeIndex );
160 return StatusCode::SUCCESS;
169 const unsigned int ) {
173 const EventContext& ctx = Gaudi::Hive::currentContext();
177 if (perpars !=
nullptr && fillTrackPerigee(perpars).isFailure()) {
178 msg(MSG::WARNING) <<
"Perigee parameters could not be written to ntuple" <<
endmsg;
180 if (perpars ==
nullptr) {
182 !m_extrapolator.empty() ) {
185 std::unique_ptr<const Trk::TrackParameters>
tmp = m_extrapolator->extrapolateTrack(
190 if (perpars !=
nullptr && fillTrackPerigee(perpars).isFailure()) {
191 msg(MSG::WARNING) <<
"Newly made perigee parameters could not be "
192 <<
"written to ntuple" <<
endmsg;
194 if (perpars !=
nullptr)
delete perpars;
196 msg(MSG::WARNING) <<
"No perigee parameters, but they are the main validation object!"
199 return StatusCode::SUCCESS;
212 if (perpars !=
nullptr && fillTrackPerigee(perpars).isFailure())
214 return StatusCode::SUCCESS;
227 if ( !m_doTruth )
return StatusCode::SUCCESS;
235 m_mc_truthTreeIndex = indexInTruthTree;
240 m_mc_particleID = genParticle->pdg_id();
241 m_mc_energy = genParticle->momentum().e();
244 if (truePerigee ==
nullptr)
return StatusCode::SUCCESS;
246 m_mc_d0 = truePerigee->parameters()[
Trk::d0];
247 m_mc_z0 = truePerigee->parameters()[
Trk::z0];
248 m_mc_phi0 = truePerigee->parameters()[
Trk::phi0];
249 m_mc_theta = truePerigee->parameters()[
Trk::theta];
250 m_mc_qOverP = truePerigee->parameters()[
Trk::qOverP];
253 m_mc_qOverPt = m_mc_qOverP /
std::sin( m_mc_theta );
255 m_mc_eta = truePerigee->
eta();
257 m_mc_diff_d0 = m_Rec_d0 - m_mc_d0;
258 m_mc_diff_z0 = m_Rec_z0 - m_mc_z0;
259 m_mc_diff_phi0 = m_Rec_phi0 - m_mc_phi0;
260 m_mc_diff_theta = m_Rec_theta - m_mc_theta;
261 m_mc_diff_qOverP = m_Rec_qOverP - m_mc_qOverP;
263 m_mc_pull_d0 = m_errord0 ? m_mc_diff_d0 / m_errord0 : 0.;
264 m_mc_pull_z0 = m_errorz0 ? m_mc_diff_z0 / m_errorz0 : 0.;
265 m_mc_pull_phi0 = m_errorphi0 ? m_mc_diff_phi0 / m_errorphi0 : 0.;
266 m_mc_pull_theta = m_errortheta0 ? m_mc_diff_theta / m_errortheta0 : 0.;
267 m_mc_pull_qOverP = m_errorqoverp ? m_mc_diff_qOverP / m_errorqoverp : 0.;
269 return StatusCode::SUCCESS;
283 msg(MSG::WARNING) <<
"Something is wrong - track has no perigee at all!" <<
endmsg;
289 return StatusCode::FAILURE;
294 m_Rec_d0 = perigee->parameters()[
Trk::d0];
295 m_Rec_z0 = perigee->parameters()[
Trk::z0];
296 m_Rec_phi0 = perigee->parameters()[
Trk::phi0];
297 m_Rec_theta = perigee->parameters()[
Trk::theta];
298 m_Rec_eta = perigee->eta();
303 if (perigee->covariance()) {
317 ATH_MSG_DEBUG (
"Trackparameters: d0=" << m_Rec_d0 <<
", z0=" << m_Rec_z0 <<
", phi0=" << m_Rec_phi0 <<
", theta=" << m_Rec_theta);
319 return StatusCode::SUCCESS;