ATLAS Offline Software
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 
7 NAME: CaloSwDeadOTX_back.cxx
8 PACKAGE: offline/Calorimeter/CaloSwCalibHitsCalibration
9 
10 AUTHORS: L. Carminati
11 CREATED: March 26, 2010
12 
13 PURPOSE: 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 
25 using xAOD::CaloCluster;
26 using 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 
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 
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] = {
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 
CaloAffectedRegionInfoVec
std::vector< CaloAffectedRegionInfo > CaloAffectedRegionInfoVec
Definition: CaloAffectedRegionInfoVec.h:11
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CaloSwDeadOTX_back::m_eta_start_crack
Constant< float > m_eta_start_crack
Definition: CaloSwDeadOTX_back.h:72
CaloCluster::eSample
double eSample(sampling_type sampling) const
Retrieve energy in a given sampling.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:975
CaloSwDeadOTX_back::makeTheCorrection
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.
Definition: CaloSwDeadOTX_back.cxx:52
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
CaloSwDeadOTX_back::m_sampling_depth
Constant< CxxUtils::Array< 2 > > m_sampling_depth
Definition: CaloSwDeadOTX_back.h:71
CaloSwDeadOTX_back::m_affectedTool
ToolHandle< ICaloAffectedTool > m_affectedTool
Definition: CaloSwDeadOTX_back.h:68
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
CaloUtils::ToolConstantsContext::ctx
const EventContext & ctx() const
Definition: ToolWithConstants.h:63
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloSwDeadOTX_back::m_etamax
Constant< float > m_etamax
Definition: CaloSwDeadOTX_back.h:74
python.SystemOfUnits.TeV
int TeV
Definition: SystemOfUnits.py:158
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
CaloClusterCorrection::initialize
virtual StatusCode initialize() override
Initialize method.
Definition: CaloClusterCorrection.cxx:47
tools.zlumi_mc_cf.correction
def correction(mu, runmode, campaign, run=None)
Definition: zlumi_mc_cf.py:4
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
CxxUtils::Array< 3 >
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
CaloCluster
Principal data class for CaloCell clusters.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
CaloSwDeadOTX_back::m_use_raw_eta
Constant< bool > m_use_raw_eta
Definition: CaloSwDeadOTX_back.h:75
CaloSwDeadOTX_back::m_eta_end_crack
Constant< float > m_eta_end_crack
Definition: CaloSwDeadOTX_back.h:73
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArNewCalib_Delay_OFC_Cali.check
check
Definition: LArNewCalib_Delay_OFC_Cali.py:258
CaloSwDeadOTX_back::initialize
virtual StatusCode initialize() override
Initialize method.
Definition: CaloSwDeadOTX_back.cxx:29
CaloCluster::setE
virtual void setE(double e)
Set energy.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:767
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
CaloSwDeadOTX_back.h
CaloCluster::e
virtual double e() const
Retrieve energy independent of signal state.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:753
CaloUtils::ToolConstantsContext
Context object for retrieving ToolConstant values.
Definition: ToolWithConstants.h:61
CaloSwDeadOTX_back::m_correction
Constant< CxxUtils::Array< 3 > > m_correction
Definition: CaloSwDeadOTX_back.h:70
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
CaloSwDeadOTX_back::m_affKey
SG::ReadCondHandleKey< CaloAffectedRegionInfoVec > m_affKey
Definition: CaloSwDeadOTX_back.h:65
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56