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 histocompare() {
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
TString path1 = "/uscms_data/d2/jbabb/CMSSW_4_2_5/src/TopQuarkAnalysis/Skynet/test/Skynet_Preselection_AltMassReco_";
|
45 |
|
|
TString path2 = "/uscms_data/d2/jbabb/CMSSW_4_2_5/src/TopQuarkAnalysis/Skynet/test/Skynet_Preselection_AltMassRecoWithErrors_";
|
46 |
|
|
|
47 |
|
|
//Get files
|
48 |
|
|
TFile *file1 = new TFile(path1+"Zprime2000.root", "open");
|
49 |
|
|
TFile *file2 = new TFile(path2+"Zprime2000.root", "open");
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
//Get trees
|
53 |
|
|
TTree *tree1 = (TTree*)file1->Get("PATuple");
|
54 |
|
|
TTree *tree2 = (TTree*)file2->Get("PATuple");
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
int n1 = tree1->GetEntries();
|
58 |
|
|
int n2 = tree2->GetEntries();
|
59 |
|
|
|
60 |
|
|
float scale = float(n2)/float(n1);
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
//List the variables that we want plots of
|
64 |
|
|
int nVariables = 3;
|
65 |
|
|
int nBins = 50;
|
66 |
|
|
TString VariableList[] = {
|
67 |
|
|
"unfittedEvent_ttInvariantMass", "unfittedHadTopMass", "unfittedLepTopMass"
|
68 |
|
|
};
|
69 |
|
|
double VariableMax[] = { 3000., 1000., 1000.
|
70 |
|
|
};
|
71 |
|
|
double VariableMin[] = { 0., 0., 0.
|
72 |
|
|
};
|
73 |
|
|
|
74 |
|
|
TString PlotType = ".png";
|
75 |
|
|
|
76 |
|
|
//Loop over all of the variables we want to plot
|
77 |
|
|
for ( int i = 0; i < nVariables; i++ ) {
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
// TTbar
|
81 |
|
|
|
82 |
|
|
float entry1;
|
83 |
|
|
|
84 |
|
|
int entries_tree1 = tree1->GetEntries();
|
85 |
|
|
TH1F *Plot1 = new TH1F( "Spring11_"+VariableList[i], "Spring11_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
|
86 |
|
|
TBranch *Branch1 = tree1->GetBranch( VariableList[i] );
|
87 |
|
|
|
88 |
|
|
Branch1->SetAddress(&entry1);
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
TCanvas* c1 = new TCanvas();
|
92 |
|
|
c1->cd();
|
93 |
|
|
|
94 |
|
|
for ( int j = 0; j < entries_tree1; j++ ) {
|
95 |
|
|
|
96 |
|
|
Branch1->GetEntry(j);
|
97 |
|
|
Plot1->Fill(entry1);
|
98 |
|
|
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
Plot1->SetLineColor(kRed);
|
102 |
|
|
|
103 |
|
|
Plot1->Scale( scale, "" );
|
104 |
|
|
Plot1->Draw();
|
105 |
|
|
c1->Update();
|
106 |
|
|
delete c1;
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
float entry2;
|
112 |
|
|
|
113 |
|
|
int entries_tree2 = tree2->GetEntries();
|
114 |
|
|
TH1F *Plot2 = new TH1F( "Summer11_"+VariableList[i], "Summer11_"+VariableList[i], nBins, VariableMin[i], VariableMax[i]);
|
115 |
|
|
TBranch *Branch2 = tree2->GetBranch( VariableList[i] );
|
116 |
|
|
|
117 |
|
|
Branch2->SetAddress(&entry2);
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
TCanvas* c1 = new TCanvas();
|
121 |
|
|
c1->cd();
|
122 |
|
|
|
123 |
|
|
for ( int j = 0; j < entries_tree2; j++ ) {
|
124 |
|
|
|
125 |
|
|
Branch2->GetEntry(j);
|
126 |
|
|
Plot2->Fill(entry2);
|
127 |
|
|
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
Plot2->SetLineColor(kBlue);
|
131 |
|
|
|
132 |
|
|
Plot2->Draw();
|
133 |
|
|
c1->Update();
|
134 |
|
|
delete c1;
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
TCanvas* c9 = new TCanvas();
|
139 |
|
|
c9->cd();
|
140 |
|
|
|
141 |
|
|
Plot1->Draw("");
|
142 |
|
|
c9->Update();
|
143 |
|
|
Plot2->Draw("SAME");
|
144 |
|
|
c9->Update();
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
TLegend *leg = new TLegend(.6, .75, .95, .95);
|
148 |
|
|
leg->AddEntry(Plot1, "Reco without errors", "l");
|
149 |
|
|
leg->AddEntry(Plot2, "Reco with errors", "l");
|
150 |
|
|
leg->Draw();
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
TString plotname = "Combined_"+VariableList[i]+PlotType;
|
155 |
|
|
c9->Print( plotname );
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
delete c9;
|
159 |
|
|
|
160 |
|
|
delete Plot1;
|
161 |
|
|
delete Plot2;
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
} //for i
|
167 |
|
|
|
168 |
|
|
}//DataPlotter
|