ATLAS Offline Software
CaloSwEtaoff_v2.cxx
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 */
13 #include "CaloSwEtaoff_v2.h"
17 #include <cmath>
18 #include <cassert>
19 
20 
21 using xAOD::CaloCluster;
23 
24 
46  CaloCluster* cluster,
47  const CaloDetDescrElement* elt,
48  float eta,
49  float adj_eta,
50  float /*phi*/,
51  float /*adj_phi*/,
52  CaloSampling::CaloSample samp) const
53 {
55  const CxxUtils::Array<1> interp_barriers = m_interp_barriers (myctx);
56  const CxxUtils::Array<1> energies = m_energies (myctx);
57  const int degree = m_degree (myctx);
58  const int energy_degree = m_energy_degree (myctx);
59 
60  // Find u, the normalized displacement of the cluster within the cell.
61  // In the range -1...1, with 0 at the center.
62  float u = (eta - elt->eta()) / elt->deta() * 2;
63  if (elt->eta_raw() < 0)
64  u = -u;
65 
66  // u can sometimes be outside of the prescribed range, due to DD bugs.
67  if (u > 1)
68  u = 1;
69  else if (u < -1)
70  u = -1;
71 
72  // For each energy, interpolate in eta.
73  // We can't use the common energy_interpolation code here,
74  // because we're interpolating the fit parameters, not the overall
75  // correction. This should probably be done differently in the
76  // next version.
77  unsigned int n_energies = energies.size();
78  unsigned int shape[] = {n_energies, 4};
79  CaloRec::WritableArrayData<2> partab (shape);
80 
81  // If we're outside the range of the table, we'll just be using the
82  // value at the end (no extrapolation). We only need to calculate
83  // that one point in that case.
84  int beg = 0;
85  int end = n_energies;
86  float energy = cluster->e();
87  if (energy <= energies[0])
88  end = 1;
89  else if (energy >= energies[n_energies-1])
90  beg = n_energies-1;
91 
92  for (int i=beg; i<end; i++) {
93  partab[i][0] = energies[i];
94  for (int j=0; j < 3; j++)
95  partab[i][j+1] = interpolate (correction[i],
96  std::abs (adj_eta),
97  degree,
98  j+1,
99  interp_barriers);
100  }
101 
102  // Now interpolate in energy.
103  // But if we're outside of the range of the table, just use the value
104  // at the end (don't extrapolate).
105  float par[3];
106  for (int i=0; i < 3; i++) {
107  if (end-beg > 1)
108  par[i] = interpolate (partab, energy, energy_degree, i+1);
109  else
110  par[i] = partab[beg][i+1];
111  }
112 
113  // Calculate the fit function.
114  // Don't allow b to go all the way to zero; we get a division
115  // by zero there.
116  double b = std::max ((double)par[1], 1e-5);
117  double atanb = std::atan(b);
118  double sq = std::sqrt (b/atanb - 1);
119  double den = (sq/b*atanb - std::atan(sq));
120  float offs = par[0]* ((- std::atan (b*u) + u*atanb) / den +
121  par[2]*(1-std::abs(u)));
122 
123  // Apply the offset correction to the cluster.
124  if (eta < 0)
125  offs = -offs;
126  cluster->setEta (samp, eta + offs);
127 }
CaloDetDescrElement::deta
float deta() const
cell deta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:356
CaloSwEtaoff_v2::m_correction
Constant< CxxUtils::Array< 3 > > m_correction
Calibration constant: tabulated arrays of function parameters.
Definition: CaloSwEtaoff_v2.h:110
CaloSwEtaoff_v2.h
EM calorimeter eta offset (S-shape) corrections.
max
#define max(a, b)
Definition: cfImp.cxx:41
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
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
CaloSwEtaoff_v2::m_energies
Constant< CxxUtils::Array< 1 > > m_energies
Calibration constant: table of energies at which the correction was tabulated.
Definition: CaloSwEtaoff_v2.h:124
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
CaloDetDescrElement::eta_raw
float eta_raw() const
cell eta_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:350
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
CaloSwEtaoff_v2::m_degree
Constant< int > m_degree
Calibration constant: degree of the polynomial interpolation.
Definition: CaloSwEtaoff_v2.h:119
tools.zlumi_mc_cf.correction
def correction(mu, runmode, campaign, run=None)
Definition: zlumi_mc_cf.py:4
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloSampling::CaloSample
CaloSample
Definition: Calorimeter/CaloGeoHelpers/CaloGeoHelpers/CaloSampling.h:22
sq
#define sq(x)
Definition: CurvedSegmentFinder.cxx:6
CaloSwEtaoff_v2::m_energy_degree
Constant< int > m_energy_degree
Calibration constant: degree of the polynomial interpolation in energy.
Definition: CaloSwEtaoff_v2.h:128
CxxUtils::Array< 3 >
CxxUtils::WritableArrayData
Definition: Control/CxxUtils/CxxUtils/Array.h:778
CaloCluster
Principal data class for CaloCell clusters.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:79
CaloPhiRange.h
CaloPhiRange class declaration.
CaloCluster::setEta
virtual void setEta(double eta)
Set eta.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:769
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
CaloSwEtaoff_v2::m_interp_barriers
Constant< CxxUtils::Array< 1 > > m_interp_barriers
Calibration constant: allow breaking up the interpolation into independent regions.
Definition: CaloSwEtaoff_v2.h:115
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
CaloSwEtaoff_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: CaloSwEtaoff_v2.cxx:45
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
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
interpolate.h
Polynomial interpolation in a table.
python.SystemOfUnits.degree
tuple degree
Definition: SystemOfUnits.py:106