ATLAS Offline Software
Loading...
Searching...
No Matches
EgammaSshapeCalibration Class Reference

#include <EgammaSshapeCalibration.h>

Inheritance diagram for EgammaSshapeCalibration:
Collaboration diagram for EgammaSshapeCalibration:

Classes

class  Builder

Public Member Functions

virtual StatusCode initialize () override
 Initialization of the tool.
virtual StatusCode finalize () override
 Finalization of the tool.
virtual void makeCorrection (xAOD::TrigEMCluster *, const void *) const override
 Virtual function from IEgammaCalibration.

Private Types

enum  {
  REG_LO = 0 , REG_HI = 1 , REG_FORM = 2 , REG_CELLSIZE = 3 ,
  REG_PHASE = 4
}

Private Member Functions

void docalc (int, const CaloClusterCorrectionCommon::TableBuilder &, const CxxUtils::Array< 1 > &, CxxUtils::WritableArray< 2 > &, int &) const

Private Attributes

Constant< CxxUtils::Array< 4 > > m_correction { this, "correction" }
 Calibration constant: tabulated arrays of function parameters.
Constant< CxxUtils::Array< 2 > > m_regions { this, "regions" }
 Calibration constant: table of regions.
Constant< CxxUtils::Array< 1 > > m_energies { this, "energies" }
 Table of energies at which the correction was tabulated.
Constant< int > m_energy_degree { this, "energy_degree", 3 }
 Degree of the polynomial interpolation in energy.
Constant< bool > m_isRange_barrel { this, "rangeBarrel" }
Constant< CxxUtils::Array< 2 > > m_forms { this, "forms" }
 Calibration constant: Functional form to use per region per energy.

Friends

class Builder

Detailed Description

Definition at line 23 of file EgammaSshapeCalibration.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
REG_LO 
REG_HI 
REG_FORM 
REG_CELLSIZE 
REG_PHASE 

Definition at line 103 of file EgammaSshapeCalibration.h.

Member Function Documentation

◆ docalc()

void EgammaSshapeCalibration::docalc ( int i,
const CaloClusterCorrectionCommon::TableBuilder & builder,
const CxxUtils::Array< 1 > & energies,
CxxUtils::WritableArray< 2 > & corrtab,
int & n_good ) const
inlineprivate

Definition at line 216 of file EgammaSshapeCalibration.cxx.

220 {
221 corrtab[n_good][0] = energies[i];
222 bool good = false;
223 corrtab[n_good][1] = builder.calculate (i, good);
224 if (good)
225 ++n_good;
226}

◆ finalize()

StatusCode EgammaSshapeCalibration::finalize ( )
overridevirtual

Finalization of the tool.

Definition at line 26 of file EgammaSshapeCalibration.cxx.

26 {
27 return StatusCode::SUCCESS;
28}

◆ initialize()

StatusCode EgammaSshapeCalibration::initialize ( )
overridevirtual

Initialization of the tool.

Definition at line 17 of file EgammaSshapeCalibration.cxx.

17 {
18 CHECK(base_class::initialize());
19 ATH_MSG_DEBUG( "Initialize Tool : " << name() );
20 return StatusCode::SUCCESS;
21}
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.

◆ makeCorrection()

void EgammaSshapeCalibration::makeCorrection ( xAOD::TrigEMCluster * clus,
const void * arg ) const
overridevirtual

Virtual function from IEgammaCalibration.

Definition at line 33 of file EgammaSshapeCalibration.cxx.

