ATLAS Offline Software
CaloSwClcon_v2.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
38 #include "CaloSwClcon_v2.h"
40 #include <cmath>
41 
42 
43 using xAOD::CaloCluster;
45 
46 
68  CaloCluster* cluster,
69  const CaloDetDescrElement* /*elt*/,
70  float eta,
71  float adj_eta,
72  float /*phi*/,
73  float /*adj_phi*/,
74  CaloSampling::CaloSample /*samp*/)
75  const
76 {
77  // ??? In principle, we should use adj_eta for the interpolation
78  // and range checks. However, the v2 corrections were derived
79  // using regular eta instead.
80  float the_aeta;
81  if (m_use_raw_eta (myctx))
82  the_aeta = std::abs (adj_eta);
83  else
84  the_aeta = std::abs (eta);
85 
86  if (the_aeta >= m_etamax (myctx))
87  return;
88 
90  const CxxUtils::Array<1> energies = m_energies (myctx);
91 
92  // Calculate the correction for each energy.
93  unsigned int n_energies = energies.size();
94  unsigned int shape[] = {n_energies, 2};
95  CaloRec::WritableArrayData<2> offstab (shape);
96 
97  for (unsigned int i=0; i<n_energies; i++) {
98  offstab[i][0] = energies[i];
99  offstab[i][1] = interpolate (correction,
100  the_aeta,
101  m_degree (myctx),
102  i+1);
103  }
104 
105  // Find the median correction.
106  float energy = cluster->e() * offstab[n_energies/2][1];
107 
108  // Now interpolate in energy.
109  float corr;
110  if (energy <= offstab[0][0])
111  corr = offstab[0][1];
112  else if (energy >= offstab[n_energies-1][0])
113  corr = offstab[n_energies-1][1];
114  else
115  corr = interpolate (offstab, energy, m_energy_degree (myctx));
116 
117  // Do the correction
118  setenergy (cluster, corr * cluster->e());
119 }
CaloSwClcon_v2::m_etamax
Constant< float > m_etamax
Calibration constant: maximum eta for which this correction is defined.
Definition: CaloSwClcon_v2.h:109
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
CaloSwClcon_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: CaloSwClcon_v2.h:131
CxxUtils::Array::size
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloClusterCorrection::setenergy
virtual void setenergy(xAOD::CaloCluster *cluster, float energy) const
Definition: CaloClusterCorrection.cxx:94
CaloSwClcon_v2::m_degree
Constant< int > m_degree
Calibration constant: degree of the polynomial interpolation.
Definition: CaloSwClcon_v2.h:113
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
CaloSwClcon_v2.h
EM calorimeter containment correction.
tools.zlumi_mc_cf.correction
def correction(mu, runmode, campaign, run=None)
Definition: zlumi_mc_cf.py:4
CaloSwClcon_v2::m_energy_degree
Constant< int > m_energy_degree
Calibration constant: degree of the polynomial interpolation in energy.
Definition: CaloSwClcon_v2.h:126
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloSwClcon_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: CaloSwClcon_v2.cxx:67
CxxUtils::Array< 2 >
CxxUtils::WritableArrayData
Definition: Control/CxxUtils/CxxUtils/Array.h:778
CaloCluster
Principal data class for CaloCell clusters.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
CaloSwClcon_v2::m_energies
Constant< CxxUtils::Array< 1 > > m_energies
Calibration constant: table of energies at which the correction was tabulated.
Definition: CaloSwClcon_v2.h:122
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
CaloSwClcon_v2::m_correction
Constant< CxxUtils::Array< 2 > > m_correction
Calibration constant: tabulated arrays of function parameters.
Definition: CaloSwClcon_v2.h:117
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
interpolate.h
Polynomial interpolation in a table.