DESY Hbb Analysis Framework
SignalEffTrigger.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <vector>
4 
5 #include "TFile.h"
6 #include "TFileCollection.h"
7 #include "TChain.h"
8 #include "TH1.h"
9 #include "TGraphAsymmErrors.h"
10 
12 
13 using namespace std;
14 using namespace analysis;
15 using namespace analysis::tools;
16 
17 
18 // =============================================================================================
19 int main(int argc, char * argv[])
20 {
21  TH1::SetDefaultSumw2(); // proper treatment of errors when scaling histograms
22 
23  // Input files list
24  std::string inputList = "rootFileList.txt";
25  Analysis analysis(inputList,"MssmHbbTrigger/Events/EventInfo");
26 
27  // Physics Objects Collections
28  analysis.triggerResults("MssmHbb/Events/TriggerResults");
29  std::string hltPath = "HLT_DoubleJetsC100_DoubleBTagCSV_p014_DoublePFJetsC100MaxDeta1p6_v";
30 
31  // BTag
32  analysis.addTree<JetTag> ("JetsTags","MssmHbbTrigger/Events/hltCombinedSecondaryVertexBJetTagsCalo");
33 
34 
35  // Trigger objects
36  std::vector<std::string> jetTriggerObjects;
37  jetTriggerObjects.push_back("hltL1sDoubleJetC100");
38  jetTriggerObjects.push_back("hltDoubleJetsC100");
39  jetTriggerObjects.push_back("hltSingleBTagCSV0p84");
40  jetTriggerObjects.push_back("hltJetC350");
41 
42 // std::string trgobj_path = "MssmHbbTrigger/Events/selectedPatTrigger/";
43 // for ( auto & obj : jetTriggerObjects )
44 // analysis.addTree<TriggerObject>(obj,trgobj_path+obj);
45 
46  TH1F * h_total = new TH1F("h_total","",70,0,70);
47  TH1F * h_selected = new TH1F("h_selected","",70,0,70);
48 
49  // Analysis of events
50  std::cout << "This analysis has " << analysis.size() << " events" << std::endl;
51  for ( int i = 0 ; i < analysis.size() ; ++i )
52  {
53  analysis.event(i);
54 
55 // std::cout << "++++++ ENTRY " << i;
56 // std::cout << std::endl;
57 
58  int nPU = analysis.nPileup();
59 
60  h_total -> Fill(nPU);
61 
62  // Trigger results: fired and prescales
63  // hltPath
64  if ( ! analysis.triggerResult(hltPath) ) continue;
65 
66  std::shared_ptr< Collection<JetTag> > jetstags = analysis.collection<JetTag>("JetsTags");
67  std::vector<JetTag> jetstagswp092;
68  for ( int jt = 0; jt < jetstags->size() ; ++jt )
69  {
70  JetTag jet = jetstags->at(jt);
71  if ( jet.pt() >= 80 )
72  {
73  if ( jet.btag() >= 0.92 ) jetstagswp092.push_back(jet);
74  }
75  }
76 
77  if ( jetstagswp092.size() < 2 ) continue;
78 
79  h_selected -> Fill(nPU);
80  }
81 
82  TGraphAsymmErrors * g_eff = new TGraphAsymmErrors(h_selected,h_total,"cl=0.683 b(1,1) mode");
83 
84  TFile * out = new TFile("signalEffTrigger.root","recreate");
85  h_total -> Write();
86  h_selected -> Write();
87  g_eff -> Write();
88 
89  out->Close();
90 
91 //
92 }
93 
std::shared_ptr< Collection< Object > > collection(const std::string &unique_name)
Definition: Analysis.h:336
float btag() const
returns the btag value of btag_csvivf
Definition: JetTag.cc:38
int main(int argc, char *argv[])
bool triggerResult(const std::string &trig)
Definition: Analysis.cc:190
float pt() const
returns the transverse momentum
Definition: Candidate.cc:133
bool triggerResults(const std::string &path)
Definition: Analysis.cc:162
void event(const int &event, const bool &addCollections=true)
Definition: Analysis.cc:94
std::shared_ptr< PhysicsObjectTree< Object > > addTree(const std::string &unique_name, const std::string &path)
Definition: Analysis.h:273