34 {
35
36 if(arg!=0){
37 const CaloDetDescrElement *caloDDE = (const CaloDetDescrElement*) arg;
38
39 bool isRange_barrel = m_isRange_barrel();
40
41#ifndef NDEBUG
42 ATH_MSG_DEBUG( "caloDDE->descriptor()->is_lar_em_barrel() = "
43 << caloDDE->descriptor()->is_lar_em_barrel() );
44 ATH_MSG_DEBUG( "caloDDE->descriptor()->is_lar_em_endcap() = "
45 << caloDDE->descriptor()->is_lar_em_endcap() );
46
47 ATH_MSG_DEBUG( "m_isRange_barrel=" << isRange_barrel );
48
49 ATH_MSG_DEBUG( "clus->energy(CaloSampling::PreSamplerB) = "
50 << clus->energy(CaloSampling::PreSamplerB) );
51 ATH_MSG_DEBUG( "clus->energy(CaloSampling::EMB1) = "
52 << clus->energy(CaloSampling::EMB1) );
53 ATH_MSG_DEBUG( "clus->energy(CaloSampling::EMB2) = "
54 << clus->energy(CaloSampling::EMB2) );
55 ATH_MSG_DEBUG( "clus->energy(CaloSampling::EMB3) = "
56 << clus->energy(CaloSampling::EMB3) );
57 ATH_MSG_DEBUG( "clus->energy(CaloSampling::PreSamplerE) = "
58 << clus->energy(CaloSampling::PreSamplerE) );
59 ATH_MSG_DEBUG( "clus->energy(CaloSampling::EME1) = "
60 << clus->energy(CaloSampling::EME1) );
61 ATH_MSG_DEBUG( "clus->energy(CaloSampling::EME2) = "
62 << clus->energy(CaloSampling::EME2) );
63 ATH_MSG_DEBUG( "clus->energy(CaloSampling::EME3) = "
64 << clus->energy(CaloSampling::EME3) );
65
66 if((caloDDE->descriptor()->is_lar_em_barrel() && isRange_barrel) ||
67 (caloDDE->descriptor()->is_lar_em_endcap() && !isRange_barrel))
68 ATH_MSG_DEBUG( "[GOOD]: seedCell location and selected eta range agree" );
69 else if((caloDDE->descriptor()->is_lar_em_barrel() && !isRange_barrel) ||
70 (caloDDE->descriptor()->is_lar_em_endcap() && isRange_barrel))
71 ATH_MSG_DEBUG( "[BAD]: seedCell location and selected eta range disagree !!" );
72#endif
73
74 // check if seedCell is in barrel or end-cap for correct range selection
75 if((caloDDE->descriptor()->is_lar_em_barrel() && !isRange_barrel) ||
76 (caloDDE->descriptor()->is_lar_em_endcap() && isRange_barrel))
77 return;
78
79 double eta = clus->eta(); // cluster position in eta
80 double elt_eta = caloDDE->eta(); // seedCell position in eta
81 double elt_deta = caloDDE->deta(); // seedCell width in eta
82
83 // Find u, the normalized displacement of the cluster within the cell
84 // in the range -1...1, with 0 being at the center.
85 double u = 2*(eta-elt_eta)/elt_deta; // position within cell
86
87 // cluster position in eta without accounting for alignment corrections
88 double elt_eta_raw = clus->rawEta();
89
90 if(elt_eta_raw<0.) u=-u;
91
92 // Sanity-check of valid u-range...
93 if(u>1)
94 u=1;
95 else if(u<-1)
96 u=-1;
97
98 // The eta adjusted for any shift between the actual and nominal coordinates.
99 double aeta = fabs(eta - elt_eta + elt_eta_raw);
100
101#ifndef NDEBUG
102 ATH_MSG_DEBUG( "eta = " << eta );
103 ATH_MSG_DEBUG( "elt_eta = " << elt_eta );
104 ATH_MSG_DEBUG( "elt_deta = " << elt_deta );
105 ATH_MSG_DEBUG( "elt_eta_raw = " << elt_eta_raw );
106 ATH_MSG_DEBUG( "u = " << u );
107 ATH_MSG_DEBUG( "aeta = " << aeta );
108#endif
109
110 // Find the appropriate region
111 int region_ndx=-1;
112 const CxxUtils::Array<2> regions = m_regions();
113 unsigned int nreg = regions.size();
114
115 // find correct region
116 for (unsigned int i=0; i<nreg; i++) {
117 if(aeta>=regions[i][REG_LO] && aeta<regions[i][REG_HI]){
118 region_ndx=i;
119 break;
120 }
121 }
122
123 // Sanity-check for region index...
124 if(region_ndx<0){
125 return;
126 }
127
128 // In a few regions, the fit was done using a cell size different
129 // from what we actually have. Need to recalculate u in this case.
130 if(std::abs(regions[region_ndx][REG_CELLSIZE]-elt_deta) > 1e-3) {
131 float cellsize = regions[region_ndx][REG_CELLSIZE];
132 u = fmod(aeta,cellsize)/cellsize*2 - 1;
133 }
134
135 float energy = clus->energy();
136
137 Builder *builder = new Builder(*this, aeta, u, region_ndx);
138
139 // Calculate the correction for each energy.
140 const CxxUtils::Array<1> energies = m_energies();
141 unsigned int n_energies = energies.size();
142 unsigned int shape[] = {n_energies, 2};
143 CaloRec::WritableArrayData<2> corrtab (shape);
144
145 // If we're outside the range of the table, we'll just be using the
146 // value at the end (no extrapolation). We only need to calculate
147 // that one point in that case.
148 unsigned int beg = 0;
149 unsigned int end = n_energies;
150 if(energy <= energies[0]) // ok. energies also in MeV
151 end = 1;
152 else if(energy >= energies[n_energies-1])// ok. energies also in MeV
153 beg = n_energies-1;
154
155 // Build the table.
156 int n_good = 0;
157 for (unsigned int i=beg; i<end; i++)
158 docalc(i, *builder, energies, corrtab, n_good);
159
160 // If we only evaluated one point, but it wasn't good, keep
161 // searching until we find a good one.
162 while (n_good==0 && beg>0) {
163 --beg;
164 docalc (beg, *builder, energies, corrtab, n_good);
165 }
166 while (n_good == 0 && end<n_energies) {
167 docalc(end, *builder, energies, corrtab, n_good);
168 ++end;
169 }
170
171 // Now interpolate in energy.
172 // But if we're outside of the range of the table, just use the value
173 // at the end (don't extrapolate).
174
175 float offs=0;
176
177 if(n_good==0){ // No good energies --- return a null correction.
178 offs=0;
179 }
180 else if(n_good==1){ // Only one good energy --- nothing to do but to use it.
181 offs=corrtab[0][1];
182 }
183 else if(energy<=corrtab[0][0]){ // Off the low end of the table --- return the first value.
184 offs=corrtab[0][1];
185 }
186 else if(energy>=corrtab[n_good-1][0]) { // Off the high end of the table --- return the last value.
187 offs=corrtab[n_good-1][1];
188 }
189 else{ // Do the interpolation.
190 offs = CaloClusterCorr::interpolate(corrtab,
191 energy,
193 1,
194 CaloRec::Array<1>(),
195 n_good);
196 }
197
198 if (eta<0)
199 offs=-offs;
200
201 clus->setEta(eta+offs);
202
203#ifndef NDEBUG
204 ATH_MSG_DEBUG( "Before correction : " << eta );
205 ATH_MSG_DEBUG( "offset =" << offs );
206 ATH_MSG_DEBUG( "After correction : " << eta+offs );
207#endif
208
209 delete builder;
210 }
211}
Scalar eta() const
pseudorapidity method
static const std::vector< std::string > regions
const CaloDetDescriptor * descriptor() const
cell descriptor
bool is_lar_em_barrel() const
descriptor belongs to EM barrel
bool is_lar_em_endcap() const
descriptor belongs to EM end cap
unsigned int size(unsigned int dim=0) const
Return the size of the array along one dimension.
Constant< CxxUtils::Array< 1 > > m_energies
Table of energies at which the correction was tabulated.
void docalc(int, const CaloClusterCorrectionCommon::TableBuilder &, const CxxUtils::Array< 1 > &, CxxUtils::WritableArray< 2 > &, int &) const
Constant< int > m_energy_degree
Degree of the polynomial interpolation in energy.
Constant< CxxUtils::Array< 2 > > m_regions
Calibration constant: table of regions.
float rawEta() const
get Raw Eta (no calibration)
void setEta(float)
set Eta (calibrated)
float eta() const
get Eta (calibrated)
float energy() const
get Energy (calibrated)
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.
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77

