ATLAS Offline Software
Loading...
Searching...
No Matches
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
7NAME: eflowRingSubtractionManager.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
20
21#include <cmath>
22#include <list>
23
24
25using std::vector;
26
28
29double 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++) {
93 weight = ringMeanRank(param.getShapeParameters(layer), iRing*ringThickness[layer], (iRing+1)*ringThickness[layer]);
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
103bool 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 */
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.
122 ringThicknesses[i] = eflowRingThicknesses::ringThickness((eflowCaloENUM) i);
123 }
124
125 setParameters(meanBin, ringThicknesses);
126 return true;
127}
Scalar eta() const
pseudorapidity method
This defines the eflowCalo enum, which is used to label calorimeter layers in a simplified scheme whi...
static const int nRegions
Inherits from eflowEEtaBinBase.
eflowFirstIntENUM adjustLFI(double e, double eta, eflowFirstIntENUM j1st, bool useLegacyEnergyBinIndexing) const
double getInterpolation(const eflowParameters **bin1, const eflowParameters **bin2, double e, double eta, bool useLegacyEnergyBinIndexing) const
Extends eflowFirstInt to include parameters of the fits to radial shower profiles.
double getShapeParameter(eflowCaloENUM layer, int paramIndex) const
bool getWeightedParameters(const eflowFirstIntParameters *bin1, const eflowFirstIntParameters *bin2, const double w1)
const std::vector< double > & getShapeParameters(eflowCaloENUM layer) const
double fudgeMean() const
double fudgeStdDev() const
static std::vector< eflowCaloENUM > orderedLayersByShowerParam(const eflowFirstIntParameters &param, unsigned int whichParam=0)
static double ringMeanRank(const std::vector< double > &p, double rMin, double rMax)
bool getOrdering(const eflowEEtaBinnedParameters *binnedParameters, double e, double eta, eflowFirstIntENUM j1st, bool useLegacyEnergyBinIndexing)
double ringThickness(eflowCaloENUM layer) const
std::map< double, RingId > m_rankMap
void setParameters(const eflowFirstIntParameters &param, const std::vector< double > &ringThickness)
static double ringThickness(const eflowCaloENUM &layer)
eflowCalo::LAYER eflowCaloENUM
eflowFirstIntRegions::J1STLAYER eflowFirstIntENUM
std::pair< eflowCaloENUM, short > RingId