ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
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. More...
 
void cell (const CaloCell *cell, double weight)
 Accumulate results for another cell. More...
 
 ~Helper ()
 Calculate the layer variables from the accumulated cells The variables in the parent CaloLayerCalculator instance (passed to the constructor) are updated. More...
 

Public Attributes

CaloLayerCalculatorm_calc
 These members hold the values passed to the constructor. More...
 
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. More...
 
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 }

◆ ~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;
264 
265 
268 
269  // In the calorimeter frame
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  {
282  }
283  }
284  else {
285  //reset();//replaced by:
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 }

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:
CaloLayerCalculator::Helper::m_s01r
double m_s01r
Definition: CaloLayerCalculator.h:345
CaloLayerCalculator::Helper::m_calc
CaloLayerCalculator & m_calc
These members hold the values passed to the constructor.
Definition: CaloLayerCalculator.h:327
CaloLayerCalculator::m_phim
double m_phim
Definition: CaloLayerCalculator.h:259
ReadCellNoiseFromCoolCompare.s1
s1
Definition: ReadCellNoiseFromCoolCompare.py:378
CaloLayerCalculator::resetOnNegativeEnergy
void resetOnNegativeEnergy()
Reset output variables, but not m_em, allowing samplings to be negative.
Definition: CaloLayerCalculator.cxx:98
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
CaloLayerCalculator::Helper::m_dphi
double m_dphi
Definition: CaloLayerCalculator.h:331
CaloLayerCalculator::Helper::m_s10r
double m_s10r
Definition: CaloLayerCalculator.h:344
CaloLayerCalculator::Helper::cell
void cell(const CaloCell *cell, double weight)
Accumulate results for another cell.
Definition: CaloLayerCalculator.cxx:190
CaloLayerCalculator::Helper::m_cell_container
const CaloCellContainer * m_cell_container
Definition: CaloLayerCalculator.h:334
CaloLayerCalculator::Helper::m_tofill
xAOD::CaloCluster * m_tofill
Definition: CaloLayerCalculator.h:333
CaloLayerCalculator::m_etas
double m_etas
Definition: CaloLayerCalculator.h:260
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
CaloLayerCalculator::Helper::m_s01
double m_s01
Definition: CaloLayerCalculator.h:340
CaloLayerCalculator::m_etamax
double m_etamax
Definition: CaloLayerCalculator.h:263
CaloLayerCalculator::m_phis
double m_phis
Definition: CaloLayerCalculator.h:261
CaloLayerCalculator::m_etamr
double m_etamr
Definition: CaloLayerCalculator.h:268
CaloLayerCalculator::m_phimax
double m_phimax
Definition: CaloLayerCalculator.h:264
CaloLayerCalculator::Helper::m_phi
double m_phi
Definition: CaloLayerCalculator.h:329
CaloLayerCalculator::m_em
double m_em
Definition: CaloLayerCalculator.h:262
CaloLayerCalculator::m_etarmax
double m_etarmax
Definition: CaloLayerCalculator.h:270
CaloLayerCalculator::Helper::m_s02
double m_s02
Definition: CaloLayerCalculator.h:341
CaloPhiRange::fix
static double fix(double phi)
Definition: CaloPhiRange.cxx:14
CaloLayerCalculator::Helper::m_deta
double m_deta
Definition: CaloLayerCalculator.h:330
CaloLayerCalculator::Helper::m_s20
double m_s20
Definition: CaloLayerCalculator.h:339
CaloLayerCalculator::Helper::m_sampling
CaloSampling::CaloSample m_sampling
Definition: CaloLayerCalculator.h:332
CaloLayerCalculator::m_phirmax
double m_phirmax
Definition: CaloLayerCalculator.h:271
CaloLayerCalculator::m_etam
double m_etam
Layer variables.
Definition: CaloLayerCalculator.h:258
CaloLayerCalculator::Helper::m_s10
double m_s10
Definition: CaloLayerCalculator.h:338
CaloLayerCalculator::m_emax
double m_emax
Definition: CaloLayerCalculator.h:265
xAOD::CaloCluster_v1::addCell
bool addCell(const unsigned index, const double weight)
Method to add a cell to the cluster (Beware: Kinematics not updated!)
Definition: CaloCluster_v1.h:771
CaloCellContainer::findIndex
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
Definition: CaloCellContainer.cxx:363
CaloLayerCalculator::Helper::m_s00
double m_s00
Temporary variables used to accumulate the results.
Definition: CaloLayerCalculator.h:337
CaloLayerCalculator::Helper::m_eta
double m_eta
Definition: CaloLayerCalculator.h:328
CaloLayerCalculator::m_phimr
double m_phimr
Definition: CaloLayerCalculator.h:269
beamspotnt.calc
calc
Definition: bin/beamspotnt.py:1252
CaloPhiRange::diff
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
Definition: CaloPhiRange.cxx:22