ATLAS Offline Software
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 
7 NAME: CaloSwLongWeights.cxx
8 PACKAGE: offline/Calorimter/CaloSwLongWeights
9 
10 AUTHORS: K.Loureiro, S.Paganis
11 CREATED: July 5, 2004
12 
13 PURPOSE: 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 
26 using xAOD::CaloCluster;
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 
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++)
99  the_aeta,
100  degree,
101  i+1,
102  interp_barriers);
103 
104  static const
105  CaloSampling::CaloSample samps[2][4] = {
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 
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
CaloCluster::eSample
double eSample(sampling_type sampling) const
Retrieve energy in a given sampling.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:975
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
CaloSwLongWeights::m_etamax
Constant< float > m_etamax
Definition: CaloSwLongWeights.h:78
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
CaloSwLongWeights::m_degree
Constant< int > m_degree
Definition: CaloSwLongWeights.h:79
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
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CaloSwLongWeights::m_eta_end_crack
Constant< float > m_eta_end_crack
Definition: CaloSwLongWeights.h:77
CxxUtils::Array< 2 >
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
CxxUtils::WritableArrayData
Definition: Control/CxxUtils/CxxUtils/Array.h:778
CaloCluster
Principal data class for CaloCell clusters.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
CaloSwLongWeights::m_eta_start_crack
Constant< float > m_eta_start_crack
Definition: CaloSwLongWeights.h:76
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
CaloCluster::setE
virtual void setE(double e)
Set energy.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:767
CaloSwLongWeights::m_correction
Constant< CxxUtils::Array< 2 > > m_correction
Definition: CaloSwLongWeights.h:75
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
CaloClusterCorr::interpolate
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.
Definition: interpolate.cxx:75
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
interpolate.h
Polynomial interpolation in a table.
CaloSwLongWeights::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: CaloSwLongWeights.cxx:51
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
CaloSwLongWeights.h
CaloSwLongWeights::m_preserve_offset
Constant< bool > m_preserve_offset
Definition: CaloSwLongWeights.h:81
CaloSwLongWeights::m_use_raw_eta
Constant< bool > m_use_raw_eta
Definition: CaloSwLongWeights.h:80