ATLAS Offline Software
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
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. More...
 
virtual StatusCode finalize () override
 Finalization of the tool. More...
 
virtual void makeCorrection (xAOD::TrigEMCluster *, const void *) const override
 Virtual function from IEgammaCalibration. More...
 

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. More...
 
Constant< CxxUtils::Array< 2 > > m_regions { this, "regions" }
 Calibration constant: table of regions. More...
 
Constant< CxxUtils::Array< 1 > > m_energies { this, "energies" }
 Table of energies at which the correction was tabulated. More...
 
Constant< int > m_energy_degree { this, "energy_degree", 3 }
 Degree of the polynomial interpolation in energy. More...
 
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. More...
 

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.

103  {
104  REG_LO = 0,
105  REG_HI = 1,
106  REG_FORM = 2,
107  REG_CELLSIZE = 3,
108  REG_PHASE = 4
109  };

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  {
19  ATH_MSG_DEBUG( "Initialize Tool : " << name() );
20  return StatusCode::SUCCESS;
21 }

◆ 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) = "
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) = "
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,
192  m_energy_degree(),
193  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 }

Friends And Related Function Documentation

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ m_isRange_barrel

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

Definition at line 117 of file EgammaSshapeCalibration.h.

◆ 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.


The documentation for this class was generated from the following files:
CaloDetDescrElement::deta
float deta() const
cell deta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:356
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
xAOD::TrigEMCluster_v1::setEta
void setEta(float)
set Eta (calibrated)
xAOD::TrigEMCluster_v1::eta
float eta() const
get Eta (calibrated)
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
initialize
void initialize()
Definition: run_EoverP.cxx:894
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
EgammaSshapeCalibration::REG_LO
@ REG_LO
Definition: EgammaSshapeCalibration.h:104
EgammaSshapeCalibration::docalc
void docalc(int, const CaloClusterCorrectionCommon::TableBuilder &, const CxxUtils::Array< 1 > &, CxxUtils::WritableArray< 2 > &, int &) const
Definition: EgammaSshapeCalibration.cxx:216
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
EgammaSshapeCalibration::REG_FORM
@ REG_FORM
Definition: EgammaSshapeCalibration.h:106
EgammaSshapeCalibration::REG_PHASE
@ REG_PHASE
Definition: EgammaSshapeCalibration.h:108
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
createSimpleDistributions.builder
builder
Definition: createSimpleDistributions.py:52
EgammaSshapeCalibration::m_energy_degree
Constant< int > m_energy_degree
Degree of the polynomial interpolation in energy.
Definition: EgammaSshapeCalibration.h:115
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CxxUtils::Array< 2 >
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
CxxUtils::WritableArrayData
Definition: Control/CxxUtils/CxxUtils/Array.h:778
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
CaloDetDescriptor::is_lar_em_barrel
bool is_lar_em_barrel() const
descriptor belongs to EM barrel
Definition: CaloDetDescriptor.h:466
EgammaSshapeCalibration::m_regions
Constant< CxxUtils::Array< 2 > > m_regions
Calibration constant: table of regions.
Definition: EgammaSshapeCalibration.h:102
EgammaSshapeCalibration::REG_CELLSIZE
@ REG_CELLSIZE
Definition: EgammaSshapeCalibration.h:107
EgammaSshapeCalibration::m_isRange_barrel
Constant< bool > m_isRange_barrel
Definition: EgammaSshapeCalibration.h:117
create_dcsc_inputs_sqlite.arg
list arg
Definition: create_dcsc_inputs_sqlite.py:48
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CaloDetDescriptor::is_lar_em_endcap
bool is_lar_em_endcap() const
descriptor belongs to EM end cap
Definition: CaloDetDescriptor.h:471
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
ReadBchFromCool.good
good
Definition: ReadBchFromCool.py:433
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
EgammaSshapeCalibration::m_energies
Constant< CxxUtils::Array< 1 > > m_energies
Table of energies at which the correction was tabulated.
Definition: EgammaSshapeCalibration.h:112
CaloDetDescrElement::descriptor
const CaloDetDescriptor * descriptor() const
cell descriptor
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:428
EgammaSshapeCalibration::Builder
friend class Builder
Definition: EgammaSshapeCalibration.h:77
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
xAOD::TrigCaloCluster_v1::rawEta
float rawEta() const
get Raw Eta (no calibration)
EgammaSshapeCalibration::REG_HI
@ REG_HI
Definition: EgammaSshapeCalibration.h:105
xAOD::TrigEMCluster_v1::energy
float energy() const
get Energy (calibrated)
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56