17 |
|
#include <TEventList.h> |
18 |
|
#include <TH1F.h> |
19 |
|
#include <TF1.h> |
20 |
– |
#include <TGraphErrors.h> |
21 |
– |
#include <TMultiGraph.h> |
22 |
– |
#include <TCanvas.h> |
23 |
– |
#include <TLegend.h> |
20 |
|
|
21 |
|
#include <iostream> |
22 |
|
#include <iomanip> |
27 |
– |
#include <fstream> |
23 |
|
#include <cmath> |
24 |
|
#include <string> |
25 |
|
#include <vector> |
31 |
|
//////////////////////////////////////////////////////////////////////////////// |
32 |
|
// defaults |
33 |
|
//////////////////////////////////////////////////////////////////////////////// |
34 |
< |
string dflt_ptbins ="7,9,12,15,20,25,30,45,65,90,120"; |
35 |
< |
string dflt_etabins=".2,.4,.7,1.,1.3,1.5,1.75,2.,2.3,2.5,2.7,2.9,3.2"; |
41 |
< |
//string dflt_etabins=".3,.6,.9,1.2,1.5,1.8,2.1,2.4,2.7"; |
34 |
> |
string dflt_etbins ="8,12,15,20,25,30,45,65,90,120,180"; |
35 |
> |
string dflt_etabins=".2,.4,.6,.8,1.,1.2,1.4,1.6,1.8,2.,2.3,2.5,2.7,3.0,3.3"; |
36 |
|
string dflt_phibins="-2.75,-2.25,-1.75.,-1.25,-.75,-.25,.25,.75,1.25,1.75,2.25,2.75"; |
37 |
+ |
string dflt_emfbins="0.2,0.4,0.6,0.8"; |
38 |
|
|
39 |
|
|
40 |
|
//////////////////////////////////////////////////////////////////////////////// |
41 |
|
// declare global functions |
42 |
|
//////////////////////////////////////////////////////////////////////////////// |
43 |
+ |
void replaceHistos(int nbins, |
44 |
+ |
TH1F**& hVar,TH1F**& hEtCorr,TH1F**& hAbsRsp,TH1F**& hRelRsp, |
45 |
+ |
TTree**& tVar); |
46 |
+ |
void replaceHistos(int nbins1,int nbins2, |
47 |
+ |
TH1F***&hVar,TH1F***&hEtCorr,TH1F***&hAbsRsp,TH1F***&hRelRsp, |
48 |
+ |
TTree***& tVar); |
49 |
+ |
void replaceHistos(int nbins1,int nbins2,int nbins3, |
50 |
+ |
TH1F****&hVar,TH1F****&hEtCorr, |
51 |
+ |
TH1F****&hAbsRsp,TH1F****&hRelRsp, |
52 |
+ |
TTree****& tVar); |
53 |
+ |
void fitHistos (TH1F** histos,int n,double nsigma); |
54 |
+ |
void fitHistos (TH1F*** histos,int n1,int n2,double nsigma); |
55 |
+ |
void fitHistos (TH1F**** histos,int n1,int n2,int n3,double nsigma); |
56 |
+ |
void saveHistos (TH1F** histos,int n); |
57 |
+ |
void saveHistos (TH1F*** histos,int n1,int n2); |
58 |
+ |
void saveHistos (TH1F**** histos,int n1,int n2,int n3); |
59 |
|
|
49 |
– |
void fillRspAndSgm(TGraphErrors* gRsp,TGraphErrors* gSgm,float nsigma, |
50 |
– |
const vector<float>& bins,TH1F** hVar,TH1F** hPt,TH1F** hRsp); |
51 |
– |
TCanvas* plotVarHistos(const vector<float>& bins,TH1F** hVar,bool logy=false); |
52 |
– |
TCanvas* plotRspHistos(const vector<float>& bins,TH1F** hRsp); |
53 |
– |
TCanvas* plotResponse (const vector<string>& jetalgs,short applyjes, |
54 |
– |
const vector<TGraphErrors*> gRsp, |
55 |
– |
const string& varname,const string& xtitle); |
56 |
– |
TCanvas* plotResponse (const string& jetalg,short applyjes,bool fitcorr, |
57 |
– |
const vector<float>& bins1,TGraphErrors** gRsp, |
58 |
– |
const string& varname1,const string vartitle1, |
59 |
– |
const string& varname2,const string& xtitle); |
60 |
– |
TCanvas* plotResolution(const vector<string>& jetalgs, |
61 |
– |
const vector<TGraphErrors*> gSgm, |
62 |
– |
const string& varname,const string& xtitle); |
63 |
– |
TCanvas* plotResolution(const string& jetalg,const vector<float>& bins1, |
64 |
– |
TGraphErrors** gSgm, |
65 |
– |
const string& varname1,const string vartitle1, |
66 |
– |
const string& varname2,const string& xtitle); |
67 |
– |
|
68 |
– |
float get_xmax(TGraph* g); |
60 |
|
|
61 |
|
|
62 |
|
//////////////////////////////////////////////////////////////////////////////// |
70 |
|
cl.parse(argc,argv); |
71 |
|
|
72 |
|
vector<string> input = cl.get_vector<string>("input"); |
73 |
+ |
string output = cl.get_value<string> ("output", "mcrsp.root"); |
74 |
|
string selection = cl.get_value<string> ("selection", "njt>0"); |
75 |
|
float drmax = cl.get_value<float> ("drmax", 0.3); |
76 |
+ |
short applyjes = cl.get_value<short> ("applyjes", 0); |
77 |
|
string treename = cl.get_value<string> ("treename", "t"); |
78 |
|
float nsigma = cl.get_value<float> ("nsigma", 3.0); |
79 |
< |
short applyjes = cl.get_value<short> ("applyjes", 0); |
87 |
< |
bool fitcorr = cl.get_value<bool> ("fitcorr", false); |
88 |
< |
vector<float> ptbins = cl.get_vector<float> ("ptbins", dflt_ptbins); |
79 |
> |
vector<float> etbins = cl.get_vector<float> ("etbins", dflt_etbins); |
80 |
|
vector<float> etabins = cl.get_vector<float> ("etabins",dflt_etabins); |
81 |
|
vector<float> phibins = cl.get_vector<float> ("phibins",dflt_phibins); |
82 |
+ |
vector<float> emfbins = cl.get_vector<float> ("emfbins",dflt_emfbins); |
83 |
|
bool abseta = cl.get_value<bool> ("abseta", true); |
84 |
|
|
85 |
|
if (!cl.check()) return 0; |
108 |
|
// prepare branch variables and histograms / graphs |
109 |
|
float weight; |
110 |
|
char njt; |
111 |
+ |
float jtet[100]; |
112 |
|
float jtpt[100]; |
113 |
|
float jteta[100]; |
114 |
|
float jtphi[100]; |
115 |
+ |
float jtemf[100]; |
116 |
+ |
float jtgenet[100]; |
117 |
|
float jtgenpt[100]; |
118 |
|
float jtgendr[100]; |
119 |
|
float jtjes[100][3]; |
120 |
|
|
121 |
< |
int nptbins = ptbins.size()+1; |
121 |
> |
int netbins = etbins.size()+1; |
122 |
|
int netabins = etabins.size()+1; |
123 |
|
int nphibins = phibins.size()+1; |
124 |
+ |
int nemfbins = emfbins.size()+1; |
125 |
|
|
126 |
< |
vector<TH1F**> hGenPt; |
127 |
< |
vector<TH1F**> hGenPtPtCorr; |
128 |
< |
vector<TH1F**> hRspVsGenPt; |
129 |
< |
vector<TH1F**> hPt; |
130 |
< |
vector<TH1F**> hPtCorr; |
131 |
< |
vector<TH1F**> hRspVsPt; |
132 |
< |
vector<TH1F**> hEta; |
133 |
< |
vector<TH1F**> hEtaPtCorr; |
134 |
< |
vector<TH1F**> hRspVsEta; |
135 |
< |
vector<TH1F**> hPhi; |
136 |
< |
vector<TH1F**> hPhiPtCorr; |
137 |
< |
vector<TH1F**> hRspVsPhi; |
138 |
< |
|
139 |
< |
vector<TH1F***> hEtaPtPt; |
140 |
< |
vector<TH1F***> hEtaPtPtCorr; |
141 |
< |
vector<TH1F***> hRspVsEtaPt; |
142 |
< |
|
143 |
< |
vector<TGraphErrors*> gRspVsGenPt; |
144 |
< |
vector<TGraphErrors*> gSgmVsGenPt; |
145 |
< |
vector<TGraphErrors*> gRspVsPt; |
146 |
< |
vector<TGraphErrors*> gSgmVsPt; |
147 |
< |
vector<TGraphErrors*> gRspVsEta; |
148 |
< |
vector<TGraphErrors*> gSgmVsEta; |
149 |
< |
vector<TGraphErrors*> gRspVsPhi; |
150 |
< |
vector<TGraphErrors*> gSgmVsPhi; |
126 |
> |
vector<TH1F**> hGenEt; |
127 |
> |
vector<TH1F**> hEtCorrGenEt; |
128 |
> |
vector<TH1F**> hAbsRspGenEt; |
129 |
> |
vector<TH1F**> hRelRspGenEt; |
130 |
> |
|
131 |
> |
vector<TH1F**> hEt; |
132 |
> |
vector<TH1F**> hEtCorrEt; |
133 |
> |
vector<TH1F**> hAbsRspEt; |
134 |
> |
vector<TH1F**> hRelRspEt; |
135 |
> |
|
136 |
> |
vector<TH1F**> hEta; |
137 |
> |
vector<TH1F**> hEtCorrEta; |
138 |
> |
vector<TH1F**> hAbsRspEta; |
139 |
> |
vector<TH1F**> hRelRspEta; |
140 |
> |
|
141 |
> |
vector<TH1F**> hPhi; |
142 |
> |
vector<TH1F**> hEtCorrPhi; |
143 |
> |
vector<TH1F**> hAbsRspPhi; |
144 |
> |
vector<TH1F**> hRelRspPhi; |
145 |
> |
|
146 |
> |
vector<TH1F**> hEmf; |
147 |
> |
vector<TH1F**> hEtCorrEmf; |
148 |
> |
vector<TH1F**> hAbsRspEmf; |
149 |
> |
vector<TH1F**> hRelRspEmf; |
150 |
> |
|
151 |
> |
vector<TH1F***> hEtEtaEt; |
152 |
> |
vector<TH1F***> hEtCorrEtaEt; |
153 |
> |
vector<TH1F***> hAbsRspEtaEt; |
154 |
> |
vector<TH1F***> hRelRspEtaEt; |
155 |
> |
|
156 |
> |
vector<TH1F***> hEtEmfEt; |
157 |
> |
vector<TH1F***> hEtCorrEmfEt; |
158 |
> |
vector<TH1F***> hAbsRspEmfEt; |
159 |
> |
vector<TH1F***> hRelRspEmfEt; |
160 |
> |
|
161 |
> |
vector<TH1F****> hEtEmfEtaEt; |
162 |
> |
vector<TH1F****> hEtCorrEmfEtaEt; |
163 |
> |
vector<TH1F****> hAbsRspEmfEtaEt; |
164 |
> |
vector<TH1F****> hRelRspEmfEtaEt; |
165 |
|
|
156 |
– |
vector<TGraphErrors**> gRspVsEtaPt; |
157 |
– |
vector<TGraphErrors**> gSgmVsEtaPt; |
166 |
|
|
167 |
< |
argc=1; //argv[1]="-b"; |
168 |
< |
TRint* app = new TRint(argv[0],&argc,argv); |
167 |
> |
argc=3; argv[1]="-l"; argv[2]="-b"; |
168 |
> |
TRint* app = new TRint(argv[0],&argc,argv); app->Argc(); |
169 |
|
|
170 |
|
|
171 |
|
// |
172 |
|
// loop over all input files |
173 |
|
// |
174 |
< |
TFile* plotfile = new TFile("mcresponse.root","RECREATE"); |
174 |
> |
TFile* plotfile = new TFile(output.c_str(),"RECREATE"); |
175 |
|
|
176 |
|
for (unsigned int i=0;i<input.size();++i) { |
177 |
< |
TFile* f = new TFile(input[i].c_str(),"READ"); if (!f->IsOpen()) return 0; |
177 |
> |
TFile* f = new TFile(input[i].c_str(),"UPDATE"); if (!f->IsOpen()) return 0; |
178 |
|
TTree* t = (TTree*)f->Get(treename.c_str()); |
179 |
|
|
180 |
|
TEventList* el = new TEventList("sel","sel"); |
182 |
|
|
183 |
|
t->SetBranchAddress("weight", &weight); |
184 |
|
t->SetBranchAddress("njt", &njt); |
185 |
+ |
t->SetBranchAddress("jtet", jtet); |
186 |
|
t->SetBranchAddress("jtpt", jtpt); |
187 |
|
t->SetBranchAddress("jteta", jteta); |
188 |
|
t->SetBranchAddress("jtphi", jtphi); |
189 |
+ |
t->SetBranchAddress("jtemf", jtemf); |
190 |
+ |
t->SetBranchAddress("jtgenet",jtgenet); |
191 |
|
t->SetBranchAddress("jtgenpt",jtgenpt); |
192 |
|
t->SetBranchAddress("jtgendr",jtgendr); |
193 |
|
|
197 |
|
for (int i2=0;i2<3;i2++) jtjes[i1][i2]=1.0; |
198 |
|
|
199 |
|
|
200 |
< |
string rsp_xtitle = "E_{T}^{gen}-E_{T}^{rec} [GeV]"; |
200 |
> |
string absrsp_xtitle = "E_{T}^{gen}-E_{T} [GeV]"; |
201 |
> |
string relrsp_xtitle = "E_{T}^{rec}/E_{T}"; |
202 |
|
|
203 |
< |
hGenPt .push_back(hist::initHistos("JetGenPt",jetalgs[i], |
204 |
< |
4000,0,4000,"jet p_{T}^{gen} [GeV]", |
205 |
< |
"GenPt",ptbins)); |
206 |
< |
hGenPtPtCorr.push_back(hist::initHistos("JetPtCorr",jetalgs[i], |
207 |
< |
4000,0,4000,"jet p_{T}^{gen} [GeV]", |
208 |
< |
"GenPt",ptbins)); |
209 |
< |
hRspVsGenPt .push_back(hist::initHistos("JetRspGenPt",jetalgs[i], |
210 |
< |
100,-100,100,rsp_xtitle, |
211 |
< |
"GenPt",ptbins)); |
212 |
< |
|
213 |
< |
hPt .push_back(hist::initHistos("JetPt",jetalgs[i], |
214 |
< |
4000,0,4000,"jet p_{T} [GeV]", |
215 |
< |
"Pt",ptbins)); |
216 |
< |
hPtCorr .push_back(hist::initHistos("JetPtCorr",jetalgs[i], |
217 |
< |
4000,0,4000,"jet p_{T} [GeV]", |
218 |
< |
"Pt",ptbins)); |
219 |
< |
hRspVsPt .push_back(hist::initHistos("JetRspPt",jetalgs[i], |
220 |
< |
100,-100,100,rsp_xtitle, |
221 |
< |
"Pt",ptbins)); |
222 |
< |
|
223 |
< |
hEta .push_back(hist::initHistos("JetEta",jetalgs[i], |
224 |
< |
100,0,5,"jet #eta","Eta",etabins)); |
225 |
< |
hEtaPtCorr .push_back(hist::initHistos("JetPtCorr",jetalgs[i], |
226 |
< |
4000,0,4000,"jet p_{T} [GeV]", |
227 |
< |
"Eta",etabins)); |
228 |
< |
hRspVsEta .push_back(hist::initHistos("JetRspEta",jetalgs[i], |
229 |
< |
100,-100,100,rsp_xtitle,"Eta",etabins)); |
230 |
< |
|
231 |
< |
hPhi .push_back(hist::initHistos("JetPhi",jetalgs[i], |
232 |
< |
100,-3.2,3.2,"jet #phi","Phi",phibins)); |
233 |
< |
hPhiPtCorr .push_back(hist::initHistos("JetPtCorr",jetalgs[i], |
234 |
< |
4000,0,4000,"jet p_{T} [Gev]", |
235 |
< |
"Phi",phibins)); |
236 |
< |
hRspVsPhi .push_back(hist::initHistos("JetRspPhi",jetalgs[i], |
237 |
< |
100,-100,100,rsp_xtitle,"Phi",phibins)); |
238 |
< |
|
239 |
< |
hEtaPtPt .push_back(hist::initHistos("JetPt",jetalgs[i], |
240 |
< |
4000,0,4000,"jet p_{T} [GeV]", |
241 |
< |
"Eta",etabins,"Pt",ptbins)); |
242 |
< |
hEtaPtPtCorr.push_back(hist::initHistos("JetPtCorr",jetalgs[i], |
243 |
< |
4000,0,4000,"jet p_{T} [GeV]", |
244 |
< |
"Eta",etabins,"Pt",ptbins)); |
245 |
< |
hRspVsEtaPt .push_back(hist::initHistos("JetRspEtaPt",jetalgs[i], |
246 |
< |
100,-100,100,rsp_xtitle, |
247 |
< |
"Eta",etabins,"Pt",ptbins)); |
203 |
> |
hGenEt .push_back(hist::initHistos("GenEt",jetalgs[i],100, |
204 |
> |
"jet E_{T}^{gen} [GeV]","GenEt",etbins)); |
205 |
> |
hEtCorrGenEt.push_back(hist::initHistos("EtCorrGenEt",jetalgs[i],100, |
206 |
> |
"jet E_{T}^{gen} [GeV]","GenEt",etbins)); |
207 |
> |
hAbsRspGenEt.push_back(hist::initHistos("AbsRspGenEt",jetalgs[i],100,-50,150, |
208 |
> |
absrsp_xtitle,"GenEt",etbins)); |
209 |
> |
hRelRspGenEt.push_back(hist::initHistos("RelRspGenEt",jetalgs[i],100,0,2, |
210 |
> |
relrsp_xtitle,"GenEt",etbins)); |
211 |
> |
|
212 |
> |
hEt .push_back(hist::initHistos("Et",jetalgs[i],100, |
213 |
> |
"jet E_{T} [GeV]","Et",etbins)); |
214 |
> |
hEtCorrEt .push_back(hist::initHistos("EtCorrEt",jetalgs[i],100, |
215 |
> |
"jet E_{T} [GeV]","Et",etbins)); |
216 |
> |
hAbsRspEt .push_back(hist::initHistos("AbsRspEt",jetalgs[i],100,-50,150, |
217 |
> |
absrsp_xtitle,"Et",etbins)); |
218 |
> |
hRelRspEt .push_back(hist::initHistos("RelRspEt",jetalgs[i],100,0,2, |
219 |
> |
relrsp_xtitle,"Et",etbins)); |
220 |
> |
|
221 |
> |
hEta .push_back(hist::initHistos("Eta",jetalgs[i],100, |
222 |
> |
"jet #eta","Eta",etabins)); |
223 |
> |
hEtCorrEta .push_back(hist::initHistos("EtCorrEta",jetalgs[i],100, |
224 |
> |
"jet E_{T} [GeV]","Eta",etabins)); |
225 |
> |
hAbsRspEta .push_back(hist::initHistos("AbsRspEta",jetalgs[i],100,-50,150, |
226 |
> |
absrsp_xtitle,"Eta",etabins)); |
227 |
> |
hRelRspEta .push_back(hist::initHistos("RelRspEta",jetalgs[i],100,0,2, |
228 |
> |
relrsp_xtitle,"Eta",etabins)); |
229 |
> |
|
230 |
> |
hPhi .push_back(hist::initHistos("Phi",jetalgs[i],100, |
231 |
> |
"jet #phi","Phi",phibins)); |
232 |
> |
hEtCorrPhi .push_back(hist::initHistos("EtCorrPhi",jetalgs[i],100, |
233 |
> |
"jet E_{T} [Gev]","Phi",phibins)); |
234 |
> |
hAbsRspPhi .push_back(hist::initHistos("AbsRspPhi",jetalgs[i],100,-50,150, |
235 |
> |
absrsp_xtitle,"Phi",phibins)); |
236 |
> |
hRelRspPhi .push_back(hist::initHistos("RelRspPhi",jetalgs[i],100,0,2, |
237 |
> |
relrsp_xtitle,"Phi",phibins)); |
238 |
> |
|
239 |
> |
hEmf .push_back(hist::initHistos("Emf",jetalgs[i],100, |
240 |
> |
"jet emf","Emf",emfbins)); |
241 |
> |
hEtCorrEmf .push_back(hist::initHistos("EtCorrEmf",jetalgs[i],100, |
242 |
> |
"jet E_{T} [Gev]","Emf",emfbins)); |
243 |
> |
hAbsRspEmf .push_back(hist::initHistos("AbsRspEmf",jetalgs[i],100,-50,150, |
244 |
> |
absrsp_xtitle,"Emf",emfbins)); |
245 |
> |
hRelRspEmf .push_back(hist::initHistos("RelRspEmf",jetalgs[i],100,0,2, |
246 |
> |
relrsp_xtitle,"Emf",emfbins)); |
247 |
> |
|
248 |
> |
hEtEtaEt .push_back(hist::initHistos("Et",jetalgs[i],100,"jet E_{T} [GeV]", |
249 |
> |
"Eta",etabins,"Et",etbins)); |
250 |
> |
hEtCorrEtaEt.push_back(hist::initHistos("EtCorrEtaEt",jetalgs[i],100, |
251 |
> |
"jet E_{T} [GeV]", |
252 |
> |
"Eta",etabins,"Et",etbins)); |
253 |
> |
hAbsRspEtaEt.push_back(hist::initHistos("AbsRspEtaEt",jetalgs[i],100,-50,150, |
254 |
> |
absrsp_xtitle, |
255 |
> |
"Eta",etabins,"Et",etbins)); |
256 |
> |
hRelRspEtaEt.push_back(hist::initHistos("RelRspEtaEt",jetalgs[i],100,0,2, |
257 |
> |
relrsp_xtitle, |
258 |
> |
"Eta",etabins,"Et",etbins)); |
259 |
> |
|
260 |
> |
hEtEmfEt .push_back(hist::initHistos("Et",jetalgs[i],100,"jet E_{T} [GeV]", |
261 |
> |
"Emf",emfbins,"Et",etbins)); |
262 |
> |
hEtCorrEmfEt.push_back(hist::initHistos("EtCorrEmfEt",jetalgs[i],100, |
263 |
> |
"jet E_{T} [GeV]", |
264 |
> |
"Emf",emfbins,"Et",etbins)); |
265 |
> |
hAbsRspEmfEt.push_back(hist::initHistos("AbsRspEmfEt",jetalgs[i],100,-50,150, |
266 |
> |
absrsp_xtitle, |
267 |
> |
"Emf",emfbins,"Et",etbins)); |
268 |
> |
hRelRspEmfEt.push_back(hist::initHistos("RelRspEmfEt",jetalgs[i],100,0,2, |
269 |
> |
relrsp_xtitle, |
270 |
> |
"Emf",emfbins,"Et",etbins)); |
271 |
> |
|
272 |
> |
hEtEmfEtaEt .push_back(hist::initHistos("Et",jetalgs[i],100,"jet E_{T} [GeV]", |
273 |
> |
"Emf",emfbins, |
274 |
> |
"Eta",etabins, |
275 |
> |
"Et", etbins)); |
276 |
> |
hEtCorrEmfEtaEt.push_back(hist::initHistos("EtCorrEmfEtaEt",jetalgs[i],100, |
277 |
> |
"jet E_{T} [GeV]", |
278 |
> |
"Emf",emfbins, |
279 |
> |
"Eta",etabins, |
280 |
> |
"Et", etbins)); |
281 |
> |
hAbsRspEmfEtaEt.push_back(hist::initHistos("AbsRspEmfEtaEt",jetalgs[i], |
282 |
> |
100,-50,150,absrsp_xtitle, |
283 |
> |
"Emf",emfbins, |
284 |
> |
"Eta",etabins, |
285 |
> |
"Et", etbins)); |
286 |
> |
hRelRspEmfEtaEt.push_back(hist::initHistos("RelRspEmfEtaEt",jetalgs[i], |
287 |
> |
100,0,2,relrsp_xtitle, |
288 |
> |
"Emf",emfbins, |
289 |
> |
"Eta",etabins, |
290 |
> |
"Et", etbins)); |
291 |
|
|
292 |
|
|
293 |
|
int nevts = el->GetN(); |
294 |
|
cout<<jetalgs[i]<<": "<<nevts<<" events selected."<<endl; |
295 |
|
|
296 |
+ |
// prepare intermediate trees |
297 |
+ |
float genet,et,eta,phi,emf,etcorr,absrsp,relrsp; |
298 |
+ |
TTree** tGenEt = new TTree*[netbins]; |
299 |
+ |
TTree** tEt = new TTree*[netbins]; |
300 |
+ |
TTree** tEta = new TTree*[netabins]; |
301 |
+ |
TTree** tPhi = new TTree*[nphibins]; |
302 |
+ |
TTree** tEmf = new TTree*[nemfbins]; |
303 |
+ |
TTree*** tEtEtaEt = new TTree**[netabins]; |
304 |
+ |
TTree*** tEtEmfEt = new TTree**[nemfbins]; |
305 |
+ |
TTree**** tEtEmfEtaEt = new TTree***[nemfbins]; |
306 |
+ |
|
307 |
+ |
for (int iet=0;iet<netbins;iet++) { |
308 |
+ |
|
309 |
+ |
tGenEt[iet]=new TTree("tGenEt","tGenEt"); |
310 |
+ |
tGenEt[iet]->Branch("val", &genet, "val/F"); |
311 |
+ |
tGenEt[iet]->Branch("etcorr",&etcorr,"etcorr/F"); |
312 |
+ |
tGenEt[iet]->Branch("absrsp",&absrsp,"absrsp/F"); |
313 |
+ |
tGenEt[iet]->Branch("relrsp",&relrsp,"relrsp/F"); |
314 |
+ |
tGenEt[iet]->Branch("weight",&weight,"weight/F"); |
315 |
+ |
|
316 |
+ |
tEt[iet]=new TTree("tEt","tEt"); |
317 |
+ |
tEt[iet]->Branch("val", &et, "val/F"); |
318 |
+ |
tEt[iet]->Branch("etcorr",&etcorr,"etcorr/F"); |
319 |
+ |
tEt[iet]->Branch("absrsp",&absrsp,"absrsp/F"); |
320 |
+ |
tEt[iet]->Branch("relrsp",&relrsp,"relrsp/F"); |
321 |
+ |
tEt[iet]->Branch("weight",&weight,"weight/F"); |
322 |
+ |
} |
323 |
+ |
for (int ieta=0;ieta<netabins;ieta++) { |
324 |
+ |
tEta[ieta]=new TTree("tEta","tEta"); |
325 |
+ |
tEta[ieta]->Branch("val", &eta, "val/F"); |
326 |
+ |
tEta[ieta]->Branch("etcorr",&etcorr,"etcorr/F"); |
327 |
+ |
tEta[ieta]->Branch("absrsp",&absrsp,"absrsp/F"); |
328 |
+ |
tEta[ieta]->Branch("relrsp",&relrsp,"relrsp/F"); |
329 |
+ |
tEta[ieta]->Branch("weight",&weight,"weight/F"); |
330 |
+ |
} |
331 |
+ |
for (int iphi=0;iphi<nphibins;iphi++) { |
332 |
+ |
tPhi[iphi]=new TTree("tPhi","tPhi"); |
333 |
+ |
tPhi[iphi]->Branch("val", &phi, "val/F"); |
334 |
+ |
tPhi[iphi]->Branch("etcorr",&etcorr,"etcorr/F"); |
335 |
+ |
tPhi[iphi]->Branch("absrsp",&absrsp,"absrsp/F"); |
336 |
+ |
tPhi[iphi]->Branch("relrsp",&relrsp,"relrsp/F"); |
337 |
+ |
tPhi[iphi]->Branch("weight",&weight,"weight/F"); |
338 |
+ |
} |
339 |
+ |
for (int iemf=0;iemf<nemfbins;iemf++) { |
340 |
+ |
tEmf[iemf]=new TTree("tEmf","tEmf"); |
341 |
+ |
tEmf[iemf]->Branch("val", &emf, "val/F"); |
342 |
+ |
tEmf[iemf]->Branch("etcorr",&etcorr,"etcorr/F"); |
343 |
+ |
tEmf[iemf]->Branch("absrsp",&absrsp,"absrsp/F"); |
344 |
+ |
tEmf[iemf]->Branch("relrsp",&relrsp,"relrsp/F"); |
345 |
+ |
tEmf[iemf]->Branch("weight",&weight,"weight/F"); |
346 |
+ |
} |
347 |
+ |
for (int ieta=0;ieta<netabins;ieta++) { |
348 |
+ |
tEtEtaEt[ieta] = new TTree*[netbins]; |
349 |
+ |
for (int iet=0;iet<netbins;iet++) { |
350 |
+ |
tEtEtaEt[ieta][iet] = new TTree("tEtEtaEt","tEtEtaEt"); |
351 |
+ |
tEtEtaEt[ieta][iet]->Branch("val", &et, "val/F"); |
352 |
+ |
tEtEtaEt[ieta][iet]->Branch("etcorr",&etcorr,"etcorr/F"); |
353 |
+ |
tEtEtaEt[ieta][iet]->Branch("absrsp",&absrsp,"absrsp/F"); |
354 |
+ |
tEtEtaEt[ieta][iet]->Branch("relrsp",&relrsp,"relrsp/F"); |
355 |
+ |
tEtEtaEt[ieta][iet]->Branch("weight",&weight,"weight/F"); |
356 |
+ |
} |
357 |
+ |
} |
358 |
+ |
for (int iemf=0;iemf<nemfbins;iemf++) { |
359 |
+ |
tEtEmfEt[iemf] = new TTree*[netbins]; |
360 |
+ |
for (int iet=0;iet<netbins;iet++) { |
361 |
+ |
tEtEmfEt[iemf][iet] = new TTree("tEtEmfEt","tEtEmfEt"); |
362 |
+ |
tEtEmfEt[iemf][iet]->Branch("val", &et, "val/F"); |
363 |
+ |
tEtEmfEt[iemf][iet]->Branch("etcorr",&etcorr,"etcorr/F"); |
364 |
+ |
tEtEmfEt[iemf][iet]->Branch("absrsp",&absrsp,"absrsp/F"); |
365 |
+ |
tEtEmfEt[iemf][iet]->Branch("relrsp",&relrsp,"relrsp/F"); |
366 |
+ |
tEtEmfEt[iemf][iet]->Branch("weight",&weight,"weight/F"); |
367 |
+ |
} |
368 |
+ |
} |
369 |
+ |
for (int iemf=0;iemf<nemfbins;iemf++) { |
370 |
+ |
tEtEmfEtaEt[iemf] = new TTree**[netabins]; |
371 |
+ |
for (int ieta=0;ieta<netabins;ieta++) { |
372 |
+ |
tEtEmfEtaEt[iemf][ieta] = new TTree*[netbins]; |
373 |
+ |
for (int iet=0;iet<netbins;iet++) { |
374 |
+ |
tEtEmfEtaEt[iemf][ieta][iet] = new TTree("tEtEmfEtaEt","tEtEmfEtaEt"); |
375 |
+ |
tEtEmfEtaEt[iemf][ieta][iet]->Branch("val", &et, "val/F"); |
376 |
+ |
tEtEmfEtaEt[iemf][ieta][iet]->Branch("etcorr",&etcorr,"etcorr/F"); |
377 |
+ |
tEtEmfEtaEt[iemf][ieta][iet]->Branch("absrsp",&absrsp,"absrsp/F"); |
378 |
+ |
tEtEmfEtaEt[iemf][ieta][iet]->Branch("relrsp",&relrsp,"relrsp/F"); |
379 |
+ |
tEtEmfEtaEt[iemf][ieta][iet]->Branch("weight",&weight,"weight/F"); |
380 |
+ |
} |
381 |
+ |
} |
382 |
+ |
} |
383 |
+ |
|
384 |
|
|
385 |
|
// loop over all events |
386 |
|
for (int ievt=0;ievt<nevts;ievt++) { |
394 |
|
|
395 |
|
if (ijt>0) continue; |
396 |
|
|
397 |
< |
float pt = jtpt[ijt]; |
398 |
< |
float genpt = jtgenpt[ijt]; |
399 |
< |
float eta = (abseta) ? std::abs(jteta[ijt]) : jteta[ijt]; |
400 |
< |
float phi = jtphi[ijt]; |
397 |
> |
et = jtet[ijt]; |
398 |
> |
genet = jtgenet[ijt]; |
399 |
> |
eta = (abseta) ? std::abs(jteta[ijt]) : jteta[ijt]; |
400 |
> |
phi = jtphi[ijt]; |
401 |
> |
emf = jtemf[ijt]; |
402 |
> |
etcorr = (applyjes==0) ? et : et*jtjes[ijt][applyjes-1]; |
403 |
|
|
404 |
< |
float ptcorr = (applyjes==0) ? pt : pt*jtjes[ijt][applyjes-1]; |
405 |
< |
float deltapt = genpt - ptcorr; |
404 |
> |
absrsp = genet - etcorr; |
405 |
> |
relrsp = etcorr/genet; |
406 |
|
|
407 |
< |
// genpt |
408 |
< |
int igenpt = hist::get_ibin(genpt,ptbins); |
409 |
< |
hGenPt[i][igenpt] ->Fill(genpt,weight); |
410 |
< |
//hGenPtPtCorr[i][igenpt]->Fill(ptcorr,weight); |
411 |
< |
hGenPtPtCorr[i][igenpt]->Fill(genpt,weight); |
267 |
< |
hRspVsGenPt[i][igenpt] ->Fill(deltapt,weight); |
407 |
> |
// genet |
408 |
> |
int igenet = hist::get_ibin(genet,etbins); |
409 |
> |
hAbsRspGenEt[i][igenet] ->Fill(absrsp,weight); |
410 |
> |
hRelRspGenEt[i][igenet] ->Fill(relrsp,weight); |
411 |
> |
tGenEt[igenet]->Fill(); |
412 |
|
|
413 |
< |
// pt |
414 |
< |
int ipt = hist::get_ibin(pt,ptbins); |
415 |
< |
hPt[i][ipt] ->Fill(pt,weight); |
416 |
< |
hPtCorr[i][ipt] ->Fill(ptcorr,weight); |
417 |
< |
hRspVsPt[i][ipt]->Fill(deltapt,weight); |
413 |
> |
// et |
414 |
> |
int iet = hist::get_ibin(et,etbins); |
415 |
> |
hAbsRspEt[i][iet]->Fill(absrsp,weight); |
416 |
> |
hRelRspEt[i][iet]->Fill(relrsp,weight); |
417 |
> |
tEt[iet]->Fill(); |
418 |
|
|
419 |
|
// eta |
420 |
|
int ieta = hist::get_ibin(eta,etabins); |
421 |
< |
hEta[i][ieta] ->Fill(eta, weight); |
422 |
< |
hEtaPtCorr[i][ieta]->Fill(ptcorr, weight); |
423 |
< |
hRspVsEta[i][ieta] ->Fill(deltapt,weight); |
424 |
< |
|
421 |
> |
hAbsRspEta[i][ieta]->Fill(absrsp,weight); |
422 |
> |
hRelRspEta[i][ieta]->Fill(relrsp,weight); |
423 |
> |
tEta[ieta]->Fill(); |
424 |
> |
|
425 |
|
// phi |
426 |
|
int iphi = hist::get_ibin(phi,phibins); |
427 |
< |
hPhi[i][iphi] ->Fill(phi, weight); |
428 |
< |
hPhiPtCorr[i][iphi]->Fill(ptcorr, weight); |
429 |
< |
hRspVsPhi[i][iphi] ->Fill(deltapt,weight); |
430 |
< |
|
431 |
< |
// pt-eta |
432 |
< |
hEtaPtPt[i][ieta][ipt] ->Fill(pt, weight); |
433 |
< |
hEtaPtPtCorr[i][ieta][ipt]->Fill(ptcorr, weight); |
434 |
< |
hRspVsEtaPt[i][ieta][ipt] ->Fill(deltapt,weight); |
435 |
< |
|
427 |
> |
hAbsRspPhi[i][iphi]->Fill(absrsp,weight); |
428 |
> |
hRelRspPhi[i][iphi]->Fill(relrsp,weight); |
429 |
> |
tPhi[iphi]->Fill(); |
430 |
> |
|
431 |
> |
// emf |
432 |
> |
int iemf = hist::get_ibin(emf,emfbins); |
433 |
> |
hAbsRspEmf[i][iemf]->Fill(absrsp,weight); |
434 |
> |
hRelRspEmf[i][iemf]->Fill(relrsp,weight); |
435 |
> |
tEmf[iemf]->Fill(); |
436 |
> |
|
437 |
> |
// et-eta |
438 |
> |
hAbsRspEtaEt[i][ieta][iet]->Fill(absrsp,weight); |
439 |
> |
hRelRspEtaEt[i][ieta][iet]->Fill(relrsp,weight); |
440 |
> |
tEtEtaEt[ieta][iet]->Fill(); |
441 |
> |
|
442 |
> |
// et-emf |
443 |
> |
hAbsRspEmfEt[i][iemf][iet]->Fill(absrsp,weight); |
444 |
> |
hRelRspEmfEt[i][iemf][iet]->Fill(relrsp,weight); |
445 |
> |
tEtEmfEt[iemf][iet]->Fill(); |
446 |
> |
|
447 |
> |
// et-eta-emf |
448 |
> |
hAbsRspEmfEtaEt[i][iemf][ieta][iet]->Fill(absrsp,weight); |
449 |
> |
hRelRspEmfEtaEt[i][iemf][ieta][iet]->Fill(relrsp,weight); |
450 |
> |
tEtEmfEtaEt[iemf][ieta][iet]->Fill(); |
451 |
|
|
452 |
|
} // jets |
453 |
|
} // evts |
454 |
|
|
455 |
|
cout<<jetalgs[i]<<": all events processed / histograms filled."<<endl; |
297 |
– |
|
298 |
– |
|
299 |
– |
TDirectory* d = plotfile->mkdir(jetalgs[i].c_str()); |
300 |
– |
d->cd(); |
301 |
– |
|
302 |
– |
|
303 |
– |
// response / resolution vs *genpt* |
304 |
– |
gRspVsGenPt.push_back(new TGraphErrors(nptbins)); |
305 |
– |
gSgmVsGenPt.push_back(new TGraphErrors(nptbins)); |
306 |
– |
gRspVsGenPt.back()->SetName(("RspVsGenPt_"+jetalgs[i]).c_str()); |
307 |
– |
gSgmVsGenPt.back()->SetName(("SgmVsGenPt_"+jetalgs[i]).c_str()); |
308 |
– |
fillRspAndSgm(gRspVsGenPt.back(),gSgmVsGenPt.back(),nsigma, |
309 |
– |
ptbins,hGenPt[i],hGenPtPtCorr[i],hRspVsGenPt[i]); |
310 |
– |
|
311 |
– |
// response / resolution vs *pt* |
312 |
– |
gRspVsPt.push_back(new TGraphErrors(nptbins)); |
313 |
– |
gSgmVsPt.push_back(new TGraphErrors(nptbins)); |
314 |
– |
gRspVsPt.back()->SetName(("RspVsPt_"+jetalgs[i]).c_str()); |
315 |
– |
gSgmVsPt.back()->SetName(("SgmVsPt_"+jetalgs[i]).c_str()); |
316 |
– |
fillRspAndSgm(gRspVsPt.back(),gSgmVsPt.back(),nsigma, |
317 |
– |
ptbins,hPt[i],hPtCorr[i],hRspVsPt[i]); |
318 |
– |
|
319 |
– |
// response / resolution vs *eta* |
320 |
– |
gRspVsEta.push_back(new TGraphErrors(netabins)); |
321 |
– |
gSgmVsEta.push_back(new TGraphErrors(netabins)); |
322 |
– |
gRspVsEta.back()->SetName(("RspVsEta_"+jetalgs[i]).c_str()); |
323 |
– |
gSgmVsEta.back()->SetName(("SgmVsEta_"+jetalgs[i]).c_str()); |
324 |
– |
fillRspAndSgm(gRspVsEta.back(),gSgmVsEta.back(),nsigma, |
325 |
– |
etabins,hEta[i],hEtaPtCorr[i],hRspVsEta[i]); |
326 |
– |
|
327 |
– |
// response / resolution vs *phi* |
328 |
– |
gRspVsPhi.push_back(new TGraphErrors(nphibins)); |
329 |
– |
gSgmVsPhi.push_back(new TGraphErrors(nphibins)); |
330 |
– |
gRspVsPhi.back()->SetName(("RspVsPhi_"+jetalgs[i]).c_str()); |
331 |
– |
gSgmVsPhi.back()->SetName(("SgmVsPhi_"+jetalgs[i]).c_str()); |
332 |
– |
fillRspAndSgm(gRspVsPhi.back(),gSgmVsPhi.back(),nsigma, |
333 |
– |
phibins,hPhi[i],hPhiPtCorr[i],hRspVsPhi[i]); |
334 |
– |
|
335 |
– |
// response / resolution vs *pt-eta* |
336 |
– |
TGraphErrors** g; |
337 |
– |
g=new TGraphErrors*[netabins]; |
338 |
– |
for (int ieta=0;ieta<netabins;ieta++) g[ieta] = new TGraphErrors(nptbins); |
339 |
– |
gRspVsEtaPt.push_back(g); |
340 |
– |
g=new TGraphErrors*[netabins]; |
341 |
– |
for (int ieta=0;ieta<netabins;ieta++) g[ieta] = new TGraphErrors(nptbins); |
342 |
– |
gSgmVsEtaPt.push_back(g); |
343 |
– |
for (int ieta=0;ieta<netabins;ieta++) { |
344 |
– |
gRspVsEtaPt[i][ieta]->SetName(("RspVsPhi_"+ |
345 |
– |
hist::get_bin_name("Eta",ieta,etabins)+ |
346 |
– |
"_"+jetalgs[i]).c_str()); |
347 |
– |
gSgmVsEtaPt[i][ieta]->SetName(("SgmVsPhi_"+ |
348 |
– |
hist::get_bin_name("Eta",ieta,etabins)+ |
349 |
– |
"_"+jetalgs[i]).c_str()); |
350 |
– |
fillRspAndSgm(gRspVsEtaPt[i][ieta],gSgmVsEtaPt[i][ieta],nsigma,ptbins, |
351 |
– |
hEtaPtPt[i][ieta],hEtaPtPtCorr[i][ieta],hRspVsEtaPt[i][ieta]); |
352 |
– |
} |
353 |
– |
} |
354 |
– |
|
355 |
– |
|
356 |
– |
TCanvas* c = (TCanvas*)gROOT->FindObject("c1"); |
357 |
– |
if (0!=c) delete c; |
358 |
– |
|
359 |
– |
|
360 |
– |
// |
361 |
– |
// make plots |
362 |
– |
// |
363 |
– |
for (unsigned int ialg=0;ialg<jetalgs.size();ialg++) { |
364 |
– |
|
365 |
– |
TDirectory* d = plotfile->GetDirectory(jetalgs[ialg].c_str()); |
366 |
– |
d->cd(); |
367 |
– |
|
368 |
– |
// genpt |
369 |
– |
TCanvas* cGenPt = plotVarHistos(ptbins,hGenPt[ialg],true); |
370 |
– |
TCanvas* cGenPtPtCorr = plotVarHistos(ptbins,hGenPtPtCorr[ialg],true); |
371 |
– |
TCanvas* cRspGenPt = plotRspHistos(ptbins,hRspVsGenPt[ialg]); |
372 |
– |
|
373 |
– |
delete cGenPt; |
374 |
– |
delete cGenPtPtCorr; |
375 |
– |
delete cRspGenPt; |
376 |
– |
|
377 |
– |
// pt |
378 |
– |
TCanvas* cPt = plotVarHistos(ptbins,hPt[ialg],true); |
379 |
– |
TCanvas* cPtCorr = plotVarHistos(ptbins,hPtCorr[ialg],true); |
380 |
– |
TCanvas* cRspPt = plotRspHistos(ptbins,hRspVsPt[ialg]); |
381 |
– |
|
382 |
– |
delete cPt; |
383 |
– |
delete cPtCorr; |
384 |
– |
delete cRspPt; |
385 |
– |
|
386 |
– |
// eta |
387 |
– |
TCanvas* cEta = plotVarHistos(etabins,hEta[ialg]); |
388 |
– |
TCanvas* cEtaPtCorr = plotVarHistos(etabins,hEtaPtCorr[ialg],true); |
389 |
– |
TCanvas* cRspEta = plotRspHistos(etabins,hRspVsEta[ialg]); |
390 |
– |
|
391 |
– |
delete cEta; |
392 |
– |
delete cEtaPtCorr; |
393 |
– |
delete cRspEta; |
394 |
– |
|
395 |
– |
// phi |
396 |
– |
TCanvas* cPhi = plotVarHistos(phibins,hPhi[ialg]); |
397 |
– |
TCanvas* cPhiPtCorr = plotVarHistos(phibins,hPhiPtCorr[ialg],true); |
398 |
– |
TCanvas* cRspPhi = plotRspHistos(phibins,hRspVsPhi[ialg]); |
399 |
– |
|
400 |
– |
delete cPhi; |
401 |
– |
delete cPhiPtCorr; |
402 |
– |
delete cRspPhi; |
403 |
– |
|
404 |
– |
// eta-pt |
405 |
– |
for (int ieta=0;ieta<netabins;ieta++) { |
406 |
– |
TCanvas* cEtaPtPt = plotVarHistos(ptbins,hEtaPtPt[ialg][ieta],true); |
407 |
– |
TCanvas* cEtaPtPtCorr = plotVarHistos(ptbins,hEtaPtPtCorr[ialg][ieta],true); |
408 |
– |
TCanvas* cRspEtaPt = plotRspHistos(ptbins,hRspVsEtaPt[ialg][ieta]); |
409 |
– |
|
410 |
– |
delete cEtaPtPt; |
411 |
– |
delete cEtaPtPtCorr; |
412 |
– |
delete cRspEtaPt; |
413 |
– |
} |
456 |
|
|
415 |
– |
} |
416 |
– |
|
417 |
– |
plotfile->cd(); |
457 |
|
|
458 |
< |
// response & resolution vs genpT |
420 |
< |
TCanvas* cRspVsGenPt=plotResponse(jetalgs,applyjes,gRspVsGenPt, |
421 |
< |
"GenPt","jet p_{T}^{gen} [GeV]"); |
422 |
< |
TCanvas* cSgmVsGenPt=plotResolution(jetalgs,gSgmVsGenPt, |
423 |
< |
"GenPt","jet p_{T}^{gen} [GeV]"); |
424 |
< |
cRspVsGenPt->cd(); |
425 |
< |
cSgmVsGenPt->cd(); |
426 |
< |
|
427 |
< |
// response & resolution vs pT |
428 |
< |
TCanvas* cRspVsPt = plotResponse(jetalgs,applyjes,gRspVsPt,"Pt","jet p_{T} [GeV]"); |
429 |
< |
TCanvas* cSgmVsPt = plotResolution(jetalgs,gSgmVsPt,"Pt","jet p_{T} [GeV]"); |
430 |
< |
cRspVsPt->cd(); |
431 |
< |
cSgmVsPt->cd(); |
432 |
< |
|
433 |
< |
// response & resolution vs eta |
434 |
< |
TCanvas* cRspVsEta = plotResponse(jetalgs,applyjes,gRspVsEta,"Eta","jet #eta"); |
435 |
< |
TCanvas* cSgmVsEta = plotResolution(jetalgs,gSgmVsEta,"Eta","jet #eta"); |
436 |
< |
cRspVsEta->cd(); |
437 |
< |
cSgmVsEta->cd(); |
438 |
< |
|
439 |
< |
// response & resolution vs phi |
440 |
< |
TCanvas* cRspVsPhi = plotResponse(jetalgs,applyjes,gRspVsPhi,"Phi","jet #phi"); |
441 |
< |
TCanvas* cSgmVsPhi = plotResolution(jetalgs,gSgmVsPhi,"Phi","jet #phi"); |
442 |
< |
cRspVsPhi->cd(); |
443 |
< |
cSgmVsPhi->cd(); |
458 |
> |
// replace histograms |
459 |
|
|
460 |
< |
// response & resolution vs eta/pT |
461 |
< |
for (unsigned int ialg=0;ialg<jetalgs.size();ialg++) { |
460 |
> |
replaceHistos(netbins, |
461 |
> |
hGenEt[i],hEtCorrGenEt[i],hAbsRspGenEt[i],hRelRspGenEt[i],tGenEt); |
462 |
> |
replaceHistos(netbins,hEt[i],hEtCorrEt[i],hAbsRspEt[i],hRelRspEt[i],tEt); |
463 |
> |
replaceHistos(netabins,hEta[i],hEtCorrEta[i],hAbsRspEta[i],hRelRspEta[i],tEta); |
464 |
> |
replaceHistos(nphibins,hPhi[i],hEtCorrPhi[i],hAbsRspPhi[i],hRelRspPhi[i],tPhi); |
465 |
> |
replaceHistos(nemfbins,hEmf[i],hEtCorrEmf[i],hAbsRspEmf[i],hRelRspEmf[i],tEmf); |
466 |
> |
replaceHistos(netabins,netbins, |
467 |
> |
hEtEtaEt[i],hEtCorrEtaEt[i],hAbsRspEtaEt[i],hRelRspEtaEt[i], |
468 |
> |
tEtEtaEt); |
469 |
> |
replaceHistos(nemfbins,netbins, |
470 |
> |
hEtEmfEt[i],hEtCorrEmfEt[i],hAbsRspEmfEt[i],hRelRspEmfEt[i], |
471 |
> |
tEtEmfEt); |
472 |
> |
replaceHistos(nemfbins,netabins,netbins, |
473 |
> |
hEtEmfEtaEt[i],hEtCorrEmfEtaEt[i], |
474 |
> |
hAbsRspEmfEtaEt[i],hRelRspEmfEtaEt[i], |
475 |
> |
tEtEmfEtaEt); |
476 |
|
|
477 |
< |
TDirectory* d = plotfile->GetDirectory(jetalgs[ialg].c_str()); |
477 |
> |
TDirectory* d = plotfile->mkdir(jetalgs[i].c_str()); |
478 |
|
d->cd(); |
479 |
|
|
480 |
< |
TCanvas* cRspVsEtaPt = plotResponse(jetalgs[ialg],applyjes,fitcorr, |
481 |
< |
etabins,gRspVsEtaPt[ialg], |
482 |
< |
"Eta","#eta","Pt","jet p_{T} [GeV]"); |
483 |
< |
TCanvas* cSgmVsEtaPt = plotResolution(jetalgs[ialg],etabins,gSgmVsEtaPt[ialg], |
484 |
< |
"Eta","#eta","Pt","jet p_{T} [GeV]"); |
485 |
< |
|
486 |
< |
cRspVsEtaPt->cd(); |
487 |
< |
cSgmVsEtaPt->cd(); |
480 |
> |
// fit response histos |
481 |
> |
fitHistos(hAbsRspGenEt[i],netbins,nsigma); |
482 |
> |
fitHistos(hRelRspGenEt[i],netbins,nsigma); |
483 |
> |
|
484 |
> |
fitHistos(hAbsRspEt[i], netbins,nsigma); |
485 |
> |
fitHistos(hRelRspEt[i], netbins,nsigma); |
486 |
> |
|
487 |
> |
fitHistos(hAbsRspEta[i], netabins,nsigma); |
488 |
> |
fitHistos(hRelRspEta[i], netabins,nsigma); |
489 |
> |
|
490 |
> |
fitHistos(hAbsRspPhi[i], nphibins,nsigma); |
491 |
> |
fitHistos(hRelRspPhi[i], nphibins,nsigma); |
492 |
> |
|
493 |
> |
fitHistos(hAbsRspEmf[i], nemfbins,nsigma); |
494 |
> |
fitHistos(hRelRspEmf[i], nemfbins,nsigma); |
495 |
> |
|
496 |
> |
fitHistos(hAbsRspEtaEt[i],netabins,netbins,nsigma); |
497 |
> |
fitHistos(hRelRspEtaEt[i],netabins,netbins,nsigma); |
498 |
> |
|
499 |
> |
fitHistos(hAbsRspEmfEt[i],nemfbins,netbins,nsigma); |
500 |
> |
fitHistos(hRelRspEmfEt[i],nemfbins,netbins,nsigma); |
501 |
> |
|
502 |
> |
fitHistos(hAbsRspEmfEtaEt[i],nemfbins,netabins,netbins,nsigma); |
503 |
> |
fitHistos(hRelRspEmfEtaEt[i],nemfbins,netabins,netbins,nsigma); |
504 |
> |
|
505 |
> |
|
506 |
> |
// save histograms |
507 |
> |
saveHistos(hGenEt[i], netbins); |
508 |
> |
saveHistos(hEtCorrGenEt[i],netbins); |
509 |
> |
saveHistos(hAbsRspGenEt[i],netbins); |
510 |
> |
saveHistos(hRelRspGenEt[i],netbins); |
511 |
> |
|
512 |
> |
saveHistos(hEt[i], netbins); |
513 |
> |
saveHistos(hEtCorrEt[i], netbins); |
514 |
> |
saveHistos(hAbsRspEt[i], netbins); |
515 |
> |
saveHistos(hRelRspEt[i], netbins); |
516 |
> |
|
517 |
> |
saveHistos(hEta[i], netabins); |
518 |
> |
saveHistos(hEtCorrEta[i], netabins); |
519 |
> |
saveHistos(hAbsRspEta[i], netabins); |
520 |
> |
saveHistos(hRelRspEta[i], netabins); |
521 |
> |
|
522 |
> |
saveHistos(hPhi[i], nphibins); |
523 |
> |
saveHistos(hEtCorrPhi[i], nphibins); |
524 |
> |
saveHistos(hAbsRspPhi[i], nphibins); |
525 |
> |
saveHistos(hRelRspPhi[i], nphibins); |
526 |
> |
|
527 |
> |
saveHistos(hEmf[i], nemfbins); |
528 |
> |
saveHistos(hEtCorrEmf[i], nemfbins); |
529 |
> |
saveHistos(hAbsRspEmf[i], nemfbins); |
530 |
> |
saveHistos(hRelRspEmf[i], nemfbins); |
531 |
> |
|
532 |
> |
saveHistos(hEtEtaEt[i], netabins,netbins); |
533 |
> |
saveHistos(hEtCorrEtaEt[i],netabins,netbins); |
534 |
> |
saveHistos(hAbsRspEtaEt[i],netabins,netbins); |
535 |
> |
saveHistos(hRelRspEtaEt[i],netabins,netbins); |
536 |
> |
|
537 |
> |
saveHistos(hEtEmfEt[i], nemfbins,netbins); |
538 |
> |
saveHistos(hEtCorrEmfEt[i],nemfbins,netbins); |
539 |
> |
saveHistos(hAbsRspEmfEt[i],nemfbins,netbins); |
540 |
> |
saveHistos(hRelRspEmfEt[i],nemfbins,netbins); |
541 |
> |
|
542 |
> |
saveHistos(hEtEmfEtaEt[i], nemfbins,netabins,netbins); |
543 |
> |
saveHistos(hEtCorrEmfEtaEt[i],nemfbins,netabins,netbins); |
544 |
> |
saveHistos(hAbsRspEmfEtaEt[i],nemfbins,netabins,netbins); |
545 |
> |
saveHistos(hRelRspEmfEtaEt[i],nemfbins,netabins,netbins); |
546 |
|
} |
547 |
|
|
548 |
|
plotfile->Write(); |
549 |
|
plotfile->Close(); |
550 |
|
delete plotfile; |
551 |
|
|
465 |
– |
app->Run(); |
466 |
– |
|
552 |
|
return 0; |
553 |
|
} |
554 |
|
|
559 |
|
//////////////////////////////////////////////////////////////////////////////// |
560 |
|
|
561 |
|
//______________________________________________________________________________ |
562 |
< |
void fillRspAndSgm(TGraphErrors* gRsp,TGraphErrors* gSgm,float nsigma, |
563 |
< |
const vector<float>& bins,TH1F** hVar,TH1F** hPt,TH1F** hRsp) |
562 |
> |
void replaceHistos(int nbins, |
563 |
> |
TH1F**& hVar,TH1F**& hEtCorr,TH1F**& hAbsRsp,TH1F**& hRelRsp, |
564 |
> |
TTree**& tVar) |
565 |
|
{ |
566 |
< |
int nbins = bins.size()+1; |
566 |
> |
TH1::SetDefaultSumw2(); |
567 |
|
for (int ibin=0;ibin<nbins;ibin++) { |
568 |
|
|
569 |
< |
float var = hVar[ibin]->GetMean(); |
570 |
< |
float pt = hPt[ibin]->GetMean(); |
571 |
< |
TH1F* h = hRsp[ibin]; |
572 |
< |
|
573 |
< |
float de = h->GetMean(); |
574 |
< |
float errde = h->GetMeanError(); |
575 |
< |
float sgmde = h->GetRMS(); |
576 |
< |
float errsgmde = h->GetRMSError(); |
577 |
< |
|
578 |
< |
if (h->GetEntries()>50) { |
579 |
< |
string fname = "fitfnc" + (string)h->GetName(); |
580 |
< |
TF1* f = new TF1(fname.c_str(),"gaus",de-nsigma*sgmde,de+nsigma*sgmde); |
581 |
< |
f->SetLineColor(kRed); |
582 |
< |
f->SetLineWidth(1); |
583 |
< |
f->SetParameter(1,de); |
584 |
< |
f->SetParameter(2,sgmde); |
585 |
< |
h->Fit(f,"QR"); |
586 |
< |
|
587 |
< |
de = f->GetParameter(1); |
588 |
< |
errde = f->GetParError(1); |
589 |
< |
sgmde = f->GetParameter(2); |
590 |
< |
errsgmde = f->GetParError(2); |
591 |
< |
} |
569 |
> |
TH1F* h(0); |
570 |
> |
|
571 |
> |
if (tVar[ibin]->GetEntries()==0) continue; |
572 |
> |
|
573 |
> |
tVar[ibin]->Project("h(50)","val","weight*(1)"); |
574 |
> |
h = (TH1F*)gROOT->FindObject("h"); |
575 |
> |
h->SetNameTitle(hVar[ibin]->GetName(),hVar[ibin]->GetTitle()); |
576 |
> |
h->SetXTitle(hVar[ibin]->GetXaxis()->GetTitle()); |
577 |
> |
h->SetYTitle(hVar[ibin]->GetYaxis()->GetTitle()); |
578 |
> |
delete hVar[ibin]; |
579 |
> |
hVar[ibin] = h; |
580 |
> |
|
581 |
> |
tVar[ibin]->Project("h(50)","etcorr","weight*(1)"); |
582 |
> |
h = (TH1F*)gROOT->FindObject("h"); |
583 |
> |
h->SetNameTitle(hEtCorr[ibin]->GetName(),hEtCorr[ibin]->GetTitle()); |
584 |
> |
h->SetXTitle(hEtCorr[ibin]->GetXaxis()->GetTitle()); |
585 |
> |
h->SetYTitle(hEtCorr[ibin]->GetYaxis()->GetTitle()); |
586 |
> |
delete hEtCorr[ibin]; |
587 |
> |
hEtCorr[ibin] = h; |
588 |
> |
|
589 |
> |
tVar[ibin]->Project("h(50)","absrsp","weight*(1)"); |
590 |
> |
h = (TH1F*)gROOT->FindObject("h"); |
591 |
> |
h->SetNameTitle(hAbsRsp[ibin]->GetName(),hAbsRsp[ibin]->GetTitle()); |
592 |
> |
h->SetXTitle(hAbsRsp[ibin]->GetXaxis()->GetTitle()); |
593 |
> |
h->SetYTitle(hAbsRsp[ibin]->GetYaxis()->GetTitle()); |
594 |
> |
delete hAbsRsp[ibin]; |
595 |
> |
hAbsRsp[ibin] = h; |
596 |
> |
|
597 |
> |
tVar[ibin]->Project("h(50)","relrsp","weight*(1)"); |
598 |
> |
h = (TH1F*)gROOT->FindObject("h"); |
599 |
> |
h->SetNameTitle(hRelRsp[ibin]->GetName(),hRelRsp[ibin]->GetTitle()); |
600 |
> |
h->SetXTitle(hRelRsp[ibin]->GetXaxis()->GetTitle()); |
601 |
> |
h->SetYTitle(hRelRsp[ibin]->GetYaxis()->GetTitle()); |
602 |
> |
delete hRelRsp[ibin]; |
603 |
> |
hRelRsp[ibin] = h; |
604 |
|
|
605 |
< |
float rsp = pt/(pt+de); |
508 |
< |
float errrsp = pt/(pt+de)/(pt+de)*errde; |
509 |
< |
float sgm = pt/(pt+de)/(pt+de)*sgmde; |
510 |
< |
float errsgm = 2*pt*sgmde/(pt+de)/(pt+de)/(pt+de)*errde; |
511 |
< |
|
512 |
< |
sgm /= rsp; |
513 |
< |
errsgm /= rsp; |
514 |
< |
|
515 |
< |
gRsp->SetPoint(ibin,var,rsp); |
516 |
< |
gRsp->SetPointError(ibin,0.0,errrsp); |
517 |
< |
gSgm->SetPoint(ibin,var,sgm); |
518 |
< |
gSgm->SetPointError(ibin,0.0,errsgm); |
605 |
> |
delete tVar[ibin]; |
606 |
|
} |
607 |
|
|
608 |
< |
gRsp->Write(); |
522 |
< |
gSgm->Write(); |
608 |
> |
delete [] tVar; |
609 |
|
} |
610 |
|
|
611 |
|
|
612 |
|
//______________________________________________________________________________ |
613 |
< |
TCanvas* plotVarHistos(const vector<float>& bins,TH1F** hVar,bool logy) |
613 |
> |
void replaceHistos(int nbins1,int nbins2, |
614 |
> |
TH1F***& hVar,TH1F***& hEtCorr,TH1F***& hAbsRsp,TH1F***& hRelRsp, |
615 |
> |
TTree***& tVar) |
616 |
|
{ |
617 |
< |
string::size_type pos; |
618 |
< |
string cname,jetalg; |
531 |
< |
|
532 |
< |
cname = hVar[0]->GetName(); |
533 |
< |
pos = cname.find_last_of('_'); |
534 |
< |
jetalg = cname.substr(pos+1); |
535 |
< |
cname = cname.substr(0,pos); |
536 |
< |
pos = cname.find_last_of(':'); |
537 |
< |
cname = cname.substr(0,pos); |
538 |
< |
cname += "_"+jetalg; |
539 |
< |
|
540 |
< |
TCanvas* c = new TCanvas(cname.c_str(),cname.c_str()); |
541 |
< |
|
542 |
< |
int nbins = bins.size()+1; |
543 |
< |
int ncx= int(std::sqrt((float)nbins)); |
544 |
< |
int ncy= ncx; |
545 |
< |
if (ncx*ncy<nbins) ncx++; |
546 |
< |
if (ncx*ncy<nbins) ncy++; |
547 |
< |
|
548 |
< |
c->Divide(ncx,ncy); |
549 |
< |
|
550 |
< |
for (int ibin=0;ibin<nbins;ibin++) { |
551 |
< |
c->cd(ibin+1); |
552 |
< |
gPad->SetLogy(logy); |
553 |
< |
hVar[ibin]->Draw("EHIST"); |
554 |
< |
hVar[ibin]->Write(); |
555 |
< |
} |
556 |
< |
|
557 |
< |
//c->Write(); |
558 |
< |
|
559 |
< |
return c; |
617 |
> |
for (int i1=0;i1<nbins1;i1++) |
618 |
> |
replaceHistos(nbins2,hVar[i1],hEtCorr[i1],hAbsRsp[i1],hRelRsp[i1],tVar[i1]); |
619 |
|
} |
620 |
|
|
621 |
|
|
622 |
|
//______________________________________________________________________________ |
623 |
< |
TCanvas* plotRspHistos(const vector<float>& bins,TH1F** hRsp) |
623 |
> |
void replaceHistos(int nbins1,int nbins2,int nbins3, |
624 |
> |
TH1F****& hVar,TH1F****& hEtCorr,TH1F****&hAbsRsp,TH1F****&hRelRsp, |
625 |
> |
TTree****& tVar) |
626 |
|
{ |
627 |
< |
string::size_type pos; |
628 |
< |
string cname,jetalg; |
629 |
< |
|
569 |
< |
|
570 |
< |
cname = hRsp[0]->GetName(); |
571 |
< |
pos = cname.find_last_of('_'); |
572 |
< |
jetalg = cname.substr(pos+1); |
573 |
< |
cname = cname.substr(0,pos); |
574 |
< |
pos = cname.find_last_of('_'); |
575 |
< |
cname = cname.substr(0,pos); |
576 |
< |
cname += "_"+jetalg; |
577 |
< |
|
578 |
< |
TCanvas* c = new TCanvas(cname.c_str(),cname.c_str()); |
579 |
< |
|
580 |
< |
int nbins = bins.size()+1; |
581 |
< |
int ncx= int(std::sqrt((float)nbins)); |
582 |
< |
int ncy= ncx; |
583 |
< |
if (ncx*ncy<nbins) ncx++; |
584 |
< |
if (ncx*ncy<nbins) ncy++; |
585 |
< |
|
586 |
< |
c->Divide(ncx,ncy); |
587 |
< |
|
588 |
< |
for (int ibin=0;ibin<nbins;ibin++) { |
589 |
< |
c->cd(ibin+1); |
590 |
< |
if (hRsp[ibin]->GetEntries()>0) gPad->SetLogy(); |
591 |
< |
hRsp[ibin]->Draw("EHIST"); |
592 |
< |
string fname = "fitfnc" + (string)hRsp[ibin]->GetName(); |
593 |
< |
TF1* fitfnc=hRsp[ibin]->GetFunction(fname.c_str()); |
594 |
< |
if (0!=fitfnc) fitfnc->Draw("SAME"); |
595 |
< |
hRsp[ibin]->Write(); |
596 |
< |
} |
597 |
< |
|
598 |
< |
c->Write(); |
599 |
< |
|
600 |
< |
return c; |
627 |
> |
for (int i1=0;i1<nbins1;i1++) |
628 |
> |
replaceHistos(nbins2,nbins3, |
629 |
> |
hVar[i1],hEtCorr[i1],hAbsRsp[i1],hRelRsp[i1],tVar[i1]); |
630 |
|
} |
631 |
|
|
632 |
|
|
633 |
|
//______________________________________________________________________________ |
634 |
< |
TCanvas* plotResponse(const vector<string>& jetalgs,short applyjes, |
606 |
< |
const vector<TGraphErrors*> gRsp, |
607 |
< |
const string& varname,const string& xtitle) |
634 |
> |
void fitHistos(TH1F** histos,int n,double nsigma) |
635 |
|
{ |
636 |
< |
assert(jetalgs.size()==gRsp.size()); |
637 |
< |
|
638 |
< |
string cname = "RspVs"+varname; |
639 |
< |
TCanvas* c = new TCanvas(cname.c_str(),cname.c_str()); |
640 |
< |
TLegend* l = new TLegend(0.7,0.25+jetalgs.size()*0.045,0.85,0.25); |
641 |
< |
|
642 |
< |
l->SetFillColor(10); |
643 |
< |
Color_t color=kBlack; |
644 |
< |
TMultiGraph* mg = new TMultiGraph(); |
645 |
< |
|
646 |
< |
for (unsigned int i=0;i<gRsp.size();i++) { |
620 |
< |
TGraphErrors* g = gRsp[i]; |
621 |
< |
l->AddEntry(g,jetalgs[i].c_str(),"l"); |
622 |
< |
while (color==kYellow||color==kWhite||color==10) color++; |
623 |
< |
g->SetMarkerColor(color); |
624 |
< |
g->SetLineColor(color); |
625 |
< |
g->SetMarkerStyle(kFullCircle); |
626 |
< |
g->SetMarkerSize(0.5); |
627 |
< |
mg->Add(g,"P"); |
628 |
< |
|
629 |
< |
if (varname=="Pt") { |
630 |
< |
string fname = "fitfnc"+cname; |
631 |
< |
string fitfncAsString = |
632 |
< |
//(applyjes==0) ? "[0]+[1]*log(x)+[2]*log(x)*log(x)+[3]*x+[4]*x*x" : "pol0"; |
633 |
< |
(applyjes==0) ? "[0]*(pow(log(x),[1])-1/x)" : "pol0"; |
634 |
< |
|
635 |
< |
TF1* fitfnc = new TF1(fname.c_str(),fitfncAsString.c_str(),1,get_xmax(g)); |
636 |
< |
|
637 |
< |
if (applyjes==0) { |
638 |
< |
fitfnc->SetParameter(0,0.4); |
639 |
< |
fitfnc->SetParameter(1,0.4); |
640 |
< |
} |
641 |
< |
else { |
642 |
< |
fitfnc->SetParameter(0,1.0); |
643 |
< |
} |
644 |
< |
|
645 |
< |
fitfnc->SetLineWidth(1); |
646 |
< |
fitfnc->SetLineColor(color); |
647 |
< |
g->Fit(fitfnc,"QR"); |
648 |
< |
} |
649 |
< |
|
650 |
< |
g->Write(); |
651 |
< |
|
652 |
< |
color++; |
636 |
> |
for (int i=0;i<n;i++) { |
637 |
> |
float nrm = histos[i]->Integral(); |
638 |
> |
float mean = histos[i]->GetMean(); |
639 |
> |
float rms = histos[i]->GetRMS(); |
640 |
> |
TF1* f = new TF1("gaus","gaus",mean-nsigma*rms,mean+nsigma*rms); |
641 |
> |
f->SetParameter(0,nrm); |
642 |
> |
f->SetParameter(1,mean); |
643 |
> |
f->SetParameter(2,rms); |
644 |
> |
f->SetLineWidth(1); |
645 |
> |
f->SetLineColor(kRed); |
646 |
> |
histos[i]->Fit(f,"QR"); |
647 |
|
} |
654 |
– |
|
655 |
– |
string mgtitle = "Jet Response Vs "+varname; |
656 |
– |
mg->Draw("a"); |
657 |
– |
mg->SetTitle(mgtitle.c_str()); |
658 |
– |
mg->GetXaxis()->SetTitle(xtitle.c_str()); |
659 |
– |
mg->GetYaxis()->SetTitle("E_{T}^{rec}/E_{T}^{gen}"); |
660 |
– |
if (varname=="Pt") mg->GetXaxis()->SetLimits(0.0,mg->GetXaxis()->GetXmax()); |
661 |
– |
mg->SetMinimum(0.0); |
662 |
– |
mg->SetMaximum(1.1); |
663 |
– |
l->Draw(); |
664 |
– |
|
665 |
– |
c->Write(); |
666 |
– |
|
667 |
– |
return c; |
648 |
|
} |
649 |
|
|
650 |
|
|
651 |
|
//______________________________________________________________________________ |
652 |
< |
TCanvas* plotResponse(const string& jetalg,short applyjes,bool fitcorr, |
673 |
< |
const vector<float>& bins1,TGraphErrors** gRsp, |
674 |
< |
const string& varname1,const string vartitle1, |
675 |
< |
const string& varname2,const string& xtitle) |
676 |
< |
|
652 |
> |
void fitHistos(TH1F*** histos,int n1,int n2,double nsigma) |
653 |
|
{ |
654 |
< |
int nbins = bins1.size()+1; |
679 |
< |
|
680 |
< |
string fitfncAsString = "pol0"; |
681 |
< |
int fitfncNbParams = 1; |
682 |
< |
|
683 |
< |
ofstream fout; |
684 |
< |
|
685 |
< |
if (applyjes==0) { |
686 |
< |
//fitfncAsString = "[0]+[1]*log(x)+[2]*log(x)*log(x)+[3]*x+[4]*x*x"; |
687 |
< |
//fitfncNbParams = 5; |
688 |
< |
fitfncAsString = "[0]*(pow(log(x),[1])-1/x)"; |
689 |
< |
fitfncNbParams = 2; |
690 |
< |
} |
691 |
< |
if (fitcorr) { |
692 |
< |
fout.open((jetalg+".txt").c_str()); assert(fout.is_open()); |
693 |
< |
fout<<"#\n# jet correction parameters for "<<jetalg<<" algorithm\n#\n\n" |
694 |
< |
<<"# number of eta bins\n"<<nbins |
695 |
< |
<<"\n\n# fit function\n"<<fitfncAsString<<"\n"<<fitfncNbParams |
696 |
< |
<<endl<<endl; |
697 |
< |
} |
698 |
< |
|
699 |
< |
string cname = "RspVs"+varname1+varname2+"_"+jetalg; |
700 |
< |
TCanvas* c = new TCanvas(cname.c_str(),cname.c_str()); |
701 |
< |
TLegend* l = new TLegend(0.7,0.25+nbins*0.045,0.85,0.25); |
702 |
< |
|
703 |
< |
l->SetFillColor(10); |
704 |
< |
Color_t color=kBlack; |
705 |
< |
TMultiGraph* mg = new TMultiGraph(); |
706 |
< |
|
707 |
< |
for (int ibin=0;ibin<nbins;ibin++) { |
708 |
< |
|
709 |
< |
TGraphErrors* g = gRsp[ibin]; |
710 |
< |
l->AddEntry(g,hist::get_bin_title(vartitle1,ibin,bins1).c_str(),"l"); |
711 |
< |
while (color==kYellow||color==kWhite||color==10) color++; |
712 |
< |
g->SetMarkerColor(color); |
713 |
< |
g->SetLineColor(color); |
714 |
< |
g->SetMarkerStyle(kFullCircle); |
715 |
< |
g->SetMarkerSize(0.5); |
716 |
< |
mg->Add(g,"P"); |
717 |
< |
|
718 |
< |
if (varname2=="Pt") { |
719 |
< |
string fname = "fitfnc"+cname; |
720 |
< |
TF1* fitfnc = new TF1(fname.c_str(),fitfncAsString.c_str(),1,get_xmax(g)); |
721 |
< |
|
722 |
< |
if (applyjes==0) { |
723 |
< |
fitfnc->SetParameter(0,0.4); |
724 |
< |
fitfnc->SetParameter(1,0.4); |
725 |
< |
} |
726 |
< |
else { |
727 |
< |
fitfnc->SetParameter(0,1.0); |
728 |
< |
} |
729 |
< |
|
730 |
< |
fitfnc->SetLineWidth(1); |
731 |
< |
fitfnc->SetLineColor(color); |
732 |
< |
g->Fit(fitfnc,"QR"); |
733 |
< |
|
734 |
< |
if (fitcorr==0) { |
735 |
< |
if (ibin==nbins-1) |
736 |
< |
fout<<"# eta > "<<bins1.back()<<"\n999.9"<<endl; |
737 |
< |
else |
738 |
< |
fout<<"# eta < "<<bins1[ibin]<<"\n"<<bins1[ibin]<<endl; |
739 |
< |
for (int ipar=0;ipar<fitfnc->GetNpar();ipar++) |
740 |
< |
fout<<setw(12)<<fitfnc->GetParameter(ipar)<<" " |
741 |
< |
<<setw(12)<<fitfnc->GetParError(ipar)<<endl; |
742 |
< |
fout<<endl; |
743 |
< |
} |
744 |
< |
|
745 |
< |
} |
746 |
< |
|
747 |
< |
g->Write(); |
748 |
< |
|
749 |
< |
color++; |
750 |
< |
} |
751 |
< |
|
752 |
< |
if (fout.is_open()) fout.close(); |
753 |
< |
|
754 |
< |
string mgtitle = jetalg+": Jet Response vs "+varname1+" and "+varname2; |
755 |
< |
mg->Draw("a"); |
756 |
< |
mg->SetTitle(mgtitle.c_str()); |
757 |
< |
mg->GetXaxis()->SetTitle(xtitle.c_str()); |
758 |
< |
mg->GetYaxis()->SetTitle("E_{T}^{rec}/E_{T}^{gen}"); |
759 |
< |
if (varname2=="Pt") mg->GetXaxis()->SetLimits(0.0,mg->GetXaxis()->GetXmax()); |
760 |
< |
mg->SetMinimum(0.0); |
761 |
< |
mg->SetMaximum(1.1); |
762 |
< |
l->Draw(); |
763 |
< |
|
764 |
< |
c->Write(); |
765 |
< |
|
766 |
< |
return c; |
654 |
> |
for (int i1=0;i1<n1;i1++) fitHistos(histos[i1],n2,nsigma); |
655 |
|
} |
656 |
|
|
657 |
|
|
658 |
|
//______________________________________________________________________________ |
659 |
< |
TCanvas* plotResolution(const vector<string>& jetalgs, |
772 |
< |
const vector<TGraphErrors*> gSgm, |
773 |
< |
const string& varname,const string& xtitle) |
659 |
> |
void fitHistos(TH1F**** histos,int n1,int n2,int n3,double nsigma) |
660 |
|
{ |
661 |
< |
string cname = "SgmVs"+varname; |
776 |
< |
TCanvas* c = new TCanvas(cname.c_str(),cname.c_str()); |
777 |
< |
TLegend* l = new TLegend(0.7,0.85-jetalgs.size()*0.045,0.85,0.85); |
778 |
< |
|
779 |
< |
l->SetFillColor(10); |
780 |
< |
Color_t color=kBlack; |
781 |
< |
TMultiGraph* mg = new TMultiGraph(); |
782 |
< |
|
783 |
< |
for (unsigned int i=0;i<gSgm.size();i++) { |
784 |
< |
TGraphErrors* g = gSgm[i]; |
785 |
< |
l->AddEntry(g,jetalgs[i].c_str(),"l"); |
786 |
< |
while (color==kYellow||color==kWhite||color==10) color++; |
787 |
< |
g->SetMarkerColor(color); |
788 |
< |
g->SetLineColor(color); |
789 |
< |
g->SetMarkerStyle(kFullCircle); |
790 |
< |
g->SetMarkerSize(0.5); |
791 |
< |
mg->Add(g,"P"); |
792 |
< |
|
793 |
< |
if (varname=="Pt") { |
794 |
< |
string fname = "fitfnc"+cname; |
795 |
< |
TF1* fitfnc = new TF1(fname.c_str(),"sqrt([0]*[0]/x*x+[1]*[1]/x+[2]*[2])"); |
796 |
< |
fitfnc->SetParameter(0,0.0); |
797 |
< |
fitfnc->SetParameter(1,0.5); |
798 |
< |
fitfnc->SetParameter(2,0.1); |
799 |
< |
fitfnc->SetLineWidth(1); |
800 |
< |
fitfnc->SetLineColor(color); |
801 |
< |
fitfnc->SetRange(2.0,get_xmax(g)); |
802 |
< |
g->Fit(fitfnc,"QR"); |
803 |
< |
} |
804 |
< |
|
805 |
< |
g->Write(); |
806 |
< |
|
807 |
< |
color++; |
808 |
< |
} |
809 |
< |
|
810 |
< |
string mgtitle = "Jet Resolution Vs "+varname; |
811 |
< |
mg->Draw("a"); |
812 |
< |
mg->SetTitle(mgtitle.c_str()); |
813 |
< |
mg->GetXaxis()->SetTitle(xtitle.c_str()); |
814 |
< |
mg->GetYaxis() |
815 |
< |
->SetTitle("#sigma(E_{T}^{rec}/E_{T}^{gen})/<E_{T}^{rec}/E_{T}^{gen}>"); |
816 |
< |
if (varname=="Pt") mg->GetXaxis()->SetLimits(0.0,mg->GetXaxis()->GetXmax()); |
817 |
< |
mg->SetMinimum(0.0); |
818 |
< |
mg->SetMaximum(0.5); |
819 |
< |
l->Draw(); |
820 |
< |
|
821 |
< |
c->Write(); |
822 |
< |
|
823 |
< |
return c; |
661 |
> |
for (int i1=0;i1<n1;i1++) fitHistos(histos[i1],n2,n3,nsigma); |
662 |
|
} |
663 |
|
|
664 |
|
|
665 |
|
//______________________________________________________________________________ |
666 |
< |
TCanvas* plotResolution(const string& jetalg,const vector<float>& bins1, |
829 |
< |
TGraphErrors** gSgm, |
830 |
< |
const string& varname1,const string vartitle1, |
831 |
< |
const string& varname2,const string& xtitle) |
666 |
> |
void saveHistos(TH1F** histos,int n) |
667 |
|
{ |
668 |
< |
int nbins = bins1.size()+1; |
669 |
< |
|
835 |
< |
string cname = "SgmVs"+varname1+varname2+"_"+jetalg; |
836 |
< |
TCanvas* c = new TCanvas(cname.c_str(),cname.c_str()); |
837 |
< |
TLegend* l = new TLegend(0.7,0.85-nbins*0.045,0.85,0.85); |
838 |
< |
|
839 |
< |
l->SetFillColor(10); |
840 |
< |
Color_t color=kBlack; |
841 |
< |
TMultiGraph* mg = new TMultiGraph(); |
668 |
> |
for (int i=0;i<n;i++) histos[i]->Write(); |
669 |
> |
} |
670 |
|
|
671 |
< |
for (int ibin=0;ibin<nbins;ibin++) { |
672 |
< |
TGraphErrors* g = gSgm[ibin]; |
673 |
< |
l->AddEntry(g,hist::get_bin_title(vartitle1,ibin,bins1).c_str(),"l"); |
674 |
< |
while (color==kYellow||color==kWhite||color==10) color++; |
675 |
< |
g->SetMarkerColor(color); |
848 |
< |
g->SetLineColor(color); |
849 |
< |
g->SetMarkerStyle(kFullCircle); |
850 |
< |
g->SetMarkerSize(0.5); |
851 |
< |
mg->Add(g,"P"); |
852 |
< |
|
853 |
< |
if (varname2=="Pt") { |
854 |
< |
string fname = "fitfnc"+cname; |
855 |
< |
TF1* fitfnc = new TF1(fname.c_str(),"sqrt([0]*[0]/x*x+[1]*[1]/x+[2]*[2])"); |
856 |
< |
fitfnc->SetParameter(0,0.0); |
857 |
< |
fitfnc->SetParameter(1,0.5); |
858 |
< |
fitfnc->SetParameter(2,0.1); |
859 |
< |
fitfnc->SetLineWidth(1); |
860 |
< |
fitfnc->SetLineColor(color); |
861 |
< |
fitfnc->SetRange(2.0,get_xmax(g)); |
862 |
< |
g->Fit(fitfnc,"QR"); |
863 |
< |
} |
864 |
< |
|
865 |
< |
g->Write(); |
866 |
< |
|
867 |
< |
color++; |
868 |
< |
} |
869 |
< |
|
870 |
< |
string mgtitle=jetalg+": Jet Resolution Vs "+varname1+" and "+varname2; |
871 |
< |
mg->Draw("a"); |
872 |
< |
mg->SetTitle(mgtitle.c_str()); |
873 |
< |
mg->GetXaxis()->SetTitle(xtitle.c_str()); |
874 |
< |
mg->GetYaxis() |
875 |
< |
->SetTitle("#sigma(E_{T}^{rec}/E_{T}^{gen})/<E_{T}^{rec}/E_{T}^{gen}>"); |
876 |
< |
if (varname2=="Pt") mg->GetXaxis()->SetLimits(0.0,mg->GetXaxis()->GetXmax()); |
877 |
< |
mg->SetMinimum(0.0); |
878 |
< |
mg->SetMaximum(0.5); |
879 |
< |
l->Draw(); |
880 |
< |
|
881 |
< |
c->Write(); |
882 |
< |
|
883 |
< |
return c; |
671 |
> |
|
672 |
> |
//______________________________________________________________________________ |
673 |
> |
void saveHistos(TH1F*** histos,int n1,int n2) |
674 |
> |
{ |
675 |
> |
for (int i1=0;i1<n1;i1++) saveHistos(histos[i1],n2); |
676 |
|
} |
677 |
|
|
678 |
|
|
679 |
|
//______________________________________________________________________________ |
680 |
< |
float get_xmax(TGraph* g) |
680 |
> |
void saveHistos(TH1F**** histos,int n1,int n2,int n3) |
681 |
|
{ |
682 |
< |
float result(-1e200); |
891 |
< |
for (int i=0;i<g->GetN();++i) if (g->GetX()[i]>result) result=g->GetX()[i]; |
892 |
< |
return result; |
682 |
> |
for (int i1=0;i1<n1;i1++) saveHistos(histos[i1],n2,n3); |
683 |
|
} |