TIMBER  beta
Tree Interface for Making Binned Events with RDataFrame
common.h
1 #include <ROOT/RVec.hxx>
2 
3 using namespace ROOT::VecOps;
4 namespace analyzer {
5  std::vector<float> HistLookup(TH1D* hist, float xval, float yval=0.0, float zval=0.0){
6  std::vector<float> out;
7 
8  int bin = hist->FindBin(xval,yval,zval);
9  float Weight = hist->GetBinContent(bin);
10  float Weightup = Weight + hist->GetBinErrorUp(bin);
11  float Weightdown = Weight - hist->GetBinErrorLow(bin);
12 
13  out.push_back(Weight);
14  out.push_back(Weightup);
15  out.push_back(Weightdown);
16  return out;
17  }
18 
19  float deltaPhi(float phi1,float phi2) {
20  float result = phi1 - phi2;
21  while (result > TMath::Pi()) result -= 2*TMath::Pi();
22  while (result <= -TMath::Pi()) result += 2*TMath::Pi();
23  return result;
24  }
25 
26  ROOT::Math::PtEtaPhiMVector TLvector(float pt,float eta,float phi,float m) {
27  ROOT::Math::PtEtaPhiMVector v(pt,eta,phi,m);
28  return v;
29  }
30 
31  double invariantMass(ROOT::Math::PtEtaPhiMVector v1, ROOT::Math::PtEtaPhiMVector v2) {
32  return (v1+v2).M();
33  }
34  double invariantMass(int idx1, int idx2, RVec<float> pts, RVec<float> etas, RVec<float> phis, RVec<float> masses) {
35  ROOT::Math::PtEtaPhiMVector v1, v2;
36  v1.SetCoordinates(pts[idx1],etas[idx1],phis[idx1],masses[idx1]);
37  v2.SetCoordinates(pts[idx2],etas[idx2],phis[idx2],masses[idx2]);
38  return invariantMass(v1,v2);
39  }
40 
41  double invariantMassThree(ROOT::Math::PtEtaPhiMVector v1, ROOT::Math::PtEtaPhiMVector v2, ROOT::Math::PtEtaPhiMVector v3) {
42  return (v1+v2+v3).M();
43  }
44 
45  float HT(std::vector<int> pts) {
46  float ht = 0.0;
47  for(int pt : pts) {
48  ht = ht + pt;
49  }
50  return ht;
51  }
52 
53 }
Definition: hemispherize.cc:10