ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwPhimod_v2.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 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
39
42using CLHEP::pi;
43using std::atan;
44using std::abs;
45using std::cos;
46
47
48
70 CaloCluster* cluster,
71 const CaloDetDescrElement* /*elt*/,
72 float eta,
73 float adj_eta,
74 float /*phi*/,
75 float adj_phi,
77 const
78{
79 // ??? In principle, we should use adj_eta for the interpolation
80 // and range checks. However, the v2 corrections were derived
81 // using regular eta instead.
82 float the_aeta;
83 if (m_use_raw_eta(myctx)) {
84 the_aeta = std::abs (adj_eta);
85 if (adj_eta < 0)
86 adj_phi = -adj_phi;
87 }
88 else {
89 the_aeta = std::abs (eta);
90 if (eta < 0)
91 adj_phi = -adj_phi;
92 }
93
94 // Number of absorbers.
95 // It would be better to be able to get this from the detector description,
96 // but i can't find these numbers there.
97 int nabs;
98 if (the_aeta < 1.5)
99 nabs = 1024;
100 else if (the_aeta < 2.5)
101 nabs = 768;
102 else
103 nabs = 256;
104
105 // Before doing the energy interpolation, make a crude total correction
106 // of the energy. This is needed since the corrections are tabulated
107 // using the true cluster energies.
108 float energy = cluster->e();
109 float rfac = interpolate (m_rfac(myctx), the_aeta, m_rfac_degree(myctx));
110 energy /= rfac;
111
112 float corr = energy_interpolation (energy,
113 Builder (m_correction (myctx),
114 m_interp_barriers (myctx),
115 m_degree (myctx),
116 m_correction_coef (myctx),
117 the_aeta, adj_phi, nabs),
118 m_energies(myctx),
119 m_energy_degree(myctx));
120
121 // set energy, and rescale each sampling
122 setenergy (cluster, cluster->e() / corr);
123}
124
125
139 const CxxUtils::Array<1>& interp_barriers,
140 int degree,
141 float correction_coef,
142 float aeta,
143 float phi,
144 int nabs)
145 : m_correction (correction),
146 m_interp_barriers (interp_barriers),
147 m_degree (degree),
148 m_correction_coef (correction_coef),
149 m_aeta (aeta),
150 m_phi (phi),
151 m_nabs (nabs)
152{
153}
154
155
162float CaloSwPhimod_v2::Builder::calculate (int energy_ndx, bool& good) const
163{
164 good = true;
165 float par[4];
166 for (int j=0; j<4; j++) {
167 par[j] = interpolate (m_correction[energy_ndx],
168 m_aeta,
169 m_degree,
170 j+1,
172 }
173 double a = atan (par[2])*(1./pi) + 0.5;
174 return 1 + m_correction_coef * abs (par[0]) *
175 (a*cos(m_nabs*m_phi + par[1]) +
176 (1-a)*cos (2*m_nabs*m_phi + par[3]));
177}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Definition of CaloDetDescrManager.
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.
Constant< int > m_energy_degree
Calibration constant: degree of the polynomial interpolation in energy.
Constant< int > m_rfac_degree
Constant< CxxUtils::Array< 2 > > m_rfac
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< 1 > > m_energies
Calibration constant: table of energies at which the correction was tabulated.
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.