ATLAS Offline Software
CaloLongWeights_v2.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: CaloLongWeights_v2.cxx
8 PACKAGE: offline/Calorimter/CaloClusterCorrection
9 
10 AUTHORS: Mohamed Aharrouche
11 CREATED: Jan 25, 2006
12 
13 PURPOSE: correction for the energy lost in the dead material
14 
15 ********************************************************************/
16 #include "CaloLongWeights_v2.h"
18 
19 
20 using xAOD::CaloCluster;
22 
24  CaloCluster* cluster,
25  const CaloDetDescrElement* /*elt*/,
26  float eta,
27  float /*adj_eta*/,
28  float /*phi*/,
29  float /*phi*/,
30  CaloSampling::CaloSample /*samp*/) const
31 {
32  float the_eta = std::abs (eta);
33  if (the_eta >= m_etamax (myctx)) return;
34 
35 
36  bool inBarrel = false;
37  if (the_eta < m_barrel_frontier (myctx))
38  inBarrel= true;
39  else if (the_eta <= m_endcap_frontier (myctx))
40  return;
41 
43  const CxxUtils::Array<1> energies = m_energies (myctx);
44  const int degree = m_degree (myctx);
45 
46  //initial cluster energy
47  float energy = cluster->e();
48 
49  //Weights
50  float coefs[5];
51 
52  //eta bin
53  int etaIndex = (int) (the_eta * (1./0.025));
54 
55  //samples
56  unsigned int n_samples = energies.size();
57 
58 
59  unsigned int shape[] = {n_samples, 6};
60  CaloRec::WritableArrayData<2> vectParm (shape);
61 
62 
63  for(unsigned int i=0;i<n_samples;i++)
64  {
65  vectParm[i][0] = energies[i];
66  for(unsigned int j=0;j<5;j++)
67  {
68  vectParm[i][j+1] = correction[i][etaIndex][j+1];
69  }
70  }
71 
72  for(unsigned int k=0; k<5;k++)
73  {
74  if(energy < energies[0])
75  coefs[k] = vectParm[0][k+1];
76  else if(energy > energies[n_samples-1])
77  coefs[k] = vectParm[n_samples-1][k+1];
78  else
79  coefs[k] = interpolate (vectParm, energy, degree, k+1);
80  }
81 
82 
83 
84  typedef CaloSampling::CaloSample Samplingmap[4];
85  static const Samplingmap LBarrel = { CaloSampling::PreSamplerB,
87  static const Samplingmap LEndcap = { CaloSampling::PreSamplerE,
89  const Samplingmap& L = inBarrel ? LBarrel : LEndcap;
90 
91 
92  float Egap=0.0;
93 
94  if(cluster->eSample(L[0])*cluster->eSample(L[1])>0.)
95  Egap=coefs[3]*std::sqrt(cluster->eSample(L[0])*cluster->eSample(L[1]));
96 
97 
98  cluster->setEnergy ( L[0],cluster->eSample(L[0])*coefs[0]);
99 
100  float Eleak = cluster->eSample(L[3])*coefs[1];
101 
102  //total energy
103  float Erec = 0.0;
104  for (int iSample=1; iSample < 4 ; ++iSample)
105  {
106  Erec += cluster->eSample (L[iSample]);
107  }
108 
109 
110  cluster->setE (coefs[4]*Erec + cluster->eSample (L[0]) + Eleak + coefs[2]+ Egap);
111 
112 }
113 
CaloLongWeights_v2::m_degree
Constant< int > m_degree
Definition: CaloLongWeights_v2.h:59
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
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
CxxUtils::Array::size
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
egammaEnergyPositionAllSamples::inBarrel
bool inBarrel(const xAOD::CaloCluster &cluster, int is)
return boolean to know if we are in barrel/end-cap
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
tools.zlumi_mc_cf.correction
def correction(mu, runmode, campaign, run=None)
Definition: zlumi_mc_cf.py:4
CaloLongWeights_v2::m_endcap_frontier
Constant< float > m_endcap_frontier
Definition: CaloLongWeights_v2.h:62
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
lumiFormat.i
int i
Definition: lumiFormat.py:85
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
CxxUtils::Array< 3 >
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
CaloLongWeights_v2::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: CaloLongWeights_v2.cxx:23
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
CaloLongWeights_v2::m_barrel_frontier
Constant< float > m_barrel_frontier
Definition: CaloLongWeights_v2.h:61
CaloCluster::setE
virtual void setE(double e)
Set energy.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:767
CaloLongWeights_v2::m_etamax
Constant< float > m_etamax
Definition: CaloLongWeights_v2.h:60
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
CaloLongWeights_v2::m_energies
Constant< CxxUtils::Array< 1 > > m_energies
Definition: CaloLongWeights_v2.h:58
CaloLongWeights_v2.h
interpolate.h
Polynomial interpolation in a table.
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
CaloLongWeights_v2::m_correction
Constant< CxxUtils::Array< 3 > > m_correction
Definition: CaloLongWeights_v2.h:57
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
fitman.k
k
Definition: fitman.py:528