358 unsigned int SampleID =
cell.caloDDE()->getSampling();
360 constexpr
double CellZB[9] = {141.495, 424.49, 707.485, 999.605, 1300.855, 1615.8, 1949., 2300.46, 2651.52};
361 constexpr
double CellDZB[9] = {282.99, 283., 282.99, 301.25, 301.25, 328.64, 337.76, 365.16, 336.96};
362 constexpr
double CellZC[9] = {159.755, 483.83, 812.465, 1150.23, 1497.125, 1857.71, 2241.12, 2628.695, 0};
363 constexpr
double CellDZC[9] = {319.51, 328.64, 328.63, 346.9, 346.89, 374.28, 392.54, 382.61, 0};
367 if (SampleID == 13 && (fabs(
cell.caloDDE()->eta() - 0.85) < 0.001 || fabs(
cell.caloDDE()->eta() + 0.85) < 0.001)) isBC9 =
true;
372 double Layer1X(
exit.x()), Layer1Y(
exit.y()), Layer1Z(
exit.z());
373 double Layer2X(entrance.x()), Layer2Y(entrance.y()), Layer2Z(entrance.z());
375 double CellPhimin =
cell.caloDDE()->phi() -
cell.caloDDE()->dphi() * 0.5;
376 double CellPhimax =
cell.caloDDE()->phi() +
cell.caloDDE()->dphi() * 0.5;
377 double CellZmin =
cell.caloDDE()->z() -
cell.caloDDE()->dz() * 0.5;
378 double CellZmax =
cell.caloDDE()->z() +
cell.caloDDE()->dz() * 0.5;
379 double CellRmin =
cell.caloDDE()->r() -
cell.caloDDE()->dr() * 0.5;
380 double CellRmax =
cell.caloDDE()->r() +
cell.caloDDE()->dr() * 0.5;
383 if (
cell.caloDDE()->dr() == 0) {
385 double CellVolume =
cell.caloDDE()->volume();
386 double product =
cell.caloDDE()->dphi() *
cell.caloDDE()->r() *
cell.caloDDE()->dz();
387 double drFormula = 0;
388 if (product != 0) { drFormula = CellVolume / product; }
389 CellRmin =
cell.caloDDE()->r() - drFormula * 0.5;
390 CellRmax =
cell.caloDDE()->r() + drFormula * 0.5;
395 double CellXimp[2], CellYimp[2], CellZimp[2];
396 double X(0),
Y(0),
Z(0),
Phi(0);
404 if (lBC == 1 && isBC9)
break;
406 if (sqrt((Layer1X - Layer2X) * (Layer1X - Layer2X) + (Layer1Y - Layer2Y) * (Layer1Y - Layer2Y)) < 3818.5) {
407 if (SampleID == 13 && lBC == 0) {
408 int cpos = fabs(
cell.caloDDE()->eta()) / 0.1;
412 CellZmin = CellZB[cpos] - 0.5 * CellDZB[cpos];
413 CellZmax = CellZB[cpos] + 0.5 * CellDZB[cpos];
415 else if (SampleID == 13 && lBC == 1) {
416 int cpos = fabs(
cell.caloDDE()->eta()) / 0.1;
420 CellZmin = CellZC[cpos] - 0.5 * CellDZC[cpos];
421 CellZmax = CellZC[cpos] + 0.5 * CellDZC[cpos];
425 double Sxy = (Layer2X - Layer1X) / (Layer2Y - Layer1Y);
426 double Sxz = (Layer2X - Layer1X) / (Layer2Z - Layer1Z);
427 double Syz = (Layer2Y - Layer1Y) / (Layer2Z - Layer1Z);
431 double Radius(CellRmin);
433 double x0int(
exit.x()), x1int(entrance.x()), y0int(
exit.y()), y1int(entrance.y()), z0int(
exit.z()), z1int(entrance.z());
434 double S((y1int - y0int) / (x1int - x0int));
435 double a(1 +
S *
S),
b(2 *
S * y0int - 2 *
S *
S * x0int),
436 c(y0int * y0int - Radius * Radius +
S *
S * x0int * x0int - 2 * y0int *
S * x0int);
437 double x1((-
b + sqrt(
b *
b - 4 *
a *
c)) / (2 *
a)),
x2((-
b - sqrt(
b *
b - 4 *
a *
c)) / (2 *
a));
438 double y1(y0int +
S * (
x1 - x0int)),
y2(y0int +
S * (
x2 - x0int));
439 double S1 = ((z1int - z0int) / (x1int - x0int));
440 double z1(z0int +
S1 * (
x1 - x0int)), z2(z0int +
S1 * (
x2 - x0int));
446 if (((
x1 - x0int) * (
x1 - x0int) + (
y1 - y0int) * (
y1 - y0int) + (z1 - z0int) * (z1 - z0int)) >
447 ((
x2 - x0int) * (
x2 - x0int) + (
y2 - y0int) * (
y2 - y0int) + (z2 - z0int) * (z2 - z0int))) {
453 if (CellRmin != CellRmax) {
454 Phi = acos(
X / sqrt(
X *
X +
Y *
Y));
458 if (
Z >= CellZmin && Z <= CellZmax && Phi >= CellPhimin &&
Phi <= CellPhimax) {
468 c = y0int * y0int - Radius * Radius +
S *
S * x0int * x0int - 2 * y0int *
S * x0int;
469 x1 = ((-
b + sqrt(
b *
b - 4 *
a *
c)) / (2 *
a));
470 x2 = ((-
b - sqrt(
b *
b - 4 *
a *
c)) / (2 *
a));
471 y1 = (y0int +
S * (
x1 - x0int));
472 y2 = (y0int +
S * (
x2 - x0int));
473 z1 = (z0int +
S1 * (
x1 - x0int));
474 z2 = (z0int +
S1 * (
x2 - x0int));
475 S1 = ((z1int - z0int) / (x1int - x0int));
481 if (((
x1 - x0int) * (
x1 - x0int) + (
y1 - y0int) * (
y1 - y0int) + (z1 - z0int) * (z1 - z0int)) >
482 ((
x2 - x0int) * (
x2 - x0int) + (
y2 - y0int) * (
y2 - y0int) + (z2 - z0int) * (z2 - z0int))) {
488 Phi = std::acos(
X / sqrt(
X *
X +
Y *
Y));
492 if (
Z >= CellZmin && Z <= CellZmax && Phi >= CellPhimin &&
Phi <= CellPhimax) {
501 if (CellZmin != CellZmax) {
504 X = Layer1X + Sxz * (
Z - Layer1Z);
505 Y = Layer1Y + Syz * (
Z - Layer1Z);
506 const double R = sqrt(
X *
X +
Y *
Y);
507 Phi = std::acos(
X /
R);
509 if (
R >= CellRmin && R <= CellRmax && Phi >= CellPhimin &&
Phi <= CellPhimax) {
519 X = Layer1X + Sxz * (
Z - Layer1Z);
520 Y = Layer1Y + Syz * (
Z - Layer1Z);
521 const double R = sqrt(
X *
X +
Y *
Y);
522 Phi = std::acos(
X /
R);
524 if (
R >= CellRmin && R <= CellRmax && Phi >= CellPhimin &&
Phi <= CellPhimax) {
534 if (CellPhimin != CellPhimax) {
536 X = (Layer1X - Sxy * Layer1Y) / (1 - Sxy *
tan(CellPhimin));
538 Z = Layer1Z + (1 / Sxz) * (
X - Layer1X);
539 const double R = sqrt(
X *
X +
Y *
Y);
540 Phi = std::acos(
X /
R);
542 DeltaPhi = fabs(
Phi - CellPhimin);
543 if (DeltaPhi > 3.141593) DeltaPhi = fabs(
Phi + CellPhimin);
544 if (
R >= CellRmin && R <= CellRmax && Z >= CellZmin &&
Z <= CellZmax && DeltaPhi < 0.0001) {
553 X = (Layer1X - Sxy * Layer1Y) / (1 - Sxy *
tan(CellPhimax));
555 Z = Layer1Z + (1 / Sxz) * (
X - Layer1X);
556 const double R = sqrt(
X *
X +
Y *
Y);
559 DeltaPhi = fabs(
Phi - CellPhimax);
560 if (DeltaPhi > 3.141593) DeltaPhi = fabs(
Phi + CellPhimax);
561 if (
R >= CellRmin && R <= CellRmax && Z >= CellZmin &&
Z <= CellZmax && DeltaPhi < 0.0001) {
572 pathl += sqrt((CellXimp[0] - CellXimp[1]) * (CellXimp[0] - CellXimp[1]) +
573 (CellYimp[0] - CellYimp[1]) * (CellYimp[0] - CellYimp[1]) +
574 (CellZimp[0] - CellZimp[1]) * (CellZimp[0] - CellZimp[1]));
577 if (SampleID == 13 && lBC == 0)