ATLAS Offline Software
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 */
33 #include "CaloSwPhimod_v2.h"
36 #include "CLHEP/Units/PhysicalConstants.h" // for pi
37 #include <cmath>
38 
39 
40 using xAOD::CaloCluster;
42 using CLHEP::pi;
43 using std::atan;
44 using std::abs;
45 using 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,
76  CaloSampling::CaloSample /*samp*/)
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 
162 float 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 }
CaloSwPhimod_v2::Builder
Helper class for calculating the energy interpolation table.
Definition: CaloSwPhimod_v2.h:132
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloSwPhimod_v2::Builder::calculate
virtual float calculate(int energy_ndx, bool &good) const
Calculate the correction for tabulated energy ENERGY_NDX.
Definition: CaloSwPhimod_v2.cxx:162
CaloClusterCorrection::setenergy
virtual void setenergy(xAOD::CaloCluster *cluster, float energy) const
Definition: CaloClusterCorrection.cxx:94
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
pi
#define pi
Definition: TileMuonFitter.cxx:65
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
CaloSwPhimod_v2::m_interp_barriers
Constant< CxxUtils::Array< 1 > > m_interp_barriers
Calibration constant: allow breaking up the interpolation into independent regions.
Definition: CaloSwPhimod_v2.h:178
tools.zlumi_mc_cf.correction
def correction(mu, runmode, campaign, run=None)
Definition: zlumi_mc_cf.py:4
CaloSwCorrections.rfac
def rfac(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:182
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CxxUtils::Array< 3 >
CaloCluster
Principal data class for CaloCell clusters.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
CaloSwPhimod_v2::m_rfac_degree
Constant< int > m_rfac_degree
Definition: CaloSwPhimod_v2.h:197
CaloSwPhimod_v2::m_rfac
Constant< CxxUtils::Array< 2 > > m_rfac
Definition: CaloSwPhimod_v2.h:192
CaloSwPhimod_v2::m_energy_degree
Constant< int > m_energy_degree
Calibration constant: degree of the polynomial interpolation in energy.
Definition: CaloSwPhimod_v2.h:206
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
ReadBchFromCool.good
good
Definition: ReadBchFromCool.py:433
a
TList * a
Definition: liststreamerinfos.cxx:10
CaloClusterCorrectionCommon::energy_interpolation
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.
Definition: CaloClusterCorrectionCommon.cxx:575
CaloSwPhimod_v2::m_use_raw_eta
Constant< bool > m_use_raw_eta
Calibration constant: If true, tabulated values are in terms of raw (local) eta.
Definition: CaloSwPhimod_v2.h:211
CaloClusterCorr::interpolate
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.
Definition: interpolate.cxx:75
CaloSwPhimod_v2::m_energies
Constant< CxxUtils::Array< 1 > > m_energies
Calibration constant: table of energies at which the correction was tabulated.
Definition: CaloSwPhimod_v2.h:202
CaloCluster::e
virtual double e() const
Retrieve energy independent of signal state.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:753
CaloUtils::ToolConstantsContext
Context object for retrieving ToolConstant values.
Definition: ToolWithConstants.h:61
CaloSwPhimod_v2::Builder::Builder
Builder(const CxxUtils::Array< 3 > &correction, const CxxUtils::Array< 1 > &interp_barriers, int degree, float correction_coef, float aeta, float phi, int nabs)
Constructor.
Definition: CaloSwPhimod_v2.cxx:138
CaloSwPhimod_v2::m_degree
Constant< int > m_degree
Calibration constant: degree of the polynomial interpolation.
Definition: CaloSwPhimod_v2.h:182
interpolate.h
Polynomial interpolation in a table.
CaloSwPhimod_v2::m_correction
Constant< CxxUtils::Array< 3 > > m_correction
Calibration constant: tabulated arrays of function parameters.
Definition: CaloSwPhimod_v2.h:173
CaloSwPhimod_v2::makeTheCorrection
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.
Definition: CaloSwPhimod_v2.cxx:69
CaloSwPhimod_v2.h
EM calorimeter phi modulation corrections.
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106
CaloSwPhimod_v2::m_correction_coef
Constant< float > m_correction_coef
Calibration constant: coefficient by which to scale the entire correction.
Definition: CaloSwPhimod_v2.h:187