ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/LJMet/MultivariateAnalysis/root/plot_ht_classifier.C
Revision: 1.1
Committed: Thu Jun 18 16:46:55 2009 UTC (15 years, 10 months ago) by kukartse
Content type: text/plain
Branch: MAIN
CVS Tags: V00-03-01, ZMorph_BASE_20100408, gak040610_morphing, V00-02-02, gak011410, gak010310, ejterm2010_25nov2009, V00-02-01, V00-02-00, gak112409, CMSSW_22X_branch_base, segala101609, V00-01-15, HEAD
Branch point for: ZMorph-V00-03-01, CMSSW_22X_branch
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 kukartse 1.1 {
2     #include "style.C"
3    
4     set_ljets_style();
5    
6     TCanvas c("c", "canvas", 800,600);
7    
8     //gROOT->SetStyle("Plain");
9     //gStyle->SetOptStat(0);
10     //gStyle->SetOptFit(0);
11    
12     toyMC t(20);
13     //t.load_templates();
14     //
15     //_____ attach as friends classifier trees _______________________________
16     //
17     TFile * f_ttbar_cl = new TFile("TMVApp-ttbar-16jun2009.root");
18     TFile * f_phys_cl = new TFile("TMVApp-phys-16jun2009.root");
19     TFile * f_qcd_cl = new TFile("TMVApp-qcd-16jun2009.root");
20     TTree * t_ttbar_cl = (TTree*)f_ttbar_cl -> Get("classifier");
21     TTree * t_phys_cl = (TTree*)f_phys_cl -> Get("classifier");
22     TTree * t_qcd_cl = (TTree*)f_qcd_cl -> Get("classifier");
23     t_ttbar_cl->SetBranchStatus("*",0);
24     t_ttbar_cl->SetBranchStatus("MVA_BDT",1);
25     t_phys_cl->SetBranchStatus("*",0);
26     t_phys_cl->SetBranchStatus("MVA_BDT",1);
27     t_qcd_cl->SetBranchStatus("*",0);
28     t_qcd_cl->SetBranchStatus("MVA_BDT",1);
29     //
30     TFile * training_file = new TFile("muon_jets_training-wfastsim-summer08-15may2009.root");
31     TTree * ttbar = (TTree*)training_file -> Get("ttbar");
32     TTree * phys_bg = (TTree*)training_file -> Get("wjets");
33     TTree * qcd = (TTree*)training_file -> Get("qcd");
34     //
35     TFile * file = new TFile("ljets-data-1fb-classifier-14jun2009.root");
36     TTree * data = (TTree*)file -> Get("data");
37     TTree * classifier = (TTree*)file -> Get("classifier");
38     //
39     ttbar -> AddFriend( t_ttbar_cl );
40     phys_bg -> AddFriend( t_phys_cl );
41     qcd -> AddFriend( t_qcd_cl );
42    
43     TCut the_cut = "getHt<180";
44     //TCut the_cut = "getHt>250";
45     //TCut the_cut = "n_tagged_jets_trackCounting_loose>1";
46     //TCut the_cut = "";
47    
48     double n_ttbar_data = 19600.0;
49     double n_phys_data = 8710.0;
50     double n_qcd_data = 1000.0;
51     //
52     double n_ttbar = (double)ttbar -> GetEntries();
53     double n_phys = (double)phys_bg -> GetEntries();
54     double n_qcd = (double)qcd -> GetEntries();
55     double n_ttbar_sel = (double)ttbar ->Draw("getHt",the_cut,"goff");
56     double n_phys_sel = (double)phys_bg->Draw("getHt",the_cut,"goff");
57     double n_qcd_sel = (double)qcd ->Draw("getHt",the_cut,"goff");
58     double ttbar_eff = n_ttbar_sel/n_ttbar;
59     double phys_eff = n_phys_sel/n_phys;
60     double qcd_eff = n_qcd_sel/n_qcd;
61    
62     TH1F * h1 = new TH1F("h1", "", 100, 100, 800);
63     TH1F * h2 = new TH1F("h2", "", 100, 100, 800);
64     TH1F * h3 = new TH1F("h3", "", 100, 100, 800);
65     TH1F * h4 = new TH1F("h4", "", 20, -0.8, 0.8);
66     TH1F * h5 = new TH1F("h5", "", 20, -0.8, 0.8);
67     //
68     double n_data_sel = data->Draw("classifier.MVA_BDT>>h4",the_cut,"goff");
69     data->Draw("classifier.MVA_BDT>>h5","","goff");
70     t.set_overflow_bins(h4);
71     t.set_overflow_bins(h5);
72     ttbar -> Draw("getHt>>h1","","goff");
73     phys_bg -> Draw("getHt>>h2","","goff");
74     qcd -> Draw("getHt>>h3","","goff");
75     //
76     double norm = n_data_sel/(n_ttbar_data*ttbar_eff+n_phys_data*phys_eff+n_qcd_data*qcd_eff);
77     //
78     double n_ttbar_exp = norm*ttbar_eff*n_ttbar_data;
79     double n_phys_exp = norm*phys_eff*n_phys_data;
80     double n_qcd_exp = norm*qcd_eff*n_qcd_data;
81     cout << endl << "Selected events: " << n_data_sel << endl;
82     cout << "ttbar events: " << n_ttbar_exp << endl;
83     cout << "phys BG events: " << n_phys_exp << endl;
84     cout << "QCD events: " << n_qcd_exp << endl<< endl;
85     cout << "ttbar eff: " << ttbar_eff << endl;
86     cout << "phys eff: " << phys_eff << endl;
87     cout << "qcd eff: " << qcd_eff << endl;
88     //
89     h1->Scale(1.0/h1->Integral());
90     h2->Scale(1.0/h2->Integral());
91     h3->Scale(1.0/h3->Integral());
92    
93     h1->SetLineColor(4);
94     //h1->SetFillColor(4);
95     //h1->SetFillStyle(3345);
96     //
97     h2->SetLineColor(2);
98     h2->SetFillColor(2);
99     h2->SetFillStyle(3354);
100     //
101     h3->SetLineColor(6);
102     h3->SetFillColor(6);
103     h3->SetFillStyle(3345);
104     //
105     //h4->SetLineColor(2);
106     //h4->SetFillColor(2);
107     //h4->SetFillStyle(3354);
108    
109     c.Divide(2,2);
110    
111     TVirtualPad * pad = c.cd(1);
112     h1->Draw();
113     h2->Draw("same");
114     h3->Draw("same");
115     pad->SaveAs("mu_ht.eps");
116    
117     pad = c.cd(2);
118     TH1F h31 = *h3;
119     TH1F h21 = *h2;
120     TH1F h11 = *h1;
121     h31.Scale(n_qcd_data/h31.Integral());
122     h21.Scale(n_phys_data/h21.Integral());
123     h11.Scale(n_ttbar_data/h11.Integral());
124     h21.Add(&h31);
125     h11.Add(&h21);
126     h11->Draw();
127     h21->Draw("same");
128     h31->Draw("same");
129     pad->SaveAs("mu_ht_fractions.eps");
130    
131     pad = c.cd(3);
132     h4->SetMarkerStyle(21);
133     h4->SetMarkerSize(0.7);
134     h4->SetLineColor(1);
135     h4->Draw("E1:X0");
136     TH1F * h_ttbar_cl = new TH1F("h_ttbar_cl", "", 20, -0.8, 0.8);
137     ttbar->Draw("MVA_BDT>>h_ttbar_cl",the_cut,"goff");
138     t.set_overflow_bins(h_ttbar_cl);
139     h_ttbar_cl->Scale(n_ttbar_exp/h_ttbar_cl->Integral());
140     //
141     TH1F * h_phys_cl = new TH1F("h_phys_cl", "", 20, -0.8, 0.8);
142     phys_bg->Draw("MVA_BDT>>h_phys_cl",the_cut,"goff");
143     t.set_overflow_bins(h_phys_cl);
144     h_phys_cl->Scale(n_phys_exp/h_phys_cl->Integral());
145     //
146     TH1F * h_qcd_cl = new TH1F("h_qcd_cl", "", 20, -0.8, 0.8);
147     qcd->Draw("MVA_BDT>>h_qcd_cl",the_cut,"goff");
148     t.set_overflow_bins(h_qcd_cl);
149     h_qcd_cl->Scale(n_qcd_exp/h_qcd_cl->Integral());
150     //
151     h_ttbar_cl->Add(h_phys_cl);
152     h_ttbar_cl->Add(h_qcd_cl);
153     h_phys_cl->Add(h_qcd_cl);
154     //
155     h_ttbar_cl->SetFillColor(42);
156     h_phys_cl->SetFillColor(46);
157     h_qcd_cl->SetFillColor(48);
158     //
159     h_ttbar_cl->Draw("same");
160     h_phys_cl->Draw("same");
161     h_qcd_cl->Draw("same");
162     h4->Draw("E1:X0:same");
163     pad->SaveAs("mu_classifier_ht_cut.eps");
164     }