◆ Builder

friend class Builder
friend

Definition at line 77 of file EgammaSshapeCalibration.h.

Member Data Documentation

◆ m_correction

Constant<CxxUtils::Array<4> > EgammaSshapeCalibration::m_correction { this, "correction" }
private

Calibration constant: tabulated arrays of function parameters.

Index 0: energy Index 1: region Index 2: parameter Index 3: polynomial coefficient

Note: If [e][r][0][-1] (where -1 means the last in the array) is exactly 0, for any e and r, then this energy/region is skipped. (This is usually because insufficient statistics were available to get a good fit.)

Definition at line 90 of file EgammaSshapeCalibration.h.

90{ this, "correction" };

◆ m_energies

Constant<CxxUtils::Array<1> > EgammaSshapeCalibration::m_energies { this, "energies" }
private

Table of energies at which the correction was tabulated.

Definition at line 112 of file EgammaSshapeCalibration.h.

112{ this, "energies" };

◆ m_energy_degree

Constant<int> EgammaSshapeCalibration::m_energy_degree { this, "energy_degree", 3 }
private

Degree of the polynomial interpolation in energy.

Definition at line 115 of file EgammaSshapeCalibration.h.

115{ this, "energy_degree", 3 };

◆ m_forms

Constant<CxxUtils::Array<2> > EgammaSshapeCalibration::m_forms { this, "forms" }
private

Calibration constant: Functional form to use per region per energy.

If this is empty, the form is taken instead from the region table (and is thus same for all energies).

Definition at line 122 of file EgammaSshapeCalibration.h.

122{ this, "forms" };

◆ m_isRange_barrel

Constant<bool> EgammaSshapeCalibration::m_isRange_barrel { this, "rangeBarrel" }
private

Definition at line 117 of file EgammaSshapeCalibration.h.

117{ this, "rangeBarrel" };

◆ m_regions

Constant<CxxUtils::Array<2> > EgammaSshapeCalibration::m_regions { this, "regions" }
private

Calibration constant: table of regions.

For each region, we have:

  • Lower \(|\eta|\) for the region.
  • Upper \(|\eta|\) for the region.
  • Index of the functional form for this region.
  • Cell size for this region.
  • Offset of cell low edge wrt a multiple of the cell size (not currently used).

If the forms variable is provided, then the functional form is taken from there instead of from here.

Definition at line 102 of file EgammaSshapeCalibration.h.

102{ this, "regions" };

The documentation for this class was generated from the following files: