ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/NonMCBackground/src/plotSignalFakes.cc
Revision: 1.7
Committed: Mon Dec 17 17:25:55 2012 UTC (12 years, 5 months ago) by dkralph
Content type: text/plain
Branch: MAIN
CVS Tags: compiled
Changes since 1.6: +528 -648 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 "TCanvas.h"
7     #include "TChain.h"
8 dkralph 1.7 #include "TStopwatch.h"
9 dkralph 1.1 #include "TString.h"
10     #include "TStyle.h"
11     #include "TH1D.h"
12 dkralph 1.3 #include "TNtuple.h"
13 dkralph 1.5 #include "TROOT.h"
14 dkralph 1.1
15     #include "CPlot.h"
16     #include "FOArgs.h"
17    
18     #include "fake_defs.h"
19     #include "Various.h"
20     #include "CommonDefs.h"
21     #include "PlotHeaders.h"
22 dkralph 1.7 #include "HistHeaders.h"
23 dkralph 1.3 #include "TriggerUtils.h"
24     #include "JetDefs.h"
25     #include "JetInfoStruct.h"
26 dkralph 1.5 #include "FR_struct.h"
27     #include "SelectionFuncs.h"
28     #include "SampleWeight.h"
29 dkralph 1.6 #include "MitStyleRemix.h"
30 dkralph 1.3
31     #include "TMVA/Reader.h"
32     #include "TMVA/Tools.h"
33     #include "TMVA/Config.h"
34     #include "TMVA/MethodBDT.h"
35 dkralph 1.1
36     #ifndef CMSSW_BASE
37     #define CMSSW_BASE "../../"
38     #endif
39    
40     using namespace std;
41     using namespace RooFit;
42     using namespace mithep;
43    
44 dkralph 1.4 //----------------------------------------------------------------------------------------
45 dkralph 1.1 TCanvas *can;
46 dkralph 1.3
47     bool findGoodJets(vector<SimpleLepton> &goodJets, filestuff *fs,
48     SimpleLepton lep1, SimpleLepton lep2, SimpleLepton lep3, SimpleLepton lep4);
49 dkralph 1.7 // void fillHist(CSample *cs, TString channel, TString type, TString var, double val, double wgt, double wgt_lo=0, double wgt_hi=0);
50     // void fillAllHists(FOFlags ctrl, CSample *cs, TString channel, TString type, filestuff *fs, KinematicsStruct kine, Angles angles,
51     // SimpleLepton lep1, SimpleLepton lep2, SimpleLepton lep3, SimpleLepton lep4,
52     // double wgt, double wgt_lo=0, double wgt_hi=0);
53     // void fillAllJetHists(FOFlags ctrl, CSample *cs, TString channel, TString type, filestuff *fs, KinematicsStruct kine,
54     // SimpleLepton lep1, SimpleLepton lep2, SimpleLepton lep3, SimpleLepton lep4,
55     // FusionMva &fusion, vector<SimpleLepton> &goodJets, JetInfoStruct ji,
56     // double wgt, double wgt_lo=0, double wgt_hi=0);
57     // void makeHTML(FOFlags &ctrl, TString type, TString plotLabel, TString fullOutDir);
58 dkralph 1.1 map<TString,map<TString,TH1D*>* > init_hists(FOFlags &ctrl, TString str="");
59 dkralph 1.3 bool passHlt(FOFlags &ctrl, TrigInfo ti, InfoStruct *info, unsigned lep1matchBits,
60     unsigned lep2matchBits, unsigned lep3matchBits,
61     unsigned lep4matchBits);
62     void init_cuts(vector<TString> &cutstrs, map<TString,int> &cutvec);
63     void resetCutVect(map<TString,int> &cutvec) {
64     for(map<TString,int>::iterator it=cutvec.begin(); it!=cutvec.end(); it++)
65     cutvec[(*it).first] = 0;
66     }
67 dkralph 1.4 map<TString,TH1D*> setHistSet(CSample *cs, TString type, TString var);
68     void fillFakeTuple(CSample *cs, filestuff *fs, EventData evtdata, unsigned ientry, double fillweight);
69 dkralph 1.5 void incrementSsofCounters(FOFlags &ctrl, filestuff *fs, double minMz2,
70     pair<int,int> *best_z_indices, double wgt);
71     map<TString,double> init_counter(TString fname="");
72     map<TString,double> initSsofRatios(vector<CSample*> &samplev);
73     double getSsofWgt(TString channel, map<TString,double> &ssofRatios);
74 dkralph 1.1 //----------------------------------------------------------------------------------------
75     int main(int argc, char** argv)
76     {
77 dkralph 1.7 // Three usage modes:
78     // ctrl.faketype=="SR": plot events in signal region, if requested including ntuples of the extrapolation from 2P2F and 3P1F regions
79     // ctrl.faketype=="2P2F": plot 2P2F region, and if requested write out ntuple which gives extrapolation to SR (ntuple would then be read by "SR", above)
80     // ctrl.faketype=="3P1F": plot 3P1F region (including the extrapolation to there from the 2P2F region), and if requested write out ntuple with SR prediction
81     //
82     // ctrl.makeFakeTuples: write out zznt-type ntuples to be read by plotH4l or by SR mode
83     // ctrl.hiStatFakes: same as makeFakeTuples, but reverse charge and flavor req's to get a larger sample for BDT training (or to plot the WrongFlavorCharge control region)
84     // ctrl.ssof: look only at ssof region
85     // ctrl.writessofratio: write the OS / SS ratio to text files that can be read later in ssof mode
86     // ctrl.plotWholeSample: plot the whole fake sample without weighting with the fake rate
87    
88     TStopwatch watch;
89 dkralph 1.6 SetStyle();
90 dkralph 1.4 initPUWeights();
91 dkralph 1.6 ControlFlags dummyCtrl;
92 dkralph 1.5
93 dkralph 1.3 vector<TString> cutstrs;
94     map<TString,int> cutvec;
95     init_cuts(cutstrs, cutvec);
96 dkralph 1.1
97 dkralph 1.7 bool dummyStr(true); // don't add the yield numbers to legends
98    
99 dkralph 1.4 // arguments...
100 dkralph 1.1 FOFlags ctrl;
101     parse_foargs( argc, argv, ctrl );
102     ctrl.dump();
103 dkralph 1.3 FusionMva fusion(ctrl.uncert);//"./weights/againstZZ-fusion_BDTG.weights.xml");
104 dkralph 1.4 bool makeJetTuple=false; // jet tuple for vbf mva training
105 dkralph 1.7 assert(ctrl.faketype=="SR" || ctrl.faketype=="2P2F" || ctrl.faketype=="3P1F");
106 dkralph 1.4 if(ctrl.heavyFlavor) assert(ctrl.faketype=="2P2F");
107     if(ctrl.ssof) assert(ctrl.faketype=="2P2F");
108 dkralph 1.1
109 dkralph 1.6 can = new TCanvas("can","can",700,500);
110 dkralph 1.1
111 dkralph 1.5 FR_struct fr2011(ctrl.mufakefile2011,ctrl.elefakefile2011);
112     FR_struct fr2012(ctrl.mufakefile2012,ctrl.elefakefile2012);
113 dkralph 1.1
114     TString cmsswpath(CMSSW_BASE + TString("/src"));
115     string xspath = (string(cmsswpath)+"/MitPhysics/data/xs.dat");
116     SimpleTable xstab(xspath.c_str());
117    
118 dkralph 1.3 TrigInfo ti;
119     initAnalysisTriggers(ti);
120    
121 dkralph 1.1 vector<CSample*> samplev;
122     TString ntupledir(""),label(""),plotLabel(""),jsonFile("");
123 dkralph 1.2 int puTarget;
124     readConfigFile(ctrl.config, ntupledir, label, plotLabel, jsonFile, puTarget, samplev, &ctrl, init_hists);
125 dkralph 1.5 map<TString,double> ssofRatios;
126     if(ctrl.ssof && !ctrl.writessofratio && !ctrl.plotWholeSample) ssofRatios = initSsofRatios(samplev);
127 dkralph 1.1
128 dkralph 1.6 Angles angles; // NOTE: this is not the same as fs->angles -- the one in fs is filled with whichever choice of leptons was made in applyZPlusX
129 dkralph 1.3 KinematicsStruct kine; // NOTE: this is not the same as fs->kine -- the one in fs is filled with whichever choice of leptons was made in applyZPlusX
130     JetInfoStruct ji;
131    
132 dkralph 1.1 UInt_t minRun=999999999,maxRun=0;
133     for(unsigned ics=0; ics<samplev.size(); ics++) {
134     CSample *cs = samplev[ics];
135     cout << cs->name << endl;
136 dkralph 1.3
137     // output for vbf mva training
138     unsigned evtVar;
139     AngleTuple *jettuple;
140     if(makeJetTuple) {
141     jettuple = new AngleTuple( (const char*)(TString(cs->name)+"_pass.root").Data(), (const char*)"zznt");
142 dkralph 1.6 jettuple->makeAngleBranch(angles);
143 dkralph 1.3 jettuple->makeKinematicsBranch(kine);
144     jettuple->makeJetInfoBranch(ji);
145     const char *str1 = "evt";
146     const char *str2 = "evt/i";
147     jettuple->makeBranch(str1,(void *)(&evtVar),str2);
148     }
149    
150     vector<pair<unsigned,unsigned> > runEvtv; // vector to veto duplicate events
151     resetCutVect(cutvec);
152 dkralph 1.1 for(unsigned ifs=0; ifs<(cs->fsv).size(); ifs++) {
153     filestuff *fs = (cs->fsv)[ifs];
154 dkralph 1.6 if(ctrl.makeFakeTuples && fs->dataset_!="fakes") { // write a copy of the input trees for events that will be used for the SR fake prediction
155 dkralph 1.3 TString fakefilename(fs->fname_);
156 dkralph 1.7 fakefilename.ReplaceAll(".root","-"+ctrl.faketype+(ctrl.ssof ? "-ssof" : "")+"-fakes.root");
157 dkralph 1.6 if(ctrl.hiStatFakes) fakefilename.ReplaceAll("-fakes.root","-fakes-histat.root");
158 dkralph 1.3 fs->makeOutputFile(fakefilename);
159     }
160 dkralph 1.4 cout << "\t" << fs->fname_; cout.flush();
161 dkralph 1.7 unsigned nDuplSkipped=0,nBadZs=0;
162     watch.Start();
163 dkralph 1.1 for(unsigned ientry=0; ientry<fs->getentries("FOtree"); ientry++) {
164 dkralph 1.4 fs->getentry(ientry,"FOs","FOtree");
165     fs->getentry(ientry,"Zleptons","FOtree");
166 dkralph 1.1 fs->getentry(ientry,"info","zznt");
167 dkralph 1.4
168 dkralph 1.7 if(!(ientry%15000)) {
169     watch.Stop();
170     cout << "\ntime: " << watch.RealTime() << " (entry: " << ientry << " )" << endl;
171     watch.Start();
172     }
173 dkralph 1.3 cutvec["start"] = fs->total_entries_;
174     if(fs->isdata_) {// && !(fs->dataset_=="fakes")) {
175     // WARNING: when I write the fakeTuple from here, I fill an event *twice* if it has two fake z2 candidates, so event numbers are duplicated.
176     // in plotH4l I *don't* want to remove these, but here I *do*, because in this file I again loop over all z2 candidates
177 dkralph 1.1 setMinMaxRun(fs->info->run, minRun, maxRun);
178     bool dupl = takeCareOfDuplicateEvents(fs->info->run, fs->info->evt, runEvtv, nDuplSkipped);
179 dkralph 1.5 if(dupl) continue;
180     if(!fs->rlrm_.HasRunLumi(pair<unsigned,unsigned> (fs->info->run, fs->info->lumi))) continue;
181 dkralph 1.1 }
182 dkralph 1.3 cutvec["rlrmAndDupl"] += 1;
183 dkralph 1.1
184     unsigned npass = fs->passingL->size();
185     unsigned nfail = fs->failingL->size();
186    
187 dkralph 1.3 // look for a z1
188 dkralph 1.1 pair<int,int> best_z_indices;
189 dkralph 1.3 double best_mz1 = findZ1(fs->passingL,best_z_indices,40);
190 dkralph 1.7 if(best_mz1<=0) nBadZs++;
191     if(best_mz1 < 40 || best_mz1 > 120) continue;
192 dkralph 1.5 if(ctrl.heavyFlavor && best_mz1<60) continue;
193 dkralph 1.1 EventData evtdata;
194     evtdata.Z1leptons.push_back((*fs->passingL)[best_z_indices.first]);
195     evtdata.Z1leptons.push_back((*fs->passingL)[best_z_indices.second]);
196    
197     // Look for a z2
198     vector<pair<SimpleLepton,SimpleLepton> > z2cands;
199     vector<TString> types;
200 dkralph 1.4 TString signFlavor;
201 dkralph 1.6 if(ctrl.heavyFlavor) signFlavor = "";
202     else if(ctrl.ssof) signFlavor = "SS-SF";
203     else if(ctrl.hiStatFakes) signFlavor = "signalExclude";
204     else signFlavor = "OS-SF";
205 dkralph 1.4 double minMz2 = ctrl.heavyFlavor ? 0 : 12;
206     int hiPtPassingZ2 = findZ2CandidatesPassFail(fs->passingL, z2cands, types, signFlavor, minMz2, "pass",&best_z_indices); // signal region
207     int hiPtFailingZ2 = findZ2CandidatesPassFail(fs->failingL, z2cands, types, signFlavor, minMz2, "fail"); // 2P+2F
208     int hiPtPfZ2 = findZ2CandidatesPassFail(fs->passingL, z2cands, types, signFlavor, minMz2, "PF", &best_z_indices, fs->failingL); // 3P+1F
209    
210 dkralph 1.7 double wgt=1;
211     if(z2cands.size() > 0) {
212     if(!fs->isdata_) {
213     fs->getentry(ientry,"weights","zznt");
214     double xsWgt = fs->lumi_*xstab.Get(fs->dataset_)/fs->total_entries_;
215     double puWgt = getPUWeight(fs->era_, fs->era_==2011 ? "/025/" : "/029/", fs->info->npu);
216     // if(fs->era_==2012)
217     // puWgt = hpu_2012_me->GetBinContent(hpu_2012_me->FindBin(fs->info->npu));
218     // else if(fs->era_==2011)
219     // puWgt = hpu_2011_me->GetBinContent(hpu_2011_me->FindBin(fs->info->npu));
220     // else assert(0);
221     wgt = xsWgt * puWgt;//* fs->weights->won * fs->weights->woff;
222     if(wgt!=wgt) cout << "xsWgt: " << xsWgt << " puWgt: " << puWgt << endl;
223     }
224     if(fs->dataset_=="fakes") { // if we're reading in the fake ntuple that we wrote out earlier, use the event weight that was stored (this should be the same as what we'd get if we calculated it below)
225     // fs->getentry(ientry,"weights","zznt");
226     wgt = fs->weights->w;
227     }
228     if(ctrl.writessofratio) incrementSsofCounters(ctrl, fs, minMz2, &best_z_indices, wgt);
229     }
230 dkralph 1.3
231 dkralph 1.1 for(unsigned iz2=0; iz2<z2cands.size(); iz2++) {
232     SimpleLepton lep1 = evtdata.Z1leptons[0];
233     SimpleLepton lep2 = evtdata.Z1leptons[1];
234     SimpleLepton lep3 = z2cands[iz2].first;
235     SimpleLepton lep4 = z2cands[iz2].second;
236     evtdata.Z2leptons.clear();
237     evtdata.Z2leptons.push_back(lep3);
238     evtdata.Z2leptons.push_back(lep4);
239 dkralph 1.6 fillAngles(evtdata,angles);
240 dkralph 1.1 fillKinematics(evtdata,kine);
241 dkralph 1.4 lepFrs fwgts;
242 dkralph 1.5 fillLeptonFakeWeights(fwgts, (fs->era_==2011) ? &fr2011 : &fr2012, lep3, lep4);
243 dkralph 1.4 TString channel = getChannel(lep1,lep2,lep3,lep4);
244     // bool hltPass = fs->isdata_ ? passHlt(ctrl,ti,fs->info,lep1.scID,lep2.scID,lep3.scID,lep4.scID) : true;
245    
246     if(ctrl.heavyFlavor) {
247 dkralph 1.5 if(fabs(lep1.dz) > 0.01 || fabs(lep2.dz) > 0.01) continue;
248 dkralph 1.4 if( !(fabs(lep3.ip3dSig) > 2 && fabs(lep4.ip3dSig) > 8) &&
249 dkralph 1.5 !(fabs(lep4.ip3dSig) > 2 && fabs(lep3.ip3dSig) > 8) ) continue;
250 dkralph 1.4 if( !(fabs(lep3.d0) > .002 && fabs(lep4.d0) > .01) &&
251 dkralph 1.5 !(fabs(lep4.d0) > .002 && fabs(lep3.d0) > .01) ) continue;
252     if(fabs(lep3.d0) > 0.1 || fabs(lep4.d0) > 0.1) continue;
253     if(fabs(lep3.dz) > 0.2 || fabs(lep4.dz) > 0.2) continue;
254 dkralph 1.4 } else {
255 dkralph 1.5 if(fabs(lep3.ip3dSig) >= 4 || fabs(lep4.ip3dSig) >= 4) continue; // |sip| < 4 is applied to lep1, lep2 in ZPlusX
256     if(!leptonDrReqs(lep1,lep2,lep3,lep4)) continue;
257     if(kine.m4l < 100) continue;
258     if(!resonanceKilling(lep1,lep2,lep3,lep4)) continue;
259 dkralph 1.4 }
260 dkralph 1.5 if(!finalLeptonPtReqs(lep1,lep2,lep3,lep4)) continue;
261 dkralph 1.1
262 dkralph 1.3 cutvec["4lsele"] += 1;
263 dkralph 1.1
264 dkralph 1.3 //
265     // jets!
266     //
267 dkralph 1.4 bool doJets=false;
268 dkralph 1.3 vector<SimpleLepton> goodJets;
269     if(doJets) {
270 dkralph 1.4 fs->getentry(ientry,"jets","FOtree");
271 dkralph 1.3 if(fs->jets->size() > 1) cutvec["twoJets"] += 1;
272     bool hazJetz = findGoodJets(goodJets, fs, lep1, lep2, lep3, lep4);
273     if(goodJets.size() > 1) cutvec["twoJetsAfter"] += 1;
274 dkralph 1.5 if(!hazJetz) continue;
275 dkralph 1.3 ControlFlags ctrlTmp;
276     fillJetInfo(goodJets,ji,ctrlTmp);
277     if(makeJetTuple) {
278     evtVar = fs->info->evt;
279     jettuple->Fill();
280     }
281 dkralph 1.4 fusion.setValues(ji,kine);
282 dkralph 1.3 }
283 dkralph 1.5
284 dkralph 1.3 cutvec["filling"] += 1;
285    
286 dkralph 1.4 if(types[iz2]=="pass" || ((fs->dataset_=="fakes") && (types[iz2]=="fail"))) { // for the fakes ntuple, we plot the "failing" z2s as passing ones, i.e. put them in hObs, but with the proper weight
287     // llll events
288 dkralph 1.5 if((fs->dataset_!="fakes") && (iz2!=hiPtPassingZ2)) continue; // for non-fakes, we only want the highest-pt "passing" z2 (for the fakes these are by design failing z2s, and we want all of 'em)
289 dkralph 1.3 cutvec["fillPass"] += 1;
290 dkralph 1.6 fillAllHists( ctrl, cs, channel, "obs", fs, kine, angles, lep1, lep2, lep3, lep4, wgt);
291 dkralph 1.7 if(doJets) fillAllJetHists( ctrl, cs, channel, "obs", fs, kine, lep1, lep2, lep3, lep4, /*fusion,*/ /*goodJets, */ji, wgt);
292 dkralph 1.4
293     } else if(types[iz2]=="fail") { // lljj events
294 dkralph 1.5 if(iz2!=hiPtFailingZ2 && ctrl.plotWholeSample) continue;
295 dkralph 1.4 double centr=0,lo=0,hi=0;
296     if(ctrl.faketype=="2P2F") {
297     if(ctrl.plotWholeSample) { // make plots without weighting with the FR
298     centr = wgt;
299     } else {
300     centr = wgt*fwgts.fwgt_3*fwgts.fwgt_4;
301     lo = wgt*fwgts.fwgt_lo_3*fwgts.fwgt_lo_4;
302     hi = wgt*fwgts.fwgt_hi_3*fwgts.fwgt_hi_4;
303 dkralph 1.5 if(ctrl.ssof && !ctrl.writessofratio && !ctrl.plotWholeSample) {
304     double ssof_wgt = getSsofWgt(channel,ssofRatios);
305     centr *= ssof_wgt;
306     lo *= ssof_wgt;
307     hi *= ssof_wgt;
308     }
309 dkralph 1.4 }
310     } else if(ctrl.faketype=="3P1F") { // apply the weights for extrapolation from 2P2F region to 3P1F region
311     centr = wgt*(fwgts.fwgt_3 + fwgts.fwgt_4);
312     lo = wgt*(fwgts.fwgt_lo_3 + fwgts.fwgt_lo_4);
313     hi = wgt*(fwgts.fwgt_hi_3 + fwgts.fwgt_hi_4);
314 dkralph 1.3 }
315 dkralph 1.4
316 dkralph 1.6 if(ctrl.makeFakeTuples && fs->dataset_!="fakes") {
317 dkralph 1.4 double fillwgt;
318     bool dofill=true;
319     if(ctrl.faketype=="2P2F") {
320 dkralph 1.7 // assert(fs->isdata_);
321 dkralph 1.4 fillwgt = centr;
322     } else if(ctrl.faketype=="3P1F") {
323     fillwgt = - wgt*(fwgts.fwgt_3*fwgts.fwgt_4 + fwgts.fwgt_4*fwgts.fwgt_3);
324     dofill = (cs->name=="data" || cs->name=="2012" || cs->name=="2011");
325     } else assert(0);
326     fillFakeTuple(cs,fs,evtdata,ientry,fillwgt);
327 dkralph 1.3 }
328 dkralph 1.4 cutvec["fillFail"] += 1;
329 dkralph 1.6 fillAllHists( ctrl, cs, channel, "pred", fs, kine, angles, lep1, lep2, lep3, lep4, centr, lo, hi);
330 dkralph 1.7 if(doJets) fillAllJetHists( ctrl, cs, channel, "pred", fs, kine, lep1, lep2, lep3, lep4, /*fusion,*/ /*goodJets,*/ ji, centr, lo, hi);
331 dkralph 1.4
332     } else if(types[iz2]=="PF") { // lllj events
333     if(fs->dataset_!="fakes" && iz2!=hiPtPfZ2) continue; // shouldn't have this when I extrapolate to signal region
334 dkralph 1.3
335 dkralph 1.6 if(ctrl.makeFakeTuples && fs->dataset_!="fakes" && ctrl.faketype=="3P1F") {
336 dkralph 1.4 assert(lep3.isLoose || lep4.isLoose);
337     assert(!(lep3.isLoose && lep4.isLoose));
338     double fwgt = lep3.isLoose ? fwgts.fwgt_4 : fwgts.fwgt_3;
339     double fillwgt;// only fill for data or ZZ
340     if(fs->isdata_) fillwgt = wgt*fwgt; // set the weight to be the fake weight (maybe check that this is the same weight as I read in from the fakes dataset?)
341     else if(cs->name=="zz") fillwgt = -wgt*fwgt; // subtract off the zz contribution in the 3P1F region
342     else assert(0);
343     fillFakeTuple(cs,fs,evtdata,ientry,fillwgt);
344 dkralph 1.3 }
345 dkralph 1.4
346     cutvec["fillPF"] += 1;
347 dkralph 1.6 fillAllHists( ctrl, cs, channel, "PF", fs, kine, angles, lep1, lep2, lep3, lep4, wgt);
348 dkralph 1.7 if(doJets) fillAllJetHists( ctrl, cs, channel, "PF", fs, kine, lep1, lep2, lep3, lep4, /*fusion,*/ /*goodJets,*/ ji, wgt);
349 dkralph 1.1 } else assert(0);
350     }
351     }
352 dkralph 1.5 if(ctrl.writessofratio) fs->writeSsofRatios();
353 dkralph 1.7 cout << "\t\t" << setw(7) << nDuplSkipped << " duplicate events skipped (" << nBadZs << " bad Zs)" << endl;
354 dkralph 1.6 if(ctrl.makeFakeTuples) {
355 dkralph 1.3 fs->outFotuple->getFile()->cd();
356     fs->outFotuple->getTree()->Write();
357     fs->outtuple->WriteClose();
358     }
359 dkralph 1.7 // fs->del();
360 dkralph 1.3 }
361     for(unsigned icut=0; icut<cutstrs.size(); icut++) {
362     cout << setw(22) << cutstrs[icut] << setw(22) << cutvec[cutstrs[icut]] << endl;
363 dkralph 1.1 }
364 dkralph 1.3 if(makeJetTuple)
365     jettuple->WriteClose();
366 dkralph 1.1 }
367     cout << "run range: " << setw(12) << minRun << setw(12) << maxRun << endl;
368 dkralph 1.3
369     // plot!
370 dkralph 1.1 assert(samplev.size()>0);
371     vector<TString> typev;
372     typev.push_back("all");
373 dkralph 1.4
374 dkralph 1.5 if(ctrl.plotAllCats) {
375 dkralph 1.3 typev.push_back("4e");
376     typev.push_back("4m");
377     typev.push_back("2e2m");
378     }
379 dkralph 1.4
380 dkralph 1.6 ofstream txtOutFile("fakes.txt",ios_base::app);
381     txtOutFile << "---> " << ctrl.faketype << " " << plotLabel << endl;
382 dkralph 1.4 // loop over channels
383 dkralph 1.1 for(unsigned itype=0; itype<typev.size(); itype++) {
384     TString type(typev[itype]);
385 dkralph 1.6 TString fullOutDir(ctrl.outdir+"/"+plotLabel+"/"+type);
386     gSystem->mkdir(fullOutDir,true);
387     TFile runHistFile(fullOutDir+"/runs.root","recreate");
388 dkralph 1.4 // loop over variables
389 dkralph 1.1 map<TString,TH1D*>::iterator it_v;
390     for(it_v=(*(samplev[0]->hists)[type+"_obs"]).begin(); it_v!=(*(samplev[0]->hists)[type+"_obs"]).end(); it_v++) {
391     TString var((*it_v).first);
392 dkralph 1.6 CPlot cplot(var,TString(""),(*(samplev[0]->hists)[type+"_obs"])[var]->GetXaxis()->GetTitle(),TString("events"),TString(fullOutDir+"/plots"));
393 dkralph 1.4 double fakeCounter=0;
394 dkralph 1.1 double ymax=0;
395 dkralph 1.4 // loop over csamples
396 dkralph 1.1 for(unsigned isam=0; isam<samplev.size(); isam++) {
397     CSample *cs = samplev[isam];
398 dkralph 1.4 map<TString,TH1D*> hs = setHistSet(cs,type,var);
399     if(var=="met") //var=="mjj" || var=="etaProd" || var=="ncj")
400     shiftOverflows(hs);
401 dkralph 1.3 bool plotShapeOnly = false;
402 dkralph 1.4 if(plotShapeOnly)
403     scaleHists(hs);
404    
405 dkralph 1.3 if(cs->isdata && !(cs->name=="fakes")) {
406 dkralph 1.7 // add observation (llll events) in an 'E' hists
407 dkralph 1.5 if(ctrl.faketype=="SR" || (ctrl.heavyFlavor && !ctrl.plotWholeSample) || (ctrl.ssof && !ctrl.plotWholeSample)) {
408 dkralph 1.7 cplot.AddHist1D(hs["obs"],cs->legend+": "+integral_str(hs["obs"],0,dummyStr),"E");
409 dkralph 1.4 ymax = max(ymax,hs["obs"]->GetMaximum());
410     }
411     if(ctrl.faketype=="2P2F") {
412     if(ctrl.plotWholeSample) {
413 dkralph 1.7 // add 'pred' (lljj events with weight *1*) as an 'E' hist
414     cplot.AddHist1D(hs["pred"],cs->legend+": "+integral_str(hs["pred"],0,dummyStr),"E");
415 dkralph 1.4 ymax = max(ymax,hs["pred"]->GetMaximum());
416     } else {
417 dkralph 1.7 // add 'pred' (lljj events with weight w1*w2) as red-line hists
418     cplot.AddHist1D(hs["pred"], TString("FR predic: "+integral_str(hs["pred"],3,dummyStr)), "hist",kRed);
419     cplot.AddHist1D(hs["pred_lo"], TString( "stat lo: "+integral_str(hs["pred_lo"],2,dummyStr)),"hist",kRed,kDashed);
420     cplot.AddHist1D(hs["pred_hi"], TString( "stat hi: "+integral_str(hs["pred_hi"],2,dummyStr)),"hist",kRed,kDashed);
421 dkralph 1.5 if(var=="m4l") {
422 dkralph 1.6 txtOutFile << " " << type << ": " << integral_str(hs["pred"],3) << " (" << integral_str(hs["pred_lo"],2) << "," << integral_str(hs["pred_hi"],2) << ")" << endl;
423 dkralph 1.5 }
424 dkralph 1.4 ymax = max(ymax,histMax(hs["pred"],hs["pred_lo"],hs["pred_hi"]));
425     }
426     }
427     if(ctrl.faketype=="3P1F") {
428 dkralph 1.7 // add 'PF' (lllj events with weight 1) as an 'E' hist
429     // double ratio = 0;//integrateHist(hs["PF"]) / integrateHist(hs["pred"]);
430     // cplot.AddHist1D(hs["PF"],TString(cs->legend+": "+integral_str(hs["PF"],0,dummyStr)+", ratio: "+f_to_a(ratio)),"E",cs->color);
431     cplot.AddHist1D(hs["PF"],TString(cs->legend+": "+integral_str(hs["PF"],0,dummyStr)),"E",cs->color);
432 dkralph 1.4 if(!ctrl.plotWholeSample) {
433 dkralph 1.7 // add 'pred' (lljj events with weight ~w1) as a red stacked hist
434     cplot.AddToStack(hs["pred"],TString(cs->legend+"(2P2F extrap.): "+integral_str(hs["pred"],1,dummyStr)), 823, -1);
435 dkralph 1.4 ymax = max(ymax,histMax(hs["PF"],cplot.GetStack(),hs["pred"]));
436     } else {
437     ymax = max(ymax,hs["PF"]->GetMaximum());
438     }
439     fakeCounter = integrateHist(hs["PF"]) - integrateHist(hs["pred"]);
440     }
441     } else { // mc
442     TH1D *mchist = 0;
443     if(ctrl.faketype=="SR") mchist = hs["obs"];
444     if(ctrl.faketype=="2P2F") {
445     if(ctrl.plotWholeSample) mchist = hs["pred"];
446     else mchist = hs["obs"];
447 dkralph 1.3 }
448 dkralph 1.4 if(ctrl.faketype=="3P1F") mchist = hs["PF"];
449     assert(mchist);
450     bool stackMc = true;
451 dkralph 1.7 if(stackMc) cplot.AddToStack(mchist,TString(cs->legend+": "+integral_str(mchist,2,dummyStr)),cs->color,-1);
452     else cplot.AddHist1D(mchist,TString(cs->legend +": "+integral_str(mchist,3,dummyStr)),"Ehist",cs->color);//cs->color);
453 dkralph 1.4 if(cs->name=="zz") fakeCounter -= integrateHist(hs["PF"]);
454     ymax = max(ymax,histMax(mchist,cplot.GetStack()));
455 dkralph 1.1 }
456     if(cs->isdata && var=="run") {
457 dkralph 1.4 assert(hs["obs"]->GetBinContent(0)==0 && hs["obs"]->GetBinContent(hs["obs"]->GetXaxis()->GetNbins()+1)==0);
458     hs["obs"]->Write("runs");
459 dkralph 1.1 }
460 dkralph 1.4 if(!var.Contains("fusionMVA"))
461 dkralph 1.1 cplot.SetYRange(0,1.2*ymax);
462 dkralph 1.7 if(!dummyStr && ctrl.faketype=="3P1F") cplot.AddTextBox(TString("diff: "+f_to_a(fakeCounter)),.7,.5,.8,.6);
463 dkralph 1.1 }
464 dkralph 1.7 TString txt("#bf{CMS Preliminary L = 5 ( + 12 ) fb^{-1} at #sqrt{s} = 7 ( + 8 ) TeV}"); // #sqrt{s} = 7 TeV, L = 5 fb^{-1}; #sqrt{s} = 8 TeV, L = 12 fb^{-1}");
465     cplot.AddTextBox(txt,0.16,0.95,0.85,0.99,0);
466 dkralph 1.1 cplot.Draw(can,true,"png");
467 dkralph 1.4 if(var.Contains("fusionMVA")) {
468     cplot.SetLogy();
469     cplot.Draw(can,true,"png",0,var+"-log");
470     cplot.SetLogy(false);
471     }
472 dkralph 1.1 }
473     runHistFile.Close();
474 dkralph 1.6 makeHTML(ctrl,type,plotLabel,fullOutDir);
475 dkralph 1.1 }
476 dkralph 1.6 txtOutFile.close();
477    
478 dkralph 1.5 fr2011.FR_struct::~FR_struct();
479     fr2012.FR_struct::~FR_struct();
480 dkralph 1.1 }
481     //----------------------------------------------------------------------------------------
482     map<TString,map<TString,TH1D*>* > init_hists(FOFlags &ctrl, TString str)
483     {
484     map<TString,map<TString,TH1D*>* > hists;
485     map<TString,TH1D*> *h_4e_obs = new map<TString,TH1D*>; hists["4e_obs"] = h_4e_obs;
486     map<TString,TH1D*> *h_4e_pred = new map<TString,TH1D*>; hists["4e_pred"] = h_4e_pred;
487     map<TString,TH1D*> *h_4e_pred_lo = new map<TString,TH1D*>; hists["4e_pred_lo"] = h_4e_pred_lo;
488     map<TString,TH1D*> *h_4e_pred_hi = new map<TString,TH1D*>; hists["4e_pred_hi"] = h_4e_pred_hi;
489 dkralph 1.4 map<TString,TH1D*> *h_4e_PF = new map<TString,TH1D*>; hists["4e_PF"] = h_4e_PF;
490     map<TString,TH1D*> *h_4e_PF_lo = new map<TString,TH1D*>; hists["4e_PF_lo"] = h_4e_PF_lo;
491     map<TString,TH1D*> *h_4e_PF_hi = new map<TString,TH1D*>; hists["4e_PF_hi"] = h_4e_PF_hi;
492 dkralph 1.1 map<TString,TH1D*> *h_4m_obs = new map<TString,TH1D*>; hists["4m_obs"] = h_4m_obs;
493     map<TString,TH1D*> *h_4m_pred = new map<TString,TH1D*>; hists["4m_pred"] = h_4m_pred;
494     map<TString,TH1D*> *h_4m_pred_lo = new map<TString,TH1D*>; hists["4m_pred_lo"] = h_4m_pred_lo;
495     map<TString,TH1D*> *h_4m_pred_hi = new map<TString,TH1D*>; hists["4m_pred_hi"] = h_4m_pred_hi;
496 dkralph 1.4 map<TString,TH1D*> *h_4m_PF = new map<TString,TH1D*>; hists["4m_PF"] = h_4m_PF;
497     map<TString,TH1D*> *h_4m_PF_lo = new map<TString,TH1D*>; hists["4m_PF_lo"] = h_4m_PF_lo;
498     map<TString,TH1D*> *h_4m_PF_hi = new map<TString,TH1D*>; hists["4m_PF_hi"] = h_4m_PF_hi;
499 dkralph 1.1 map<TString,TH1D*> *h_2e2m_obs = new map<TString,TH1D*>; hists["2e2m_obs"] = h_2e2m_obs;
500     map<TString,TH1D*> *h_2e2m_pred = new map<TString,TH1D*>; hists["2e2m_pred"] = h_2e2m_pred;
501     map<TString,TH1D*> *h_2e2m_pred_lo = new map<TString,TH1D*>; hists["2e2m_pred_lo"] = h_2e2m_pred_lo;
502     map<TString,TH1D*> *h_2e2m_pred_hi = new map<TString,TH1D*>; hists["2e2m_pred_hi"] = h_2e2m_pred_hi;
503 dkralph 1.4 map<TString,TH1D*> *h_2e2m_PF = new map<TString,TH1D*>; hists["2e2m_PF"] = h_2e2m_PF;
504     map<TString,TH1D*> *h_2e2m_PF_lo = new map<TString,TH1D*>; hists["2e2m_PF_lo"] = h_2e2m_PF_lo;
505     map<TString,TH1D*> *h_2e2m_PF_hi = new map<TString,TH1D*>; hists["2e2m_PF_hi"] = h_2e2m_PF_hi;
506 dkralph 1.1 map<TString,TH1D*> *h_all_obs = new map<TString,TH1D*>; hists["all_obs"] = h_all_obs;
507     map<TString,TH1D*> *h_all_pred = new map<TString,TH1D*>; hists["all_pred"] = h_all_pred;
508     map<TString,TH1D*> *h_all_pred_lo = new map<TString,TH1D*>; hists["all_pred_lo"] = h_all_pred_lo;
509     map<TString,TH1D*> *h_all_pred_hi = new map<TString,TH1D*>; hists["all_pred_hi"] = h_all_pred_hi;
510 dkralph 1.4 map<TString,TH1D*> *h_all_PF = new map<TString,TH1D*>; hists["all_PF"] = h_all_PF;
511     map<TString,TH1D*> *h_all_PF_lo = new map<TString,TH1D*>; hists["all_PF_lo"] = h_all_PF_lo;
512     map<TString,TH1D*> *h_all_PF_hi = new map<TString,TH1D*>; hists["all_PF_hi"] = h_all_PF_hi;
513 dkralph 1.1 map<TString,map<TString,TH1D*>* >::iterator it_h;
514    
515 dkralph 1.7 allocate_hists(hists,str);
516     // for(it_h=hists.begin(); it_h!=hists.end(); it_h++) {
517     // (*((*it_h).second))["npv"] = new TH1D(TString("npv") +"_"+(*it_h).first+str,";#bf{N PV};", 50,-0.5,49.5); (*((*it_h).second))["npv"]->Sumw2();
518     // (*((*it_h).second))["run"] = new TH1D(TString("run") +"_"+(*it_h).first+str,";#bf{run};", 50,160800,203744/*196535*/); (*((*it_h).second))["run"]->Sumw2();
519     // (*((*it_h).second))["mZ1"] = new TH1D(TString("mZ1") +"_"+(*it_h).first+str,";#bf{mZ1 [GeV]};", 20,40,120); (*((*it_h).second))["mZ1"]->Sumw2();
520     // (*((*it_h).second))["mZ2"] = new TH1D(TString("mZ2") +"_"+(*it_h).first+str,";#bf{mZ2 [GeV]};", 30,0,115); (*((*it_h).second))["mZ2"]->Sumw2();
521     // (*((*it_h).second))["mZ2_lo"] = new TH1D(TString("mZ2_lo") +"_"+(*it_h).first+str,";#bf{mZ2 [GeV]};", 30,0,10); (*((*it_h).second))["mZ2_lo"]->Sumw2();
522     // (*((*it_h).second))["m4l_lo"] = new TH1D(TString("m4l_lo") +"_"+(*it_h).first+str,";#bf{m4l [GeV]};", 35,70,120); (*((*it_h).second))["m4l_lo"]->Sumw2();
523     // (*((*it_h).second))["m4l_med"] = new TH1D(TString("m4l_med") +"_"+(*it_h).first+str,";#bf{m4l [GeV]};",35,100,180); (*((*it_h).second))["m4l_med"]->Sumw2();
524     // (*((*it_h).second))["m4l"] = new TH1D(TString("m4l") +"_"+(*it_h).first+str,";#bf{m4l [GeV]};", 35,100,450); (*((*it_h).second))["m4l"]->Sumw2();
525     // // (*((*it_h).second))["Z1pt"] = new TH1D(TString("Z1pt") +"_"+(*it_h).first+str,";#bf{Z1pt [GeV]};", 20,0,200); (*((*it_h).second))["Z1pt"]->Sumw2();
526     // // (*((*it_h).second))["ZZpt"] = new TH1D(TString("ZZpt") +"_"+(*it_h).first+str,";#bf{ZZpt [GeV]};", 30,0,200); (*((*it_h).second))["ZZpt"]->Sumw2();
527     // (*((*it_h).second))["met"] = new TH1D(TString("met") +"_"+(*it_h).first+str,";#bf{met [GeV]};", 30,0,100); (*((*it_h).second))["met"]->Sumw2();
528    
529     // (*((*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();
530     // (*((*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();
531     // (*((*it_h).second))["pt_l3"] = new TH1D(TString("pt_l3") +"_"+(*it_h).first+str,";#bf{l3 p_{T} [GeV]};", 37,0,75); (*((*it_h).second))["pt_l3"]->Sumw2();
532     // (*((*it_h).second))["pt_l4"] = new TH1D(TString("pt_l4") +"_"+(*it_h).first+str,";#bf{l4 p_{T} [GeV]};", 37,0,50); (*((*it_h).second))["pt_l4"]->Sumw2();
533    
534     // (*((*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();
535     // (*((*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();
536     // (*((*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();
537     // (*((*it_h).second))["eta_l4"] = new TH1D(TString("eta_l4")+"_"+(*it_h).first+str,";#bf{l4 #eta};", 25,-2.5,2.5); (*((*it_h).second))["eta_l4"]->Sumw2();
538    
539     // (*((*it_h).second))["ip3ds_l1"] = new TH1D(TString("ip3ds_l1") +"_"+(*it_h).first+str,";#bf{ip3ds l1};",37,-3,3); (*((*it_h).second))["ip3ds_l1"]->Sumw2();
540     // (*((*it_h).second))["ip3ds_l2"] = new TH1D(TString("ip3ds_l2") +"_"+(*it_h).first+str,";#bf{ip3ds l2};",37,-3,3); (*((*it_h).second))["ip3ds_l2"]->Sumw2();
541     // (*((*it_h).second))["ip3ds_l3_lo"] = new TH1D(TString("ip3ds_l3_lo") +"_"+(*it_h).first+str,";#bf{ip3ds l3_lo};",25,-6,6); (*((*it_h).second))["ip3ds_l3_lo"]->Sumw2();
542     // (*((*it_h).second))["ip3ds_l4_lo"] = new TH1D(TString("ip3ds_l4_lo") +"_"+(*it_h).first+str,";#bf{ip3ds l4_lo};",25,-6,6); (*((*it_h).second))["ip3ds_l4_lo"]->Sumw2();
543     // (*((*it_h).second))["ip3ds_l3"] = new TH1D(TString("ip3ds_l3") +"_"+(*it_h).first+str,";#bf{ip3ds l3};",55,-40,40); (*((*it_h).second))["ip3ds_l3"]->Sumw2();
544     // (*((*it_h).second))["ip3ds_l4"] = new TH1D(TString("ip3ds_l4") +"_"+(*it_h).first+str,";#bf{ip3ds l4};",55,-40,40); (*((*it_h).second))["ip3ds_l4"]->Sumw2();
545    
546     // (*((*it_h).second))["d0_l1"] = new TH1D(TString("d0_l1") +"_"+(*it_h).first+str,";#bf{d0 l1};",50,-.008,.008); (*((*it_h).second))["d0_l1"]->Sumw2();
547     // (*((*it_h).second))["d0_l2"] = new TH1D(TString("d0_l2") +"_"+(*it_h).first+str,";#bf{d0 l2};",50,-.008,.008); (*((*it_h).second))["d0_l2"]->Sumw2();
548     // (*((*it_h).second))["d0_l3_lo"] = new TH1D(TString("d0_l3_lo") +"_"+(*it_h).first+str,";#bf{d0 l3_lo};",25,-.03,.03); (*((*it_h).second))["d0_l3_lo"]->Sumw2();
549     // (*((*it_h).second))["d0_l4_lo"] = new TH1D(TString("d0_l4_lo") +"_"+(*it_h).first+str,";#bf{d0 l4_lo};",25,-.03,.03); (*((*it_h).second))["d0_l4_lo"]->Sumw2();
550     // (*((*it_h).second))["d0_l3"] = new TH1D(TString("d0_l3") +"_"+(*it_h).first+str,";#bf{d0 l3};",50,-.1,.1); (*((*it_h).second))["d0_l3"]->Sumw2();
551     // (*((*it_h).second))["d0_l4"] = new TH1D(TString("d0_l4") +"_"+(*it_h).first+str,";#bf{d0 l4};",50,-.1,.1); (*((*it_h).second))["d0_l4"]->Sumw2();
552    
553     // (*((*it_h).second))["dz_l1"] = new TH1D(TString("dz_l1") +"_"+(*it_h).first+str,";#bf{dz l1};",50,-.01,.01); (*((*it_h).second))["dz_l1"]->Sumw2();
554     // (*((*it_h).second))["dz_l2"] = new TH1D(TString("dz_l2") +"_"+(*it_h).first+str,";#bf{dz l2};",50,-.01,.01); (*((*it_h).second))["dz_l2"]->Sumw2();
555     // (*((*it_h).second))["dz_l3"] = new TH1D(TString("dz_l3") +"_"+(*it_h).first+str,";#bf{dz l3};",50,-.2,.2); (*((*it_h).second))["dz_l3"]->Sumw2();
556     // (*((*it_h).second))["dz_l4"] = new TH1D(TString("dz_l4") +"_"+(*it_h).first+str,";#bf{dz l4};",50,-.2,.2); (*((*it_h).second))["dz_l4"]->Sumw2();
557    
558     // (*((*it_h).second))["dR_l3l4_lo"] = new TH1D(TString("dR_l3l4_lo") +"_"+(*it_h).first+str,";#bf{#Delta R l3,l4};",75,0,.2); (*((*it_h).second))["dR_l3l4_lo"]->Sumw2();
559     // (*((*it_h).second))["dR_l3l4"] = new TH1D(TString("dR_l3l4") +"_"+(*it_h).first+str,";#bf{#Delta R l3,l4};",75,0,6); (*((*it_h).second))["dR_l3l4"]->Sumw2();
560    
561     // // jets
562     // (*((*it_h).second))["pt_allJet"] = new TH1D(TString("pt_allJet") +"_"+(*it_h).first+str,";#bf{jet 1 p_{T} [GeV]};",37,0,400); (*((*it_h).second))["pt_allJet"]->Sumw2();
563     // (*((*it_h).second))["eta_allJet"] = new TH1D(TString("eta_allJet") +"_"+(*it_h).first+str,";#bf{jet 1 p_{T} [GeV]};",37,-4.8,4.8); (*((*it_h).second))["eta_allJet"]->Sumw2();
564     // (*((*it_h).second))["pt_j1"] = new TH1D(TString("pt_j1") +"_"+(*it_h).first+str,";#bf{jet 1 p_{T} [GeV]};", 37,0,400); (*((*it_h).second))["pt_j1"]->Sumw2();
565     // (*((*it_h).second))["pt_j2"] = new TH1D(TString("pt_j2") +"_"+(*it_h).first+str,";#bf{jet 2 p_{T} [GeV]};", 37,0,125); (*((*it_h).second))["pt_j2"]->Sumw2();
566     // (*((*it_h).second))["pt_j3"] = new TH1D(TString("pt_j3") +"_"+(*it_h).first+str,";#bf{jet 3 p_{T} [GeV]};", 37,0,125); (*((*it_h).second))["pt_j3"]->Sumw2();
567     // (*((*it_h).second))["pt_j4"] = new TH1D(TString("pt_j4") +"_"+(*it_h).first+str,";#bf{jet 4 p_{T} [GeV]};", 37,0,125); (*((*it_h).second))["pt_j4"]->Sumw2();
568     // (*((*it_h).second))["eta_j1"] = new TH1D(TString("eta_j1")+"_"+(*it_h).first+str,";#bf{jet 1 #eta};", 55,-4.8,4.8); (*((*it_h).second))["eta_j1"]->Sumw2();
569     // (*((*it_h).second))["eta_j2"] = new TH1D(TString("eta_j2")+"_"+(*it_h).first+str,";#bf{jet 2 #eta};", 55,-4.8,4.8); (*((*it_h).second))["eta_j2"]->Sumw2();
570     // (*((*it_h).second))["eta_j3"] = new TH1D(TString("eta_j3")+"_"+(*it_h).first+str,";#bf{jet 3 #eta};", 55,-4.8,4.8); (*((*it_h).second))["eta_j3"]->Sumw2();
571     // (*((*it_h).second))["eta_j4"] = new TH1D(TString("eta_j4")+"_"+(*it_h).first+str,";#bf{jet 4 #eta};", 55,-4.8,4.8); (*((*it_h).second))["eta_j4"]->Sumw2();
572     // (*((*it_h).second))["phi_j1"] = new TH1D(TString("phi_j1")+"_"+(*it_h).first+str,";#bf{jet 1 #phi};", 25,-3.2,3.2); (*((*it_h).second))["phi_j1"]->Sumw2();
573     // (*((*it_h).second))["phi_j2"] = new TH1D(TString("phi_j2")+"_"+(*it_h).first+str,";#bf{jet 2 #phi};", 25,-3.2,3.2); (*((*it_h).second))["phi_j2"]->Sumw2();
574     // (*((*it_h).second))["phi_j3"] = new TH1D(TString("phi_j3")+"_"+(*it_h).first+str,";#bf{jet 3 #phi};", 25,-3.2,3.2); (*((*it_h).second))["phi_j3"]->Sumw2();
575     // (*((*it_h).second))["phi_j4"] = new TH1D(TString("phi_j4")+"_"+(*it_h).first+str,";#bf{jet 4 #phi};", 25,-3.2,3.2); (*((*it_h).second))["phi_j4"]->Sumw2();
576     // (*((*it_h).second))["idmva_j1"] = new TH1D(TString("idmva_j1")+"_"+(*it_h).first+str,";#bf{jet 1 MVA};", 25,-1.1,1.1); (*((*it_h).second))["idmva_j1"]->Sumw2();
577     // (*((*it_h).second))["idmva_j2"] = new TH1D(TString("idmva_j2")+"_"+(*it_h).first+str,";#bf{jet 2 MVA};", 25,-1.1,1.1); (*((*it_h).second))["idmva_j2"]->Sumw2();
578     // (*((*it_h).second))["idmva_j3"] = new TH1D(TString("idmva_j3")+"_"+(*it_h).first+str,";#bf{jet 3 MVA};", 25,-1.1,1.1); (*((*it_h).second))["idmva_j3"]->Sumw2();
579     // (*((*it_h).second))["idmva_j4"] = new TH1D(TString("idmva_j4")+"_"+(*it_h).first+str,";#bf{jet 4 MVA};", 25,-1.1,1.1); (*((*it_h).second))["idmva_j4"]->Sumw2();
580     // (*((*it_h).second))["mjj"] = new TH1D(TString("mjj")+"_"+(*it_h).first+str,";#bf{m_{jj}};", 25,10,1550); (*((*it_h).second))["mjj"]->Sumw2();
581     // (*((*it_h).second))["dEta"] = new TH1D(TString("dEta")+"_"+(*it_h).first+str,";#bf{#Delta #eta};", 25,-6,6); (*((*it_h).second))["dEta"]->Sumw2();
582     // (*((*it_h).second))["etaProd"] = new TH1D(TString("etaProd")+"_"+(*it_h).first+str,";#bf{#eta_{1} * #eta_{2}};",25,-12,12); (*((*it_h).second))["etaProd"]->Sumw2();
583     // (*((*it_h).second))["njets"] = new TH1D(TString("njets")+"_"+(*it_h).first+str,";#bf{N Jets};", 7,-0.5,6.5); (*((*it_h).second))["njets"]->Sumw2();
584    
585     // // (*((*it_h).second))["dR_l1j1"] = new TH1D(TString("dR_l1j1") +"_"+(*it_h).first+str,";#bf{#Delta R l1,jet 1};",75,0,6); (*((*it_h).second))["dR_l1j1"]->Sumw2();
586     // // (*((*it_h).second))["dR_l2j1"] = new TH1D(TString("dR_l2j1") +"_"+(*it_h).first+str,";#bf{#Delta R l2,jet 1};",75,0,6); (*((*it_h).second))["dR_l2j1"]->Sumw2();
587     // // (*((*it_h).second))["dR_l3j1"] = new TH1D(TString("dR_l3j1") +"_"+(*it_h).first+str,";#bf{#Delta R l3,jet 1};",75,0,6); (*((*it_h).second))["dR_l3j1"]->Sumw2();
588     // // (*((*it_h).second))["dR_l4j1"] = new TH1D(TString("dR_l4j1") +"_"+(*it_h).first+str,";#bf{#Delta R l4,jet 1};",75,0,6); (*((*it_h).second))["dR_l4j1"]->Sumw2();
589     // // (*((*it_h).second))["dR_l1j2"] = new TH1D(TString("dR_l1j2") +"_"+(*it_h).first+str,";#bf{#Delta R l1,jet 2};",75,0,6); (*((*it_h).second))["dR_l1j2"]->Sumw2();
590     // // (*((*it_h).second))["dR_l2j2"] = new TH1D(TString("dR_l2j2") +"_"+(*it_h).first+str,";#bf{#Delta R l2,jet 2};",75,0,6); (*((*it_h).second))["dR_l2j2"]->Sumw2();
591     // // (*((*it_h).second))["dR_l3j2"] = new TH1D(TString("dR_l3j2") +"_"+(*it_h).first+str,";#bf{#Delta R l3,jet 2};",75,0,6); (*((*it_h).second))["dR_l3j2"]->Sumw2();
592     // // (*((*it_h).second))["dR_l4j2"] = new TH1D(TString("dR_l4j2") +"_"+(*it_h).first+str,";#bf{#Delta R l4,jet 2};",75,0,6); (*((*it_h).second))["dR_l4j2"]->Sumw2();
593     // // (*((*it_h).second))["dR_l1j3"] = new TH1D(TString("dR_l1j3") +"_"+(*it_h).first+str,";#bf{#Delta R l1,jet 3};",75,0,6); (*((*it_h).second))["dR_l1j3"]->Sumw2();
594     // // (*((*it_h).second))["dR_l2j3"] = new TH1D(TString("dR_l2j3") +"_"+(*it_h).first+str,";#bf{#Delta R l2,jet 3};",75,0,6); (*((*it_h).second))["dR_l2j3"]->Sumw2();
595     // // (*((*it_h).second))["dR_l3j3"] = new TH1D(TString("dR_l3j3") +"_"+(*it_h).first+str,";#bf{#Delta R l3,jet 3};",75,0,6); (*((*it_h).second))["dR_l3j3"]->Sumw2();
596     // // (*((*it_h).second))["dR_l4j3"] = new TH1D(TString("dR_l4j3") +"_"+(*it_h).first+str,";#bf{#Delta R l4,jet 3};",75,0,6); (*((*it_h).second))["dR_l4j3"]->Sumw2();
597     // // (*((*it_h).second))["dR_l1j4"] = new TH1D(TString("dR_l1j4") +"_"+(*it_h).first+str,";#bf{#Delta R l1,jet 4};",75,0,6); (*((*it_h).second))["dR_l1j4"]->Sumw2();
598     // // (*((*it_h).second))["dR_l2j4"] = new TH1D(TString("dR_l2j4") +"_"+(*it_h).first+str,";#bf{#Delta R l2,jet 4};",75,0,6); (*((*it_h).second))["dR_l2j4"]->Sumw2();
599     // // (*((*it_h).second))["dR_l3j4"] = new TH1D(TString("dR_l3j4") +"_"+(*it_h).first+str,";#bf{#Delta R l3,jet 4};",75,0,6); (*((*it_h).second))["dR_l3j4"]->Sumw2();
600     // // (*((*it_h).second))["dR_l4j4"] = new TH1D(TString("dR_l4j4") +"_"+(*it_h).first+str,";#bf{#Delta R l4,jet 4};",75,0,6); (*((*it_h).second))["dR_l4j4"]->Sumw2();
601    
602     // int nbins=35;
603     // (*((*it_h).second))["costheta1"] = new TH1D(TString("costheta1") +"_"+(*it_h).first+str,";#bf{costheta1};", nbins,-1,1); (*((*it_h).second))["costheta1"]->Sumw2();
604     // (*((*it_h).second))["costheta2"] = new TH1D(TString("costheta2") +"_"+(*it_h).first+str,";#bf{costheta2};", nbins,-1,1); (*((*it_h).second))["costheta2"]->Sumw2();
605     // (*((*it_h).second))["costhetastar"] = new TH1D(TString("costhetastar") +"_"+(*it_h).first+str,";#bf{costhetastar};", nbins,-1,1); (*((*it_h).second))["costhetastar"]->Sumw2();
606     // (*((*it_h).second))["Phi"] = new TH1D(TString("Phi") +"_"+(*it_h).first+str,";#bf{Phi};", nbins,-3.15,3.15); (*((*it_h).second))["Phi"]->Sumw2();
607     // (*((*it_h).second))["Phi1"] = new TH1D(TString("Phi1") +"_"+(*it_h).first+str,";#bf{Phi1};", nbins,-3.15,3.15); (*((*it_h).second))["Phi1"]->Sumw2();
608    
609     // (*((*it_h).second))["pt4l"] = new TH1D(TString("pt4l") +"_"+(*it_h).first+str,";#bf{pt4l/m4l};", nbins-7,0,0.5); (*((*it_h).second))["pt4l"]->Sumw2();
610     // (*((*it_h).second))["pt4l_log"] = new TH1D(TString("pt4l_log") +"_"+(*it_h).first+str,";#bf{pt4l/m4l};", nbins,0,1.5); (*((*it_h).second))["pt4l_log"]->Sumw2();
611     // (*((*it_h).second))["y4l"] = new TH1D(TString("y4l") +"_"+(*it_h).first+str,";#bf{y4l};", nbins,-2.4,2.4); (*((*it_h).second))["y4l"]->Sumw2();
612     // (*((*it_h).second))["Z1pt"] = new TH1D(TString("Z1pt") +"_"+(*it_h).first+str,";#bf{Z1pt/m4l};", nbins,0,0.5); (*((*it_h).second))["Z1pt"]->Sumw2();
613     // (*((*it_h).second))["Z1pt_log"] = new TH1D(TString("Z1pt_log") +"_"+(*it_h).first+str,";#bf{Z1pt/m4l};", nbins,0,1.5); (*((*it_h).second))["Z1pt_log"]->Sumw2();
614     // (*((*it_h).second))["Z2pt"] = new TH1D(TString("Z2pt") +"_"+(*it_h).first+str,";#bf{Z2pt/m4l};", nbins,0,0.5); (*((*it_h).second))["Z2pt"]->Sumw2();
615     // (*((*it_h).second))["Z2pt_log"] = new TH1D(TString("Z2pt_log") +"_"+(*it_h).first+str,";#bf{Z2pt/m4l};", nbins,0,1.5); (*((*it_h).second))["Z2pt_log"]->Sumw2();
616    
617     // (*((*it_h).second))["ZZdotZ1"] = new TH1D(TString("ZZdotZ1") +"_"+(*it_h).first+str,";#bf{ZZ #bullet Z1/(m4l*mZ1)};", nbins,-.2,2.5); (*((*it_h).second))["ZZdotZ1"]->Sumw2();
618     // (*((*it_h).second))["ZZdotZ2"] = new TH1D(TString("ZZdotZ2") +"_"+(*it_h).first+str,";#bf{ZZ #bullet Z2/(m4l*mZ2)};", nbins,-1,3); (*((*it_h).second))["ZZdotZ2"]->Sumw2();
619     // (*((*it_h).second))["ZZdotZ1_log"] = new TH1D(TString("ZZdotZ1_log") +"_"+(*it_h).first+str,";#bf{ZZ #bullet Z1/(m4l*mZ1)};",nbins,-1.5,15); (*((*it_h).second))["ZZdotZ1_log"]->Sumw2();
620     // (*((*it_h).second))["ZZdotZ2_log"] = new TH1D(TString("ZZdotZ2_log") +"_"+(*it_h).first+str,";#bf{ZZ #bullet Z2/(m4l*mZ2)};",nbins,-1.5,15); (*((*it_h).second))["ZZdotZ2_log"]->Sumw2();
621     // (*((*it_h).second))["dphi1"] = new TH1D(TString("dphi1") +"_"+(*it_h).first+str,";#bf{dphi1};", nbins,-1,1); (*((*it_h).second))["dphi1"]->Sumw2();
622     // (*((*it_h).second))["dphi2"] = new TH1D(TString("dphi2") +"_"+(*it_h).first+str,";#bf{dphi2};", nbins,-1,1); (*((*it_h).second))["dphi2"]->Sumw2();
623     // (*((*it_h).second))["dphi1_log"] = new TH1D(TString("dphi1_log") +"_"+(*it_h).first+str,";#bf{dphi1};", nbins,-1,1); (*((*it_h).second))["dphi1_log"]->Sumw2();
624     // (*((*it_h).second))["dphi2_log"] = new TH1D(TString("dphi2_log") +"_"+(*it_h).first+str,";#bf{dphi2};", nbins,-1,1); (*((*it_h).second))["dphi2_log"]->Sumw2();
625    
626     // (*((*it_h).second))["fusionMVA"] = new TH1D(TString("fusionMVA")+"_"+(*it_h).first+str,";#bf{MVA output};", 100,-1,1); (*((*it_h).second))["fusionMVA"]->Sumw2();
627     // (*((*it_h).second))["fusionMVA_lo"] = new TH1D(TString("fusionMVA_lo")+"_"+(*it_h).first+str,";#bf{MVA output};", 100,-1,-.83); (*((*it_h).second))["fusionMVA_lo"]->Sumw2();
628     // (*((*it_h).second))["fusionMVA_med"] = new TH1D(TString("fusionMVA_med")+"_"+(*it_h).first+str,";#bf{MVA output};", 100,-.5,1); (*((*it_h).second))["fusionMVA_med"]->Sumw2();
629     // (*((*it_h).second))["fusionMVA_hi"] = new TH1D(TString("fusionMVA_hi")+"_"+(*it_h).first+str,";#bf{MVA output};", 100,.75,1); (*((*it_h).second))["fusionMVA_hi"]->Sumw2();
630     // (*((*it_h).second))["m4l_jet_lo"] = new TH1D(TString("m4l_jet_lo") +"_"+(*it_h).first+str,";#bf{m4l [GeV]};", 45,100,180); (*((*it_h).second))["m4l_jet_lo"]->Sumw2();
631     // (*((*it_h).second))["m4l_jet"] = new TH1D(TString("m4l_jet") +"_"+(*it_h).first+str,";#bf{m4l [GeV]};", 45,100,600); (*((*it_h).second))["m4l_jet"]->Sumw2();
632     // }
633 dkralph 1.1 return hists;
634     }
635     //--------------------------------------------------------------------------------------------------
636 dkralph 1.7 // void makeHTML(FOFlags &ctrl, TString type, TString plotLabel, TString fullOutDir)
637     // {
638     // TString tmpString(plotLabel);
639     // tmpString.ReplaceAll("/"," ");
640     // TString title(ctrl.faketype+", "+tmpString+", "+type);
641     // TString htmlfname(fullOutDir+"/plots.html");
642     // ofstream htmlfile(htmlfname);
643    
644     // htmlfile << "<!DOCTYPE html" << endl;
645     // htmlfile << " PUBLIC \"-//W3C//DTD HTML 3.2//EN\">" << endl;
646     // htmlfile << "<html>" << endl;
647    
648     // htmlfile << "<head><title>"+title+"</title></head>" << endl;
649     // htmlfile << "<body bgcolor=\"000000\">" << endl;
650     // htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">"+title+"</h3>" << endl;
651    
652     // htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">boson kinematics</h3>" << endl;
653     // htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
654    
655     // htmlfile << "<tr>" << endl;
656     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/m4l_lo.png\"><img src=\"plots/m4l_lo.png\" alt=\"plots/m4l_lo.png\" width=\"100%\"></a></td>" << endl;
657     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/m4l_med.png\"><img src=\"plots/m4l_med.png\" alt=\"plots/m4l_med.png\" width=\"100%\"></a></td>" << endl;
658     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/m4l.png\"><img src=\"plots/m4l.png\" alt=\"plots/m4l.png\" width=\"100%\"></a></td>" << endl;
659     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
660     // htmlfile << "</tr>" << endl;
661    
662     // htmlfile << "<tr>" << endl;
663     // 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;
664     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/mZ2_lo.png\"><img src=\"plots/mZ2_lo.png\" alt=\"plots/mZ2_lo.png\" width=\"100%\"></a></td>" << endl;
665     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/mZ2.png\"><img src=\"plots/mZ2.png\" alt=\"plots/mZ2.png\" width=\"100%\"></a></td>" << endl;
666     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
667     // htmlfile << "</tr>" << endl;
668    
669     // htmlfile << "<tr>" << endl;
670     // 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;
671     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ZZpt.png\"><img src=\"plots/ZZpt.png\" alt=\"plots/ZZpt.png\" width=\"100%\"></a></td>" << endl;
672     // 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;
673     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
674     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
675     // htmlfile << "</tr>" << endl;
676    
677     // htmlfile << "</table>" << endl;
678     // htmlfile << "<hr />" << endl;
679     // htmlfile << "control: " << endl;
680     // htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
681    
682     // htmlfile << "<tr>" << endl;
683     // 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;
684     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/npv.png\"><img src=\"plots/npv.png\" alt=\"plots/npv.png\" width=\"100%\"></a></td>" << endl;
685     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
686     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
687     // htmlfile << "</tr>" << endl;
688    
689     // htmlfile << "</table>" << endl;
690    
691     // htmlfile << "</body>" << endl;
692     // htmlfile << "</html>" << endl;
693     // htmlfile.close();
694    
695     // TString anglefname(htmlfname);
696     // anglefname.ReplaceAll("plots.html","angleplots.html");
697     // htmlfile.open(anglefname);
698    
699     // htmlfile << "<!DOCTYPE html" << endl;
700     // htmlfile << " PUBLIC \"-//W3C//DTD HTML 3.2//EN\">" << endl;
701     // htmlfile << "<html>" << endl;
702    
703     // htmlfile << "<head><title>"+title+"</title></head>" << endl;
704     // htmlfile << "<body bgcolor=\"000000\">" << endl;
705     // htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">"+title+"</h3>" << endl;
706    
707     // htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">Angles & Co.</h3>" << endl;
708     // htmlfile << "<hr />" << endl;
709     // htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
710     // htmlfile << "</table>" << endl;
711    
712     // htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">Angles:</h3>" << endl;
713     // htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
714    
715     // htmlfile << "<tr>" << endl;
716     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/costheta1.png\"><img src=\"plots/costheta1.png\" alt=\"plots/costheta1.png\" width=\"100%\"></a></td>" << endl;
717     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/costheta2.png\"><img src=\"plots/costheta2.png\" alt=\"plots/costheta2.png\" width=\"100%\"></a></td>" << endl;
718     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/costhetastar.png\"><img src=\"plots/costhetastar.png\" alt=\"plots/costhetastar.png\" width=\"100%\"></a></td>" << endl;
719     // htmlfile << "<td width=\"25%\"></td>" << endl;
720     // htmlfile << "</tr>" << endl;
721    
722     // htmlfile << "<tr>" << endl;
723     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/Phi.png\"><img src=\"plots/Phi.png\" alt=\"plots/Phi.png\" width=\"100%\"></a></td>" << endl;
724     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/Phi1.png\"><img src=\"plots/Phi1.png\" alt=\"plots/Phi1.png\" width=\"100%\"></a></td>" << endl;
725     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
726     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
727     // htmlfile << "</tr>" << endl;
728    
729     // htmlfile << "</table>" << endl;
730     // htmlfile << "<hr />" << endl;
731     // htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">Boson pt variables: " << endl;
732     // htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
733    
734     // htmlfile << "<tr>" << endl;
735     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/y4l.png\"><img src=\"plots/y4l.png\" alt=\"plots/y4l.png\" width=\"100%\"></a></td>" << endl;
736     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt4l.png\"><img src=\"plots/pt4l.png\" alt=\"plots/pt4l.png\" width=\"100%\"></a></td>" << endl;
737     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt4l_log.png\"><img src=\"plots/pt4l_log.png\" alt=\"plots/pt4l_log.png\" width=\"100%\"></a></td>" << endl;
738     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
739     // htmlfile << "<tr>" << endl;
740    
741     // htmlfile << "</tr>" << endl;
742     // 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;
743     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/Z2pt.png\"><img src=\"plots/Z2pt.png\" alt=\"plots/Z2pt.png\" width=\"100%\"></a></td>" << endl;
744     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/Z1pt_log.png\"><img src=\"plots/Z1pt_log.png\" alt=\"plots/Z1pt_log.png\" width=\"100%\"></a></td>" << endl;
745     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/Z2pt_log.png\"><img src=\"plots/Z2pt_log.png\" alt=\"plots/Z2pt_log.png\" width=\"100%\"></a></td>" << endl;
746     // htmlfile << "</tr>" << endl;
747    
748     // htmlfile << "<tr>" << endl;
749     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ZZdotZ1.png\"><img src=\"plots/ZZdotZ1.png\" alt=\"plots/ZZdotZ1.png\" width=\"100%\"></a></td>" << endl;
750     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ZZdotZ2.png\"><img src=\"plots/ZZdotZ2.png\" alt=\"plots/ZZdotZ2.png\" width=\"100%\"></a></td>" << endl;
751     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ZZdotZ1_log.png\"><img src=\"plots/ZZdotZ1_log.png\" alt=\"plots/ZZdotZ1_log.png\" width=\"100%\"></a></td>" << endl;
752     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ZZdotZ2_log.png\"><img src=\"plots/ZZdotZ2_log.png\" alt=\"plots/ZZdotZ2_log.png\" width=\"100%\"></a></td>" << endl;
753     // htmlfile << "</tr>" << endl;
754    
755     // htmlfile << "<tr>" << endl;
756     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dphi1.png\"><img src=\"plots/dphi1.png\" alt=\"plots/dphi1.png\" width=\"100%\"></a></td>" << endl;
757     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dphi2.png\"><img src=\"plots/dphi2.png\" alt=\"plots/dphi2.png\" width=\"100%\"></a></td>" << endl;
758     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dphi1_log.png\"><img src=\"plots/dphi1_log.png\" alt=\"plots/dphi1_log.png\" width=\"100%\"></a></td>" << endl;
759     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dphi2_log.png\"><img src=\"plots/dphi2_log.png\" alt=\"plots/dphi2_log.png\" width=\"100%\"></a></td>" << endl;
760     // htmlfile << "</tr>" << endl;
761    
762    
763     // htmlfile << "</table>" << endl;
764    
765     // htmlfile << "</body>" << endl;
766     // htmlfile << "</html>" << endl;
767     // htmlfile.close();
768    
769     // TString leptonfname(htmlfname);
770     // leptonfname.ReplaceAll("plots.html","leptonplots.html");
771     // htmlfile.open(leptonfname);
772    
773     // htmlfile << "<!DOCTYPE html" << endl;
774     // htmlfile << " PUBLIC \"-//W3C//DTD HTML 3.2//EN\">" << endl;
775     // htmlfile << "<html>" << endl;
776    
777     // htmlfile << "<head><title>"+title+"</title></head>" << endl;
778     // htmlfile << "<body bgcolor=\"000000\">" << endl;
779     // htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">"+title+"</h3>" << endl;
780    
781     // htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">lepton plots</h3>" << endl;
782     // htmlfile << "<hr />" << endl;
783     // htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
784     // htmlfile << "</table>" << endl;
785    
786     // htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">Z1 leptons:</h3>" << endl;
787     // htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
788    
789     // htmlfile << "<tr>" << endl;
790     // 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;
791     // 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;
792     // 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;
793     // 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;
794     // htmlfile << "</tr>" << endl;
795    
796     // htmlfile << "<tr>" << endl;
797     // 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;
798     // 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;
799     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
800     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
801     // htmlfile << "</tr>" << endl;
802    
803     // htmlfile << "<tr>" << endl;
804     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/d0_l1.png\"><img src=\"plots/d0_l1.png\" alt=\"plots/d0_l1.png\" width=\"100%\"></a></td>" << endl;
805     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/d0_l2.png\"><img src=\"plots/d0_l2.png\" alt=\"plots/d0_l2.png\" width=\"100%\"></a></td>" << endl;
806     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
807     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
808     // htmlfile << "</tr>" << endl;
809    
810     // htmlfile << "<tr>" << endl;
811     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dz_l1.png\"><img src=\"plots/dz_l1.png\" alt=\"plots/dz_l1.png\" width=\"100%\"></a></td>" << endl;
812     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dz_l2.png\"><img src=\"plots/dz_l2.png\" alt=\"plots/dz_l2.png\" width=\"100%\"></a></td>" << endl;
813     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
814     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
815     // htmlfile << "</tr>" << endl;
816    
817     // // htmlfile << "<tr>" << endl;
818     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l3l4_lo.png\"><img src=\"plots/dR_l3l4_lo.png\" alt=\"plots/dR_l3l4_lo.png\" width=\"100%\"></a></td>" << endl;
819     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l3l4.png\"><img src=\"plots/dR_l3l4.png\" alt=\"plots/dR_l3l4.png\" width=\"100%\"></a></td>" << endl;
820     // // htmlfile << "<td width=\"25%\"><a><</a></td>" << endl;
821     // // htmlfile << "<td width=\"25%\"><a><</a></td>" << endl;
822     // // htmlfile << "</tr>" << endl;
823    
824     // htmlfile << "</table>" << endl;
825     // htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">extra leptons (l3 and l4): </h3>" << endl;
826     // htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
827    
828     // htmlfile << "<tr>" << endl;
829     // 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;
830     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt_l4.png\"><img src=\"plots/pt_l4.png\" alt=\"plots/pt_l4.png\" width=\"100%\"></a></td>" << endl;
831     // 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;
832     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/eta_l4.png\"><img src=\"plots/eta_l4.png\" alt=\"plots/eta_l4.png\" width=\"100%\"></a></td>" << endl;
833     // htmlfile << "</tr>" << endl;
834    
835     // htmlfile << "<tr>" << endl;
836     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ip3ds_l3_lo.png\"><img src=\"plots/ip3ds_l3_lo.png\" alt=\"plots/ip3ds_l3_lo.png\" width=\"100%\"></a></td>" << endl;
837     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ip3ds_l4_lo.png\"><img src=\"plots/ip3ds_l4_lo.png\" alt=\"plots/ip3ds_l4_lo.png\" width=\"100%\"></a></td>" << endl;
838     // 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;
839     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ip3ds_l4.png\"><img src=\"plots/ip3ds_l4.png\" alt=\"plots/ip3ds_l4.png\" width=\"100%\"></a></td>" << endl;
840     // htmlfile << "</tr>" << endl;
841 dkralph 1.4
842 dkralph 1.7 // htmlfile << "<tr>" << endl;
843     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/d0_l3_lo.png\"><img src=\"plots/d0_l3_lo.png\" alt=\"plots/d0_l3_lo.png\" width=\"100%\"></a></td>" << endl;
844     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/d0_l4_lo.png\"><img src=\"plots/d0_l4_lo.png\" alt=\"plots/d0_l4_lo.png\" width=\"100%\"></a></td>" << endl;
845     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/d0_l3.png\"><img src=\"plots/d0_l3.png\" alt=\"plots/d0_l3.png\" width=\"100%\"></a></td>" << endl;
846     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/d0_l4.png\"><img src=\"plots/d0_l4.png\" alt=\"plots/d0_l4.png\" width=\"100%\"></a></td>" << endl;
847     // htmlfile << "</tr>" << endl;
848    
849     // htmlfile << "<tr>" << endl;
850     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dz_l3.png\"><img src=\"plots/dz_l3.png\" alt=\"plots/dz_l3.png\" width=\"100%\"></a></td>" << endl;
851     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dz_l4.png\"><img src=\"plots/dz_l4.png\" alt=\"plots/dz_l4.png\" width=\"100%\"></a></td>" << endl;
852     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
853     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
854     // htmlfile << "</tr>" << endl;
855 dkralph 1.4
856 dkralph 1.7 // htmlfile << "</table>" << endl;
857 dkralph 1.4
858 dkralph 1.7 // htmlfile << "</body>" << endl;
859     // htmlfile << "</html>" << endl;
860     // htmlfile.close();
861    
862     // TString jetfname(htmlfname);
863     // jetfname.ReplaceAll("plots.html","jetplots.html");
864     // htmlfile.open(jetfname);
865    
866     // htmlfile << "<!DOCTYPE html" << endl;
867     // htmlfile << " PUBLIC \"-//W3C//DTD HTML 3.2//EN\">" << endl;
868     // htmlfile << "<html>" << endl;
869    
870     // htmlfile << "<head><title>"+title+"</title></head>" << endl;
871     // htmlfile << "<body bgcolor=\"000000\">" << endl;
872     // htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">"+title+"</h3>" << endl;
873    
874     // htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">jet plots</h3>" << endl;
875     // htmlfile << "<hr />" << endl;
876     // htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;
877    
878     // htmlfile << "<tr>" << endl;
879     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt_j1.png\"><img src=\"plots/pt_j1.png\" alt=\"plots/pt_j1.png\" width=\"100%\"></a></td>" << endl;
880     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt_j2.png\"><img src=\"plots/pt_j2.png\" alt=\"plots/pt_j2.png\" width=\"100%\"></a></td>" << endl;
881     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt_j2.png\"><img src=\"plots/pt_j2.png\" alt=\"plots/pt_j2.png\" width=\"100%\"></a></td>" << endl;
882     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt_j4.png\"><img src=\"plots/pt_j4.png\" alt=\"plots/pt_j4.png\" width=\"100%\"></a></td>" << endl;
883     // htmlfile << "</tr>" << endl;
884    
885     // htmlfile << "<tr>" << endl;
886     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/eta_j1.png\"><img src=\"plots/eta_j1.png\" alt=\"plots/eta_j1.png\" width=\"100%\"></a></td>" << endl;
887     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/eta_j2.png\"><img src=\"plots/eta_j2.png\" alt=\"plots/eta_j2.png\" width=\"100%\"></a></td>" << endl;
888     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/eta_j3.png\"><img src=\"plots/eta_j3.png\" alt=\"plots/eta_j3.png\" width=\"100%\"></a></td>" << endl;
889     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/eta_j4.png\"><img src=\"plots/eta_j4.png\" alt=\"plots/eta_j4.png\" width=\"100%\"></a></td>" << endl;
890     // htmlfile << "</tr>" << endl;
891    
892     // htmlfile << "<tr>" << endl;
893     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/idmva_j1.png\"><img src=\"plots/idmva_j1.png\" alt=\"plots/idmva_j1.png\" width=\"100%\"></a></td>" << endl;
894     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/idmva_j2.png\"><img src=\"plots/idmva_j2.png\" alt=\"plots/idmva_j2.png\" width=\"100%\"></a></td>" << endl;
895     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/idmva_j3.png\"><img src=\"plots/idmva_j3.png\" alt=\"plots/idmva_j3.png\" width=\"100%\"></a></td>" << endl;
896     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/idmva_j4.png\"><img src=\"plots/idmva_j4.png\" alt=\"plots/idmva_j4.png\" width=\"100%\"></a></td>" << endl;
897     // htmlfile << "</tr>" << endl;
898    
899     // htmlfile << "<tr>" << endl;
900     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/phi_j1.png\"><img src=\"plots/phi_j1.png\" alt=\"plots/phi_j1.png\" width=\"100%\"></a></td>" << endl;
901     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/phi_j2.png\"><img src=\"plots/phi_j2.png\" alt=\"plots/phi_j2.png\" width=\"100%\"></a></td>" << endl;
902     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/phi_j3.png\"><img src=\"plots/phi_j3.png\" alt=\"plots/phi_j3.png\" width=\"100%\"></a></td>" << endl;
903     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/phi_j4.png\"><img src=\"plots/phi_j4.png\" alt=\"plots/phi_j4.png\" width=\"100%\"></a></td>" << endl;
904     // htmlfile << "</tr>" << endl;
905    
906     // htmlfile << "<tr>" << endl;
907     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/mjj.png\"><img src=\"plots/mjj.png\" alt=\"plots/mjj.png\" width=\"100%\"></a></td>" << endl;
908     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dEta.png\"><img src=\"plots/dEta.png\" alt=\"plots/dEta.png\" width=\"100%\"></a></td>" << endl;
909     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/etaProd.png\"><img src=\"plots/etaProd.png\" alt=\"plots/etaProd.png\" width=\"100%\"></a></td>" << endl;
910     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/njets.png\"><img src=\"plots/njets.png\" alt=\"plots/njets.png\" width=\"100%\"></a></td>" << endl;
911     // htmlfile << "</tr>" << endl;
912    
913     // // htmlfile << "<tr>" << endl;
914     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l1j1.png\"><img src=\"plots/dR_l1j1.png\" alt=\"plots/dR_l1j1.png\" width=\"100%\"></a></td>" << endl;
915     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l2j1.png\"><img src=\"plots/dR_l2j1.png\" alt=\"plots/dR_l2j1.png\" width=\"100%\"></a></td>" << endl;
916     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l3j1.png\"><img src=\"plots/dR_l3j1.png\" alt=\"plots/dR_l3j1.png\" width=\"100%\"></a></td>" << endl;
917     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l4j1.png\"><img src=\"plots/dR_l4j1.png\" alt=\"plots/dR_l4j1.png\" width=\"100%\"></a></td>" << endl;
918     // // htmlfile << "</tr>" << endl;
919    
920     // // htmlfile << "<tr>" << endl;
921     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l1j2.png\"><img src=\"plots/dR_l1j2.png\" alt=\"plots/dR_l1j2.png\" width=\"100%\"></a></td>" << endl;
922     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l2j2.png\"><img src=\"plots/dR_l2j2.png\" alt=\"plots/dR_l2j2.png\" width=\"100%\"></a></td>" << endl;
923     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l3j2.png\"><img src=\"plots/dR_l3j2.png\" alt=\"plots/dR_l3j2.png\" width=\"100%\"></a></td>" << endl;
924     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l4j2.png\"><img src=\"plots/dR_l4j2.png\" alt=\"plots/dR_l4j2.png\" width=\"100%\"></a></td>" << endl;
925     // // htmlfile << "</tr>" << endl;
926    
927     // // htmlfile << "<tr>" << endl;
928     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l1j3.png\"><img src=\"plots/dR_l1j3.png\" alt=\"plots/dR_l1j3.png\" width=\"100%\"></a></td>" << endl;
929     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l2j3.png\"><img src=\"plots/dR_l2j3.png\" alt=\"plots/dR_l2j3.png\" width=\"100%\"></a></td>" << endl;
930     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l3j3.png\"><img src=\"plots/dR_l3j3.png\" alt=\"plots/dR_l3j3.png\" width=\"100%\"></a></td>" << endl;
931     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l4j3.png\"><img src=\"plots/dR_l4j3.png\" alt=\"plots/dR_l4j3.png\" width=\"100%\"></a></td>" << endl;
932     // // htmlfile << "</tr>" << endl;
933    
934     // // htmlfile << "<tr>" << endl;
935     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l1j4.png\"><img src=\"plots/dR_l1j4.png\" alt=\"plots/dR_l1j4.png\" width=\"100%\"></a></td>" << endl;
936     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l2j4.png\"><img src=\"plots/dR_l2j4.png\" alt=\"plots/dR_l2j4.png\" width=\"100%\"></a></td>" << endl;
937     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l3j4.png\"><img src=\"plots/dR_l3j4.png\" alt=\"plots/dR_l3j4.png\" width=\"100%\"></a></td>" << endl;
938     // // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dR_l4j4.png\"><img src=\"plots/dR_l4j4.png\" alt=\"plots/dR_l4j4.png\" width=\"100%\"></a></td>" << endl;
939     // // htmlfile << "</tr>" << endl;
940    
941     // htmlfile << "<tr>" << endl;
942     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/fusionMVA.png\"><img src=\"plots/fusionMVA.png\" alt=\"plots/fusionMVA.png\" width=\"100%\"></a></td>" << endl;
943     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/fusionMVA_lo.png\"><img src=\"plots/fusionMVA_lo.png\" alt=\"plots/fusionMVA_lo.png\" width=\"100%\"></a></td>" << endl;
944     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/fusionMVA_hi.png\"><img src=\"plots/fusionMVA_hi.png\" alt=\"plots/fusionMVA_hi.png\" width=\"100%\"></a></td>" << endl;
945     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
946     // htmlfile << "</tr>" << endl;
947    
948     // htmlfile << "<tr>" << endl;
949     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/fusionMVA-log.png\"><img src=\"plots/fusionMVA-log.png\" alt=\"plots/fusionMVA-log.png\" width=\"100%\"></a></td>" << endl;
950     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/fusionMVA_lo-log.png\"><img src=\"plots/fusionMVA_lo-log.png\" alt=\"plots/fusionMVA_lo-log.png\" width=\"100%\"></a></td>" << endl;
951     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/fusionMVA_hi-log.png\"><img src=\"plots/fusionMVA_hi-log.png\" alt=\"plots/fusionMVA_hi-log.png\" width=\"100%\"></a></td>" << endl;
952     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
953     // htmlfile << "</tr>" << endl;
954    
955     // htmlfile << "<tr>" << endl;
956     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/m4l_jet_lo.png\"><img src=\"plots/m4l_jet_lo.png\" alt=\"plots/m4l_jet_lo.png\" width=\"100%\"></a></td>" << endl;
957     // htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/m4l_jet.png\"><img src=\"plots/m4l_jet.png\" alt=\"plots/m4l_jet.png\" width=\"100%\"></a></td>" << endl;
958     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
959     // htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
960     // htmlfile << "</tr>" << endl;
961 dkralph 1.4
962    
963 dkralph 1.7 // htmlfile << "</table>" << endl;
964 dkralph 1.1
965 dkralph 1.7 // htmlfile << "<hr />" << endl;
966 dkralph 1.1
967 dkralph 1.7 // htmlfile << "<hr />" << endl;
968 dkralph 1.1
969 dkralph 1.7 // htmlfile << "</body>" << endl;
970     // htmlfile << "</html>" << endl;
971     // htmlfile.close();
972     // }
973 dkralph 1.3 //----------------------------------------------------------------------------------------
974     bool passHlt(FOFlags &ctrl, TrigInfo ti, InfoStruct *info, unsigned lep1matchBits,
975     unsigned lep2matchBits, unsigned lep3matchBits,
976     unsigned lep4matchBits)
977     {
978     bool pass=false;
979     bool onePassedButWasOutside=false;
980     bitset<30> firedBits(info->status);
981     if(ctrl.debug) cout << setw(12) << info->run << setw(12) << info->evt << setw(65) << firedBits <<endl;
982     for(unsigned ibit=0; ibit<ti.trigBits.size(); ibit++) {
983     bool outsideRunRange=false;
984     if(info->run < ti.minRuns[ibit] || info->run > ti.maxRuns[ibit]) {
985     outsideRunRange = true;
986     }
987     int baconBit = ti.trigBits[ibit];
988     bool passBit = firedBits.test(ibit);
989     if(ctrl.debug) cout << " ibit: " << setw(4) << ibit << " (bacon bit: " << baconBit << ") fired: " << passBit << endl;
990     if(ctrl.debug && passBit && outsideRunRange) cout << " would have passed but it's outside run range (" << ti.minRuns[ibit] << "," << ti.maxRuns[ibit] << ")" << endl;
991     if(passBit && outsideRunRange) {
992     onePassedButWasOutside = true;
993     }
994     if(passBit && !outsideRunRange) pass = true;
995     }
996     if(!pass && onePassedButWasOutside) cout << "WARNING: would have passed, but one was outside its run range" << endl;
997     return pass;
998     }
999     //----------------------------------------------------------------------------------------
1000     void init_cuts( vector<TString> &cutstrs, map<TString,int> &cutvec)
1001     {
1002     cutstrs.push_back("start" ); cutvec["start"] = 0;
1003     cutstrs.push_back("rlrmAndDupl" ); cutvec["rlrmAndDupl"] = 0;
1004     // cutstrs.push_back("skim" ); cutvec["skim"] = 0;
1005     cutstrs.push_back("4lsele" ); cutvec["4lsele"] = 0;
1006     cutstrs.push_back("twoJets" ); cutvec["twoJets"] = 0;
1007     cutstrs.push_back("twoJetsAfter" ); cutvec["twoJetsAfter"] = 0;
1008     cutstrs.push_back("filling" ); cutvec["filling"] = 0;
1009     cutstrs.push_back("fillPass" ); cutvec["fillPass"] = 0;
1010 dkralph 1.4 cutstrs.push_back("fillFail" ); cutvec["fillFail"] = 0;
1011     cutstrs.push_back("fillPF" ); cutvec["fillPF"] = 0;
1012 dkralph 1.3 }
1013     //----------------------------------------------------------------------------------------
1014     bool findGoodJets(vector<SimpleLepton> &goodJets, filestuff *fs,
1015     SimpleLepton lep1, SimpleLepton lep2, SimpleLepton lep3, SimpleLepton lep4)
1016     {
1017     int nHighPtJets=0,nLowPtJets=0;
1018     for(unsigned ijet=0; ijet<fs->jets->size(); ijet++) {
1019     SimpleLepton *jet = &((*fs->jets)[ijet]);
1020     if(dr(*jet,lep1) < 0.2) continue;
1021     if(dr(*jet,lep2) < 0.2) continue;
1022     if(dr(*jet,lep3) < 0.2) continue;
1023     if(dr(*jet,lep4) < 0.2) continue;
1024     if(!(jet->status.passPre())) continue;
1025     if(!jet->isLoose) continue;
1026     if(fabs(jet->vec.Eta()) > 4.5) continue;
1027     goodJets.push_back(*jet);
1028     if(jet->vec.Pt() > 40) nHighPtJets++;
1029     if(jet->vec.Pt() > 20) nLowPtJets++;
1030     }
1031     sort( goodJets.begin(), goodJets.end(), SimpleLepton::lep_pt_sort ); // note: they're not sorted, 'cause jet corrections were applied in applyZPlusX
1032     if((goodJets.size()>0 && nHighPtJets<1) || // require pt > 40,20 if the jets are there
1033     (goodJets.size()>1 && nLowPtJets<2))
1034     return false;
1035     else
1036     return true;
1037     }
1038 dkralph 1.4 //----------------------------------------------------------------------------------------
1039     map<TString,TH1D*> setHistSet(CSample *cs, TString type, TString var)
1040     {
1041     map<TString,TH1D*> hset;
1042     hset["obs"] = (*(cs->hists)[type+"_obs"])[var];
1043     hset["pred"] = (*(cs->hists)[type+"_pred"])[var];
1044     hset["pred_lo"] = (*(cs->hists)[type+"_pred_lo"])[var];
1045     hset["pred_hi"] = (*(cs->hists)[type+"_pred_hi"])[var];
1046     hset["PF"] = (*(cs->hists)[type+"_PF"])[var];
1047     hset["PF_lo"] = (*(cs->hists)[type+"_PF_lo"])[var];
1048     hset["PF_hi"] = (*(cs->hists)[type+"_PF_hi"])[var];
1049     return hset;
1050     }
1051     //----------------------------------------------------------------------------------------
1052     void fillFakeTuple(CSample *cs, filestuff *fs, EventData evtdata, unsigned ientry, double fillweight)
1053     {
1054     fs->getentry(ientry,"","zznt"); // make sure we've got this entry for all the branches
1055 dkralph 1.6 fillAngles(evtdata,*fs->angles);
1056 dkralph 1.4 fillKinematics(evtdata,*fs->kine); // reminder: kine has the fake information, while fs->kine *had*, until this line, whatever ZPlusX put in it
1057     fs->weights->w = fillweight;
1058     fs->outtuple->Fill();
1059     fs->outFotuple->Fill();
1060     }
1061 dkralph 1.5 //----------------------------------------------------------------------------------------
1062     void incrementSsofCounters(FOFlags &ctrl, filestuff *fs, double minMz2,
1063     pair<int,int> *best_z_indices,
1064     double wgt)
1065     {
1066     assert(ctrl.ssof); // only makes sense to write this out when we're thinking about ssof method
1067     vector<pair<SimpleLepton,SimpleLepton> > z2cands;
1068     vector<TString> types;
1069    
1070     int hiPtFailZ2 = findZ2CandidatesPassFail(fs->failingL, z2cands, types, "XX-SF", minMz2, "fail");
1071     if(hiPtFailZ2 == -1) return; // no z2 found
1072     SimpleLepton lep1 = (*fs->passingL)[best_z_indices->first];
1073     SimpleLepton lep2 = (*fs->passingL)[best_z_indices->second];
1074     SimpleLepton lep3 = z2cands[hiPtFailZ2].first;
1075     SimpleLepton lep4 = z2cands[hiPtFailZ2].second;
1076     TString channel = getChannel(lep1,lep2,lep3,lep4);
1077     TString sign = (lep3.charge == lep4.charge) ? "SS" : "OS";
1078 dkralph 1.4
1079 dkralph 1.5 fs->counters_[sign+"_"+channel] += wgt;
1080     fs->counters_[sign] += wgt;
1081     }
1082     //----------------------------------------------------------------------------------------
1083     double getSsofWgt(TString channel, map<TString,double> &ssofRatios)
1084     {
1085     double returnval = ssofRatios[channel];
1086     if(returnval < 0.1 || returnval > 3) {
1087     cout << "\nERROR! ssof ratio out of bounds for " << channel << ": " << returnval << endl;
1088     assert(0);
1089     }
1090     return returnval;
1091     }
1092     //----------------------------------------------------------------------------------------
1093     map<TString,double> initSsofRatios(vector<CSample*> &samplev)
1094     {
1095     double OS,SS;
1096     double OS_4e,SS_4e;
1097     double OS_4m,SS_4m;
1098     double OS_2e2m,SS_2e2m;
1099     cout << "Initializing ssof ratios: " << endl;
1100     for(unsigned isam=0; isam<samplev.size(); isam++) {
1101     CSample *cs = samplev[isam];
1102     for(unsigned ifs=0; ifs<(cs->fsv).size(); ifs++) {
1103     filestuff *fs = (cs->fsv)[ifs];
1104     if(fs->useSsofRatio_) {
1105     cout << " adding from: " << fs->fname_ << endl;
1106     cout << " " << fs->counters_["ratio"] << setw(8) << fixed << setprecision(2) << fs->counters_["ratio_4e"] << setw(8) << fixed << setprecision(2) << fs->counters_["ratio_4m"] << setw(8) << fixed << setprecision(2) << fs->counters_["ratio_2e2m"] << endl;
1107     OS += fs->counters_["OS"];
1108     SS += fs->counters_["SS"];
1109     OS_4e += fs->counters_["OS_4e"];
1110     SS_4e += fs->counters_["SS_4e"];
1111     OS_4m += fs->counters_["OS_4m"];
1112     SS_4m += fs->counters_["SS_4m"];
1113     OS_2e2m += fs->counters_["OS_2e2m"];
1114     SS_2e2m += fs->counters_["SS_2e2m"];
1115     }
1116     }
1117     }
1118     assert(OS!=0 && SS!=0 && OS_4e!=0 && SS_4e!=0 && OS_4m!=0 && SS_4m!=0 && OS_2e2m && SS_2e2m!=0);
1119     map<TString,double> ssofRatios;
1120     ssofRatios[""] = OS/SS;
1121     ssofRatios["4e"] = OS_4e/SS_4e;
1122     ssofRatios["4m"] = OS_4m/SS_4m;
1123     ssofRatios["2e2m"] = OS_2e2m/SS_2e2m;
1124     cout << "returning: " << ssofRatios[""] << setw(8) << fixed << setprecision(2) << ssofRatios["4e"] << setw(8) << fixed << setprecision(2) << ssofRatios["4m"] << setw(8) << fixed << setprecision(2) << ssofRatios["2e2m"] << endl;
1125     return ssofRatios;
1126     }
1127