1 |
kukartse |
1.1 |
{
|
2 |
kukartse |
1.3 |
TFile * data_file = new TFile("./TMVApp-data-27apr2009.root","READ");
|
3 |
|
|
TFile * ttbar_phys_template_file = new TFile("./TMVA.root","READ");
|
4 |
|
|
TFile * qcd_template_file = new TFile("./TMVApp-qcd-27apr2009.root","READ");
|
5 |
kukartse |
1.1 |
|
6 |
kukartse |
1.2 |
TTree * t_data = data_file->Get("classifier");
|
7 |
|
|
TTree * t_ttbar_phys = ttbar_phys_template_file->Get("TestTree");
|
8 |
|
|
TTree * t_qcd = qcd_template_file->Get("classifier");
|
9 |
|
|
|
10 |
kukartse |
1.3 |
TH1F * data = new TH1F("data" ,"data" ,50, -0.9, 0.9);
|
11 |
|
|
TH1F * ttbar = new TH1F("ttbar" ,"ttbar" ,50, -0.9, 0.9);
|
12 |
|
|
TH1F * wzjets = new TH1F("wzjets","wzjets",50, -0.9, 0.9);
|
13 |
|
|
TH1F * qcd = new TH1F("qcd" ,"qcd" ,50, -0.9, 0.9);
|
14 |
|
|
|
15 |
|
|
int n_data = t_data->GetEntries();
|
16 |
kukartse |
1.2 |
|
17 |
|
|
t_data . Draw("MVA_BDT>>data");
|
18 |
|
|
t_ttbar_phys . Draw("MVA_BDT>>ttbar","type==1");
|
19 |
|
|
t_ttbar_phys . Draw("MVA_BDT>>wzjets","type==0");
|
20 |
|
|
t_qcd . Draw("MVA_BDT>>qcd");
|
21 |
|
|
|
22 |
|
|
//TH1F * data = (TH1F *)data_file->Get("MVA_Likelihood");
|
23 |
kukartse |
1.1 |
//TH1F * ttbar = (TH1F *)template_file->Get("Method_Likelihood/Likelihood/MVA_Likelihood_S");
|
24 |
|
|
//TH1F * wzjets = (TH1F *)template_file->Get("Method_Likelihood/Likelihood/MVA_Likelihood_B");
|
25 |
kukartse |
1.2 |
//TH1F * ttbar = (TH1F *)ttbar_template_file->Get("MVA_Likelihood");
|
26 |
|
|
//TH1F * wzjets = (TH1F *)wzjets_template_file->Get("MVA_Likelihood");
|
27 |
|
|
//TH1F * qcd = (TH1F *)qcd_template_file->Get("MVA_Likelihood");
|
28 |
kukartse |
1.1 |
|
29 |
|
|
//data->Draw();
|
30 |
|
|
//ttbar->Draw();
|
31 |
|
|
//wzjets->Draw();
|
32 |
|
|
//qcd->Draw();
|
33 |
|
|
|
34 |
|
|
TObjArray *mc = new TObjArray(3); // MC histograms are put in this array
|
35 |
|
|
mc->Add(ttbar);
|
36 |
|
|
mc->Add(wzjets);
|
37 |
|
|
mc->Add(qcd);
|
38 |
|
|
TFractionFitter* fit = new TFractionFitter(data, mc); // initialise
|
39 |
|
|
fit->Constrain(1,0.0,1.0); // constrain fraction 1 to be between 0 and 1
|
40 |
|
|
fit->Constrain(2,0.0,1.0); // constrain fraction 1 to be between 0 and 1
|
41 |
kukartse |
1.3 |
//fit->Constrain(3,0.03,1.0); // constrain fraction 1 to be between 0 and 1
|
42 |
|
|
fit->Constrain(3,0.0,0.073); // constrain fraction 1 to be between 0 and 1
|
43 |
kukartse |
1.2 |
fit->SetRangeX(0,50); // use only the first 15 bins in the fit
|
44 |
kukartse |
1.1 |
Int_t status = fit->Fit(); // perform the fit
|
45 |
|
|
cout << "fit status: " << status << endl;
|
46 |
|
|
if (status == 0) { // check on fit status
|
47 |
|
|
TH1F* result = (TH1F*) fit->GetPlot();
|
48 |
|
|
data->Draw("Ep");
|
49 |
|
|
result->Draw("same");
|
50 |
kukartse |
1.3 |
//
|
51 |
|
|
Double_t value,error;
|
52 |
|
|
fit->GetResult(0,value,error);
|
53 |
|
|
ttbar->Scale(n_data*value/ttbar->Integral());
|
54 |
|
|
ttbar->Draw("same");
|
55 |
|
|
//
|
56 |
|
|
fit->GetResult(1,value,error);
|
57 |
|
|
wzjets->Scale(n_data*value/wzjets->Integral());
|
58 |
|
|
wzjets->Draw("same");
|
59 |
|
|
//
|
60 |
|
|
fit->GetResult(2,value,error);
|
61 |
|
|
qcd->Scale(n_data*value/qcd->Integral());
|
62 |
|
|
qcd->Draw("same");
|
63 |
kukartse |
1.1 |
}
|
64 |
|
|
}
|