ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwPhimod_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#include "CaloSwPhimod_v2.h"
36#include "CLHEP/Units/PhysicalConstants.h" // for pi
37#include <cmath>
38#include <numbers>
39
40
43using std::numbers::pi;
44using std::atan;
45using std::abs;
46using std::cos;
47
48
49
70void CaloSwPhimod_v2::makeTheCorrection (const Context& myctx,
71 CaloCluster* cluster,
72 const CaloDetDescrElement* /*elt*/,
73 float eta,
74 float adj_eta,
75 float /*phi*/,
76 float adj_phi,
78 const
79{
80 // ??? In principle, we should use adj_eta for the interpolation
81 // and range checks. However, the v2 corrections were derived
82 // using regular eta instead.
83 float the_aeta;
84 if (m_use_raw_eta(myctx)) {
85 the_aeta = std::abs (adj_eta);
86 if (adj_eta < 0)
87 adj_phi = -adj_phi;
88 }
89 else {
90 the_aeta = std::abs (eta);
91 if (eta < 0)
92 adj_phi = -adj_phi;
93 }
94
95 // Number of absorbers.
96 // It would be better to be able to get this from the detector description,
97 // but i can't find these numbers there.
98 int nabs;
99 if (the_aeta < 1.5)
100 nabs = 1024;
101 else if (the_aeta < 2.5)
102 nabs = 768;
103 else
104 nabs = 256;
105
106 // Before doing the energy interpolation, make a crude total correction
107 // of the energy. This is needed since the corrections are tabulated
108 // using the true cluster energies.
109 float energy = cluster->e();
110 float rfac = interpolate (m_rfac(myctx), the_aeta, m_rfac_degree(myctx));
111 energy /= rfac;
112
113 float corr = energy_interpolation (energy,
114 Builder (m_correction (myctx),
115 m_interp_barriers (myctx),
116 m_degree (myctx),
117 m_correction_coef (myctx),
118 the_aeta, adj_phi, nabs),
119 m_energies(myctx),
120 m_energy_degree(myctx));
121 if (corr == 0.) [[unlikely]]{
122 throw std::runtime_error("CaloSwPhimod_v2::makeTheCorrection: denominator 'corr' is zero.");
123 }
124 // set energy, and rescale each sampling
125 setenergy (cluster, cluster->e() / corr);
126}
127
128
142 const CxxUtils::Array<1>& interp_barriers,
143 int degree,
144 float correction_coef,
145 float aeta,
146 float phi,
147 int nabs)
148 : m_correction (correction),
149 m_interp_barriers (interp_barriers),
150 m_degree (degree),
151 m_correction_coef (correction_coef),
152 m_aeta (aeta),
153 m_phi (phi),
154 m_nabs (nabs)
155{
156}
157
158
165float CaloSwPhimod_v2::Builder::calculate (int energy_ndx, bool& good) const
166{
167 good = true;
168 float par[4];
169 for (int j=0; j<4; j++) {
170 par[j] = interpolate (m_correction[energy_ndx],
171 m_aeta,
172 m_degree,
173 j+1,
175 }
176 double a = atan (par[2])*(1./pi) + 0.5;
177 return 1 + m_correction_coef * abs (par[0]) *
178 (a*cos(m_nabs*m_phi + par[1]) +
179 (1-a)*cos (2*m_nabs*m_phi + par[3]));
180}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Definition of CaloDetDescrManager.
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_rfac
EM calorimeter phi modulation corrections.
static Double_t a
#define pi
static float energy_interpolation(float energy, const TableBuilder &builder, const CaloRec::Array< 1 > &energies, int energy_degree)
Many of the corrections use the same method for doing the final interpolation in energy.
virtual void setenergy(xAOD::CaloCluster *cluster, float energy) const
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.
float m_aeta
The abs(eta) at which the correction is being evaluated (in cal-local coordinates).
Builder(const CxxUtils::Array< 3 > &correction, const CxxUtils::Array< 1 > &interp_barriers, int degree, float correction_coef, float aeta, float phi, int nabs)
Constructor.
const CxxUtils::Array< 1 > m_interp_barriers
Allow breaking up the interpolation into independent regions.
int m_nabs
Number of absorbers in .
int m_degree
Interpolation degree.
float m_correction_coef
Coefficient by which to scale the entire correction.
float m_phi
The cluster phi.
virtual float calculate(int energy_ndx, bool &good) const
Calculate the correction for tabulated energy ENERGY_NDX.
const CxxUtils::Array< 3 > m_correction
The correction table.
virtual void makeTheCorrection(const Context &myctx, xAOD::CaloCluster *cluster, const CaloDetDescrElement *elt, float eta, float adj_eta, float phi, float adj_phi, CaloSampling::CaloSample samp) const override
Virtual function for the correction-specific code.
Constant< CxxUtils::Array< 3 > > m_correction
Calibration constant: tabulated arrays of function parameters.
Constant< int > m_degree
Calibration constant: degree of the polynomial interpolation.
Constant< bool > m_use_raw_eta
Calibration constant: If true, tabulated values are in terms of raw (local) eta.
Constant< float > m_correction_coef
Calibration constant: coefficient by which to scale the entire correction.
Constant< CxxUtils::Array< 1 > > m_interp_barriers
Calibration constant: allow breaking up the interpolation into independent regions.
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.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
#define unlikely(x)