ATLAS Offline Software
Loading...
Searching...
No Matches
CaloLayerCalculator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id: CaloLayerCalculator.cxx,v 1.1 2006-03-20 17:42:26 ssnyder Exp $
13
17
27
28
46StatusCode
48 const CaloCellContainer* cell_container,
49 double eta,
50 double phi,
51 double deta,
52 double dphi,
54 xAOD::CaloCluster* tofill /*= 0*/)
55{
56
57 //Check if cell_container and cluster matches
58 if (tofill) {
59 if (tofill->getCellLinks()->getCellContainer()!=cell_container) {
60 std::cout << "ERROR attempt to fill a cluster from different cell containers\n";
61 return StatusCode::FAILURE;
62 }
63 }
64
65 CaloCellList cell_list(&mgr,cell_container);
66 cell_list.select(eta,phi,deta,dphi,sampling);
67
68 fill (cell_list.begin(),
69 cell_list.end(),
70 eta, phi, deta, dphi, sampling, tofill);
71
72 return StatusCode::SUCCESS;
73}
74
77{
78 m_etam = -999;
79 m_phim = -999;
80 m_etamax = -999;
81 m_phimax = -999;
82 m_etarmax= -999;
83 m_phirmax= -999;
84
85 m_etas = 0;
86 m_phis = 0;
87 m_em = 0;
88 m_emax = 0;
89
90 // Added to cluster in the calorimeter frame
91 m_etamr = -999;
92 m_phimr = -999;
93
94}
95
96
99{
100 m_etam = -999;
101 m_phim = -999;
102 m_etamax = -999;
103 m_phimax = -999;
104 // Don't reset these --- that could prevent us from being able
105 // to calculate the e2* variables in egammaMiddleShape if there
106 // are negative energy cells just outside the cluster.
107 //m_etarmax= -999;
108 //m_phirmax= -999;
109
110 m_etas = 0;
111 m_phis = 0;
112 //m_em = 0;
113 m_emax = 0;
114
115 // Added to cluster in the calorimeter frame
116 m_etamr = -999;
117 m_phimr = -999;
118}
119
122{
123 m_etam = eta;
124 m_phim = phi;
125 m_etamax = eta;
126 m_phimax = phi;
127 m_etarmax= eta;
128 m_phirmax= phi;
129
130 m_etas = 0;
131 m_phis = 0;
132 //m_em = 0;
133 m_emax = 0;
134
135 // Added to cluster in the calorimeter frame
136 m_etamr = eta;
137 m_phimr = phi;
138}
139
140
155 double eta,
156 double phi,
157 double deta,
158 double dphi,
160 xAOD::CaloCluster* tofill,
161 const CaloCellContainer*
162 cell_container)
163 : m_calc (calc),
164 m_eta (eta),
165 m_phi (CaloPhiRange::fix (phi)),
166 m_deta (deta),
167 m_dphi (dphi),
168 m_sampling (sampling),
169 m_tofill (tofill),
170 m_cell_container (cell_container),
171 m_s00 (0),
172 m_s10 (0),
173 m_s20 (0),
174 m_s01 (0),
175 m_s02 (0),
176 // Added to cluster in the calorimeter frame
177 m_s10r (0),
178 m_s01r (0)
179{
180 m_calc.m_emax = -999999;
181}
182
183
189void
191{
192 // Test to see if this cell should be selected.
193 if (cell->caloDDE()->getSampling() == m_sampling) {
194 double etac = cell->eta();
195 double phic = cell->phi();
196 double etar = cell->caloDDE()->eta_raw();
197 double phir = cell->caloDDE()->phi_raw();
198 // Ideally, phi is computed as a deltaphi + phi to be safe with range
199 // the offset is taken to be the seed from the previous sampling
200 // I take the same offset for the raw and real computations
201 double dphic = CaloPhiRange::diff (phic, m_phi);
202 double dphir = CaloPhiRange::diff (phir, m_phi);
203
204 // The conditions are applied in the calorimeter frame, the biggest difference w.r.t. before...
205 if (etar >= m_eta-m_deta/2. && etar <= m_eta+m_deta/2.) {
206 if (dphir >= -m_dphi/2. && dphir <= m_dphi/2.) {
207
208 // Is this the maximum-energy cell so far?
209 double ene = cell->energy() * weight;
210
211 if (ene > m_calc.m_emax) {
212 m_calc.m_etamax = etac;
213 m_calc.m_phimax = phic;
214 m_calc.m_emax = ene;
215 // In the calorimeter frame
216 m_calc.m_etarmax = etar;
217 m_calc.m_phirmax = phir;
218 }
219
220 // Update accumulation.
221 m_s00 += ene;
222 m_s10 += etac*ene;
223 m_s20 += ene*etac*etac;
224 m_s01 += dphic*ene;
225 m_s02 += ene*dphic*dphic;
226 // In the calorimeter frame
227 m_s10r += etar*ene;
228 m_s01r += dphir*ene;
229
230 // Add the cell to the cluster, if requested.
231 if (m_tofill)
232 m_tofill->addCell(m_cell_container->findIndex(cell->caloDDE()->calo_hash()), weight);
233 }
234 }
235 }
236}
237
238
245{
246 m_calc.m_em = m_s00;
247
248 if (m_s00 > 0.) {
249 // When we computed m_s01 and m_s02 above, we had subtracted phi from each
250 // angle to avoid wrapping problems. We need to add it back in
251 // when computing the mean, but not when we compute the width.
252 // To be pedantic (but i got this wrong the first time, so maybe
253 // someone else will also be confused):
254 // We want <phic^2>-<phic>^2.
255 // s2 = s02/s00 = <(phic-phi)^2>
256 // s1 = s01/s00 = <(phic-phi)>
257 // Expanding the square in s2 gives
258 // <phic^2>-<phic>^2 = s2 - <phic>^2 + phi*(2<phic>-phi)
259 // Expanding the square in s1^2 and substituting for <phic>^2 above gives
260 // <phic^2>-<phic>^2 = s2 - s1^2
261 double s1 = m_s01/m_s00;
262 m_calc.m_phim = CaloPhiRange::fix (s1 + m_phi);
263 m_calc.m_phis = m_s02/m_s00 - s1*s1;
264
265
266 m_calc.m_etam = m_s10/m_s00;
267 m_calc.m_etas = m_s20/m_s00 - m_calc.m_etam*m_calc.m_etam;
268
269 // In the calorimeter frame
270 m_calc.m_etamr = m_s10r/m_s00;
272
273 // Reset position variables if the calculated eta,phi is outside
274 // of the window defined by deta,dphi. This usually happens
275 // if the negative energy within the window nearly cancels
276 // the positive energy.
277 if (std::abs (m_calc.m_etamr - m_eta) > m_deta ||
278 std::abs (m_calc.m_etam) > 10 ||
279 std::abs (CaloPhiRange::fix (m_calc.m_phimr - m_phi)) > m_dphi)
280 {
281 m_calc.resetOnNegativeEnergy(m_eta,m_phi);
282 }
283 }
284 else {
285 //reset();//replaced by:
286 m_calc.resetOnNegativeEnergy(m_eta,m_phi);
287
288 //energy of a sampling CAN be negative (especially PS and back)
289 //when there is the (gaussian) noise
290 //TEMPORARY SOLUTION ( energy negative is not reset to 0 anymore,
291 //but m_etam, m_phim, m_etas, m_phis are still null !! )
292 // => << TO BE REDONE >>
293 }
294
295 if (m_calc.m_etas > 0.) m_calc.m_etas = sqrt(m_calc.m_etas);
296 if (m_calc.m_phis > 0.) m_calc.m_phis = sqrt (m_calc.m_phis);
297}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Calculate total energy, position, etc. for a given layer of a cluster.
Container class for CaloCell.
list_iterator end() const
void select(double eta, double phi, double deta, double dphi)
list_iterator begin() const
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
This class provides the client interface for accessing the detector description information common to...
void fill(Iterator beg, Iterator end, double eta, double phi, double deta, double dphi, CaloSampling::CaloSample sampling, xAOD::CaloCluster *tofill=0)
Calculate layer variables from cells in a list.
CaloLayerCalculator()
Initialization.
double m_etam
Layer variables.
void resetOnNegativeEnergy()
Reset output variables, but not m_em, allowing samplings to be negative.
This class defines the phi convention for Calorimeters.
static double fix(double phi)
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
const CaloClusterCellLink * getCellLinks() const
Get a pointer to the CaloClusterCellLink object (const version)
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
const CaloCellContainer * m_cell_container
CaloSampling::CaloSample m_sampling
void cell(const CaloCell *cell, double weight)
Accumulate results for another cell.
Helper(CaloLayerCalculator &calc, double eta, double phi, double deta, double dphi, CaloSampling::CaloSample sampling, xAOD::CaloCluster *tofill, const CaloCellContainer *cell_container)
Initialize for doing layer variable calculation.
double m_s00
Temporary variables used to accumulate the results.
~Helper()
Calculate the layer variables from the accumulated cells The variables in the parent CaloLayerCalcula...
CaloLayerCalculator & m_calc
These members hold the values passed to the constructor.