ra4_macros  bede988c286599a3a84b77a4d788ac0a971e89f9
plot_gamma.cxx
Go to the documentation of this file.
1 // plot_trigger: Plots for the trigger section of the RA4 note
2 
3 #include <iostream>
4 #include <vector>
5 #include <ctime>
6 
7 #include "TMath.h"
8 #include "TChain.h"
9 #include "TH1D.h"
10 #include "TCanvas.h"
11 #include "TLegend.h"
12 #include "TLine.h"
13 #include "TString.h"
14 #include "TRandom3.h"
15 #include "TGraphAsymmErrors.h"
16 
17 #include "styles.hpp"
18 #include "utilities.hpp"
19 #include "utilities_macros.hpp"
20 
21 using namespace std;
22 
23 int main(){
24  time_t begtime, endtime;
25  time(&begtime);
26  TString folder="/afs/cern.ch/user/m/manuelf/work/ucsb/2015_05_25/skim/";
27  vector<TString> s_tt;
28  s_tt.push_back(folder+"*_TTJet*");
29  vector<TString> s_singlet;
30  s_singlet.push_back(folder+"*_T*t-channel*");
31  s_singlet.push_back(folder+"*_T*s-channel*");
32  s_singlet.push_back(folder+"*_T*W-channel*");
33  vector<TString> s_other;
34  s_other.push_back(folder+"*QCD_HT*");
35  s_other.push_back(folder+"*_ZJet*");
36  s_other.push_back(folder+"*DY*");
37  s_other.push_back(folder+"*WH_HToBB*");
38  s_other.push_back(folder+"*TTW*");
39  s_other.push_back(folder+"*TTZ*");
40  s_other.push_back(folder+"*_WJets*");
41 
42  // Reading ntuples
43  vector<sfeats> Samples;
44  Samples.push_back(sfeats(s_tt, "t#bar{t}, 2 l", ra4::c_tt_2l,1));
45  Samples.push_back(sfeats(s_singlet, "Single t", ra4::c_singlet));
46  Samples.push_back(sfeats(s_other, "Other", ra4::c_other, 1));
47 
48  vector<TChain *> chain;
49  for(unsigned sam(0); sam < Samples.size(); sam++){
50  chain.push_back(new TChain("tree"));
51  for(unsigned insam(0); insam < Samples[sam].file.size(); insam++)
52  chain[sam]->Add(Samples[sam].file[insam]);
53  }
54 
55  vector<int> ra4_sam;
56  unsigned nsam(Samples.size());
57  for(unsigned sam(0); sam < nsam; sam++){
58  ra4_sam.push_back(sam);
59  } // Loop over samples
60 
61 
62  vector<vector<float> > entries;
63  vector<vector<float> > weights;
64  vector<float> powers;
65  vector<TString> cuts;
66 
67  // TString baseline("(nmus+nels)==1&&ht>500&&met>200&&njets>=7&&nbm>=2");
68  // TString bincut("met>400"), totcut, lumi("10");
69  // powers.push_back(-1); cuts.push_back("mt<=140&&mj<=400"); // R1
70  // powers.push_back(1); cuts.push_back("mt>140&&mj<=400"); // R3
71 
72 
73  // for(unsigned obs(0); obs < powers.size(); obs++) {
74  // entries.push_back(vector<float>());
75  // weights.push_back(vector<float>());
76  // float yield_singlet(0);
77  // for(unsigned sam(0); sam < ra4_sam.size(); sam++) {
78  // totcut = (lumi+"*weight*("+baseline+"&&"+bincut+"&&"+cuts[obs]+
79  // "&&"+Samples[ra4_sam[sam]].cut+")");
80  // //cout << totcut<<endl;
81  // double yield(0.), sigma(0.), avWeight(1.);
82  // int Nentries(0);
83  // Nentries = getYieldErr(*chain[ra4_sam[sam]], totcut, yield, sigma);
84  // // Zero-ing out the single t, not adding its uncertainty
85  // if(Samples[ra4_sam[sam]].label=="Single t"){
86  // if(yield>0) yield_singlet = yield;
87  // continue;
88  // }
89  // if(Samples[ra4_sam[sam]].label=="Other") yield += yield_singlet;
90  // if(yield<=0) entries[obs].push_back(0);
91  // //else entries[obs].push_back(yield*yield/pow(sigma,2));
92  // else entries[obs].push_back(yield);
93  // if(Nentries==0){ // If no entries, find averate weight in signal bin
94  // totcut = (lumi+"*weight*("+baseline+"&&"+cuts[obs]+")");
95  // Nentries = getYieldErr(*chain[ra4_sam[sam]], totcut, yield, sigma);
96  // // If no entries, find averate weight in baseline region
97  // if(Nentries==0){
98  // totcut = (lumi+"*weight*("+baseline+")");
99  // Nentries = getYieldErr(*chain[ra4_sam[sam]], totcut, yield, sigma);
100  // }
101  // }
102  // avWeight = sigma*sigma/yield;
103  // avWeight = 1;
104  // weights[obs].push_back(avWeight);
105  // //cout<<obs<<","<<sam<<": entries "<<entries[obs][sam]<<", weight "<<avWeight<<", yield "<<yield<<endl;
106  // } // Loop over samples
107  // } // Loop over number of observables going into kappa
108 
109 
110  entries.push_back(vector<float>());
111  entries[0].push_back(4);
112  entries.push_back(vector<float>());
113  entries[1].push_back(5);
114  entries.push_back(vector<float>());
115  entries[2].push_back(0);
116 
117  weights.push_back(vector<float>());
118  weights[0].push_back(1.);
119  weights.push_back(vector<float>());
120  weights[1].push_back(1.);
121  weights.push_back(vector<float>());
122  weights[2].push_back(1.);
123  weights.push_back(vector<float>());
124  weights[3].push_back(1.);
125 
126  powers.push_back(-1.);
127  powers.push_back(1.);
128  powers.push_back(1.);
129  // powers.push_back(-1.);
130 
131 
132  float mSigma, pSigma;
133  calcKappa(entries, weights, powers, mSigma, pSigma, true, true, true);
134  time(&endtime);
135  cout<<endl<<"Calculation took "<<difftime(endtime, begtime)<<" seconds"<<endl<<endl;
136 }
137 
STL namespace.
int main()
Definition: plot_gamma.cxx:23
tuple file
Definition: parse_card.py:238
double calcKappa(std::vector< std::vector< float > > &entries, std::vector< std::vector< float > > &weights, std::vector< float > &powers, float &mSigma, float &pSigma, bool do_data=false, bool verbose=false, bool do_plot=false, int nrep=100000)