ATLAS Offline Software
Loading...
Searching...
No Matches
CaloLongWeights_v2.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5/********************************************************************
6
7NAME: CaloLongWeights_v2.cxx
8PACKAGE: offline/Calorimter/CaloClusterCorrection
9
10AUTHORS: Mohamed Aharrouche
11CREATED: Jan 25, 2006
12
13PURPOSE: correction for the energy lost in the dead material
14
15********************************************************************/
16#include "CaloLongWeights_v2.h"
18
19
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
42 const CxxUtils::Array<3> correction = m_correction (myctx);
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 if (n_samples == 0) {
58 ATH_MSG_ERROR("Empty energies vector");
59 return;
60 }
61
62 unsigned int shape[] = {n_samples, 6};
63 CaloRec::WritableArrayData<2> vectParm (shape);
64
65
66 for(unsigned int i=0;i<n_samples;i++)
67 {
68 vectParm[i][0] = energies[i];
69 for(unsigned int j=0;j<5;j++)
70 {
71 vectParm[i][j+1] = correction[i][etaIndex][j+1];
72 }
73 }
74
75 for(unsigned int k=0; k<5;k++)
76 {
77 if(energy < energies[0])
78 coefs[k] = vectParm[0][k+1];
79 else if(energy > energies[n_samples-1])
80 coefs[k] = vectParm[n_samples-1][k+1];
81 else
82 coefs[k] = interpolate (vectParm, energy, degree, k+1);
83 }
84
85
86
87 typedef CaloSampling::CaloSample Samplingmap[4];
88 static const Samplingmap LBarrel = { CaloSampling::PreSamplerB,
89 CaloSampling::EMB1, CaloSampling::EMB2, CaloSampling::EMB3 };
90 static const Samplingmap LEndcap = { CaloSampling::PreSamplerE,
91 CaloSampling::EME1, CaloSampling::EME2, CaloSampling::EME3 };
92 const Samplingmap& L = inBarrel ? LBarrel : LEndcap;
93
94
95 float Egap=0.0;
96
97 if(cluster->eSample(L[0])*cluster->eSample(L[1])>0.)
98 Egap=coefs[3]*std::sqrt(cluster->eSample(L[0])*cluster->eSample(L[1]));
99
100
101 cluster->setEnergy ( L[0],cluster->eSample(L[0])*coefs[0]);
102
103 float Eleak = cluster->eSample(L[3])*coefs[1];
104
105 //total energy
106 float Erec = 0.0;
107 for (int iSample=1; iSample < 4 ; ++iSample)
108 {
109 Erec += cluster->eSample (L[iSample]);
110 }
111
112
113 cluster->setE (coefs[4]*Erec + cluster->eSample (L[0]) + Eleak + coefs[2]+ Egap);
114
115}
116
Scalar eta() const
pseudorapidity method
#define ATH_MSG_ERROR(x)
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.
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.
Constant< CxxUtils::Array< 3 > > m_correction
Constant< float > m_etamax
Constant< float > m_barrel_frontier
Constant< CxxUtils::Array< 1 > > m_energies
Constant< int > m_degree
Constant< float > m_endcap_frontier
Read-only multidimensional array.
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
Polynomial interpolation in a table.
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.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.