ATLAS Offline Software
Loading...
Searching...
No Matches
egammaClusterHelpers.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3 */
4
6
9
10namespace egammaClusterHelpers {
11
12 std::pair<const double, const double>
14 double eta,
15 double phi,
17 const CaloDetDescrElement* elt)
18 {
19 // Should be smaller than the eta half-width of any cell.
20 constexpr double eps = 0.001;
21
22 // Now look in the negative eta direction, on the low (left) side.
23 const CaloDetDescrElement* elt_l = mgr.get_element_raw(sampling, eta - elt->deta() - eps, phi);
24 double deta_l = elt_l ? std::abs(eta - elt_l->eta_raw()) + eps : 0.;
25
26 // Now look in the positive eta direction, on the high (right) side.
27 const CaloDetDescrElement* elt_r = mgr.get_element_raw(sampling, eta + elt->deta() + eps, phi);
28 double deta_r = elt_r ? std::abs(eta - elt_r->eta_raw()) + eps : 0.;
29
30 // Now for the phi variation.
31 // The phi size can change as a function of eta, but not of phi.
32 // Thus we have to look again at the adjacent eta cells, and
33 // take the largest variation.
34
35 // Now look in the negative eta direction, on the low-eta () side.
36 elt_l = mgr.get_element_raw(sampling, eta - elt->deta() - eps, CaloPhiRange::fix(phi - elt->dphi() - eps));
37 double dphi_l = elt_l ? std::abs(CaloPhiRange::fix(phi - elt_l->phi_raw())) + eps : 0.;
38
39 // Now look in the positive eta direction, on the positive (down) side.
40 elt_r = mgr.get_element_raw(sampling, eta + elt->deta() + eps, CaloPhiRange::fix(phi - elt->dphi() - eps));
41 double dphi_r = elt_r ? std::abs(CaloPhiRange::fix(phi - elt_r->phi_raw())) + eps : 0.;
42
43 // Total is twice the maximum.
44 return {2 * std::max(deta_r, deta_l), 2 * std::max(dphi_l, dphi_r)};
45}
46
47 void
49 {
50 bool isBarrel = cluster->inBarrel();
51 const bool isEndcap = cluster->inEndcap();
52 if (isBarrel && isEndcap) {
53 isBarrel = cluster->eSample(CaloSampling::EMB2)
54 >= cluster->eSample(CaloSampling::EME2);
55 }
57 isBarrel ? CaloCell_ID::EMB2 : CaloCell_ID::EME2;
58 // eta and phi of the cluster in the calorimeter frame
59 double eta;
60 double phi;
62 mgr, sample, cluster->eta(), cluster->phi(), eta, phi);
65 // eta in the second sampling
67 mgr, sample, cluster->etaBE(2), cluster->phiBE(2), eta, phi);
70 // eta in the first sampling
71 sample = isBarrel ? CaloCell_ID::EMB1 : CaloCell_ID::EME1;
73 mgr, sample, cluster->etaBE(1), cluster->phiBE(1), eta, phi);
76 }
77
78 void
80 const CaloDetDescrManager& mgr,
81 const CaloSampling::CaloSample sample)
82 {
83 const double clusterEtaMax = cluster->etamax(sample);
84 const double clusterPhiMax = cluster->phimax(sample);
85
86 // Protections.
87 if (clusterEtaMax == -999. || clusterPhiMax == -999.) {
88 return;
89 }
90 if (std::abs(clusterEtaMax) < 1E-6 && std::abs(clusterPhiMax) < 1E-6) {
91 return;
92 }
93
94 // Get the hottest in raw co-ordinates
95 // We have two kinds of enums ...
96 const CaloCell_ID::CaloSample xsample =
97 (sample == CaloSampling::EMB1) ? CaloCell_ID::EMB1 : CaloCell_ID::EME1;
98
99 const CaloDetDescrElement* dde = mgr.get_element(xsample,
100 clusterEtaMax,
101 clusterPhiMax);
102
103 if (!dde) {
104 return;
105 }
106
107 double etamax = dde->eta_raw();
108 double phimax = dde->phi_raw();
109
110 const CaloDetDescrElement* elt = mgr.get_element_raw(xsample, etamax, phimax);
111 if (!elt) {
112 return;
113 }
114
115 // Now Locate the +-1 range, use raw co-ordinates here.
116 auto [detastr, dphistr] = etaphi_range(mgr, etamax, phimax, xsample, elt);
117
118 // Given the range refine the position employing the smaller window
119 if (detastr > 0 && dphistr > 0) {
120 CaloLayerCalculator helper;
121 const auto* const cellLink = cluster->getCellLinks();
122 helper.fill(cellLink->begin(),
123 cellLink->end(),
124 etamax,
125 phimax,
126 detastr,
127 dphistr,
128 sample);
129
130 // Here is where we (re-)fill the eta in the 1st sampling
131 if (helper.etam() != -999.) {
132 // This is "real" atlas co-ordinates
133 cluster->setEta(sample, helper.etam());
134 }
135 }
136 }
137
138 void
140 {
141 // This only makes sense if we have cells there
142 if (!cluster->hasSampling(CaloSampling::EMB1) &&
143 !cluster->hasSampling(CaloSampling::EME1)) {
144 return;
145 }
146 // Now calculare the position using cells in barrel or endcap or both
147 const double aeta = std::abs(cluster->etaBE(2));
148 if (aeta < 1.6 && cluster->hasSampling(CaloSampling::EMB1)) {
149 makeCorrection1(cluster, mgr, CaloSampling::EMB1);
150 }
151 if (aeta > 1.3 && cluster->hasSampling(CaloSampling::EME1)) {
152 makeCorrection1(cluster, mgr, CaloSampling::EME1);
153 }
154 }
155}
156
157
158
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Calculate total energy, position, etc. for a given layer of a cluster.
static bool getDetPosition(const CaloDetDescrManager &mgr, CaloCell_ID::CaloSample sam, double etaAtlas, double phiAtlas, double &etaDet, double &phiDet)
get Detector level eta-phi position from Atlas level (aligned) position
CaloSampling::CaloSample CaloSample
Definition CaloCell_ID.h:53
This class groups all DetDescr information related to a CaloCell.
This class provides the client interface for accessing the detector description information common to...
static double fix(double phi)
float phiBE(const unsigned layer) const
Get the phi in one layer of the EM Calo.
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
virtual double eta() const
The pseudorapidity ( ) of the particle.
void insertMoment(MomentType type, double value)
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
bool inBarrel() const
Returns true if at least one clustered cell in the barrel.
float eSample(const CaloSample sampling) const
bool inEndcap() const
Returns true if at least one clustered cell in the endcap.
virtual double phi() const
The azimuthal angle ( ) of the particle.
float etamax(const CaloSample sampling) const
Retrieve of cell with maximum energy in given sampling.
@ ETA2CALOFRAME
Eta of sampling 2 in the calo frame (for egamma)
@ ETACALOFRAME
Eta in the calo frame (for egamma)
@ PHI2CALOFRAME
Phi of sampling 2 in the calo frame (for egamma)
@ PHI1CALOFRAME
Phi of sampling 1 in the calo frame (for egamma)
@ PHICALOFRAME
Phi in the calo frame (for egamma)
@ ETA1CALOFRAME
Eta of sampling 1 in the calo frame (for egamma)
float phimax(const CaloSample sampling) const
Retrieve of cell with maximum energy in given sampling.
bool hasSampling(const CaloSample s) const
Checks if certain smapling contributes to cluster.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
void fillPositionsInCalo(xAOD::CaloCluster *cluster, const CaloDetDescrManager &mgr)
Function to decorate the calo cluster with position variables.
std::pair< const double, const double > etaphi_range(const CaloDetDescrManager &mgr, double eta, double phi, CaloCell_ID::CaloSample sampling, const CaloDetDescrElement *elt)
Duplicate code.
void refineEta1Position(xAOD::CaloCluster *cluster, const CaloDetDescrManager &mgr)
function to refine position in eta1
void makeCorrection1(xAOD::CaloCluster *cluster, const CaloDetDescrManager &mgr, const CaloSampling::CaloSample sample)
functions to make 1st sampling (strips) specific corrections
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.