ATLAS Offline Software
Loading...
Searching...
No Matches
BichselData.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
5 #include "BichselData.h"
6 #include <cmath> //for pow
7 #include <algorithm> //for std::clamp
8
9
10
11double
13 if (not logBetaGammaVector.empty()){
14 return logBetaGammaVector.back();
15 } else {
16 return std::numeric_limits<double>::quiet_NaN();
17 }
18}
19
20
21void
23
24 if (not empty()) {
26 }
27 logBetaGammaVector.push_back(logBetaGamma);
28 //insert empty arrays
31}
32
33void
34BichselData::addEntry(double logBetaGamma, double logCollisionEnergy, double logIntegratedCrossSection){
35 if (empty() or (lastBetaGammaValue() != logBetaGamma)) { // a new BetaGamma
36 addNewLogBetaGamma(logBetaGamma);
37 }
38 logCollisionEnergyVectorOfVector.back().push_back(logCollisionEnergy);
39 logIntegratedCrossSectionsVectorOfVector.back().push_back(logIntegratedCrossSection);
40}
41
45
46
47 //=======================================
48// B E T A G A M M A I N D E X
49//=======================================
50std::pair<int, int>
51BichselData::getBetaGammaIndices(double BetaGammaLog10) const {
52 std::pair<int, int> indices_BetaGammaLog10;
53 if (empty()) return {-1,-1};
54 if (BetaGammaLog10 > logBetaGammaVector.back()) { // last one is used because when beta-gamma is very large,
55 // energy deposition behavior is very similar
56 indices_BetaGammaLog10.first = logBetaGammaVector.size() - 1;
57 indices_BetaGammaLog10.second = logBetaGammaVector.size() - 1;
58 } else {
59 indices_BetaGammaLog10 =PixelDigitization::fastSearch(logBetaGammaVector, BetaGammaLog10);
60 }
61
62 return indices_BetaGammaLog10;
63}
64
65
66
67
68//==========================================
69// G E T C O L L I S I O N E N E R G Y
70//==========================================
71//Interpolate collision energy
72double
73BichselData::interpolateCollisionEnergy(std::pair<int, int> indices_BetaGammaLog10, double IntXLog10) const {
74 if ((indices_BetaGammaLog10.first == -1) && (indices_BetaGammaLog10.second == -1)) return -1.;
75 if (empty()) return -1.;
76
77
78 // BetaGammaLog10_2 then
79 std::pair<int, int> indices_IntXLog10_x2 =
80 PixelDigitization::fastSearch(logIntegratedCrossSectionsVectorOfVector[indices_BetaGammaLog10.second], IntXLog10);
81 if (indices_IntXLog10_x2.first < 0) {
82 return -1;
83 }
84 if (indices_IntXLog10_x2.second < 0) {
85 return -1;
86 }
87
88 double y21 = logIntegratedCrossSectionsVectorOfVector.at(indices_BetaGammaLog10.second).at(indices_IntXLog10_x2.first);
89 double y22 = logIntegratedCrossSectionsVectorOfVector.at(indices_BetaGammaLog10.second).at(indices_IntXLog10_x2.second);
90 const auto diff = y22 - y21;
91 if (diff<1e-300){
92 //these are the same value
93 return -1;
94 }
95 double Est_x2 =
96 ((y22 - IntXLog10) *
97 logCollisionEnergyVectorOfVector[indices_BetaGammaLog10.second][indices_IntXLog10_x2.first] +
98 (IntXLog10 - y21) *
99 logCollisionEnergyVectorOfVector[indices_BetaGammaLog10.second][indices_IntXLog10_x2.second]) / diff;
100 double Est = std::clamp(Est_x2,-300.,300.);
101 return std::pow(10., Est);
102}
103
104//===========================================
105// Overloaded C O L L I S I O N E N E R G Y
106//===========================================
107double
108BichselData::interpolateCollisionEnergy(double BetaGammaLog10, double IntXLog10) const {
109 std::pair<int, int> indices_BetaGammaLog10 = getBetaGammaIndices(BetaGammaLog10);
110 return interpolateCollisionEnergy(indices_BetaGammaLog10, IntXLog10);
111}
112
113//==========================================
114// G E T U P P E R B O U N D BETA GAMMA
115//==========================================
116double
117BichselData::interpolateCrossSection(std::pair<int, int> indices_BetaGammaLog10, double BetaGammaLog10) const {
118 if (empty()) return -1;
119 if (indices_BetaGammaLog10.first < 0) {
120 return -1;
121 }
122 if (indices_BetaGammaLog10.second < 0) {
123 return -1;
124 }
125 if (indices_BetaGammaLog10.second == indices_BetaGammaLog10.first){ //either an exact value or the last one in the table
126 return std::pow(10., logHighestCrossSectionsVector.at(indices_BetaGammaLog10.first));
127 }
128 double BetaGammaLog10_1 = logBetaGammaVector.at(indices_BetaGammaLog10.first);
129 double BetaGammaLog10_2 = logBetaGammaVector.at(indices_BetaGammaLog10.second);
130
131 // obtain estimation
132 double Est_1 = logHighestCrossSectionsVector.at(indices_BetaGammaLog10.first);
133 double Est_2 = logHighestCrossSectionsVector.at(indices_BetaGammaLog10.second);
134
135 // final estimation
136 const auto diff=BetaGammaLog10_2 - BetaGammaLog10_1;
137 if (diff<1e-300){
138 return -1;
139 }
140 double Est = ((BetaGammaLog10_2 - BetaGammaLog10) * Est_1 + (BetaGammaLog10 - BetaGammaLog10_1) * Est_2) /diff;
141 Est = std::clamp(Est,-300.,300.);
142 return std::pow(10., Est);
143
144
145}
146//==========================================
147// overloaded G E T U P P E R B O U N D
148//==========================================
149double
150BichselData::interpolateCrossSection(double BetaGammaLog10) const {
151 std::pair<int, int> indices_BetaGammaLog10 = getBetaGammaIndices(BetaGammaLog10);
152 return interpolateCrossSection(indices_BetaGammaLog10, BetaGammaLog10);
153}
154
155
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Definition Jet.cxx:631
std::pair< int, int > fastSearch(const std::vector< double > &vec, double item)
std::vector< std::vector< double > > logIntegratedCrossSectionsVectorOfVector
Definition BichselData.h:18
void addEntry(double logBetaGamma, double logCollisionEnergy, double logIntegratedCrossSection)
std::vector< std::vector< double > > logCollisionEnergyVectorOfVector
Definition BichselData.h:17
void updateAfterLastEntry()
double interpolateCrossSection(std::pair< int, int > indices_BetaGammaLog10, double BetaGammaLog10) const
std::pair< int, int > getBetaGammaIndices(double BetaGammaLog10) const
bool empty() const
Definition BichselData.h:22
std::vector< double > logHighestCrossSectionsVector
Definition BichselData.h:19
double lastBetaGammaValue() const
double interpolateCollisionEnergy(std::pair< int, int > indices_BetaGammaLog10, double IntXLog10) const
std::vector< double > logBetaGammaVector
Definition BichselData.h:16
void addNewLogBetaGamma(double logBetaGamma)