ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwDeadOTX_back.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_back.cxx
8PACKAGE: offline/Calorimeter/CaloSwCalibHitsCalibration
9
10AUTHORS: L. Carminati
11CREATED: March 26, 2010
12
13PURPOSE: Apply specif calibration for the energy in the back
14 compartment and longitudinal leakage when there's a
15 dead OTX
16 Calibration constants derived by D. Banfi
17 base class: CaloClusterCorrectionCommon
18 Uses ToolWithConstants to get correction constants
19
20********************************************************************/
21
22#include "CaloSwDeadOTX_back.h"
23#include "CLHEP/Units/SystemOfUnits.h"
24
26using CLHEP::TeV;
27
28
30{
32
33 // Need the explicit std::string here to avoid matching
34 // the template in AlgTool.
35 // CHECK( setProperty ("isDummy", std::string("1")) );
36
37 ATH_CHECK(m_affKey.initialize());
38
39 ATH_MSG_DEBUG( " --------------->>>>> CaloSwDeadOTX_back :: retrieving affectedTool" << endmsg);
40
41 if (m_affectedTool.retrieve().isFailure()){
42 ATH_MSG_DEBUG( " --------------->>>>> CaloSwDeadOTX_back :: failure retrieving affectedTool !! " << endmsg);
43 return StatusCode::FAILURE;
44 }
45
46 ATH_MSG_DEBUG( " --------------->>>>> CaloSwDeadOTX_back :: affectedTool successfully retrieved" << endmsg);
47
48 return StatusCode::SUCCESS;
49}
50
52 (const Context& myctx,
53 CaloCluster* cluster,
54 const CaloDetDescrElement* /*elt*/,
55 float eta,
56 float adj_eta,
57 float /*phi*/,
58 float /*adj_phi*/,
59 CaloSampling::CaloSample /*samp*/) const
60{
61// ??? In principle, we should use adj_eta for the interpolation
62// and range checks. However, the v2 corrections were derived
63// using regular eta instead.
64//
65 //Get affected info for this event
67 const CaloAffectedRegionInfoVec* affCont=*affHdl;
68 if(!affCont) {
69 ATH_MSG_WARNING("Do not have affected regions info, is this expected ?");
70 }
71
72 float the_aeta;
73 if (m_use_raw_eta(myctx))
74 the_aeta = std::abs (adj_eta);
75 else
76 the_aeta = std::abs (eta);
77
78 const float etamax = m_etamax (myctx);
79 if (the_aeta >= etamax) return;
80
81 int si;
82 if (the_aeta < m_eta_start_crack(myctx))
83 si = 0;
84 else if (the_aeta > m_eta_end_crack(myctx))
85 si = 1;
86 else {
87 // No corrections are applied for the crack region.
88 return;
89 }
90
91 const CxxUtils::Array<3> correction = m_correction (myctx);
92
93 ATH_MSG_DEBUG( "************************************************************************************************" << endmsg);
94 ATH_MSG_DEBUG( " USING CALIBHITS CALIBRATION : apply correction for dead OTX in the back" << endmsg);
95 ATH_MSG_DEBUG( " Tool Name " << name() << endmsg);
96 ATH_MSG_DEBUG( "************************************************************************************************" << endmsg);
97
98// -------------------------------------------------------------
99// check if the cluster is in an affected region
100// -------------------------------------------------------------
101
102 static const CaloSampling::CaloSample samps[2][4] = {
103 { CaloSampling::PreSamplerB,
104 CaloSampling::EMB1,
105 CaloSampling::EMB2,
106 CaloSampling::EMB3 },
107 { CaloSampling::PreSamplerE,
108 CaloSampling::EME1,
109 CaloSampling::EME2,
110 CaloSampling::EME3 }
111 };
112
113// Keep memory of the energy stored in the back
114
115 float eneBackold = cluster->eSample (samps[si][3]) ;
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 + 3 ;
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 back 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][3], 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> lleak = correction[0][ibin];
144
145// -------------------------------------------------------------
146// Compute longitudinal barycenter: this is a very old and approximate
147// parametrization that needs to be updated.
148// -------------------------------------------------------------
149
150 double raw_energy =0;
151 double shower_lbary_raw =0;
152 for (int nl = 0 ; nl< 4 ; nl++){
153 raw_energy += cluster->eSample (samps[si][nl]);
154 shower_lbary_raw += (m_sampling_depth(myctx)[ibin][nl+1] * cluster->eSample (samps[si][nl])) ;
155 }
156
157 if (raw_energy == 0) return;
158 double shower_lbary = shower_lbary_raw / raw_energy;
159
160 ATH_MSG_DEBUG( "Shower longitudinal barycenter ---->> " << shower_lbary << endmsg);
161
162 double depth_max = 20. + raw_energy*(3./TeV) ;
163
164 if ( shower_lbary > depth_max || shower_lbary < 0.) {
165 shower_lbary = 15.;
166 ATH_MSG_DEBUG( " replace pathological depth by 15 X0 "
167 << endmsg);
168 }
169
170
171 raw_energy = raw_energy * 1e-3;
172
173// -------------------------------------------------------------
174// Estimate the energy deposited in the back sampling and the
175// longitudinal leakage based on the longitudinal barycenter
176// -------------------------------------------------------------
177
178 double e_acc_reco = 0;
179 for (int nl = 1 ; nl< 4 ; nl++){
180 e_acc_reco += cluster->eSample (samps[si][nl]);
181 }
182
183 ATH_MSG_DEBUG( "Leakage : " << lleak[0] <<" " << lleak[1]
184 << " " << lleak[2] << " " << lleak[3] << endmsg);
185
186 double e_leak_perc = lleak[3] + lleak[1] * shower_lbary + lleak[2] * exp(shower_lbary);
187
188 ATH_MSG_DEBUG( "LongLeakage correction --> " << e_leak_perc << endmsg);
189
190 if (e_leak_perc < 0 ) e_leak_perc = 0.;
191 if (e_leak_perc > 100.) e_leak_perc = 100.;
192
193 double e_leak_reco = e_leak_perc * (e_acc_reco)*0.01;
194
195// If something goes wrong keep the old energy
196 if (e_leak_reco<0.) e_leak_reco= eneBackold;
197
198// -------------------------------------------------------------
199// Now set the energies of the cluster
200// -------------------------------------------------------------
201
202// set the energy of the presampler
203 cluster->setEnergy (samps[si][3], e_leak_reco );
204
205// take the cluster energy, subtract the old PS energy and add the new one
206
207 ATH_MSG_DEBUG( "CaloSwDeadOTX_back:: cluster energy before correction --> " << cluster->e() << endmsg);
208 ATH_MSG_DEBUG( "subtracting back energy -->> " << eneBackold << endmsg);
209 ATH_MSG_DEBUG( "adding new back energy -->> " << e_leak_reco << endmsg);
210
211 float e_temp = cluster->e() - eneBackold + e_leak_reco ;
212
213// set the energy of the cluster
214 cluster->setE (e_temp);
215
216 ATH_MSG_DEBUG( "CaloSwDeadOTX_back::Energy after correction --> " << cluster->e() << endmsg);
217
218}
219
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< CxxUtils::Array< 2 > > m_sampling_depth
Constant< bool > m_use_raw_eta
Constant< float > m_etamax
virtual void makeTheCorrection(const Context &muctx, 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.
ToolHandle< ICaloAffectedTool > m_affectedTool
virtual StatusCode initialize() override
Initialize method.
Constant< float > m_eta_end_crack
SG::ReadCondHandleKey< CaloAffectedRegionInfoVec > m_affKey
Constant< CxxUtils::Array< 3 > > m_correction
Constant< float > m_eta_start_crack
Read-only multidimensional array.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
const EventContext & ctx() const