14 |
|
#include <TRint.h> |
15 |
|
#include <TFile.h> |
16 |
|
#include <TTree.h> |
17 |
< |
#include <TChain.h> |
17 |
> |
#include <TEventList.h> |
18 |
|
#include <TH1F.h> |
19 |
|
#include <TCanvas.h> |
20 |
|
#include <TLegend.h> |
39 |
|
cl.parse(argc,argv); |
40 |
|
|
41 |
|
vector<string> input = cl.get_vector<string>("input"); |
42 |
< |
vector<string> variables = cl.get_vector<string>("variables"); |
43 |
< |
string selection = cl.get_value<string> ("selection", "njt>0"); |
44 |
< |
string treename = cl.get_value<string> ("treename", "t"); |
45 |
< |
bool overlay = cl.get_value<bool> ("overlay", true); |
42 |
> |
string variable = cl.get_value<string> ("variable"); |
43 |
> |
string selection = cl.get_value<string> ("selection","njt>0"); |
44 |
> |
string treename = cl.get_value<string> ("treename", "t"); |
45 |
> |
bool logy = cl.get_value<bool> ("logy", true); |
46 |
> |
bool overlay = cl.get_value<bool> ("overlay", true); |
47 |
|
|
48 |
|
if (!cl.check()) return 0; |
49 |
|
cl.print(); |
61 |
|
jetalg = jetalg.substr(0,jetalg.find(".root")); |
62 |
|
jetalgs.push_back(jetalg); |
63 |
|
} |
64 |
+ |
|
65 |
+ |
argc=1; |
66 |
+ |
TRint* app = new TRint(argv[0],&argc,argv); |
67 |
|
|
68 |
|
// samples |
69 |
|
vector<TTree*> samples; |
70 |
|
for (unsigned int i=0;i<input.size();++i) { |
71 |
|
TFile* f = new TFile(input[i].c_str(),"READ"); |
72 |
|
TTree* t = (TTree*)f->Get(treename.c_str()); |
73 |
+ |
|
74 |
|
samples.push_back(t); |
75 |
|
cout<<jetalgs[i]<<" sample has "<<t->GetEntries()<<" total events."<<endl; |
76 |
|
} |
77 |
< |
|
77 |
> |
|
78 |
|
|
79 |
|
// histograms |
80 |
< |
TH1::SetDefaultSumw2(); |
81 |
< |
vector<TH1F**> histograms; |
82 |
< |
for (unsigned int i=0;i<variables.size();i++) |
83 |
< |
histograms.push_back(new TH1F*[jetalgs.size()]); |
84 |
< |
for (unsigned int ivar=0;ivar<variables.size();++ivar) { |
85 |
< |
string variable = variables[ivar]; |
86 |
< |
for (unsigned int isample=0;isample<samples.size();++isample) { |
87 |
< |
string jetalg = jetalgs[isample]; |
88 |
< |
TTree* sample = samples[isample]; |
89 |
< |
sample->Draw(variable.c_str(),selection.c_str(),"goff"); |
90 |
< |
TH1F* h = (TH1F*)gROOT->FindObject("htemp"); |
91 |
< |
if (ivar==0) cout<<jetalg<<": "<<h->GetEntries()<<" events selected."<<endl; |
92 |
< |
string hname = "h"+variable+"_"+jetalg; |
93 |
< |
string::size_type pos; |
94 |
< |
while ((pos=hname.find('['))<string::npos) hname.erase(pos,1); |
95 |
< |
while ((pos=hname.find(']'))<string::npos) hname.erase(pos,1); |
96 |
< |
h->SetNameTitle(hname.c_str(),hname.c_str()); |
97 |
< |
histograms[ivar][isample]=h; |
98 |
< |
cout<<hname<<" finished."<<endl; |
80 |
> |
vector<TH1F*> histograms; |
81 |
> |
|
82 |
> |
for (unsigned int isample=0;isample<samples.size();++isample) { |
83 |
> |
string jetalg = jetalgs[isample]; |
84 |
> |
TTree* sample = samples[isample]; |
85 |
> |
|
86 |
> |
TEventList* el = new TEventList("elist","elist"); |
87 |
> |
sample->Draw(">>elist",selection.c_str()); |
88 |
> |
int nevts = el->GetN(); |
89 |
> |
|
90 |
> |
char njt; |
91 |
> |
float weight; |
92 |
> |
float jtet[100]; |
93 |
> |
float jteta[100]; |
94 |
> |
float jtphi[100]; |
95 |
> |
float jtgendr[100]; |
96 |
> |
float jtgenet[100]; |
97 |
> |
|
98 |
> |
float* values(0); |
99 |
> |
if (variable=="jtet") values = jtet; |
100 |
> |
if (variable=="jteta") values = jteta; |
101 |
> |
if (variable=="jtphi") values = jtphi; |
102 |
> |
if (variable=="jtgendr") values = jtgendr; |
103 |
> |
if (variable=="jtgenet") values = jtgenet; |
104 |
> |
|
105 |
> |
sample->SetBranchAddress("njt", &njt); |
106 |
> |
sample->SetBranchAddress("weight",&weight); |
107 |
> |
sample->SetBranchAddress("jtet", jtet); |
108 |
> |
sample->SetBranchAddress("jteta", jteta); |
109 |
> |
sample->SetBranchAddress("jtphi", jtphi); |
110 |
> |
sample->SetBranchAddress("jtgendr",jtgendr); |
111 |
> |
sample->SetBranchAddress("jtgenet",jtgenet); |
112 |
> |
|
113 |
> |
|
114 |
> |
gROOT->cd(); |
115 |
> |
float value; |
116 |
> |
string treename = "t" + variable; |
117 |
> |
TTree* tree = new TTree(treename.c_str(),treename.c_str()); |
118 |
> |
tree->Branch("value", &value, "value/F"); |
119 |
> |
tree->Branch("weight",&weight,"value/F"); |
120 |
> |
|
121 |
> |
for (int ievt=0;ievt<nevts;ievt++) { |
122 |
> |
|
123 |
> |
sample->GetEntry(el->GetEntry(ievt)); |
124 |
> |
|
125 |
> |
for (int ijt=0;ijt<njt;ijt++) { |
126 |
> |
|
127 |
> |
// Section Cuts |
128 |
> |
if (jtgendr[ijt]<0.0||jtgendr[ijt]>0.3) continue; |
129 |
> |
|
130 |
> |
// fill 'value' tree for selected events |
131 |
> |
value = values[ijt]; |
132 |
> |
tree->Fill(); |
133 |
> |
} |
134 |
|
} |
135 |
+ |
|
136 |
+ |
TH1F::SetDefaultSumw2(); |
137 |
+ |
tree->Draw("value","weight*(1)","goff"); |
138 |
+ |
TH1F* h = (TH1F*)gROOT->FindObject("htemp"); |
139 |
+ |
cout<<jetalg<<": "<<h->GetEntries()<<" jets selected."<<endl; |
140 |
+ |
string hname = "h"+variable+"_"+jetalg; |
141 |
+ |
string::size_type pos; |
142 |
+ |
while ((pos=hname.find('['))<string::npos) hname.erase(pos,1); |
143 |
+ |
while ((pos=hname.find(']'))<string::npos) hname.erase(pos,1); |
144 |
+ |
h->SetNameTitle(hname.c_str(),hname.c_str()); |
145 |
+ |
h->SetXTitle(variable.c_str()); |
146 |
+ |
histograms.push_back(h); |
147 |
+ |
cout<<hname<<" finished."<<endl; |
148 |
+ |
|
149 |
+ |
delete tree; |
150 |
+ |
delete el; |
151 |
|
} |
152 |
|
|
153 |
|
|
154 |
|
// make plots |
99 |
– |
argc=1; |
100 |
– |
TRint* app = new TRint(argv[0],&argc,argv); |
155 |
|
if (overlay) gStyle->SetOptStat(0); |
156 |
< |
for (unsigned int ihist=0;ihist<histograms.size();++ihist) { |
157 |
< |
string variable = variables[ihist]; |
158 |
< |
TLegend* leg(0); |
159 |
< |
|
160 |
< |
if (overlay) { |
161 |
< |
string cname = "c"+variable; |
162 |
< |
TCanvas* c = new TCanvas(cname.c_str(),cname.c_str()); |
163 |
< |
if (variable.find("photone")<string::npos|| |
164 |
< |
variable.find("photonpt")<string::npos|| |
165 |
< |
variable.find("njt")<string::npos|| |
112 |
< |
variable.find("jte")<string::npos|| |
113 |
< |
variable.find("jtpt")<string::npos|| |
114 |
< |
variable.find("met")<string::npos) c->SetLogy(); |
115 |
< |
leg = new TLegend(0.6,0.85-jetalgs.size()*0.05,0.9,0.85); |
116 |
< |
leg->SetFillColor(10); |
117 |
< |
} |
156 |
> |
|
157 |
> |
TLegend* leg(0); |
158 |
> |
|
159 |
> |
if (overlay) { |
160 |
> |
string cname = "c"+variable; |
161 |
> |
TCanvas* c = new TCanvas(cname.c_str(),cname.c_str()); |
162 |
> |
c->SetLogy(logy); |
163 |
> |
leg = new TLegend(0.6,0.85-jetalgs.size()*0.06,0.85,0.85); |
164 |
> |
leg->SetFillColor(10); |
165 |
> |
} |
166 |
|
|
167 |
< |
Color_t color = kBlack; |
167 |
> |
Color_t color = kBlack; |
168 |
|
|
169 |
< |
for (unsigned int ialg=0;ialg<jetalgs.size();++ialg) { |
170 |
< |
string jetalg = jetalgs[ialg]; |
171 |
< |
TH1F* h = histograms[ihist][ialg]; |
172 |
< |
if (!overlay) { |
173 |
< |
string cname = "c"+variable+"_"+jetalg; |
174 |
< |
TCanvas* c = new TCanvas(cname.c_str(),cname.c_str()); |
175 |
< |
if (variable.find("photone")<string::npos|| |
176 |
< |
variable.find("photonpt")<string::npos|| |
177 |
< |
variable.find("njt")<string::npos|| |
178 |
< |
variable.find("jte")<string::npos|| |
179 |
< |
variable.find("jtpt")<string::npos|| |
180 |
< |
variable.find("met")<string::npos) c->SetLogy(); |
133 |
< |
} |
134 |
< |
else { |
135 |
< |
h->SetTitle(variable.c_str()); |
136 |
< |
h->SetLineColor(color++); |
137 |
< |
} |
138 |
< |
|
139 |
< |
(ialg==0||!overlay) ? h->Draw("EHIST") : h->Draw("EHISTSAME"); |
140 |
< |
|
141 |
< |
if (leg!=0) { |
142 |
< |
stringstream ss; |
143 |
< |
ss<<jetalg<<" (" |
144 |
< |
<<h->GetEntries()<<"/" |
145 |
< |
<<setiosflags(ios::scientific)<<setprecision(2) |
146 |
< |
<<h->GetMean()<<"/" |
147 |
< |
<<h->GetRMS() |
148 |
< |
<<resetiosflags(ios::scientific)<<setprecision(6) |
149 |
< |
<<")"; |
150 |
< |
leg->AddEntry(h,ss.str().c_str(),"l"); |
151 |
< |
if (ialg==jetalgs.size()-1) leg->Draw(); |
152 |
< |
} |
169 |
> |
for (unsigned int ialg=0;ialg<jetalgs.size();++ialg) { |
170 |
> |
string jetalg = jetalgs[ialg]; |
171 |
> |
TH1F* h = histograms[ialg]; |
172 |
> |
h->SetLineWidth(2); |
173 |
> |
if (!overlay) { |
174 |
> |
string cname = "c"+variable+"_"+jetalg; |
175 |
> |
TCanvas* c = new TCanvas(cname.c_str(),cname.c_str()); |
176 |
> |
c->SetLogy(logy); |
177 |
> |
} |
178 |
> |
else { |
179 |
> |
h->SetTitle(variable.c_str()); |
180 |
> |
h->SetLineColor(color); |
181 |
|
} |
182 |
|
|
183 |
< |
} |
183 |
> |
(ialg==0||!overlay) ? h->Draw("EHIST") : h->Draw("EHISTSAME"); |
184 |
> |
|
185 |
> |
if (leg!=0) { |
186 |
> |
leg->AddEntry(h,jetalg.c_str(),"l"); |
187 |
> |
if (ialg==jetalgs.size()-1) leg->Draw(); |
188 |
> |
} |
189 |
|
|
190 |
+ |
color++; |
191 |
+ |
while (color==10||color==kWhite||color==kYellow) color++; |
192 |
+ |
} |
193 |
+ |
|
194 |
|
app->Run(); |
195 |
|
|
196 |
|
return 0; |