ATLAS Offline Software
Loading...
Searching...
No Matches
Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7
9 std::stringstream tmpStream;
10 tmpStream << x;
11 return tmpStream.str();
12}
13
14
15int PanTau::HelperFunctions::getBinIndex(const std::vector<double>& binEdges, double value) const {
16 int resBin = -1;
17 for(unsigned int i=0; i<binEdges.size()-1; i++) {
18 double lowerEdge = binEdges[i];
19 double upperEdge = binEdges[i+1];
20 if(lowerEdge <= value && value < upperEdge) resBin = i;
21 }
22 if(resBin == -1) {
23 ATH_MSG_WARNING("Could not find matching bin for value " << value << " in these bin edges:");
24 for(unsigned int i=0; i<binEdges.size(); i++) ATH_MSG_WARNING("\tbin edge " << i << ": " << binEdges[i]);
25 }
26 return resBin;
27}
28
29
30double PanTau::HelperFunctions::stddev(double sumOfSquares, double sumOfValues, int numConsts) const {
31 // calculate standard deviations according to:
32 // sigma^2 = (sum_i x_i^2) / N - ((sum_i x_i)/N)^2 (biased maximum-likelihood estimate)
33 // directly set sigma^2 to 0 in case of N=1, otherwise numerical effects may yield very small negative sigma^2
34 if(numConsts == 1) return 0;
35 double a = sumOfSquares / (static_cast<double>(numConsts));
36 double b = sumOfValues / (static_cast<double>(numConsts));
37 double stdDev = a - b*b;
38 if(stdDev < 0.) stdDev = 0;
39 return std::sqrt(stdDev);
40}
41
#define ATH_MSG_WARNING(x)
static Double_t a
#define x
virtual double stddev(double sumOfSquares, double sumOfValues, int numConsts) const
virtual int getBinIndex(const std::vector< double > &binEdges, double value) const