12 #include "GaudiKernel/ITHistSvc.h"
30 : base_class(
t,
n,
p),
32 m_extrapolateDirectly(false),
33 m_extrapolateIncrementally(false),
37 m_parameterCache(nullptr),
38 m_parameterCacheCov(nullptr),
39 m_parameterCacheEntry(nullptr),
40 m_parameterCacheEntryCov(nullptr),
42 m_crossedEntry(false),
44 m_destinationSurface(),
45 m_validationTreeName(
"G4Follower"),
46 m_validationTreeDescription(
"Output of the G4Follower_"),
47 m_validationTreeFolder(
"/val/G4Follower"),
48 m_validationTree(nullptr) {
67 m_treeData = std::make_unique<TreeData>();
73 if (m_extrapolator.retrieve().isFailure()) {
74 ATH_MSG_ERROR(
"Could not retrieve Extrapolator " << m_extrapolator
76 return StatusCode::FAILURE;
79 if (m_elossupdator.retrieve().isFailure()) {
80 ATH_MSG_ERROR(
"Could not retrieve ElossUpdator " << m_elossupdator
82 return StatusCode::FAILURE;
94 m_validationTree =
new TTree(m_validationTreeName.c_str(),
95 m_validationTreeDescription.c_str());
97 m_validationTree->Branch(
"InitX", &m_treeData->m_t_x,
"initX/F");
98 m_validationTree->Branch(
"InitY", &m_treeData->m_t_y,
"initY/F");
99 m_validationTree->Branch(
"InitZ", &m_treeData->m_t_z,
"initZ/F");
100 m_validationTree->Branch(
"InitTheta", &m_treeData->m_t_theta,
"initTheta/F");
101 m_validationTree->Branch(
"InitEta", &m_treeData->m_t_eta,
"initEta/F");
102 m_validationTree->Branch(
"InitPhi", &m_treeData->m_t_phi,
"initPhi/F");
103 m_validationTree->Branch(
"InitP", &m_treeData->m_t_p,
"initP/F");
104 m_validationTree->Branch(
"InitPdg", &m_treeData->m_t_pdg,
"initPdg/I");
105 m_validationTree->Branch(
"InitCharge", &m_treeData->m_t_charge,
"initQ/F");
107 m_validationTree->Branch(
"MEntryX", &m_treeData->m_m_x,
"mentryX/F");
108 m_validationTree->Branch(
"MEntryY", &m_treeData->m_m_y,
"mentryY/F");
109 m_validationTree->Branch(
"MEntryZ", &m_treeData->m_m_z,
"mentryZ/F");
110 m_validationTree->Branch(
"MEntryTheta", &m_treeData->m_m_theta,
112 m_validationTree->Branch(
"MEntryEta", &m_treeData->m_m_eta,
"mentryEta/F");
113 m_validationTree->Branch(
"MEntryPhi", &m_treeData->m_m_phi,
"mentryPhi/F");
114 m_validationTree->Branch(
"MEntryP", &m_treeData->m_m_p,
"mentryP/F");
116 m_validationTree->Branch(
"BackX", &m_treeData->m_b_x,
"backX/F");
117 m_validationTree->Branch(
"BackY", &m_treeData->m_b_y,
"backY/F");
118 m_validationTree->Branch(
"BackZ", &m_treeData->m_b_z,
"backZ/F");
119 m_validationTree->Branch(
"BackTheta", &m_treeData->m_b_theta,
"backTheta/F");
120 m_validationTree->Branch(
"BackEta", &m_treeData->m_b_eta,
"backEta/F");
121 m_validationTree->Branch(
"BackPhi", &m_treeData->m_b_phi,
"backPhi/F");
122 m_validationTree->Branch(
"BackP", &m_treeData->m_b_p,
"backP/F");
123 m_validationTree->Branch(
"BackX0", &m_treeData->m_b_X0,
"backX0/F");
124 m_validationTree->Branch(
"BackEloss", &m_treeData->m_b_Eloss,
"backEloss/F");
126 m_validationTree->Branch(
"G4Steps", &m_treeData->m_g4_steps,
"g4steps/I");
127 m_validationTree->Branch(
"TrkStepScats", &m_treeData->m_trk_scats,
130 m_validationTree->Branch(
"G4StepP", m_treeData->m_g4_p,
"g4stepP[g4steps]/F");
131 m_validationTree->Branch(
"G4StepEta", m_treeData->m_g4_eta,
132 "g4stepEta[g4steps]/F");
133 m_validationTree->Branch(
"G4StepTheta", m_treeData->m_g4_theta,
134 "g4stepTheta[g4steps]/F");
135 m_validationTree->Branch(
"G4StepPhi", m_treeData->m_g4_phi,
136 "g4stepPhi[g4steps]/F");
137 m_validationTree->Branch(
"G4StepX", m_treeData->m_g4_x,
"g4stepX[g4steps]/F");
138 m_validationTree->Branch(
"G4StepY", m_treeData->m_g4_y,
"g4stepY[g4steps]/F");
139 m_validationTree->Branch(
"G4StepZ", m_treeData->m_g4_z,
"g4stepZ[g4steps]/F");
140 m_validationTree->Branch(
"G4AccumTX0", m_treeData->m_g4_tX0,
141 "g4stepAccTX0[g4steps]/F");
142 m_validationTree->Branch(
"G4StepT", m_treeData->m_g4_t,
143 "g4stepTX[g4steps]/F");
144 m_validationTree->Branch(
"G4StepX0", m_treeData->m_g4_X0,
145 "g4stepX0[g4steps]/F");
147 m_validationTree->Branch(
"TrkStepStatus", m_treeData->m_trk_status,
148 "trkstepStatus[g4steps]/I");
149 m_validationTree->Branch(
"TrkStepP", m_treeData->m_trk_p,
150 "trkstepP[g4steps]/F");
151 m_validationTree->Branch(
"TrkStepEta", m_treeData->m_trk_eta,
152 "trkstepEta[g4steps]/F");
153 m_validationTree->Branch(
"TrkStepTheta", m_treeData->m_trk_theta,
154 "trkstepTheta[g4steps]/F");
155 m_validationTree->Branch(
"TrkStepPhi", m_treeData->m_trk_phi,
156 "trkstepPhi[g4steps]/F");
157 m_validationTree->Branch(
"TrkStepX", m_treeData->m_trk_x,
158 "trkstepX[g4steps]/F");
159 m_validationTree->Branch(
"TrkStepY", m_treeData->m_trk_y,
160 "trkstepY[g4steps]/F");
161 m_validationTree->Branch(
"TrkStepZ", m_treeData->m_trk_z,
162 "trkstepZ[g4steps]/F");
163 m_validationTree->Branch(
"TrkStepLocX", m_treeData->m_trk_lx,
164 "trkstepLX[g4steps]/F");
165 m_validationTree->Branch(
"TrkStepLocY", m_treeData->m_trk_ly,
166 "trkstepLY[g4steps]/F");
167 m_validationTree->Branch(
"TrkStepEloss", m_treeData->m_trk_eloss,
168 "trkstepEloss[g4steps]/F");
169 m_validationTree->Branch(
"TrkStepEloss1", m_treeData->m_trk_eloss1,
170 "trkstepEloss1[g4steps]/F");
171 m_validationTree->Branch(
"TrkStepEloss0", m_treeData->m_trk_eloss0,
172 "trkstepEloss0[g4steps]/F");
173 m_validationTree->Branch(
"TrkStepEloss5", m_treeData->m_trk_eloss5,
174 "trkstepEloss5[g4steps]/F");
175 m_validationTree->Branch(
"TrkStepEloss10", m_treeData->m_trk_eloss10,
176 "trkstepEloss10[g4steps]/F");
177 m_validationTree->Branch(
"TrkStepScaleEloss", m_treeData->m_trk_scaleeloss,
178 "trkstepScaleEloss[g4steps]/F");
179 m_validationTree->Branch(
"TrkStepScaleX0", m_treeData->m_trk_scalex0,
180 "trkstepScaleX0[g4steps]/F");
181 m_validationTree->Branch(
"TrkStepX0", m_treeData->m_trk_x0,
182 "trkstepX0[g4steps]/F");
183 m_validationTree->Branch(
"TrkStepErd0", m_treeData->m_trk_erd0,
184 "trkstepErd0[g4steps]/F");
185 m_validationTree->Branch(
"TrkStepErz0", m_treeData->m_trk_erz0,
186 "trkstepErz0[g4steps]/F");
187 m_validationTree->Branch(
"TrkStepErphi", m_treeData->m_trk_erphi,
188 "trkstepErphi[g4steps]/F");
189 m_validationTree->Branch(
"TrkStepErtheta", m_treeData->m_trk_ertheta,
190 "trkstepErtheta[g4steps]/F");
191 m_validationTree->Branch(
"TrkStepErqoverp", m_treeData->m_trk_erqoverp,
192 "trkstepErqoverp[g4steps]/F");
194 m_validationTree->Branch(
"TrkStepScatStatus", m_treeData->m_trk_sstatus,
195 "trkscatStatus[trkscats]/I");
196 m_validationTree->Branch(
"TrkStepScatX", m_treeData->m_trk_sx,
197 "trkscatX[trkscats]/F");
198 m_validationTree->Branch(
"TrkStepScatY", m_treeData->m_trk_sy,
199 "trkscatY[trkscats]/F");
200 m_validationTree->Branch(
"TrkStepScatZ", m_treeData->m_trk_sz,
201 "trkscatZ[trkscats]/F");
202 m_validationTree->Branch(
"TrkStepScatX0", m_treeData->m_trk_sx0,
203 "trkscatX0[trkscats]/F");
204 m_validationTree->Branch(
"TrkStepScatEloss", m_treeData->m_trk_seloss,
205 "trkscatEloss[trkscats]/F");
206 m_validationTree->Branch(
"TrkStepScatMeanIoni", m_treeData->m_trk_smeanIoni,
207 "trkscatMeanIoni[trkscats]/F");
208 m_validationTree->Branch(
"TrkStepScatSigIoni", m_treeData->m_trk_ssigIoni,
209 "trkscatSigIoni[trkscats]/F");
210 m_validationTree->Branch(
"TrkStepScatMeanRad", m_treeData->m_trk_smeanRad,
211 "trkscatMeanRad[trkscats]/F");
212 m_validationTree->Branch(
"TrkStepScatSigRad", m_treeData->m_trk_ssigRad,
213 "trkscatSigRad[trkscats]/F");
214 m_validationTree->Branch(
"TrkStepScatSigTheta", m_treeData->m_trk_ssigTheta,
215 "trkscatSigTheta[trkscats]/F");
216 m_validationTree->Branch(
"TrkStepScatSigPhi", m_treeData->m_trk_ssigPhi,
217 "trkscatSigPhi[trkscats]/F");
219 m_crossedEntry =
false;
222 SmartIF<ITHistSvc> tHistSvc{Gaudi::svcLocator()->service(
"THistSvc")};
225 "Could not find Hist Service -> Switching ValidationMode Off !");
226 delete m_validationTree;
227 m_validationTree =
nullptr;
229 if ((tHistSvc->regTree(m_validationTreeFolder, m_validationTree))
232 "Could not register the validation Tree -> Switching ValidationMode "
234 delete m_validationTree;
235 m_validationTree =
nullptr;
239 return StatusCode::SUCCESS;
243 return StatusCode::SUCCESS;
247 m_treeData->m_t_x = 0.;
248 m_treeData->m_t_y = 0.;
249 m_treeData->m_t_z = 0.;
250 m_treeData->m_t_theta = 0.;
251 m_treeData->m_t_eta = 0.;
252 m_treeData->m_t_phi = 0.;
253 m_treeData->m_t_p = 0.;
254 m_treeData->m_t_charge = 0.;
255 m_treeData->m_t_pdg = 0;
257 m_treeData->m_m_x = 0.;
258 m_treeData->m_m_y = 0.;
259 m_treeData->m_m_z = 0.;
260 m_treeData->m_m_theta = 0.;
261 m_treeData->m_m_eta = 0.;
262 m_treeData->m_m_phi = 0.;
263 m_treeData->m_m_p = 0.;
265 m_treeData->m_b_x = 0.;
266 m_treeData->m_b_y = 0.;
267 m_treeData->m_b_z = 0.;
268 m_treeData->m_b_theta = 0.;
269 m_treeData->m_b_eta = 0.;
270 m_treeData->m_b_phi = 0.;
271 m_treeData->m_b_p = 0.;
272 m_treeData->m_b_X0 = 0.;
273 m_treeData->m_b_Eloss = 0.;
275 m_treeData->m_g4_steps = -1;
276 m_treeData->m_g4_stepsEntry = -1;
277 m_treeData->m_trk_scats = 0;
280 m_crossedEntry =
false;
285 const G4ThreeVector&
mom,
286 int pdg,
double charge,
float t,
288 const EventContext& ctx = Gaudi::Hive::currentContext();
291 double zMuonEntry = 6735.;
292 double rMuonEntry = 4254;
293 double zMuonExit = 21800.;
294 double rMuonExit = 12500.;
295 double zIDExit = 2720.;
296 double rIDExit = 1080.;
298 double zEntry = zMuonEntry;
299 double rEntry = rMuonEntry;
300 double zExit = zMuonExit;
301 double rExit = rMuonExit;
315 if (m_treeData->m_g4_steps == -1) {
316 ATH_MSG_INFO(
"Initial step ... preparing event cache.");
317 m_treeData->m_t_x = npos.x();
318 m_treeData->m_t_y = npos.y();
319 m_treeData->m_t_z = npos.z();
320 m_treeData->m_t_theta = nmom.theta();
321 m_treeData->m_t_eta = nmom.eta();
322 m_treeData->m_t_phi = nmom.phi();
323 m_treeData->m_t_p = nmom.mag();
324 m_treeData->m_t_charge =
charge;
325 m_treeData->m_t_pdg = pdg;
326 m_treeData->m_g4_steps = 0;
342 << *m_parameterCacheCov->covariance());
346 float tX0 =
X0 > 10
e-5 ?
t /
X0 : 0.;
348 ATH_MSG_DEBUG(
" position R " << npos.perp() <<
" z " << npos.z() <<
" X0 "
349 <<
X0 <<
" t " <<
t <<
" m_tX0Cache "
352 bool useEntry =
true;
355 if (useEntry && !m_crossedEntry &&
356 (std::fabs(npos.z()) > zEntry || npos.perp() > rEntry)) {
357 m_treeData->m_m_x = npos.x();
358 m_treeData->m_m_y = npos.y();
359 m_treeData->m_m_z = npos.z();
360 m_treeData->m_m_theta = nmom.theta();
361 m_treeData->m_m_eta = nmom.eta();
362 m_treeData->m_m_phi = nmom.phi();
363 m_treeData->m_m_p = nmom.mag();
365 m_treeData->m_g4_stepsEntry = 0;
374 << m_parameterCacheEntry->position().x() <<
" y "
375 << m_parameterCacheEntry->position().y() <<
" z "
376 << m_parameterCacheEntry->position().z());
377 m_crossedEntry =
true;
385 m_treeData->m_g4_steps =
386 (m_treeData->m_g4_steps == -1) ? 0 : m_treeData->m_g4_steps;
388 if (!m_parameterCache) {
393 if (m_treeData->m_g4_steps >=
MAXPROBES) {
395 <<
" reached, step is ignored.");
400 if (!m_crossedEntry)
return;
401 if (m_exitLayer)
return;
405 m_treeData->m_g4_p[m_treeData->m_g4_steps] = nmom.mag();
406 m_treeData->m_g4_eta[m_treeData->m_g4_steps] = nmom.eta();
407 m_treeData->m_g4_theta[m_treeData->m_g4_steps] = nmom.theta();
408 m_treeData->m_g4_phi[m_treeData->m_g4_steps] = nmom.phi();
409 m_treeData->m_g4_x[m_treeData->m_g4_steps] = npos.x();
410 m_treeData->m_g4_y[m_treeData->m_g4_steps] = npos.y();
411 m_treeData->m_g4_z[m_treeData->m_g4_steps] = npos.z();
412 m_treeData->m_g4_tX0[m_treeData->m_g4_steps] = m_tX0Cache;
413 m_treeData->m_g4_t[m_treeData->m_g4_steps] =
t;
414 m_treeData->m_g4_X0[m_treeData->m_g4_steps] =
X0;
416 m_treeData->m_trk_p[m_treeData->m_g4_steps] = 0.;
417 m_treeData->m_trk_eta[m_treeData->m_g4_steps] = 0.;
418 m_treeData->m_trk_theta[m_treeData->m_g4_steps] = 0.;
419 m_treeData->m_trk_phi[m_treeData->m_g4_steps] = 0.;
420 m_treeData->m_trk_x[m_treeData->m_g4_steps] = 0.;
421 m_treeData->m_trk_y[m_treeData->m_g4_steps] = 0.;
422 m_treeData->m_trk_z[m_treeData->m_g4_steps] = 0.;
423 m_treeData->m_trk_lx[m_treeData->m_g4_steps] = 0.;
424 m_treeData->m_trk_ly[m_treeData->m_g4_steps] = 0.;
425 m_treeData->m_trk_eloss[m_treeData->m_g4_steps] = 0.;
426 m_treeData->m_trk_eloss0[m_treeData->m_g4_steps] = 0.;
427 m_treeData->m_trk_eloss1[m_treeData->m_g4_steps] = 0.;
428 m_treeData->m_trk_eloss5[m_treeData->m_g4_steps] = 0.;
429 m_treeData->m_trk_eloss10[m_treeData->m_g4_steps] = 0.;
430 m_treeData->m_trk_scaleeloss[m_treeData->m_g4_steps] = 0.;
431 m_treeData->m_trk_scalex0[m_treeData->m_g4_steps] = 0.;
432 m_treeData->m_trk_x0[m_treeData->m_g4_steps] = 0.;
433 m_treeData->m_trk_status[m_treeData->m_g4_steps] = 0;
434 m_treeData->m_trk_erd0[m_treeData->m_g4_steps] = 0.;
435 m_treeData->m_trk_erz0[m_treeData->m_g4_steps] = 0.;
436 m_treeData->m_trk_erphi[m_treeData->m_g4_steps] = 0.;
437 m_treeData->m_trk_ertheta[m_treeData->m_g4_steps] = 0.;
438 m_treeData->m_trk_erqoverp[m_treeData->m_g4_steps] = 0.;
439 ++m_treeData->m_g4_steps;
441 ATH_MSG_DEBUG(
"initialise m_treeData->m_g4_steps" << m_treeData->m_g4_steps);
443 bool crossedExitLayer =
false;
445 if (std::fabs(npos.z()) > zExit || npos.perp() > rExit)
446 crossedExitLayer =
true;
448 ATH_MSG_DEBUG(
"npos Z: " << npos.z() <<
"npos prep: " << npos.perp()
449 <<
"crossedExitLayer: " << crossedExitLayer);
453 <<
"m_crossedEntry: " << m_crossedEntry
454 <<
"m_treeData->m_g4_steps: " << m_treeData->m_g4_steps
455 <<
"m_treeData->m_g4_stepsEntry: " << m_treeData->m_g4_stepsEntry);
456 if (m_crossedEntry && m_treeData->m_g4_steps >= 2 && !crossedExitLayer)
472 std::unique_ptr<Trk::TrackParameters> trkParameters =
473 m_extrapolateDirectly && m_crossedEntry
474 ? m_extrapolator->extrapolateDirectly(
477 : m_extrapolator->extrapolate(ctx, *m_parameterCache,
480 if (!trkParameters) {
482 " G4 extrapolate failed without covariance to destination surface ");
484 if (m_treeData->m_g4_stepsEntry == 0 && m_useCovMatrix) {
485 ATH_MSG_DEBUG(
" Extrapolate m_parameterCacheCov with covMatrix ");
486 extrapolationCache.
reset();
487 trkParameters = m_extrapolateDirectly && m_crossedEntry
488 ? m_extrapolator->extrapolateDirectly(
489 ctx, *m_parameterCacheCov, destinationSurface,
491 : m_extrapolator->extrapolate(
492 ctx, *m_parameterCacheCov, destinationSurface,
495 if (!trkParameters) {
496 ATH_MSG_DEBUG(
" G4 extrapolate failed with covariance to Muon Entry or ID Exit");
497 ATH_MSG_DEBUG(
" Redo G4 extrapolateM without covariance matrix to Muon Entry or ID Exit ");
498 extrapolationCache.
reset();
499 trkParameters = m_extrapolateDirectly && m_crossedEntry
500 ? m_extrapolator->extrapolateDirectly(
501 ctx, *m_parameterCache, destinationSurface,
503 : m_extrapolator->extrapolate(
504 ctx, *m_parameterCache, destinationSurface,
510 " G4 extrapolate succesfull with covariance to Muon Entry or ID exit "
511 <<
" X0 " << extrapolationCache.
x0tot() <<
" Eloss deltaE "
512 << extrapolationCache.
eloss()->
deltaE() <<
" Eloss sigma "
516 << extrapolationCache.
eloss()->
meanRad() <<
" sigmaRad "
523 m_treeData->m_trk_status[m_treeData->m_g4_steps] = trkParameters ? 1 : 0;
525 << m_treeData->m_g4_steps <<
" exit Layer: " << crossedExitLayer
526 <<
" track parameters: " << trkParameters.get());
528 if (!trkParameters) {
533 <<
"track parameters: " << trkParameters.get());
534 if (crossedExitLayer) {
538 m_treeData->m_trk_status[m_treeData->m_g4_steps] = 1000;
540 if (m_useCovMatrix) {
541 extrapolationCache.
reset();
542 ATH_MSG_DEBUG(
" Extrapolate m_parameterCacheEntryCov with covMatrix "
543 <<
" x " << m_parameterCacheEntryCov->position().x() <<
" y "
544 << m_parameterCacheEntryCov->position().y() <<
" z "
545 << m_parameterCacheEntryCov->position().z());
547 <<
"m_extrapolateDirectly: " << m_extrapolateDirectly
548 <<
"m_crossedEntry: " << m_crossedEntry);
550 trkParameters = m_extrapolateDirectly && m_crossedEntry
551 ? m_extrapolator->extrapolateDirectly(
552 ctx, *m_parameterCacheEntryCov, destinationSurface,
554 : m_extrapolator->extrapolate(
555 ctx, *m_parameterCacheEntryCov, destinationSurface,
559 ATH_MSG_DEBUG(
"extrapolation with m_parameterCacheEntryCov succeeded ");
561 ATH_MSG_DEBUG(
" extrapolation failed with m_parameterCacheEntryCov ");
562 if (!m_parameterCacheEntryCov) {
563 ATH_MSG_DEBUG(
" failed due to m_parameterCacheEntryCov is zero");
565 extrapolationCache.
reset();
566 trkParameters = m_extrapolateDirectly
567 ? m_extrapolator->extrapolateDirectly(
568 ctx, *m_parameterCacheEntry, destinationSurface,
570 : m_extrapolator->extrapolate(
571 ctx, *m_parameterCacheEntry, destinationSurface,
576 ATH_MSG_DEBUG(
"extrapolation with m_parameterCacheEntry succeeded");
579 extrapolationCache.
reset();
580 trkParameters = m_extrapolateDirectly
581 ? m_extrapolator->extrapolateDirectly(
582 ctx, *m_parameterCacheEntry, destinationSurface,
584 : m_extrapolator->extrapolate(
585 ctx, *m_parameterCacheEntry, destinationSurface,
593 bool doBackWard =
false;
595 std::unique_ptr<Trk::TrackParameters> trkParameters_BACK =
596 m_extrapolateDirectly
597 ? m_extrapolator->extrapolateDirectly(
598 ctx, *trkParameters, m_destinationSurface,
600 : m_extrapolator->extrapolate(
601 ctx, *trkParameters, m_destinationSurface,
603 if (trkParameters_BACK) {
606 m_treeData->m_b_p = trkParameters_BACK->
momentum().mag();
607 m_treeData->m_b_eta = trkParameters_BACK->
momentum().eta();
608 m_treeData->m_b_theta = trkParameters_BACK->
momentum().theta();
609 m_treeData->m_b_phi = trkParameters_BACK->
momentum().phi();
610 m_treeData->m_b_x = trkParameters_BACK->
position().x();
611 m_treeData->m_b_y = trkParameters_BACK->
position().y();
612 m_treeData->m_b_z = trkParameters_BACK->
position().z();
613 if (std::fabs(m_treeData->m_m_p - m_treeData->m_b_p) > 10.)
615 " Back extrapolation to Muon Entry or ID Exit finds different "
616 "momentum difference MeV "
617 << m_treeData->m_m_p - m_treeData->m_b_p);
619 extrapolationCache.
reset();
620 const std::vector<const Trk::TrackStateOnSurface*>* matvec_BACK =
621 m_extrapolator->extrapolateM(
622 ctx, *trkParameters, m_destinationSurface,
628 if (matvec_BACK && !matvec_BACK->empty()) {
629 std::vector<const Trk::TrackStateOnSurface*>::const_iterator
it =
630 matvec_BACK->begin();
631 std::vector<const Trk::TrackStateOnSurface*>::const_iterator
632 it_end = matvec_BACK->end();
633 for (;
it != it_end; ++
it) {
635 (*it)->materialEffectsOnTrack();
638 if (m_treeData->m_trk_status[m_treeData->m_g4_steps] == 1000)
644 if (not matEfs)
continue;
647 double meanIoni = 0.;
648 double sigmaIoni = 0.;
650 double sigmaRad = 0.;
651 double sigmaTheta = 0.;
652 double sigmaPhi = 0.;
662 if (m_treeData->m_trk_status[m_treeData->m_g4_steps] == 1000)
665 <<
" eLoss->length() "
670 (matEfs)->scatteringAngles();
675 if (m_treeData->m_trk_scats < 500) {
677 if (m_treeData->m_trk_status[m_treeData->m_g4_steps] == 1000)
678 m_treeData->m_trk_sstatus[m_treeData->m_trk_scats] = -1000;
679 if ((*it)->trackParameters()) {
680 m_treeData->m_trk_sx[m_treeData->m_trk_scats] =
681 (*it)->trackParameters()->position().x();
682 m_treeData->m_trk_sy[m_treeData->m_trk_scats] =
683 (*it)->trackParameters()->position().y();
684 m_treeData->m_trk_sz[m_treeData->m_trk_scats] =
685 (*it)->trackParameters()->position().z();
687 m_treeData->m_trk_sx0[m_treeData->m_trk_scats] =
689 m_treeData->m_trk_seloss[m_treeData->m_trk_scats] = eloss0;
690 m_treeData->m_trk_smeanIoni[m_treeData->m_trk_scats] =
692 m_treeData->m_trk_ssigIoni[m_treeData->m_trk_scats] =
694 m_treeData->m_trk_smeanRad[m_treeData->m_trk_scats] = meanRad;
695 m_treeData->m_trk_ssigRad[m_treeData->m_trk_scats] = sigmaRad;
696 m_treeData->m_trk_ssigTheta[m_treeData->m_trk_scats] =
698 m_treeData->m_trk_ssigPhi[m_treeData->m_trk_scats] = sigmaPhi;
699 m_treeData->m_trk_scats++;
704 m_treeData->m_b_X0 = x0;
705 m_treeData->m_b_Eloss = Eloss;
712 extrapolationCache.
reset();
713 const std::vector<const Trk::TrackStateOnSurface*>* matvec =
714 m_extrapolator->extrapolateM(ctx, *m_parameterCache, destinationSurface,
716 &extrapolationCache);
723 if (m_useCovMatrix) {
725 "m_treeData->m_g4_stepsEntry (debug): " << m_treeData->m_g4_stepsEntry);
726 if (m_treeData->m_g4_stepsEntry <= 0) {
727 extrapolationCache.
reset();
728 matvec = m_extrapolator->extrapolateM(
731 if (!matvec || matvec->empty()) {
733 " G4 extrapolateM failed with covariance matrix to Muon Entry or ID Exit ");
735 " Redo G4 extrapolateM without covariance matrix to Muon Entry or ID Exit ");
736 extrapolationCache.
reset();
737 matvec = m_extrapolator->extrapolateM(
742 " G4 extrapolateM succesfull with covariance matrix to Muon Entry or ID Exit ");
745 << extrapolationCache.
x0tot() <<
" Eloss deltaE "
746 << extrapolationCache.
eloss()->
deltaE() <<
" Eloss sigma "
750 << extrapolationCache.
eloss()->
meanRad() <<
" sigmaRad "
753 if (m_treeData->m_g4_stepsEntry == 1) {
754 extrapolationCache.
reset();
755 matvec = m_extrapolator->extrapolateM(
758 if (!matvec || matvec->empty()) {
760 " G4 extrapolateM failed with covariance matrix to Muon or Calo Exit ");
762 " Redo G4 extrapolateM without covariance matrix to Muon or Calo Exit ");
763 extrapolationCache.
reset();
764 matvec = m_extrapolator->extrapolateM(
769 " G4 extrapolateM succesfull with covariance matrix to Muon or Calo Exit ");
772 << extrapolationCache.
x0tot() <<
" Eloss deltaE "
773 << extrapolationCache.
eloss()->
deltaE() <<
" Eloss sigma "
777 << extrapolationCache.
eloss()->
meanRad() <<
" sigmaRad "
781 if (m_treeData->m_g4_stepsEntry == 1) {
782 extrapolationCache.
reset();
783 matvec = m_extrapolator->extrapolateM(
786 ATH_MSG_DEBUG(
" G4 extrapolateM without covariance matrix to Muon Entry or ID Exit "
787 <<
" X0 " << extrapolationCache.
x0tot() <<
" Eloss deltaE "
788 << extrapolationCache.
eloss()->
deltaE() <<
" Eloss sigma "
792 << extrapolationCache.
eloss()->
meanRad() <<
" sigmaRad "
798 const std::vector<const Trk::TrackStateOnSurface*> matvecNewRepAggrUp =
799 modifyTSOSvector(*matvec, 1.0, 1.0,
true,
true,
true, 0., 0., 10000., 0.,
802 double X0Scale = 1.0;
803 double ElossScale = 1.0;
809 bool system1 =
false;
810 bool system2 =
false;
812 if (!matvec->empty()) {
813 if (m_crossedEntry && !m_exitLayer) system1 =
true;
814 if (m_crossedEntry && m_exitLayer) system2 =
true;
817 ATH_MSG_DEBUG(
" ID or Calorimeter system " << system1 <<
" Calorimeter or Muon system " << system2);
822 m_elossupdator->getX0ElossScales(0, m_treeData->m_m_eta,
823 m_treeData->m_m_phi, X0Scale, ElossScale);
824 ATH_MSG_DEBUG(
" system2 scales X0 " << X0Scale <<
" ElossScale "
827 const std::vector<const Trk::TrackStateOnSurface*> matvecNew1 =
828 modifyTSOSvector(*matvec, X0Scale, 1.,
true,
true,
true, 0., 0.,
829 m_treeData->m_m_p, 0., Eloss1);
830 const std::vector<const Trk::TrackStateOnSurface*> matvecNew0 =
831 modifyTSOSvector(*matvec, X0Scale, ElossScale,
true,
true,
true, 0., 0.,
832 m_treeData->m_m_p, 0., Eloss0);
834 const std::vector<const Trk::TrackStateOnSurface*> matvecNew5 =
835 modifyTSOSvector(*matvec, X0Scale, ElossScale,
true,
true,
true, 0., 0.,
836 m_treeData->m_m_p, 0.05 * m_treeData->m_m_p, Eloss5);
838 const std::vector<const Trk::TrackStateOnSurface*> matvecNew10 =
839 modifyTSOSvector(*matvec, X0Scale, ElossScale,
true,
true,
true, 0., 0.,
840 m_treeData->m_m_p, 0.10 * m_treeData->m_m_p, Eloss10);
846 double phiCaloExit = atan2(m_treeData->m_m_y, m_treeData->m_m_x);
847 m_elossupdator->getX0ElossScales(1, m_treeData->m_t_eta, phiCaloExit,
848 X0Scale, ElossScale);
849 ATH_MSG_DEBUG(
" calorimeter scales X0 " << X0Scale <<
" ElossScale "
851 const std::vector<const Trk::TrackStateOnSurface*> matvecNew1 =
852 modifyTSOSvector(*matvec, X0Scale, 1.,
true,
true,
true, 0., 0.,
853 m_treeData->m_m_p, 0., Eloss1);
854 const std::vector<const Trk::TrackStateOnSurface*> matvecNew0 =
855 modifyTSOSvector(*matvec, X0Scale, ElossScale,
true,
true,
true, 0., 0.,
856 m_treeData->m_t_p, 0., Eloss0);
857 if (std::fabs(Eloss1) > 0)
858 ATH_MSG_DEBUG(
" **** Cross Check calorimeter with Eloss Scale1 "
859 << Eloss1 <<
" Eloss0 " << Eloss0 <<
" ratio "
863 const std::vector<const Trk::TrackStateOnSurface*> matvecNew5 =
864 modifyTSOSvector(*matvec, X0Scale, ElossScale,
true,
true,
true, 0., 0.,
865 m_treeData->m_t_p, 0.05 * m_treeData->m_m_p, Eloss5);
867 const std::vector<const Trk::TrackStateOnSurface*> matvecNew10 =
868 modifyTSOSvector(*matvec, X0Scale, ElossScale,
true,
true,
true, 0., 0.,
869 m_treeData->m_t_p, 0.10 * m_treeData->m_m_p, Eloss10);
872 ATH_MSG_DEBUG(
" status " << m_treeData->m_trk_status[m_treeData->m_g4_steps]
873 <<
"Eloss1 " << Eloss1 <<
" Eloss0 " << Eloss0
874 <<
" Eloss5 " << Eloss5 <<
" Eloss10 " << Eloss10);
881 if (!(matvec->empty()) && m_treeData->m_g4_stepsEntry <= 1) {
882 std::vector<const Trk::TrackStateOnSurface*>::const_iterator
it =
884 std::vector<const Trk::TrackStateOnSurface*>::const_iterator it_end =
886 for (;
it != it_end; ++
it) {
890 if (m_treeData->m_trk_status[m_treeData->m_g4_steps] == 1000)
897 double meanIoni = 0.;
898 double sigmaIoni = 0.;
900 double sigmaRad = 0.;
901 double sigmaTheta = 0.;
902 double sigmaPhi = 0.;
913 << m_treeData->m_g4_stepsEntry <<
" mmat " << mmat
915 <<
" eLoss->deltaE() " << eLoss->
deltaE()
916 <<
" meanIoni " << meanIoni <<
" Total Eloss "
917 << Eloss <<
" eLoss->length() " << eLoss->
length());
922 (matEfs) ? ((matEfs)->scatteringAngles()) : (
nullptr);
928 << m_treeData->m_g4_stepsEntry <<
" mmat " << mmat
929 <<
" sigmaTheta " << sigmaTheta <<
" sigmaPhi "
933 if (m_treeData->m_trk_scats < 500) {
934 if (m_treeData->m_g4_stepsEntry == 0 ||
935 m_treeData->m_trk_status[m_treeData->m_g4_steps] == 1000) {
937 if (m_treeData->m_g4_stepsEntry == 0)
938 m_treeData->m_trk_sstatus[m_treeData->m_trk_scats] = 10;
939 if (m_treeData->m_trk_status[m_treeData->m_g4_steps] == 1000)
940 m_treeData->m_trk_sstatus[m_treeData->m_trk_scats] = 1000;
941 if ((*it)->trackParameters()) {
942 m_treeData->m_trk_sx[m_treeData->m_trk_scats] =
943 (*it)->trackParameters()->position().x();
944 m_treeData->m_trk_sy[m_treeData->m_trk_scats] =
945 (*it)->trackParameters()->position().y();
946 m_treeData->m_trk_sz[m_treeData->m_trk_scats] =
947 (*it)->trackParameters()->position().z();
949 m_treeData->m_trk_sx0[m_treeData->m_trk_scats] =
951 m_treeData->m_trk_seloss[m_treeData->m_trk_scats] = eloss0;
952 m_treeData->m_trk_smeanIoni[m_treeData->m_trk_scats] = meanIoni;
953 m_treeData->m_trk_ssigIoni[m_treeData->m_trk_scats] = sigmaIoni;
954 m_treeData->m_trk_smeanRad[m_treeData->m_trk_scats] = meanRad;
955 m_treeData->m_trk_ssigRad[m_treeData->m_trk_scats] = sigmaRad;
956 m_treeData->m_trk_ssigTheta[m_treeData->m_trk_scats] = sigmaTheta;
957 m_treeData->m_trk_ssigPhi[m_treeData->m_trk_scats] = sigmaPhi;
958 m_treeData->m_trk_scats++;
967 << m_treeData->m_g4_steps <<
" Radius " << npos.perp() <<
" z "
968 << npos.z() <<
" size matvec "
969 <<
" total X0 " << x0 <<
" total Eloss " << Eloss);
973 if (m_treeData->m_g4_steps > 0) --m_treeData->m_g4_steps;
975 m_treeData->m_g4_p[m_treeData->m_g4_steps] = nmom.mag();
976 m_treeData->m_g4_eta[m_treeData->m_g4_steps] = nmom.eta();
977 m_treeData->m_g4_theta[m_treeData->m_g4_steps] = nmom.theta();
978 m_treeData->m_g4_phi[m_treeData->m_g4_steps] = nmom.phi();
979 m_treeData->m_g4_x[m_treeData->m_g4_steps] = npos.x();
980 m_treeData->m_g4_y[m_treeData->m_g4_steps] = npos.y();
981 m_treeData->m_g4_z[m_treeData->m_g4_steps] = npos.z();
982 m_treeData->m_g4_tX0[m_treeData->m_g4_steps] = m_tX0Cache;
983 m_treeData->m_g4_t[m_treeData->m_g4_steps] =
t;
984 m_treeData->m_g4_X0[m_treeData->m_g4_steps] =
X0;
986 m_treeData->m_trk_p[m_treeData->m_g4_steps] =
987 trkParameters ? trkParameters->
momentum().mag() : 0.;
988 m_treeData->m_trk_eta[m_treeData->m_g4_steps] =
989 trkParameters ? trkParameters->
momentum().eta() : 0.;
990 m_treeData->m_trk_theta[m_treeData->m_g4_steps] =
991 trkParameters ? trkParameters->
momentum().theta() : 0.;
992 m_treeData->m_trk_phi[m_treeData->m_g4_steps] =
993 trkParameters ? trkParameters->
momentum().phi() : 0.;
994 m_treeData->m_trk_x[m_treeData->m_g4_steps] =
995 trkParameters ? trkParameters->
position().x() : 0.;
996 m_treeData->m_trk_y[m_treeData->m_g4_steps] =
997 trkParameters ? trkParameters->
position().y() : 0.;
998 m_treeData->m_trk_z[m_treeData->m_g4_steps] =
999 trkParameters ? trkParameters->
position().z() : 0.;
1000 m_treeData->m_trk_lx[m_treeData->m_g4_steps] =
1001 trkParameters ? trkParameters->parameters()[
Trk::locX] : 0.;
1002 m_treeData->m_trk_ly[m_treeData->m_g4_steps] =
1003 trkParameters ? trkParameters->parameters()[
Trk::locY] : 0.;
1004 m_treeData->m_trk_eloss[m_treeData->m_g4_steps] = Eloss;
1005 m_treeData->m_trk_eloss0[m_treeData->m_g4_steps] = Eloss0;
1006 m_treeData->m_trk_eloss1[m_treeData->m_g4_steps] = Eloss1;
1007 m_treeData->m_trk_eloss5[m_treeData->m_g4_steps] = Eloss5;
1008 m_treeData->m_trk_eloss10[m_treeData->m_g4_steps] = Eloss10;
1009 m_treeData->m_trk_scaleeloss[m_treeData->m_g4_steps] = ElossScale;
1010 m_treeData->m_trk_scalex0[m_treeData->m_g4_steps] = X0Scale;
1011 m_treeData->m_trk_x0[m_treeData->m_g4_steps] = x0;
1012 if (m_treeData->m_g4_stepsEntry == 0)
1013 m_treeData->m_trk_status[m_treeData->m_g4_steps] = 10;
1015 m_treeData->m_trk_status[m_treeData->m_g4_steps] = 1000;
1017 double errord0 = 0.;
1018 double errorz0 = 0.;
1019 double errorphi = 0.;
1020 double errortheta = 0.;
1021 double errorqoverp = 0.;
1022 if (trkParameters && trkParameters->covariance()) {
1028 ATH_MSG_DEBUG(
" Covariance found for m_treeData->m_trk_status "
1029 << m_treeData->m_trk_status[m_treeData->m_g4_steps]);
1032 m_treeData->m_trk_erd0[m_treeData->m_g4_steps] = sqrt(errord0);
1033 m_treeData->m_trk_erz0[m_treeData->m_g4_steps] = sqrt(errorz0);
1034 m_treeData->m_trk_erphi[m_treeData->m_g4_steps] = sqrt(errorphi);
1035 m_treeData->m_trk_ertheta[m_treeData->m_g4_steps] = sqrt(errortheta);
1036 m_treeData->m_trk_erqoverp[m_treeData->m_g4_steps] = sqrt(errorqoverp);
1039 if (m_treeData->m_g4_stepsEntry == 0) m_tX0Cache = 0.;
1041 if (m_extrapolateIncrementally && trkParameters) {
1042 delete m_parameterCache;
1047 ++m_treeData->m_g4_steps;
1048 if (m_treeData->m_g4_stepsEntry != -1) ++m_treeData->m_g4_stepsEntry;
1051 std::vector<const Trk::TrackStateOnSurface*>
1053 const std::vector<const Trk::TrackStateOnSurface*>& matvec,
double scaleX0,
1054 double scaleEloss,
bool reposition,
bool aggregate,
bool updateEloss,
1055 double caloEnergy,
double caloEnergyError,
double pCaloEntry,
1056 double momentumError,
double& Eloss_tot)
const {
1082 std::vector<const Trk::TrackStateOnSurface*> newTSOSvector;
1083 int maxsize = 2 * matvec.size();
1085 newTSOSvector.reserve(
maxsize);
1094 double sigmaDeltaPhi2_tot = 0.;
1095 double sigmaDeltaTheta2_tot = 0.;
1096 double deltaE_tot = 0.;
1097 double sigmaDeltaE_tot = 0.;
1098 double sigmaPlusDeltaE_tot = 0.;
1099 double sigmaMinusDeltaE_tot = 0.;
1100 double deltaE_ioni_tot = 0.;
1101 double sigmaDeltaE_ioni_tot = 0.;
1102 double deltaE_rad_tot = 0.;
1103 double sigmaDeltaE_rad_tot = 0.;
1110 double deltaEFirst = 0.;
1113 double deltaTheta = 0.;
1122 std::bitset<Trk::MaterialEffectsBase::NumberOfMaterialEffectsTypes>
1128 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes>
1133 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes>
1134 typePatternDeposit(0);
1139 for (
const auto*
m : matvec) {
1140 if (!
m->trackParameters()) {
1144 if (
m->materialEffectsOnTrack()) {
1145 double X0 =
m->materialEffectsOnTrack()->thicknessInX0();
1148 m->materialEffectsOnTrack());
1174 <<
m->dumpType() <<
" TSOS surface "
1175 <<
m->trackParameters()->associatedSurface()
1176 <<
" position x " <<
m->trackParameters()->position().x()
1177 <<
" y " <<
m->trackParameters()->position().y() <<
" z "
1178 <<
m->trackParameters()->position().z() <<
" direction x "
1179 <<
m->trackParameters()->momentum().unit().x() <<
" y "
1180 <<
m->trackParameters()->momentum().unit().y() <<
" z "
1181 <<
m->trackParameters()->momentum().unit().z() <<
" p "
1182 <<
m->trackParameters()->momentum().mag() <<
" X0 " <<
X0
1183 <<
" deltaE " << energyLoss->
deltaE()
1185 <<
" depth " <<
depth);
1187 X0_tot += scaleX0 *
X0;
1189 sigmaDeltaTheta2_tot +=
1191 sigmaDeltaPhi2_tot +=
1197 deltaE_tot += scaleEloss * energyLoss->
deltaE();
1198 sigmaDeltaE_tot += scaleEloss * energyLoss->
sigmaDeltaE();
1201 deltaE_ioni_tot += scaleEloss * energyLoss->
meanIoni();
1202 sigmaDeltaE_ioni_tot += scaleEloss * energyLoss->
sigmaIoni();
1203 deltaE_rad_tot += scaleEloss * energyLoss->
meanRad();
1204 sigmaDeltaE_rad_tot += scaleEloss * energyLoss->
sigmaRad();
1216 <<
pos.z() <<
" perp " <<
pos.perp());
1223 << pos0.x() <<
" y " << pos0.y() <<
" z " << pos0.z()
1224 <<
" perp " << pos0.perp());
1226 << posNew.x() <<
" y " << posNew.y() <<
" z " << posNew.z()
1227 <<
" perp " << posNew.perp() <<
" distance "
1228 << (pos0 - posNew).mag() <<
" depth " <<
depth);
1232 deltaEFirst = energyLoss->
deltaE();
1238 wpos +=
w * pos0 / 2.;
1239 wpos +=
w * posNew / 2.;
1242 wdist2 +=
w * (pos0 - posFirst).
mag2() / 2.;
1243 wdist2 +=
w * (posNew - posFirst).
mag2() / 2.;
1245 if (!aggregate && !reposition) {
1247 std::sqrt(sigmaDeltaPhi2_tot),
1248 std::sqrt(sigmaDeltaTheta2_tot));
1249 auto energyLossNew = std::make_unique<Trk::EnergyLoss>(
1250 deltaE_tot, sigmaDeltaE_tot, sigmaPlusDeltaE_tot,
1251 sigmaMinusDeltaE_tot, deltaE_ioni_tot, sigmaDeltaE_ioni_tot,
1252 deltaE_rad_tot, sigmaDeltaE_rad_tot,
depth);
1253 Eloss_tot += energyLossNew->deltaE();
1255 auto meotLast = std::make_unique<Trk::MaterialEffectsOnTrack>(
1256 X0_tot, scatNew, std::move(energyLossNew), surf, meotPattern);
1257 auto pars =
m->trackParameters()->uniqueClone();
1261 nullptr, std::move(
pars), std::move(meotLast), typePattern);
1262 newTSOSvector.push_back(newTSOS);
1265 sigmaDeltaTheta2_tot = 0.;
1266 sigmaDeltaPhi2_tot = 0.;
1268 sigmaDeltaE_tot = 0;
1269 sigmaPlusDeltaE_tot = 0.;
1270 sigmaMinusDeltaE_tot = 0.;
1271 deltaE_ioni_tot = 0.;
1272 sigmaDeltaE_ioni_tot = 0.;
1273 deltaE_rad_tot = 0.;
1274 sigmaDeltaE_rad_tot = 0.;
1276 }
else if (!aggregate && reposition) {
1277 if (std::abs(
depth) < 10.) {
1279 std::sqrt(sigmaDeltaPhi2_tot),
1280 std::sqrt(sigmaDeltaTheta2_tot));
1281 auto energyLossNew = std::make_unique<Trk::EnergyLoss>(
1282 deltaE_tot, sigmaDeltaE_tot, sigmaPlusDeltaE_tot,
1283 sigmaMinusDeltaE_tot, deltaE_ioni_tot, sigmaDeltaE_ioni_tot,
1284 deltaE_rad_tot, sigmaDeltaE_rad_tot,
depth);
1286 Eloss_tot += energyLossNew->deltaE();
1287 auto meotLast = std::make_unique<Trk::MaterialEffectsOnTrack>(
1288 X0_tot, scatNew, std::move(energyLossNew), surf, meotPattern);
1289 std::unique_ptr<Trk::TrackParameters>
pars =
1290 m->trackParameters()->uniqueClone();
1294 std::move(meotLast), typePattern);
1295 newTSOSvector.push_back(newTSOS);
1297 sigmaDeltaTheta2_tot = 0.;
1298 sigmaDeltaPhi2_tot = 0.;
1300 sigmaDeltaE_tot = 0;
1301 sigmaPlusDeltaE_tot = 0.;
1302 sigmaMinusDeltaE_tot = 0.;
1303 deltaE_ioni_tot = 0.;
1304 sigmaDeltaE_ioni_tot = 0.;
1305 deltaE_rad_tot = 0.;
1306 sigmaDeltaE_rad_tot = 0.;
1314 auto energyLoss0 = std::make_unique<Trk::EnergyLoss>(0., 0., 0., 0.);
1316 sqrt(sigmaDeltaPhi2_tot / 2.),
1317 sqrt(sigmaDeltaTheta2_tot / 2.));
1322 sqrt(sigmaDeltaPhi2_tot / 2.),
1323 sqrt(sigmaDeltaTheta2_tot / 2.));
1324 auto energyLossNew = std::make_unique<Trk::EnergyLoss>(
1325 deltaE_tot, sigmaDeltaE_tot, sigmaPlusDeltaE_tot,
1326 sigmaMinusDeltaE_tot, deltaE_ioni_tot, sigmaDeltaE_ioni_tot,
1327 deltaE_rad_tot, sigmaDeltaE_rad_tot, 0.);
1341 Eloss_tot += energyLossNew->deltaE();
1343 auto meotFirst = std::make_unique<Trk::MaterialEffectsOnTrack>(
1344 X0_tot / 2., scatFirst, std::move(energyLoss0), *surfFirst,
1346 auto meotLast = std::make_unique<Trk::MaterialEffectsOnTrack>(
1347 X0_tot / 2., scatNew, std::move(energyLossNew), *surfLast,
1351 double qOverP0 =
m->trackParameters()->charge() /
1352 (
m->trackParameters()->momentum().mag() -
1353 std::fabs(energyLoss->
deltaE()));
1357 std::unique_ptr<Trk::TrackParameters> parsFirst =
1359 0., 0.,
dir.phi(),
dir.theta(), qOverP0);
1361 double qOverPNew =
m->trackParameters()->charge() /
1362 m->trackParameters()->momentum().mag();
1363 std::unique_ptr<Trk::TrackParameters> parsLast =
1365 0., 0.,
dir.phi(),
dir.theta(), qOverPNew);
1370 std::move(meotFirst), typePattern);
1373 std::move(meotLast), typePattern);
1375 newTSOSvector.push_back(newTSOSFirst);
1376 newTSOSvector.push_back(newTSOS);
1379 sigmaDeltaTheta2_tot = 0.;
1380 sigmaDeltaPhi2_tot = 0.;
1382 sigmaDeltaE_tot = 0;
1383 sigmaPlusDeltaE_tot = 0.;
1384 sigmaMinusDeltaE_tot = 0.;
1385 deltaE_ioni_tot = 0.;
1386 sigmaDeltaE_ioni_tot = 0.;
1387 deltaE_rad_tot = 0.;
1388 sigmaDeltaE_rad_tot = 0.;
1395 if (aggregate && reposition) {
1401 bool threePlanes =
false;
1402 if (X0_tot > 50 && std::fabs(
pos.z()) < 6700 &&
pos.perp() < 4200)
1405 auto energyLoss0 = std::make_unique<Trk::EnergyLoss>(0., 0., 0., 0.);
1408 sqrt(sigmaDeltaTheta2_tot / 2.));
1412 sqrt(sigmaDeltaTheta2_tot / 2.));
1414 deltaE_tot, sigmaDeltaE_tot, sigmaPlusDeltaE_tot,
1415 sigmaMinusDeltaE_tot, deltaE_ioni_tot, sigmaDeltaE_ioni_tot,
1416 deltaE_rad_tot, sigmaDeltaE_rad_tot, 0.);
1420 auto energyLossNew =
1422 ? m_elossupdator->updateEnergyLoss(energyLoss2, caloEnergy,
1423 caloEnergyError, pCaloEntry,
1424 momentumError, elossFlag)
1426 sigmaPlusDeltaE_tot, sigmaMinusDeltaE_tot,
1427 deltaE_ioni_tot, sigmaDeltaE_ioni_tot,
1428 deltaE_rad_tot, sigmaDeltaE_rad_tot, 0.));
1440 double halflength2 =
1441 wdist2 / w_tot - (
pos - posFirst).
mag() * (
pos - posFirst).
mag();
1442 double halflength = 0.;
1443 if (halflength2 > 0) halflength = sqrt(halflength2);
1448 ATH_MSG_DEBUG(
" WITH aggregation and WITH reposition center planes x "
1449 <<
pos.x() <<
" y " <<
pos.y() <<
" z " <<
pos.z()
1450 <<
" halflength " << halflength <<
" w_tot " << w_tot
1451 <<
" X0_tot " << X0_tot);
1461 std::fabs(deltaEFirst));
1465 std::unique_ptr<Trk::TrackParameters> parsFirst =
1467 0., 0.,
dir.phi(),
dir.theta(), qOverP0);
1468 std::unique_ptr<Trk::TrackParameters> parsLast =
1470 0., 0.,
dir.phi(),
dir.theta(), qOverPNew);
1472 Eloss_tot += energyLossNew.deltaE();
1479 auto meotFirst = std::make_unique<Trk::MaterialEffectsOnTrack>(
1480 X0_tot / 2., scatFirst, std::move(energyLoss0), *surfFirst,
1485 auto meotLast = std::make_unique<Trk::MaterialEffectsOnTrack>(
1486 X0_tot / 2., scatNew,
1487 std::make_unique<Trk::EnergyLoss>(std::move(energyLossNew)),
1488 *surfLast, meotPattern);
1492 std::move(meotFirst), typePattern);
1493 auto whichType = (elossFlag != 0) ? typePatternDeposit : typePattern;
1495 nullptr, std::move(parsLast),
1496 std::move(meotLast), whichType);
1498 newTSOSvector.push_back(newTSOSFirst);
1499 newTSOSvector.push_back(newTSOS);
1507 std::unique_ptr<Trk::TrackParameters>
pars =
1509 0., 0.,
dir.phi(),
dir.theta(), qOverPNew);
1512 auto meotFirst = std::make_unique<Trk::MaterialEffectsOnTrack>(
1513 X0_tot / 2., scatFirst,
1514 std::make_unique<Trk::EnergyLoss>(0., 0., 0., 0.), *surfFirst,
1518 auto meot = std::make_unique<Trk::MaterialEffectsOnTrack>(
1520 std::make_unique<Trk::EnergyLoss>(std::move(energyLossNew)), *surf,
1524 auto meotLast = std::make_unique<Trk::MaterialEffectsOnTrack>(
1525 X0_tot / 2., scatNew,
1526 std::make_unique<Trk::EnergyLoss>(0., 0., 0., 0.), *surfLast,
1530 std::move(meotFirst), typePattern);
1532 nullptr, std::move(
pars), std::move(meot), typePatternDeposit);
1535 std::move(meotLast), typePattern);
1536 newTSOSvector.push_back(newTSOSFirst);
1537 newTSOSvector.push_back(newTSOS);
1538 newTSOSvector.push_back(newTSOSLast);
1543 return newTSOSvector;
1547 m_validationTree->Fill();
1548 delete m_parameterCache;
1549 delete m_parameterCacheCov;
1551 if (m_crossedEntry) {
1552 if (m_parameterCacheEntry)
delete m_parameterCacheEntry;
1553 if (m_parameterCacheEntryCov)
delete m_parameterCacheEntryCov;