ATLAS Offline Software
PathLengthUtils.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  PathLengthUtils.h - Description
7  -------------------
8  begin : Summer 2014
9  authors : Marius Cornelis van Woerden
10  email : mvanwoer@cern.ch
11  changes :
12 
13  ***************************************************************************/
14 
15 #ifndef PATHLENGTUTILS_H
16 #define PATHLENGTUTILS_H
17 
18 #include <cmath>
19 
20 #include "CaloEvent/CaloCell.h"
23 #include "CaloGeoHelpers/CaloSampling.h"
27 
29 public:
31  ~PathLengthUtils() = default;
32 
34  static double get3DPathLength(const CaloCell& cell, const Amg::Vector3D& entry, const Amg::Vector3D& exit, double drFix, double dzFix) ;
35 
36  static double getPathLengthInTile(const CaloCell& cell, const Amg::Vector3D& entry, const Amg::Vector3D& exit) ;
37  // double path(xAOD::TrackParticle& trackParticle, const CaloCell* cell);
38  // double path(xAOD::TrackParticle& trackParticle, const CaloCell_ID::CaloSample sample);
39 
40 private:
43 
44  double phiMean(double a, double b) const;
45  bool crossedPhi(const CaloCell& cell, double phi_entrance, double phi_exit) const;
46  double getPathLengthInEta(const CaloCell& cell, double eta_entrance, double eta_exit) const;
47  double getPathLengthInZ(double zMin, double zMax, double z_entrance, double z_exit) const;
48  double getPathLengthInZ(const CaloCell& cell, double z_entrance, double z_exit) const;
49  static bool crossingMatrix(const AmgMatrix(3,3)& Matrix, const Amg::Vector3D& entry, Amg::Vector3D& path) ;
50 };
51 
52 inline double PathLengthUtils::phiMean(double a, double b) const { return 0.5 * (a + b) + (a * b < 0) * M_PI; }
53 
55 inline bool PathLengthUtils::crossedPhi(const CaloCell& cell, double phi_entrance, double phi_exit) const {
56  double mean_phi = phiMean(phi_entrance, phi_exit);
57  double dphi = fabs(CaloPhiRange::diff(phi_entrance, phi_exit));
58  double phi_min = mean_phi - dphi, phi_max = mean_phi + dphi;
59 
60  return (CaloPhiRange::diff(cell.phi() + cell.caloDDE()->dphi() / 2., phi_min) > 0 &&
61  CaloPhiRange::diff(phi_max, cell.phi() - cell.caloDDE()->dphi() / 2.) > 0);
62 }
63 
65 inline double PathLengthUtils::getPathLengthInEta(const CaloCell& cell, double eta_entrance, double eta_exit) const {
66  double etaMin = cell.eta() - 0.5 * cell.caloDDE()->deta();
67  double etaMax = cell.eta() + 0.5 * cell.caloDDE()->deta();
68  if (fabs(eta_entrance - eta_exit) < 1e-6) // to avoid FPE
69  return eta_entrance > etaMin && eta_entrance < etaMax;
70 
71  double etaMinTrack = std::min(eta_entrance, eta_exit);
72  double etaMaxTrack = std::max(eta_entrance, eta_exit);
73  return (std::min(etaMax, etaMaxTrack) - std::max(etaMin, etaMinTrack)) / (etaMaxTrack - etaMinTrack);
74 }
75 
77 inline double PathLengthUtils::getPathLengthInZ(double zMin, double zMax, double z_entrance, double z_exit) const {
78  if (fabs(z_entrance - z_exit) < 1e-6) // to avoid FPE
79  return z_entrance > zMin && z_entrance < zMax;
80 
81  double zMinTrack = std::min(z_entrance, z_exit);
82  double zMaxTrack = std::max(z_entrance, z_exit);
83  return (std::min(zMax, zMaxTrack) - std::max(zMin, zMinTrack)) / (zMaxTrack - zMinTrack);
84 }
85 
87 inline double PathLengthUtils::getPathLengthInZ(const CaloCell& cell, double z_entrance, double z_exit) const {
88  return getPathLengthInZ(cell.z() - 0.5 * cell.caloDDE()->dz(), cell.z() + 0.5 * cell.caloDDE()->dz(), z_entrance, z_exit);
89 }
90 
91 #endif //> !PATHLENGTUTILS_H
PathLengthUtils::~PathLengthUtils
~PathLengthUtils()=default
Matrix
Definition: Trigger/TrigT1/TrigT1RPChardware/TrigT1RPChardware/Matrix.h:15
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
max
#define max(a, b)
Definition: cfImp.cxx:41
CaloExtensionHelpers.h
M_PI
#define M_PI
Definition: ActiveFraction.h:11
CaloExtensionHelpers::entryExitLayerMap
void entryExitLayerMap(const Trk::CaloExtension &extension, EntryExitLayerMap &result, const LayersToSelect *selection=nullptr)
Definition: CaloExtensionHelpers.h:192
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
CaloCell.h
PathLengthUtils::phiMean
double phiMean(double a, double b) const
Definition: PathLengthUtils.h:52
PathLengthUtils::getPathLengthInZ
double getPathLengthInZ(double zMin, double zMax, double z_entrance, double z_exit) const
Return the % of path length crossed by the track inside a cell in Z.
Definition: PathLengthUtils.h:77
AmgMatrix
#define AmgMatrix(rows, cols)
Definition: EventPrimitives.h:51
PathLengthUtils::crossingMatrix
static bool crossingMatrix(const AmgMatrix(3, 3)&Matrix, const Amg::Vector3D &entry, Amg::Vector3D &path)
Definition: PathLengthUtils.cxx:337
PathLengthUtils::getPathLengthInTile
static double getPathLengthInTile(const CaloCell &cell, const Amg::Vector3D &entry, const Amg::Vector3D &exit)
Definition: PathLengthUtils.cxx:355
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloPhiRange.h
CaloPhiRange class declaration.
CaloExtensionHelpers::EntryExitLayerMap
std::map< CaloSampling::CaloSample, std::pair< Amg::Vector3D, Amg::Vector3D > > EntryExitLayerMap
Definition: CaloExtensionHelpers.h:21
calibdata.exit
exit
Definition: calibdata.py:236
min
#define min(a, b)
Definition: cfImp.cxx:40
PathLengthUtils::getPathLengthInEta
double getPathLengthInEta(const CaloCell &cell, double eta_entrance, double eta_exit) const
Return the % of path length crossed by the track inside a cell in eta.
Definition: PathLengthUtils.h:65
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
PathLengthUtils::get3DPathLength
static double get3DPathLength(const CaloCell &cell, const Amg::Vector3D &entry, const Amg::Vector3D &exit, double drFix, double dzFix)
Definition: PathLengthUtils.cxx:18
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
PathLengthUtils
Definition: PathLengthUtils.h:28
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
CaloCellContainer.h
PathLengthUtils::PathLengthUtils
PathLengthUtils()
TrackParticle.h
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
a
TList * a
Definition: liststreamerinfos.cxx:10
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
PathLengthUtils::tileEntrance
static CaloSampling::CaloSample tileEntrance(CaloSampling::CaloSample sample)
Definition: PathLengthUtils.cxx:586
PathLengthUtils::crossedPhi
bool crossedPhi(const CaloCell &cell, double phi_entrance, double phi_exit) const
Return true if the cell crossed was crossed by the track in phi.
Definition: PathLengthUtils.h:55
TrackParticleContainer.h
PathLengthUtils::pathInsideCell
double pathInsideCell(const CaloCell &cell, const CaloExtensionHelpers::EntryExitLayerMap &entryExitLayerMap) const
Return the length(mm) of the path crossed inside the cell, given the parameters for the extrapolation...
Definition: PathLengthUtils.cxx:612
PathLengthUtils::tileExit
static CaloSampling::CaloSample tileExit(CaloSampling::CaloSample sample)
Definition: PathLengthUtils.cxx:598
CaloPhiRange::diff
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
Definition: CaloPhiRange.cxx:22