ATLAS Offline Software
Loading...
Searching...
No Matches
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
29public:
31 ~PathLengthUtils() = default;
32
33 double pathInsideCell(const CaloCell& cell, const CaloExtensionHelpers::EntryExitLayerMap& entryExitLayerMap) const;
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
40private:
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
52inline double PathLengthUtils::phiMean(double a, double b) const { return 0.5 * (a + b) + (a * b < 0) * M_PI; }
53
55inline 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
65inline 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
77inline 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
87inline 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
#define M_PI
CaloPhiRange class declaration.
#define AmgMatrix(rows, cols)
static Double_t a
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
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...
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.
static double getPathLengthInTile(const CaloCell &cell, const Amg::Vector3D &entry, const Amg::Vector3D &exit)
double phiMean(double a, double b) const
~PathLengthUtils()=default
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.
static CaloSampling::CaloSample tileEntrance(CaloSampling::CaloSample sample)
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.
static CaloSampling::CaloSample tileExit(CaloSampling::CaloSample sample)
static double get3DPathLength(const CaloCell &cell, const Amg::Vector3D &entry, const Amg::Vector3D &exit, double drFix, double dzFix)
static bool crossingMatrix(const AmgMatrix(3, 3)&Matrix, const Amg::Vector3D &entry, Amg::Vector3D &path)
Eigen::Matrix< double, 3, 1 > Vector3D
std::map< CaloSampling::CaloSample, std::pair< Amg::Vector3D, Amg::Vector3D > > EntryExitLayerMap