ATLAS Offline Software
Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "Math/SpecFuncMathMore.h"
8 #include "TMath.h"
9 #include "TLorentzVector.h"
10 #include "TVector3.h"
11 #include <vector>
12 #include <sstream>
13 #include <cmath>
14 
15 
17  const std::vector<PanTau::TauConstituent*>& neutral) {
18  if(neutral.empty()) return nullptr;
19  //loop through neutrals to find the one with largest angle
20  unsigned int idx_Neutral = -1;
21  double angle_Neutral = -1.;
22  for(unsigned int iNeut=0; iNeut<neutral.size(); iNeut++) {
23  TLorentzVector tlv_CurNeut = neutral[iNeut]->p4();
24  double angle = charged.Angle(tlv_CurNeut.Vect());
25  if(angle > angle_Neutral) {
26  angle_Neutral = angle;
27  idx_Neutral = iNeut;
28  }
29  }//end loop neutrals
30 
31  return neutral[idx_Neutral];
32 }
33 
34 
36  std::stringstream tmpStream;
37  tmpStream << x;
38  return tmpStream.str();
39 }
40 
41 
42 int PanTau::HelperFunctions::getBinIndex(const std::vector<double>& binEdges, double value) const {
43  int resBin = -1;
44  for(unsigned int i=0; i<binEdges.size()-1; i++) {
45  double lowerEdge = binEdges[i];
46  double upperEdge = binEdges[i+1];
47  if(lowerEdge <= value && value < upperEdge) resBin = i;
48  }
49  if(resBin == -1) {
50  ATH_MSG_WARNING("Could not find matching bin for value " << value << " in these bin edges:");
51  for(unsigned int i=0; i<binEdges.size(); i++) ATH_MSG_WARNING("\tbin edge " << i << ": " << binEdges[i]);
52  }
53  return resBin;
54 }
55 
56 
57 double PanTau::HelperFunctions::stddev(double sumOfSquares, double sumOfValues, int numConsts) const {
58  // calculate standard deviations according to:
59  // sigma^2 = (sum_i x_i^2) / N - ((sum_i x_i)/N)^2 (biased maximum-likelihood estimate)
60  // directly set sigma^2 to 0 in case of N=1, otherwise numerical effects may yield very small negative sigma^2
61  if(numConsts == 1) return 0;
62  double a = sumOfSquares / ((double)numConsts);
63  double b = sumOfValues / ((double)numConsts);
64  double stdDev = a - b*b;
65  if(stdDev < 0.) stdDev = 0;
66  return std::sqrt(stdDev);
67 }
68 
69 
70 double PanTau::HelperFunctions::deltaRprime(const TVector3& vec1, const TVector3& vec2) const {
71  const double a = vec1.DeltaPhi(vec2);
72  const double b = vec1.Theta() - vec2.Theta();
73  double dRprime = std::sqrt(a*a + b*b);
74  return dRprime;
75 }
76 
D3PDMakerTestInstan::vec2
std::vector< D3PDTest::MyVec2 > vec2
Definition: D3PDMakerTestDict.h:14
HelperFunctions.h
athena.value
value
Definition: athena.py:124
x
#define x
PanTau::HelperFunctions::deltaRprime
virtual double deltaRprime(const TVector3 &vec1, const TVector3 &vec2) const
Definition: Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx:70
TauConstituent.h
PanTau::HelperFunctions::getNeutralConstWithLargestAngle
static TauConstituent * getNeutralConstWithLargestAngle(const TLorentzVector &charged, const std::vector< PanTau::TauConstituent * > &neutral)
Definition: Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx:16
lumiFormat.i
int i
Definition: lumiFormat.py:85
PanTau::HelperFunctions::getBinIndex
virtual int getBinIndex(const std::vector< double > &binEdges, double value) const
Definition: Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx:42
angle
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
Definition: TRTDetectorFactory_Full.cxx:73
PanTau::HelperFunctions::convertNumberToString
virtual std::string convertNumberToString(double x) const
Definition: Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx:35
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
CP::neutral
@ neutral
Definition: Reconstruction/PFlow/PFlowUtils/PFlowUtils/PFODefs.h:11
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
a
TList * a
Definition: liststreamerinfos.cxx:10
PanTau::HelperFunctions::stddev
virtual double stddev(double sumOfSquares, double sumOfValues, int numConsts) const
Definition: Reconstruction/PanTau/PanTauAlgs/Root/HelperFunctions.cxx:57
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
PanTau::TauConstituent
Definition: TauConstituent.h:25
CP::charged
@ charged
Definition: Reconstruction/PFlow/PFlowUtils/PFlowUtils/PFODefs.h:11