ATLAS Offline Software
Loading...
Searching...
No Matches
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
7NAME: eflowEEtaBinnedParameters.h
8PACKAGE: offline/Reconstruction/eflowRec
9
10AUTHORS: M.Hodgkinson, R Duxfield (based on R.Duxfields Root package)
11CREATED: 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
27using namespace std;
29// eflowEEtaBinnedParameters //
31
32
33void 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}
Scalar eta() const
pseudorapidity method
int getEBinIndexLegacy(double e) const
int getEtaBinIndex(double eta) const
int getEBinIndex(double e) const
std::vector< double > m_etaBinBounds
int getNumEtaBins() const
int getNumEBins() const
std::vector< double > m_eBinBounds
eflowFirstIntENUM adjustLFI(double e, double eta, eflowFirstIntENUM j1st, bool useLegacyEnergyBinIndexing) const
std::vector< std::vector< std::unique_ptr< eflowParameters > > > m_bins
void initialise(const std::vector< double > &eBinBounds, const std::vector< double > &etaBinBounds, bool useAbsEta=true)
double getInterpolation(const eflowParameters **bin1, const eflowParameters **bin2, double e, double eta, bool useLegacyEnergyBinIndexing) const
eflowFirstIntRegions::J1STLAYER eflowFirstIntENUM
STL namespace.