1 |
buchmann |
1.1 |
#include <iostream>
|
2 |
|
|
#include <vector>
|
3 |
|
|
#include <sys/stat.h>
|
4 |
|
|
|
5 |
|
|
#include <TCut.h>
|
6 |
|
|
#include <TROOT.h>
|
7 |
|
|
#include <TCanvas.h>
|
8 |
|
|
#include <TMath.h>
|
9 |
|
|
#include <TColor.h>
|
10 |
|
|
#include <TPaveText.h>
|
11 |
|
|
#include <TRandom.h>
|
12 |
|
|
#include <TH1.h>
|
13 |
|
|
#include <TH2.h>
|
14 |
|
|
#include <TF1.h>
|
15 |
|
|
#include <TSQLResult.h>
|
16 |
|
|
#include <TProfile.h>
|
17 |
|
|
#include <TLegendEntry.h>
|
18 |
|
|
|
19 |
|
|
using namespace std;
|
20 |
|
|
|
21 |
buchmann |
1.3 |
string IdentifierForUnderlinedEntry(string Entry) {
|
22 |
|
|
if(Contains(Entry,"t_bar_t__")) return "ttbar";
|
23 |
|
|
if(Contains(Entry,"Single_top__")) return "SingleTop";
|
24 |
|
|
if(Contains(Entry,"W_Jets__")) return "W+Jets";
|
25 |
|
|
if(Contains(Entry,"WZ__")) return "WZ";
|
26 |
|
|
if(Contains(Entry,"Z_Jets")) return "Z+Jets";
|
27 |
|
|
if(Contains(Entry,"DATA")) return "Data";
|
28 |
|
|
if(Contains(Entry,"2l2q_")) return "ZZ->2l2q";
|
29 |
|
|
if(Contains(Entry,"4l_")) return "ZZ->4l";
|
30 |
|
|
return Entry;
|
31 |
|
|
}
|
32 |
buchmann |
1.2 |
|
33 |
buchmann |
1.3 |
void WZ_kin_plot(string variable, int nbins, float min, float high, string xlabel, TCut cut, string saveas) {
|
34 |
buchmann |
1.1 |
TCanvas *can = new TCanvas("can","can");
|
35 |
|
|
TPad *pad = new TPad("pad","pad",0,0,1,1);
|
36 |
|
|
pad->cd();
|
37 |
|
|
|
38 |
buchmann |
1.3 |
THStack stack = allsamples.DrawStack("stack",variable,nbins,min,high,xlabel, "events", cut,mc, luminosity);
|
39 |
|
|
TH1F *hdata = allsamples.Draw("hdata",variable,nbins,min,high,xlabel, "events", cut,data, luminosity);
|
40 |
buchmann |
1.1 |
|
41 |
buchmann |
1.3 |
hdata->Draw("e1");
|
42 |
|
|
stack.Draw("same");
|
43 |
|
|
hdata->Draw("e1,same");
|
44 |
buchmann |
1.1 |
TLegend *kinleg = allsamples.allbglegend();
|
45 |
|
|
kinleg->Draw();
|
46 |
|
|
DrawPrelim();
|
47 |
|
|
|
48 |
buchmann |
1.3 |
float total=0;
|
49 |
|
|
float wz=0;
|
50 |
|
|
cout << "Numbers with variable " << variable << " and cut " << cut << ": " << endl;
|
51 |
|
|
TIter nextSF = TIter(stack.GetHists());
|
52 |
buchmann |
1.1 |
TH1F *h;
|
53 |
buchmann |
1.3 |
stringstream spurity;
|
54 |
|
|
int bracecounter=0;
|
55 |
|
|
|
56 |
|
|
|
57 |
buchmann |
1.1 |
while ( h = (TH1F*)nextSF() ) {
|
58 |
buchmann |
1.3 |
cout << IdentifierForUnderlinedEntry(h->GetName()) << " : " << h->Integral() << endl;
|
59 |
|
|
if(IdentifierForUnderlinedEntry(h->GetName())=="WZ") {
|
60 |
|
|
wz+=h->Integral();
|
61 |
|
|
total+=h->Integral();
|
62 |
|
|
} else {
|
63 |
|
|
if(IdentifierForUnderlinedEntry(h->GetName())!="Data") total+=h->Integral();
|
64 |
|
|
}
|
65 |
|
|
bracecounter++;
|
66 |
|
|
spurity << "#splitline{" << IdentifierForUnderlinedEntry(h->GetName()) << " : " << h->Integral() << "}{";
|
67 |
buchmann |
1.1 |
}
|
68 |
buchmann |
1.3 |
|
69 |
|
|
spurity << "#splitline{Purity: " << wz/total << "}{Nevents: " << total << "}";
|
70 |
|
|
for(int i=0;i<bracecounter;i++) spurity << "}";
|
71 |
|
|
|
72 |
|
|
TPaveText *PurityPaveText = new TPaveText(0.60, 0.40,0.89, 0.6,"blNDC");
|
73 |
|
|
PurityPaveText->SetFillStyle(4000);
|
74 |
|
|
PurityPaveText->SetBorderSize(0);
|
75 |
|
|
PurityPaveText->SetFillColor(kWhite);
|
76 |
|
|
PurityPaveText->SetTextFont(42);
|
77 |
|
|
PurityPaveText->SetTextSize(0.021);
|
78 |
|
|
PurityPaveText->AddText(spurity.str().c_str());
|
79 |
|
|
PurityPaveText->Draw();
|
80 |
buchmann |
1.1 |
|
81 |
|
|
|
82 |
buchmann |
1.3 |
// TText *purity = new TText(0.8,0.6,spurity.str().c_str());
|
83 |
|
|
// purity->Draw();
|
84 |
|
|
cout << "DATA : " << hdata->Integral() << endl;
|
85 |
buchmann |
1.1 |
|
86 |
buchmann |
1.3 |
save_with_ratio(hdata,stack,pad->cd(),"WZ_study/"+saveas);
|
87 |
|
|
delete hdata;
|
88 |
|
|
delete can;
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
void write_report(TCut BasicCut, TCut cut, ofstream &report) {
|
92 |
|
|
THStack stack = allsamples.DrawStack("stack","tri_mll",10,0,1000,"m_{ll}", "events", BasicCut&&cut,mc, luminosity);
|
93 |
|
|
float total=0;
|
94 |
|
|
float wz=0;
|
95 |
|
|
TIter nextSF = TIter(stack.GetHists());
|
96 |
|
|
TH1F *h;
|
97 |
buchmann |
1.1 |
while ( h = (TH1F*)nextSF() ) {
|
98 |
buchmann |
1.3 |
cout << IdentifierForUnderlinedEntry(h->GetName()) << " : " << h->Integral() << endl;
|
99 |
|
|
if(IdentifierForUnderlinedEntry(h->GetName())=="WZ") {
|
100 |
|
|
wz+=h->Integral();
|
101 |
|
|
total+=h->Integral();
|
102 |
|
|
} else {
|
103 |
|
|
if(IdentifierForUnderlinedEntry(h->GetName())!="Data") total+=h->Integral();
|
104 |
|
|
}
|
105 |
|
|
report << h->Integral() << ";";
|
106 |
|
|
}
|
107 |
|
|
report << wz/total << ";\n";
|
108 |
|
|
report << flush;
|
109 |
|
|
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
vector<string> producecuts(string variablename, float cut1, float cut2, float cut3, float cut4, float cut5, float cut6 ) {
|
113 |
|
|
float allcuts[6] = {cut1,cut2,cut3,cut4,cut5,cut5};
|
114 |
|
|
vector<string> cuts;
|
115 |
|
|
for(int i = 0; i < 6; ++i ) {
|
116 |
|
|
if(allcuts[i]<0) continue;
|
117 |
|
|
stringstream nowcut;
|
118 |
|
|
nowcut << variablename << allcuts[i];
|
119 |
|
|
cuts.push_back(nowcut.str());
|
120 |
|
|
}
|
121 |
|
|
return cuts;
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
void OptimizeSelection(TCut BasicCut) {
|
126 |
|
|
ofstream report;
|
127 |
|
|
report.open ("report3.txt");
|
128 |
|
|
|
129 |
|
|
vector<string> mt = producecuts("tri_mT>",0,10,20,30,40,50);
|
130 |
|
|
vector<string> et = producecuts("met[4]>",0,10,20,30,40,50);
|
131 |
|
|
vector<string> mll = producecuts("abs(tri_mll-91.2)<",10000,10,20,-1,-1,-1);
|
132 |
|
|
vector<string> mlll = producecuts("abs(tri_mlll-91)>",0,10,20,30,40,50);
|
133 |
|
|
|
134 |
|
|
for(int imt=0;imt<mt.size();imt++) {
|
135 |
|
|
for(int iet=0;iet<et.size();iet++) {
|
136 |
|
|
for(int imll=0;imll<mll.size();imll++) {
|
137 |
|
|
for(int imlll=0;imlll<mlll.size();imlll++) {
|
138 |
|
|
stringstream cut;
|
139 |
|
|
cut << mt[imt] << " && " << et[iet] << " && " << mll[imll] << " && " << mlll[imlll];
|
140 |
|
|
report << mt[imt] << ";" << et[iet] << ";" << mll[imll] << ";" << mlll[imlll] <<";";
|
141 |
|
|
// cout << "Cut is : " << cut.str() << endl;
|
142 |
|
|
write_report(BasicCut, TCut(cut.str().c_str()),report);
|
143 |
|
|
}
|
144 |
|
|
}
|
145 |
|
|
}
|
146 |
buchmann |
1.1 |
}
|
147 |
buchmann |
1.3 |
report.close();
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
void CarryOutWZStudy() {
|
151 |
|
|
TCut BasicCut("leptonNum>2&&tri_pt1>30&&tri_pt2>20&&tri_pt3>20");
|
152 |
|
|
TCut Selection("abs(tri_mlll-91)>30 && tri_mT>40 && met[4] > 30 && abs(tri_mll-91)<10");
|
153 |
|
|
|
154 |
|
|
// OptimizeSelection(BasicCut);
|
155 |
|
|
/*
|
156 |
|
|
WZ_kin_plot("tri_mll",40,0,200,"m_{Z} [GeV]",BasicCut,"Inclusive/Zmass");
|
157 |
|
|
WZ_kin_plot("tri_mlll",40,0,400,"m_{ll} [GeV]",BasicCut,"Inclusive/TrileptonMass");
|
158 |
|
|
WZ_kin_plot("tri_mT",40,0,200,"m_{T} [GeV]",BasicCut,"Inclusive/mT");
|
159 |
|
|
WZ_kin_plot("met[4]", 40,0,400,"raw PFMET [GeV]",BasicCut,"Inclusive/MET");
|
160 |
|
|
WZ_kin_plot("tri_pt1",40,0,400,"p_{T}^{1} [GeV]",BasicCut,"Inclusive/Pt1");
|
161 |
|
|
WZ_kin_plot("tri_pt2",40,0,400,"p_{T}^{2} [GeV]",BasicCut,"Inclusive/Pt2");
|
162 |
|
|
WZ_kin_plot("tri_pt3",40,0,400,"p_{T}^{3} [GeV]",BasicCut,"Inclusive/Pt3");
|
163 |
|
|
|
164 |
|
|
WZ_kin_plot("tri_mll",40,0,200,"m_{Z} [GeV]",BasicCut&&TCut("abs(tri_mlll-91)>30"),"Mlll_cut/Zmass");
|
165 |
|
|
WZ_kin_plot("tri_mlll",40,0,400,"m_{ll} [GeV]",BasicCut&&TCut("abs(tri_mlll-91)>30"),"Mlll_cut/TrileptonMass");
|
166 |
|
|
WZ_kin_plot("tri_mT",40,0,200,"m_{T} [GeV]",BasicCut&&TCut("abs(tri_mlll-91)>30"),"Mlll_cut/mT");
|
167 |
|
|
WZ_kin_plot("met[4]", 40,0,400,"raw PFMET [GeV]",BasicCut&&TCut("abs(tri_mlll-91)>30"),"Mlll_cut/MET");
|
168 |
|
|
|
169 |
|
|
WZ_kin_plot("tri_mll",40,0,200,"m_{Z} [GeV]",BasicCut&&TCut("abs(tri_mll-91)<10"),"Zwindow/Zmass");
|
170 |
|
|
WZ_kin_plot("tri_mlll",40,0,400,"m_{ll} [GeV]",BasicCut&&TCut("abs(tri_mll-91)<10"),"Zwindow/TrileptonMass");
|
171 |
|
|
WZ_kin_plot("tri_mT",40,0,200,"m_{T} [GeV]",BasicCut&&TCut("abs(tri_mll-91)<10"),"Zwindow/mT");
|
172 |
|
|
WZ_kin_plot("met[4]", 40,0,400,"raw PFMET [GeV]",BasicCut&&TCut("abs(tri_mll-91)<10"),"Zwindow/MET");
|
173 |
|
|
|
174 |
|
|
WZ_kin_plot("tri_mll",40,0,200,"m_{Z} [GeV]",BasicCut,"CutFlow/Zmass__0_CutOnNothing");
|
175 |
|
|
WZ_kin_plot("tri_mll",40,0,200,"m_{Z} [GeV]",BasicCut&&TCut("tri_mT>40"),"CutFlow/Zmass__1_CutOn_MT");
|
176 |
|
|
WZ_kin_plot("tri_mll",40,0,200,"m_{Z} [GeV]",BasicCut&&TCut("tri_mT>40&&abs(tri_mlll-91)>30"),"CutFlow/Zmass__2_CutOn_MT_n_Mll");
|
177 |
|
|
WZ_kin_plot("tri_mll",40,0,200,"m_{Z} [GeV]",BasicCut&&TCut("tri_mT>40&&abs(tri_mlll-91)>30&&met[4]>30"),"CutFlow/Zmass__3_CutOn_MT_n_Mll_n_Met");
|
178 |
|
|
WZ_kin_plot("tri_mll",40,0,200,"m_{Z} [GeV]",BasicCut&&TCut("tri_mT>40&&abs(tri_mlll-91)>30&&met[4]>30&&abs(tri_mll-91)<10"),"CutFlow/Zmass__4_CutOn_MT_n_Mll_n_Met_MllWindow");
|
179 |
|
|
|
180 |
|
|
WZ_kin_plot("tri_mT",40,0,200,"m_{T} [GeV]",BasicCut,"CutFlow/MT__0_CutOnNothing");
|
181 |
|
|
WZ_kin_plot("tri_mT",40,0,200,"m_{T} [GeV]",BasicCut&&TCut("tri_mT>40"),"CutFlow/MT__1_CutOn_MT");
|
182 |
|
|
WZ_kin_plot("tri_mT",40,0,200,"m_{T} [GeV]",BasicCut&&TCut("tri_mT>40&&abs(tri_mlll-91)>30"),"CutFlow/MT__2_CutOn_MT_n_Mll");
|
183 |
|
|
WZ_kin_plot("tri_mT",40,0,200,"m_{T} [GeV]",BasicCut&&TCut("tri_mT>40&&abs(tri_mlll-91)>30&&met[4]>30"),"CutFlow/MT__3_CutOn_MT_n_Mll_n_Met");
|
184 |
|
|
WZ_kin_plot("tri_mT",40,0,200,"m_{T} [GeV]",BasicCut&&TCut("tri_mT>40&&abs(tri_mlll-91)>30&&met[4]>30&&abs(tri_mll-91)<10"),"CutFlow/MT__4_CutOn_MT_n_Mll_n_Met_MllWindow");
|
185 |
|
|
|
186 |
|
|
WZ_kin_plot("met[4]",40,0,200,"MET [GeV]",BasicCut,"CutFlow/MET__0_CutOnNothing");
|
187 |
|
|
WZ_kin_plot("met[4]",40,0,200,"MET [GeV]",BasicCut&&TCut("tri_mT>40"),"CutFlow/MET__1_CutOn_MT");
|
188 |
|
|
WZ_kin_plot("met[4]",40,0,200,"MET [GeV]",BasicCut&&TCut("tri_mT>40&&abs(tri_mlll-91)>30"),"CutFlow/MET__2_CutOn_MT_n_Mll");
|
189 |
|
|
WZ_kin_plot("met[4]",40,0,200,"MET [GeV]",BasicCut&&TCut("tri_mT>40&&abs(tri_mlll-91)>30&&met[4]>30"),"CutFlow/MET__3_CutOn_MT_n_Mll_n_Met");
|
190 |
|
|
WZ_kin_plot("met[4]",40,0,200,"MET [GeV]",BasicCut&&TCut("tri_mT>40&&abs(tri_mlll-91)>30&&met[4]>30&&abs(tri_mll-91)<10"),"CutFlow/MET__4_CutOn_MT_n_Mll_n_Met_MllWindow");
|
191 |
|
|
|
192 |
|
|
|
193 |
|
|
WZ_kin_plot("tri_mll",40,0,200,"m_{Z} [GeV]",BasicCut&&Selection,"Zmass");
|
194 |
|
|
WZ_kin_plot("tri_mlll",40,0,400,"m_{lll} [GeV]",BasicCut&&Selection,"TrileptonMass");
|
195 |
|
|
WZ_kin_plot("tri_mT",40,0,200,"m_{T} [GeV]",BasicCut&&Selection,"mT");
|
196 |
|
|
WZ_kin_plot("met[4]", 40,0,400,"raw PFMET [GeV]",BasicCut&&Selection,"MET");
|
197 |
|
|
WZ_kin_plot("tri_pt1",40,0,400,"p_{T}^{1} [GeV]",BasicCut&&Selection,"Pt1");
|
198 |
|
|
WZ_kin_plot("tri_pt2",40,0,400,"p_{T}^{2} [GeV]",BasicCut&&Selection,"Pt2");
|
199 |
|
|
WZ_kin_plot("tri_pt3",40,0,400,"p_{T}^{3} [GeV]",BasicCut&&Selection,"Pt3");
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
TCut SF("tri_id1==tri_id2");
|
203 |
|
|
TCut OF("tri_id1!=tri_id2");
|
204 |
|
|
|
205 |
|
|
TH1F *sfdata = allsamples.Draw("sfdata","tri_mll",30,75,105,"m_{Z} [GeV]", "events", BasicCut&&Selection&&SF,data, luminosity);
|
206 |
|
|
TH1F *ofdata = allsamples.Draw("ofdata","tri_mll",30,75,105,"m_{Z} [GeV]", "events", BasicCut&&Selection&&OF,data, luminosity);
|
207 |
|
|
|
208 |
|
|
// all MC samples
|
209 |
|
|
TH1F *sfmc = allsamples.Draw("sfmc" ,"tri_mll",30,75,105,"m_{Z} [GeV]", "events", BasicCut&&Selection&&SF,mc , luminosity);
|
210 |
|
|
TH1F *ofmc = allsamples.Draw("ofmc" ,"tri_mll",30,75,105,"m_{Z} [GeV]", "events", BasicCut&&Selection&&OF,mc , luminosity);
|
211 |
|
|
|
212 |
|
|
// WZ only
|
213 |
|
|
TH1F *sfwz = allsamples.Draw("sfwz" ,"tri_mll",30,75,105,"m_{Z} [GeV]", "events", BasicCut&&Selection&&SF,mc , luminosity,allsamples.FindSample("WZJetsTo3"));
|
214 |
|
|
TH1F *ofwz = allsamples.Draw("ofwz" ,"tri_mll",30,75,105,"m_{Z} [GeV]", "events", BasicCut&&Selection&&OF,mc , luminosity,allsamples.FindSample("WZJetsTo3"));
|
215 |
|
|
|
216 |
|
|
dout << "SF events: " << sfdata->Integral() << " (mc : " << sfmc->Integral() << " , wz : " << sfwz->Integral() << " ) WZ purity: " << 100*sfwz->Integral()/sfmc->Integral() << " %" << endl;
|
217 |
|
|
dout << "OF events: " << ofdata->Integral() << " (mc : " << ofmc->Integral() << " , wz : " << ofwz->Integral() << " ) WZ purity: " << 100*ofwz->Integral()/ofmc->Integral() << " %" << endl;
|
218 |
|
|
|
219 |
|
|
dout << "RATIO : SF / OF = " << sfdata->Integral() / ofdata->Integral() << " +/- " << (sfdata->Integral()/ofdata->Integral()) * TMath::Sqrt(1/sfdata->Integral()+1/ofdata->Integral()) << " (stat) " << endl;
|
220 |
|
|
*/
|
221 |
buchmann |
1.1 |
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
void WZstudy() {
|
228 |
|
|
|
229 |
|
|
switch_overunderflow(true);
|
230 |
|
|
cout << "Essential cut is " << (const char*) essentialcut << endl;
|
231 |
|
|
cout << "Going to set essential cut to new triggers" << endl;
|
232 |
|
|
TCut essential_bkp = essentialcut;
|
233 |
|
|
write_warning(__FUNCTION__,"Need to define trigger requirement for WZ!");
|
234 |
buchmann |
1.3 |
essentialcut=TCut("mll>5||mll<6");
|
235 |
buchmann |
1.1 |
cout << "Essential cut is now " << (const char*) essentialcut << endl;
|
236 |
|
|
|
237 |
|
|
CarryOutWZStudy();
|
238 |
|
|
|
239 |
|
|
|
240 |
|
|
cout << "Essential cut is now " << (const char*) essentialcut << endl;
|
241 |
|
|
essentialcut = essential_bkp;
|
242 |
|
|
cout << "Essential cut is now " << (const char*) essentialcut << " (restored)" << endl;
|
243 |
|
|
switch_overunderflow(false);
|
244 |
|
|
}
|
245 |
buchmann |
1.3 |
|