ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwEtamod_v2.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
32
33
34#include "CaloSwEtamod_v2.h"
37#include <cmath>
38#include <stdexcept>
39
40
43using std::abs;
44
45
66void CaloSwEtamod_v2::makeTheCorrection (const Context& myctx,
67 CaloCluster* cluster,
68 const CaloDetDescrElement* elt,
69 float eta,
70 float adj_eta,
71 float /*phi*/,
72 float /*adj_phi*/,
74 const
75{
76 // Compute the eta offset within the cell.
77 float etamod = eta - elt->eta() + elt->deta()/2;
78 if (elt->eta_raw() < 0)
79 etamod = elt->deta() - etamod;
80
81 // These can happen due to DD bugs.
82 if (etamod < 0)
83 etamod = 0;
84 else if (etamod > elt->deta())
85 etamod = elt->deta();
86
87 float adj_aeta = std::abs (adj_eta);
88
89 // ??? In most of the calorimeter, the cells in sampling 2 have an eta
90 // width of 0.025. This correction was derived with this assumption.
91 // However, it's not completely accurate: in the gap region, some
92 // cells have a different size. For example, the last sampling 2
93 // cell in the barrel (starting at 1.4) has a width of 0.075.
94 // For this pass, fix up etamod to match what was used when
95 // the correction was derived. This should be cleaned up in
96 // a subsequent version.
97 if (adj_aeta >= 1.4 && adj_aeta <= 1.475)
98 etamod = std::fmod (adj_aeta, 0.025);
99
100 // Before doing the energy interpolation, make a crude total correction
101 // of the energy. This is needed since the corrections are tabulated
102 // using the true cluster energies.
103 float energy = cluster->e();
104 float rfac = interpolate (m_rfac(myctx), adj_aeta, m_rfac_degree(myctx));
105 energy /= rfac;
106
107 // Calculate the correction.
108 float corr = energy_interpolation (energy,
109 Builder (m_correction(myctx), etamod),
110 m_energies(myctx),
111 m_energy_degree(myctx));
112 if (corr == 0.)[[unlikely]]{
113 throw std::runtime_error("CaloSwEtamod_v2::makeTheCorrection: denominator 'corr' is zero");
114 }
115 // set energy, and rescale each sampling
116 setenergy (cluster, cluster->e() / corr);
117}
118
119
125CaloSwEtamod_v2::Builder::Builder (const CxxUtils::Array<2>& correction,
126 float etamod)
128 m_etamod (etamod)
129{
130}
131
132
139float CaloSwEtamod_v2::Builder::calculate (int energy_ndx, bool& good) const
140{
141 good = true;
142 return m_correction[energy_ndx][0]
143 + m_etamod*m_correction[energy_ndx][1]
144 + m_etamod*m_etamod*m_correction[energy_ndx][2];
145}
Scalar eta() const
pseudorapidity method
Definition of CaloDetDescrManager.
EM calorimeter modulation corrections.
Constant< CxxUtils::Array< 1 > > m_energies
Calibration constant: table of energies at which the correction was tabulated.
Constant< int > m_rfac_degree
Constant< int > m_energy_degree
Calibration constant: degree of the polynomial interpolation in energy.
Constant< CxxUtils::Array< 2 > > m_correction
Calibration constant: tabulated arrays of function parameters.
Constant< CxxUtils::Array< 2 > > m_rfac
Principal data class for CaloCell clusters.
virtual double e() const
Retrieve energy independent of signal state.
This class groups all DetDescr information related to a CaloCell.
Read-only multidimensional array.
Polynomial interpolation in a table.
float interpolate(const CaloRec::Array< 2 > &a, float x, unsigned int degree, unsigned int ycol=1, const CaloRec::Array< 1 > &regions=CaloRec::Array< 1 >(), int n_points=-1, bool fixZero=false)
Polynomial interpolation in a table.
etamod(flags, cells_name, *args, **kw)
rfac(flags, cells_name, *args, **kw)
correction(mu, runmode, campaign, run=None)
Definition zlumi_mc_cf.py:4
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
#define unlikely(x)