5#ifndef REC_CALOCELLHELPERS_H
6#define REC_CALOCELLHELPERS_H
13inline double phiMean(
double a,
double b) {
return 0.5 * (
a + b) + (
a * b < 0) *
M_PI; }
17 double mean_phi =
phiMean(phi_entrance, phi_exit);
19 double phi_min = mean_phi - dphi, phi_max = mean_phi + dphi;
27 double etaMin = cell.eta() - 0.5 * cell.caloDDE()->deta();
28 double etaMax = cell.eta() + 0.5 * cell.caloDDE()->deta();
29 if (fabs(eta_entrance - eta_exit) < 1e-6)
30 return eta_entrance > etaMin && eta_entrance < etaMax;
32 double etaMinTrack = std::min(eta_entrance, eta_exit);
33 double etaMaxTrack = std::max(eta_entrance, eta_exit);
34 return (std::min(etaMax, etaMaxTrack) - std::max(etaMin, etaMinTrack)) / (etaMaxTrack - etaMinTrack);
38inline double getPathLengthInZ(
double zMin,
double zMax,
double z_entrance,
double z_exit) {
39 if (fabs(z_entrance - z_exit) < 1e-6)
40 return z_entrance > zMin && z_entrance < zMax;
42 double zMinTrack = std::min(z_entrance, z_exit);
43 double zMaxTrack = std::max(z_entrance, z_exit);
44 return (std::min(zMax, zMaxTrack) - std::max(zMin, zMinTrack)) / (zMaxTrack - zMinTrack);
49 return getPathLengthInZ(cell.z() - 0.5 * cell.caloDDE()->dz(), cell.z() + 0.5 * cell.caloDDE()->dz(), z_entrance, z_exit);
85 if (!
crossedPhi(cell, entry.phi(), exit.phi()))
return 0;
86 double pathCrossed = 0;
89 else if (cell.caloDDE()->getSampling() == CaloCell_ID::TileBar1)
93 if (pathCrossed <= 0)
return 0;
double getPathLengthInEta(const CaloCell &cell, double eta_entrance, double eta_exit)
Return the % of path length crossed by the track inside a cell in eta.
double pathInsideCell(const CaloCell &cell, const Amg::Vector3D &entry, const Amg::Vector3D &exit)
Return the % of path length crossed by the track inside a cell in Z for a ladder shaped cell.
bool crossedPhi(const CaloCell &cell, double phi_entrance, double phi_exit)
Return true if the cell crossed was crossed by the track in phi.
double phiMean(double a, double b)
double getPathLengthInZ(double zMin, double zMax, double z_entrance, double z_exit)
Return the % of path length crossed by the track inside a cell in Z.
CaloPhiRange class declaration.
Data object for each calorimeter readout cell.
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
Eigen::Matrix< double, 3, 1 > Vector3D