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