ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCellHelpers.h File Reference
#include <cmath>
#include "CaloEvent/CaloCell.h"
#include "CaloGeoHelpers/CaloPhiRange.h"
Include dependency graph for CaloCellHelpers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

double phiMean (double a, double b)
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 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 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.
double getPathLengthInZ (const CaloCell &cell, double z_entrance, double z_exit)
 Return the % of path length crossed by the track inside a cell in Z.
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.

Function Documentation

◆ crossedPhi()

bool crossedPhi ( const CaloCell & cell,
double phi_entrance,
double phi_exit )
inline

Return true if the cell crossed was crossed by the track in phi.

Definition at line 16 of file CaloCellHelpers.h.

16 {
17 double mean_phi = phiMean(phi_entrance, phi_exit);
18 double dphi = fabs(CaloPhiRange::diff(phi_entrance, phi_exit));
19 double phi_min = mean_phi - dphi, phi_max = mean_phi + dphi;
20
21 return (CaloPhiRange::diff(cell.phi() + cell.caloDDE()->dphi() / 2., phi_min) > 0 &&
22 CaloPhiRange::diff(phi_max, cell.phi() - cell.caloDDE()->dphi() / 2.) > 0);
23}
double phiMean(double a, double b)
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.

◆ getPathLengthInEta()

double getPathLengthInEta ( const CaloCell & cell,
double eta_entrance,
double eta_exit )
inline

Return the % of path length crossed by the track inside a cell in eta.

Definition at line 26 of file CaloCellHelpers.h.

26 {
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) // to avoid FPE
30 return eta_entrance > etaMin && eta_entrance < etaMax;
31
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);
35}

◆ getPathLengthInZ() [1/2]

double getPathLengthInZ ( const CaloCell & cell,
double z_entrance,
double z_exit )
inline

Return the % of path length crossed by the track inside a cell in Z.

Definition at line 48 of file CaloCellHelpers.h.

48 {
49 return getPathLengthInZ(cell.z() - 0.5 * cell.caloDDE()->dz(), cell.z() + 0.5 * cell.caloDDE()->dz(), z_entrance, z_exit);
50}
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.

◆ getPathLengthInZ() [2/2]

double getPathLengthInZ ( double zMin,
double zMax,
double z_entrance,
double z_exit )
inline

Return the % of path length crossed by the track inside a cell in Z.

Definition at line 38 of file CaloCellHelpers.h.

38 {
39 if (fabs(z_entrance - z_exit) < 1e-6) // to avoid FPE
40 return z_entrance > zMin && z_entrance < zMax;
41
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);
45}

◆ pathInsideCell()

double pathInsideCell ( const CaloCell & cell,
const Amg::Vector3D & entry,
const Amg::Vector3D & exit )
inline

Return the % of path length crossed by the track inside a cell in Z for a ladder shaped cell.

Return the % of the path crossed inside the cell, given the parameters for the extrapolation at entrance and exit of the layer

Definition at line 84 of file CaloCellHelpers.h.

84 {
85 if (!crossedPhi(cell, entry.phi(), exit.phi())) return 0;
86 double pathCrossed = 0;
87 if (cell.caloDDE()->getSubCalo() != CaloCell_ID::TILE)
88 pathCrossed = getPathLengthInEta(cell, entry.eta(), exit.eta());
89 else if (cell.caloDDE()->getSampling() == CaloCell_ID::TileBar1) // ladder shape cells, divide the problem in 2
90 pathCrossed = 0; // getPathLengthInZTileBar1(cell, entry.z(), exit.z());
91 else
92 pathCrossed = getPathLengthInZ(cell, entry.z(), exit.z());
93 if (pathCrossed <= 0) return 0;
94 return pathCrossed;
95}
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.
bool crossedPhi(const CaloCell &cell, double phi_entrance, double phi_exit)
Return true if the cell crossed was crossed by the track in phi.

◆ phiMean()

double phiMean ( double a,
double b )
inline

Definition at line 13 of file CaloCellHelpers.h.

13{ return 0.5 * (a + b) + (a * b < 0) * M_PI; }
#define M_PI
static Double_t a