ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterUpdate.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
7NAME: CaloClusterUpdate.cxx
8PACKAGE: offline/LArCalorimeter/LArClusterRec
9
10AUTHORS: H. Ma, S. Rajagopalan
11CREATED: Nov, 2000
12
13PURPOSE: Recalculate the total energy, eta,phi of a cluster.
14 This should be called after all corrections to individual
15 samplings are done.
16
17 energy = Sum of energy in all sampling
18 eta = average of eta1 and eta2, weighted by energy and
19 relative resolution.
20 This needs to be tuned.
21 phi = phi of second sampling.
22
23Base class: LArClusterCorrection (Algorithm)
24
25Atrecon Orig: emreco/qetamod.F
26
27Updated: May 10, 2000 (SR, HM)
28 Migrated to Athena Framework from PASO
29
30Updated: Jan 5, 2001 (HM)
31 QA.
32
33Updated: Feb 28, 2003, Mar 4, 2003 (MW)
34 protect against unphysical clusters
35
36Updated: May 5, 2004 (Sven Menke)
37 base class changed from algo to tool
38
39********************************************************************/
40// include header files
41#include "CaloClusterUpdate.h"
42
43#include "GaudiKernel/MsgStream.h"
46
49 CaloCluster* cluster) const
50{
51 float energy=0;
52 float eta=0;
53 float weta=0;
54
55 // set eta to be weighted average of eta1 and eta2
56 ATH_MSG_DEBUG(" inBarrel "<<cluster->inBarrel()
57 << " inEndcap "<<cluster->inEndcap()) ;
58
59 for(int i=0; i<5; i=i+4 )
60 {
61
62 if (i==0 && !cluster->inBarrel()) continue;
63 if (i==4 && !cluster->inEndcap()) continue;
64
65 CaloSampling::CaloSample sam0 = (CaloSampling::CaloSample)(CaloSampling::PreSamplerB+i);
66 CaloSampling::CaloSample sam1 = (CaloSampling::CaloSample)(CaloSampling::PreSamplerB+i+1);
67 CaloSampling::CaloSample sam2 = (CaloSampling::CaloSample)(CaloSampling::PreSamplerB+i+2);
68 CaloSampling::CaloSample sam3 = (CaloSampling::CaloSample)(CaloSampling::PreSamplerB+i+3);
69
70 float e0 = cluster->eSample(sam0);
71 float e1 = cluster->eSample(sam1);
72 float e2 = cluster->eSample(sam2);
73 float e3 = cluster->eSample(sam3);
74
75 // total energy is the sum of each sampling, which had all corrections
76 energy += (e0 + e1 + e2 + e3);
77
78 // do not consider including in the average if both energies are negative
79 if (e1 <= 0 && e2 <= 0) continue;
80
81 // reject weird clusters. Not even sure it can ever happen
82 float eta2 = cluster->etaSample(sam2);
83 if (cluster->hasSampling(sam2) && eta2 == -999.) continue;
84
85 float eta1 = cluster->etaSample(sam1);
86 if (cluster->hasSampling(sam1) && eta1 == -999.) continue;
87
88 // eta1 has better resolution, so weight it differently
89 float w1 = e1*m_w1;
90 float w2 = e2;
91
92 // do not include layer if energy is negative
93 if (e1 <= 0) {
94 w1 = 0;
95 }
96 else if (e2 <= 0) {
97 w2 = 0;
98 }
99
100 eta += (eta1*w1+eta2*w2) ;
101 weta += w1+w2;
102 }
103
104 //
105 // set them in the cluster.
106 //
107 if (eta != -999. && weta != 0)
108 eta = eta/weta;
109 else {
110 ATH_MSG_DEBUG("Weird cluster "
111 " EB1 = " << cluster->eSample(CaloSampling::EMB1)
112 << " etaB1 = " << cluster->etaSample(CaloSampling::EMB1)
113 << " EE1 = " << cluster->eSample(CaloSampling::EME1)
114 << " etaE1 = " << cluster->etaSample(CaloSampling::EME1)
115 << " EB2 = " << cluster->eSample(CaloSampling::EMB2)
116 << " etaB2 = " << cluster->etaSample(CaloSampling::EMB2)
117 << " EE2 = " << cluster->eSample(CaloSampling::EME2)
118 << " etaE2 = " << cluster->etaSample(CaloSampling::EME2));
119 if (cluster->inBarrel() && !cluster->inEndcap())
120 eta = cluster->etaSample(CaloSampling::EMB2);
121 else if (cluster->inEndcap() && !cluster->inBarrel())
122 eta = cluster->etaSample(CaloSampling::EME2);
123 else {
124 if (cluster->eSample(CaloSampling::EMB2) >
125 cluster->eSample(CaloSampling::EME2))
126 eta = cluster->etaSample(CaloSampling::EMB2);
127 else
128 eta = cluster->etaSample(CaloSampling::EME2);
129 }
130 }
131
132 cluster->setEta(eta);
133 cluster->setPhi(cluster->phiBE(2));
134
135 if (m_update_energy (myctx))
136 cluster->setE(energy);
137}
138
139
Scalar eta() const
pseudorapidity method
#define ATH_MSG_DEBUG(x)
CaloPhiRange class declaration.
virtual void makeCorrection(const Context &myctx, xAOD::CaloCluster *cluster) const override
Gaudi::Property< float > m_w1
Constant< bool > m_update_energy
Principal data class for CaloCell clusters.
double eSample(sampling_type sampling) const
Retrieve energy in a given sampling.
double phiBE(int sampling) const
EMB/EMEC combined barycenter .
virtual void setEta(double eta)
Set eta.
double etaSample(sampling_type sampling) const
Retrieve barycenter in a given sample.
bool inEndcap() const
Returns true if at least one clustered cell in EMEC.
bool hasSampling(const sampling_type &theSampling) const
Checks if certain sampling contributes to cluster.
virtual void setPhi(double phi)
Set phi.
bool inBarrel() const
Returns true if at least one clustered cell in EMB.
virtual void setE(double e)
Set energy.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.