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.5 by dkralph, Tue Aug 7 13:00:53 2012 UTC vs.
Revision 1.6 by dkralph, Tue Oct 23 11:22:41 2012 UTC

# Line 24 | Line 24
24   #include "FR_struct.h"
25   #include "SelectionFuncs.h"
26   #include "SampleWeight.h"
27 + #include "MitStyleRemix.h"
28  
29   #include "TMVA/Reader.h"
30   #include "TMVA/Tools.h"
# Line 38 | Line 39 | using namespace std;
39   using namespace RooFit;
40   using namespace mithep;
41  
42 < TH1D* hpu_2011;
43 < TH1D* hpu_2012;
44 < TH1D* hpu_2012_me;
42 > // TH1D* hpu_2011;
43 > // TH1D* hpu_2012;
44 > // TH1D* hpu_2011_me;
45 > // TH1D* hpu_2012_me;
46   //----------------------------------------------------------------------------------------
47   TCanvas *can;
48  
49 + TString dummy_integral_str(TH1D *hist, int nDecPlaces) { return TString(""); };
50   bool findGoodJets(vector<SimpleLepton> &goodJets, filestuff *fs,
51                    SimpleLepton lep1, SimpleLepton lep2, SimpleLepton lep3, SimpleLepton lep4);
52   void fillHist(CSample *cs, TString channel, TString type, TString var, double val, double wgt, double wgt_lo=0, double wgt_hi=0);
53 < void fillAllHists(FOFlags ctrl, CSample *cs, TString channel, TString type, filestuff *fs, KinematicsStruct kine,
53 > void fillAllHists(FOFlags ctrl, CSample *cs, TString channel, TString type, filestuff *fs, KinematicsStruct kine, Angles angles,
54                    SimpleLepton lep1, SimpleLepton lep2, SimpleLepton lep3, SimpleLepton lep4,
55                    double wgt, double wgt_lo=0, double wgt_hi=0);
56   void fillAllJetHists(FOFlags ctrl,  CSample *cs, TString channel, TString type, filestuff *fs, KinematicsStruct kine,
57                        SimpleLepton lep1, SimpleLepton lep2, SimpleLepton lep3, SimpleLepton lep4,
58                        FusionMva &fusion, vector<SimpleLepton> &goodJets, JetInfoStruct ji,
59                        double wgt, double wgt_lo=0, double wgt_hi=0);
60 < void makeHTML(FOFlags &ctrl, TString type, TString plotLabel);
60 > void makeHTML(FOFlags &ctrl, TString type, TString plotLabel, TString fullOutDir);
61   map<TString,map<TString,TH1D*>* > init_hists(FOFlags &ctrl, TString str="");
62   bool passHlt(FOFlags &ctrl, TrigInfo ti, InfoStruct *info, unsigned lep1matchBits,
63               unsigned lep2matchBits, unsigned lep3matchBits,
# Line 74 | Line 77 | double getSsofWgt(TString channel, map<T
77   //----------------------------------------------------------------------------------------
78   int main(int argc, char** argv)
79   {
80 +  SetStyle();
81    initPUWeights();
82 <  TFile * puf_me;
83 <  puf_me= new TFile("data/pileup/PUWeights_S12To2012_190456-199011.root");
84 <  hpu_2012_me = (TH1D*)(puf_me->Get("puWeights"));
85 <  hpu_2012_me->SetDirectory(0);
86 <  puf_me->Close();
82 >  ControlFlags dummyCtrl;
83 >  // TFile * puf_me;
84 >  // puf_me = new TFile("data/pileup/PUWeights_S12To2012_190456-199011.root");
85 >  // hpu_2012_me = (TH1D*)(puf_me->Get("puWeights"));
86 >  // hpu_2012_me->SetDirectory(0);
87 >  // puf_me->Close();
88 >  // puf_me = new TFile("data/pileup/PUWeights_F11To2011.root");
89 >  // hpu_2011_me = (TH1D*)(puf_me->Get("puWeights"));
90 >  // hpu_2011_me->SetDirectory(0);
91 >  // puf_me->Close();
92  
93    vector<TString> cutstrs;
94    map<TString,int> cutvec;
# Line 89 | Line 98 | int main(int argc, char** argv)
98    FOFlags ctrl;
99    parse_foargs( argc, argv, ctrl );
100    ctrl.dump();
92  bool makeFakeTuples = (ctrl.extraArgs.Contains("makeFakeTuples"));
101    FusionMva fusion(ctrl.uncert);//"./weights/againstZZ-fusion_BDTG.weights.xml");
102    bool makeJetTuple=false; // jet tuple for vbf mva training
103    assert(ctrl.faketype=="SR"   || // plot events in signal region, if requested including ntuples of the extrapolation from 2P2F and 3P1F regions
# Line 98 | Line 106 | int main(int argc, char** argv)
106    if(ctrl.heavyFlavor) assert(ctrl.faketype=="2P2F");
107    if(ctrl.ssof) assert(ctrl.faketype=="2P2F");
108  
109 <  can = new TCanvas("can","can");
109 >  can = new TCanvas("can","can",700,500);
110  
111    FR_struct fr2011(ctrl.mufakefile2011,ctrl.elefakefile2011);
112    FR_struct fr2012(ctrl.mufakefile2012,ctrl.elefakefile2012);
# Line 117 | Line 125 | int main(int argc, char** argv)
125    map<TString,double> ssofRatios;
126    if(ctrl.ssof && !ctrl.writessofratio && !ctrl.plotWholeSample) ssofRatios = initSsofRatios(samplev);
127  
128 +  Angles angles; // NOTE: this is not the same as fs->angles -- the one in fs is filled with whichever choice of leptons was made in applyZPlusX
129    KinematicsStruct kine; // NOTE: this is not the same as fs->kine -- the one in fs is filled with whichever choice of leptons was made in applyZPlusX
130    JetInfoStruct ji;
131  
# Line 130 | Line 139 | int main(int argc, char** argv)
139      AngleTuple *jettuple;
140      if(makeJetTuple) {
141        jettuple = new AngleTuple( (const char*)(TString(cs->name)+"_pass.root").Data(), (const char*)"zznt");
142 +      jettuple->makeAngleBranch(angles);
143        jettuple->makeKinematicsBranch(kine);
144        jettuple->makeJetInfoBranch(ji);
145        const char *str1 = "evt";
# Line 141 | Line 151 | int main(int argc, char** argv)
151      resetCutVect(cutvec);
152      for(unsigned ifs=0; ifs<(cs->fsv).size(); ifs++) {
153        filestuff *fs = (cs->fsv)[ifs];
154 <      if(makeFakeTuples && fs->dataset_!="fakes") { // write a copy of the input trees for events that will be used for the SR fake prediction
154 >      if(ctrl.makeFakeTuples && fs->dataset_!="fakes") { // write a copy of the input trees for events that will be used for the SR fake prediction
155          TString fakefilename(fs->fname_);
156          fakefilename.ReplaceAll(".root","-fakes.root");
157 +        if(ctrl.hiStatFakes) fakefilename.ReplaceAll("-fakes.root","-fakes-histat.root");
158          fs->makeOutputFile(fakefilename);
159        }
160        cout << "\t" << fs->fname_; cout.flush();
# Line 167 | Line 178 | int main(int argc, char** argv)
178          double wgt=1;
179          if(!fs->isdata_) {
180            double xsWgt = fs->lumi_*xstab.Get(fs->dataset_)/fs->total_entries_;
181 <          double puWgt = getPUWeight(fs->era_,fs->info->npu);
182 <          if(fs->era_==2012) {
183 <            puWgt = hpu_2012_me->GetBinContent(hpu_2012_me->FindBin(fs->info->npu));
184 <            // puWgt = weightTrue2012(fs->info->npu);
185 <          }
181 >          cout << "WARNING: check the pu weihgs funciton here" << endl;
182 >          double puWgt = getPUWeight(fs->era_, "/029/", fs->info->npu);
183 >          // if(fs->era_==2012)
184 >          //   puWgt = hpu_2012_me->GetBinContent(hpu_2012_me->FindBin(fs->info->npu));
185 >          // else if(fs->era_==2011)
186 >          //   puWgt = hpu_2011_me->GetBinContent(hpu_2011_me->FindBin(fs->info->npu));
187 >          // else assert(0);
188            wgt = xsWgt*puWgt;
189            if(wgt!=wgt) cout << "xsWgt: " << xsWgt << " puWgt: " << puWgt << endl;
190          }
# Line 198 | Line 211 | int main(int argc, char** argv)
211          vector<pair<SimpleLepton,SimpleLepton> > z2cands;
212          vector<TString> types;
213          TString signFlavor;
214 <        if(ctrl.heavyFlavor) signFlavor = "";
215 <        else if(ctrl.ssof)   signFlavor = "SS-SF";
216 <        else                 signFlavor = "OS-SF";
214 >        if(ctrl.heavyFlavor)            signFlavor = "";
215 >        else if(ctrl.ssof)              signFlavor = "SS-SF";
216 >        else if(ctrl.hiStatFakes)       signFlavor = "signalExclude";
217 >        else                            signFlavor = "OS-SF";
218          double minMz2 = ctrl.heavyFlavor ? 0 : 12;
219          int hiPtPassingZ2 = findZ2CandidatesPassFail(fs->passingL, z2cands, types, signFlavor, minMz2, "pass",&best_z_indices); // signal region
220          int hiPtFailingZ2 = findZ2CandidatesPassFail(fs->failingL, z2cands, types, signFlavor, minMz2, "fail"); // 2P+2F
# Line 216 | Line 230 | int main(int argc, char** argv)
230            evtdata.Z2leptons.clear();
231            evtdata.Z2leptons.push_back(lep3);
232            evtdata.Z2leptons.push_back(lep4);
233 +          fillAngles(evtdata,angles);
234            fillKinematics(evtdata,kine);
235            lepFrs fwgts;
236            fillLeptonFakeWeights(fwgts, (fs->era_==2011) ? &fr2011 : &fr2012, lep3, lep4);
# Line 266 | Line 281 | int main(int argc, char** argv)
281              // llll events
282              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)
283              cutvec["fillPass"] += 1;
284 <            fillAllHists( ctrl, cs, channel, "obs", fs, kine, lep1, lep2, lep3, lep4, wgt);
284 >            fillAllHists( ctrl, cs, channel, "obs", fs, kine, angles, lep1, lep2, lep3, lep4, wgt);
285              if(doJets) fillAllJetHists( ctrl, cs, channel, "obs", fs, kine, lep1, lep2, lep3, lep4, fusion, goodJets, ji, wgt);
286  
287            } else if(types[iz2]=="fail") { // lljj events
# Line 292 | Line 307 | int main(int argc, char** argv)
307                hi    = wgt*(fwgts.fwgt_hi_3 + fwgts.fwgt_hi_4);
308              }
309  
310 <            if(makeFakeTuples && fs->dataset_!="fakes") {
310 >            if(ctrl.makeFakeTuples && fs->dataset_!="fakes") {
311                double fillwgt;
312                bool dofill=true;
313                if(ctrl.faketype=="2P2F") {
# Line 305 | Line 320 | int main(int argc, char** argv)
320                fillFakeTuple(cs,fs,evtdata,ientry,fillwgt);
321              }
322              cutvec["fillFail"] += 1;
323 <            fillAllHists( ctrl, cs, channel, "pred", fs, kine, lep1, lep2, lep3, lep4, centr, lo, hi);
323 >            fillAllHists( ctrl, cs, channel, "pred", fs, kine, angles, lep1, lep2, lep3, lep4, centr, lo, hi);
324              if(doJets) fillAllJetHists( ctrl, cs, channel, "pred", fs, kine, lep1, lep2, lep3, lep4, fusion, goodJets, ji, centr, lo, hi);
325  
326            } else if(types[iz2]=="PF") { // lllj events
327              if(fs->dataset_!="fakes" && iz2!=hiPtPfZ2) continue; // shouldn't have this when I extrapolate to signal region
328  
329 <            if(makeFakeTuples && fs->dataset_!="fakes" && ctrl.faketype=="3P1F") {
329 >            if(ctrl.makeFakeTuples && fs->dataset_!="fakes" && ctrl.faketype=="3P1F") {
330                assert(lep3.isLoose || lep4.isLoose);
331                assert(!(lep3.isLoose && lep4.isLoose));
332                double fwgt = lep3.isLoose ? fwgts.fwgt_4 : fwgts.fwgt_3;
# Line 323 | Line 338 | int main(int argc, char** argv)
338              }
339              
340              cutvec["fillPF"] += 1;
341 <            fillAllHists( ctrl, cs, channel, "PF", fs, kine, lep1, lep2, lep3, lep4, wgt);
341 >            fillAllHists( ctrl, cs, channel, "PF", fs, kine, angles, lep1, lep2, lep3, lep4, wgt);
342              if(doJets) fillAllJetHists( ctrl, cs, channel, "PF", fs, kine, lep1, lep2, lep3, lep4, fusion, goodJets, ji, wgt);
343            } else assert(0);
344          }
345        }
346        if(ctrl.writessofratio) fs->writeSsofRatios();
347        cout << "\t\t" << setw(7) << nDuplSkipped << " duplicate events skipped" << endl;
348 <      if(makeFakeTuples) {
348 >      if(ctrl.makeFakeTuples) {
349          fs->outFotuple->getFile()->cd();
350          fs->outFotuple->getTree()->Write();
351          fs->outtuple->WriteClose();
# Line 356 | Line 371 | int main(int argc, char** argv)
371      typev.push_back("2e2m");
372    }
373  
374 +  ofstream txtOutFile("fakes.txt",ios_base::app);
375 +  txtOutFile << "---> " << ctrl.faketype << " " << plotLabel << endl;
376    // loop over channels
377    for(unsigned itype=0; itype<typev.size(); itype++) {
378      TString type(typev[itype]);
379 <    gSystem->mkdir(ctrl.outdir+"/"+plotLabel+"/"+type,true);
380 <    TFile runHistFile(ctrl.outdir+"/"+plotLabel+"/"+type+"/runs.root","recreate");
379 >    TString fullOutDir(ctrl.outdir+"/"+plotLabel+"/"+type);
380 >    gSystem->mkdir(fullOutDir,true);
381 >    TFile runHistFile(fullOutDir+"/runs.root","recreate");
382      // loop over variables
383      map<TString,TH1D*>::iterator it_v;
384      for(it_v=(*(samplev[0]->hists)[type+"_obs"]).begin(); it_v!=(*(samplev[0]->hists)[type+"_obs"]).end(); it_v++) {
385        TString var((*it_v).first);
386 <      CPlot cplot(var,TString(""),(*(samplev[0]->hists)[type+"_obs"])[var]->GetXaxis()->GetTitle(),TString("events"),TString(ctrl.outdir+"/"+plotLabel+"/"+type+"/plots"));
386 >      CPlot cplot(var,TString(""),(*(samplev[0]->hists)[type+"_obs"])[var]->GetXaxis()->GetTitle(),TString("events"),TString(fullOutDir+"/plots"));
387        double fakeCounter=0;
388        double ymax=0;
389        // loop over csamples
372      ofstream txtOutFile("fakes.txt",ios_base::app);
390        for(unsigned isam=0; isam<samplev.size(); isam++) {
391          CSample *cs = samplev[isam];
392          map<TString,TH1D*> hs = setHistSet(cs,type,var);
# Line 393 | Line 410 | int main(int argc, char** argv)
410                cplot.AddHist1D(hs["pred_lo"], TString(  "stat lo: "+integral_str(hs["pred_lo"],2)),"hist",kRed,kDashed);
411                cplot.AddHist1D(hs["pred_hi"], TString(  "stat hi: "+integral_str(hs["pred_hi"],2)),"hist",kRed,kDashed);
412                if(var=="m4l") {
413 <                txtOutFile << type << ": " << integral_str(hs["pred"],3) << " (" << integral_str(hs["pred_lo"],2) << "," << integral_str(hs["pred_hi"],2) << ")" << endl;
413 >                txtOutFile << "  " << type << ": " << integral_str(hs["pred"],3) << " (" << integral_str(hs["pred_lo"],2) << "," << integral_str(hs["pred_hi"],2) << ")" << endl;
414                }
415                ymax = max(ymax,histMax(hs["pred"],hs["pred_lo"],hs["pred_hi"]));
416              }
# Line 402 | Line 419 | int main(int argc, char** argv)
419              double ratio = 0;//integrateHist(hs["PF"]) / integrateHist(hs["pred"]);
420              cplot.AddHist1D(hs["PF"],TString(cs->legend+": "+integral_str(hs["PF"],0)+", ratio: "+f_to_a(ratio)),"E",cs->color);
421              if(!ctrl.plotWholeSample) {
422 <              cplot.AddToStack(hs["pred"],TString(cs->legend+"(2P2F extrap.): "+integral_str(hs["pred"],1)), kRed);
422 >              cplot.AddToStack(hs["pred"],TString(cs->legend+"(2P2F extrap.): "+integral_str(hs["pred"],1)), kRed, -1);
423                ymax = max(ymax,histMax(hs["PF"],cplot.GetStack(),hs["pred"]));
424              } else {
425                ymax = max(ymax,hs["PF"]->GetMaximum());
# Line 419 | Line 436 | int main(int argc, char** argv)
436            if(ctrl.faketype=="3P1F")   mchist = hs["PF"];
437            assert(mchist);
438            bool stackMc = true;
439 <          if(stackMc) cplot.AddToStack(mchist,TString(cs->legend+": "+integral_str(mchist,2)),cs->color);
439 >          if(stackMc) cplot.AddToStack(mchist,TString(cs->legend+": "+integral_str(mchist,2)),cs->color,-1);
440            else        cplot.AddHist1D(mchist,TString(cs->legend +": "+integral_str(mchist,3)),"Ehist",cs->color);//cs->color);
441            if(cs->name=="zz") fakeCounter -= integrateHist(hs["PF"]);
442            ymax = max(ymax,histMax(mchist,cplot.GetStack()));
# Line 432 | Line 449 | int main(int argc, char** argv)
449            cplot.SetYRange(0,1.2*ymax);
450          if(ctrl.faketype=="3P1F") cplot.AddTextBox(TString("diff: "+f_to_a(fakeCounter)),.7,.5,.8,.6);
451        }
435      txtOutFile.close();
452        cplot.Draw(can,true,"png");
453        if(var.Contains("fusionMVA")) {
454          cplot.SetLogy();
# Line 441 | Line 457 | int main(int argc, char** argv)
457        }
458      }
459      runHistFile.Close();
460 <    makeHTML(ctrl,type,plotLabel);
460 >    makeHTML(ctrl,type,plotLabel,fullOutDir);
461    }
462 <
462 >  txtOutFile.close();
463 >      
464    fr2011.FR_struct::~FR_struct();
465    fr2012.FR_struct::~FR_struct();
466   }
# Line 483 | Line 500 | map<TString,map<TString,TH1D*>* > init_h
500  
501    for(it_h=hists.begin(); it_h!=hists.end(); it_h++) {
502      (*((*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();
503 <    (*((*it_h).second))["run"]          = new TH1D(TString("run") +"_"+(*it_h).first+str,";#bf{run};",          50,160800,196535);   (*((*it_h).second))["run"]->Sumw2();
503 >    (*((*it_h).second))["run"]          = new TH1D(TString("run") +"_"+(*it_h).first+str,";#bf{run};",          50,160800,203744/*196535*/);   (*((*it_h).second))["run"]->Sumw2();
504      (*((*it_h).second))["mZ1"]          = new TH1D(TString("mZ1") +"_"+(*it_h).first+str,";#bf{mZ1 [GeV]};",    20,40,120);          (*((*it_h).second))["mZ1"]->Sumw2();
505      (*((*it_h).second))["mZ2"]          = new TH1D(TString("mZ2") +"_"+(*it_h).first+str,";#bf{mZ2 [GeV]};",    30,0,115);           (*((*it_h).second))["mZ2"]->Sumw2();
506      (*((*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();
507      (*((*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();
508      (*((*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();
509      (*((*it_h).second))["m4l"]          = new TH1D(TString("m4l") +"_"+(*it_h).first+str,";#bf{m4l [GeV]};",    35,100,600);          (*((*it_h).second))["m4l"]->Sumw2();
510 <    (*((*it_h).second))["Z1pt"]         = new TH1D(TString("Z1pt") +"_"+(*it_h).first+str,";#bf{Z1pt [GeV]};",  20,0,200);           (*((*it_h).second))["Z1pt"]->Sumw2();
511 <    (*((*it_h).second))["ZZpt"]         = new TH1D(TString("ZZpt") +"_"+(*it_h).first+str,";#bf{ZZpt [GeV]};",  30,0,200);           (*((*it_h).second))["ZZpt"]->Sumw2();
510 >    // (*((*it_h).second))["Z1pt"]              = new TH1D(TString("Z1pt") +"_"+(*it_h).first+str,";#bf{Z1pt [GeV]};",  20,0,200);           (*((*it_h).second))["Z1pt"]->Sumw2();
511 >    // (*((*it_h).second))["ZZpt"]              = new TH1D(TString("ZZpt") +"_"+(*it_h).first+str,";#bf{ZZpt [GeV]};",  30,0,200);           (*((*it_h).second))["ZZpt"]->Sumw2();
512      (*((*it_h).second))["met"]          = new TH1D(TString("met") +"_"+(*it_h).first+str,";#bf{met [GeV]};",    30,0,100);           (*((*it_h).second))["met"]->Sumw2();
513  
514      (*((*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();
# Line 567 | Line 584 | map<TString,map<TString,TH1D*>* > init_h
584      (*((*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();
585      (*((*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();
586  
587 +    int nbins=35;
588 +    (*((*it_h).second))["costheta1"]    = new TH1D(TString("costheta1") +"_"+(*it_h).first+str,";#bf{costheta1};",                nbins,-1,1);          (*((*it_h).second))["costheta1"]->Sumw2();
589 +    (*((*it_h).second))["costheta2"]    = new TH1D(TString("costheta2") +"_"+(*it_h).first+str,";#bf{costheta2};",                nbins,-1,1);          (*((*it_h).second))["costheta2"]->Sumw2();
590 +    (*((*it_h).second))["costhetastar"] = new TH1D(TString("costhetastar") +"_"+(*it_h).first+str,";#bf{costhetastar};",          nbins,-1,1);          (*((*it_h).second))["costhetastar"]->Sumw2();
591 +    (*((*it_h).second))["Phi"]          = new TH1D(TString("Phi") +"_"+(*it_h).first+str,";#bf{Phi};",                            nbins,-3.15,3.15);          (*((*it_h).second))["Phi"]->Sumw2();
592 +    (*((*it_h).second))["Phi1"]         = new TH1D(TString("Phi1") +"_"+(*it_h).first+str,";#bf{Phi1};",                          nbins,-3.15,3.15);          (*((*it_h).second))["Phi1"]->Sumw2();
593 +
594 +    (*((*it_h).second))["pt4l"]         = new TH1D(TString("pt4l") +"_"+(*it_h).first+str,";#bf{pt4l/m4l};",                      nbins-7,0,0.5);          (*((*it_h).second))["pt4l"]->Sumw2();
595 +    (*((*it_h).second))["pt4l_log"]     = new TH1D(TString("pt4l_log") +"_"+(*it_h).first+str,";#bf{pt4l/m4l};",                  nbins,0,1.5);          (*((*it_h).second))["pt4l_log"]->Sumw2();
596 +    (*((*it_h).second))["y4l"]          = new TH1D(TString("y4l") +"_"+(*it_h).first+str,";#bf{y4l};",                            nbins,-2.4,2.4);      (*((*it_h).second))["y4l"]->Sumw2();
597 +    (*((*it_h).second))["Z1pt"]         = new TH1D(TString("Z1pt") +"_"+(*it_h).first+str,";#bf{Z1pt/m4l};",                      nbins,0,0.5);          (*((*it_h).second))["Z1pt"]->Sumw2();
598 +    (*((*it_h).second))["Z1pt_log"]     = new TH1D(TString("Z1pt_log") +"_"+(*it_h).first+str,";#bf{Z1pt/m4l};",                  nbins,0,1.5);          (*((*it_h).second))["Z1pt_log"]->Sumw2();
599 +    (*((*it_h).second))["Z2pt"]         = new TH1D(TString("Z2pt") +"_"+(*it_h).first+str,";#bf{Z2pt/m4l};",                      nbins,0,0.5);          (*((*it_h).second))["Z2pt"]->Sumw2();
600 +    (*((*it_h).second))["Z2pt_log"]     = new TH1D(TString("Z2pt_log") +"_"+(*it_h).first+str,";#bf{Z2pt/m4l};",                  nbins,0,1.5);          (*((*it_h).second))["Z2pt_log"]->Sumw2();
601 +
602 +    (*((*it_h).second))["ZZdotZ1"]      = new TH1D(TString("ZZdotZ1") +"_"+(*it_h).first+str,";#bf{ZZ #bullet Z1/(m4l*mZ1)};",    nbins,-.2,2.5);          (*((*it_h).second))["ZZdotZ1"]->Sumw2();
603 +    (*((*it_h).second))["ZZdotZ2"]      = new TH1D(TString("ZZdotZ2") +"_"+(*it_h).first+str,";#bf{ZZ #bullet Z2/(m4l*mZ2)};",    nbins,-1,3);          (*((*it_h).second))["ZZdotZ2"]->Sumw2();
604 +    (*((*it_h).second))["ZZdotZ1_log"]  = new TH1D(TString("ZZdotZ1_log") +"_"+(*it_h).first+str,";#bf{ZZ #bullet Z1/(m4l*mZ1)};",nbins,-1.5,15);          (*((*it_h).second))["ZZdotZ1_log"]->Sumw2();
605 +    (*((*it_h).second))["ZZdotZ2_log"]  = new TH1D(TString("ZZdotZ2_log") +"_"+(*it_h).first+str,";#bf{ZZ #bullet Z2/(m4l*mZ2)};",nbins,-1.5,15);          (*((*it_h).second))["ZZdotZ2_log"]->Sumw2();
606 +    (*((*it_h).second))["dphi1"]        = new TH1D(TString("dphi1") +"_"+(*it_h).first+str,";#bf{dphi1};",                        nbins,-1,1);          (*((*it_h).second))["dphi1"]->Sumw2();
607 +    (*((*it_h).second))["dphi2"]        = new TH1D(TString("dphi2") +"_"+(*it_h).first+str,";#bf{dphi2};",                        nbins,-1,1);          (*((*it_h).second))["dphi2"]->Sumw2();
608 +    (*((*it_h).second))["dphi1_log"]    = new TH1D(TString("dphi1_log") +"_"+(*it_h).first+str,";#bf{dphi1};",                    nbins,-1,1);          (*((*it_h).second))["dphi1_log"]->Sumw2();
609 +    (*((*it_h).second))["dphi2_log"]    = new TH1D(TString("dphi2_log") +"_"+(*it_h).first+str,";#bf{dphi2};",                    nbins,-1,1);          (*((*it_h).second))["dphi2_log"]->Sumw2();
610 +
611      (*((*it_h).second))["fusionMVA"]            = new TH1D(TString("fusionMVA")+"_"+(*it_h).first+str,";#bf{MVA output};",        100,-1,1);      (*((*it_h).second))["fusionMVA"]->Sumw2();
612      (*((*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();
613      (*((*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();
# Line 577 | Line 618 | map<TString,map<TString,TH1D*>* > init_h
618    return hists;
619   }
620   //--------------------------------------------------------------------------------------------------
621 < void makeHTML(FOFlags &ctrl, TString type, TString plotLabel)
621 > void makeHTML(FOFlags &ctrl, TString type, TString plotLabel, TString fullOutDir)
622   {
623    TString tmpString(plotLabel);
624    tmpString.ReplaceAll("/"," ");
625    TString title(ctrl.faketype+", "+tmpString+", "+type);
626 <  TString htmlfname(ctrl.outdir+"/"+plotLabel+"/"+type+"/plots.html");
626 >  TString htmlfname(fullOutDir+"/plots.html");
627    ofstream htmlfile(htmlfname);
628  
629    htmlfile << "<!DOCTYPE html" << endl;
# Line 636 | Line 677 | void makeHTML(FOFlags &ctrl, TString typ
677    htmlfile << "</html>" << endl;
678    htmlfile.close();
679  
680 +  TString anglefname(htmlfname);
681 +  anglefname.ReplaceAll("plots.html","angleplots.html");
682 +  htmlfile.open(anglefname);
683 +
684 +  htmlfile << "<!DOCTYPE html" << endl;
685 +  htmlfile << "    PUBLIC \"-//W3C//DTD HTML 3.2//EN\">" << endl;
686 +  htmlfile << "<html>" << endl;
687 +
688 +  htmlfile << "<head><title>"+title+"</title></head>" << endl;
689 +  htmlfile << "<body bgcolor=\"000000\">" << endl;
690 +  htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">"+title+"</h3>" << endl;
691 +
692 +  htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">Angles & Co.</h3>" << endl;
693 +  htmlfile << "<hr />" << endl;
694 +  htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;  
695 +  htmlfile << "</table>" << endl;
696 +
697 +  htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">Angles:</h3>" << endl;
698 +  htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;  
699 +
700 +  htmlfile << "<tr>" << endl;
701 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/costheta1.png\"><img src=\"plots/costheta1.png\" alt=\"plots/costheta1.png\" width=\"100%\"></a></td>" << endl;
702 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/costheta2.png\"><img src=\"plots/costheta2.png\" alt=\"plots/costheta2.png\" width=\"100%\"></a></td>" << endl;
703 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/costhetastar.png\"><img src=\"plots/costhetastar.png\" alt=\"plots/costhetastar.png\" width=\"100%\"></a></td>" << endl;
704 +  htmlfile << "<td width=\"25%\"></td>" << endl;
705 +  htmlfile << "</tr>" << endl;
706 +
707 +  htmlfile << "<tr>" << endl;
708 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/Phi.png\"><img src=\"plots/Phi.png\" alt=\"plots/Phi.png\" width=\"100%\"></a></td>" << endl;
709 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/Phi1.png\"><img src=\"plots/Phi1.png\" alt=\"plots/Phi1.png\" width=\"100%\"></a></td>" << endl;
710 +  htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
711 +  htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
712 +  htmlfile << "</tr>" << endl;
713 +
714 +  htmlfile << "</table>" << endl;
715 +  htmlfile << "<hr />" << endl;
716 +  htmlfile << "<h3 style=\"text-align:left; color:DD6600;\">Boson pt variables: " << endl;
717 +  htmlfile << "<table border=\"0\" cellspacing=\"5\" width=\"100%\">" << endl;  
718 +
719 +  htmlfile << "<tr>" << endl;
720 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/y4l.png\"><img src=\"plots/y4l.png\" alt=\"plots/y4l.png\" width=\"100%\"></a></td>" << endl;
721 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt4l.png\"><img src=\"plots/pt4l.png\" alt=\"plots/pt4l.png\" width=\"100%\"></a></td>" << endl;
722 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/pt4l_log.png\"><img src=\"plots/pt4l_log.png\" alt=\"plots/pt4l_log.png\" width=\"100%\"></a></td>" << endl;
723 +  htmlfile << "<td width=\"25%\"><a></a></td>" << endl;
724 +  htmlfile << "<tr>" << endl;
725 +
726 +  htmlfile << "</tr>" << endl;
727 +  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;
728 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/Z2pt.png\"><img src=\"plots/Z2pt.png\" alt=\"plots/Z2pt.png\" width=\"100%\"></a></td>" << endl;
729 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/Z1pt_log.png\"><img src=\"plots/Z1pt_log.png\" alt=\"plots/Z1pt_log.png\" width=\"100%\"></a></td>" << endl;
730 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/Z2pt_log.png\"><img src=\"plots/Z2pt_log.png\" alt=\"plots/Z2pt_log.png\" width=\"100%\"></a></td>" << endl;
731 +  htmlfile << "</tr>" << endl;
732 +
733 +  htmlfile << "<tr>" << endl;
734 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ZZdotZ1.png\"><img src=\"plots/ZZdotZ1.png\" alt=\"plots/ZZdotZ1.png\" width=\"100%\"></a></td>" << endl;
735 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ZZdotZ2.png\"><img src=\"plots/ZZdotZ2.png\" alt=\"plots/ZZdotZ2.png\" width=\"100%\"></a></td>" << endl;
736 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ZZdotZ1_log.png\"><img src=\"plots/ZZdotZ1_log.png\" alt=\"plots/ZZdotZ1_log.png\" width=\"100%\"></a></td>" << endl;
737 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/ZZdotZ2_log.png\"><img src=\"plots/ZZdotZ2_log.png\" alt=\"plots/ZZdotZ2_log.png\" width=\"100%\"></a></td>" << endl;
738 +  htmlfile << "</tr>" << endl;
739 +
740 +  htmlfile << "<tr>" << endl;
741 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dphi1.png\"><img src=\"plots/dphi1.png\" alt=\"plots/dphi1.png\" width=\"100%\"></a></td>" << endl;
742 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dphi2.png\"><img src=\"plots/dphi2.png\" alt=\"plots/dphi2.png\" width=\"100%\"></a></td>" << endl;
743 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dphi1_log.png\"><img src=\"plots/dphi1_log.png\" alt=\"plots/dphi1_log.png\" width=\"100%\"></a></td>" << endl;
744 +  htmlfile << "<td width=\"25%\"><a target=\"_blank\" href=\"plots/dphi2_log.png\"><img src=\"plots/dphi2_log.png\" alt=\"plots/dphi2_log.png\" width=\"100%\"></a></td>" << endl;
745 +  htmlfile << "</tr>" << endl;
746 +
747 +
748 +  htmlfile << "</table>" << endl;
749 +
750 +  htmlfile << "</body>" << endl;
751 +  htmlfile << "</html>" << endl;
752 +  htmlfile.close();
753 +
754    TString leptonfname(htmlfname);
755    leptonfname.ReplaceAll("plots.html","leptonplots.html");
756    htmlfile.open(leptonfname);
# Line 859 | Line 974 | void fillHist(CSample *cs, TString chann
974    }
975   }
976   //----------------------------------------------------------------------------------------
977 < void fillAllHists(FOFlags ctrl, CSample *cs, TString channel, TString type, filestuff *fs, KinematicsStruct kine,
977 > void fillAllHists(FOFlags ctrl, CSample *cs, TString channel, TString type, filestuff *fs, KinematicsStruct kine, Angles angles,
978                    SimpleLepton lep1, SimpleLepton lep2, SimpleLepton lep3, SimpleLepton lep4,
979                    double wgt, double wgt_lo, double wgt_hi)
980   {
# Line 871 | Line 986 | void fillAllHists(FOFlags ctrl, CSample
986    fillHist( cs, channel, type, "m4l_lo"      , kine.m4l       , wgt, wgt_lo, wgt_hi);                
987    fillHist( cs, channel, type, "m4l_med"     , kine.m4l       , wgt, wgt_lo, wgt_hi);                
988    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);                
989    fillHist( cs, channel, type, "met"         , fs->info->met  , wgt, wgt_lo, wgt_hi);                
990    fillHist( cs, channel, type, "ip3ds_l1"    , lep1.ip3dSig   , wgt, wgt_lo, wgt_hi);
991    fillHist( cs, channel, type, "ip3ds_l2"    , lep2.ip3dSig   , wgt, wgt_lo, wgt_hi);
# Line 900 | Line 1013 | void fillAllHists(FOFlags ctrl, CSample
1013    fillHist( cs, channel, type, "eta_l4"      , lep4.vec.Eta() , wgt, wgt_lo, wgt_hi);
1014    fillHist( cs, channel, type, "dR_l3l4_lo"  , dr(lep3,lep4)  , wgt, wgt_lo, wgt_hi);
1015    fillHist( cs, channel, type, "dR_l3l4"     , dr(lep3,lep4)  , wgt, wgt_lo, wgt_hi);
1016 +
1017 +  fillHist( cs, channel, type, "costheta1"      , angles.costheta1                  ,   wgt, wgt_lo, wgt_hi);
1018 +  fillHist( cs, channel, type, "costheta2"      , angles.costheta2                  ,   wgt, wgt_lo, wgt_hi);
1019 +  fillHist( cs, channel, type, "costhetastar"   , angles.costhetastar               ,   wgt, wgt_lo, wgt_hi);
1020 +  fillHist( cs, channel, type, "Phi"            , angles.Phi                        ,   wgt, wgt_lo, wgt_hi);
1021 +  fillHist( cs, channel, type, "Phi1"           , angles.Phi1                       ,   wgt, wgt_lo, wgt_hi);
1022 +  fillHist( cs, channel, type, "pt4l"           , kine.ZZpt/kine.m4l                ,   wgt, wgt_lo, wgt_hi);
1023 +  fillHist( cs, channel, type, "pt4l_log"       , kine.ZZpt/kine.m4l                ,   wgt, wgt_lo, wgt_hi);
1024 +  fillHist( cs, channel, type, "y4l"            , kine.ZZy                          ,   wgt, wgt_lo, wgt_hi);
1025 +  fillHist( cs, channel, type, "Z1pt"           , kine.Z1pt/kine.m4l                ,   wgt, wgt_lo, wgt_hi);
1026 +  fillHist( cs, channel, type, "Z1pt_log"       , kine.Z1pt/kine.m4l                ,   wgt, wgt_lo, wgt_hi);
1027 +  fillHist( cs, channel, type, "Z2pt"           , kine.Z2pt/kine.m4l                ,   wgt, wgt_lo, wgt_hi);
1028 +  fillHist( cs, channel, type, "Z2pt_log"       , kine.Z2pt/kine.m4l                ,   wgt, wgt_lo, wgt_hi);
1029 +  fillHist( cs, channel, type, "ZZdotZ1"        , kine.ZZdotZ1/(kine.m4l*kine.mZ1)  ,   wgt, wgt_lo, wgt_hi);
1030 +  fillHist( cs, channel, type, "ZZdotZ2"        , kine.ZZdotZ2/(kine.m4l*kine.mZ2)  ,   wgt, wgt_lo, wgt_hi);
1031 +  fillHist( cs, channel, type, "ZZdotZ1_log"    , kine.ZZdotZ1/(kine.m4l*kine.mZ1)  ,   wgt, wgt_lo, wgt_hi);
1032 +  fillHist( cs, channel, type, "ZZdotZ2_log"    , kine.ZZdotZ2/(kine.m4l*kine.mZ2)  ,   wgt, wgt_lo, wgt_hi);
1033 +  fillHist( cs, channel, type, "dphi1"          , kine.ZZptZ1ptCosDphi              ,   wgt, wgt_lo, wgt_hi);
1034 +  fillHist( cs, channel, type, "dphi2"          , kine.ZZptZ2ptCosDphi              ,   wgt, wgt_lo, wgt_hi);
1035 +  fillHist( cs, channel, type, "dphi1_log"      , kine.ZZptZ1ptCosDphi              ,   wgt, wgt_lo, wgt_hi);
1036 +  fillHist( cs, channel, type, "dphi2_log"      , kine.ZZptZ2ptCosDphi              ,   wgt, wgt_lo, wgt_hi);
1037 +
1038   }
1039   //----------------------------------------------------------------------------------------
1040   void fillAllJetHists( FOFlags ctrl, CSample *cs, TString channel, TString type, filestuff *fs, KinematicsStruct kine,
# Line 1037 | Line 1172 | map<TString,TH1D*> setHistSet(CSample *c
1172   void fillFakeTuple(CSample *cs, filestuff *fs, EventData evtdata, unsigned ientry, double fillweight)
1173   {
1174    fs->getentry(ientry,"","zznt"); // make sure we've got this entry for all the branches
1175 +  fillAngles(evtdata,*fs->angles);
1176    fillKinematics(evtdata,*fs->kine); // reminder: kine has the fake information, while fs->kine *had*, until this line, whatever ZPlusX put in it
1177    fs->weights->w = fillweight;
1178    fs->outtuple->Fill();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines