ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwDeadOTX_ps.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: CaloSwDeadOTX_ps.cxx
8PACKAGE: offline/Calorimeter/CaloSwCalibHitsCalibration
9
10AUTHORS: L. Carminati
11CREATED: March 26, 2010
12
13PURPOSE: Apply specif calibration for the energy lost in front
14 when the PS is missing
15 Calibration constants derived by D. Banfi
16 base class: CaloClusterCorrectionCommon
17 Uses ToolWithConstants to get correction constants
18
19********************************************************************/
20
21#include "CaloSwDeadOTX_ps.h"
22#include "CLHEP/Units/SystemOfUnits.h"
23
25using CLHEP::TeV;
26
27
29{
31
32 // Need the explicit std::string here to avoid matching
33 // the template in AlgTool.
34 // CHECK( setProperty ("isDummy", std::string("1")) );
35
36 ATH_CHECK(m_affKey.initialize());
37
38 ATH_MSG_DEBUG( " --------------->>>>> CaloSwDeadOTX_ps :: retrieving affectedTool" << endmsg);
39
40 if (m_affectedTool.retrieve().isFailure()){
41 ATH_MSG_DEBUG( " --------------->>>>> CaloSwDeadOTX_ps :: failure retrieving affectedTool !! " << endmsg);
42 return StatusCode::FAILURE;
43 }
44
45 ATH_MSG_DEBUG( " --------------->>>>> CaloSwDeadOTX_ps :: affectedTool successfully retrieved" << endmsg);
46
47 return StatusCode::SUCCESS;
48}
49
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// ??? In principle, we should use adj_eta for the interpolation
61// and range checks. However, the v2 corrections were derived
62// using regular eta instead.
63
64 //Get affected info for this event
66 const CaloAffectedRegionInfoVec* affCont=*affHdl;
67 if(!affCont) {
68 ATH_MSG_WARNING("Do not have affected regions info, is this expected ?");
69 }
70
71 float the_aeta;
72 if (m_use_raw_eta(myctx))
73 the_aeta = std::abs (adj_eta);
74 else
75 the_aeta = std::abs (eta);
76
77 const float etamax = m_etamax (myctx);
78 if (the_aeta >= etamax) return;
79
80 int si;
81 if (the_aeta < m_eta_start_crack(myctx))
82 si = 0;
83 else if (the_aeta > m_eta_end_crack(myctx))
84 si = 1;
85 else {
86 // No corrections are applied for the crack region.
87 return;
88 }
89
90 const CxxUtils::Array<3> correction = m_correction (myctx);
91
92 ATH_MSG_DEBUG( "************************************************************************************************" << endmsg);
93 ATH_MSG_DEBUG( " USING CALIBHITS CALIBRATION : apply correction for dead OTX in the presampler" << endmsg);
94 ATH_MSG_DEBUG( " Tool Name " << name() << endmsg);
95 ATH_MSG_DEBUG( "************************************************************************************************" << endmsg);
96
97// -------------------------------------------------------------
98// check if the cluster is in an affected region
99// -------------------------------------------------------------
100
101 static const CaloSampling::CaloSample samps[2][4] = {
102 { CaloSampling::PreSamplerB,
103 CaloSampling::EMB1,
104 CaloSampling::EMB2,
105 CaloSampling::EMB3 },
106 { CaloSampling::PreSamplerE,
107 CaloSampling::EME1,
108 CaloSampling::EME2,
109 CaloSampling::EME3 }
110 };
111
112// Keep memory of the energy in front from the standard correction
113
114 float enePSold = cluster->eSample (samps[si][0]) ;
115
116
117// Set the safety margin around the dead region
118 float deta = 0.025;
119 float dphi = 0.025;
120
121 int layer = si * 4 ;
122 bool check = m_affectedTool->isAffected(cluster, affCont, deta , dphi ,layer,layer,0) ; // check dead OTX in barrel PS
123
124
125// if a cluster is in an affected region set the PS energy to zero else return
126
127 if (check) {
128 ATH_MSG_DEBUG( "The cluster is in an affected region, apply corrections" << endmsg);
129 cluster->setEnergy (samps[si][0], 0 );
130 } else {
131 ATH_MSG_DEBUG( "The cluster is NOT in an affected region, skip correction" << endmsg);
132 return;
133 }
134
135// -------------------------------------------------------------
136// If the cluster is in an affected region load the corrections
137// -------------------------------------------------------------
138
139// Determine the eta bin for the correction
140 int ibin = (static_cast<int> (the_aeta / etamax * 100)) ;
141
142// Load the correction coefficients
143 CaloRec::Array<1> froffset = correction[0][ibin];
144 CaloRec::Array<1> frslope = correction[1][ibin];
145 CaloRec::Array<1> sec = correction[2][ibin];
146
147// -------------------------------------------------------------
148// Compute longitudinal barycenter: this is a very old and approximate
149// parametrization that needs to be updated.
150// -------------------------------------------------------------
151
152 double raw_energy =0;
153 double shower_lbary_raw =0;
154 for (int nl = 0 ; nl< 4 ; nl++){
155 raw_energy += cluster->eSample (samps[si][nl]);
156 shower_lbary_raw += (m_sampling_depth(myctx)[ibin][nl+1] * cluster->eSample (samps[si][nl])) ;
157 }
158
159 if (raw_energy == 0) return;
160 double shower_lbary = shower_lbary_raw / raw_energy;
161
162 ATH_MSG_DEBUG( "Shower longitudinal barycenter ---->> " << shower_lbary << endmsg);
163
164 double depth_max = 20. + raw_energy*(3./TeV);
165
166 if ( shower_lbary > depth_max || shower_lbary<0.) {
167 shower_lbary = 15.;
168 ATH_MSG_DEBUG( " replace pathological depth by 15 X0 "
169 << endmsg);
170 }
171
172 raw_energy = raw_energy * 1e-3;
173
174// -------------------------------------------------------------
175// Estimate the total energy lost in front of the accordion using the
176// longitudinal barycenter
177// -------------------------------------------------------------
178
179 double p1 = froffset[1] + froffset[2] * raw_energy + froffset[3] * raw_energy * raw_energy ;
180 double p2 = frslope[1] + frslope[2] * raw_energy + frslope[3] * raw_energy * raw_energy ;
181 double p3 = sec[1] + sec[2] * raw_energy + sec[3] * raw_energy * raw_energy ;
182
183 ATH_MSG_DEBUG( "p1 " << froffset[1] << " " << froffset[2] << " " << froffset[3] << endmsg);
184 ATH_MSG_DEBUG( "p2 " << frslope[1] << " " << frslope[2] << " " << frslope[3] << endmsg);
185 ATH_MSG_DEBUG( "p3 " << sec[1] << " " << sec[2] << " " << sec[3] << endmsg);
186
187 double e_front_reco= (p1 + p2 * shower_lbary + p3 * shower_lbary * shower_lbary);
188
189// If something goes wrong keep the old energy
190 if (e_front_reco<0.) {
191 e_front_reco= enePSold;
192 ATH_MSG_DEBUG( "CaloSwDeadOTX_ps:: new E front is negative, no correction!" << endmsg);
193 }
194// -------------------------------------------------------------
195// Now set the energies of the cluster
196// -------------------------------------------------------------
197
198// set the energy of the presampler
199 cluster->setEnergy (samps[si][0], e_front_reco );
200
201// take the cluster energy, subtract the old PS energy and add the new one
202
203 ATH_MSG_DEBUG( "CaloSwDeadOTX_ps:: cluster energy before correction --> " << cluster->e() << endmsg);
204 ATH_MSG_DEBUG( "CaloSwDeadOTX_ps:: subtracting PS energy --> " << enePSold << endmsg);
205 ATH_MSG_DEBUG( "CaloSwDeadOTX_ps:: adding new PS energy -->> " << e_front_reco << endmsg);
206
207 float e_temp = cluster->e() - enePSold + e_front_reco ;
208
209// set the energy of the cluster
210 cluster->setE (e_temp);
211
212 ATH_MSG_DEBUG( "CaloSwDeadOTX_ps::Energy after correction --> " << cluster->e() << endmsg);
213
214}
215
Scalar eta() const
pseudorapidity method
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
std::vector< CaloAffectedRegionInfo > CaloAffectedRegionInfoVec
#define CHECK(...)
Evaluate an expression and check for errors.
virtual StatusCode initialize() override
Initialize 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< float > m_eta_start_crack
Constant< float > m_eta_end_crack
SG::ReadCondHandleKey< CaloAffectedRegionInfoVec > m_affKey
Constant< CxxUtils::Array< 2 > > m_sampling_depth
ToolHandle< ICaloAffectedTool > m_affectedTool
Constant< bool > m_use_raw_eta
virtual StatusCode initialize() override
Initialize method.
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< CxxUtils::Array< 3 > > m_correction
Read-only multidimensional array.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
const EventContext & ctx() const