ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/NonMCBackground/src/plotSignalFakes.cc
(Generate patch)

Comparing UserCode/MitHzz4l/NonMCBackground/src/plotSignalFakes.cc (file contents):
Revision 1.1 by dkralph, Mon Jul 16 10:21:13 2012 UTC vs.
Revision 1.5 by dkralph, Tue Aug 7 13:00:53 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines