Skip to content

Commit 4d750cf

Browse files
shahor02chiarazampolli
authored andcommitted
Update TOF integral calculation when propagation is aborted
1 parent 8a12f0e commit 4d750cf

1 file changed

Lines changed: 95 additions & 66 deletions

File tree

Detectors/Base/src/Propagator.cxx

Lines changed: 95 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -180,28 +180,36 @@ GPUd() bool PropagatorImpl<value_T>::PropagateToXBxByBz(TrackParCov_t& track, va
180180
auto xyz0 = track.getXYZGlo();
181181
getFieldXYZ(xyz0, &b[0]);
182182

183+
auto correct = [&track, &xyz0, tofInfo, matCorr, signCorr, this]() {
184+
bool res = true;
185+
if (matCorr != MatCorrType::USEMatCorrNONE) {
186+
auto xyz1 = track.getXYZGlo();
187+
auto mb = this->getMatBudget(matCorr, xyz0, xyz1);
188+
if (!track.correctForMaterial(mb.meanX2X0, mb.getXRho(signCorr))) {
189+
res = false;
190+
}
191+
if (tofInfo) {
192+
tofInfo->addStep(mb.length, track.getP2Inv()); // fill L,ToF info using already calculated step length
193+
tofInfo->addX2X0(mb.meanX2X0);
194+
tofInfo->addXRho(mb.getXRho(signCorr));
195+
}
196+
} else if (tofInfo) { // if tofInfo filling was requested w/o material correction, we need to calculate the step lenght
197+
auto xyz1 = track.getXYZGlo();
198+
math_utils::Vector3D<value_type> stepV(xyz1.X() - xyz0.X(), xyz1.Y() - xyz0.Y(), xyz1.Z() - xyz0.Z());
199+
tofInfo->addStep(stepV.R(), track.getP2Inv());
200+
}
201+
return res;
202+
};
203+
183204
if (!track.propagateTo(x, b)) {
184205
return false;
185206
}
186207
if (maxSnp > 0 && math_utils::detail::abs<value_type>(track.getSnp()) >= maxSnp) {
208+
correct();
187209
return false;
188210
}
189-
if (matCorr != MatCorrType::USEMatCorrNONE) {
190-
auto xyz1 = track.getXYZGlo();
191-
auto mb = getMatBudget(matCorr, xyz0, xyz1);
192-
if (!track.correctForMaterial(mb.meanX2X0, mb.getXRho(signCorr))) {
193-
return false;
194-
}
195-
196-
if (tofInfo) {
197-
tofInfo->addStep(mb.length, track.getP2Inv()); // fill L,ToF info using already calculated step length
198-
tofInfo->addX2X0(mb.meanX2X0);
199-
tofInfo->addXRho(mb.getXRho(signCorr));
200-
}
201-
} else if (tofInfo) { // if tofInfo filling was requested w/o material correction, we need to calculate the step lenght
202-
auto xyz1 = track.getXYZGlo();
203-
math_utils::Vector3D<value_type> stepV(xyz1.X() - xyz0.X(), xyz1.Y() - xyz0.Y(), xyz1.Z() - xyz0.Z());
204-
tofInfo->addStep(stepV.R(), track.getP2Inv());
211+
if (!correct()) {
212+
return false;
205213
}
206214
dx = xToGo - track.getX();
207215
}
@@ -241,27 +249,36 @@ GPUd() bool PropagatorImpl<value_T>::PropagateToXBxByBz(TrackPar_t& track, value
241249
auto xyz0 = track.getXYZGlo();
242250
getFieldXYZ(xyz0, &b[0]);
243251

252+
auto correct = [&track, &xyz0, tofInfo, matCorr, signCorr, this]() {
253+
bool res = true;
254+
if (matCorr != MatCorrType::USEMatCorrNONE) {
255+
auto xyz1 = track.getXYZGlo();
256+
auto mb = this->getMatBudget(matCorr, xyz0, xyz1);
257+
if (!track.correctForELoss(((signCorr < 0) ? -mb.length : mb.length) * mb.meanRho)) {
258+
res = false;
259+
}
260+
if (tofInfo) {
261+
tofInfo->addStep(mb.length, track.getP2Inv()); // fill L,ToF info using already calculated step length
262+
tofInfo->addX2X0(mb.meanX2X0);
263+
tofInfo->addXRho(mb.getXRho(signCorr));
264+
}
265+
} else if (tofInfo) { // if tofInfo filling was requested w/o material correction, we need to calculate the step lenght
266+
auto xyz1 = track.getXYZGlo();
267+
math_utils::Vector3D<value_type> stepV(xyz1.X() - xyz0.X(), xyz1.Y() - xyz0.Y(), xyz1.Z() - xyz0.Z());
268+
tofInfo->addStep(stepV.R(), track.getP2Inv());
269+
}
270+
return res;
271+
};
272+
244273
if (!track.propagateParamTo(x, b)) {
245274
return false;
246275
}
247276
if (maxSnp > 0 && math_utils::detail::abs<value_type>(track.getSnp()) >= maxSnp) {
277+
correct();
248278
return false;
249279
}
250-
if (matCorr != MatCorrType::USEMatCorrNONE) {
251-
auto xyz1 = track.getXYZGlo();
252-
auto mb = getMatBudget(matCorr, xyz0, xyz1);
253-
if (!track.correctForELoss(((signCorr < 0) ? -mb.length : mb.length) * mb.meanRho)) {
254-
return false;
255-
}
256-
if (tofInfo) {
257-
tofInfo->addStep(mb.length, track.getP2Inv()); // fill L,ToF info using already calculated step length
258-
tofInfo->addX2X0(mb.meanX2X0);
259-
tofInfo->addXRho(mb.getXRho(signCorr));
260-
}
261-
} else if (tofInfo) { // if tofInfo filling was requested w/o material correction, we need to calculate the step lenght
262-
auto xyz1 = track.getXYZGlo();
263-
math_utils::Vector3D<value_type> stepV(xyz1.X() - xyz0.X(), xyz1.Y() - xyz0.Y(), xyz1.Z() - xyz0.Z());
264-
tofInfo->addStep(stepV.R(), track.getP2Inv());
280+
if (!correct()) {
281+
return false;
265282
}
266283
dx = xToGo - track.getX();
267284
}
@@ -298,30 +315,35 @@ GPUd() bool PropagatorImpl<value_T>::propagateToX(TrackParCov_t& track, value_ty
298315
}
299316
auto x = track.getX() + step;
300317
auto xyz0 = track.getXYZGlo();
301-
318+
auto correct = [&track, &xyz0, tofInfo, matCorr, signCorr, this]() {
319+
bool res = true;
320+
if (matCorr != MatCorrType::USEMatCorrNONE) {
321+
auto xyz1 = track.getXYZGlo();
322+
auto mb = this->getMatBudget(matCorr, xyz0, xyz1);
323+
if (!track.correctForMaterial(mb.meanX2X0, mb.getXRho(signCorr))) {
324+
res = false;
325+
}
326+
if (tofInfo) {
327+
tofInfo->addStep(mb.length, track.getP2Inv()); // fill L,ToF info using already calculated step length
328+
tofInfo->addX2X0(mb.meanX2X0);
329+
tofInfo->addXRho(mb.getXRho(signCorr));
330+
}
331+
} else if (tofInfo) { // if tofInfo filling was requested w/o material correction, we need to calculate the step lenght
332+
auto xyz1 = track.getXYZGlo();
333+
math_utils::Vector3D<value_type> stepV(xyz1.X() - xyz0.X(), xyz1.Y() - xyz0.Y(), xyz1.Z() - xyz0.Z());
334+
tofInfo->addStep(stepV.R(), track.getP2Inv());
335+
}
336+
return res;
337+
};
302338
if (!track.propagateTo(x, bZ)) {
303339
return false;
304340
}
305341
if (maxSnp > 0 && math_utils::detail::abs<value_type>(track.getSnp()) >= maxSnp) {
342+
correct();
306343
return false;
307344
}
308-
if (matCorr != MatCorrType::USEMatCorrNONE) {
309-
auto xyz1 = track.getXYZGlo();
310-
auto mb = getMatBudget(matCorr, xyz0, xyz1);
311-
//
312-
if (!track.correctForMaterial(mb.meanX2X0, mb.getXRho(signCorr))) {
313-
return false;
314-
}
315-
316-
if (tofInfo) {
317-
tofInfo->addStep(mb.length, track.getP2Inv()); // fill L,ToF info using already calculated step length
318-
tofInfo->addX2X0(mb.meanX2X0);
319-
tofInfo->addXRho(mb.getXRho(signCorr));
320-
}
321-
} else if (tofInfo) { // if tofInfo filling was requested w/o material correction, we need to calculate the step lenght
322-
auto xyz1 = track.getXYZGlo();
323-
math_utils::Vector3D<value_type> stepV(xyz1.X() - xyz0.X(), xyz1.Y() - xyz0.Y(), xyz1.Z() - xyz0.Z());
324-
tofInfo->addStep(stepV.R(), track.getP2Inv());
345+
if (!correct()) {
346+
return false;
325347
}
326348
dx = xToGo - track.getX();
327349
}
@@ -359,29 +381,36 @@ GPUd() bool PropagatorImpl<value_T>::propagateToX(TrackPar_t& track, value_type
359381
auto x = track.getX() + step;
360382
auto xyz0 = track.getXYZGlo();
361383

384+
auto correct = [&track, &xyz0, tofInfo, matCorr, signCorr, this]() {
385+
bool res = true;
386+
if (matCorr != MatCorrType::USEMatCorrNONE) {
387+
auto xyz1 = track.getXYZGlo();
388+
auto mb = this->getMatBudget(matCorr, xyz0, xyz1);
389+
if (!track.correctForELoss(mb.getXRho(signCorr))) {
390+
res = false;
391+
}
392+
if (tofInfo) {
393+
tofInfo->addStep(mb.length, track.getP2Inv()); // fill L,ToF info using already calculated step length
394+
tofInfo->addX2X0(mb.meanX2X0);
395+
tofInfo->addXRho(mb.getXRho(signCorr));
396+
}
397+
} else if (tofInfo) { // if tofInfo filling was requested w/o material correction, we need to calculate the step lenght
398+
auto xyz1 = track.getXYZGlo();
399+
math_utils::Vector3D<value_type> stepV(xyz1.X() - xyz0.X(), xyz1.Y() - xyz0.Y(), xyz1.Z() - xyz0.Z());
400+
tofInfo->addStep(stepV.R(), track.getP2Inv());
401+
}
402+
return res;
403+
};
404+
362405
if (!track.propagateParamTo(x, bZ)) {
363406
return false;
364407
}
365408
if (maxSnp > 0 && math_utils::detail::abs<value_type>(track.getSnp()) >= maxSnp) {
409+
correct();
366410
return false;
367411
}
368-
if (matCorr != MatCorrType::USEMatCorrNONE) {
369-
auto xyz1 = track.getXYZGlo();
370-
auto mb = getMatBudget(matCorr, xyz0, xyz1);
371-
//
372-
if (!track.correctForELoss(mb.getXRho(signCorr))) {
373-
return false;
374-
}
375-
376-
if (tofInfo) {
377-
tofInfo->addStep(mb.length, track.getP2Inv()); // fill L,ToF info using already calculated step length
378-
tofInfo->addX2X0(mb.meanX2X0);
379-
tofInfo->addXRho(mb.getXRho(signCorr));
380-
}
381-
} else if (tofInfo) { // if tofInfo filling was requested w/o material correction, we need to calculate the step lenght
382-
auto xyz1 = track.getXYZGlo();
383-
math_utils::Vector3D<value_type> stepV(xyz1.X() - xyz0.X(), xyz1.Y() - xyz0.Y(), xyz1.Z() - xyz0.Z());
384-
tofInfo->addStep(stepV.R(), track.getP2Inv());
412+
if (!correct()) {
413+
return false;
385414
}
386415
dx = xToGo - track.getX();
387416
}

0 commit comments

Comments
 (0)