ATLAS Offline Software
eflowEEtaBinnedParameters.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /********************************************************************
6 
7 NAME: eflowEEtaBinnedParameters.h
8 PACKAGE: offline/Reconstruction/eflowRec
9 
10 AUTHORS: M.Hodgkinson, R Duxfield (based on R.Duxfields Root package)
11 CREATED: 18th Aug, 2005
12 
13 ********************************************************************/
14 
15 //Athena Headers
19 
20 #include "GaudiKernel/SystemOfUnits.h"
21 
22 //C++ Headers
23 #include <float.h>
24 #include <cmath>
25 #include <stdexcept>
26 
27 using namespace std;
29 // eflowEEtaBinnedParameters //
31 
32 
33 void eflowEEtaBinnedParameters::initialise(const std::vector<double>& eBinBounds, const std::vector<double>& etaBinBounds, bool useAbsEta) {
34  m_useAbsEta = useAbsEta;
35  m_eBinBounds = eBinBounds;
36  m_etaBinBounds = etaBinBounds;
37 
38  /* Create all the bins */
39  int nEBins = getNumEBins();
40  int nEtaBins = getNumEtaBins()-1;
41  m_bins.reserve(nEBins);
42  for (int iEBin = 0; iEBin < nEBins; iEBin++) {
43  std::vector<std::unique_ptr<eflowParameters> > tempVector;
44  tempVector.reserve(nEtaBins);
45  for (int iEtaBin = 0; iEtaBin < nEtaBins; iEtaBin++) {
46  tempVector.push_back(std::make_unique<eflowParameters>());
47  }
48  m_bins.push_back(std::move(tempVector));
49  }
50 }
51 
53  const eflowParameters** bin2,
54  double e, double eta, bool useLegacyEnergyBinIndexing) const {
55  double weight;
56  int eBin = 0;
57  if (useLegacyEnergyBinIndexing) {
58  eBin = getEBinIndexLegacy(e);
59  } else {
60  eBin = getEBinIndex(e);
61  }
62  int etaBin = getEtaBinIndex(eta);
63 
64  /* Check for invalid bins */
65  if (eBin < 0 || etaBin < 0) {
66  *bin1 = nullptr;
67  *bin2 = nullptr;
68  weight = -1.0;
69  return weight;
70  }
71 
72  if ((0 == eBin && e <= m_eBinBounds[eBin]) ||
73  (eBin == getNumEBins() - 1 && e >= m_eBinBounds[getNumEBins() - 1])) {
74  /* If e is below the lowest (above the highest) pinpoint, just return the lowest (highest) bin; no interpolation in this case. */
75  *bin1 = m_bins[eBin][etaBin].get();
76  *bin2 = m_bins[eBin][etaBin].get();
77  weight = 1.0;
78  } else {
79  /* The "normal" case: interpolate between two energies */
80  int lowEBin = eBin;
81  int highEBin = eBin;
82 
83  if (e >= m_eBinBounds[eBin]) {
84  highEBin = eBin + 1;
85  } else {
86  lowEBin = eBin - 1;
87  }
88  auto outOfRange = [this](int bin)->bool{
89  return (bin<0) or (bin>=std::ssize(m_bins));
90  };
91 
92  if (outOfRange(lowEBin) or outOfRange(highEBin)){
93  throw std::out_of_range("Attempt to access element out of range in eflowEEtaBinnedParameters::getInterpolation");
94  }
95  *bin1 = m_bins[lowEBin][etaBin].get();
96  *bin2 = m_bins[highEBin][etaBin].get();
97 
98  double higherEBound = m_eBinBounds[highEBin];
99  double lowerEBound = m_eBinBounds[lowEBin];
100  //deals with e = 0 bin to avoid dividing by zero
101  if (lowerEBound < FLT_MIN) lowerEBound = FLT_MIN;
102 
103  weight = log(higherEBound / e) / log(higherEBound / lowerEBound);
104  }
105  return weight;
106 }
107 
110  eflowFirstIntENUM j1st, bool useLegacyEnergyBinIndexing) const {
111 
112 
113  int eBinIndex = 0;
114  if (useLegacyEnergyBinIndexing) {
115  eBinIndex = getEBinIndexLegacy(e);
116  } else {
117  eBinIndex = getEBinIndex(e);
118  }
119 
120  //hard code this check - needs to be rechecked if ever remake e/p tables
121  //if e.g track extrapolation slightly off can have inconsistent j1st and eta (e.g eta = 1.52, j1st = EMB2) and hence fudgeMean is zero
122  if (0 <= eBinIndex && eBinIndex <= 5) {
123  if (fabs(eta) < 1.5) {
128  }
129  if (fabs(eta) >= 1.6) {
134  }
135 
136  }
137 
138  if (0 == eBinIndex || 1 == eBinIndex) {
139  if (fabs(eta) >= 1.0 && fabs(eta) < 1.1) {
141  }
142  else if (fabs(eta) >= 1.2 && fabs(eta) < 1.3) {
144  }
145  else if (fabs(eta) >= 1.5 && fabs(eta) < 1.6) {
147  }
148 
149  } else if (2 == eBinIndex) {
150  if (fabs(eta) >= 1.5 && fabs(eta) < 1.6) {
152  }
153 
154  } else if (3 == eBinIndex) {
155  if (fabs(eta) >= 1.5 && fabs(eta) < 1.6) {
158  }
159 
160  } else if (4 == eBinIndex || 5 == eBinIndex) {
161  if (fabs(eta) >= 1.5 && fabs(eta) < 1.6) {
163  }
164  }
165 
166  return j1st;
167 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
TCS::KFMET::nEtaBins
constexpr unsigned nEtaBins
Definition: KalmanMETCorrectionConstants.h:18
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
eflowFirstIntRegions::EMB3
@ EMB3
Definition: eflowCaloRegions.h:59
eflowFirstIntRegions::EME3
@ EME3
Definition: eflowCaloRegions.h:60
bin
Definition: BinsDiffFromStripMedian.h:43
eflowFirstIntRegions::EMB1
@ EMB1
Definition: eflowCaloRegions.h:59
eflowFirstIntParameters.h
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
eflowFirstIntRegions::Tile
@ Tile
Definition: eflowCaloRegions.h:62
xAOD::etaBin
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap etaBin
Definition: L2StandAloneMuon_v1.cxx:148
eflowParameters
Definition: eflowEEtaBinnedParameters.h:30
bin2
Definition: KillBinsByStrip.h:34
eflowRingSubtractionManager.h
eflowEEtaBinnedParameters::initialise
void initialise(const std::vector< double > &eBinBounds, const std::vector< double > &etaBinBounds, bool useAbsEta=true)
Definition: eflowEEtaBinnedParameters.cxx:33
eflowEEtaBinnedParameters::adjustLFI
eflowFirstIntENUM adjustLFI(double e, double eta, eflowFirstIntENUM j1st, bool useLegacyEnergyBinIndexing) const
Definition: eflowEEtaBinnedParameters.cxx:109
eflowFirstIntRegions::HEC
@ HEC
Definition: eflowCaloRegions.h:61
eflowFirstIntRegions::EME2
@ EME2
Definition: eflowCaloRegions.h:60
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
dqt_zlumi_pandas.bin1
bin1
Definition: dqt_zlumi_pandas.py:336
eflowFirstIntRegions::EMB2
@ EMB2
Definition: eflowCaloRegions.h:59
eflowFirstIntRegions::EME1
@ EME1
Definition: eflowCaloRegions.h:60
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
eflowEEtaBinnedParameters.h
eflowEEtaBinnedParameters::getInterpolation
double getInterpolation(const eflowParameters **bin1, const eflowParameters **bin2, double e, double eta, bool useLegacyEnergyBinIndexing) const
Definition: eflowEEtaBinnedParameters.cxx:52
eflowFirstIntRegions::J1STLAYER
J1STLAYER
Definition: eflowCaloRegions.h:58