ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwLongWeights.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5/********************************************************************
6
7NAME: CaloSwLongWeights.cxx
8PACKAGE: offline/Calorimter/CaloSwLongWeights
9
10AUTHORS: K.Loureiro, S.Paganis
11CREATED: July 5, 2004
12
13PURPOSE: Optimization correction for the weights in the
14 different layers of the EM calorimeter.
15 The weights are tuned on electrons at
16 20,50,100 and 150 GeV, from -2.5 <eta < 2.5
17 with fixed vertex
18 base class: CaloClusterCorrectionCommon
19 Uses ToolWithConstants to get corrections constants
20
21********************************************************************/
22#include "CaloSwLongWeights.h"
24
25
28
29
51 (const Context& myctx,
52 CaloCluster* cluster,
53 const CaloDetDescrElement* /*elt*/,
54 float eta,
55 float adj_eta,
56 float /*phi*/,
57 float /*adj_phi*/,
58 CaloSampling::CaloSample /*samp*/) const
59{
60 const float eta_start_crack = m_eta_start_crack (myctx);
61 const float eta_end_crack = m_eta_end_crack (myctx);
62
63 // ??? In principle, we should use adj_eta for the interpolation
64 // and range checks. However, the v2 corrections were derived
65 // using regular eta instead.
66 float the_aeta;
67 if (m_use_raw_eta(myctx))
68 the_aeta = std::abs (adj_eta);
69 else
70 the_aeta = std::abs (eta);
71
72 const float etamax = m_etamax (myctx);
73 if (the_aeta >= etamax) return;
74
75 int si;
76 if (the_aeta < eta_start_crack)
77 si = 0;
78 else if (the_aeta > eta_end_crack)
79 si = 1;
80 else {
81 // No corrections are applied for the crack region.
82 return;
83 }
84
85 const CxxUtils::Array<2> correction = m_correction (myctx);
86 const int degree = m_degree (myctx);
87
88 unsigned int shape[] = {2};
89 CaloRec::WritableArrayData<1> interp_barriers (shape);
90 interp_barriers[0] = eta_start_crack;
91 interp_barriers[1] = eta_end_crack;
92
93 float pars[4];
94 int ibin = static_cast<int> (the_aeta / etamax * correction.size());
95 pars[0] = correction[ibin][1];
96 pars[1] = correction[ibin][2];
97 for (int i=2; i<4; i++)
98 pars[i] = interpolate (correction,
99 the_aeta,
100 degree,
101 i+1,
102 interp_barriers);
103
104 static const
105 CaloSampling::CaloSample samps[2][4] = {
106 { CaloSampling::PreSamplerB,
107 CaloSampling::EMB1,
108 CaloSampling::EMB2,
109 CaloSampling::EMB3 },
110 { CaloSampling::PreSamplerE,
111 CaloSampling::EME1,
112 CaloSampling::EME2,
113 CaloSampling::EME3 }
114 };
115
116 float e_offset = 0;
117 if (m_preserve_offset(myctx)) {
118 double total0 = 0;
119 for (int sampling=0; sampling<4; ++sampling)
120 total0 += cluster->eSample (samps[si][sampling]);
121 e_offset = cluster->e() - total0;
122 }
123
124 cluster->setEnergy (samps[si][0], cluster->eSample (samps[si][0]) * pars[0]);
125 cluster->setEnergy (samps[si][3], cluster->eSample (samps[si][3]) * pars[1]);
126
127 double total = e_offset;
128 for (int sampling=0; sampling<4; ++sampling)
129 total += cluster->eSample (samps[si][sampling]);
130
131 cluster->setE (pars[2] * (pars[3] + total));
132}
133
134
Scalar eta() const
pseudorapidity method
Principal data class for CaloCell clusters.
double eSample(sampling_type sampling) const
Retrieve energy in a given sampling.
virtual double e() const
Retrieve energy independent of signal state.
virtual void setE(double e)
Set energy.
This class groups all DetDescr information related to a CaloCell.
Constant< int > m_degree
Constant< float > m_etamax
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< bool > m_use_raw_eta
Constant< float > m_eta_end_crack
Constant< float > m_eta_start_crack
Constant< bool > m_preserve_offset
Constant< CxxUtils::Array< 2 > > m_correction
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.