ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/NonMCBackground/src/plotZPlusFake.cc
Revision: 1.5
Committed: Thu Jul 19 11:15:32 2012 UTC (12 years, 10 months ago) by dkralph
Content type: text/plain
Branch: MAIN
CVS Tags: compiled, HEAD
Changes since 1.4: +3 -4 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 dkralph 1.1 #include <iostream>
2     #include <algorithm>
3     #include <iomanip>
4     // #include <pair.h>
5    
6     #include "RooHistPdf.h"
7     #include "RooGlobalFunc.h"
8     #include "RooPlot.h"
9     #include "RooRealVar.h"
10     #include "RooDataHist.h"
11     #include "RooGenericPdf.h"
12     #include "RooDataSet.h"
13     #include "RooAddPdf.h"
14     #include "RooFormulaVar.h"
15     #include "RooFitResult.h"
16     #include "RooCurve.h"
17     #include "RooBinning.h"
18     #include "RooExponential.h"
19     #include "RooExtendPdf.h"
20    
21 dkralph 1.2 #include "RunLumiSet.h"
22    
23 dkralph 1.1 #include "TCanvas.h"
24     #include "TChain.h"
25     #include "TString.h"
26     #include "TStyle.h"
27     #include "TH1D.h"
28    
29     #include "CPlot.h"
30     #include "FOArgs.h"
31    
32     #include "fake_defs.h"
33     #include "Various.h"
34     #include "CommonDefs.h"
35 dkralph 1.2 #include "PlotHeaders.h"
36 dkralph 1.1
37     #ifndef CMSSW_BASE
38     #define CMSSW_BASE "../../"
39     #endif
40    
41     using namespace std;
42     using namespace RooFit;
43 dkralph 1.4 using namespace mithep;
44 dkralph 1.1
45     TCanvas *can;
46    
47     void fillHist(CSample *cs, TString channel, TString type, TString var, double val, double wgt, double wgt_lo=0, double wgt_hi=0);
48 dkralph 1.2 void makeHTML(FOFlags &ctrl, TString type, TString plotLabel);
49 dkralph 1.1 map<TString,map<TString,TH1D*>* > init_hists(FOFlags &ctrl, TString str="");
50    
51     //----------------------------------------------------------------------------------------
52     int main(int argc, char** argv)
53     {
54    
55     FOFlags ctrl;
56     parse_foargs( argc, argv, ctrl );
57     ctrl.dump();
58    
59     can = new TCanvas("can","can");
60    
61 dkralph 1.2 FR_struct fr2011 = initFRs(ctrl.mufakefile2011,ctrl.elefakefile2011);
62     FR_struct fr2012 = initFRs(ctrl.mufakefile2012,ctrl.elefakefile2012);
63 dkralph 1.1
64     TString cmsswpath(CMSSW_BASE + TString("/src"));
65     string xspath = (string(cmsswpath)+"/MitPhysics/data/xs.dat");
66     SimpleTable xstab(xspath.c_str());
67    
68     vector<CSample*> samplev;
69 dkralph 1.4 TString ntupledir(""),label(""),plotLabel(""),jsonFile("");
70 dkralph 1.5 int puTarget;
71     readConfigFile(ctrl.config, ntupledir, label, plotLabel, jsonFile, puTarget, samplev, &ctrl, init_hists);
72 dkralph 1.1
73 dkralph 1.2 RunLumiSet rls;
74     UInt_t minRun=999999999,maxRun=0;
75 dkralph 1.1 for(unsigned ics=0; ics<samplev.size(); ics++) {
76     CSample *cs = samplev[ics];
77     cout << cs->name << endl;
78     for(unsigned ifs=0; ifs<(cs->fsv).size(); ifs++) {
79     filestuff *fs = (cs->fsv)[ifs];
80     cout << "\t" << fs->fname_ << endl;
81 dkralph 1.2 FR_struct *fr = (fs->era_==2011) ? &fr2011 : &fr2012;
82     unsigned nDuplSkipped=0;
83 dkralph 1.1 for(unsigned ientry=0; ientry<fs->getentries("FOtree"); ientry++) {
84     fs->getentry(ientry,"","FOtree");
85     fs->getentry(ientry,"info","zznt");
86 dkralph 1.2
87     if(fs->isdata_) {
88     setMinMaxRun(fs->info->run, minRun, maxRun);
89     bool dupl = takeCareOfDuplicateEvents(fs->info->run, fs->info->evt, rls, nDuplSkipped);
90     if(dupl) continue;
91 dkralph 1.4 pair<unsigned,unsigned> rl(fs->info->run, fs->info->lumi);
92     if(!fs->rlrm_.HasRunLumi(rl)) continue;
93 dkralph 1.1 }
94    
95     double wgt=1;
96 dkralph 1.2 if(!fs->isdata_) {
97 dkralph 1.5 double xsWgt = fs->lumi_*xstab.Get(fs->dataset_)/fs->total_entries_;
98 dkralph 1.2 // double puWgt = weightTrue2012(fs->info->npu);
99     wgt = xsWgt;//*puWgt;
100     // cout << "npu: " << fs->info->npu
101     }
102    
103     if(fs->info->met > 25) continue;
104 dkralph 1.1
105     unsigned npass = fs->passingL->size();
106     unsigned nfail = fs->failingL->size();
107    
108     float best_z_mass = -99999;
109     pair<int,int> best_z_indices;
110     for(unsigned ilep1=0; ilep1<npass; ilep1++) {
111     SimpleLepton lep1 = (*fs->passingL)[ilep1];
112     for(unsigned ilep2=ilep1+1; ilep2<npass; ilep2++) {
113     SimpleLepton lep2 = (*fs->passingL)[ilep2];
114     if(abs(lep1.type) != abs(lep2.type)) continue;
115     if(lep1.charge == lep2.charge) continue;
116    
117     if(lep1.vec.Pt() < 20 && lep2.vec.Pt() < 20) continue;
118     if(lep1.vec.Pt() < 10 || lep2.vec.Pt() < 10) continue;
119    
120     float tmpM = ((lep1.vec)+(lep2.vec)).M();
121     if( fabs(tmpM-Z_MASS) < fabs(best_z_mass-Z_MASS) ) {
122     best_z_mass = tmpM;
123     best_z_indices = pair<int,int> (ilep1,ilep2);
124     }
125     }
126     }
127     assert( best_z_mass != 0 );
128     if( best_z_mass < 80 || best_z_mass > 100 ) continue;
129     EventData evtdata;
130     evtdata.Z1leptons.push_back((*fs->passingL)[best_z_indices.first]);
131     evtdata.Z1leptons.push_back((*fs->passingL)[best_z_indices.second]);
132    
133     //
134     // Look extra leptons
135     //
136     vector<SimpleLepton> ex_leps;
137     vector<TString> types;
138     for(unsigned ipass=0; ipass<npass; ipass++) {
139     SimpleLepton ex_lep = (*fs->passingL)[ipass];
140     if(ipass == best_z_indices.first) continue;
141     if(ipass == best_z_indices.second) continue;
142     ex_leps.push_back(ex_lep);
143     types.push_back("pass");
144     }
145     for(unsigned ifail=0; ifail<nfail; ifail++) {
146     SimpleLepton ex_lep = (*fs->failingL)[ifail];
147     ex_leps.push_back(ex_lep);
148     types.push_back("fail");
149     }
150    
151 dkralph 1.2 if(npass>3) continue;
152    
153 dkralph 1.1 for(unsigned iextra=0; iextra<ex_leps.size(); iextra++) {
154     SimpleLepton ex_lep = ex_leps[iextra];
155    
156 dkralph 1.2 if(types[iextra]=="fail" && npass>2) continue;
157 dkralph 1.3 SimpleLepton lep1=evtdata.Z1leptons[0],lep2=evtdata.Z1leptons[1];
158     if( dr(lep1,ex_lep) < 0.3) continue;
159     if( dr(lep2,ex_lep) < 0.3) continue;
160 dkralph 1.2
161    
162 dkralph 1.1 TString channel;
163     if(abs(ex_lep.type) == 13) channel = "mu";
164     if(abs(ex_lep.type) == 11) channel = "ele";
165    
166     // if( !(fabs(lep1.ip3dSig) > 3. &&
167     // fabs(lep2.ip3dSig) > 5.) &&
168     // !(fabs(lep2.ip3dSig) > 3. &&
169     // fabs(lep1.ip3dSig) > 5.) ) continue;
170    
171     evtdata.Z2leptons.clear();
172     //????????????????????????????????????????????????????????????????????????????????????????
173     // hack:
174     evtdata.Z2leptons.push_back((*fs->passingL)[best_z_indices.first]);
175     evtdata.Z2leptons.push_back((*fs->passingL)[best_z_indices.second]);
176     //????????????????????????????????????????????????????????????????????????????????????????
177     KinematicsStruct kine;
178     fillKinematics(evtdata,kine);
179 dkralph 1.2 TLorentzVector l1l3(lep1.vec+ex_lep.vec);
180     TLorentzVector l2l3(lep2.vec+ex_lep.vec);
181 dkralph 1.1
182     if(types[iextra]=="pass") {
183     fillHist( cs, channel, "obs", "run", fs->info->run , wgt);
184     fillHist( cs, channel, "obs", "mZ1", kine.mZ1 , wgt);
185     fillHist( cs, channel, "obs", "Z1pt", kine.Z1pt , wgt);
186 dkralph 1.2 fillHist( cs, channel, "obs", "ip3ds_l1", lep1.ip3dSig , wgt);
187     fillHist( cs, channel, "obs", "ip3ds_l2", lep2.ip3dSig , wgt);
188     fillHist( cs, channel, "obs", "ip3ds_l3", ex_lep.ip3dSig , wgt);
189     fillHist( cs, channel, "obs", "pt_l1", lep1.vec.Pt() , wgt);
190     fillHist( cs, channel, "obs", "pt_l2", lep2.vec.Pt() , wgt);
191 dkralph 1.1 fillHist( cs, channel, "obs", "pt_l3", ex_lep.vec.Pt() , wgt);
192 dkralph 1.2 fillHist( cs, channel, "obs", "pt_l3_lo", ex_lep.vec.Pt() , wgt);
193     fillHist( cs, channel, "obs", "eta_l1", lep1.vec.Eta(), wgt);
194     fillHist( cs, channel, "obs", "eta_l2", lep2.vec.Eta(), wgt);
195     fillHist( cs, channel, "obs", "eta_l3", ex_lep.vec.Eta(), wgt);
196     fillHist( cs, channel, "obs", "dR_l1l3_lo",dr(lep1,ex_lep), wgt);
197     fillHist( cs, channel, "obs", "dR_l1l3", dr(lep1,ex_lep), wgt);
198     fillHist( cs, channel, "obs", "dR_l2l3_lo",dr(lep2,ex_lep), wgt);
199     fillHist( cs, channel, "obs", "dR_l2l3", dr(lep2,ex_lep), wgt);
200     fillHist( cs, channel, "obs", "ml1l3", l1l3.M(), wgt);
201     fillHist( cs, channel, "obs", "ml2l3", l2l3.M(), wgt);
202     fillHist( cs, channel, "obs", "met", fs->info->met, wgt);
203 dkralph 1.1 } else if(types[iextra]=="fail") {
204 dkralph 1.2 double fwgt = get_fake_weight("",ex_lep,*fr);
205     double fwgt_lo = get_fake_weight("lo",ex_lep,*fr);
206     double fwgt_hi = get_fake_weight("hi",ex_lep,*fr);
207 dkralph 1.1 double centr = wgt*fwgt;
208     double lo = wgt*fwgt_lo;
209     double hi = wgt*fwgt_hi;
210 dkralph 1.2
211     fillHist( cs, channel, "pred", "run", fs->info->run, centr, lo, hi);
212     fillHist( cs, channel, "pred", "mZ1", kine.mZ1, centr, lo, hi);
213     fillHist( cs, channel, "pred", "Z1pt", kine.Z1pt, centr, lo, hi);
214     fillHist( cs, channel, "pred", "ip3ds_l1", lep1.ip3dSig, centr, lo, hi);
215     fillHist( cs, channel, "pred", "ip3ds_l2", lep2.ip3dSig, centr, lo, hi);
216     fillHist( cs, channel, "pred", "ip3ds_l3", ex_lep.ip3dSig, centr, lo, hi);
217     fillHist( cs, channel, "pred", "pt_l1", lep1.vec.Pt(), centr, lo, hi);
218     fillHist( cs, channel, "pred", "pt_l2", lep2.vec.Pt(), centr, lo, hi);
219     fillHist( cs, channel, "pred", "pt_l3", ex_lep.vec.Pt(), centr, lo, hi);
220     fillHist( cs, channel, "pred", "pt_l3_lo", ex_lep.vec.Pt(), centr, lo, hi);
221     fillHist( cs, channel, "pred", "eta_l1", lep1.vec.Eta(), centr, lo, hi);
222     fillHist( cs, channel, "pred", "eta_l2", lep2.vec.Eta(), centr, lo, hi);
223     fillHist( cs, channel, "pred", "eta_l3", ex_lep.vec.Eta(), centr, lo, hi);
224     fillHist( cs, channel, "pred", "dR_l1l3_lo",dr(lep1,ex_lep), centr, lo, hi);
225     fillHist( cs, channel, "pred", "dR_l1l3", dr(lep1,ex_lep), centr, lo, hi);
226     fillHist( cs, channel, "pred", "dR_l2l3_lo",dr(lep2,ex_lep), centr, lo, hi);
227     fillHist( cs, channel, "pred", "dR_l2l3", dr(lep2,ex_lep), centr, lo, hi);
228     fillHist( cs, channel, "pred", "ml1l3", l1l3.M(), centr, lo, hi);
229     fillHist( cs, channel, "pred", "ml2l3", l2l3.M(), centr, lo, hi);
230     fillHist( cs, channel, "pred", "met", fs->info->met, centr, lo, hi);
231 dkralph 1.1 } else assert(0);
232     }
233     }
234 dkralph 1.2 cout << "\t\tWARNING: skipped " << nDuplSkipped << " duplicate events" << endl;
235 dkralph 1.1 }
236     }
237 dkralph 1.2 cout << "run range: " << setw(12) << minRun << setw(12) << maxRun << endl;
238 dkralph 1.1
239     assert(samplev.size()>0);
240     vector<TString> typev;
241     typev.push_back("both");
242     typev.push_back("mu");
243     typev.push_back("ele");
244     for(unsigned itype=0; itype<typev.size(); itype++) {
245     TString type(typev[itype]);
246 dkralph 1.2 gSystem->mkdir(ctrl.outdir+"/"+plotLabel+"/"+type,true);
247     TFile runHistFile(ctrl.outdir+"/"+plotLabel+"/"+type+"/runs.root","recreate");
248 dkralph 1.1 map<TString,TH1D*>::iterator it_v;
249     for(it_v=(*(samplev[0]->hists)[type+"_obs"]).begin(); it_v!=(*(samplev[0]->hists)[type+"_obs"]).end(); it_v++) {
250     TString var((*it_v).first);
251 dkralph 1.2 CPlot cplot(var,"",(*(samplev[0]->hists)[type+"_obs"])[var]->GetXaxis()->GetTitle(),"events",ctrl.outdir+"/"+plotLabel+"/"+type+"/plots");
252     double ymax=0;
253 dkralph 1.1 for(unsigned isam=0; isam<samplev.size(); isam++) {
254     CSample *cs = samplev[isam];
255     TH1D *hObs = (*(cs->hists)[type+"_obs"])[var];
256     TH1D *hPred = (*(cs->hists)[type+"_pred"])[var];
257     TH1D *hPred_lo = (*(cs->hists)[type+"_pred_lo"])[var];
258     TH1D *hPred_hi = (*(cs->hists)[type+"_pred_hi"])[var];
259     if(cs->isdata) {
260 dkralph 1.2 cplot.AddHist1D(hObs,cs->legend+": "+integral_str(hObs),"E");
261 dkralph 1.1 double ratio = integrateHist(hObs) / integrateHist(hPred);
262     cplot.AddHist1D(hPred,"FR predic: "+integral_str(hPred),"hist",kRed);
263     cplot.AddHist1D(hPred_lo,"stat lo: "+integral_str(hPred_lo),"hist",kRed,kDashed);
264     cplot.AddHist1D(hPred_hi,"stat hi: "+integral_str(hPred_hi),"hist",kRed,kDashed);
265 dkralph 1.2 ymax = max(ymax,histMax(hObs,hPred));
266 dkralph 1.1 } else {
267 dkralph 1.2 cplot.AddToStack(hObs,cs->legend+": "+integral_str(hObs),kCyan-6);
268     ymax = max(ymax,histMax(hObs,hPred));
269 dkralph 1.1 }
270     if(cs->isdata && var=="run") {
271     assert(hObs->GetBinContent(0)==0 && hObs->GetBinContent(hObs->GetXaxis()->GetNbins()+1)==0);
272     hObs->Write("runs");
273     }
274     if(var.Contains("ip3d")) {
275     double maxVal = max(hObs->GetMaximum(), hPred->GetMaximum());
276     double isoMin = 0.00005*maxVal;
277     double isoMax = 1.8*maxVal;
278     cplot.SetYRange(isoMin,isoMax);
279 dkralph 1.2 cplot.SetLogy();
280     } else {
281     cplot.SetYRange(0,1.2*ymax);
282 dkralph 1.1 }
283 dkralph 1.2
284 dkralph 1.1 }
285     cplot.Draw(can,true,"png");
286     }
287     runHistFile.Close();
288 dkralph 1.2 makeHTML(ctrl,type, plotLabel);
289 dkralph 1.1 }
290     }
291     //----------------------------------------------------------------------------------------
292     map<TString,map<TString,TH1D*>* > init_hists(FOFlags &ctrl, TString str)
293     {
294     map<TString,map<TString,TH1D*>* > hists;
295    
296     map<TString,TH1D*> *h_mu_obs = new map<TString,TH1D*>; hists["mu_obs"] = h_mu_obs;
297     map<TString,TH1D*> *h_mu_pred = new map<TString,TH1D*>; hists["mu_pred"] = h_mu_pred;
298     map<TString,TH1D*> *h_mu_pred_lo = new map<TString,TH1D*>; hists["mu_pred_lo"] = h_mu_pred_lo;
299     map<TString,TH1D*> *h_mu_pred_hi = new map<TString,TH1D*>; hists["mu_pred_hi"] = h_mu_pred_hi;
300    
301     map<TString,TH1D*> *h_ele_obs = new map<TString,TH1D*>; hists["ele_obs"] = h_ele_obs;
302     map<TString,TH1D*> *h_ele_pred = new map<TString,TH1D*>; hists["ele_pred"] = h_ele_pred;
303     map<TString,TH1D*> *h_ele_pred_lo = new map<TString,TH1D*>; hists["ele_pred_lo"] = h_ele_pred_lo;
304     map<TString,TH1D*> *h_ele_pred_hi = new map<TString,TH1D*>; hists["ele_pred_hi"] = h_ele_pred_hi;
305    
306     map<TString,TH1D*> *h_both_obs = new map<TString,TH1D*>; hists["both_obs"] = h_both_obs;
307     map<TString,TH1D*> *h_both_pred = new map<TString,TH1D*>; hists["both_pred"] = h_both_pred;
308     map<TString,TH1D*> *h_both_pred_lo = new map<TString,TH1D*>; hists["both_pred_lo"] = h_both_pred_lo;
309     map<TString,TH1D*> *h_both_pred_hi = new map<TString,TH1D*>; hists["both_pred_hi"] = h_both_pred_hi;
310    
311     map<TString,map<TString,TH1D*>* >::iterator it_h;
312     for(it_h=hists.begin(); it_h!=hists.end(); it_h++) {
313     (*((*it_h).second))["run"] = new TH1D(TString("run") +"_"+(*it_h).first+str,";#bf{run};", 50,160800,196535); (*((*it_h).second))["run"]->Sumw2();
314 dkralph 1.2 (*((*it_h).second))["mZ1"] = new TH1D(TString("mZ1") +"_"+(*it_h).first+str,";#bf{mZ1 [GeV]};", 37,70,110); (*((*it_h).second))["mZ1"]->Sumw2();
315     (*((*it_h).second))["Z1pt"] = new TH1D(TString("Z1pt") +"_"+(*it_h).first+str,";#bf{Z1pt [GeV]};", 37,0,100); (*((*it_h).second))["Z1pt"]->Sumw2();
316 dkralph 1.1
317     (*((*it_h).second))["pt_l1"] = new TH1D(TString("pt_l1") +"_"+(*it_h).first+str,";#bf{l1 p_{T} [GeV]};", 37,0,120); (*((*it_h).second))["pt_l1"]->Sumw2();
318 dkralph 1.2 (*((*it_h).second))["pt_l2"] = new TH1D(TString("pt_l2") +"_"+(*it_h).first+str,";#bf{l2 p_{T} [GeV]};", 37,0,65); (*((*it_h).second))["pt_l2"]->Sumw2();
319     (*((*it_h).second))["pt_l3_lo"] = new TH1D(TString("pt_l3_lo") +"_"+(*it_h).first+str,";#bf{l3_lo p_{T} [GeV]};",37,3,15); (*((*it_h).second))["pt_l3_lo"]->Sumw2();
320     (*((*it_h).second))["pt_l3"] = new TH1D(TString("pt_l3") +"_"+(*it_h).first+str,";#bf{l3 p_{T} [GeV]};", 37,10,40); (*((*it_h).second))["pt_l3"]->Sumw2();
321 dkralph 1.1
322     (*((*it_h).second))["eta_l1"] = new TH1D(TString("eta_l1")+"_"+(*it_h).first+str,";#bf{l1 #eta};", 25,-2.5,2.5); (*((*it_h).second))["eta_l1"]->Sumw2();
323     (*((*it_h).second))["eta_l2"] = new TH1D(TString("eta_l2")+"_"+(*it_h).first+str,";#bf{l2 #eta};", 25,-2.5,2.5); (*((*it_h).second))["eta_l2"]->Sumw2();
324     (*((*it_h).second))["eta_l3"] = new TH1D(TString("eta_l3")+"_"+(*it_h).first+str,";#bf{l3 #eta};", 25,-2.5,2.5); (*((*it_h).second))["eta_l3"]->Sumw2();
325    
326 dkralph 1.4 (*((*it_h).second))["ip3ds_l1"] = new TH1D(TString("ip3ds_l1") +"_"+(*it_h).first+str,";#bf{ip3ds l1};",30,-10,10); (*((*it_h).second))["ip3ds_l1"]->Sumw2();
327     (*((*it_h).second))["ip3ds_l2"] = new TH1D(TString("ip3ds_l2") +"_"+(*it_h).first+str,";#bf{ip3ds l2};",30,-10,10); (*((*it_h).second))["ip3ds_l2"]->Sumw2();
328     (*((*it_h).second))["ip3ds_l3"] = new TH1D(TString("ip3ds_l3") +"_"+(*it_h).first+str,";#bf{ip3ds l3};",30,-10,10); (*((*it_h).second))["ip3ds_l3"]->Sumw2();
329 dkralph 1.2
330     (*((*it_h).second))["dR_l1l3_lo"] = new TH1D(TString("dR_l1l3_lo") +"_"+(*it_h).first+str,";#bf{#Delta R l3,l4};",75,0,.2); (*((*it_h).second))["dR_l1l3_lo"]->Sumw2();
331     (*((*it_h).second))["dR_l1l3"] = new TH1D(TString("dR_l1l3") +"_"+(*it_h).first+str,";#bf{#Delta R l3,l4};",75,0,6); (*((*it_h).second))["dR_l1l3"]->Sumw2();
332     (*((*it_h).second))["dR_l2l3_lo"] = new TH1D(TString("dR_l2l3_lo") +"_"+(*it_h).first+str,";#bf{#Delta R l3,l4};",75,0,.2); (*((*it_h).second))["dR_l2l3_lo"]->Sumw2();
333     (*((*it_h).second))["dR_l2l3"] = new TH1D(TString("dR_l2l3") +"_"+(*it_h).first+str,";#bf{#Delta R l3,l4};",75,0,6); (*((*it_h).second))["dR_l2l3"]->Sumw2();
334    
335     (*((*it_h).second))["ml1l3"] = new TH1D(TString("ml1l3") +"_"+(*it_h).first+str,";#bf{m_{l1l3} [GeV]};",50,0,120); (*((*it_h).second))["ml1l3"]->Sumw2();
336     (*((*it_h).second))["ml2l3"] = new TH1D(TString("ml2l3") +"_"+(*it_h).first+str,";#bf{m_{l2l3} [GeV]};",50,0,120); (*((*it_h).second))["ml2l3"]->Sumw2();
337    
338     (*((*it_h).second))["met"] = new TH1D(TString("met") +"_"+(*it_h).first+str,";#bf{m_{l2l3} [GeV]};",50,0,50); (*((*it_h).second))["met"]->Sumw2();
339 dkralph 1.1 }
340    
341     return hists;
342     }
343     //--------------------------------------------------------------------------------------------------
344 dkralph 1.2 void makeHTML(FOFlags &ctrl, TString type, TString plotLabel)
345 dkralph 1.1 {
346     TString title("Z Plus Fake: "+type);
347     ofstream htmlfile;
348     char htmlfname[100];
349 dkralph 1.2 sprintf(htmlfname,"%s/plots.html",TString(ctrl.outdir+"/"+plotLabel+"/"+type).Data());
350 dkralph 1.1 htmlfile.open(htmlfname);
351    
352     htmlfile << "<!DOCTYPE html" << endl;
353     htmlfile << " PUBLIC \"-//W3C//DTD HTML 3.2//EN\">" << endl;
354     htmlfile << "<html>" << endl;
355    
356     htmlfile << "<head><title>"+title+"</title></head>" << endl;
357     htmlfile << "<body bgcolor=\"EEEEEE\">" << endl;
358     htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">"+title+"</h3>" << endl;
359    
360     htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
361     htmlfile << "<tr>" << endl;
362     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/mZ1.png\"><img src=\"plots/mZ1.png\" alt=\"plots/mZ1.png\" width=\"100%\"></a></td>" << endl;
363     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/Z1pt.png\"><img src=\"plots/Z1pt.png\" alt=\"plots/Z1pt.png\" width=\"100%\"></a></td>" << endl;
364     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/run.png\"><img src=\"plots/run.png\" alt=\"plots/run.png\" width=\"100%\"></a></td>" << endl;
365     htmlfile << "</tr>" << endl;
366    
367     htmlfile << "<tr>" << endl;
368     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ip3ds_l1.png\"><img src=\"plots/ip3ds_l1.png\" alt=\"plots/ip3ds_l1.png\" width=\"100%\"></a></td>" << endl;
369     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ip3ds_l2.png\"><img src=\"plots/ip3ds_l2.png\" alt=\"plots/ip3ds_l2.png\" width=\"100%\"></a></td>" << endl;
370     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ip3ds_l3.png\"><img src=\"plots/ip3ds_l3.png\" alt=\"plots/ip3ds_l3.png\" width=\"100%\"></a></td>" << endl;
371     htmlfile << "</tr>" << endl;
372    
373     htmlfile << "<tr>" << endl;
374     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt_l1.png\"><img src=\"plots/pt_l1.png\" alt=\"plots/pt_l1.png\" width=\"100%\"></a></td>" << endl;
375     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt_l2.png\"><img src=\"plots/pt_l2.png\" alt=\"plots/pt_l2.png\" width=\"100%\"></a></td>" << endl;
376 dkralph 1.2 htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt_l3_lo.png\"><img src=\"plots/pt_l3_lo.png\" alt=\"plots/pt_l3_lo.png\" width=\"100%\"></a></td>" << endl;
377 dkralph 1.1 htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt_l3.png\"><img src=\"plots/pt_l3.png\" alt=\"plots/pt_l3.png\" width=\"100%\"></a></td>" << endl;
378     htmlfile << "</tr>" << endl;
379    
380     htmlfile << "<tr>" << endl;
381     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/eta_l1.png\"><img src=\"plots/eta_l1.png\" alt=\"plots/eta_l1.png\" width=\"100%\"></a></td>" << endl;
382     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/eta_l2.png\"><img src=\"plots/eta_l2.png\" alt=\"plots/eta_l2.png\" width=\"100%\"></a></td>" << endl;
383     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/eta_l3.png\"><img src=\"plots/eta_l3.png\" alt=\"plots/eta_l3.png\" width=\"100%\"></a></td>" << endl;
384     htmlfile << "</tr>" << endl;
385 dkralph 1.2
386     htmlfile << "<tr>" << endl;
387     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l1l3_lo.png\"><img src=\"plots/dR_l1l3_lo.png\" alt=\"plots/dR_l1l3_lo.png\" width=\"100%\"></a></td>" << endl;
388     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l1l3.png\"><img src=\"plots/dR_l1l3.png\" alt=\"plots/dR_l1l3.png\" width=\"100%\"></a></td>" << endl;
389     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l2l3_lo.png\"><img src=\"plots/dR_l2l3_lo.png\" alt=\"plots/dR_l2l3_lo.png\" width=\"100%\"></a></td>" << endl;
390     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l2l3.png\"><img src=\"plots/dR_l2l3.png\" alt=\"plots/dR_l2l3.png\" width=\"100%\"></a></td>" << endl;
391     // htmlfile << "<td width=\"25%\"><a><</a></td>" << endl;
392     htmlfile << "</tr>" << endl;
393    
394     htmlfile << "<tr>" << endl;
395     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ml1l3.png\"><img src=\"plots/ml1l3.png\" alt=\"plots/ml1l3.png\" width=\"100%\"></a></td>" << endl;
396     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ml2l3.png\"><img src=\"plots/ml2l3.png\" alt=\"plots/ml2l3.png\" width=\"100%\"></a></td>" << endl;
397     htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/met.png\"><img src=\"plots/met.png\" alt=\"plots/met.png\" width=\"100%\"></a></td>" << endl;
398     htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
399     htmlfile << "</tr>" << endl;
400    
401 dkralph 1.1 htmlfile << "</table>" << endl;
402    
403     htmlfile << "<hr />" << endl;
404    
405     htmlfile << "<hr />" << endl;
406    
407     htmlfile << "</body>" << endl;
408     htmlfile << "</html>" << endl;
409     htmlfile.close();
410     }
411     //----------------------------------------------------------------------------------------
412     void fillHist(CSample *cs, TString channel, TString type, TString var, double val, double wgt, double wgt_lo, double wgt_hi)
413     {
414     (*(cs->hists)["both_"+type])[var]->Fill( val, wgt);
415     (*(cs->hists)[channel+"_"+type])[var]->Fill( val, wgt);
416     if(type=="pred") {
417     (*(cs->hists)["both_"+type+"_lo"])[var]->Fill( val, wgt_lo);
418     (*(cs->hists)["both_"+type+"_hi"])[var]->Fill( val, wgt_hi);
419     (*(cs->hists)[channel+"_"+type+"_lo"])[var]->Fill( val, wgt_lo);
420     (*(cs->hists)[channel+"_"+type+"_hi"])[var]->Fill( val, wgt_hi);
421     }
422     }