ATLAS Offline Software
Loading...
Searching...
No Matches
CaloLayerCalculator::Helper Struct Reference

Helper class for layer variable calculation. More...

Collaboration diagram for CaloLayerCalculator::Helper:

Public Member Functions

 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.
void cell (const CaloCell *cell, double weight)
 Accumulate results for another cell.
 ~Helper ()
 Calculate the layer variables from the accumulated cells The variables in the parent CaloLayerCalculator instance (passed to the constructor) are updated.

Public Attributes

CaloLayerCalculatorm_calc
 These members hold the values passed to the constructor.
double m_eta
double m_phi
double m_deta
double m_dphi
CaloSampling::CaloSample m_sampling
xAOD::CaloClusterm_tofill
const CaloCellContainerm_cell_container
double m_s00
 Temporary variables used to accumulate the results.
double m_s10
double m_s20
double m_s01
double m_s02
double m_s10r
double m_s01r

Detailed Description

Helper class for layer variable calculation.

This class is used to allow factoring out the layer variable calculation itself (which we only want to write once) from the loop over cells (of which there may be multiple varieties). To compute the layer variables, a Helper instance is created; it will contain the temporary variables used to accumulate the results. Then, for each cell in the list, call the cell method of Helper. At the end, the Helper destructor will update the layer variables.

Definition at line 285 of file CaloLayerCalculator.h.

Constructor & Destructor Documentation

◆ Helper()

CaloLayerCalculator::Helper::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.

Parameters
calcThe parent CaloLayerCalculator instance.
etaThe \(\eta\) center of the cluster, for cell selection.
phiThe \(\phi\) center of the cluster, for cell selection.
detaThe \(\eta\) full width for cell selection.
dphiThe \(\phi\) full width for cell selection.
samplingThe sampling for cell selection.
tofillIf non-null, then selected cells will be added to this cluster.
cell_containerIf tofill is non-null, then this is this container from which the cells came.

Definition at line 154 of file CaloLayerCalculator.cxx.

163 : m_calc (calc),
164 m_eta (eta),
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}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
static double fix(double phi)
const CaloCellContainer * m_cell_container
CaloSampling::CaloSample m_sampling
double m_s00
Temporary variables used to accumulate the results.
CaloLayerCalculator & m_calc
These members hold the values passed to the constructor.

◆ ~Helper()

CaloLayerCalculator::Helper::~Helper ( )

Calculate the layer variables from the accumulated cells The variables in the parent CaloLayerCalculator instance (passed to the constructor) are updated.

Definition at line 244 of file CaloLayerCalculator.cxx.

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}

Member Function Documentation

◆ cell()

void CaloLayerCalculator::Helper::cell ( const CaloCell * cell,
double weight )

Accumulate results for another cell.

Parameters
cellThe cell to accumulate.
weightThe weight for the cell.

Definition at line 190 of file CaloLayerCalculator.cxx.

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}
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
void cell(const CaloCell *cell, double weight)
Accumulate results for another cell.

Member Data Documentation

◆ m_calc

CaloLayerCalculator& CaloLayerCalculator::Helper::m_calc

These members hold the values passed to the constructor.

Definition at line 327 of file CaloLayerCalculator.h.

◆ m_cell_container

const CaloCellContainer* CaloLayerCalculator::Helper::m_cell_container

Definition at line 334 of file CaloLayerCalculator.h.

◆ m_deta

double CaloLayerCalculator::Helper::m_deta

Definition at line 330 of file CaloLayerCalculator.h.

◆ m_dphi

double CaloLayerCalculator::Helper::m_dphi

Definition at line 331 of file CaloLayerCalculator.h.

◆ m_eta

double CaloLayerCalculator::Helper::m_eta

Definition at line 328 of file CaloLayerCalculator.h.

◆ m_phi

double CaloLayerCalculator::Helper::m_phi

Definition at line 329 of file CaloLayerCalculator.h.

◆ m_s00

double CaloLayerCalculator::Helper::m_s00

Temporary variables used to accumulate the results.

Definition at line 337 of file CaloLayerCalculator.h.

◆ m_s01

double CaloLayerCalculator::Helper::m_s01

Definition at line 340 of file CaloLayerCalculator.h.

◆ m_s01r

double CaloLayerCalculator::Helper::m_s01r

Definition at line 345 of file CaloLayerCalculator.h.

◆ m_s02

double CaloLayerCalculator::Helper::m_s02

Definition at line 341 of file CaloLayerCalculator.h.

◆ m_s10

double CaloLayerCalculator::Helper::m_s10

Definition at line 338 of file CaloLayerCalculator.h.

◆ m_s10r

double CaloLayerCalculator::Helper::m_s10r

Definition at line 344 of file CaloLayerCalculator.h.

◆ m_s20

double CaloLayerCalculator::Helper::m_s20

Definition at line 339 of file CaloLayerCalculator.h.

◆ m_sampling

CaloSampling::CaloSample CaloLayerCalculator::Helper::m_sampling

Definition at line 332 of file CaloLayerCalculator.h.

◆ m_tofill

xAOD::CaloCluster* CaloLayerCalculator::Helper::m_tofill

Definition at line 333 of file CaloLayerCalculator.h.


The documentation for this struct was generated from the following files: