ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Calorimeter
CaloClusterCorrection
src
CaloSwEtaoff_v2.cxx
Go to the documentation of this file.
1
// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
/*
3
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4
*/
11
12
13
#include "
CaloSwEtaoff_v2.h
"
14
#include "
CaloClusterCorrection/interpolate.h
"
15
#include "
CaloDetDescr/CaloDetDescrManager.h
"
16
#include "
CaloGeoHelpers/CaloPhiRange.h
"
17
#include <cmath>
18
#include <cassert>
19
20
21
using
xAOD::CaloCluster
;
22
using
CaloClusterCorr::interpolate
;
23
24
45
void
CaloSwEtaoff_v2::makeTheCorrection
(
const
Context& myctx,
46
CaloCluster
* cluster,
47
const
CaloDetDescrElement
* elt,
48
float
eta
,
49
float
adj_eta,
50
float
/*phi*/
,
51
float
/*adj_phi*/
,
52
CaloSampling::CaloSample
samp)
const
53
{
54
const
CxxUtils::Array<3>
correction =
m_correction
(myctx);
55
const
CxxUtils::Array<1>
interp_barriers =
m_interp_barriers
(myctx);
56
const
CxxUtils::Array<1>
energies =
m_energies
(myctx);
57
const
int
degree =
m_degree
(myctx);
58
const
int
energy_degree =
m_energy_degree
(myctx);
59
60
// Find u, the normalized displacement of the cluster within the cell.
61
// In the range -1...1, with 0 at the center.
62
float
u = (
eta
- elt->
eta
()) / elt->
deta
() * 2;
63
if
(elt->
eta_raw
() < 0)
64
u = -u;
65
66
// u can sometimes be outside of the prescribed range, due to DD bugs.
67
if
(u > 1)
68
u = 1;
69
else
if
(u < -1)
70
u = -1;
71
72
// For each energy, interpolate in eta.
73
// We can't use the common energy_interpolation code here,
74
// because we're interpolating the fit parameters, not the overall
75
// correction. This should probably be done differently in the
76
// next version.
77
unsigned
int
n_energies = energies.
size
();
78
unsigned
int
shape[] = {n_energies, 4};
79
CaloRec::WritableArrayData<2>
partab (shape);
80
if
(n_energies == 0) {
81
ATH_MSG_ERROR
(
"Empty energies vector"
);
82
return
;
83
}
84
85
// If we're outside the range of the table, we'll just be using the
86
// value at the end (no extrapolation). We only need to calculate
87
// that one point in that case.
88
int
beg = 0;
89
int
end = n_energies;
90
float
energy = cluster->
e
();
91
if
(energy <= energies[0])
92
end = 1;
93
else
if
(energy >= energies[n_energies-1])
94
beg = n_energies-1;
95
96
for
(
int
i=beg; i<end; i++) {
97
partab[i][0] = energies[i];
98
for
(
int
j=0; j < 3; j++)
99
partab[i][j+1] = interpolate (correction[i],
100
std::abs (adj_eta),
101
degree,
102
j+1,
103
interp_barriers);
104
}
105
106
// Now interpolate in energy.
107
// But if we're outside of the range of the table, just use the value
108
// at the end (don't extrapolate).
109
float
par[3];
110
for
(
int
i=0; i < 3; i++) {
111
if
(end-beg > 1)
112
par[i] = interpolate (partab, energy, energy_degree, i+1);
113
else
114
par[i] = partab[beg][i+1];
115
}
116
117
// Calculate the fit function.
118
// Don't allow b to go all the way to zero; we get a division
119
// by zero there.
120
double
b = std::max ((
double
)par[1], 1e-5);
121
double
atanb = std::atan(b);
122
double
sq
= std::sqrt (b/atanb - 1);
123
double
den = (
sq
/b*atanb - std::atan(
sq
));
124
float
offs = par[0]* ((- std::atan (b*u) + u*atanb) / den +
125
par[2]*(1-std::abs(u)));
126
127
// Apply the offset correction to the cluster.
128
if
(
eta
< 0)
129
offs = -offs;
130
cluster->
setEta
(samp,
eta
+ offs);
131
}
eta
Scalar eta() const
pseudorapidity method
Definition
AmgMatrixBasePlugin.h:83
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
CaloPhiRange.h
CaloPhiRange class declaration.
m_energies
Constant< CxxUtils::Array< 1 > > m_energies
Calibration constant: table of energies at which the correction was tabulated.
Definition
CaloSwEtamod_v2.h:157
m_energy_degree
Constant< int > m_energy_degree
Calibration constant: degree of the polynomial interpolation in energy.
Definition
CaloSwEtamod_v2.h:161
m_correction
Constant< CxxUtils::Array< 2 > > m_correction
Calibration constant: tabulated arrays of function parameters.
Definition
CaloSwEtamod_v2.h:142
CaloSwEtaoff_v2.h
EM calorimeter eta offset (S-shape) corrections.
sq
#define sq(x)
Definition
CurvedSegmentFinder.cxx:6
CaloCluster
Principal data class for CaloCell clusters.
Definition
Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
CaloCluster::e
virtual double e() const
Retrieve energy independent of signal state.
Definition
Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:753
CaloCluster::setEta
virtual void setEta(double eta)
Set eta.
Definition
Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:769
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell.
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloDetDescrElement::eta_raw
float eta_raw() const
cell eta_raw
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:350
CaloDetDescrElement::eta
float eta() const
cell eta
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloDetDescrElement::deta
float deta() const
cell deta
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:356
CaloSampling::CaloSample
CaloSample
Definition
Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloSwEtaoff_v2::m_interp_barriers
Constant< CxxUtils::Array< 1 > > m_interp_barriers
Calibration constant: allow breaking up the interpolation into independent regions.
Definition
CaloSwEtaoff_v2.h:115
CaloSwEtaoff_v2::m_degree
Constant< int > m_degree
Calibration constant: degree of the polynomial interpolation.
Definition
CaloSwEtaoff_v2.h:119
CaloSwEtaoff_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
CaloSwEtaoff_v2.cxx:45
CxxUtils::Array
Read-only multidimensional array.
Definition
Control/CxxUtils/CxxUtils/Array.h:135
CxxUtils::Array::size
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
CxxUtils::WritableArrayData
Definition
Control/CxxUtils/CxxUtils/Array.h:775
interpolate.h
Polynomial interpolation in a table.
CaloClusterCorr::interpolate
float interpolate(const CaloRec::Array< 2 > &a, float x, unsigned int degree, unsigned int ycol=1, const CaloRec::Array< 1 > ®ions=CaloRec::Array< 1 >(), int n_points=-1, bool fixZero=false)
Polynomial interpolation in a table.
Definition
interpolate.cxx:74
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
Generated on
for ATLAS Offline Software by
1.17.0