ATLAS Offline Software
eflowRingSubtractionManager.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: eflowRingSubtractionManager.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
20 
21 #include <cmath>
22 #include <list>
23 
24 
25 using std::vector;
26 
27 eflowRingSubtractionManager::eflowRingSubtractionManager() : m_ringThickness(eflowCalo::nRegions), m_fudgeMean(0), m_fudgeStdDev(-1) {}
28 
29 double eflowRingSubtractionManager::ringMeanRank(const vector<double>& p, double rMin, double rMax) {
30 
31  double x1 = 0.0;
32  double x2 = 0.0;
33 
34  if (0 != p[1] && 0 != p[3]){
35  x1 = exp(-rMin / p[1]) - exp(-rMax / p[1]);
36  x2 = exp(-rMin / p[3]) - exp(-rMax / p[3]);
37  }
38 
39  return (p[0] * p[1] * x1 + p[2] * p[3] * x2) / (rMax - rMin); // hard coded 4-param model for now
40 }
41 
43  const eflowFirstIntParameters& param, unsigned int whichParam) {
44  /* Prepare a vector of calo layers which is ordered by the p0 parameter */
45  /* First prepare a list of all layers (which are not eflowCalo::Unknown i.e. 999) */
46  std::list<eflowCaloENUM> allLayers;
47  for (int iLayer = 0; iLayer < eflowCalo::nRegions; iLayer++) {
48  if (iLayer != eflowCalo::Unknown) {
49  allLayers.push_back((eflowCaloENUM) (iLayer));
50  }
51  }
52  /* Loop over the list to find the layer with highest p0.
53  * Attach it to the end of the ordered vector and remove it from the list.
54  * Repeat until the list is empty */
55  std::vector<eflowCaloENUM> orderedLayers;
56  while (!allLayers.empty()) {
57  std::list<eflowCaloENUM>::iterator itLayer = allLayers.begin();
58  std::list<eflowCaloENUM>::iterator itMaxP0Layer = itLayer;
59  double p0Max = param.getShapeParameter(*itMaxP0Layer, whichParam);
60  /* Get current highest p0-layer */
61  for (; itLayer != allLayers.end(); ++itLayer) {
62  double p0 = param.getShapeParameter(*itLayer, whichParam);
63  if (p0 > p0Max) {
64  itMaxP0Layer = itLayer;
65  p0Max = p0;
66  }
67  }
68  /* Attach to vector and remove from list */
69  orderedLayers.push_back(*itMaxP0Layer);
70  allLayers.erase(itMaxP0Layer);
71  }
72  return orderedLayers;
73 }
74 
76  /* Prepare a vector of calo layers which is ordered by the p0 parameter */
77  std::vector<eflowCaloENUM> orderedLayers = orderedLayersByShowerParam(param, 0);
78 
79  /* Set e/p and ring thicknesses */
80  m_fudgeMean = param.fudgeMean();
81  m_fudgeStdDev = param.fudgeStdDev();
83 
84  /* Populate the ring/rank map */
85  m_rankMap.clear();
86  double weight;
87  double weightMax = ringMeanRank(param.getShapeParameters(orderedLayers[0]), 0.0, ringThickness[orderedLayers[0]])/m_weightRange;
88  for (const auto & layer : orderedLayers) {
89  /* Add weights to map (map does the ordering) */
90  const int nRings = (int)(m_rMax / ringThickness[layer]);
91 
92  for (int iRing = 0; iRing < nRings; iRing++) {
94  if (weight == 0 || weight < weightMax) {
95  break; // only add weights within a factor (range) of weightMax (say 10^6)
96  } else {
97  m_rankMap[1.0/weight] = RingId(layer, iRing);
98  }
99  }
100  }
101 }
102 
103 bool eflowRingSubtractionManager::getOrdering(const eflowEEtaBinnedParameters* binnedParameters, double e, double eta, eflowFirstIntENUM j1st, bool useLegacyEnergyBinIndexing) {
104  const eflowParameters* bin1 = nullptr;
105  const eflowParameters* bin2 = nullptr;
106 
107  /* Get the left- and right-bin given (e,eta), return the weight of the two bins and fill the bins to &bin1 and &bin2 */
108  double weight = binnedParameters->getInterpolation(&bin1, &bin2, e, eta, useLegacyEnergyBinIndexing);
109  if (!(bin1 && bin2)) { return false; }
110 
111  eflowFirstIntENUM adjustedJ1st = binnedParameters->adjustLFI(e, eta, j1st, useLegacyEnergyBinIndexing);
112 
113  /* Interpolate the firstInBins */
114  eflowFirstIntParameters meanBin;
115  bool isFailed = !(meanBin.getWeightedParameters(bin1->getFirstIntBin(adjustedJ1st), bin2->getFirstIntBin(adjustedJ1st), weight));
116  if (isFailed) { return false; }
117 
118  /* Set the ring thicknesses */
119  std::vector<double> ringThicknesses(eflowCalo::nRegions);
120  for (int i = 0; i < eflowCalo::nRegions; i++) {
121  //This was reviously interpolated - but the ring thickeness is a geometric property of the calorimeter without any energy dependence, so it was not needed.
123  }
124 
125  setParameters(meanBin, ringThicknesses);
126  return true;
127 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
eflowRingSubtractionManager::setParameters
void setParameters(const eflowFirstIntParameters &param, const std::vector< double > &ringThickness)
Definition: eflowRingSubtractionManager.cxx:75
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
eflowEEtaBinnedParameters
Inherits from eflowEEtaBinBase.
Definition: eflowEEtaBinnedParameters.h:56
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
eflowCalo
This defines the eflowCalo enum, which is used to label calorimeter layers in a simplified scheme whi...
Definition: eflowCaloRegions.h:25
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
eflowCalo::Unknown
@ Unknown
Definition: eflowCaloRegions.h:50
eflowRingSubtractionManager::m_ringThickness
std::vector< double > m_ringThickness
Definition: eflowRingSubtractionManager.h:60
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
eflowRingSubtractionManager::orderedLayersByShowerParam
static std::vector< eflowCaloENUM > orderedLayersByShowerParam(const eflowFirstIntParameters &param, unsigned int whichParam=0)
Definition: eflowRingSubtractionManager.cxx:42
eflowFirstIntParameters.h
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
eflowRingSubtractionManager::m_fudgeMean
double m_fudgeMean
Definition: eflowRingSubtractionManager.h:61
eflowFirstIntParameters::getWeightedParameters
bool getWeightedParameters(const eflowFirstIntParameters *bin1, const eflowFirstIntParameters *bin2, const double w1)
Definition: eflowFirstIntParameters.cxx:31
beamspotman.isFailed
bool isFailed
Definition: beamspotman.py:1042
eflowFirstInt::fudgeStdDev
double fudgeStdDev() const
Definition: eflowFirstInt.h:40
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
eflowRingThicknesses.h
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
eflowRingThicknesses::ringThickness
static double ringThickness(const eflowCaloENUM &layer)
Definition: eflowRingThicknesses.cxx:5
lumiFormat.i
int i
Definition: lumiFormat.py:85
vector< double >
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
eflowFirstIntParameters::getShapeParameters
const std::vector< double > & getShapeParameters(eflowCaloENUM layer) const
Definition: eflowFirstIntParameters.h:45
eflowParameters
Definition: eflowEEtaBinnedParameters.h:30
bin2
Definition: KillBinsByStrip.h:34
eflowRingSubtractionManager.h
eflowRingSubtractionManager::ringMeanRank
static double ringMeanRank(const std::vector< double > &p, double rMin, double rMax)
Definition: eflowRingSubtractionManager.cxx:29
eflowEEtaBinnedParameters::adjustLFI
eflowFirstIntENUM adjustLFI(double e, double eta, eflowFirstIntENUM j1st, bool useLegacyEnergyBinIndexing) const
Definition: eflowEEtaBinnedParameters.cxx:109
eflowRingSubtractionManager::m_fudgeStdDev
double m_fudgeStdDev
Definition: eflowRingSubtractionManager.h:62
eflowFirstInt::fudgeMean
double fudgeMean() const
Definition: eflowFirstInt.h:39
eflowRingSubtractionManager::getOrdering
bool getOrdering(const eflowEEtaBinnedParameters *binnedParameters, double e, double eta, eflowFirstIntENUM j1st, bool useLegacyEnergyBinIndexing)
Definition: eflowRingSubtractionManager.cxx:103
eflowCalo::nRegions
static const int nRegions
Definition: eflowCaloRegions.h:45
RingId
std::pair< eflowCaloENUM, short > RingId
Definition: eflowRingSubtractionManager.h:24
eflowRingSubtractionManager::m_weightRange
static constexpr double m_weightRange
Definition: eflowRingSubtractionManager.h:65
eflowCalo::LAYER
LAYER
Definition: eflowCaloRegions.h:36
dqt_zlumi_pandas.bin1
bin1
Definition: dqt_zlumi_pandas.py:336
eflowRingSubtractionManager::m_rankMap
std::map< double, RingId > m_rankMap
Definition: eflowRingSubtractionManager.h:59
eflowFirstIntParameters::getShapeParameter
double getShapeParameter(eflowCaloENUM layer, int paramIndex) const
Definition: eflowFirstIntParameters.h:46
eflowRingSubtractionManager::m_rMax
static constexpr double m_rMax
Definition: eflowRingSubtractionManager.h:64
eflowRingSubtractionManager::eflowRingSubtractionManager
eflowRingSubtractionManager()
Definition: eflowRingSubtractionManager.cxx:27
eflowFirstIntParameters
Extends eflowFirstInt to include parameters of the fits to radial shower profiles.
Definition: eflowFirstIntParameters.h:28
eflowEEtaBinnedParameters.h
TRTCalib_cfilter.p0
p0
Definition: TRTCalib_cfilter.py:129
eflowRingSubtractionManager::ringThickness
double ringThickness(eflowCaloENUM layer) const
Definition: eflowRingSubtractionManager.h:47
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