ATLAS Offline Software
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 
7 NAME: CaloSwDeadOTX_ps.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 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 
24 using xAOD::CaloCluster;
25 using 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 
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 
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] = {
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 
CaloAffectedRegionInfoVec
std::vector< CaloAffectedRegionInfo > CaloAffectedRegionInfoVec
Definition: CaloAffectedRegionInfoVec.h:11
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CaloSwDeadOTX_ps::m_eta_start_crack
Constant< float > m_eta_start_crack
Definition: CaloSwDeadOTX_ps.h:72
CaloCluster::eSample
double eSample(sampling_type sampling) const
Retrieve energy in a given sampling.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:975
CaloSwDeadOTX_ps::m_use_raw_eta
Constant< bool > m_use_raw_eta
Definition: CaloSwDeadOTX_ps.h:75
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
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
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
python.SystemOfUnits.TeV
int TeV
Definition: SystemOfUnits.py:158
CaloSwDeadOTX_ps::m_affectedTool
ToolHandle< ICaloAffectedTool > m_affectedTool
Definition: CaloSwDeadOTX_ps.h:67
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
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
CaloSwDeadOTX_ps.h
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloSwDeadOTX_ps::m_affKey
SG::ReadCondHandleKey< CaloAffectedRegionInfoVec > m_affKey
Definition: CaloSwDeadOTX_ps.h:65
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
CaloSwDeadOTX_ps::m_etamax
Constant< float > m_etamax
Definition: CaloSwDeadOTX_ps.h:74
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_ps::initialize
virtual StatusCode initialize() override
Initialize method.
Definition: CaloSwDeadOTX_ps.cxx:28
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
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
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_ps::m_eta_end_crack
Constant< float > m_eta_end_crack
Definition: CaloSwDeadOTX_ps.h:73
CaloSwDeadOTX_ps::m_correction
Constant< CxxUtils::Array< 3 > > m_correction
Definition: CaloSwDeadOTX_ps.h:70
TRTCalib_cfilter.p3
p3
Definition: TRTCalib_cfilter.py:132
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
CaloSwDeadOTX_ps::m_sampling_depth
Constant< CxxUtils::Array< 2 > > m_sampling_depth
Definition: CaloSwDeadOTX_ps.h:71
CaloSwDeadOTX_ps::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: CaloSwDeadOTX_ps.cxx:51