ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwClcon_v2.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
36
37
38#include "CaloSwClcon_v2.h"
40#include <cmath>
41
42
45
46
68 CaloCluster* cluster,
69 const CaloDetDescrElement* /*elt*/,
70 float eta,
71 float adj_eta,
72 float /*phi*/,
73 float /*adj_phi*/,
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
89 const CxxUtils::Array<2> correction = m_correction (myctx);
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 if (n_energies == 0) {
97 ATH_MSG_ERROR("Empty energies vector");
98 return;
99 }
100
101 for (unsigned int i=0; i<n_energies; i++) {
102 offstab[i][0] = energies[i];
103 offstab[i][1] = interpolate (correction,
104 the_aeta,
105 m_degree (myctx),
106 i+1);
107 }
108
109 // Find the median correction.
110 float energy = cluster->e() * offstab[n_energies/2][1];
111
112 // Now interpolate in energy.
113 float corr;
114 if (energy <= offstab[0][0])
115 corr = offstab[0][1];
116 else if (energy >= offstab[n_energies-1][0])
117 corr = offstab[n_energies-1][1];
118 else
119 corr = interpolate (offstab, energy, m_energy_degree (myctx));
120
121 // Do the correction
122 setenergy (cluster, corr * cluster->e());
123}
Scalar eta() const
pseudorapidity method
#define ATH_MSG_ERROR(x)
EM calorimeter containment correction.
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.
Constant< int > m_degree
Calibration constant: degree of the polynomial interpolation.
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< 2 > > m_correction
Calibration constant: tabulated arrays of function parameters.
Constant< CxxUtils::Array< 1 > > m_energies
Calibration constant: table of energies at which the correction was tabulated.
Constant< bool > m_use_raw_eta
Calibration constant: If true, tabulated values are in terms of raw (local) eta.
Constant< int > m_energy_degree
Calibration constant: degree of the polynomial interpolation in energy.
Constant< float > m_etamax
Calibration constant: maximum eta for which this correction is defined.
Read-only multidimensional array.
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
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.