TIMBER  beta
Tree Interface for Making Binned Events with RDataFrame
TopTag_SF.h
1 #ifndef _TIMBER_TOPTAG_SF
2 #define _TIMBER_TOPTAG_SF
3 #include <string>
4 #include <TFile.h>
5 #include <TH1F.h>
6 #include <TString.h>
7 #include <Math/Vector4Dfwd.h>
8 #include <Math/GenVector/LorentzVector.h>
9 #include <Math/GenVector/PtEtaPhiM4D.h>
10 #include "GenMatching.h"
11 using LVector = ROOT::Math::PtEtaPhiMVector;
12 
17 class TopTag_SF {
18  private:
19  std::string workpoint_name;
20  int _year;
21  std::map<int, std::map<std::string, TH1F*>> _hists;
22  TFile *_file;
23 
24  public:
32  TopTag_SF(int year, int workpoint, bool NoMassCut=false);
33  ~TopTag_SF(){};
45  int NMerged(LVector top_vect, RVec<Particle*> Ws,
46  RVec<Particle*> quarks, GenParticleTree GPT);
56  template <class T>
57  RVec<double> eval(LVector top_vect, std::vector<T> GenParts){
58  GenParticleTree GPT(GenParts.size());
59  // prongs are final particles we'll check
60  RVec<Particle*> Ws, quarks;
61  int this_pdgId;
62 
63  for (size_t i = 0; i < GenParts.size(); i++) {
64  Particle* this_particle = GPT.AddParticle(Particle(i,GenParts[i])); // add particle to tree
65  this_pdgId = this_particle->pdgId;
66  if (abs(this_pdgId) == 24) {
67  Ws.push_back(this_particle);
68  } else if (abs(this_pdgId) >= 1 && abs(this_pdgId) <= 5) {
69  quarks.push_back(this_particle);
70  }
71  }
72  int nMergedProngs = NMerged(top_vect, Ws, quarks, GPT);
73  std::vector<double> sfs(3);
74  if (nMergedProngs > 0){
75  if (top_vect.Pt() > 5000) {
76  sfs = {_hists[nMergedProngs]["nom"]->GetBinContent(_hists[nMergedProngs]["nom"]->GetNbinsX()),
77  _hists[nMergedProngs]["up"]->GetBinContent(_hists[nMergedProngs]["up"]->GetNbinsX()),
78  _hists[nMergedProngs]["down"]->GetBinContent(_hists[nMergedProngs]["down"]->GetNbinsX())
79  };
80  } else {
81  sfs = {_hists[nMergedProngs]["nom"]->GetBinContent(_hists[nMergedProngs]["nom"]->FindFixBin(top_vect.Pt())),
82  _hists[nMergedProngs]["up"]->GetBinContent(_hists[nMergedProngs]["up"]->FindFixBin(top_vect.Pt())),
83  _hists[nMergedProngs]["down"]->GetBinContent(_hists[nMergedProngs]["down"]->FindFixBin(top_vect.Pt()))
84  };
85  }
86  } else {
87  sfs = {1, 1, 1};
88  }
89  return sfs;
90  }
91 };
92 #endif
int NMerged(LVector top_vect, RVec< Particle *> Ws, RVec< Particle *> quarks, GenParticleTree GPT)
Finds the number of merged generator particles in the reconstructed jet.
Definition: TopTag_SF.cc:25
Particle * AddParticle(Particle particle)
Add particle to tree.
Definition: GenMatching.cc:73
C++ class. Stores identifying features of a particle in the GenPart collection.
Definition: GenMatching.h:38
C++ class. Constructs tree by adding particles. Establish relationships between particles (parent...
Definition: GenMatching.h:123
int pdgId
Definition: GenMatching.h:47
RVec< double > eval(LVector top_vect, std::vector< T > GenParts)
Evaluation function based on the reconstructed top jet pt and the matched generator particles (GenPar...
Definition: TopTag_SF.h:57
TopTag_SF(int year, int workpoint, bool NoMassCut=false)
Construct a new TopTag_SF object.
Definition: TopTag_SF.cc:3
C++ class to access scale factors associated with tau32+subjet btag(+mass) based top tagging...
Definition: TopTag_SF.h:17