ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/Plotting_Functions.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/Plotting_Functions.C (file contents):
Revision 1.57 by buchmann, Thu Sep 6 10:19:18 2012 UTC vs.
Revision 1.66 by buchmann, Thu Sep 13 20:32:52 2012 UTC

# Line 89 | Line 89 | void find_one_peak_combination(TCut spec
89  
90   void find_peaks(float &MCPeak,float &MCPeakError, float &DataPeak, float &DataPeakError, stringstream &result, bool doPUreweighting, stringstream &datajzb, stringstream &mcjzb, string sSpecialCut="", bool SwitchOffNJetsCut=false)
91   {
92 +  bool overunderflowstatus=addoverunderflowbins;
93    switch_overunderflow(false);
94    
95    TCut SpecialCut("mll>=0");
# Line 160 | Line 161 | void find_peaks(float &MCPeak,float &MCP
161      MCPeakError=mcpeakerr;
162      DataPeak=datapeak;
163      DataPeakError=datapeakerr;
164 <    
164 <    switch_overunderflow(true);
165 <  
164 >    switch_overunderflow(overunderflowstatus);
165   }
166  
167   void make_special_obs_pred_mll_plot(string datajzb, string mcjzb, float jzbthreshold, float binWidth = 5.0) {
# Line 373 | Line 372 | void draw_ratio_plot(TH1* hdata, THStack
372   }
373  
374   float make_one_OFSF_plot(string variable, string addcut, string legendTitle, int nbins, float min, float max, float ymax, bool logscale,
375 <                        string xlabel, string filename, bool plotratio=true, bool loadlastminmax=false, float legendPosition=0.55) {
375 >                        string xlabel, string filename, float legendPosition=0.55) {
376  
377    TCut ibasiccut=basiccut;
378    bool draw_separation_lines=false;
# Line 391 | Line 390 | float make_one_OFSF_plot(string variable
390    rcan->SetLogy(logscale);
391    rcan->cd();
392  
393 +  std::cout << "OF/SF comparison: variable = " << variable << ", cut = " << cutSF.GetTitle() << std::endl;
394    TH1F *datahistoSF = allsamples.Draw("datahistoSF",variable,nbins,min,max, xlabel, "events",cutSF,data,luminosity);
395    TH1F *datahistoOF = allsamples.Draw("datahistoOF",variable,nbins,min,max, xlabel, "events",cutOF,data,luminosity);
396 <  string signal("LM3");
397 <  TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
398 <  int idx = signalsamples.FindSample(signal)[0];
399 <  (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cutSF);
400 <  signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
401 <  signalhisto->SetLineColor((signalsamples.collection)[idx].samplecolor);
402 <  signalhisto->SetLineStyle(2);
396 > //   string signal("LM3");
397 > //   TH1F* signalhisto = new TH1F("signalhisto",signal.c_str(),nbins,min,max);
398 > //   int idx = signalsamples.FindSample(signal)[0];
399 > //   (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cutSF);
400 > //   signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
401 > //   signalhisto->SetLineColor((signalsamples.collection)[idx].samplecolor);
402 > //   signalhisto->SetLineStyle(2);
403    datahistoSF->SetMarkerSize(DataMarkerSize);
404    datahistoOF->SetLineColor(kRed);
405  
# Line 429 | Line 429 | float make_one_OFSF_plot(string variable
429    } else {
430      mleg->AddEntry((TObject*)0, "", "");
431    }
432 <  mleg->AddEntry(signalhisto, "LM3", "L");
432 >  //mleg->AddEntry(signalhisto, "LM3", "L");
433  
434    datahistoSF->Draw("E1");
435    if (datahistoOF->Integral()>0) datahistoOF->Draw("HIST,SAMES");
436 <  signalhisto->Draw("HIST,SAMES");
436 >  //signalhisto->Draw("HIST,SAMES");
437    mleg->Draw();
438    DrawPrelim();
439 <  if (datahistoOF->Integral()>0) save_with_ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
440 <  else CompleteSave(ckin, "SFOF/" + filename);
439 >  if (datahistoOF->Integral()>0) {
440 >    save_with_ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
441 >  } else {
442 >    CompleteSave(rcan, "SFOF/" + filename);
443 >    delete rcan;
444 >  }
445  
446    datahistoSF->Delete();
447    datahistoOF->Delete();
448 <  signalhisto->Delete();
448 >  //signalhisto->Delete();
449    delete mleg;
450    delete ckin;
451  
# Line 488 | Line 492 | float make_data_comparison_plot(string v
492    data1->GetYaxis()->CenterTitle();
493  
494    TLegend *mleg = make_legend("",legendPosition,0.7,false,legendPosition+0.2);
495 <  mleg->AddEntry(data1, "Old 5/fb", "PL");
496 <  mleg->AddEntry(data2, "New x/fb", "L");
495 >  mleg->AddEntry(data1, "New 3.8/fb", "PL");
496 >  mleg->AddEntry(data2, "Old 5.1/fb", "L");
497  
498    data1->Draw("E1");
499    data2->Draw("HIST,SAMES");
# Line 507 | Line 511 | float make_data_comparison_plot(string v
511   void make_OFSF_plots(string variable, string addcut, int nbins, float min, float max, bool logscale,
512                       string xlabel, string filename, float legendPosition=0.55) {
513  
514 <  string mllcuts[] = { "mll>20","mll>20&&mll<70", "mll>75&&mll<105", "mll>120" };
515 <  string mllcutname[] = { "m_{ll} > 20 GeV", "20 < m_{ll} < 70 GeV", "75 < m_{ll} < 105 GeV", "m_{ll} > 120 GeV" };
514 >  string mllcuts[] = { "mll>15","mll>15&&mll<70", "mll>75&&mll<105", "mll>120" };
515 >  string mllcutname[] = { "m_{ll} > 15 GeV", "15 < m_{ll} < 70 GeV", "70 < m_{ll} < 110 GeV", "m_{ll} > 120 GeV" };
516    string plotname[] = {"_all","_low","_peak","_high"};
517    float ymax;
518  
# Line 518 | Line 522 | void make_OFSF_plots(string variable, st
522    for ( int i=start; i<4; ++i ) {
523      if ( addcut != "" ) mllcuts[i] += "&&"+addcut;
524      if ( i==start ) {
525 <      ymax = make_one_OFSF_plot(variable, mllcuts[i],            mllcutname[i], nbins, min, max, -1, logscale, xlabel,
525 >      ymax = make_one_OFSF_plot(variable, mllcuts[i], mllcutname[i], nbins, min, max, -1, logscale, xlabel,
526                           filename+plotname[i], legendPosition );
527      } else {
528 <      make_one_OFSF_plot(variable, mllcuts[i],            mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
528 >      make_one_OFSF_plot(variable, mllcuts[i],        mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
529                           filename+plotname[i], legendPosition );
530      }
531      make_one_OFSF_plot(variable, "id1==1&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
# Line 562 | Line 566 | void make_kin_plot(string variable, stri
566    //Step 2: Refine the cut
567    TCut cut;
568    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
569 <  if(filename=="nJets" || filename=="nJets_inclusive") cut=cutmass&&cutOSSF&&ibasiccut;
570 <  if(filename=="nJets_osof" || filename=="nJets_osof_inclusive") cut=cutmass&&cutOSOF&&ibasiccut;
569 >  if(filename=="nJets" || filename=="nJets_inclusive" || filename=="nJets_met100" || filename=="nJets_inclusive_met100") cut=cutmass&&cutOSSF&&ibasiccut;
570 >  if(filename=="nJets_osof" || filename=="nJets_osof_inclusive" || filename=="nJets_osof_met100" || filename=="nJets_osof_inclusive_met100") cut=cutmass&&cutOSOF&&ibasiccut;
571    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
572 <  if(filename=="mll") {
572 >  if(filename=="mll"||filename=="mll_met100") {
573          cut=cutOSSF&&cutnJets&&ibasiccut;
574          draw_separation_lines=true;
575    }
576 <  if(filename=="mll_ee") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==0";
577 <  if(filename=="mll_mm") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
578 <  if(filename=="mll_osof") {
576 >  if(filename=="mll_ee"||filename=="mll_ee_met100") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==0";
577 >  if(filename=="mll_mm"||filename=="mll_mm_met100") cut=cutOSSF&&cutnJets&&ibasiccut&&"id1==1";
578 >  if(filename=="mll_osof"||filename=="mll_osof_met100") {
579          cut=cutOSOF&&cutnJets&&ibasiccut;
580          draw_separation_lines=true;
581    }
# Line 579 | Line 583 | void make_kin_plot(string variable, stri
583    if(Contains(filename,"mll_ee_above")) cut=cut&&"id1==0";
584    if(Contains(filename,"mll_mm_above")) cut=cut&&"id1==1";
585    if(Contains(filename,"mll_osof_aboveJZB")) cut=cutOSOF&&cutnJets&&ibasiccut;
586 <  if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutmass&&cutOSSF;
587 <  if(filename=="mll_inclusive_osof") cut=cutmass&&cutOSOF;
588 <  if(filename=="mll_inclusive_ee") cut=cutmass&&cutOSSF&&"id1==0";
589 <  if(filename=="mll_inclusive_mm") cut=cutmass&&cutOSSF&&"id1==1";
586 >  if(filename=="mll_inclusive"||filename=="mll_inclusive_highrange") cut=cutOSSF;
587 >  if(filename=="mll_inclusive_osof") cut=cutOSOF;
588 >  if(filename=="mll_inclusive_ee") cut=cutOSSF&&"id1==0";
589 >  if(filename=="mll_inclusive_mm") cut=cutOSSF&&"id1==1";
590    if(filename=="pfJetGoodEta_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
591    if(filename=="pfJetGoodPt_0") cut=cutOSSF&&cutmass&&ibasiccut&&cutnJets;
592    if(filename=="numVtx") cut=cutmass&&ibasiccut;
# Line 603 | Line 607 | void make_kin_plot(string variable, stri
607    if (logscale) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
608    else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
609  
610 <  cout << "******** Cut used : " << (const char*) cut << endl;
610 >  cout << "******** Cut used : " << (const char*) cut << " for plot " << filename << endl;
611    if(loadlastminmax) {
612          datahisto->SetMinimum(lastrange_min);
613          datahisto->SetMaximum(lastrange_max);
# Line 691 | Line 695 | void make_kin_plot(string variable, stri
695          else CompleteSave(ckin,"kin/"+filename);
696    }
697    datahisto->Delete();
698 +  delete signalhisto;
699    delete ckin;
700   }
701  
# Line 741 | Line 746 | void make_JES_plot(TCut cut, string name
746  
747   void do_kinematic_plots(string mcjzb, string datajzb, bool doPF=false)
748   {
749 + //  switch_overunderflow(true);
750    bool dolog=true;
751    bool nolog=false;
752  
753 <  bool doOFSF = false;
754 <  bool doKin  = false;
753 >  bool doOFSF = true;
754 >  bool doKin  = true;
755    bool doDataComp = true;
756    
757  
# Line 760 | Line 766 | void do_kinematic_plots(string mcjzb, st
766    if ( doOFSF ) {
767      make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll");
768  
769 <    make_OFSF_plots("pfJetGoodNum40",     "met[4]>100", 7, 3, 10, true, "#(jets)", "njets");
770 <    make_OFSF_plots("pfJetGoodNum40",     "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
771 <    make_OFSF_plots("pfJetGoodNum40",     "met[4]>100&&pfJetGoodNumBtag30>0", 7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
769 >    make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
770 >    make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
771 >    make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
772  
773      make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
774 +    make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
775 +
776      make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
777      make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
778      //  make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
# Line 786 | Line 794 | void do_kinematic_plots(string mcjzb, st
794  
795    if ( doDataComp && !PlottingSetup::openBox ) {
796      TCut mllCut("");
797 <    if ( !PlottingSetup::openBox ) mllCut = "mll>120";
797 >    float massmin = 15.;
798 >    float massmax = 315;
799 >    int massnbins = 60;
800 >    if ( !PlottingSetup::openBox ) {
801 >      mllCut = "mll>120";
802 >      massmin = 120;
803 >      massmax = 360;
804 >      massnbins = 14;
805 >    }
806  
807      TCut cutSignal = cutmass&&cutnJets&&"met[4]>100";
808 <    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut,           60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig");
809 <    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"id1==0", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_ee");
794 <    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"id1==1", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_mm");
795 <
796 <    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30==0",           60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_btagVeto");
797 <    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"id1==0&&pfJetGoodNumBtag30==0", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_ee_btagVeto");
798 <    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"id1==1&&pfJetGoodNumBtag30==0", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_mm_btagVeto");
799 <
800 <    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",           60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_AtLeastOneBJet");
801 <    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"id1==0&&pfJetGoodNumBtag30>0", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_ee_AtLeastOneBJet");
802 <    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"id1==1&&pfJetGoodNumBtag30>0", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_sig_mm_AtLeastOneBJet");
808 >    make_data_comparison_plot("mll", cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive");
809 >    make_data_comparison_plot("mll", cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_inclusive");
810  
811 <    make_data_comparison_plot("mll", cutOSOF&&cutSignal, 60, 20., 320.,-1., false, "m_{ll}", "mll_OF_sig");
812 <    make_data_comparison_plot("mll", cutmass&&"met[4]>100&&met[4]<150&&pfJetGoodNum40<3", 60, 20., 320.,-1., false, "m_{ll}", "mll_SF_CR");
811 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig");
812 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30==0", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_btagVeto");
813 >    make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",  massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_AtLeastOneBJet");
814 >
815 >    make_data_comparison_plot("mll", mllCut&&cutOSOF&&cutSignal, massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig");
816 >    make_data_comparison_plot("mll", cutmass&&cutOSSF&&"met[4]>100&&met[4]<150&&pfJetGoodNum40==2", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_CR");
817 >    make_data_comparison_plot("mll", cutmass&&cutOSOF&&"met[4]>100&&met[4]<150&&pfJetGoodNum40==2", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_CR");
818 >
819 >    make_data_comparison_plot("pfJetGoodNum40", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_SF_sig");
820 >    make_data_comparison_plot("pfJetGoodNum40", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_OF_sig");
821 >    make_data_comparison_plot("pfJetGoodNumBtag30", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_SF_sig");
822 >    make_data_comparison_plot("pfJetGoodNumBtag30", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_OF_sig");
823    }
824  
825  
# Line 811 | Line 828 | void do_kinematic_plots(string mcjzb, st
828      if ( !PlottingSetup::openBox ) mllCut = "&&mll>120";
829  
830      // Plots in signal region
831 <    make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
832 <    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
833 <    make_kin_plot("mll","mll>20&&met[4]>100",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
834 <    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
835 <    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
831 > //     make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
832 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
833 >    make_kin_plot("mll","mll>20",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
834 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
835 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm",doPF,true);
836 >    
837 >    make_kin_plot("pfJetGoodNum40",mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
838 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
839 >    
840 >    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_met100",doPF,true);
841 >    make_kin_plot("mll","mll>20&&met[4]>100",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_met100",doPF,true,true);
842 >    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee_met100",doPF,true);
843 >    make_kin_plot("mll","mll>20&&met[4]>100"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_mm_met100",doPF,true);
844      
845 <    make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
846 <    make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
845 >    make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets_met100",doPF);
846 >    make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof_met100",doPF);
847  
848      // Further inclusive invariant mass plots
849      make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
# Line 881 | Line 906 | void do_kinematic_plots(string mcjzb, st
906   //   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
907   //   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
908  
909 +  switch_overunderflow(false);
910   }
911  
912   void make_comp_plot( string var, string xlabel, string filename, float jzbcut, string mcjzb, string datajzb,
# Line 950 | Line 976 | void region_comparison_plots(string mcjz
976  
977   //  switch_overunderflow(true);  // switching overflow/underflow bins on
978      
979 <  
979 >  switch_overunderflow(true);
980      flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- the arguments changed
981    for(int ijzb=0;ijzb<(int)jzb_cuts.size();ijzb++) {
982      float jzbcut=jzb_cuts[ijzb]; // Comparison plots are done for this JZB cut
# Line 1267 | Line 1293 | if you want to start from scratch (witho
1293  
1294   void do_prediction_plot(string jzb, TCanvas *globalcanvas, float high, int use_data, bool overlay_signal = false,string subdir="" )
1295   {
1296 < //  switch_overunderflow(true);
1296 >  
1297    bool is_data=false;
1298    bool use_signal=false;
1299    if(use_data==1) is_data=true;
1300    if(use_data==2) use_signal=true;
1301 <  int nbins=50;//100;
1302 <  if(is_data) nbins=50;
1301 >  int nbins=int(high/10);//100;
1302 >  if(is_data) nbins=int(high/10);
1303    float low=0;
1304 <  float hi=500;
1304 >  float hi=high;
1305 >  
1306 >  stringstream cutpositiveS;
1307 >  cutpositiveS << "(" << jzb << ">0)";
1308 >  TCut cutpositive(cutpositiveS.str().c_str());
1309 >  stringstream cutnegativeS;
1310 >  cutnegativeS << "(" << jzb << "<0)";
1311 >  TCut cutnegative(cutnegativeS.str().c_str());
1312 >  
1313    
1314    TH1F *blankback = new TH1F("blankback","blankback",int(high/10),0,high);
1315 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1316 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1317 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1318 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1315 >  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1316 >  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1317 >  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1318 >  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1319  
1320    blankback->GetXaxis()->SetTitle(RcorrJZBeemm->GetXaxis()->GetTitle());
1321    blankback->GetYaxis()->SetTitle(RcorrJZBeemm->GetYaxis()->GetTitle());
# Line 1296 | Line 1330 | void do_prediction_plot(string jzb, TCan
1330    
1331    TH1F *RcorrJZBeemmNoS;
1332  
1333 <    //these are for the ratio
1334 <  
1335 <  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1336 <  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1337 <  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1304 <  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1333 >  //these are for the ratio
1334 >  TH1F *JRcorrJZBeemm   = allsamples.Draw("JRcorrJZBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1335 >  TH1F *JLcorrJZBeemm   = allsamples.Draw("JLcorrJZBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1336 >  TH1F *JRcorrJZBem     = allsamples.Draw("JRcorrJZBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1337 >  TH1F *JLcorrJZBem     = allsamples.Draw("JLcorrJZBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&cutmass&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1338    
1339    TH1F *JRcorrJZBSBem;
1340    TH1F *JLcorrJZBSBem;
1341    TH1F *JRcorrJZBSBeemm;
1342    TH1F *JLcorrJZBSBeemm;
1343    
1344 <  if(use_data==2 || overlay_signal) RcorrJZBeemmNoS = allsamples.Draw("RcorrJZBeemmNoS",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,false);
1344 >  if(use_data==2 || overlay_signal) RcorrJZBeemmNoS = allsamples.Draw("RcorrJZBeemmNoS",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,false);
1345  
1346    
1347    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1348 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1349 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1350 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1351 <    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1348 >    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSBem",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1349 >    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSBem",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1350 >    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1351 >    LcorrJZBSBeemm = allsamples.Draw("LcorrJZBSBeemm",("-"+jzb).c_str(),nbins,low,hi, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1352      
1353      //these are for the ratio
1354 <    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1355 <    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1356 <    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1357 <    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1354 >    JRcorrJZBSBem   = allsamples.Draw("JRcorrJZBSBem",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1355 >    JLcorrJZBSBem   = allsamples.Draw("JLcorrJZBSBem",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSOF&&cutnJets,is_data, luminosity,use_signal);
1356 >    JRcorrJZBSBeemm = allsamples.Draw("JRcorrJZBSBeemm",jzb.c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutpositive&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1357 >    JLcorrJZBSBeemm = allsamples.Draw("JLcorrJZBSBeemm",("-"+jzb).c_str(),PlottingSetup::global_ratio_binning, "JZB [GeV]", "events", cutnegative&&sidebandcut&&cutOSSF&&cutnJets,is_data, luminosity,use_signal);
1358    }
1359    
1360    TH1F *lm4RcorrJZBeemm;
1361 <  if(overlay_signal || use_data == 2 || use_data == 1) lm4RcorrJZBeemm = allsamples.Draw("lm4RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,is_data, luminosity,allsamples.FindSample("LM"));
1361 >  if(overlay_signal || use_data == 2 || use_data == 1) lm4RcorrJZBeemm = allsamples.Draw("lm4RcorrJZBSBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutpositive&&cutmass&&cutOSSF&&cutnJets,is_data, luminosity,allsamples.FindSample("LM"));
1362    
1363    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed.
1364    
# Line 1389 | Line 1422 | void do_prediction_plot(string jzb, TCan
1422    SQRT(BpredSys);
1423    BpredSys->Divide(JBpred);
1424  
1392  
1425    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
1426    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
1427    Tpred->Add(LcorrJZBem,-1.0);
# Line 1442 | Line 1474 | void do_prediction_plot(string jzb, TCan
1474      Bpred->Draw("hist,same");
1475      //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
1476      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1477 <    lm4RcorrJZBeemm->Draw("hist,same");
1477 >    //lm4RcorrJZBeemm->Draw("hist,same");
1478      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1479      legBpred->AddEntry(Bpred,"predicted","l");
1480   //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1481   //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1482 <    legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1482 > //     legBpred->AddEntry(lm4RcorrJZBeemm,(allsamples.collection[allsamples.FindSample("LM")[0]].samplename).c_str(),"l");
1483      legBpred->Draw();
1484      DrawPrelim();
1485  
# Line 1457 | Line 1489 | void do_prediction_plot(string jzb, TCan
1489      Bpred->SetLineWidth(2);
1490      predcomppad->cd();
1491      predcomppad->SetLogy(1);
1460    
1492      TH1F *jzbnegative = (TH1F*)LcorrJZBeemm->Clone("jzbnegative");
1493      TH1F *sidebandsemu = (TH1F*)Bpred->Clone("sidebandsemu");
1494      sidebandsemu->Add(jzbnegative,-1);
# Line 1479 | Line 1510 | void do_prediction_plot(string jzb, TCan
1510   //    lm4RcorrJZBeemm->SetLineColor(kOrange+1);
1511      lm4RcorrJZBeemm->SetLineWidth(2);
1512      //lm4RcorrJZBeemm->SetLineWidth(2); // paper style. overruled.
1513 <    lm4RcorrJZBeemm->Draw("histo,same");
1513 > //     lm4RcorrJZBeemm->Draw("histo,same");
1514      DrawPrelim();
1515      TLegend *speciallegBpred = make_legend("",0.45,0.55);
1516      //TLegend *speciallegBpred = make_legend("",0.35,0.55); // paper style. overruled.
# Line 1489 | Line 1520 | void do_prediction_plot(string jzb, TCan
1520      if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) speciallegBpred->AddEntry(sidebandsemu,"Sidebands/e#mu (data)","f");
1521      else speciallegBpred->AddEntry(sidebandsemu,"e#mu (data)","f");
1522   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1523 <    speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1523 > //     speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1524      speciallegBpred->Draw();
1525      save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
1526      
# Line 1525 | Line 1556 | void do_prediction_plot(string jzb, TCan
1556      legBpred->AddEntry(Bpred,"MC predicted","l");    
1557      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1558      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1559 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1559 > //     if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1560      legBpred->Draw();
1561      DrawMCPrelim();
1562      Bpredsaveas="Bpred_MC";
# Line 1557 | Line 1588 | void do_prediction_plot(string jzb, TCan
1588        
1589        RcorrJZBeemmNoS->SetLineStyle(2);
1590        legBpred2->AddEntry(RcorrJZBeemmNoS,"MC B","l");
1591 <      legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
1591 > //       legBpred2->AddEntry(lm4RcorrJZBeemm,"MC S","l");
1592        legBpred2->Draw();
1593        RcorrJZBeemmNoS->SetLineColor(TColor::GetColor("#61210B"));
1594        RcorrJZBeemmNoS->Draw("histo,same");
# Line 1576 | Line 1607 | void do_prediction_plot(string jzb, TCan
1607    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1608    save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
1609  
1610 +
1611    
1612    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1613    // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
# Line 1634 | Line 1666 | void do_prediction_plot(string jzb, TCan
1666        legBpredc->AddEntry(Bpredem,"MC OFZP","l");
1667        legBpredc->AddEntry(BpredSBem,"MC OFSB","l");
1668        legBpredc->AddEntry(BpredSBeemm,"MC SFSB","l");
1669 <      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1669 > //       if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1670        legBpredc->Draw();
1671        CompleteSave(globalcanvas,subdir+"Bpred_MCwithS_comparison");
1672      }
# Line 1670 | Line 1702 | void do_prediction_plot(string jzb, TCan
1702      delete JLcorrJZBSBeemm;
1703    }
1704    if(overlay_signal || use_data==2) delete lm4RcorrJZBeemm;
1673  switch_overunderflow(false);
1705   }
1706  
1707   void do_prediction_plots(string mcjzb, string datajzb, float DataSigma, float MCSigma, bool overlay_signal ) {
1708 +  switch_overunderflow(true);
1709    TCanvas *globalcanvas = new TCanvas("globalcanvas","Prediction Canvas");
1710    do_prediction_plot(datajzb,globalcanvas,jzbHigh ,data,overlay_signal);
1711    if ( !PlottingSetup::Approved ) {
# Line 1682 | Line 1714 | void do_prediction_plots(string mcjzb, s
1714    } else {
1715      write_info(__FUNCTION__,"You set approved to true, therefore not producing prediction/observation plots for MC with and without signal.");
1716    }
1717 < }
1718 <
1687 < void do_ratio_plot(int is_data,vector<float> binning, string jzb, TCanvas *can, float high=-9999) {
1688 <  bool do_data=0;
1689 <  bool dosignal=0;
1690 <  if(is_data==1) do_data=1;
1691 <  if(is_data==2) dosignal=1;
1692 <  TH1F *RcorrJZBeemm   = allsamples.Draw("RcorrJZBeemm",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1693 <  TH1F *LcorrJZBeemm   = allsamples.Draw("LcorrJZBeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1694 <  TH1F *RcorrJZBem     = allsamples.Draw("RcorrJZBem",jzb.c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1695 <  TH1F *LcorrJZBem     = allsamples.Draw("LcorrJZBem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1696 <  
1697 <  TH1F *RcorrJZBSBem;
1698 <  TH1F *LcorrJZBSBem;
1699 <  TH1F *RcorrJZBSBeemm;
1700 <  TH1F *LcorrJZBSbeemm;
1701 <  
1702 <  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1703 <    RcorrJZBSBem   = allsamples.Draw("RcorrJZBSbem",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1704 <    LcorrJZBSBem   = allsamples.Draw("LcorrJZBSbem",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSOF&&cutnJets,do_data, luminosity,dosignal);
1705 <    RcorrJZBSBeemm = allsamples.Draw("RcorrJZBSbeemm",jzb.c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1706 <    LcorrJZBSbeemm = allsamples.Draw("LcorrJZBSbeemm",("-"+jzb).c_str(),binning, "JZB [GeV]", "events", sidebandcut&&cutOSSF&&cutnJets,do_data, luminosity,dosignal);
1707 <  }
1708 <  
1709 <
1710 <
1711 <
1712 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1713 <  TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
1714 <  if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
1715 <    Bpred->Add(RcorrJZBem,1.0/3);
1716 <    Bpred->Add(LcorrJZBem,-1.0/3);
1717 <    Bpred->Add(RcorrJZBSBem,1.0/3);
1718 <    Bpred->Add(LcorrJZBSBem,-1.0/3);
1719 <    Bpred->Add(RcorrJZBSBeemm,1.0/3);
1720 <    Bpred->Add(LcorrJZBSbeemm,-1.0/3);
1721 <  } else {
1722 <    Bpred->Add(RcorrJZBem,1.0);
1723 <    Bpred->Add(LcorrJZBem,-1.0);
1724 <  }
1725 <
1726 <  can->cd();
1727 <  can->SetLogy(0);
1728 <  Bpred->SetLineColor(kRed);
1729 <  Bpred->SetStats(0);
1730 <  if(high>0) Bpred->GetXaxis()->SetRangeUser(0,high);
1731 <  TH1F *JZBratioforfitting=(TH1F*)RcorrJZBeemm->Clone("JZBratioforfitting");
1732 <  JZBratioforfitting->Divide(Bpred);
1733 <  TGraphAsymmErrors *JZBratio = histRatio(RcorrJZBeemm,Bpred,is_data,binning,false);
1734 <  
1735 <  
1736 <  JZBratio->SetTitle("");
1737 <  JZBratio->GetYaxis()->SetRangeUser(0.0,9.0);
1738 < //  if(is_data==1) JZBratio->GetXaxis()->SetRangeUser(0,jzbHigh );
1739 <  
1740 <  TF1 *pol0 = new TF1("pol0","[0]",0,1000);
1741 <  TF1 *pol0d = new TF1("pol0","[0]",0,1000);
1742 < //  straightline_fit->SetParameter(0,1);
1743 <  JZBratioforfitting->Fit(pol0,"Q0R","",0,30);
1744 <  pol0d->SetParameter(0,pol0->GetParameter(0));
1745 <  
1746 <  JZBratio->GetYaxis()->SetTitle("Observed/Predicted");
1747 <  JZBratio->GetXaxis()->SetTitle("JZB [GeV]");
1748 <  if ( high>0 ) JZBratio->GetXaxis()->SetRangeUser(0.0,high);
1749 <  JZBratio->GetYaxis()->SetNdivisions(519);
1750 <  JZBratio->GetYaxis()->SetRangeUser(0.0,4.0);
1751 <  JZBratio->GetYaxis()->CenterTitle();
1752 <  JZBratio->GetXaxis()->CenterTitle();
1753 <  JZBratio->SetMarkerSize(DataMarkerSize);
1754 <  JZBratio->Draw("AP");
1755 <  /////----------------------------
1756 <  TPaveText *writeresult = new TPaveText(0.15,0.78,0.49,0.91,"blNDC");
1757 <  writeresult->SetFillStyle(4000);
1758 <  writeresult->SetFillColor(kWhite);
1759 <  writeresult->SetTextFont(42);
1760 <  writeresult->SetTextSize(0.03);
1761 <  writeresult->SetTextAlign(12);
1762 <  ostringstream jzb_agreement_data_text;
1763 <  jzb_agreement_data_text<< setprecision(2) << "mean =" << pol0->GetParameter(0) << " #pm " << setprecision(1) <<  pol0->GetParError(0);
1764 <  if(is_data==1) fitresultconstdata=pol0->GetParameter(0);// data
1765 <  if(is_data==0) fitresultconstmc=pol0->GetParameter(0); // monte carlo, no signal
1766 < /*  if(is_data) writeresult->AddText("Data closure test");
1767 <  else writeresult->AddText("MC closure test");
1768 <  */
1769 <  writeresult->AddText(jzb_agreement_data_text.str().c_str());
1770 < //  writeresult->Draw("same");
1771 < //  pol0d->Draw("same");
1772 <  TF1 *topline =  new TF1("","1.5",0,1000);
1773 <  TF1 *bottomline =  new TF1("","0.5",0,1000);
1774 <  topline->SetLineColor(kBlue);
1775 <  topline->SetLineStyle(2);
1776 <  bottomline->SetLineColor(kBlue);
1777 <  bottomline->SetLineStyle(2);
1778 < //  topline->Draw("same");
1779 < //  bottomline->Draw("same");
1780 <  TF1 *oneline = new TF1("","1.0",0,1000);
1781 <  oneline->SetLineColor(kBlue);
1782 <  oneline->SetLineStyle(1);
1783 <  oneline->Draw("same");
1784 <  TLegend *phony_leg = make_legend("ratio",0.6,0.55,false);//this line is just to have the default CMS Preliminary (...) on the canvas as well.
1785 <  if(is_data==1) DrawPrelim();
1786 <  else DrawMCPrelim();
1787 <  TLegend *leg = new TLegend(0.55,0.75,0.89,0.89);
1788 <  leg->SetTextFont(42);
1789 <  leg->SetTextSize(0.04);
1790 < //   if(is_data==1) leg->SetHeader("Ratio (data)");
1791 < //   else leg->SetHeader("Ratio (MC)");
1792 <
1793 <  TString MCtitle("MC ");
1794 <  if (is_data==1) MCtitle = "";
1795 <
1796 <  leg->SetFillStyle(4000);
1797 <  leg->SetFillColor(kWhite);
1798 <  leg->SetTextFont(42);
1799 < //  leg->AddEntry(topline,"+20\% sys envelope","l");
1800 <  leg->AddEntry(JZBratio,MCtitle+"obs / "+MCtitle+"pred","p");
1801 <  leg->AddEntry(oneline,"ratio = 1","l");
1802 < //  leg->AddEntry(pol0d,"fit in [0,30] GeV","l");
1803 < //  leg->AddEntry(bottomline,"#pm50% envelope","l");
1804 <
1805 <
1806 <  //leg->Draw("same"); // no longer drawing legend
1807 <
1808 <  if(is_data==1) CompleteSave(can, "jzb_ratio_data");
1809 <  if(is_data==0) CompleteSave(can, "jzb_ratio_mc");
1810 <  if(is_data==2) CompleteSave(can, "jzb_ratio_mc_BandS");//special case, MC with signal!
1811 <  
1812 <  delete RcorrJZBeemm;
1813 <  delete LcorrJZBeemm;
1814 <  delete RcorrJZBem;
1815 <  delete LcorrJZBem;
1816 <  
1817 <  delete RcorrJZBSBem;
1818 <  delete LcorrJZBSBem;
1819 <  delete RcorrJZBSBeemm;
1820 <  delete LcorrJZBSbeemm;
1821 < }
1822 <
1823 < void do_ratio_plots(string mcjzb,string datajzb,vector<float> ratio_binning) {
1824 <  TCanvas *globalc = new TCanvas("globalc","Ratio Plot Canvas");
1825 <  globalc->SetLogy(0);
1826 <  
1827 <  do_ratio_plot(mc,ratio_binning,mcjzb,globalc, jzbHigh  );
1828 <  do_ratio_plot(data,ratio_binning,datajzb,globalc, jzbHigh  );
1829 <  do_ratio_plot(mcwithsignal,ratio_binning,mcjzb,globalc, jzbHigh  );
1717 >  delete globalcanvas;
1718 >  switch_overunderflow(false);
1719   }
1720  
1721   string give_jzb_expression(float peak, int type) {
# Line 2094 | Line 1983 | void produce_stretched_jzb_plots(string
1983    
1984  
1985   void diboson_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
1986 +  switch_overunderflow(true);
1987    vector<int> SamplesToBeModified = allsamples.FindSampleBySampleName("WW/WZ/ZZ");
1988    
1989    if(SamplesToBeModified.size()==0 || SamplesToBeModified[0]==-1) {
# Line 2133 | Line 2023 | void diboson_plots(string mcjzb, string
2023      dout << "     Reset xs for sample " << (allsamples.collection)[SamplesToBeModified[i]].samplename << " from " << Upxs << " to " << (allsamples.collection)[SamplesToBeModified[i]].xs << " (by a factor of " << stretchfactor << ") and reset the correct name (from " << Upname << ")" << endl;
2024      
2025    }
2026 <  
2026 > //   switch_overunderflow(false);
2027   }
2028  
2029  
# Line 2168 | Line 2058 | void draw_normalized_data_vs_data_histo(
2058  
2059  
2060   void jzb_plots(string mcjzb, string datajzb,vector<float> ratio_binning) {
2061 +  switch_overunderflow(true);
2062    TCanvas *can = new TCanvas("can","JZB Plots Canvas");
2063    float max=jzbHigh ;
2064    float min=-120;
# Line 2204 | Line 2095 | void jzb_plots(string mcjzb, string data
2095      if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) draw_pure_jzb_histo(cutOSOF&&cutnJets&&sidebandcut,datajzb,mcjzb,"jzb_OS_OFSB_coarse",can,coarse_binning);
2096    }
2097    delete can;
2098 +  switch_overunderflow(false);
2099   }
2100  
2101  
# Line 2744 | Line 2636 | void ttbar_sidebands_comparison(string m
2636    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2637    //in the case of the OFF peak analysis, we compare our control region to the real value
2638    TCut weightbackup=cutWeight;
2639 +  switch_overunderflow(true);
2640    
2641    bool doPURW=false;
2642    
# Line 2822 | Line 2715 | void ttbar_sidebands_comparison(string m
2715    leg->Draw("same");
2716    DrawMCPrelim(simulatedlumi);
2717    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2718 +  
2719    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2720    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2721    TH1F *TSeemmcopy;
# Line 2887 | Line 2781 | void ttbar_sidebands_comparison(string m
2781    DrawMCPrelim(simulatedlumi);
2782    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison_ratio");
2783    
2784 +  
2785    if (0) { // Turn this off: we don't need this
2786  
2787      ///-------------- second part: only look at the quantity we actually care about!
# Line 2992 | Line 2887 | void ttbar_sidebands_comparison(string m
2887  
2888    delete tcan;
2889    cutWeight=weightbackup;
2890 +  switch_overunderflow(false);
2891   }
2892  
2893   void ttbar_sidebands_comparison(string mcjzb, vector<float> jzb_binning) {
# Line 3026 | Line 2922 | void ttbar_sidebands_comparison(string m
2922    nicer_binning.push_back(150);
2923    //nicer_binning.push_back(175);
2924    nicer_binning.push_back(200);
2925 <  nicer_binning.push_back(250);
2926 <  nicer_binning.push_back(300);
2927 <  nicer_binning.push_back(400);
2925 > //  nicer_binning.push_back(250);
2926 > //  nicer_binning.push_back(300);
2927 > //  nicer_binning.push_back(400);
2928    
2929    ttbar_sidebands_comparison(mcjzb,nicer_binning, "ttbar/");
2930   }
2931  
2932  
2933   void zjets_prediction_comparison(string mcjzbWithPUa) {
2934 +  cout << "****************************************************************************************************************************************************************" << endl;
2935    TCanvas *zcan = new TCanvas("zcan","zcan");  
2936   //  zcan->SetLogy(1);
2937    TCut weightbackup=cutWeight;
2938    
2939 <  bool UsePURW=false;
2939 >  bool UsePURW=true;
2940    
2941    
2942    string mcjzb;
2943    if(UsePURW) {
2944      mcjzb=mcjzbWithPUa;
2945 +    cout << "Using PURW peak positions" << endl;
2946    } else {
2947      // Do it without PU re-weighting
2948 +    cutWeight="1.0";
2949      float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2950      stringstream resultsNoPU;
2951      stringstream noPUdatajzb;
# Line 3057 | Line 2956 | void zjets_prediction_comparison(string
2956      
2957      mcjzb = noPUmcjzb.str();
2958      
3060    cutWeight="1.0";
2959    }
2960  
2961    
# Line 3081 | Line 2979 | void zjets_prediction_comparison(string
2979    string var( "abs("+mcjzb+")" );
2980    
2981    TCut notTau("abs(genMID1)!=15");
2982 <  TCut ONLYTau("mll>20");
2982 >  TCut ee_mm_tautau("mll>0");
2983    
2984  
2985    TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets&&notTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
# Line 3110 | Line 3008 | void zjets_prediction_comparison(string
3008    }
3009    
3010    zcan->SetLogy(0);
3011 <  hratio->GetYaxis()->SetRangeUser(0,2.0);
3011 >  hratio->GetYaxis()->SetRangeUser(0,2.5);
3012    hratio->GetYaxis()->SetTitle("Observed/Predicted");
3013    hratio->Draw("e1");
3014    
# Line 3136 | Line 3034 | void zjets_prediction_comparison(string
3034    
3035    TCut reducedNJets(cutnJets);
3036    
3037 <  TH1F *TAUhJZBpos = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3038 <  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3039 <  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3040 <  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3037 >  TH1F *TAUhJZBpos = systsamples.Draw("TAUhJZBpos",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3038 >  TH1F *LcorrJZBeemm     = systsamples.Draw("LcorrJZBeemm",var,binning, "JZB [GeV]", "events",cutmass&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3039 >  TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3040 >  TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3041  
3042    TH1F *RcorrJZBSBem;
3043    TH1F *LcorrJZBSBem;
# Line 3147 | Line 3045 | void zjets_prediction_comparison(string
3045    TH1F *LcorrJZBSBeemm;
3046  
3047    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3048 <    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3049 <    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3050 <    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3051 <    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ONLYTau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3048 >    RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3049 >    LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3050 >    RcorrJZBSBeemm = systsamples.Draw("RcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
3051 >    LcorrJZBSBeemm = systsamples.Draw("LcorrJZBSBeemm",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSSF&&reducedNJets&&ee_mm_tautau&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
3052    }
3053    
3054    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
# Line 3199 | Line 3097 | void zjets_prediction_comparison(string
3097    center->Draw("same");
3098    bottom->Draw("same");
3099    
3100 <  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow #tau#tau",0.25,0.75,false);
3100 >  TLegend *TAUleg2 = make_legend("MC Z+jets #rightarrow ee,#mu#mu",0.25,0.75,false);
3101    TAUleg2->AddEntry(TAUhratio,"obs / pred","pe");
3102    TAUleg2->AddEntry(bottom,"syst. envelope","l");
3103    TAUleg2->Draw("same");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines