ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/jbabb/ScriptsAndMacros/DataPlotter.C
Revision: 1.1
Committed: Sat Sep 3 21:22:22 2011 UTC (13 years, 8 months ago) by jbabb
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 jbabb 1.1 //
2     // A root macro to plot MC and data on the
3     // same histogram for a variety of different
4     // variables.
5     //
6     // John Babb 11/11/10
7     //
8    
9     //ROOT includes
10     #include "TTree.h"
11     #include "TFile.h"
12     #include "TBranch.h"
13     #include "TLeafF.h"
14     #include "TLeafI.h"
15     #include "TH1F.h"
16     #include "TH2F.h"
17     #include "THStack.h"
18    
19    
20     //System includes
21     #include <TObject.h>
22     #include <TMinuit.h>
23     #include <TLorentzVector.h>
24     #include <TMath.h>
25     #include <TString.h>
26     #include <TStyle.h>
27     #include <TLegend.h>
28     #include <TCanvas.h>
29     #include <TPad.h>
30     #include <TGraphErrors.h>
31     #include <TSystem.h>
32     #include <vector>
33     #include <stdio.h>
34     #include <stdlib.h>
35     #include <iostream>
36     #include <string>
37    
38    
39    
40    
41     void DataPlotter() {
42    
43     //Output file
44     TFile *f = new TFile("nTuplePlots.root", "recreate");
45    
46     double ttbar_lumi = 3701947./(165.*0.85);//0.85 is from minuit scaling
47    
48     double singletop_s_t_lumi = 259971./3.19;
49     double singletop_t_t_lumi = 3900171./41.92;
50     double singletop_tw_t_lumi = 814390./7.87;
51     double singletop_s_tbar_lumi = 137980./1.44;
52     double singletop_t_tbar_lumi = 1944826./22.63;
53     double singletop_tw_tbar_lumi = 809984./7.87;
54    
55     //double ww_lumi = 2061760. / (27.79 * 1.);
56     //double wz_lumi = 2194752. / (10.4* 1.);
57     //double zz_lumi = 2113368. / (4.297 * 1.);
58     double qcd_lumi = 25064715. / (296600000. * 0.0002855);
59     //double wjets_lumi = 81352581. /(28000.);
60     //double zjets_lumi = 36277961. / 2800.;
61     double wjets_lumi = 81352581. /(31314.*0.78);//0.78 is from minuit scaling
62     double zjets_lumi = 36277961. / 3048.;
63     //double lumi_2011 = 835.;
64     double data_lumi = 835.;
65     //double data_lumi = 1564.;
66    
67     /*
68     //minuit scales
69     double scale30 = 1.20176;
70     double scale31 = 0.99251;
71     double scale32 = 0.79793;
72     double scale40 = 1.21034;
73     double scale41 = 1.03571;
74     double scale42 = 0.87861;
75     */
76    
77     //Minuit scales + qcd templating
78    
79     //Preselection
80     /*
81     double scale30 = 1.20176*0.075;
82     double scale31 = 0.99251*0.038;
83     double scale32 = 0.79793*0.010;
84     double scale40 = 1.21034*0.056;
85     double scale41 = 1.03571*0.031;
86     double scale42 = 0.87861*0.009;
87    
88    
89     //ttbar tree
90     double scale30 = 1.20176*1.;
91     double scale31 = 0.99251*0.;
92     double scale32 = 0.79793*0.011;
93     double scale40 = 1.21034*0.022;
94     double scale41 = 1.03571*0.021;
95     double scale42 = 0.87861*0.008;
96    
97    
98     //zprime tree
99     double scale30 = 1.20176*0.;
100     double scale31 = 0.99251*0.009;
101     double scale32 = 0.79793*0.003;
102     double scale40 = 1.21034*0.016;
103     double scale41 = 1.03571*0.022;
104     double scale42 = 0.87861*0.012;
105     */
106    
107    
108     double scale30 = 0.;
109     double scale31 = 0.;
110     double scale32 = 0.;
111     double scale40 = 0.;
112     double scale41 = 0.;
113     double scale42 = 0.87861*0.012;
114    
115    
116    
117     bool splitQCD = true;
118     bool splitTT = false;
119     bool splitWJ = false;
120     bool logScale = false;
121    
122    
123     bool reweight2010 = false;
124     bool reweight2011 = true;
125    
126    
127     TString weightBranch;
128    
129     if (reweight2010) weightBranch = "mcWeight2010";
130     else if (reweight2011) weightBranch = "mcWeight2011";
131    
132    
133     TString path = "/uscms_data/d2/jbabb/CMSSW_4_2_5/src/TopQuarkAnalysis/Skynet/test/ZprimeTree/Skynet_ZPtree-n0p1_4j2b_";
134     TString qcdpath = "/uscms_data/d2/jbabb/CMSSW_4_2_5/src/TopQuarkAnalysis/Skynet/test/ZprimeTree/Skynet_ZPtree-n0p1_InvertedIsolation_";
135    
136     //Get files
137     TFile *ttbar_file = new TFile(path+"TTbar.root", "open");
138     //TFile *ttbar_file1 = new TFile(path+"3jets0bjets_TTbar.root", "open");
139     //TFile *ttbar_file2 = new TFile(path+"3jets1bjets_TTbar.root", "open");
140     //TFile *ttbar_file3 = new TFile(path+"3jets2bjets_TTbar.root", "open");
141     //TFile *ttbar_file4 = new TFile(path+"4jets0bjets_TTbar.root", "open");
142     //TFile *ttbar_file5 = new TFile(path+"4jets1bjets_TTbar.root", "open");
143     //TFile *ttbar_file6 = new TFile(path+"4jets2bjets_TTbar.root", "open");
144     TFile *singletop_s_t_file = new TFile(path+"ST-s-T.root", "open");
145     TFile *singletop_t_t_file = new TFile(path+"ST-t-T.root", "open");
146     TFile *singletop_tw_t_file = new TFile(path+"ST-tW-T.root", "open");
147     TFile *singletop_s_tbar_file = new TFile(path+"ST-s-Tbar.root", "open");
148     TFile *singletop_t_tbar_file = new TFile(path+"ST-t-Tbar.root", "open");
149     TFile *singletop_tw_tbar_file = new TFile(path+"ST-tW-Tbar.root", "open");
150     //TFile *ww_file = new TFile(path+"WW.root", "open");
151     //TFile *wz_file = new TFile(path+"WZ.root", "open");
152     //TFile *zz_file = new TFile(path+"ZZ.root", "open");
153     TFile *qcd_file = new TFile(path+"QCD.root", "open");
154     TFile *qcd_file1 = new TFile(qcdpath+"3j0b_QCD.root", "open");
155     TFile *qcd_file2 = new TFile(qcdpath+"3j1b_QCD.root", "open");
156     TFile *qcd_file3 = new TFile(qcdpath+"3j2b_QCD.root", "open");
157     TFile *qcd_file4 = new TFile(qcdpath+"4j0b_QCD.root", "open");
158     TFile *qcd_file5 = new TFile(qcdpath+"4j1b_QCD.root", "open");
159     TFile *qcd_file6 = new TFile(qcdpath+"4j2b_QCD.root", "open");
160     TFile *wjets_file = new TFile(path+"WJets.root", "open");
161     //TFile *wjets_file1 = new TFile(path+"3jets0bjets_WJets.root", "open");
162     //TFile *wjets_file2 = new TFile(path+"3jets1bjets_WJets.root", "open");
163     //TFile *wjets_file3 = new TFile(path+"3jets2bjets_WJets.root", "open");
164     //TFile *wjets_file4 = new TFile(path+"4jets0bjets_WJets.root", "open");
165     //TFile *wjets_file5 = new TFile(path+"4jets1bjets_WJets.root", "open");
166     //TFile *wjets_file6 = new TFile(path+"4jets2bjets_WJets.root", "open");
167     TFile *zjets_file = new TFile(path+"ZJets.root", "open");
168     TFile *data_file = new TFile(path+"2011-835pb.root", "open");
169     //TFile *zprime750_file = new TFile(path+"Zprime750.root", "open");
170     //TFile *zprime1000_file = new TFile(path+"Zprime1000.root", "open");
171     //TFile *zprime1250_file = new TFile(path+"Zprime1250.root", "open");
172     //TFile *zprime1500_file = new TFile(path+"Zprime1500.root", "open");
173     //TFile *zprime2000_file = new TFile(path+"Zprime2000.root", "open");
174    
175    
176     //Get trees
177     TTree *ttbar_tree = (TTree*)ttbar_file ->Get("PATuple");
178     //TTree *ttbar_tree1 = (TTree*)ttbar_file1 ->Get("PATuple");
179     //TTree *ttbar_tree2 = (TTree*)ttbar_file2 ->Get("PATuple");
180     //TTree *ttbar_tree3 = (TTree*)ttbar_file3 ->Get("PATuple");
181     //TTree *ttbar_tree4 = (TTree*)ttbar_file4 ->Get("PATuple");
182     //TTree *ttbar_tree5 = (TTree*)ttbar_file5 ->Get("PATuple");
183     //TTree *ttbar_tree6 = (TTree*)ttbar_file6 ->Get("PATuple");
184     TTree *singletop_s_t_tree = (TTree*)singletop_s_t_file ->Get("PATuple");
185     TTree *singletop_t_t_tree = (TTree*)singletop_t_t_file ->Get("PATuple");
186     TTree *singletop_tw_t_tree = (TTree*)singletop_tw_t_file->Get("PATuple");
187     TTree *singletop_s_tbar_tree = (TTree*)singletop_s_tbar_file ->Get("PATuple");
188     TTree *singletop_t_tbar_tree = (TTree*)singletop_t_tbar_file ->Get("PATuple");
189     TTree *singletop_tw_tbar_tree = (TTree*)singletop_tw_tbar_file->Get("PATuple");
190     //TTree *ww_tree = (TTree*)ww_file ->Get("PATuple");
191     //TTree *wz_tree = (TTree*)wz_file ->Get("PATuple");
192     //TTree *zz_tree = (TTree*)zz_file ->Get("PATuple");
193     TTree *qcd_tree = (TTree*)qcd_file ->Get("PATuple");
194     TTree *qcd_tree1 = (TTree*)qcd_file1 ->Get("PATuple");
195     TTree *qcd_tree2 = (TTree*)qcd_file2 ->Get("PATuple");
196     TTree *qcd_tree3 = (TTree*)qcd_file3 ->Get("PATuple");
197     TTree *qcd_tree4 = (TTree*)qcd_file4 ->Get("PATuple");
198     TTree *qcd_tree5 = (TTree*)qcd_file5 ->Get("PATuple");
199     TTree *qcd_tree6 = (TTree*)qcd_file6 ->Get("PATuple");
200     TTree *wjets_tree = (TTree*)wjets_file ->Get("PATuple");
201     //TTree *wjets_tree1 = (TTree*)wjets_file1 ->Get("PATuple");
202     //TTree *wjets_tree2 = (TTree*)wjets_file2 ->Get("PATuple");
203     //TTree *wjets_tree3 = (TTree*)wjets_file3 ->Get("PATuple");
204     //TTree *wjets_tree4 = (TTree*)wjets_file4 ->Get("PATuple");
205     //TTree *wjets_tree5 = (TTree*)wjets_file5 ->Get("PATuple");
206     //TTree *wjets_tree6 = (TTree*)wjets_file6 ->Get("PATuple");
207     TTree *zjets_tree = (TTree*)zjets_file ->Get("PATuple");
208     TTree *data_tree = (TTree*)data_file ->Get("PATuple");
209     //TTree *zprime750_tree = (TTree*)zprime750_file ->Get("PATuple");
210     //TTree *zprime1000_tree = (TTree*)zprime1000_file ->Get("PATuple");
211     //TTree *zprime1250_tree = (TTree*)zprime1250_file ->Get("PATuple");
212     //TTree *zprime1500_tree = (TTree*)zprime1500_file ->Get("PATuple");
213     //TTree *zprime2000_tree = (TTree*)zprime2000_file ->Get("PATuple");
214    
215    
216     //List the variables that we want plots of
217     int nVariables = 47;
218     int nBins;
219    
220     TString VariableList[] = {
221     "unfittedEvent_ttInvariantMass", "unfittedHadTopMass", "unfittedLepTopMass", "HtJets",
222     "HtJetsLepMET", "drMinMuJ_smuon", "drMaxMuJ_smuon", "dPhiMuMET_smuon", "aplanarity",
223     "centrality", "drJ1J2", "drJ1J3", "drJ2J3", "drMinJ1", "drMinJ2", "drMinJ3", "met",
224     "pt_jet1", "pt_jet2", "pt_jet3", "pt_smuon", "sphericity", "tt_dR", "tt_dPhi", "tt_dTheta",
225     "unfittedHadWMass", "unfittedHadWE", "unfittedHadWPt", "unfittedLepWMass", "unfittedLepWE",
226     "unfittedLepWPt", "unfittedHadTopE", "unfittedHadTopPt", "unfittedLepTopE", "unfittedLepTopPt",
227     "ptRel_muon", "relIso_muon", "pfIso_muon", "MMuJet1_smuon", "MJ1J2J3", "MJ1J2", "MJ1J3", "MJ2J3",
228     "topPtDiff", "topMassDiff", "nHardJets", "bJets"
229     };
230    
231     double VariableMax[] = { 2200., 750., 500., 2000., 2000., 3., 5., 3.2, 0.3,
232     1.0, 5., 5., 5., 5., 5., 5., 500., 750., 500., 300., 500., 1., 5., 3., 3.,
233     300., 1000., 500., 200., 1000., 500., 1000., 750., 1000., 750., 350., 1.,
234     2., 1000., 1500., 1000., 1000., 1000., 400., 400., 8., 5.
235     };
236    
237     double VariableMin[] = { 200., 100., 100., 100., 150., 0., 1.5, 0.0, 0.0,
238     0.0, 0., 0., 0., 0., 0., 0., 20., 40., 30., 20., 20., 0., 0., 0., 0.,
239     50., 0., 0., 70., 50., 0., 50., 0., 100., 0., 0., 0.,
240     0., 0., 0., 0., 0., 0., 0., 0., 3., 0.
241     };
242    
243     TString TitleList[] = {
244     "M_{t#bar{t}} (GeV)", "M_{HadTop} (GeV)", "M_{LepTop} (GeV)", "H_{T} Jets (GeV)",
245     "H_{T} Jets+Leps (GeV)", "#Delta R_{Min}(#mu, Jet)", "#Delta R_{Max}(#mu, Jet)", "#Delta #phi (#mu, MET)", "Aplanarity",
246     "Centrality", "#Delta R(Jet1,Jet2)", "#Delta R(Jet1,Jet3)", "#Delta R(Jet2,Jet3)", "#Delta R_{Min} (Jet1, nearest Jet)",
247     "#Delta R_{Min} (Jet2, nearest Jet)", "#Delta R_{Min} (Jet3, nearest Jet)", "MET (GeV)",
248     "p_{T}^{Jet1} (GeV)", "p_{T}^{Jet2} (GeV)", "p_{T}^{Jet3} (GeV)", "p_{T}^{#mu} (GeV)", "Sphericity", "#Delta R t#bar{t}",
249     "#Delta #phi t#bar{t}", "#Delta #theta t#bar{t}",
250     "M_{HadW} (GeV)", "E_{HadW} (GeV)", "p_{T}^{HadW} (GeV)", "M_{LepW} (GeV)", "E_{LepW} (GeV)",
251     "p_{T}^{LepW} (GeV)", "E_{HadTop} (GeV)", "p_{T}^{HadTop} (GeV)", "E_{LepTop} (GeV)", "p_{T}^{LepTop} (GeV)",
252     "p_{T}^{Rel} (#mu, jet) (GeV)", "relIso", "pfIso", "M_{(#mu,Jet1)} (GeV)", "M_{(Jet1, Jet2, Jet3)} (GeV) ",
253     "M_{(Jet1, Jet2)} (GeV) ", "M_{(Jet1, Jet3)} (GeV) ", "M_{(Jet2, Jet3)} (GeV) ",
254     "ttPtDifference (GeV)", "topMassDifference (GeV)", "nJets", "bJets"
255     };
256    
257    
258     TString PlotType = ".png";
259    
260     //Loop over all of the variables we want to plot
261     for ( int i = 0; i < nVariables; i++ ) {
262    
263    
264    
265     //gStyle->SetOptStat(0);
266    
267    
268    
269     if (i == (nVariables-1) || i == (nVariables - 2)) nBins = 5;
270     else if (i == 0) nBins = 20;
271     else nBins = 15;
272    
273    
274     //Here take a variable and loop over it and fill histogram
275     //Must do this for each TTree, MC and data.
276    
277     //Stack for the MC
278     THStack *hStk = new THStack( VariableList[i], VariableList[i] );
279    
280    
281     // TTbar
282     double ttscale = data_lumi / ttbar_lumi;
283    
284     float tt;
285     float tt_w;
286    
287     int entries_ttbar = ttbar_tree->GetEntries();
288     TH1F *ttPlot = new TH1F( "ttbar_"+VariableList[i], "ttbar_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
289     TBranch *TopBranch = ttbar_tree->GetBranch( VariableList[i] );
290     if (reweight2010 || reweight2011) TBranch *TopWeights = ttbar_tree->GetBranch( weightBranch );
291    
292     TopBranch ->SetAddress(&tt);
293     if (reweight2010 || reweight2011) TopWeights->SetAddress(&tt_w);
294    
295    
296     TCanvas* c1 = new TCanvas();
297     c1->cd();
298    
299     for ( int j = 0; j < entries_ttbar; j++ ) {
300    
301    
302     TopBranch->GetEntry(j);
303     if (reweight2010 || reweight2011) TopWeights->GetEntry(j);
304    
305     if (reweight2010 || reweight2011) ttPlot->Fill(tt, tt_w);
306     else ttPlot->Fill(tt);
307    
308     }
309    
310     ttPlot->SetFillColor(kRed+1);
311    
312     ttPlot->Scale( ttscale, "" );
313     if (logScale) c1->SetLogy();
314    
315     ttPlot->Draw();
316    
317     f->cd();
318    
319     ttPlot->Write();
320    
321     c1->Update();
322     //c1->Print( "TTbar_"+VariableList[i]+PlotType );
323     delete c1;
324    
325    
326     /*
327     float tt1;
328     float tt_w1;
329    
330     int entries_ttbar1 = ttbar_tree1->GetEntries();
331     TH1F *TTPlot1 = new TH1F( "TTbar1_"+VariableList[i], "TTbar1_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
332     TBranch *TopBranch1 = ttbar_tree1->GetBranch( VariableList[i] );
333     if (reweight2010 || reweight2011) TBranch *TopWeights1 = ttbar_tree1->GetBranch( weightBranch );
334    
335     TopBranch1->SetAddress(&tt1);
336     if (reweight2010 || reweight2011) TopWeights1->SetAddress(&tt_w1);
337    
338    
339     TCanvas* c1 = new TCanvas();
340     c1->cd();
341    
342     for ( int j = 0; j < entries_ttbar1; j++ ) {
343    
344    
345     TopBranch1->GetEntry(j);
346     if (reweight2010 || reweight2011) TopWeights1->GetEntry(j);
347    
348     if (reweight2010 || reweight2011) TTPlot1->Fill(tt1, tt_w1);
349     else TTPlot1->Fill(tt1);
350    
351     }
352    
353     TTPlot1->SetFillColor(kRed+1);
354    
355     TTPlot1->Scale( ttscale*ttscale30, "" );
356     if (logScale) c1->SetLogy();
357    
358     TTPlot1->Draw();
359    
360     f->cd();
361    
362     TTPlot1->Write();
363    
364     c1->Update();
365     //c1->Print( "TTbar_"+VariableList[i]+PlotType );
366     delete c1;
367    
368    
369    
370     float tt2;
371     float tt_w2;
372    
373     int entries_ttbar2 = ttbar_tree2->GetEntries();
374     TH1F *TTPlot2 = new TH1F( "TTbar2_"+VariableList[i], "TTbar2_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
375     TBranch *TopBranch2 = ttbar_tree2->GetBranch( VariableList[i] );
376     if (reweight2010 || reweight2011) TBranch *TopWeights2 = ttbar_tree2->GetBranch( weightBranch );
377    
378     TopBranch2->SetAddress(&tt2);
379     if (reweight2010 || reweight2011) TopWeights2->SetAddress(&tt_w2);
380    
381    
382     TCanvas* c1 = new TCanvas();
383     c1->cd();
384    
385     for ( int j = 0; j < entries_ttbar2; j++ ) {
386    
387    
388     TopBranch2->GetEntry(j);
389     if (reweight2010 || reweight2011) TopWeights2->GetEntry(j);
390    
391     if (reweight2010 || reweight2011) TTPlot2->Fill(tt2, tt_w2);
392     else TTPlot2->Fill(tt2);
393    
394     }
395    
396     TTPlot2->SetFillColor(kRed+1);
397    
398     TTPlot2->Scale( ttscale*ttscale31, "" );
399     if (logScale) c1->SetLogy();
400    
401     TTPlot2->Draw();
402    
403     f->cd();
404    
405     TTPlot2->Write();
406    
407     c1->Update();
408     //c1->Print( "TTbar_"+VariableList[i]+PlotType );
409     delete c1;
410    
411    
412    
413     float tt3;
414     float tt_w3;
415    
416     int entries_ttbar3 = ttbar_tree3->GetEntries();
417     TH1F *TTPlot3 = new TH1F( "TTbar3_"+VariableList[i], "TTbar3_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
418     TBranch *TopBranch3 = ttbar_tree3->GetBranch( VariableList[i] );
419     if (reweight2010 || reweight2011) TBranch *TopWeights3 = ttbar_tree3->GetBranch( weightBranch );
420    
421     TopBranch3->SetAddress(&tt3);
422     if (reweight2010 || reweight2011) TopWeights3->SetAddress(&tt_w3);
423    
424    
425     TCanvas* c1 = new TCanvas();
426     c1->cd();
427    
428     for ( int j = 0; j < entries_ttbar3; j++ ) {
429    
430    
431     TopBranch3->GetEntry(j);
432     if (reweight2010 || reweight2011) TopWeights3->GetEntry(j);
433    
434     if (reweight2010 || reweight2011) TTPlot3->Fill(tt3, tt_w3);
435     else TTPlot3->Fill(tt3);
436    
437     }
438    
439     TTPlot3->SetFillColor(kRed+1);
440    
441     TTPlot3->Scale( ttscale*ttscale32, "" );
442     if (logScale) c1->SetLogy();
443    
444     TTPlot3->Draw();
445    
446     f->cd();
447    
448     TTPlot3->Write();
449    
450     c1->Update();
451     //c1->Print( "TTbar_"+VariableList[i]+PlotType );
452     delete c1;
453    
454    
455    
456     float tt4;
457     float tt_w4;
458    
459     int entries_ttbar4 = ttbar_tree4->GetEntries();
460     TH1F *TTPlot4 = new TH1F( "TTbar4_"+VariableList[i], "TTbar4_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
461     TBranch *TopBranch4 = ttbar_tree4->GetBranch( VariableList[i] );
462     if (reweight2010 || reweight2011) TBranch *TopWeights4 = ttbar_tree4->GetBranch( weightBranch );
463    
464     TopBranch4->SetAddress(&tt4);
465     if (reweight2010 || reweight2011) TopWeights4->SetAddress(&tt_w4);
466    
467    
468     TCanvas* c1 = new TCanvas();
469     c1->cd();
470    
471     for ( int j = 0; j < entries_ttbar4; j++ ) {
472    
473    
474     TopBranch4->GetEntry(j);
475     if (reweight2010 || reweight2011) TopWeights4->GetEntry(j);
476    
477     if (reweight2010 || reweight2011) TTPlot4->Fill(tt4, tt_w4);
478     else TTPlot4->Fill(tt4);
479    
480     }
481    
482     TTPlot4->SetFillColor(kRed+1);
483    
484     TTPlot4->Scale( ttscale*ttscale40, "" );
485     if (logScale) c1->SetLogy();
486    
487     TTPlot4->Draw();
488    
489     f->cd();
490    
491     TTPlot4->Write();
492    
493     c1->Update();
494     //c1->Print( "TTbar_"+VariableList[i]+PlotType );
495     delete c1;
496    
497    
498    
499     float tt5;
500     float tt_w5;
501    
502     int entries_ttbar5 = ttbar_tree5->GetEntries();
503     TH1F *TTPlot5 = new TH1F( "TTbar5_"+VariableList[i], "TTbar5_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
504     TBranch *TopBranch5 = ttbar_tree5->GetBranch( VariableList[i] );
505     if (reweight2010 || reweight2011) TBranch *TopWeights5 = ttbar_tree5->GetBranch( weightBranch );
506    
507     TopBranch5->SetAddress(&tt5);
508     if (reweight2010 || reweight2011) TopWeights5->SetAddress(&tt_w5);
509    
510    
511     TCanvas* c1 = new TCanvas();
512     c1->cd();
513    
514     for ( int j = 0; j < entries_ttbar5; j++ ) {
515    
516     TopBranch5->GetEntry(j);
517     if (reweight2010 || reweight2011) TopWeights5->GetEntry(j);
518    
519     if (reweight2010 || reweight2011) TTPlot5->Fill(tt5, tt_w5);
520     else TTPlot5->Fill(tt5);
521    
522     }
523    
524     TTPlot5->SetFillColor(kRed+1);
525    
526     TTPlot5->Scale( ttscale*ttscale41, "" );
527     if (logScale) c1->SetLogy();
528    
529     TTPlot5->Draw();
530    
531     f->cd();
532    
533     TTPlot5->Write();
534    
535     c1->Update();
536     //c1->Print( "TTbar_"+VariableList[i]+PlotType );
537     delete c1;
538    
539    
540    
541     float tt6;
542     float tt_w6;
543    
544     int entries_ttbar6 = ttbar_tree6->GetEntries();
545     TH1F *TTPlot6 = new TH1F( "TTbar6_"+VariableList[i], "TTbar6_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
546     TBranch *TopBranch6 = ttbar_tree6->GetBranch( VariableList[i] );
547     if (reweight2010 || reweight2011) TBranch *TopWeights6 = ttbar_tree6->GetBranch( weightBranch );
548    
549     TopBranch6->SetAddress(&tt6);
550     if (reweight2010 || reweight2011) TopWeights6->SetAddress(&tt_w6);
551    
552    
553     TCanvas* c1 = new TCanvas();
554     c1->cd();
555    
556     for ( int j = 0; j < entries_ttbar6; j++ ) {
557    
558    
559     TopBranch6->GetEntry(j);
560     if (reweight2010 || reweight2011) TopWeights6->GetEntry(j);
561    
562     if (reweight2010 || reweight2011) TTPlot6->Fill(tt6, tt_w6);
563     else TTPlot6->Fill(tt6);
564    
565     }
566    
567     TTPlot6->SetFillColor(kRed+1);
568    
569     TTPlot6->Scale( ttscale*ttscale42, "" );
570     if (logScale) c1->SetLogy();
571    
572     TTPlot6->Draw();
573    
574     f->cd();
575    
576     TTPlot6->Write();
577    
578     c1->Update();
579     //c1->Print( "TTbar_"+VariableList[i]+PlotType );
580     delete c1;
581    
582     */
583    
584    
585     //SingleTop_sChannel
586     float st_s_t;
587     float st_s_t_w;
588    
589     int entries_st_s_t = singletop_s_t_tree->GetEntries();
590     TH1F *ST_s_t_Plot = new TH1F( "SingleTop_s_t_"+VariableList[i], "SingleTop_s_t_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
591     TBranch *ST_s_t_Branch = singletop_s_t_tree->GetBranch( VariableList[i] );
592     if (reweight2010 || reweight2011) TBranch *ST_s_t_Weights = singletop_s_t_tree->GetBranch( weightBranch );
593    
594     ST_s_t_Branch->SetAddress(&st_s_t);
595     if (reweight2010 || reweight2011) ST_s_t_Weights->SetAddress(&st_s_t_w);
596    
597     TCanvas* c2_s_t = new TCanvas();
598     c2_s_t->cd();
599    
600     for ( int k = 0; k < entries_st_s_t; k++ ) {
601    
602    
603     ST_s_t_Branch->GetEntry(k);
604     if (reweight2010 || reweight2011) ST_s_t_Weights->GetEntry(k);
605    
606     if (reweight2010 || reweight2011) ST_s_t_Plot->Fill(st_s_t, st_s_t_w);
607     else ST_s_t_Plot->Fill(st_s_t);
608    
609     }
610    
611     ST_s_t_Plot->SetFillColor(kMagenta);
612    
613     double st_s_t_scale = data_lumi / singletop_s_t_lumi;
614     ST_s_t_Plot->Scale( st_s_t_scale, "" );
615    
616     if (logScale) c2_s_t->SetLogy();
617    
618     ST_s_t_Plot->Draw();
619    
620     //f->cd();
621    
622     //ST_s_Plot->Write();
623    
624     c2_s_t->Update();
625     //c2_s->Print( "SingleTop_s_"+VariableList[i]+PlotType );
626     delete c2_s_t;
627    
628    
629    
630     //SingleTop_tChannel
631     float st_t_t;
632     float st_t_t_w;
633    
634     int entries_st_t_t = singletop_t_t_tree->GetEntries();
635     TH1F *ST_t_t_Plot = new TH1F( "SingleTop_t_t_"+VariableList[i], "SingleTop_t_t_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
636     TBranch *ST_t_t_Branch = singletop_t_t_tree->GetBranch( VariableList[i] );
637     if (reweight2010 || reweight2011) TBranch *ST_t_t_Weights = singletop_t_t_tree->GetBranch( weightBranch );
638    
639     ST_t_t_Branch->SetAddress(&st_t_t);
640     if (reweight2010 || reweight2011) ST_t_t_Weights->SetAddress(&st_t_t_w);
641    
642     TCanvas* c2_t_t = new TCanvas();
643     c2_t_t->cd();
644    
645     for ( int k = 0; k < entries_st_t_t; k++ ) {
646    
647     ST_t_t_Branch->GetEntry(k);
648     if (reweight2010 || reweight2011) ST_t_t_Weights->GetEntry(k);
649    
650     if (reweight2010 || reweight2011) ST_t_t_Plot->Fill(st_t_t, st_t_t_w);
651     else ST_t_t_Plot->Fill(st_t_t);
652    
653     }
654    
655     ST_t_t_Plot->SetFillColor(kMagenta);
656    
657     double st_t_t_scale = data_lumi / singletop_t_t_lumi;
658     ST_t_t_Plot->Scale( st_t_t_scale, "" );
659    
660     if (logScale) c2_t_t->SetLogy();
661    
662     ST_t_t_Plot->Draw();
663    
664     //f->cd();
665    
666     //ST_t_Plot->Write();
667    
668     c2_t_t->Update();
669     //c2_t->Print( "SingleTop_t_"+VariableList[i]+PlotType );
670     delete c2_t_t;
671    
672    
673    
674     //SingleTop_tChannel
675     float st_tw_t;
676     float st_tw_t_w;
677    
678     int entries_st_tw_t = singletop_tw_t_tree->GetEntries();
679     TH1F *ST_tw_t_Plot = new TH1F( "SingleTop_tw_t_"+VariableList[i], "SingleTop_tw_t_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
680     TBranch *ST_tw_t_Branch = singletop_tw_t_tree->GetBranch( VariableList[i] );
681     if (reweight2010 || reweight2011) TBranch *ST_tw_t_Weights = singletop_tw_t_tree->GetBranch( weightBranch );
682    
683     ST_tw_t_Branch->SetAddress(&st_tw_t);
684     if (reweight2010 || reweight2011) ST_tw_t_Weights->SetAddress(&st_tw_t_w);
685    
686     TCanvas* c2_tw_t = new TCanvas();
687     c2_tw_t->cd();
688    
689     for ( int k = 0; k < entries_st_tw_t; k++ ) {
690    
691    
692     ST_tw_t_Branch->GetEntry(k);
693     if (reweight2010 || reweight2011) ST_tw_t_Weights->GetEntry(k);
694    
695     if (reweight2010 || reweight2011) ST_tw_t_Plot->Fill(st_tw_t, st_tw_t_w);
696     else ST_tw_t_Plot->Fill(st_tw_t);
697     }
698    
699     ST_tw_t_Plot->SetFillColor(kMagenta);
700    
701     double st_tw_t_scale = data_lumi / singletop_tw_t_lumi;
702     ST_tw_t_Plot->Scale( st_tw_t_scale, "" );
703    
704     if (logScale) c2_tw_t->SetLogy();
705    
706     ST_tw_t_Plot->Draw();
707    
708     //f->cd();
709    
710     //ST_tw_Plot->Write();
711    
712     c2_tw_t->Update();
713     //c2_tw->Print( "SingleTop_tw_"+VariableList[i]+PlotType );
714     delete c2_tw_t;
715    
716    
717    
718    
719    
720     //SingleTop_sChannel
721     float st_s_tbar;
722     float st_s_tbar_w;
723    
724     int entries_st_s_tbar = singletop_s_tbar_tree->GetEntries();
725     TH1F *ST_s_tbar_Plot = new TH1F( "SingleTop_s_tbar_"+VariableList[i], "SingleTop_s_tbar_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
726     TBranch *ST_s_tbar_Branch = singletop_s_tbar_tree->GetBranch( VariableList[i] );
727     if (reweight2010 || reweight2011) TBranch *ST_s_tbar_Weights = singletop_s_tbar_tree->GetBranch( weightBranch );
728    
729     ST_s_tbar_Branch->SetAddress(&st_s_tbar);
730     if (reweight2010 || reweight2011) ST_s_tbar_Weights->SetAddress(&st_s_tbar_w);
731    
732     TCanvas* c2_s_tbar = new TCanvas();
733     c2_s_tbar->cd();
734    
735     for ( int k = 0; k < entries_st_s_tbar; k++ ) {
736    
737    
738     ST_s_tbar_Branch->GetEntry(k);
739     if (reweight2010 || reweight2011) ST_s_tbar_Weights->GetEntry(k);
740    
741     if (reweight2010 || reweight2011) ST_s_tbar_Plot->Fill(st_s_tbar, st_s_tbar_w);
742     else ST_s_tbar_Plot->Fill(st_s_tbar);
743    
744     }
745    
746     ST_s_tbar_Plot->SetFillColor(kMagenta);
747    
748     double st_s_tbar_scale = data_lumi / singletop_s_tbar_lumi;
749     ST_s_tbar_Plot->Scale( st_s_tbar_scale, "" );
750    
751     if (logScale) c2_s_tbar->SetLogy();
752    
753     ST_s_tbar_Plot->Draw();
754    
755     //f->cd();
756    
757     //ST_s_Plot->Write();
758    
759     c2_s_tbar->Update();
760     //c2_s->Print( "SingleTop_s_"+VariableList[i]+PlotType );
761     delete c2_s_tbar;
762    
763    
764    
765    
766     //SingleTop_tChannel
767     float st_t_tbar;
768     float st_t_tbar_w;
769    
770     int entries_st_t_tbar = singletop_t_tbar_tree->GetEntries();
771     TH1F *ST_t_tbar_Plot = new TH1F( "SingleTop_t_tbar_"+VariableList[i], "SingleTop_t_tbar_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
772     TBranch *ST_t_tbar_Branch = singletop_t_tbar_tree->GetBranch( VariableList[i] );
773     if (reweight2010 || reweight2011) TBranch *ST_t_tbar_Weights = singletop_t_tbar_tree->GetBranch( weightBranch );
774    
775     ST_t_tbar_Branch->SetAddress(&st_t_tbar);
776     if (reweight2010 || reweight2011) ST_t_tbar_Weights->SetAddress(&st_t_tbar_w);
777    
778     TCanvas* c2_t_tbar = new TCanvas();
779     c2_t_tbar->cd();
780    
781     for ( int k = 0; k < entries_st_t_tbar; k++ ) {
782    
783     ST_t_tbar_Branch->GetEntry(k);
784     if (reweight2010 || reweight2011) ST_t_tbar_Weights->GetEntry(k);
785    
786     if (reweight2010 || reweight2011) ST_t_tbar_Plot->Fill(st_t_tbar, st_t_tbar_w);
787     else ST_t_tbar_Plot->Fill(st_t_tbar);
788    
789     }
790    
791     ST_t_tbar_Plot->SetFillColor(kMagenta);
792    
793     double st_t_tbar_scale = data_lumi / singletop_t_tbar_lumi;
794     ST_t_tbar_Plot->Scale( st_t_tbar_scale, "" );
795    
796     if (logScale) c2_t_tbar->SetLogy();
797    
798     ST_t_tbar_Plot->Draw();
799    
800     //f->cd();
801    
802     //ST_t_Plot->Write();
803    
804     c2_t_tbar->Update();
805     //c2_t->Print( "SingleTop_t_"+VariableList[i]+PlotType );
806     delete c2_t_tbar;
807    
808    
809    
810    
811     //SingleTop_tChannel
812     float st_tw_tbar;
813     float st_tw_tbar_w;
814    
815     int entries_st_tw_tbar = singletop_tw_tbar_tree->GetEntries();
816     TH1F *ST_tw_tbar_Plot = new TH1F( "SingleTop_tw_tbar_"+VariableList[i], "SingleTop_tw_tbar_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
817     TBranch *ST_tw_tbar_Branch = singletop_tw_tbar_tree->GetBranch( VariableList[i] );
818     if (reweight2010 || reweight2011) TBranch *ST_tw_tbar_Weights = singletop_tw_tbar_tree->GetBranch( weightBranch );
819    
820     ST_tw_tbar_Branch->SetAddress(&st_tw_tbar);
821     if (reweight2010 || reweight2011) ST_tw_tbar_Weights->SetAddress(&st_tw_tbar_w);
822    
823     TCanvas* c2_tw_tbar = new TCanvas();
824     c2_tw_tbar->cd();
825    
826     for ( int k = 0; k < entries_st_tw_tbar; k++ ) {
827    
828    
829     ST_tw_tbar_Branch->GetEntry(k);
830     if (reweight2010 || reweight2011) ST_tw_tbar_Weights->GetEntry(k);
831    
832     if (reweight2010 || reweight2011) ST_tw_tbar_Plot->Fill(st_tw_tbar, st_tw_tbar_w);
833     else ST_tw_tbar_Plot->Fill(st_tw_tbar);
834     }
835    
836     ST_tw_tbar_Plot->SetFillColor(kMagenta);
837    
838     double st_tw_tbar_scale = data_lumi / singletop_tw_tbar_lumi;
839     ST_tw_tbar_Plot->Scale( st_tw_tbar_scale, "" );
840    
841     if (logScale) c2_tw_tbar->SetLogy();
842    
843     ST_tw_tbar_Plot->Draw();
844    
845     //f->cd();
846    
847     //ST_tw_Plot->Write();
848    
849     c2_tw_tbar->Update();
850     //c2_tw->Print( "SingleTop_tw_"+VariableList[i]+PlotType );
851     delete c2_tw_tbar;
852    
853    
854    
855    
856    
857    
858     //WJets
859     double wjscale = data_lumi / wjets_lumi;
860    
861     float wj;
862     float wj_w;
863    
864     int entries_wj = wjets_tree->GetEntries();
865     TH1F *wjPlot = new TH1F( "wjets_"+VariableList[i], "wjets_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
866     TBranch *WJBranch = wjets_tree->GetBranch( VariableList[i] );
867     if (reweight2010 || reweight2011) TBranch *WJWeights = wjets_tree->GetBranch(weightBranch);
868    
869     WJBranch->SetAddress(&wj);
870     if (reweight2010 || reweight2011) WJWeights->SetAddress(&wj_w);
871    
872     TCanvas* c3 = new TCanvas();
873     c3->cd();
874    
875     for ( int l = 0; l < entries_wj; l++ ) {
876    
877     WJBranch->GetEntry(l);
878     if (reweight2010 || reweight2011) WJWeights->GetEntry(l);
879     if (reweight2010 || reweight2011) wjPlot->Fill(wj, wj_w);
880     else wjPlot->Fill(wj);
881    
882     }
883    
884     wjPlot->SetFillColor(kGreen);
885    
886     wjPlot->Scale( wjscale, "" );
887    
888     if (logScale) c3->SetLogy();
889    
890     wjPlot->Draw();
891    
892     f->cd();
893    
894     wjPlot->Write();
895    
896     c3->Update();
897     //c3->Print( "WJets_"+VariableList[i]+PlotType );
898     delete c3;
899    
900    
901     /*
902    
903     float wj1;
904     float wj_w1;
905    
906     int entries_wj1 = wjets_tree1->GetEntries();
907     TH1F *WJPlot1 = new TH1F( "WJets1_"+VariableList[i], "WJets1_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
908     TBranch *WJBranch1 = wjets_tree1->GetBranch( VariableList[i] );
909     if (reweight2010 || reweight2011) TBranch *WJWeights1 = wjets_tree1->GetBranch(weightBranch);
910    
911     WJBranch1->SetAddress(&wj1);
912     if (reweight2010 || reweight2011) WJWeights1->SetAddress(&wj_w1);
913    
914     TCanvas* c3 = new TCanvas();
915     c3->cd();
916    
917     for ( int l = 0; l < entries_wj1; l++ ) {
918    
919     WJBranch1->GetEntry(l);
920     if (reweight2010 || reweight2011) WJWeights1->GetEntry(l);
921     if (reweight2010 || reweight2011) WJPlot1->Fill(wj1, wj_w1);
922     else WJPlot1->Fill(wj1);
923    
924     }
925    
926     WJPlot1->SetFillColor(kGreen);
927    
928     WJPlot1->Scale( wjscale*wjscale30, "" );
929    
930     if (logScale) c3->SetLogy();
931    
932     WJPlot1->Draw();
933    
934     f->cd();
935    
936     WJPlot1->Write();
937    
938     c3->Update();
939     //c3->Print( "WJets_"+VariableList[i]+PlotType );
940     delete c3;
941    
942    
943    
944    
945     float wj2;
946     float wj_w2;
947    
948     int entries_wj2 = wjets_tree2->GetEntries();
949     TH1F *WJPlot2 = new TH1F( "WJets2_"+VariableList[i], "WJets2_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
950     TBranch *WJBranch2 = wjets_tree2->GetBranch( VariableList[i] );
951     if (reweight2010 || reweight2011) TBranch *WJWeights2 = wjets_tree2->GetBranch(weightBranch);
952    
953     WJBranch2->SetAddress(&wj2);
954     if (reweight2010 || reweight2011) WJWeights2->SetAddress(&wj_w2);
955    
956     TCanvas* c3 = new TCanvas();
957     c3->cd();
958    
959     for ( int l = 0; l < entries_wj2; l++ ) {
960    
961     WJBranch2->GetEntry(l);
962     if (reweight2010 || reweight2011) WJWeights2->GetEntry(l);
963     if (reweight2010 || reweight2011) WJPlot2->Fill(wj2, wj_w2);
964     else WJPlot2->Fill(wj2);
965    
966     }
967    
968     WJPlot2->SetFillColor(kGreen);
969    
970     WJPlot2->Scale( wjscale*wjscale31, "" );
971    
972     if (logScale) c3->SetLogy();
973    
974     WJPlot2->Draw();
975    
976     f->cd();
977    
978     WJPlot2->Write();
979    
980     c3->Update();
981     //c3->Print( "WJets_"+VariableList[i]+PlotType );
982     delete c3;
983    
984    
985    
986    
987    
988     float wj3;
989     float wj_w3;
990    
991     int entries_wj3 = wjets_tree3->GetEntries();
992     TH1F *WJPlot3 = new TH1F( "WJets3_"+VariableList[i], "WJets3_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
993     TBranch *WJBranch3 = wjets_tree3->GetBranch( VariableList[i] );
994     if (reweight2010 || reweight2011) TBranch *WJWeights3 = wjets_tree3->GetBranch(weightBranch);
995    
996     WJBranch3->SetAddress(&wj3);
997     if (reweight2010 || reweight2011) WJWeights3->SetAddress(&wj_w3);
998    
999     TCanvas* c3 = new TCanvas();
1000     c3->cd();
1001    
1002     for ( int l = 0; l < entries_wj3; l++ ) {
1003    
1004     WJBranch3->GetEntry(l);
1005     if (reweight2010 || reweight2011) WJWeights3->GetEntry(l);
1006     if (reweight2010 || reweight2011) WJPlot3->Fill(wj3, wj_w3);
1007     else WJPlot3->Fill(wj3);
1008    
1009     }
1010    
1011     WJPlot3->SetFillColor(kGreen);
1012    
1013     WJPlot3->Scale( wjscale*wjscale32, "" );
1014    
1015     if (logScale) c3->SetLogy();
1016    
1017     WJPlot3->Draw();
1018    
1019     f->cd();
1020    
1021     WJPlot3->Write();
1022    
1023     c3->Update();
1024     //c3->Print( "WJets_"+VariableList[i]+PlotType );
1025     delete c3;
1026    
1027    
1028    
1029    
1030     float wj4;
1031     float wj_w4;
1032    
1033     int entries_wj4 = wjets_tree4->GetEntries();
1034     TH1F *WJPlot4 = new TH1F( "WJets4_"+VariableList[i], "WJets4_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1035     TBranch *WJBranch4 = wjets_tree4->GetBranch( VariableList[i] );
1036     if (reweight2010 || reweight2011) TBranch *WJWeights4 = wjets_tree4->GetBranch(weightBranch);
1037    
1038     WJBranch4->SetAddress(&wj4);
1039     if (reweight2010 || reweight2011) WJWeights4->SetAddress(&wj_w4);
1040    
1041     TCanvas* c3 = new TCanvas();
1042     c3->cd();
1043    
1044     for ( int l = 0; l < entries_wj4; l++ ) {
1045    
1046     WJBranch4->GetEntry(l);
1047     if (reweight2010 || reweight2011) WJWeights4->GetEntry(l);
1048     if (reweight2010 || reweight2011) WJPlot4->Fill(wj4, wj_w4);
1049     else WJPlot4->Fill(wj4);
1050    
1051     }
1052    
1053     WJPlot4->SetFillColor(kGreen);
1054    
1055     WJPlot4->Scale( wjscale*wjscale40, "" );
1056    
1057     if (logScale) c3->SetLogy();
1058    
1059     WJPlot4->Draw();
1060    
1061     f->cd();
1062    
1063     WJPlot4->Write();
1064    
1065     c3->Update();
1066     //c3->Print( "WJets_"+VariableList[i]+PlotType );
1067     delete c3;
1068    
1069    
1070    
1071    
1072     float wj5;
1073     float wj_w5;
1074    
1075     int entries_wj5 = wjets_tree5->GetEntries();
1076     TH1F *WJPlot5 = new TH1F( "WJets5_"+VariableList[i], "WJets5_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1077     TBranch *WJBranch5 = wjets_tree5->GetBranch( VariableList[i] );
1078     if (reweight2010 || reweight2011) TBranch *WJWeights5 = wjets_tree5->GetBranch(weightBranch);
1079    
1080     WJBranch5->SetAddress(&wj5);
1081     if (reweight2010 || reweight2011) WJWeights5->SetAddress(&wj_w5);
1082    
1083     TCanvas* c3 = new TCanvas();
1084     c3->cd();
1085    
1086     for ( int l = 0; l < entries_wj5; l++ ) {
1087    
1088     WJBranch5->GetEntry(l);
1089     if (reweight2010 || reweight2011) WJWeights5->GetEntry(l);
1090     if (reweight2010 || reweight2011) WJPlot5->Fill(wj5, wj_w5);
1091     else WJPlot5->Fill(wj5);
1092    
1093     }
1094    
1095     WJPlot5->SetFillColor(kGreen);
1096    
1097     WJPlot5->Scale( wjscale*wjscale41, "" );
1098    
1099     if (logScale) c3->SetLogy();
1100    
1101     WJPlot5->Draw();
1102    
1103     f->cd();
1104    
1105     WJPlot5->Write();
1106    
1107     c3->Update();
1108     //c3->Print( "WJets_"+VariableList[i]+PlotType );
1109     delete c3;
1110    
1111    
1112    
1113    
1114     float wj6;
1115     float wj_w6;
1116    
1117     int entries_wj6 = wjets_tree6->GetEntries();
1118     TH1F *WJPlot6 = new TH1F( "WJets6_"+VariableList[i], "WJets6_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1119     TBranch *WJBranch6 = wjets_tree6->GetBranch( VariableList[i] );
1120     if (reweight2010 || reweight2011) TBranch *WJWeights6 = wjets_tree6->GetBranch(weightBranch);
1121    
1122     WJBranch6->SetAddress(&wj6);
1123     if (reweight2010 || reweight2011) WJWeights6->SetAddress(&wj_w6);
1124    
1125     TCanvas* c3 = new TCanvas();
1126     c3->cd();
1127    
1128     for ( int l = 0; l < entries_wj6; l++ ) {
1129    
1130     WJBranch6->GetEntry(l);
1131     if (reweight2010 || reweight2011) WJWeights6->GetEntry(l);
1132     if (reweight2010 || reweight2011) WJPlot6->Fill(wj6, wj_w6);
1133     else WJPlot6->Fill(wj6);
1134    
1135     }
1136    
1137     WJPlot6->SetFillColor(kGreen);
1138    
1139     WJPlot6->Scale( wjscale*wjscale42, "" );
1140    
1141     if (logScale) c3->SetLogy();
1142    
1143     WJPlot6->Draw();
1144    
1145     f->cd();
1146    
1147     WJPlot6->Write();
1148    
1149     c3->Update();
1150     //c3->Print( "WJets_"+VariableList[i]+PlotType );
1151     delete c3;
1152    
1153    
1154     */
1155    
1156    
1157    
1158     //ZJets
1159    
1160     float zj;
1161     float zj_w;
1162    
1163     int entries_zj = zjets_tree->GetEntries();
1164     TH1F *ZJPlot = new TH1F( "ZJets_"+VariableList[i], "ZJets_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1165     TBranch *ZJBranch = zjets_tree->GetBranch( VariableList[i] );
1166     if (reweight2010 || reweight2011) TBranch *ZJWeights = zjets_tree->GetBranch( weightBranch );
1167    
1168     ZJBranch->SetAddress(&zj);
1169     if (reweight2010 || reweight2011) ZJWeights->SetAddress(&zj_w);
1170    
1171     TCanvas* c4 = new TCanvas();
1172     c4->cd();
1173    
1174     for ( int m = 0; m < entries_zj; m++ ) {
1175    
1176    
1177     ZJBranch->GetEntry(m);
1178     if (reweight2010 || reweight2011) ZJWeights->GetEntry(m);
1179     if (reweight2010 || reweight2011) ZJPlot->Fill(zj, zj_w);
1180     else ZJPlot->Fill(zj);
1181    
1182     }
1183    
1184     ZJPlot->SetFillColor(kAzure-2);
1185    
1186     double zjscale = data_lumi / zjets_lumi;
1187     ZJPlot->Scale( zjscale, "" );
1188    
1189     if (logScale) c4->SetLogy();
1190    
1191     ZJPlot->Draw();
1192    
1193     f->cd();
1194    
1195     ZJPlot->Write();
1196    
1197     c4->Update();
1198     //c4->Print( "ZJets_"+VariableList[i]+PlotType );
1199     delete c4;
1200    
1201    
1202     /*
1203     //WW
1204    
1205     float ww;
1206     float ww_w;
1207    
1208     int entries_ww = ww_tree->GetEntries();
1209     TH1F *WWPlot = new TH1F( "WW_"+VariableList[i], "WW_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1210     TBranch *WWBranch = ww_tree->GetBranch( VariableList[i] );
1211     if (reweight2010 || reweight2011) TBranch *WWWeights = ww_tree->GetBranch( weightBranch );
1212    
1213     WWBranch->SetAddress(&ww);
1214     if (reweight2010 || reweight2011) WWWeights->SetAddress(&ww_w);
1215    
1216     TCanvas* c5_ww = new TCanvas();
1217     c5_ww->cd();
1218    
1219     for ( int n = 0; n < entries_ww; n++ ) {
1220    
1221    
1222     WWBranch->GetEntry(n);
1223     if (reweight2010 || reweight2011) WWWeights->GetEntry(n);
1224     if (reweight2010 || reweight2011) WWPlot->Fill(ww, ww_w);
1225     else WWPlot->Fill(ww);
1226    
1227     }
1228    
1229     WWPlot->SetFillColor(kBlue);
1230    
1231     double wwscale = data_lumi / ww_lumi;
1232     WWPlot->Scale( wwscale, "" );
1233    
1234     if (logScale) c5_ww->SetLogy();
1235    
1236     WWPlot->Draw();
1237    
1238     //f->cd();
1239    
1240     //WWPlot->Write();
1241    
1242     c5_ww->Update();
1243     //c5_ww->Print( "WW_"+VariableList[i]+PlotType );
1244     delete c5_ww;
1245    
1246    
1247    
1248     //WZ
1249    
1250     float wz;
1251     float wz_w;
1252    
1253     int entries_wz = wz_tree->GetEntries();
1254     TH1F *WZPlot = new TH1F( "WZ_"+VariableList[i], "WZ_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1255     TBranch *WZBranch = wz_tree->GetBranch( VariableList[i] );
1256     if (reweight2010 || reweight2011) TBranch *WZWeights = wz_tree->GetBranch( weightBranch );
1257    
1258     WZBranch->SetAddress(&wz);
1259     if (reweight2010 || reweight2011) WZWeights->SetAddress(&wz_w);
1260    
1261     TCanvas* c5_wz = new TCanvas();
1262     c5_wz->cd();
1263    
1264     for ( int n = 0; n < entries_wz; n++ ) {
1265    
1266    
1267     WZBranch->GetEntry(n);
1268     if (reweight2010 || reweight2011) WZWeights->GetEntry(n);
1269     if (reweight2010 || reweight2011) WZPlot->Fill(wz, wz_w);
1270     else WZPlot->Fill(wz);
1271    
1272     }
1273    
1274     WZPlot->SetFillColor(kBlue);
1275    
1276     double wzscale = data_lumi / wz_lumi;
1277     WZPlot->Scale( wzscale, "" );
1278    
1279     if (logScale) c5_wz->SetLogy();
1280    
1281     WZPlot->Draw();
1282    
1283     //f->cd();
1284    
1285     //WZPlot->Write();
1286    
1287     c5_wz->Update();
1288     //c5_wz->Print( "WZ_"+VariableList[i]+PlotType );
1289    
1290     delete c5_wz;
1291    
1292    
1293    
1294     //ZZ
1295    
1296     float zz;
1297     float zz_w;
1298    
1299     int entries_zz = zz_tree->GetEntries();
1300     TH1F *ZZPlot = new TH1F( "ZZ_"+VariableList[i], "ZZ_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1301     TBranch *ZZBranch = zz_tree->GetBranch( VariableList[i] );
1302     if (reweight2010 || reweight2011) TBranch *ZZWeights = zz_tree->GetBranch( weightBranch );
1303    
1304     ZZBranch->SetAddress(&zz);
1305     if (reweight2010 || reweight2011) ZZWeights->SetAddress(&zz_w);
1306    
1307     TCanvas* c5_zz = new TCanvas();
1308     c5_zz->cd();
1309    
1310     for ( int n = 0; n < entries_zz; n++ ) {
1311    
1312    
1313     ZZBranch->GetEntry(n);
1314     if (reweight2010 || reweight2011) ZZWeights->GetEntry(n);
1315     if (reweight2010 || reweight2011) ZZPlot->Fill(zz, zz_w);
1316     else ZZPlot->Fill(zz);
1317    
1318     }
1319    
1320     ZZPlot->SetFillColor(kBlue);
1321    
1322     double zzscale = data_lumi / zz_lumi;
1323     ZZPlot->Scale( zzscale, "" );
1324    
1325     if (logScale) c5_zz->SetLogy();
1326    
1327     ZZPlot->Draw();
1328    
1329     //f->cd();
1330    
1331     //ZZPlot->Write();
1332    
1333     c5_zz->Update();
1334     //c5_zz->Print( "ZZ_"+VariableList[i]+PlotType );
1335     delete c5_zz;
1336    
1337    
1338     */
1339    
1340    
1341    
1342    
1343     //QCD
1344     double qcdscale = data_lumi / qcd_lumi;
1345    
1346     float qcd1;
1347     float qcd_w1;
1348    
1349     int entries_qcd1 = qcd_tree1->GetEntries();
1350     TH1F *QCDPlot1 = new TH1F( "QCD1_"+VariableList[i], "QCD1_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1351     TBranch *QCDBranch1 = qcd_tree1->GetBranch( VariableList[i] );
1352     if (reweight2010 || reweight2011) TBranch *QCDWeights1 = qcd_tree1->GetBranch( weightBranch );
1353    
1354     QCDBranch1->SetAddress(&qcd1);
1355     if (reweight2010 || reweight2011) QCDWeights1->SetAddress(&qcd_w1);
1356    
1357     TCanvas* c6 = new TCanvas();
1358     c6->cd();
1359    
1360     for ( int o = 0; o < entries_qcd1; o++ ) {
1361    
1362    
1363     QCDBranch1->GetEntry(o);
1364     if (reweight2010 || reweight2011) QCDWeights1->GetEntry(o);
1365     if (reweight2010 || reweight2011) QCDPlot1->Fill(qcd1, qcd_w1);
1366     else QCDPlot1->Fill(qcd1);
1367    
1368     }
1369    
1370     QCDPlot1->SetFillColor(kYellow);
1371    
1372     QCDPlot1->Scale( qcdscale*scale30, "" );
1373    
1374     if (logScale) c6->SetLogy();
1375    
1376     QCDPlot1->Draw();
1377    
1378     f->cd();
1379    
1380     QCDPlot1->Write();
1381    
1382     c6->Update();
1383     //c6->Print( "QCD_"+VariableList[i]+PlotType );
1384     delete c6;
1385    
1386    
1387    
1388    
1389    
1390     float qcd2;
1391     float qcd_w2;
1392    
1393     int entries_qcd2 = qcd_tree2->GetEntries();
1394     TH1F *QCDPlot2 = new TH1F( "QCD2_"+VariableList[i], "QCD2_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1395     TBranch *QCDBranch2 = qcd_tree2->GetBranch( VariableList[i] );
1396     if (reweight2010 || reweight2011) TBranch *QCDWeights2 = qcd_tree2->GetBranch( weightBranch );
1397    
1398     QCDBranch2->SetAddress(&qcd2);
1399     if (reweight2010 || reweight2011) QCDWeights2->SetAddress(&qcd_w2);
1400    
1401     TCanvas* c6 = new TCanvas();
1402     c6->cd();
1403    
1404     for ( int o = 0; o < entries_qcd2; o++ ) {
1405    
1406    
1407     QCDBranch2->GetEntry(o);
1408     if (reweight2010 || reweight2011) QCDWeights2->GetEntry(o);
1409     if (reweight2010 || reweight2011) QCDPlot2->Fill(qcd2, qcd_w2);
1410     else QCDPlot2->Fill(qcd2);
1411    
1412     }
1413    
1414     QCDPlot2->SetFillColor(kYellow);
1415    
1416     QCDPlot2->Scale( qcdscale*scale31, "" );
1417    
1418     if (logScale) c6->SetLogy();
1419    
1420     QCDPlot2->Draw();
1421    
1422     f->cd();
1423    
1424     QCDPlot2->Write();
1425    
1426     c6->Update();
1427     //c6->Print( "QCD_"+VariableList[i]+PlotType );
1428     delete c6;
1429    
1430    
1431    
1432     float qcd3;
1433     float qcd_w3;
1434    
1435     int entries_qcd3 = qcd_tree3->GetEntries();
1436     TH1F *QCDPlot3 = new TH1F( "QCD3_"+VariableList[i], "QCD3_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1437     TBranch *QCDBranch3 = qcd_tree3->GetBranch( VariableList[i] );
1438     if (reweight2010 || reweight2011) TBranch *QCDWeights3 = qcd_tree3->GetBranch( weightBranch );
1439    
1440     QCDBranch3->SetAddress(&qcd3);
1441     if (reweight2010 || reweight2011) QCDWeights3->SetAddress(&qcd_w3);
1442    
1443     TCanvas* c6 = new TCanvas();
1444     c6->cd();
1445    
1446     for ( int o = 0; o < entries_qcd3; o++ ) {
1447    
1448    
1449     QCDBranch3->GetEntry(o);
1450     if (reweight2010 || reweight2011) QCDWeights3->GetEntry(o);
1451     if (reweight2010 || reweight2011) QCDPlot3->Fill(qcd3, qcd_w3);
1452     else QCDPlot3->Fill(qcd3);
1453    
1454     }
1455    
1456     QCDPlot3->SetFillColor(kYellow);
1457    
1458     QCDPlot3->Scale( qcdscale*scale32, "" );
1459    
1460     if (logScale) c6->SetLogy();
1461    
1462     QCDPlot3->Draw();
1463    
1464     f->cd();
1465    
1466     QCDPlot3->Write();
1467    
1468     c6->Update();
1469     //c6->Print( "QCD_"+VariableList[i]+PlotType );
1470     delete c6;
1471    
1472    
1473    
1474     float qcd4;
1475     float qcd_w4;
1476    
1477     int entries_qcd4 = qcd_tree4->GetEntries();
1478     TH1F *QCDPlot4 = new TH1F( "QCD4_"+VariableList[i], "QCD4_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1479     TBranch *QCDBranch4 = qcd_tree4->GetBranch( VariableList[i] );
1480     if (reweight2010 || reweight2011) TBranch *QCDWeights4 = qcd_tree4->GetBranch( weightBranch );
1481    
1482     QCDBranch4->SetAddress(&qcd4);
1483     if (reweight2010 || reweight2011) QCDWeights4->SetAddress(&qcd_w4);
1484    
1485     TCanvas* c6 = new TCanvas();
1486     c6->cd();
1487    
1488     for ( int o = 0; o < entries_qcd4; o++ ) {
1489    
1490    
1491     QCDBranch4->GetEntry(o);
1492     if (reweight2010 || reweight2011) QCDWeights4->GetEntry(o);
1493     if (reweight2010 || reweight2011) QCDPlot4->Fill(qcd4, qcd_w4);
1494     else QCDPlot4->Fill(qcd4);
1495    
1496     }
1497    
1498     QCDPlot4->SetFillColor(kYellow);
1499    
1500     double qcdscale = data_lumi / qcd_lumi;
1501     QCDPlot4->Scale( qcdscale*scale40, "" );
1502    
1503     if (logScale) c6->SetLogy();
1504    
1505     QCDPlot4->Draw();
1506    
1507     f->cd();
1508    
1509     QCDPlot4->Write();
1510    
1511     c6->Update();
1512     //c6->Print( "QCD_"+VariableList[i]+PlotType );
1513     delete c6;
1514    
1515    
1516     float qcd5;
1517     float qcd_w5;
1518    
1519     int entries_qcd5 = qcd_tree5->GetEntries();
1520     TH1F *QCDPlot5 = new TH1F( "QCD5_"+VariableList[i], "QCD5_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1521     TBranch *QCDBranch5 = qcd_tree5->GetBranch( VariableList[i] );
1522     if (reweight2010 || reweight2011) TBranch *QCDWeights5 = qcd_tree5->GetBranch( weightBranch );
1523    
1524     QCDBranch5->SetAddress(&qcd5);
1525     if (reweight2010 || reweight2011) QCDWeights5->SetAddress(&qcd_w5);
1526    
1527     TCanvas* c6 = new TCanvas();
1528     c6->cd();
1529    
1530     for ( int o = 0; o < entries_qcd5; o++ ) {
1531    
1532    
1533     QCDBranch5->GetEntry(o);
1534     if (reweight2010 || reweight2011) QCDWeights5->GetEntry(o);
1535     if (reweight2010 || reweight2011) QCDPlot5->Fill(qcd5, qcd_w5);
1536     else QCDPlot5->Fill(qcd5);
1537    
1538     }
1539    
1540     QCDPlot5->SetFillColor(kYellow);
1541    
1542     QCDPlot5->Scale( qcdscale*scale41, "" );
1543    
1544     if (logScale) c6->SetLogy();
1545    
1546     QCDPlot5->Draw();
1547    
1548     f->cd();
1549    
1550     QCDPlot5->Write();
1551    
1552     c6->Update();
1553     //c6->Print( "QCD_"+VariableList[i]+PlotType );
1554     delete c6;
1555    
1556    
1557     float qcd6;
1558     float qcd_w6;
1559    
1560     int entries_qcd6 = qcd_tree6->GetEntries();
1561     TH1F *QCDPlot6 = new TH1F( "QCD6_"+VariableList[i], "QCD6_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1562     TBranch *QCDBranch6 = qcd_tree6->GetBranch( VariableList[i] );
1563     if (reweight2010 || reweight2011) TBranch *QCDWeights6 = qcd_tree6->GetBranch( weightBranch );
1564    
1565     QCDBranch6->SetAddress(&qcd6);
1566     if (reweight2010 || reweight2011) QCDWeights6->SetAddress(&qcd_w6);
1567    
1568     TCanvas* c6 = new TCanvas();
1569     c6->cd();
1570    
1571     for ( int o = 0; o < entries_qcd6; o++ ) {
1572    
1573    
1574     QCDBranch6->GetEntry(o);
1575     if (reweight2010 || reweight2011) QCDWeights6->GetEntry(o);
1576     if (reweight2010 || reweight2011) QCDPlot6->Fill(qcd6, qcd_w6);
1577     else QCDPlot6->Fill(qcd6);
1578    
1579     }
1580    
1581     QCDPlot6->SetFillColor(kYellow);
1582    
1583     QCDPlot6->Scale( qcdscale*scale42, "" );
1584    
1585     if (logScale) c6->SetLogy();
1586    
1587     QCDPlot6->Draw();
1588    
1589     f->cd();
1590    
1591     QCDPlot6->Write();
1592    
1593     c6->Update();
1594     //c6->Print( "QCD_"+VariableList[i]+PlotType );
1595     delete c6;
1596    
1597    
1598    
1599     float qcd;
1600     float qcd_w;
1601    
1602     int entries_qcd = qcd_tree->GetEntries();
1603     TH1F *qcdPlot = new TH1F( "qcd_"+VariableList[i], "qcd_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1604     TBranch *QCDBranch = qcd_tree->GetBranch( VariableList[i] );
1605     if (reweight2010 || reweight2011) TBranch *QCDWeights = qcd_tree->GetBranch( weightBranch );
1606    
1607     QCDBranch->SetAddress(&qcd);
1608     if (reweight2010 || reweight2011) QCDWeights->SetAddress(&qcd_w);
1609    
1610     TCanvas* c6 = new TCanvas();
1611     c6->cd();
1612    
1613     for ( int o = 0; o < entries_qcd; o++ ) {
1614    
1615    
1616     QCDBranch->GetEntry(o);
1617     if (reweight2010 || reweight2011) QCDWeights->GetEntry(o);
1618     if (reweight2010 || reweight2011) qcdPlot->Fill(qcd, qcd_w);
1619     else qcdPlot->Fill(qcd);
1620    
1621     }
1622    
1623     qcdPlot->SetFillColor(kYellow);
1624    
1625    
1626     double qcdscale = data_lumi / qcd_lumi;
1627     qcdPlot->Scale( qcdscale, "" );
1628    
1629     if (logScale) c6->SetLogy();
1630    
1631     qcdPlot->Draw();
1632    
1633     f->cd();
1634    
1635     qcdPlot->Write();
1636    
1637     c6->Update();
1638     //c6->Print( "QCD_"+VariableList[i]+PlotType );
1639     delete c6;
1640    
1641    
1642    
1643    
1644    
1645     TCanvas* c6 = new TCanvas();
1646     c6->cd();
1647    
1648     TH1F *QCDPlot = new TH1F( "QCD_"+VariableList[i], "QCD_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1649    
1650    
1651     if (splitQCD){
1652     QCDPlot->Add(QCDPlot1);
1653     QCDPlot->Add(QCDPlot2);
1654     QCDPlot->Add(QCDPlot3);
1655     QCDPlot->Add(QCDPlot4);
1656     QCDPlot->Add(QCDPlot5);
1657     QCDPlot->Add(QCDPlot6);
1658     }
1659     else QCDPlot->Add(qcdPlot);
1660    
1661     if (logScale) c6->SetLogy();
1662    
1663     QCDPlot->SetFillColor(kYellow);
1664    
1665     QCDPlot->Draw();
1666    
1667     f->cd();
1668    
1669     QCDPlot->Write();
1670    
1671     c6->Update();
1672     //c6->Print( "QCD_"+VariableList[i]+PlotType );
1673     delete c6;
1674    
1675    
1676    
1677    
1678     TCanvas* c6 = new TCanvas();
1679     c6->cd();
1680    
1681     TH1F *TTPlot = new TH1F( "TT_"+VariableList[i], "TT_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1682    
1683    
1684     if (splitTT){
1685     TTPlot->Add(TTPlot1);
1686     TTPlot->Add(TTPlot2);
1687     TTPlot->Add(TTPlot3);
1688     TTPlot->Add(TTPlot4);
1689     TTPlot->Add(TTPlot5);
1690     TTPlot->Add(TTPlot6);
1691     }
1692     else TTPlot->Add(ttPlot);
1693    
1694     if (logScale) c6->SetLogy();
1695    
1696     TTPlot->SetFillColor(kRed+1);
1697    
1698     TTPlot->Draw();
1699    
1700     f->cd();
1701    
1702     TTPlot->Write();
1703    
1704     c6->Update();
1705     //c6->Print( "QCD_"+VariableList[i]+PlotType );
1706     delete c6;
1707    
1708    
1709    
1710    
1711     TCanvas* c6 = new TCanvas();
1712     c6->cd();
1713    
1714     TH1F *WJPlot = new TH1F( "WJ_"+VariableList[i], "WJ_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1715    
1716    
1717     if (splitWJ){
1718     WJPlot->Add(WJPlot1);
1719     WJPlot->Add(WJPlot2);
1720     WJPlot->Add(WJPlot3);
1721     WJPlot->Add(WJPlot4);
1722     WJPlot->Add(WJPlot5);
1723     WJPlot->Add(WJPlot6);
1724     }
1725     else WJPlot->Add(wjPlot);
1726    
1727     if (logScale) c6->SetLogy();
1728    
1729     WJPlot->SetFillColor(kGreen);
1730    
1731     WJPlot->Draw();
1732    
1733     f->cd();
1734    
1735     WJPlot->Write();
1736    
1737     c6->Update();
1738     //c6->Print( "QCD_"+VariableList[i]+PlotType );
1739     delete c6;
1740    
1741    
1742    
1743    
1744    
1745     TCanvas* c6 = new TCanvas();
1746     c6->cd();
1747    
1748     TH1F *STPlot = new TH1F( "ST_"+VariableList[i], "ST_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1749    
1750     if (logScale) c6->SetLogy();
1751    
1752     STPlot->Add(ST_s_t_Plot);
1753     STPlot->Add(ST_t_t_Plot);
1754     STPlot->Add(ST_tw_t_Plot);
1755     STPlot->Add(ST_s_tbar_Plot);
1756     STPlot->Add(ST_t_tbar_Plot);
1757     STPlot->Add(ST_tw_tbar_Plot);
1758    
1759     STPlot->SetFillColor(kMagenta);
1760    
1761     STPlot->Draw();
1762    
1763     f->cd();
1764    
1765     STPlot->Write();
1766    
1767     c6->Update();
1768     //c6->Print( "QCD_"+VariableList[i]+PlotType );
1769     delete c6;
1770    
1771    
1772    
1773     /*
1774     TCanvas* c6 = new TCanvas();
1775     c6->cd();
1776    
1777     TH1F *VVPlot = new TH1F( "VV_"+VariableList[i], "VV_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1778    
1779     if (logScale) c6->SetLogy();
1780    
1781     VVPlot->Add(WWPlot);
1782     VVPlot->Add(WZPlot);
1783     VVPlot->Add(ZZPlot);
1784    
1785     VVPlot->SetFillColor(kBlue);
1786    
1787     VVPlot->Draw();
1788    
1789     f->cd();
1790    
1791     VVPlot->Write();
1792    
1793     c6->Update();
1794     //c6->Print( "QCD_"+VariableList[i]+PlotType );
1795     delete c6;
1796     */
1797    
1798    
1799    
1800    
1801     //ZPrime
1802    
1803     /*
1804     float zp750;
1805    
1806     int entries_zp750 = zprime750_tree->GetEntries();
1807     TH1F *ZPrime750Plot = new TH1F( "ZPrime750_"+VariableList[i], "ZPrime750_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1808     TBranch *ZPrime750Branch = zprime750_tree->GetBranch( VariableList[i] );
1809    
1810     ZPrime750Branch->SetAddress(&zp750);
1811    
1812     TCanvas* cz1 = new TCanvas("c1","", 800, 600);
1813     cz1->cd();
1814    
1815     for ( int z1 = 0; z1 < entries_zp750; z1++ ) {
1816    
1817     ZPrime750Branch->GetEntry(z1);
1818     ZPrime750Plot->Fill(zp750);
1819    
1820     }
1821    
1822     ZPrime750Plot->SetFillColor(kOrange);
1823    
1824     //double zprimescale = data_lumi / zprime_lumi;
1825     //ZPrime750Plot->Scale( zprimescale, "" );
1826    
1827    
1828     ZPrime750Plot->Draw();
1829    
1830     f->cd();
1831    
1832     ZPrime750Plot->Write();
1833    
1834     cz1->Update();
1835     //cz1->Print( "ZPrime750_"+VariableList[i]+PlotType );
1836     delete cz1;
1837    
1838    
1839    
1840     float zp1000;
1841    
1842     int entries_zp1000 = zprime1000_tree->GetEntries();
1843     TH1F *ZPrime1000Plot = new TH1F( "ZPrime1000_"+VariableList[i], "ZPrime1000_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1844     TBranch *ZPrime1000Branch = zprime1000_tree->GetBranch( VariableList[i] );
1845    
1846     ZPrime1000Branch->SetAddress(&zp1000);
1847    
1848     TCanvas* cz2 = new TCanvas("c1","", 800, 600);
1849     cz2->cd();
1850    
1851     for ( int z2 = 0; z2 < entries_zp1000; z2++ ) {
1852    
1853     ZPrime1000Branch->GetEntry(z2);
1854     ZPrime1000Plot->Fill(zp1000);
1855    
1856     }
1857    
1858     ZPrime1000Plot->SetFillColor(kOrange);
1859    
1860     //double zprimescale = data_lumi / zprime_lumi;
1861     //ZPrime1000Plot->Scale( zprimescale, "" );
1862    
1863    
1864     ZPrime1000Plot->Draw();
1865    
1866     f->cd();
1867    
1868     ZPrime1000Plot->Write();
1869    
1870     cz2->Update();
1871     //cz2->Print( "ZPrime1000_"+VariableList[i]+PlotType );
1872     delete cz2;
1873    
1874    
1875    
1876    
1877    
1878     float zp1250;
1879    
1880     int entries_zp1250 = zprime1250_tree->GetEntries();
1881     TH1F *ZPrime1250Plot = new TH1F( "ZPrime1250_"+VariableList[i], "ZPrime1250_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1882     TBranch *ZPrime1250Branch = zprime1250_tree->GetBranch( VariableList[i] );
1883    
1884     ZPrime1250Branch->SetAddress(&zp1250);
1885    
1886     TCanvas* cz3 = new TCanvas("c1","", 800, 600);
1887     cz3->cd();
1888    
1889     for ( int z3 = 0; z3 < entries_zp1250; z3++ ) {
1890    
1891     ZPrime1250Branch->GetEntry(z3);
1892     ZPrime1250Plot->Fill(zp1250);
1893    
1894     }
1895    
1896     ZPrime1250Plot->SetFillColor(kOrange);
1897    
1898     //double zprimescale = data_lumi / zprime_lumi;
1899     //ZPrime1250Plot->Scale( zprimescale, "" );
1900    
1901    
1902     ZPrime1250Plot->Draw();
1903    
1904     f->cd();
1905    
1906     ZPrime1250Plot->Write();
1907    
1908     cz3->Update();
1909     //cz3->Print( "ZPrime1250_"+VariableList[i]+PlotType );
1910     delete cz3;
1911    
1912    
1913    
1914    
1915     float zp1500;
1916    
1917     int entries_zp1500 = zprime1500_tree->GetEntries();
1918     TH1F *ZPrime1500Plot = new TH1F( "ZPrime1500_"+VariableList[i], "ZPrime1500_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1919     TBranch *ZPrime1500Branch = zprime1500_tree->GetBranch( VariableList[i] );
1920    
1921     ZPrime1500Branch->SetAddress(&zp1500);
1922    
1923     TCanvas* cz4 = new TCanvas("c1","", 800, 600);
1924     cz4->cd();
1925    
1926     for ( int z4 = 0; z4 < entries_zp1500; z4++ ) {
1927    
1928     ZPrime1500Branch->GetEntry(z4);
1929     ZPrime1500Plot->Fill(zp1500);
1930    
1931     }
1932    
1933     ZPrime1500Plot->SetFillColor(kOrange);
1934    
1935     //double zprimescale = data_lumi / zprime_lumi;
1936     //ZPrime1500Plot->Scale( zprimescale, "" );
1937    
1938    
1939     ZPrime1500Plot->Draw();
1940    
1941     f->cd();
1942    
1943     ZPrime1500Plot->Write();
1944    
1945     cz4->Update();
1946     //cz4->Print( "ZPrime1500_"+VariableList[i]+PlotType );
1947     delete cz4;
1948    
1949    
1950    
1951    
1952     float zp2000;
1953    
1954     int entries_zp2000 = zprime2000_tree->GetEntries();
1955     TH1F *ZPrime2000Plot = new TH1F( "ZPrime2000_"+VariableList[i], "ZPrime2000_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1956     TBranch *ZPrime2000Branch = zprime2000_tree->GetBranch( VariableList[i] );
1957    
1958     ZPrime2000Branch->SetAddress(&zp2000);
1959    
1960     TCanvas* cz5 = new TCanvas("c1","", 800, 600);
1961     cz5->cd();
1962    
1963     for ( int z5 = 0; z5 < entries_zp2000; z5++ ) {
1964    
1965     ZPrime2000Branch->GetEntry(z5);
1966     ZPrime2000Plot->Fill(zp2000);
1967    
1968     }
1969    
1970     ZPrime2000Plot->SetFillColor(kOrange);
1971    
1972     //double zprimescale = data_lumi / zprime_lumi;
1973     //ZPrime2000Plot->Scale( zprimescale, "" );
1974    
1975    
1976     ZPrime2000Plot->Draw();
1977    
1978     f->cd();
1979    
1980     ZPrime2000Plot->Write();
1981    
1982     cz5->Update();
1983     //cz5->Print( "ZPrime2000_"+VariableList[i]+PlotType );
1984     delete cz5;
1985    
1986     */
1987    
1988    
1989    
1990     //Data
1991     float data;
1992    
1993     int entries_data = data_tree->GetEntries();
1994     TH1F *DataPlot = new TH1F( "Data_"+VariableList[i], "Data_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
1995     TBranch *DataBranch = data_tree->GetBranch( VariableList[i] );
1996    
1997     DataBranch->SetAddress(&data);
1998    
1999     TCanvas* c8 = new TCanvas();
2000     c8->cd();
2001    
2002     for ( int q = 0; q < entries_data; q++ ) {
2003    
2004     DataBranch->GetEntry(q);
2005     DataPlot->Fill(data);
2006    
2007     }
2008    
2009     if (logScale) c8->SetLogy();
2010    
2011     //hStk->Add( DataPlot );
2012    
2013     DataPlot->Draw("PE");
2014    
2015     f->cd();
2016    
2017     DataPlot->Write();
2018    
2019     c8->Update();
2020     //c8->Print( "Data_"+VariableList[i]+PlotType );
2021     delete c8;
2022    
2023    
2024    
2025     //Here scale all of the MC histograms to the Data Lumi and form a
2026     //TStack out of all of the MC and plot data on the same histo
2027    
2028     hStk->Add( QCDPlot );
2029     //hStk->Add( VVPlot );
2030     hStk->Add( ZJPlot );
2031     hStk->Add( WJPlot );
2032     hStk->Add( STPlot );
2033     hStk->Add( TTPlot );
2034     //hStk->Add( ZPrime750Plot );
2035     //hStk->Add( ZPrime1000Plot );
2036     //hStk->Add( ZPrime1250Plot );
2037     //hStk->Add( ZPrime1500Plot );
2038     //hStk->Add( ZPrime2000Plot );
2039    
2040    
2041     TCanvas* c9 = new TCanvas();
2042     c9->cd();
2043    
2044    
2045    
2046    
2047     double yscale = 1.;
2048     double max1 = 1.;
2049     double max2 = 1.;
2050    
2051    
2052     max1 = hStk->GetMaximum();
2053     max2 = DataPlot->GetBinContent(DataPlot->GetMaximumBin());
2054    
2055    
2056     if (max1 > max2) yscale = max1*1.25;
2057     else yscale = max2*1.25;
2058    
2059    
2060     c9->Update();
2061    
2062     DataPlot->Draw("PE");
2063     c9->Update();
2064     hStk->Draw("SAME");
2065     c9->Update();
2066     DataPlot->Draw("PE SAME");
2067    
2068     c9->Update();
2069    
2070     DataPlot->GetYaxis()->SetRangeUser(0., yscale);
2071     hStk->GetYaxis()->SetRangeUser(0., yscale);
2072    
2073     DataPlot->GetXaxis()->SetTitle(TitleList[i]);
2074     hStk->GetXaxis()->SetTitle(TitleList[i]);
2075    
2076     if (i ==0 ) {
2077    
2078     DataPlot->GetYaxis()->SetTitle("Events / 100 GeV");
2079     hStk->GetYaxis()->SetTitle("Events / 100 GeV");
2080    
2081     }
2082    
2083     c9->Update();
2084    
2085    
2086     TLegend *leg = new TLegend(.75, .75, .95, .95);
2087     leg->AddEntry(QCDPlot, "QCD", "f");
2088     leg->AddEntry(STPlot, "Single Top", "f");
2089     leg->AddEntry(ZJPlot, "Z+jets", "f");
2090     leg->AddEntry(WJPlot, "W+jets", "f");
2091     //leg->AddEntry(VVPlot, "Diboson", "f");
2092     leg->AddEntry(TTPlot, "t #bar{t}", "f");
2093     leg->AddEntry(DataPlot, "2011 Data", "p");
2094     leg->Draw();
2095    
2096    
2097    
2098     TPaveText *pt = new TPaveText(0.3,0.85,0.7,0.95,"brNDC");
2099     //pt->SetFillColor(18);
2100     pt->SetTextAlign(12);
2101     pt->AddText("CMS preliminary");
2102     pt->AddText("1564 pb^{-1} at #sqrt{s} = 7 TeV");
2103     pt->Draw();
2104    
2105    
2106     c9->Update();
2107    
2108     //c9->SetLogy(1);
2109    
2110     c9->Update();
2111     f->cd();
2112    
2113     hStk->Write();
2114    
2115     TString plotname = "Stack_"+VariableList[i]+PlotType;
2116     c9->Print( plotname );
2117    
2118    
2119     delete c9;
2120     delete hStk;
2121    
2122     delete TTPlot;
2123     //delete TTPlot1;
2124     //delete TTPlot2;
2125     //delete TTPlot3;
2126     //delete TTPlot4;
2127     //delete TTPlot5;
2128     //delete TTPlot6;
2129     delete STPlot;
2130     delete ST_s_t_Plot;
2131     delete ST_t_t_Plot;
2132     delete ST_tw_t_Plot;
2133     delete ST_s_tbar_Plot;
2134     delete ST_t_tbar_Plot;
2135     delete ST_tw_tbar_Plot;
2136     delete WJPlot;
2137     //delete WJPlot1;
2138     //delete WJPlot2;
2139     //delete WJPlot3;
2140     //delete WJPlot4;
2141     //delete WJPlot5;
2142     //delete WJPlot6;
2143     delete ZJPlot;
2144     delete QCDPlot1;
2145     delete QCDPlot2;
2146     delete QCDPlot3;
2147     delete QCDPlot4;
2148     delete QCDPlot5;
2149     delete QCDPlot6;
2150     delete QCDPlot;
2151     //delete WWPlot;
2152     //delete WZPlot;
2153     //delete ZZPlot;
2154     //delete VVPlot;
2155     delete DataPlot;
2156     //delete ZPrimePlot;
2157    
2158    
2159    
2160    
2161    
2162    
2163     } //for i
2164    
2165    
2166     f->cd();
2167     f->Write();
2168     f->Close();
2169    
2170    
2171     }//DataPlotter