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.70 by buchmann, Thu Oct 11 09:00:41 2012 UTC vs.
Revision 1.85 by buchmann, Tue Feb 19 10:50:47 2013 UTC

# Line 228 | Line 228 | void make_special_obs_pred_mll_plot(stri
228    
229    RcorrJZBeemm->SetTitleOffset(1.3,"y");
230    RcorrJZBeemm->Draw();
231 <  mcRcorrJZBeemm.Draw("same");
231 >  mcRcorrJZBeemm.Draw("histo,same");
232    Bpred->Draw("histo,same");
233    RcorrJZBeemm->Draw("same");
234    
# Line 285 | Line 285 | void make_special_obs_pred_mll_plot(stri
285    }
286    delete Bpred;
287    delete ckin;
288 +  CleanLegends();
289   }
290  
291   void make_special_mll_plot(int nbins, float min, float max, bool logscale,string xlabel) {
# Line 305 | Line 306 | void make_special_mll_plot(int nbins, fl
306    datahistoOSSF->SetMarkerSize(DataMarkerSize);
307    datahistoOSSF->Draw();
308  
309 <  mcstackOSSF.Draw("same");
309 >  mcstackOSSF.Draw("histo,same");
310    datahistoOSSF->Draw("same");
311  
312    datahistoOSOF->SetMarkerColor(TColor::GetColor("#FE642E"));
# Line 331 | Line 332 | void make_special_mll_plot(int nbins, fl
332    delete datahistoOSOF;
333    delete datahistoOSSF;
334    delete ckin;
335 +  CleanLegends();
336   }
337    
338  
# Line 384 | Line 386 | float make_one_OFSF_plot(string variable
386  
387    cutOF = cutOSOF&&cutnJets&&ibasiccut;
388    cutSF = cutOSSF&&cutnJets&&ibasiccut;
389 +  
390 +  TCanvas *ofsf_can = new TCanvas("ofsf_can","ofsf_can");
391  
388  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
392    TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
393    rcan->SetLogy(logscale);
394    rcan->cd();
# Line 410 | Line 413 | float make_one_OFSF_plot(string variable
413    }
414    if (ymax<0) {
415      if ( logscale ) datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
416 <    else datahistoSF->SetMaximum(1.8*datahistoSF->GetMaximum());
416 >    else datahistoSF->SetMaximum(0.8*datahistoSF->GetMaximum());
417    } else {
418      datahistoSF->SetMaximum(ymax);
419    }
# Line 437 | Line 440 | float make_one_OFSF_plot(string variable
440    mleg->Draw();
441    DrawPrelim();
442    if (datahistoOF->Integral()>0) {
443 <    save_with_ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
443 >    Save_With_Ratio( datahistoSF, datahistoOF, rcan, "SFOF/" + filename, false, false, "SF/OF" );
444    } else {
445      CompleteSave(rcan, "SFOF/" + filename);
443    delete rcan;
446    }
447  
448    datahistoSF->Delete();
449    datahistoOF->Delete();
450    //signalhisto->Delete();
451    delete mleg;
452 <  delete ckin;
452 >  delete rcan;
453 >  delete ofsf_can;
454  
455    return ymaxSet;
456  
# Line 468 | Line 471 | float make_data_comparison_plot(string v
471  
472    TH1F *data1 = allsamples.Draw("data1",variable,nbins,min,max, xlabel, "events",ibasiccut,data,luminosity);
473    TH1F *data2 = comparesamples.Draw("data2",variable,nbins,min,max, xlabel, "events",ibasiccut,data,luminosity);
474 <  data2->Scale(4.1/5.2);
474 >  data1->Scale(5.0/9.2);
475  
476    data1->SetMarkerSize(DataMarkerSize);
477    data2->SetLineColor(kRed);
# Line 493 | Line 496 | float make_data_comparison_plot(string v
496    data1->GetYaxis()->CenterTitle();
497  
498    TLegend *mleg = make_legend("",legendPosition,0.7,false,legendPosition+0.2);
499 <  mleg->AddEntry(data1, "New 4.1 fb^{-1}", "PL");
500 <  mleg->AddEntry(data2, "Old 5.1 fb^{-1} (scaled) ", "L");
499 >  mleg->AddEntry(data1, "2012 data (scaled)", "PL");
500 >  mleg->AddEntry(data2, "2011 data", "L");
501  
502    data1->Draw("E1");
503    data2->Draw("HIST,SAMES");
504    mleg->Draw();
505    DrawPrelim();
506 <  save_with_ratio( data1, data2, rcan, "compareData/" + filename, false, false, "new/old" );
506 >  Save_With_Ratio( data1, data2, rcan, "compareData/" + filename, false, false, "new/old" );
507  
508    data1->Delete();
509    data2->Delete();
510    delete mleg;
511 +  delete rcan;
512    delete ckin;
513  
514   }
# Line 537 | Line 541 | void make_OFSF_plots(string variable, st
541  
542   }
543  
544 + TCut ReplaceInCut(TCut cut, string replacethis, string withthis) {
545 +  string scut=(string)(const char*)cut;
546 +  string acut=ReplaceAll(scut,replacethis,withthis);
547 +  return TCut(acut.c_str());
548 + }
549 +
550 + void DoMCSystPlot(string datavariable, string mcvariable, int nbins, float min, float max, TCut addcut, bool dolog, string xlabel, string filename) {
551 +  TCut cut=addcut&&basiccut;
552 +
553 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
554 +  ckin->SetLogy(dolog);
555 +  cout << "\r Creating " << filename << " : data   (1/6)" << std::flush;
556 +  TH1F *datahisto = allsamples.Draw("datahisto",datavariable,nbins,min,max, xlabel, "events",cut,data,luminosity);
557 +  datahisto->SetMarkerSize(DataMarkerSize);
558 +  if ( !dolog ) datahisto->SetMinimum(0); // Defaults
559 +  else datahisto->SetMinimum(0.5);
560 +  if (dolog) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
561 +  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
562 +  cout << "\r Creating " << filename << " : MC central   (2/6)" << std::flush;
563 +  THStack mcstack   = allsamples.DrawStack("mcstack",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
564 +  TH1F *MCcentral = CollapseStack(mcstack);
565 +
566 +  TCut bkpcut = cut;
567 +  cut = ReplaceInCut(cut,"pfJetGoodNum40","pfJetGoodNum40p1sigma");
568 +  cout << "\r Creating " << filename << " : MC JES up   (3/6)" << std::flush;
569 +  TH1F *MCJESup   = allsamples.Draw("MCJESup",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
570 +
571 +  cut = ReplaceInCut(cut,"pfJetGoodNum40p1sigma","pfJetGoodNum40n1sigma");
572 +  cout << "\r Creating " << filename << " : MC JES down   (4/6)" << std::flush;
573 +  TH1F *MCJESdn   = allsamples.Draw("MCJESdn",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
574 +  
575 +  cut=bkpcut;
576 +  TCut bkpweight = cutWeight;
577 +  cutWeight= ReplaceInCut(cutWeight,"weight","PUweightUP");
578 +  cout << "\r Creating " << filename << " : MC PU up   (5/6)" << std::flush;
579 +  TH1F *MCPUup    = allsamples.Draw("MCPUup",   mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
580 +  
581 +  cutWeight= ReplaceInCut(cutWeight,"PUweightUP","PUweightDOWN");
582 +  cout << "\r Creating " << filename << " : MC PU down   (6/6)" << std::flush;
583 +  TH1F *MCPUdn    = allsamples.Draw("MCPUdn",   mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
584 +  cutWeight=bkpweight;
585 +  cout << "\r Creating " << filename << " : Processing systematics ..." << std::flush;
586 +  TH1F *Systematic = (TH1F*)MCPUdn->Clone("Systematic");
587 +  for(int i=1;i<=Systematic->GetNbinsX();i++) {
588 +    float jesdn = abs(MCcentral->GetBinContent(i)-MCJESdn->GetBinContent(i));
589 +    float jesup = abs(MCcentral->GetBinContent(i)-MCJESup->GetBinContent(i));
590 +    float jes   = jesdn>jesup?jesdn:jesup;
591 +    
592 +    float PUup = abs(MCcentral->GetBinContent(i)-MCPUup->GetBinContent(i));
593 +    float PUdn = abs(MCcentral->GetBinContent(i)-MCPUdn->GetBinContent(i));
594 +    float pu   = PUdn>PUup?PUdn:PUup;
595 +    
596 +    float sys=sqrt(jes*jes+pu*pu);
597 +    sys/=MCcentral->GetBinContent(i);
598 +    if(MCcentral->GetBinContent(i)==0) sys=0;
599 +    Systematic->SetBinContent(i,sys);
600 +  }
601 +  
602 +  datahisto->Draw("e1");
603 +  ckin->Update();
604 +  mcstack.Draw("histo,same");
605 +  
606 +  datahisto->Draw("same,e1");
607 +  TLegend *kinleg = allsamples.allbglegend();
608 +  kinleg->Draw();
609 +
610 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
611 +  kinpad->SetLogy(dolog);
612 +  kinpad->cd();
613 +  datahisto->Draw("e1");
614 +  mcstack.Draw("histo,same");
615 +  datahisto->Draw("same,e1");
616 +  datahisto->Draw("same,axis");
617 +  
618 +  kinleg->Draw("same");
619 +  DrawPrelim();
620 +  string saveas="kin/"+filename;
621 +  
622 +  cout << "Passing filename to be saved : " << filename << " as " << saveas << endl;
623 +  save_with_ratio_and_sys_band( datahisto, CollapseStack(mcstack), kinpad->cd(), saveas, false, false, "data/mc",Systematic );
624 +  
625 +  ckin->cd();
626 +  MCcentral->SetFillColor(kWhite);
627 +  MCcentral->SetLineColor(kBlack);
628 +  MCcentral->SetLineWidth(2);
629 +  MCPUdn->SetLineColor(kRed);
630 +  MCPUup->SetLineColor(kYellow);
631 +  MCJESdn->SetLineColor(kBlue);
632 +  MCJESup->SetLineColor(kGreen);
633 +  
634 +  TLegend *legsmall = new TLegend(0.0,0.85,1.0,1.00);
635 +  legsmall->SetNColumns(5);
636 +  legsmall->AddEntry(MCcentral,"central","L");
637 +  legsmall->AddEntry(MCPUdn,"PU down","L");
638 +  legsmall->AddEntry(MCPUup,"PU up","L");
639 +  legsmall->AddEntry(MCJESdn,"JES down","L");
640 +  legsmall->AddEntry(MCJESup,"JES up","L");
641 +  legsmall->SetFillColor(kWhite);
642 +  legsmall->SetBorderSize(0);
643 +  
644 +  datahisto->Draw("e1");
645 +  MCcentral->Draw("histo,same");
646 +  MCPUdn->Draw("histo,same");
647 +  MCPUup->Draw("histo,same");
648 +  MCJESdn->Draw("histo,same");
649 +  MCJESup->Draw("histo,same");
650 +  datahisto->Draw("e1,same");
651 +  legsmall->Draw();
652 +  CompleteSave(ckin,saveas+"___AllLines");
653 +  
654 +  delete datahisto;
655 +  delete MCcentral;
656 +  delete MCPUdn;
657 +  delete MCPUup;
658 +  delete MCJESdn;
659 +  delete MCJESup;
660 +  delete ckin;
661 + }
662  
663 + void DoMCSystPlot(string variable, int nbins, float min, float max, TCut addcut, bool dolog, string xlabel, string filename) {
664 +  DoMCSystPlot(variable, variable, nbins, min, max, addcut, dolog, xlabel, filename);
665 + }
666 +  
667   float lastrange_min=0;
668   float lastrange_max=0;
669  
# Line 630 | Line 756 | void make_kin_plot(string variable, stri
756    THStack mcstack   = allsamples.DrawStack("mcstack",  variable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
757    datahisto->Draw("e1");
758    ckin->Update();
759 <  mcstack.Draw("same");
759 >  mcstack.Draw("histo,same");
760    
761    datahisto->Draw("same,e1");
762    TLegend *kinleg = allsamples.allbglegend();
# Line 673 | Line 799 | void make_kin_plot(string variable, stri
799          kinpad->cd();
800          kinpad->SetLogy(logscale);
801          datahisto->Draw("e1");
802 <        mcstack.Draw("same");
802 >        mcstack.Draw("histo,same");
803          if(drawsignal) signalhisto->Draw("same");
804          datahisto->Draw("same,e1");
805          datahisto->Draw("same,axis");
# Line 688 | Line 814 | void make_kin_plot(string variable, stri
814          DrawPrelim();
815          string saveas="kin/"+filename;
816          if(isPF) saveas="kin/"+filename+"__PF";
817 <        save_with_ratio(datahisto,mcstack,kinpad->cd(),saveas);
817 >        Save_With_Ratio(datahisto,mcstack,kinpad->cd(),saveas);
818   //      if(isPF) CompleteSave(with_ratio,"kin/"+filename+"__PF_withratio");
819   //      else CompleteSave(with_ratio,"kin/"+filename+"_withratio");
820   //      delete with_ratio;
# Line 701 | Line 827 | void make_kin_plot(string variable, stri
827    delete ckin;
828   }
829  
830 +
831 + void make_plain_kin_plot(string variable, string addcut, int nbins, float min, float max, bool logscale,
832 +                   string xlabel, string filename, bool isPF=true, bool plotratio=true, bool loadlastminmax=false ) {
833 +  TCut cut=TCut(addcut.c_str())&&basiccut;
834 +
835 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
836 +  ckin->SetLogy(logscale);
837 +  TH1F *datahisto = allsamples.Draw("datahisto",variable,nbins,min,max, xlabel, "events",cut,data,luminosity);
838 +  datahisto->SetMarkerSize(DataMarkerSize);
839 +  if ( !logscale ) datahisto->SetMinimum(0); // Defaults
840 +  else datahisto->SetMinimum(0.5);
841 +  // Custom max.
842 +  if (logscale) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
843 +  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
844 +
845 +  cout << "******** Cut used : " << (const char*) cut << " for plot " << filename << endl;
846 +  if(loadlastminmax) {
847 +        datahisto->SetMinimum(lastrange_min);
848 +        datahisto->SetMaximum(lastrange_max);
849 +        if(logscale) {
850 +                datahisto->SetMinimum(pow(10,lastrange_min));
851 +                datahisto->SetMaximum(pow(10,lastrange_max));
852 +        }              
853 +  }
854 +
855 +  THStack mcstack   = allsamples.DrawStack("mcstack",  variable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
856 +  datahisto->Draw("e1");
857 +  ckin->Update();
858 +  mcstack.Draw("histo,same");
859 +  
860 +  datahisto->Draw("same,e1");
861 +  TLegend *kinleg = allsamples.allbglegend();
862 +  kinleg->Draw();
863 +
864 +  lastrange_min=ckin->GetUymin();
865 +  lastrange_max=ckin->GetUymax();
866 +
867 +  if ( plotratio ) {
868 +        TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
869 +        kinpad->cd();
870 +        kinpad->SetLogy(logscale);
871 +        datahisto->Draw("e1");
872 +        mcstack.Draw("histo,same");
873 +        datahisto->Draw("same,e1");
874 +        datahisto->Draw("same,axis");
875 +          
876 +        kinleg->Draw();
877 +        DrawPrelim();
878 +        string saveas="kin/"+filename;
879 +        if(isPF) saveas="kin/"+filename+"__PF";
880 +        Save_With_Ratio(datahisto,mcstack,kinpad->cd(),saveas);
881 +  } else {
882 +        if(isPF) CompleteSave(ckin,"kin/"+filename+"__PF");
883 +        else CompleteSave(ckin,"kin/"+filename);
884 +  }
885 +  datahisto->Delete();
886 +  delete ckin;
887 + }
888 +
889 +
890   void make_JES_plot(TCut cut, string name) {
891  
892    int nbins=10;
# Line 734 | Line 920 | void make_JES_plot(TCut cut, string name
920    JESunc->SetFillColor(TColor::GetColor("#00ADE1"));
921    JESunc->SetFillStyle(3002);
922    datahisto->Draw("e1");
923 <  mcstack.Draw("same");
923 >  mcstack.Draw("histo,same");
924    JESunc->Draw("2");
925    datahisto->Draw("same,e1");
926    TLegend *kinleg = allsamples.allbglegend();
# Line 743 | Line 929 | void make_JES_plot(TCut cut, string name
929    CompleteSave(ckin,"Systematics/JES"+name);
930    datahisto->Delete();
931    delete ckin;
932 +  delete JESunc;
933 +  delete JESup;
934 +  delete JESdn;
935 +  CleanLegends();
936 + }
937 +
938 + string Cut2Str(TCut cut) {
939 +  return ((string)(const char*)cut);
940 + }
941 +
942 + void MakeElegantTwoThreeComparisons() {
943 +    
944 +    TCut signal("met[4]>100&&met[4]<150&&mll>20"&&PlottingSetup::basicqualitycut);
945 +    TCut TwoJets("pfJetGoodNum40==2");
946 +    TCut ThreeJets("pfJetGoodNum40>=3");
947 +    
948 +    float min=20;
949 +    float max=300;
950 +    int nbins=int((max-min)/5.0);
951 +    string xlabel="m_{ll} [GeV]";
952 +    
953 +    TCanvas *can2 = new TCanvas("can2","can2");
954 +    TH1F *TwoOF = allsamples.Draw("TwoOF","mll",nbins,min,max, xlabel, "events",cutOSOF&&signal&&TwoJets,mc,luminosity,allsamples.FindSample("TTJets_"));
955 +    TH1F *TwoSF = allsamples.Draw("TwoSF","mll",nbins,min,max, xlabel, "events",cutOSSF&&signal&&TwoJets,mc,luminosity,allsamples.FindSample("TTJets_"));
956 +    TH1F *ThreeOF = allsamples.Draw("ThreeOF","mll",nbins,min,max, xlabel, "events",cutOSOF&&signal&&ThreeJets,mc,luminosity,allsamples.FindSample("TTJets_"));
957 +    TH1F *ThreeSF = allsamples.Draw("ThreeSF","mll",nbins,min,max, xlabel, "events",cutOSSF&&signal&&ThreeJets,mc,luminosity,allsamples.FindSample("TTJets_"));
958 +    
959 +    can2->cd(1);
960 +    
961 +    TwoSF->SetFillColor(kWhite);
962 +    TwoOF->SetFillColor(kWhite);
963 +    ThreeSF->SetFillColor(kWhite);
964 +    ThreeOF->SetFillColor(kWhite);
965 +    
966 +    TPad *kin3 = new TPad("kin3","kin3",0,0,1,1);
967 +    kin3->cd();
968 +    TwoOF->Draw("histo");
969 +    TwoSF->Draw("e1,same");
970 +    TLegend *leg_SFOF_Two = make_legend();
971 +    leg_SFOF_Two->SetHeader("t#bar{t} MC:");
972 +    leg_SFOF_Two->AddEntry(TwoOF,"OF, nJets==2","l");
973 +    leg_SFOF_Two->AddEntry(TwoSF,"SF, nJets==2","lp");
974 +    leg_SFOF_Two->Draw();
975 +    Save_With_Ratio(TwoSF,TwoOF,kin3->cd(),"DoubleRatios/SFOF_Two");
976 +    
977 +    TPad *kin4 = new TPad("kin4","kin4",0,0,1,1);
978 +    kin4->cd();
979 +    ThreeOF->Draw("histo");
980 +    ThreeSF->Draw("e1,same");
981 +    TLegend *leg_SFOF_Three = make_legend();
982 +    leg_SFOF_Three->SetHeader("t#bar{t} MC:");
983 +    leg_SFOF_Three->AddEntry(TwoOF,"OF, nJet#geq3","l");
984 +    leg_SFOF_Three->AddEntry(TwoSF,"SF, nJets#geq3","lp");
985 +    leg_SFOF_Three->Draw();
986 +    Save_With_Ratio(ThreeSF,ThreeOF,kin4->cd(),"DoubleRatios/SFOF_Three");
987 +    
988 +    
989 +    TwoSF->Scale(ThreeSF->Integral()/TwoSF->Integral());
990 +    TPad *kin = new TPad("kin","kin",0,0,1,1);
991 +    kin->cd();
992 +    TwoSF->Draw("histo");
993 +    ThreeSF->Draw("e1,same");
994 +    TLegend *leg_SF_Two_Three = make_legend();
995 +    leg_SF_Two_Three->SetHeader("t#bar{t} MC:");
996 +    leg_SF_Two_Three->AddEntry(TwoSF,"#splitline{SF, nJets==2}{ (scaled)}","l");
997 +    leg_SF_Two_Three->AddEntry(ThreeSF,"SF, nJets#geq3","lp");
998 +    leg_SF_Two_Three->Draw();
999 +    Save_With_Ratio(TwoSF,ThreeSF,kin->cd(),"DoubleRatios/SF_Two_Three");
1000 +    
1001 +    TwoOF->Scale(ThreeOF->Integral()/TwoOF->Integral());
1002 +    TPad *kin2 = new TPad("kin2","kin2",0,0,1,1);
1003 +    kin2->cd();
1004 +    TwoOF->Draw("histo");
1005 +    ThreeOF->Draw("e1,same");
1006 +    TLegend *leg_OF_Two_Three = make_legend();
1007 +    leg_OF_Two_Three->SetHeader("t#bar{t} MC:");
1008 +    leg_OF_Two_Three->AddEntry(TwoSF,"#splitline{OF, nJets==2}{ (scaled)}","l");
1009 +    leg_OF_Two_Three->AddEntry(ThreeSF,"OF, nJets#geq3","lp");
1010 +    leg_OF_Two_Three->Draw();
1011 +    Save_With_Ratio(TwoOF,ThreeOF,kin2->cd(),"DoubleRatios/OF_Two_Three");
1012 +    
1013 + }
1014 +
1015 + void PresentRange(TH1F *Down, TH1F *Up, TH1F *central, TVirtualPad *pad, string title) {
1016 +  pad->cd();
1017 +  TGraphErrors *gr = new TGraphErrors(Down->GetNbinsX());
1018 +  for(int i=1;i<=Down->GetNbinsX();i++) {
1019 +    float average=0.5*(Down->GetBinContent(i)+Up->GetBinContent(i));
1020 +    float error=abs(Down->GetBinContent(i)-average);
1021 +    gr->SetPoint(i-1,Down->GetBinCenter(i),average);
1022 +    gr->SetPointError(i-1,Down->GetBinWidth(i)/2.0,error);
1023 +  }
1024 +  gr->SetFillColor(TColor::GetColor("#F79F81"));
1025 +  gr->GetYaxis()->SetRangeUser(0,2);
1026 +  gr->GetXaxis()->SetTitle(central->GetXaxis()->GetTitle());
1027 +  gr->GetYaxis()->SetTitle(central->GetYaxis()->GetTitle());
1028 +  gr->GetXaxis()->CenterTitle();
1029 +  gr->GetYaxis()->CenterTitle();
1030 +  
1031 +  gr->Draw("A2");
1032 +  central->Draw("e1,same");
1033 +  DrawMCPrelim();
1034 +  TText *rtitle = write_text(0.8,0.8,title);
1035 +  TLine *line = new TLine(Down->GetBinLowEdge(1),1.0,Down->GetBinLowEdge(Down->GetNbinsX())+Down->GetBinWidth(Down->GetNbinsX()),1.0);
1036 +  line->SetLineColor(kBlue);
1037 +  line->SetLineStyle(2);
1038 +  line->Draw("same");
1039 +  rtitle->Draw("same");
1040 + }
1041 +
1042 + TH1F* ProduceTTbarRatio(TH1F *datahisto, TH1F *fullmc, TH1F *originalttbar, TH1F *httbar) {
1043 +  TH1F *basehisto = (TH1F*)fullmc->Clone("basehisto");
1044 +  basehisto->Add(originalttbar,-1);
1045 +  basehisto->Add(httbar);
1046 +  
1047 +  string sname=httbar->GetName();
1048 +  sname="R"+sname.substr(1,sname.length());
1049 +  TH1F *ratio = (TH1F*)datahisto->Clone(sname.c_str());
1050 +  ratio->Divide(basehisto);
1051 +  delete basehisto;
1052 +  return ratio;
1053 + }
1054 +  
1055 + void make_ttbar_comparison(string datavariable, string mcvariable, int nbins, float min, float max, TCut addcut, bool dolog, string xlabel, string filename) {
1056 +  
1057 +  TCut cut=addcut&&basiccut;
1058 +  
1059 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
1060 +  ckin->SetLogy(dolog);
1061 +  cout << "\r Creating " << filename << " : data   (1/11)" << std::flush;
1062 +  TH1F *datahisto = allsamples.Draw("datahisto",datavariable,nbins,min,max, xlabel, "events",cut,data,luminosity);
1063 +  datahisto->SetMarkerSize(DataMarkerSize);
1064 +  if ( !dolog ) datahisto->SetMinimum(0); // Defaults
1065 +  else datahisto->SetMinimum(0.5);
1066 +  if (dolog) datahisto->SetMaximum(5.3*datahisto->GetMaximum());
1067 +  else datahisto->SetMaximum(1.3*datahisto->GetMaximum());
1068 +  cout << "\r Creating " << filename << " : MC central  (stack) (2/11)" << std::flush;
1069 +  THStack mcstack   = allsamples.DrawStack("mcstack",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity);
1070 +  TH1F *MCcentral = CollapseStack(mcstack);
1071 +
1072 +  cout << "\r Creating " << filename << " : MC central (histo)   (3/11)" << std::flush;
1073 +  TH1F *TCentral        = allsamples.Draw ("TCentral",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,allsamples.FindSample("TTJets_"));
1074 +  TH1F *RCentral        = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TCentral);
1075 +  
1076 +  cout << "\r Creating " << filename << " : MC Matching up   (4/11)" << std::flush;
1077 +  TH1F *TMatchingUp     = systsamples.Draw("TMatchingUp",  mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_matchingup"));
1078 +  TH1F *RMatchingUp     = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TMatchingUp);
1079 +  
1080 +  cout << "\r Creating " << filename << " : MC Matching down   (5/11)" << std::flush;
1081 +  TH1F *TMatchingDown   = systsamples.Draw("TMatchingDown",mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_matchingdown"));
1082 +  TH1F *RMatchingDown   = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TMatchingDown);
1083 +  
1084 +  cout << "\r Creating " << filename << " : MC Scale up   (6/11)" << std::flush;
1085 +  TH1F *TScaleUp        = systsamples.Draw("TScaleUp",     mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_scaleup"));
1086 +  TH1F *RScaleUp        = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TScaleUp);
1087 +  
1088 +  cout << "\r Creating " << filename << " : MC Scale down   (7/11)" << std::flush;
1089 +  TH1F *TScaleDown      = systsamples.Draw("TScaleDown",   mcvariable,nbins,min,max,xlabel,"events",cut,mc,luminosity,systsamples.FindSample("TTJets_scaledown"));
1090 +  TH1F *RScaleDown      = ProduceTTbarRatio(datahisto,MCcentral,TCentral,TScaleDown);
1091 +  
1092 +  datahisto->Draw("e1");
1093 +  ckin->Update();
1094 +  mcstack.Draw("histo,same");
1095 +  
1096 +  datahisto->Draw("same,e1");
1097 +  TLegend *kinleg = allsamples.allbglegend();
1098 +  kinleg->Draw();
1099  
1100 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1101 +  kinpad->SetLogy(dolog);
1102 +  kinpad->cd();
1103 +  datahisto->Draw("e1");
1104 +  mcstack.Draw("histo,same");
1105 +  datahisto->Draw("same,e1");
1106 +  datahisto->Draw("same,axis");
1107 +  
1108 +  kinleg->Draw("same");
1109 +  DrawPrelim();
1110 +  string saveas="kin/"+filename;
1111 +  
1112 +  cout << "Passing filename to be saved : " << filename << " as " << saveas << endl;
1113 +  Save_With_Ratio( datahisto, CollapseStack(mcstack), kinpad->cd(), saveas, false, false, "data/mc");
1114 +  delete kinpad;
1115 +  
1116 +  ckin->cd();
1117 +  TCentral->SetLineColor(kBlack);
1118 +  
1119 +  TMatchingUp->SetLineColor(TColor::GetColor("#2c17b1"));//blue
1120 +  TMatchingUp->SetLineStyle(2);//dashed
1121 +  TMatchingDown->SetLineColor(TColor::GetColor("#2c17b1"));
1122 +  TMatchingDown->SetLineStyle(3);//dotted
1123 +  
1124 +  TScaleUp->SetLineColor(TColor::GetColor("#FF8500"));//orange
1125 +  TScaleUp->SetLineStyle(2);//dashed
1126 +  TScaleDown->SetLineColor(TColor::GetColor("#FF8500"));
1127 +  TScaleDown->SetLineStyle(3);//dotted
1128 +  
1129 +  MCcentral->SetLineStyle(3);
1130 +  MCcentral->SetLineColor(kRed);
1131 +  
1132 +  TCentral->Draw("e1,same");
1133 +  TCentral->Draw("histo,same");
1134 +  TMatchingUp->Draw("histo,same");
1135 +  TMatchingDown->Draw("histo,same");
1136 +  TScaleUp->Draw("histo,same");
1137 +  TScaleDown->Draw("histo,same");
1138 +  
1139 +  TLegend *sleg = make_legend();
1140 +  sleg->AddEntry(TCentral,"Central","L");
1141 +  sleg->AddEntry(TMatchingUp,"matching up","L");
1142 +  sleg->AddEntry(TMatchingDown,"matching down","L");
1143 +  sleg->AddEntry(TScaleUp,"scale up","L");
1144 +  sleg->AddEntry(TScaleDown,"scale down","L");
1145 +  sleg->Draw();
1146 +  
1147 +  CompleteSave(ckin,saveas+"___AllLines");
1148 +  ckin->cd();
1149 +  ckin->SetLogy(0);
1150 +  
1151 +  RCentral->SetLineColor(kBlack);
1152 +  
1153 +  RMatchingUp->SetLineColor(TColor::GetColor("#2c17b1"));//blue
1154 +  RMatchingUp->SetLineStyle(2);//dashed
1155 +  RMatchingDown->SetLineColor(TColor::GetColor("#2c17b1"));
1156 +  RMatchingDown->SetLineStyle(3);//dotted
1157 +  
1158 +  RScaleUp->SetLineColor(TColor::GetColor("#FF8500"));//orange
1159 +  RScaleUp->SetLineStyle(2);//dashed
1160 +  RScaleDown->SetLineColor(TColor::GetColor("#FF8500"));
1161 +  RScaleDown->SetLineStyle(3);//dotted
1162 +  
1163 +  RCentral->GetYaxis()->SetRangeUser(0,2);
1164 +  RCentral->Draw("e1");
1165 +  RMatchingUp->Draw("histo,same");
1166 +  RMatchingDown->Draw("histo,same");
1167 +  RScaleUp->Draw("histo,same");
1168 +  RScaleDown->Draw("histo,same");
1169 +  
1170 +  CompleteSave(ckin,saveas+"___AllRatios");
1171 +
1172 +  TCanvas *multicanvas = new TCanvas("multicanvas","multicanvas",1400,700);
1173 +  multicanvas->Divide(2,1);
1174 +  PresentRange(RMatchingUp,RMatchingDown,RCentral,multicanvas->cd(1),"Matching");
1175 +  PresentRange(RScaleUp,RScaleDown,RCentral,multicanvas->cd(2),"Scale");
1176 +  CompleteSave(multicanvas,saveas+"___RangeIllustration");
1177 +  
1178 +  
1179 +  delete datahisto;
1180 +  delete   TCentral;
1181 +  delete   TMatchingUp;
1182 +  delete   TMatchingDown;
1183 +  delete   TScaleUp;
1184 +  delete   TScaleDown;
1185 + //   delete   Ttmass166;
1186 + //   delete   Ttmass169;
1187 + //   delete   Ttmass175;
1188 + //   delete   Ttmass178;
1189 +  
1190 +  delete ckin;
1191 +  
1192 + }
1193 +  
1194 + void make_ttbar_comparison(string variable, int nbins, float min, float max, TCut addcut, bool dolog, string xlabel, string filename) {
1195 +  make_ttbar_comparison(variable, variable, nbins, min, max, addcut, dolog, xlabel, filename);
1196 + }
1197 +
1198 + void ProduceJanPlots() {
1199 +  TCanvas *c1 = new TCanvas("c1","c1");
1200 +  TH1F *metSF = allsamples.Draw("metSF","met[4]",30,100,400, "E_{T}^{miss} [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
1201 +  TH1F *metOF = allsamples.Draw("metOF","met[4]",30,100,400, "E_{T}^{miss} [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
1202 +  
1203 +  TPad* rcan = new TPad("rcan","rcan",0,0,1,1);
1204 +  rcan->cd();
1205 +
1206 +  metOF->SetLineColor(kRed);
1207 +  metSF->Draw("e1");
1208 +  metOF->Draw("histo,same");
1209 +  metSF->Draw("e1,same");
1210 +  
1211 +  TLegend *leg = make_legend();
1212 +  
1213 +  leg->AddEntry(metSF,"Data SF","p");
1214 +  leg->AddEntry(metOF,"Data OF","l");
1215 +  leg->Draw();
1216 +  
1217 +  DrawPrelim();
1218 +  
1219 +  Save_With_Ratio(metSF,metOF,rcan,"JanPlots/ETHConfig",false,false,"SF/OF");
1220 +  
1221 +  delete rcan;
1222 +  delete metSF;
1223 +  delete metOF;
1224 +  delete c1;
1225 + }
1226 +
1227 + THStack MakeOneSystematicsPlot(TCut cut, string saveas, string variation, TH1F *hdata, string variable, int nbins, float bmin, float bmax, string label, TH1F* &thisto) {
1228 +  THStack SystPlot = allsamples.DrawStack(variation,variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity);
1229 +  
1230 +  //now need to process the plot (calculate the variation and set the member of thstack accordingly!)
1231 +  if(variation!="Central") {
1232 +    TH1F *varttbar;
1233 +    if(variation=="MatchingUp") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_matchingup_TuneZ2s"));
1234 +    if(variation=="MatchingDown") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_matchingdown"));
1235 +    if(variation=="ScaleUp") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_scaleup"));
1236 +    if(variation=="ScaleDown") varttbar = systsamples.Draw("varttbar",variable,nbins,bmin,bmax,label,"events",cut,mc,PlottingSetup::luminosity,systsamples.FindSample("TTJets_scaledown"));
1237 +    assert(varttbar);
1238 +    
1239 +    TIter nextHisto(SystPlot.GetHists());
1240 +    TH1F* h;
1241 +    while ( h = (TH1F*)nextHisto() ) {
1242 +      if(Contains(h->GetName(),"t_bar_t")) {
1243 +        varttbar->Scale(h->Integral()/varttbar->Integral());
1244 +        for(int i=0;i<=h->GetNbinsX()+1;i++) {//note that we deliberatly consider the under/overflow bin as well!
1245 +          h->SetBinContent(i,varttbar->GetBinContent(i));
1246 +          h->SetBinError(i,varttbar->GetBinError(i));
1247 +        }
1248 +        thisto=(TH1F*)varttbar->Clone(variation.c_str());
1249 +        SystPlot.Modified();
1250 +      }
1251 +    }
1252 +    delete varttbar;
1253 +  } else {
1254 +    TIter nextHisto(SystPlot.GetHists());
1255 +    TH1F* h;
1256 +    while ( h = (TH1F*)nextHisto() ) {
1257 +      if(Contains(h->GetName(),"t_bar_t")) thisto=(TH1F*)h->Clone(variation.c_str());
1258 +    }
1259 +  }
1260 +    
1261 +  TLegend *fullleg = allsamples.allbglegend();
1262 +  fullleg->SetHeader(variation.c_str());
1263 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1264 +  kinpad->SetLogy(1);
1265 +  kinpad->cd();
1266 +  
1267 +  hdata->Draw("e1");
1268 +  SystPlot.Draw("histo,same");
1269 +  hdata->Draw("e1,same");
1270 +  fullleg->Draw();
1271 +  DrawPrelim();
1272 +  
1273 +  Save_With_Ratio(hdata,SystPlot,kinpad,saveas+"_"+variation);
1274 +  CleanLegends();
1275 +  
1276 +  delete kinpad;
1277 +  return SystPlot;
1278 + }
1279 +  
1280 +
1281 +
1282 + void ProduceMCSystematicPlot(string variable, int nbins, float bmin, float bmax, string label, TCut thiscut, string saveas) {
1283 +  TCanvas *ca = new TCanvas("ca","ca");
1284 +  TH1F *hdata = allsamples.Draw("hdata",variable,nbins,bmin,bmax,label,"events",thiscut,data,luminosity);
1285 +  
1286 +  TH1F *tScaleUp,*tScaleDown,*tMatchingUp,*tMatchingDown,*tCentral;
1287 +  
1288 +  THStack ScaleUp      = MakeOneSystematicsPlot(thiscut,saveas,"ScaleUp",hdata,variable, nbins, bmin, bmax, label,tScaleUp);
1289 +  THStack ScaleDown    = MakeOneSystematicsPlot(thiscut,saveas,"ScaleDown",hdata,variable, nbins, bmin, bmax, label,tScaleDown);
1290 +  THStack MatchingUp   = MakeOneSystematicsPlot(thiscut,saveas,"MatchingUp",hdata,variable, nbins, bmin, bmax, label,tMatchingUp);
1291 +  THStack MatchingDown = MakeOneSystematicsPlot(thiscut,saveas,"MatchingDown",hdata,variable, nbins, bmin, bmax, label,tMatchingDown);
1292 +  
1293 +  TH1F *HScaleUp = CollapseStack(ScaleUp);
1294 +  TH1F *HScaleDown = CollapseStack(ScaleDown);
1295 +  TH1F *HMatchingUp = CollapseStack(MatchingUp);
1296 +  TH1F *HMatchingDown = CollapseStack(MatchingDown);
1297 +  
1298 +  THStack Central = MakeOneSystematicsPlot(thiscut,saveas,"Central",hdata,variable, nbins, bmin, bmax, label,tCentral);
1299 +  TH1F *HCentral = CollapseStack(Central);
1300 +  
1301 +  TH1F *Systematic = (TH1F*)hdata->Clone("Systematic");
1302 +  for(int i=1;i<=Systematic->GetNbinsX();i++) {
1303 +    float matchingup   = abs(HMatchingUp->GetBinContent(i)-HCentral->GetBinContent(i));
1304 +    float matchingdown = abs(HMatchingDown->GetBinContent(i)-HCentral->GetBinContent(i));
1305 +    float scaleup   = abs(HScaleUp->GetBinContent(i)-HCentral->GetBinContent(i));
1306 +    float scaledown = abs(HScaleDown->GetBinContent(i)-HCentral->GetBinContent(i));
1307 +    
1308 +    float matching = matchingup>matchingdown?matchingup:matchingdown;
1309 +    float scale    = scaleup>scaledown?scaleup:scaledown;
1310 +    
1311 +    float sys=sqrt(matching*matching+scale*scale);
1312 +    sys/=HCentral->GetBinContent(i);
1313 +    if(HCentral->GetBinContent(i)==0) sys=0;
1314 +    Systematic->SetBinContent(i,sys);
1315 +  }
1316 +  
1317 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1318 +  kinpad->SetLogy(1);
1319 +  kinpad->cd();
1320 +  if(variable=="genMET") {
1321 +    Central.Draw("histo");
1322 +  } else {
1323 +    hdata->Draw("e1");
1324 +    Central.Draw("histo,same");
1325 +    hdata->Draw("e1,same");
1326 +  }
1327 +  
1328 +  DrawPrelim();
1329 +  
1330 +  save_with_ratio_and_sys_band( hdata, HCentral, kinpad->cd(), saveas, false, false, "data/mc",Systematic );
1331 +  
1332 +  kinpad->cd();
1333 +  tCentral->SetFillColor(kWhite);
1334 +  tCentral->SetLineColor(kBlack);
1335 +  tScaleUp->SetLineColor(kRed);
1336 +  tScaleDown->SetLineColor(kRed);
1337 +  tMatchingUp->SetLineColor(kBlue);
1338 +  tMatchingDown->SetLineColor(kBlue);
1339 +  tScaleUp->SetLineStyle(2);
1340 +  tScaleDown->SetLineStyle(3);
1341 +  tMatchingUp->SetLineStyle(2);
1342 +  tMatchingDown->SetLineStyle(3);
1343 +  
1344 +  TLegend *leg2 = make_legend();
1345 +  leg2->AddEntry(hdata,"Data","p");
1346 +  leg2->AddEntry(tCentral,"Central (ttbar)","l");
1347 +  leg2->AddEntry(tScaleUp,"ScaleUp (ttbar)","l");
1348 +  leg2->AddEntry(tScaleDown,"ScaleDown (ttbar)","l");
1349 +  leg2->AddEntry(tMatchingUp,"MatchingUp (ttbar)","l");
1350 +  leg2->AddEntry(tMatchingDown,"MatchingDown (ttbar)","l");
1351 +  if(variable=="genMET") {
1352 +    Central.Draw("histo");
1353 +  }else {
1354 +    hdata->Draw("e1");
1355 +    Central.Draw("histo,same");
1356 +    hdata->Draw("e1,same");
1357 +  }
1358 +  tCentral->Draw("histo,same");
1359 +  tScaleUp->Draw("histo,same");
1360 +  tScaleDown->Draw("histo,same");
1361 +  tMatchingUp->Draw("histo,same");
1362 +  tMatchingDown->Draw("histo,same");
1363 +  leg2->Draw();
1364 +  
1365 +  CompleteSave(kinpad,saveas+"__TTbarComparison");
1366 +  
1367 +  gStyle->SetOptFit(0);
1368 +  
1369 +  kinpad->cd();
1370 +  kinpad->SetLogy(0);
1371 +  TH1F *MatchingRatio = (TH1F*)tMatchingUp->Clone("MatchingRatio");
1372 +  MatchingRatio->Divide(tMatchingDown);
1373 +  TLine *lone = new TLine(tScaleUp->GetBinLowEdge(1),1,tScaleUp->GetBinLowEdge(tScaleUp->GetNbinsX())+tScaleUp->GetBinWidth(tScaleUp->GetNbinsX()),1);
1374 +  lone->SetLineColor(TColor::GetColor("#01DF01"));
1375 +  lone->SetLineStyle(2);
1376 +  TH1F *ScaleRatio = (TH1F*)tScaleUp->Clone("ScaleRatio");
1377 +  ScaleRatio->Divide(tScaleDown);
1378 +  MatchingRatio->GetYaxis()->SetRangeUser(0,3);
1379 +  MatchingRatio->Draw("e1");
1380 +  TF1 *QP1 = new TF1("QP1","[0]+[1]*x",50,200);//simple linear function ranging from 50 to 200
1381 +  MatchingRatio->Fit("QP1","R");
1382 +  lone->Draw();
1383 +  stringstream summary;
1384 +  summary << " #splitline{Fit result for f(x) = a+bx :}{#splitline{a=" << DigitsAfterComma(QP1->GetParameter(0),4) << " +/- " << DigitsAfterComma(QP1->GetParError(0),4) << "}{b=" << DigitsAfterComma(QP1->GetParameter(1),4);
1385 +  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1386 +  TText *infobox = write_title(summary.str());
1387 +  infobox->SetX(0.75);
1388 +  infobox->SetTextSize(0.03);
1389 +  infobox->SetY(0.75);
1390 +  infobox->Draw();
1391 +  CompleteSave(kinpad,saveas+"__TTbarComparison_MatchingUpDividedMatchingDown");
1392 +  kinpad->cd();
1393 +  ScaleRatio->GetYaxis()->SetRangeUser(0,3);
1394 +  ScaleRatio->Draw("e1");
1395 +  ScaleRatio->Fit("QP1","R");
1396 +  summary.str("");
1397 +  summary << " #splitline{Fit result for f(x) = a+bx :}{#splitline{a=" << DigitsAfterComma(QP1->GetParameter(0),4) << " +/- " << DigitsAfterComma(QP1->GetParError(0),4) << "}{b=" << DigitsAfterComma(QP1->GetParameter(1),4);
1398 +  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1399 +  TText *infobox2 = write_title(summary.str());
1400 +  infobox2->SetX(0.75);
1401 +  infobox2->SetTextSize(0.03);
1402 +  infobox2->SetY(0.75);
1403 +  infobox2->Draw();
1404 +
1405 +  lone->Draw();
1406 +  CompleteSave(kinpad,saveas+"__TTbarComparison_ScaleUpDividedScaleDown");
1407 +  
1408 +  
1409 +  delete QP1;
1410 +  delete infobox;
1411 +  delete infobox2;
1412 +  delete MatchingRatio;
1413 +  delete ScaleRatio;
1414 +  DeleteStack(ScaleUp);
1415 +  DeleteStack(ScaleDown);
1416 +  DeleteStack(MatchingUp);
1417 +  DeleteStack(MatchingDown);
1418 +  delete leg2;
1419 +  CleanLegends();
1420 +  DeleteStack(Central);
1421 +  delete Systematic;
1422 +  delete HScaleUp;
1423 +  delete HScaleDown;
1424 +  delete HMatchingUp;
1425 +  delete HMatchingDown;
1426 +  delete hdata;
1427 +  delete HCentral;
1428 +  delete ca;
1429 + }
1430 +
1431 + void QuickProduceMCSystematicPlot(string variable, int nbins, float bmin, float bmax, string label, TCut thiscut, string saveas) {
1432 +  TCanvas *ca = new TCanvas("ca","ca");
1433 +  TH1F *tScaleUp = systsamples.Draw("tScaleUp",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("scaleup"));
1434 +  TH1F *tScaleDown = systsamples.Draw("tScaleDown",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("scaledown"));
1435 +  TH1F *tMatchingUp = systsamples.Draw("tMatchingUp",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("matchingup"));
1436 +  TH1F *tMatchingDown = systsamples.Draw("tMatchingDown",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("matchingdown"));
1437 +  TH1F *tCentral = systsamples.Draw("tCentral",variable,nbins,bmin,bmax,label,"events",thiscut,mc,luminosity,systsamples.FindSample("TTJets_MassiveBinDECAY_TuneZ2sta"));
1438 +  
1439 +  tScaleUp->Scale(1.0/tScaleUp->Integral());
1440 +  tScaleDown->Scale(1.0/tScaleDown->Integral());
1441 +  tMatchingDown->Scale(1.0/tMatchingDown->Integral());
1442 +  tMatchingUp->Scale(1.0/tMatchingUp->Integral());
1443 +  
1444 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1445 +  kinpad->SetLogy(1);
1446 +  kinpad->cd();
1447 +  tCentral->SetFillColor(kWhite);
1448 +  tCentral->SetLineColor(kBlack);
1449 +  tScaleUp->SetLineColor(kRed);
1450 +  tScaleDown->SetLineColor(kRed);
1451 +  tMatchingUp->SetLineColor(kBlue);
1452 +  tMatchingDown->SetLineColor(kBlue);
1453 +  tScaleUp->SetLineStyle(2);
1454 +  tScaleDown->SetLineStyle(3);
1455 +  tMatchingUp->SetLineStyle(2);
1456 +  tMatchingDown->SetLineStyle(3);
1457 +  
1458 +  TLegend *leg2 = make_legend();
1459 +  leg2->AddEntry(tCentral,"Central (ttbar)","l");
1460 +  leg2->AddEntry(tScaleUp,"ScaleUp (ttbar)","l");
1461 +  leg2->AddEntry(tScaleDown,"ScaleDown (ttbar)","l");
1462 +  leg2->AddEntry(tMatchingUp,"MatchingUp (ttbar)","l");
1463 +  leg2->AddEntry(tMatchingDown,"MatchingDown (ttbar)","l");
1464 +  
1465 +  tCentral->Draw("histo");
1466 +  tScaleUp->Draw("histo,same");
1467 +  tScaleDown->Draw("histo,same");
1468 +  tMatchingUp->Draw("histo,same");
1469 +  tMatchingDown->Draw("histo,same");
1470 +  leg2->Draw();
1471 +  
1472 +  CompleteSave(kinpad,saveas+"__TTbarComparison");
1473 +  
1474 +  gStyle->SetOptFit(0);
1475 +  
1476 +  kinpad->cd();
1477 +  kinpad->SetLogy(0);
1478 +  TH1F *MatchingRatio = (TH1F*)tMatchingUp->Clone("MatchingRatio");
1479 +  MatchingRatio->Divide(tMatchingDown);
1480 +  TLine *lone = new TLine(tScaleUp->GetBinLowEdge(1),1,tScaleUp->GetBinLowEdge(tScaleUp->GetNbinsX())+tScaleUp->GetBinWidth(tScaleUp->GetNbinsX()),1);
1481 +  lone->SetLineColor(TColor::GetColor("#01DF01"));
1482 +  lone->SetLineStyle(2);
1483 +  TH1F *ScaleRatio = (TH1F*)tScaleUp->Clone("ScaleRatio");
1484 +  ScaleRatio->Divide(tScaleDown);
1485 +  MatchingRatio->GetYaxis()->SetRangeUser(0,3);
1486 +  MatchingRatio->Draw("e1");
1487 +  TF1 *QP1 = new TF1("QP1","[0]+[1]*x",50,200);//simple linear function ranging from 50 to 200
1488 +  MatchingRatio->Fit("QP1","RQ");
1489 +  lone->Draw();
1490 +  stringstream summary;
1491 +  summary << " #splitline{Fit result for f(x) = a+bx :}{#splitline{a=" << DigitsAfterComma(QP1->GetParameter(0),4) << " +/- " << DigitsAfterComma(QP1->GetParError(0),4) << "}{b=" << DigitsAfterComma(QP1->GetParameter(1),4);
1492 +  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1493 +  TText *infobox = write_title(summary.str());
1494 +  infobox->SetX(0.75);
1495 +  infobox->SetTextSize(0.03);
1496 +  infobox->SetY(0.75);
1497 +  infobox->Draw();
1498 +  CompleteSave(kinpad,saveas+"__TTbarComparison_MatchingUpDividedMatchingDown");
1499 +  kinpad->cd();
1500 +  ScaleRatio->GetYaxis()->SetRangeUser(0,3);
1501 +  ScaleRatio->Draw("e1");
1502 +  ScaleRatio->Fit("QP1","RQ");
1503 +  summary.str("");
1504 +  summary << " #splitline{Fit result for f(x) = a+bx :}{#splitline{a=" << DigitsAfterComma(QP1->GetParameter(0),4) << " +/- " << DigitsAfterComma(QP1->GetParError(0),4) << "}{b=" << DigitsAfterComma(QP1->GetParameter(1),4);
1505 +  summary << " +/- " << DigitsAfterComma(QP1->GetParError(1),4) << "}}";
1506 +  TText *infobox2 = write_title(summary.str());
1507 +  infobox2->SetX(0.75);
1508 +  infobox2->SetTextSize(0.03);
1509 +  infobox2->SetY(0.75);
1510 +  infobox2->Draw();
1511 +
1512 +  lone->Draw();
1513 +  CompleteSave(kinpad,saveas+"__TTbarComparison_ScaleUpDividedScaleDown");
1514 +  
1515 +  delete tScaleUp;
1516 +  delete tScaleDown;
1517 +  delete tCentral;
1518 +  delete tMatchingUp;
1519 +  delete tMatchingDown;
1520 +  delete QP1;
1521 +  delete infobox;
1522 +  delete infobox2;
1523 +  delete MatchingRatio;
1524 +  delete ScaleRatio;
1525 +  delete leg2;
1526 +  CleanLegends();
1527 +  delete ca;
1528 + }
1529 +
1530 + void ProduceMCSystematicPlots() {
1531 +  cout << "Getting ready to produce systematic plots " << endl;
1532 +  TCut cutweightBKP = cutWeight;
1533 +  
1534 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor");
1535 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor");  
1536 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor");
1537 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor");
1538 +  
1539 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE");
1540 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE");  
1541 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE_HighMass");
1542 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE_HighMass");  
1543 +  
1544 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE");
1545 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE");
1546 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE_HighMass");
1547 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE_HighMass");
1548 +  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_SameFlavor");
1549 +  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/ETH_OppositeFlavor");
1550 +  
1551 +  
1552 +  
1553 +  cout << "Kicking cutWeight  " << (const char*) cutWeight << endl;
1554 +  cout << "Keeping OSSF cut " << (const char*)cutOSSF << endl;
1555 +  cutWeight="1.0";
1556 +  
1557 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE__NOPURW");
1558 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE__NOPURW");  
1559 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1560 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/ETH_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");  
1561 +  
1562 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE__NOPURW");
1563 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE__NOPURW");
1564 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/ETH_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1565 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/ETH_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");
1566 +  
1567 +  
1568 +  // --------------------------------------    ***** AACHEN *****      --------------------------------------    
1569 +  
1570 +  
1571 +  cutWeight=cutweightBKP;
1572 +  TCut essentialcutBKP = essentialcut;
1573 +  cout << (const char*) essentialcut << endl;
1574 +  
1575 +  essentialcut = TCut((ReplaceAll((const char*)essentialcut,"pt2>20","pt2>10")).c_str());
1576 +  essentialcut = TCut((ReplaceAll((const char*)essentialcut,"abs(eta1)<1.4","abs(eta1)<2.4")).c_str());
1577 +  essentialcut = TCut((ReplaceAll((const char*)essentialcut,"abs(eta2)<1.4","abs(eta2)<2.4")).c_str());
1578 +  
1579 +  TCut cutnJetsBKP = cutnJets;
1580 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"pt2>20","pt2>10")).c_str());
1581 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"pfJetGoodNum40>=3","pfJetGoodNum40>=2")).c_str());
1582 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"abs(eta2)<1.4","abs(eta2)<2.4")).c_str());
1583 +  cutnJets = TCut((ReplaceAll((const char*)cutnJets,"abs(eta1)<1.4","abs(eta1)<2.4")).c_str());
1584 +  
1585 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor");
1586 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor");  
1587 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor");
1588 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor");
1589 +  
1590 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE");
1591 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE");  
1592 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE_HighMass");
1593 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE_HighMass");  
1594 +  
1595 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE");
1596 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE");
1597 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE_HighMass");
1598 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE_HighMass");
1599 +  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSSF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/Aachen_SameFlavor");
1600 +  QuickProduceMCSystematicPlot("pfJetGoodNum40",8,-0.5,7.5,"NJets",cutOSOF&&cutnJets&&TCut("mll>20&&mll<70&&met[4]>100"),"MCSystPlots/NJets/Aachen_OppositeFlavor");
1601 +  
1602 +  
1603 +  
1604 +  cout << "Kicking cutWeight  " << (const char*) cutWeight << endl;
1605 +  cout << "Keeping OSSF cut " << (const char*)cutOSSF << endl;
1606 +  cutWeight="1.0";
1607 +  
1608 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE__NOPURW");
1609 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE__NOPURW");  
1610 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1611 +  QuickProduceMCSystematicPlot("genMET",20,0,200,"genMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/genMET/Aachen_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");  
1612 +  
1613 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE__NOPURW");
1614 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>20&&mll<70"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE__NOPURW");
1615 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSSF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_SameFlavor_INCLUSIVE_HighMass__NOPURW");
1616 +  QuickProduceMCSystematicPlot("met[4]",20,0,200,"PFMET [GeV]",cutOSOF&&TCut("mll>120"),"MCSystPlots/MET/Aachen_OppositeFlavor_INCLUSIVE_HighMass__NOPURW");
1617 +  
1618 +  cutnJets  = cutnJetsBKP;
1619 +  cutWeight = cutweightBKP;
1620 +  essentialcut = essentialcutBKP;
1621 +  
1622 +  write_error(__FUNCTION__,"Still need to add systematic shape");assert(0);
1623 + }
1624 +
1625 + void MakeTauPlot(string label, TCut pcut, string filename, bool TauOnly) {
1626 +  TCut cut=pcut&&basiccut;
1627 +  string variable="mll";
1628 +  string xlabel="m_{ll} [GeV]";
1629 +  int nbins=40;
1630 +  float min=0;
1631 +  float max=200;
1632 +
1633 +  TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
1634 +  TH1F *datahistoSF = allsamples.Draw("datahistoSF",variable,nbins,min,max, xlabel, "events",cut&&cutOSSF,data,luminosity);
1635 +  TH1F *datahistoOF = allsamples.Draw("datahistoOF",variable,nbins,min,max, xlabel, "events",cut&&cutOSOF,data,luminosity);
1636 +  TH1F *tauSF = allsamples.Draw("tauSF",variable,nbins,min,max, xlabel, "events",cut&&cutOSSF,data,luminosity,systsamples.FindSample("DYToTauTau"));
1637 +  TH1F *tauOF = allsamples.Draw("tauOF",variable,nbins,min,max, xlabel, "events",cut&&cutOSOF,data,luminosity,systsamples.FindSample("DYToTauTau"));
1638 +  datahistoSF->SetMarkerSize(DataMarkerSize);
1639 +  datahistoSF->SetMaximum(1.3*datahistoSF->GetMaximum());
1640 +  datahistoOF->SetMarkerSize(DataMarkerSize);
1641 +  datahistoOF->SetMaximum(1.3*datahistoOF->GetMaximum());
1642 +
1643 +  THStack mcstackSF   = allsamples.DrawStack("mcstackSF",  variable,nbins,min,max,xlabel,"events",cut&&cutOSSF,mc,luminosity);
1644 +  THStack mcstackOF   = allsamples.DrawStack("mcstackOF",  variable,nbins,min,max,xlabel,"events",cut&&cutOSOF,mc,luminosity);
1645 +  datahistoSF->Draw("e1");
1646 +  ckin->Update();
1647 +  mcstackSF.Draw("histo,same");
1648 +  
1649 +  datahistoSF->Draw("same,e1");
1650 +  TLegend *kinleg = allsamples.allbglegend();
1651 +  kinleg->Draw();
1652 +  
1653 +  TPad *kinpad = new TPad("kinpad","kinpad",0,0,1,1);
1654 +  kinpad->cd();
1655 +  datahistoSF->Draw("e1");
1656 +  mcstackSF.Draw("histo,same");
1657 +  datahistoSF->Draw("same,e1");
1658 +  datahistoSF->Draw("same,axis");
1659 +  kinleg->Draw();
1660 +  DrawPrelim();
1661 +  Save_With_Ratio(datahistoSF,mcstackSF,kinpad->cd(),filename+"__SF_mc");
1662 +  
1663 +  kinpad->cd();
1664 +  datahistoOF->Draw("e1");
1665 +  mcstackOF.Draw("histo,same");
1666 +  datahistoOF->Draw("same,e1");
1667 +  datahistoOF->Draw("same,axis");
1668 +  kinleg->Draw();
1669 +  DrawPrelim();
1670 +  Save_With_Ratio(datahistoOF,mcstackOF,kinpad->cd(),filename+"__OF_mc");
1671 +  
1672 +  kinpad->cd();
1673 +  tauSF->Draw("e1");
1674 +  tauOF->Draw("histo,same");
1675 +  tauSF->Draw("e1,same");
1676 +  TLegend *legtau = make_legend();
1677 +  legtau->AddEntry(tauSF,"DY->#tau#tau, SF","p");
1678 +  legtau->AddEntry(tauSF,"DY->#tau#tau, OF","l");
1679 +  legtau->Draw();
1680 +  DrawPrelim();
1681 +  Save_With_Ratio(tauSF,tauOF,kinpad->cd(),filename+"__Tau_SF_vs_OF");
1682 +  
1683 +  delete datahistoSF;
1684 +  delete datahistoOF;
1685 +  delete tauSF;
1686 +  delete tauOF;
1687 +  delete kinpad;
1688 +  delete ckin;
1689 +  CleanLegends();
1690 + }
1691 +  
1692 +
1693 + void TauQuestion() {
1694 + //   MakeTauPlot("MET>100 GeV, #geq 3 jets",cutnJets&&TCut("met[4]>100"),"TauQ/MET100_3Jets",true);
1695 + //   MakeTauPlot("MET>100 GeV",TCut("met[4]>100"),"TauQ/MET100",true);
1696 + //   MakeTauPlot("MET>0 GeV",TCut("met[4]>0"),"TauQ/MET0",true);
1697 +  MakeTauPlot("b-tag veto, 50<MET<100",TCut("pfJetGoodNumBtag30==0&&met[4]>50&&met[4]<100"),"TauQ/ControlPlots",false);
1698   }
1699  
1700   void do_kinematic_plots(string mcjzb, string datajzb, bool doPF=false)
# Line 753 | Line 1704 | void do_kinematic_plots(string mcjzb, st
1704    bool nolog=false;
1705  
1706    bool doOFSF = false;
1707 <  bool doKin  = false;
1708 <  bool doDataComp = true;
1707 >  bool doKin  = true;
1708 >  bool doDataComp = false;
1709 >  bool MakeTwoThreeJetComparison = false;
1710    
1711  
1712    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
# Line 764 | Line 1716 | void do_kinematic_plots(string mcjzb, st
1716          mll_low=20;
1717          mll_hi=320;
1718    }
1719 +  
1720 +  if(MakeTwoThreeJetComparison) MakeElegantTwoThreeComparisons();
1721 +  
1722 +  //TauQuestion();
1723  
1724 +  //ProduceJanPlots();
1725 +  //ProduceMCSystematicPlots();
1726 + //  make_plain_kin_plot("pt",Cut2Str(cutOSSF&&TCut("mll>20&&pfJetGoodNumBtag30>=2")),40,0,200,nolog,"Z p_{T}","PlotForKostas",doPF,true);
1727 +  
1728    if ( doOFSF ) {
1729       make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll");
1730 +     make_OFSF_plots("met[4]", "met[4]>100", 30, 100., 400., false, "PFMET", "met");
1731 +     make_OFSF_plots("leptonNum", "met[4]>100", 3, 2, 5., false, "N(leptons)", "NLeptons");
1732  
1733 < //      make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
1734 < //      make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
1735 < //      make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
1736 <
1737 < //      make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
1738 < //      make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
1739 <
1740 < //     make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
1741 < //     make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
1742 <    //  make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
1743 <    //  make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
1744 < //     make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
1745 < //     make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
1746 <    //  make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
1747 <    //  make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
1748 < //     make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
1749 <    make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
1750 < //    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
1751 < //    make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
1752 < //    make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
1753 < //    make_OFSF_plots("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", "met[4]>100", 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", "dphilc");
1754 < //    make_OFSF_plots("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", "met[4]>100", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijc");
1755 < //    make_OFSF_plots("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", "met[4]>100", 16, 0, 3.2, false, "Min(#pi - |#Delta#phi(l,MET)|)", "dphilco");
1756 < //    make_OFSF_plots("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", "met[4]>100", 16, 0, 3.2, false, "Min(#pi - |#Delta#phi(jet,MET)|)", "dphijco");
1733 >     make_OFSF_plots("pfJetGoodNum40", "met[4]>100",                        7, 3, 10, true, "#(jets)", "njets");
1734 >     make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30==0", 7, 3, 10, true, "#(jets)", "njets_btagVeto");
1735 >     make_OFSF_plots("pfJetGoodNum40", "met[4]>100&&pfJetGoodNumBtag30>0",  7, 3, 10, true, "#(jets)", "njets_AtLeastOneBJet30");
1736 >
1737 >     make_OFSF_plots("pfJetGoodNumBtag30", "met[4]>100", 5, 0, 5, true, "#(b-jets)", "nbjets");
1738 >     make_OFSF_plots("pfJetGoodPtBtag[0]", "met[4]>100&&pfJetGoodNumBtag30>0", 20, 0, 400, true, "p_{T}(leading b-jet)", "ptb1");
1739 >
1740 >     make_OFSF_plots("iso1", "met[4]>100", 20, 0, 0.3, true, "lepton 1 isolation", "iso1");
1741 >     make_OFSF_plots("iso2", "met[4]>100", 20, 0, 0.3, true, "lepton 2 isolation", "iso2");
1742 >     make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1");
1743 >     make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2");
1744 >     make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", 0.15);
1745 >     make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", 0.15);
1746 >     make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", 0.2);
1747 >     make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", 0.2);
1748 >     make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", 0.2);
1749 >     make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", 0.2);
1750 >    make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", 0.2);
1751 >    make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", 0.2);
1752 >    make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", 0.2);
1753 >    make_OFSF_plots("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", "met[4]>100", 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", "dphilc");
1754 >    make_OFSF_plots("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", "met[4]>100", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijc");
1755 >    make_OFSF_plots("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", "met[4]>100", 16, 0, 3.2, false, "Min(#pi - |#Delta#phi(l,MET)|)", "dphilco");
1756 >    make_OFSF_plots("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", "met[4]>100", 16, 0, 3.2, false, "Min(#pi - |#Delta#phi(jet,MET)|)", "dphijco");
1757    }
1758  
1759    if ( doDataComp) {
# Line 808 | Line 1770 | void do_kinematic_plots(string mcjzb, st
1770  
1771      TCut cutSignal = cutmass&&cutnJets&&"met[4]>100";
1772      
1773 < /*    make_data_comparison_plot("met[4]", cutOSSF,60, 0., 300.,-1., true, "pfMET", "met_SF_inclusive");
1773 >    make_data_comparison_plot("numVtx", "",40, -0.5, 39.5,-1., true, "N(Vertices)", "numVtx");
1774 >    make_data_comparison_plot("pfJetGoodEta[0]", "",50, -3.0, 3.0,-1., true, "N(Jets)", "pfJetGoodEta0");
1775 >    
1776 >    
1777 >    make_data_comparison_plot("pfJetGoodNum40", cutOSOF,10, -0.5, 9.5,-1., true, "N(Jets)", "njets_OF");
1778 >    make_data_comparison_plot("met[4]", cutOSSF,60, 0., 300.,-1., true, "pfMET", "met_SF_inclusive");
1779      make_data_comparison_plot("met[1]", cutOSSF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_SF_inclusive");
1780      make_data_comparison_plot("met[4]", cutOSOF,60, 0., 300.,-1., true, "pfMET", "met_OF_inclusive");
1781      make_data_comparison_plot("met[1]", cutOSOF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_OF_inclusive");
# Line 817 | Line 1784 | void do_kinematic_plots(string mcjzb, st
1784      make_data_comparison_plot("met[1]", cutnJets&&cutOSSF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_SF_exclusive");
1785      make_data_comparison_plot("met[4]", cutnJets&&cutOSOF,60, 0., 300.,-1., true, "pfMET", "met_OF_exclusive");
1786      make_data_comparison_plot("met[1]", cutnJets&&cutOSOF,60, 0., 300.,-1., true, "type 1 corrected pfMET", "mett1_OF_exclusive");
1787 +
1788    
821  */  
1789      string basiccutsaved = (const char*)basiccut;
1790      
1791      string newbasiccut=basiccutsaved;
# Line 829 | Line 1796 | void do_kinematic_plots(string mcjzb, st
1796        newbasiccut.replace( found, string( "pt2>20" ).length(), "pt2>10" );
1797        found = newbasiccut.find( "pt2>20" );
1798      }
1799 < //    basiccut=TCut(newbasiccut.c_str());
1800 < //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSSF,60, 0., 300.,-1., false, "mll", "mll_SF_Aachen_pt2010_met");
1801 < //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSOF,60, 0., 300.,-1., false, "mll", "mll_OF_Aachen_pt2010_met");
1802 < //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_Aachen_pt2010_t1cpfmet");
1803 < //    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_Aachen_pt2010_t1cpfmet");
1804 < //    basiccut=TCut(basiccutsaved.c_str());
1805 <    
1806 < //     make_data_comparison_plot("pfJetGoodNum40", cutOSSF, 8, 0., 8.,-1., true, "#(jets)", "njets_SF");
1807 < //     make_data_comparison_plot("pfJetGoodNum40", cutOSOF, 8, 0., 8.,-1., true, "#(jets)", "njets_OF");
1808 <    
1809 < //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_met");
1810 < //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_met");
1811 < //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_t1cpfmet");
1812 < //     make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_t1cpfmet");
1813 <
1814 <    
1815 < //     make_data_comparison_plot("mll", cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive");
1816 < //     make_data_comparison_plot("mll", cutOSSF&&TCut("id1==0"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_ee");
1817 < //     make_data_comparison_plot("mll", cutOSSF&&TCut("id1==1"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_mm");
1818 < //     make_data_comparison_plot("mll", cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_inclusive");
1799 >    basiccut=TCut(newbasiccut.c_str());
1800 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSSF,60, 0., 300.,-1., false, "mll", "mll_SF_Aachen_pt2010_met");
1801 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[4]>150")&&cutOSOF,60, 0., 300.,-1., false, "mll", "mll_OF_Aachen_pt2010_met");
1802 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_Aachen_pt2010_t1cpfmet");
1803 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=2&&met[1]>150")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_Aachen_pt2010_t1cpfmet");
1804 >    basiccut=TCut(basiccutsaved.c_str());
1805 >    
1806 >    make_data_comparison_plot("pfJetGoodNum40", cutOSSF, 8, 0., 8.,-1., true, "#(jets)", "njets_SF");
1807 >    make_data_comparison_plot("pfJetGoodNum40", cutOSOF, 8, 0., 8.,-1., true, "#(jets)", "njets_OF");
1808 >    
1809 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_met");
1810 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[4]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_met");
1811 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSSF,60, 0., 300.,-1., true, "mll", "mll_SF_ETH_t1cpfmet");
1812 >    make_data_comparison_plot("mll", TCut("pfJetGoodNum40>=3&&met[1]>100")&&cutOSOF,60, 0., 300.,-1., true, "mll", "mll_OF_ETH_t1cpfmet");
1813 >
1814 >    
1815 >    make_data_comparison_plot("mll", cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive");
1816 >    make_data_comparison_plot("mll", cutOSSF&&TCut("id1==0"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_ee");
1817 >    make_data_comparison_plot("mll", cutOSSF&&TCut("id1==1"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_inclusive_mm");
1818 >    make_data_comparison_plot("mll", cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_inclusive");
1819      make_data_comparison_plot("mll", cutnJets&&cutOSSF&&TCut("id1==0"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_exclusive_ee");
1820      make_data_comparison_plot("mll", cutnJets&&cutOSSF&&TCut("id1==1"),60, 15., 315.,-1., true, "m_{ll}", "mll_SF_exclusive_mm");
1821      make_data_comparison_plot("mll", cutnJets&&cutOSSF,60, 15., 315.,-1., true, "m_{ll}", "mll_SF_exclusive");
1822      make_data_comparison_plot("mll", cutnJets&&cutOSOF,60, 15., 315.,-1., true, "m_{ll}", "mll_OF_exclusive");
1823 < /*
1823 >
1824      make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig");
1825 +    make_data_comparison_plot("mll", cutOSOF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig");
1826 +    
1827 +    make_data_comparison_plot("mll", TCut("abs(eta1)<1.4&&abs(eta2)<1.4") && cutOSSF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_central");
1828 +    make_data_comparison_plot("mll", TCut("abs(eta1)<1.4&&abs(eta2)<1.4") && cutOSOF&&cutSignal&&mllCut,           massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig_central");
1829 +    
1830      make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30==0", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_btagVeto");
1831 +    make_data_comparison_plot("mll", cutOSOF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30==0", massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig_btagVeto");
1832 +    
1833      make_data_comparison_plot("mll", cutOSSF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",  massnbins, 15., 315.,-1., false, "m_{ll}", "mll_SF_sig_AtLeastOneBJet");
1834 +    make_data_comparison_plot("mll", cutOSOF&&cutSignal&&mllCut&&"pfJetGoodNumBtag30>0",  massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig_AtLeastOneBJet");
1835 +
1836  
1837      make_data_comparison_plot("mll", mllCut&&cutOSOF&&cutSignal, massnbins, 15., 315.,-1., false, "m_{ll}", "mll_OF_sig");
1838      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");
# Line 866 | Line 1842 | void do_kinematic_plots(string mcjzb, st
1842      make_data_comparison_plot("pfJetGoodNum40", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(jets)", "njets_OF_sig");
1843      make_data_comparison_plot("pfJetGoodNumBtag30", cutOSSF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_SF_sig");
1844      make_data_comparison_plot("pfJetGoodNumBtag30", cutOSOF&&cutSignal&&mllCut, 8, 0., 8.,-1., false, "#(b-jets)", "nbjets_OF_sig");
1845 <  */  
1845 >
1846    }
1847  
1848  
1849    if ( doKin ) {
1850      string mllCut("");
1851 <
1852 <     make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
1853 <     make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
1851 >    
1852 >    
1853 >  
1854 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),40,0,400,dolog,"PFMET","Debunking/MET_OF_30to70_0j",doPF,true);
1855 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),40,0,400,dolog,"PFMET","Debunking/MET_OF_30to70_1j",doPF,true);
1856 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),40,0,400,dolog,"PFMET","Debunking/MET_OF_30to70_2j",doPF,true);
1857 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==3")),40,0,400,dolog,"PFMET","Debunking/MET_OF_30to70_3j",doPF,true);
1858 >
1859 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==0")),40,0,400,dolog,"PFMET","Debunking/MET_OF_Z_0j",doPF,true);
1860 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==1")),40,0,400,dolog,"PFMET","Debunking/MET_OF_Z_1j",doPF,true);
1861 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==2")),40,0,400,dolog,"PFMET","Debunking/MET_OF_Z_2j",doPF,true);
1862 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==3")),40,0,400,dolog,"PFMET","Debunking/MET_OF_Z_3j",doPF,true);
1863 >
1864 >
1865 >    make_plain_kin_plot("pfTightHT",Cut2Str(cutOSOF&&cutnJets),120,0,1200,dolog,"H_{T}","HT_3jets_OF",doPF,true);
1866 >    make_plain_kin_plot("pfTightHT",Cut2Str(cutOSSF&&cutnJets) ,120,0,1200,dolog,"H_{T}","HT_3jets_SF",doPF,true);
1867 >    make_plain_kin_plot("pfTightHT",Cut2Str(cutOSOF&&cutnJets&&TCut("met[4]>100")),120,0,1200,dolog,"H_{T}","HT_3jets_OF_MET100",doPF,true);
1868 >    make_plain_kin_plot("pfTightHT",Cut2Str(cutOSSF&&cutnJets&&TCut("met[4]>100")) ,120,0,1200,dolog,"H_{T}","HT_3jets_SF_MET100",doPF,true);
1869 >
1870 >    
1871 >    make_plain_kin_plot("met[1]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),40,0,400,dolog,"PFMET","Debunking/T1MET_OF_30to70_0j",doPF,true);
1872 >    make_plain_kin_plot("met[1]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),40,0,400,dolog,"PFMET","Debunking/T1MET_OF_30to70_1j",doPF,true);
1873 >    make_plain_kin_plot("met[1]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),40,0,400,dolog,"PFMET","Debunking/T1MET_OF_30to70_2j",doPF,true);
1874 >    make_plain_kin_plot("met[1]",Cut2Str(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==3")),40,0,400,dolog,"PFMET","Debunking/T1MET_OF_30to70_3j",doPF,true);
1875 >
1876 >    make_plain_kin_plot("met[1]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==0")),40,0,400,dolog,"PFMET","Debunking/T1MET_OF_Z_0j",doPF,true);
1877 >    make_plain_kin_plot("met[1]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==1")),40,0,400,dolog,"PFMET","Debunking/T1MET_OF_Z_1j",doPF,true);
1878 >    make_plain_kin_plot("met[1]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==2")),40,0,400,dolog,"PFMET","Debunking/T1MET_OF_Z_2j",doPF,true);
1879 >    make_plain_kin_plot("met[1]",Cut2Str(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==3")),40,0,400,dolog,"PFMET","Debunking/T1MET_OF_Z_3j",doPF,true);
1880 >
1881 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&cutnJets&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_SF_20to70",doPF,true);
1882 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&cutnJets&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_OF_20to70",doPF,true);
1883 >    
1884 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&cutnJets&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_SF_above120",doPF,true);
1885 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&cutnJets&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_OF_above120",doPF,true);
1886 >    
1887 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&TCut("pfJetGoodNum40==2")&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_SF_20to70___2jetsonly",doPF,true);
1888 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("pfJetGoodNum40==2")&&TCut("mll>20&&mll<70")),50,0,300,dolog,"PFMET","MET_OF_20to70___2jetsonly",doPF,true);
1889 >    
1890 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSSF&&TCut("pfJetGoodNum40==2")&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_SF_above120___2jetsonly",doPF,true);
1891 >    make_plain_kin_plot("met[4]",Cut2Str(cutOSOF&&TCut("pfJetGoodNum40==2")&&TCut("mll>120")),50,0,300,dolog,"PFMET","MET_OF_above120___2jetsonly",doPF,true);
1892 >
1893 >    
1894 >    make_kin_plot("pfJetGoodPt[0]/pfJetGoodPt[1]","",45,1,10,dolog,"pt_{j}^{1}/pt_{j}^{2}","j1j2ratio",doPF,true);
1895 >    make_kin_plot("TMath::Abs(pfJetDphiMet[0])","",32,0,3.2,nolog,"|#Delta#phi(jet1,MET)|","dphiJ1MET",doPF,true);
1896      // Plots in signal region
1897 < //     make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
1898 <     make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
1899 <     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);
1900 <     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);
1901 <     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);
1902 <    
1903 <     make_kin_plot("pfJetGoodNum40",mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
1904 <     make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
1905 <    
1906 < //     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);
1907 < //     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);
1908 < //     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);
1909 < //     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);
1897 >    make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
1898 >
1899 >
1900 >    make_kin_plot("MetFactor","",20,0,2,nolog,"MetFactor","MetFactor",doPF,true);
1901 >    
1902 >    make_ttbar_comparison("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_OF_30to70_2j__ALLMCSAMPLES");
1903 >    /*
1904 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_OF_30to70_0j");
1905 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_OF_30to70_1j");
1906 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_OF_30to70_2j");
1907 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_OF_30to70_3j");
1908 >
1909 >    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_SF_30to70_0j");
1910 >    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_SF_30to70_1j");
1911 >    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_SF_30to70_2j");
1912 >    DoMCSystPlot("met[4]",40,0,400,(cutOSSF&&TCut("mll>30&&mll<70&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_SF_30to70_3j");
1913 >
1914 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==0")),dolog,"PFMET","Debunking/MET_OF_Z_0j");
1915 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfJetGoodNum40==1")),dolog,"PFMET","Debunking/MET_OF_Z_1j");
1916 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==2")),dolog,"PFMET","Debunking/MET_OF_Z_2j");
1917 >    DoMCSystPlot("met[4]",40,0,400,(cutOSOF&&TCut("mll>80&&mll<100&&pfTightHT>100&&pfJetGoodNum40==3")),dolog,"PFMET","Debunking/MET_OF_Z_3j");
1918 >
1919 >    
1920 >    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF,dolog,"m_{ll} [GeV]","kinSys/mll");
1921 >    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF&&TCut("id1==0"),dolog,"m_{ll} [GeV]","kinSys/mll_ee");
1922 >    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSSF&&TCut("id1==1"),dolog,"m_{ll} [GeV]","kinSys/mll_mm");
1923 >    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutnJets&&cutOSOF,dolog,"m_{ll} [GeV]","kinSys/mll_osof");
1924 >
1925 >    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutOSSF,dolog,"m_{ll} [GeV]","kinSys/mll_inclusive");
1926 >    DoMCSystPlot("mll", (int)((mll_hi-mll_low)/5),mll_low,mll_hi,cutOSOF,dolog,"m_{ll} [GeV]","kinSys/mll_inclusive_osof");
1927 >
1928 >    DoMCSystPlot("pfJetGoodNum40", 9,-0.5,8.5,cutOSSF,dolog,"nJets","kinSys/nJets_ossf");
1929 >    DoMCSystPlot("pfJetGoodNum40", 9,-0.5,8.5,cutOSOF,dolog,"nJets","kinSys/nJets_osof");
1930 >    
1931 >    DoMCSystPlot("pfJetGoodPt[0]/pfJetGoodPt[1]",45,1,10,cutnJets&&cutOSSF,dolog,"p_{T}^{J1} / p_{T}^{J2}","kinSys/j1j2ratio");
1932 >    DoMCSystPlot("TMath::Abs(pfJetDphiMet[0])",32,0,3.2,cutnJets&&cutOSSF,dolog,"|#Delta#phi(jet1,MET)|","kinSys/dphiJ1MET");
1933 >    DoMCSystPlot(datajzb,mcjzb, (int)((PlottingSetup::jzbHigh+110)/10),-110,PlottingSetup::jzbHigh,cutnJets&&cutOSSF&&Restrmasscut,dolog,"m_{ll} [GeV]","kinSys/jzb_OS_SFZP");
1934 >    DoMCSystPlot(datajzb,mcjzb, (int)((PlottingSetup::jzbHigh+110)/10),-110,PlottingSetup::jzbHigh,cutnJets&&cutOSOF&&Restrmasscut,dolog,"m_{ll} [GeV]","kinSys/jzb_OS_OFZP");
1935 >
1936 >    make_kin_plot("mll","mll>20"+mllCut,(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
1937 >    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);
1938 >    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);
1939 >    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);
1940 >    
1941 >    make_kin_plot("pfJetGoodNum40",mllCut,9,-0.5,8.5,dolog,"nJets","nJets",doPF);
1942 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
1943 >    
1944 >    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);
1945 >    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);
1946 >    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);
1947 >    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);
1948      
1949      
1950 < //     make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets_met100",doPF);
1951 < //     make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof_met100",doPF);
1950 >    make_kin_plot("pfJetGoodNum40","met[4]>100"+mllCut,9,-0.5,8.5,dolog,"nJets","nJets_met100",doPF);
1951 >    make_kin_plot("pfJetGoodNum40","met[4]>100",9,-0.5,8.5,dolog,"nJets","nJets_osof_met100",doPF);
1952  
1953      // Further inclusive invariant mass plots
1954      make_kin_plot("mll",mllCut,(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
1955 < //     make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
1956 < //     make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
1955 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
1956 >    make_kin_plot("mll","",(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
1957      make_kin_plot("mll",mllCut,(int)((mll_hi-mll_low))/5,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
1958      
1959 <    //make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
1959 >    make_kin_plot("mll","",(int)((350-mll_low))/5,mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
1960      //if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
1961      
1962      
1963      // Number of jets
1964      make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_inclusive",doPF);
1965      make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof_inclusive",doPF);
1966 <    //make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
1966 >    make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
1967      
1968      // Others
1969      make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
# Line 939 | Line 1995 | void do_kinematic_plots(string mcjzb, st
1995      
1996      //   make_kin_plot("mll","met[4]>100",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV] (MET>100GeV)","mll_met100_ll",doPF,true);
1997      //make_kin_plot("mll","met[4]>150&&id1==0",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ee} [GeV] (MET>150GeV)","mll_met150_ee",doPF,true);
1998 <    //make_kin_plot("mll","met[4]>150&&id1==1",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{#mu#mu} [GeV] (MET>150GeV)","mll_met150_mm",doPF,true);
1998 >    //make_kin_plot("mll","met[4]>150&&id1==1",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{#mu#mu} [GeV] (MET>150GeV)","mll_met150_mm",doPF,true);*/
1999    }
2000 <    
2001 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
2002 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
2003 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
2000 >    /*
2001 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
2002 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
2003 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,80);
2004     make_special_obs_pred_mll_plot(datajzb,mcjzb,100);
2005 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
2006 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
2007 < //   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
952 <
953 < //   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
954 < //   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
2005 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,150);
2006 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,200);
2007 >   make_special_obs_pred_mll_plot(datajzb,mcjzb,250);
2008  
2009 +   make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
2010 +   make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
2011 + */
2012    switch_overunderflow(false);
2013   }
2014  
# Line 993 | Line 2049 | void make_comp_plot( string var, string
2049        if (ymax>ymin) datahisto->SetMaximum(ymax);
2050        lm3histo->SetLineStyle(2);
2051        datahisto->Draw("e1");
2052 <      mcstack.Draw("same");
2052 >      mcstack.Draw("histo,same");
2053        datahisto->Draw("same,e1");
2054        lm3histo->Draw("hist,same");
2055        TLegend *kinleg = allsamples.allbglegend((sRegions[iregion]+(ijzb?"neg":"pos")).c_str());
# Line 1569 | Line 2625 | void do_prediction_plot(string jzb, TCan
2625   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
2626   //     speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
2627      speciallegBpred->Draw();
2628 <    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
2628 >    Save_With_Ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
2629 >    delete predcomppad;
2630      
2631      TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
2632      specialcanv->SetLogy(1);
2633   //    THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
2634      blankback->Draw();
2635   //    kostack.Draw("same");
2636 <    predcomposition.Draw();
2636 >    predcomposition.Draw("hist");
2637      Bpred->Draw("hist,same");
2638      //analytical_function[0]->Draw("same"); analytical_function[1]->Draw("same");analytical_function[2]->Draw("same");
2639      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
# Line 1652 | Line 2709 | void do_prediction_plot(string jzb, TCan
2709    string ytitle("ratio");
2710    if ( use_data==1 ) ytitle = "data/pred";
2711    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
2712 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
2712 >  Save_With_Ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle,BpredSys);//not extending the y range anymore up to 4
2713 >  
2714 >  delete kinpad;
2715  
2716  
2717    
# Line 1849 | Line 2908 | void lepton_comparison_plots() {
2908    eemmlegend->AddEntry(jmmd,"#mu#mu","l");
2909    eemmlegend->Draw();
2910    DrawPrelim();
2911 <  save_with_ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
2911 >  Save_With_Ratio(jeed,jmmd,eemmpad->cd(),"lepton_comparison/jzb_Comparing_ee_mm_data");
2912    
2913    TH1F *zjeed = allsamples.Draw("zjeed",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==0)",mc,  luminosity,allsamples.FindSample("/DY"));
2914    TH1F *zjmmd = allsamples.Draw("zjmmd",jzbvariablemc,    int((jzbHigh+150)/5),-150,jzbHigh , "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets&&"(id1==1)",mc,  luminosity,allsamples.FindSample("/DY"));
# Line 1950 | Line 3009 | void draw_pure_jzb_histo(TCut cut,string
3009    datahisto->SetMinimum(0.1);
3010    datahisto->SetMarkerSize(DataMarkerSize);
3011    datahisto->Draw("e1");
3012 <  mcstack.Draw("same");
3012 >  mcstack.Draw("histo,same");
3013    datahisto->Draw("same,e1");
3014    
3015    TLegend *leg;
# Line 1972 | Line 3031 | void draw_pure_jzb_histo(TCut cut,string
3031    TText *writeline1 = write_cut_on_canvas(write_cut.c_str());
3032    writeline1->SetTextSize(0.035);
3033    writeline1->Draw();
3034 <  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
3035 <  else save_with_ratio(datahisto,mcstack,jzbpad->cd(),savename);
3034 >  if(!Contains(savename,"Dibosons")) Save_With_Ratio(datahisto,mcstack,jzbpad->cd(),("jzb/"+savename));
3035 >  else Save_With_Ratio(datahisto,mcstack,jzbpad->cd(),savename);
3036    TPad *jzbpad2 = new TPad("jzbpad2","jzbpad2",0,0,1,1);
3037    jzbpad2->cd();
3038    jzbpad2->SetLogy(1);
# Line 1981 | Line 3040 | void draw_pure_jzb_histo(TCut cut,string
3040    datahisto->SetMinimum(0.1);
3041    datahisto->SetMarkerSize(DataMarkerSize);
3042    datahisto->Draw("e1");
3043 <  mcstack.Draw("same");
3043 >  mcstack.Draw("histo,same");
3044    datahisto->Draw("same,e1");
3045    leg->SetHeader("");
3046    leg->Draw();
3047    writeline1->SetTextSize(0.035);
3048    writeline1->Draw();
3049    DrawPrelim();
3050 <  if(!Contains(savename,"Dibosons")) save_with_ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
3051 <  else save_with_ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
3050 >  if(!Contains(savename,"Dibosons")) Save_With_Ratio(datahisto,mcstack,jzbpad2->cd(),("jzb/PositiveSideOnly/"+savename+""));
3051 >  else Save_With_Ratio(datahisto,mcstack,jzbpad2->cd(),(savename+"__PosOnly"));
3052    datahisto->Delete();
3053    mcstack.Delete();
3054   }
# Line 2097 | Line 3156 | void draw_normalized_data_vs_data_histo(
3156    leg->AddEntry(datahisto2,legentry2.c_str());
3157    leg->Draw();
3158    
3159 <  save_with_ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
3159 >  Save_With_Ratio(datahisto1,datahisto2,jzbpad->cd(),("jzb/"+savename));
3160    
3161    datahisto1->Delete();
3162    datahisto2->Delete();
# Line 2591 | Line 3650 | void find_correction_factors(string &jzb
3650    
3651   }
3652  
3653 < void pick_up_events(string cut) {
3654 <  dout << "Picking up events with cut " << cut << endl;
2596 <  allsamples.PickUpEvents(cut);
3653 > void pick_up_events(string cut, string filename) {
3654 >  allsamples.PickUpEvents(cut,filename);
3655   }
3656  
3657   void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
# Line 2705 | Line 3763 | void ttbar_sidebands_comparison(string m
3763        
3764    float simulatedlumi = luminosity; //in pb please - adjust to your likings
3765  
3766 <  TH1F *TZem  = systsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
3767 <  TH1F *nTZem = systsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
3766 >  TH1F *TZem  = allsamples.Draw("TZem",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
3767 >  TH1F *nTZem = allsamples.Draw("nTZem","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
3768    TH1F *TSem;
3769    TH1F *nTSem;
3770 <  TH1F *TZeemm  = systsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
3771 <  TH1F *nTZeemm = systsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
3770 >  TH1F *TZeemm  = allsamples.Draw("TZeemm",     mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
3771 >  TH1F *nTZeemm = allsamples.Draw("nTZeemm","-"+mcjzb,binning,"JZB [GeV]","events",cutmass&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
3772    TH1F *TSeemm;
3773    TH1F *nTSeemm;
3774    
3775    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
3776 <    TSem    = systsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
3777 <    nTSem   = systsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
3778 <    TSeemm  = systsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
3779 <    nTSeemm = systsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,systsamples.FindSample("TTT"));
3776 >    TSem    = allsamples.Draw("TSem",       mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
3777 >    nTSem   = allsamples.Draw("nTSem",  "-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSOF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
3778 >    TSeemm  = allsamples.Draw("TSeemm",     mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
3779 >    nTSeemm = allsamples.Draw("nTSeemm","-"+mcjzb,binning,"JZB [GeV]","events",sidebandcut&&cutOSSF&&cutnJets,mc,simulatedlumi,allsamples.FindSample("/TT"));
3780    }
3781  
3782    TCanvas *tcan = new TCanvas("tcan","tcan");
# Line 3064 | Line 4122 | void zjets_prediction_comparison(string
4122    TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
4123    
4124  
3067  cout << __LINE__ << endl;
4125    top->SetLineColor(kBlue);top->SetLineStyle(2);
4126    bottom->SetLineColor(kBlue);bottom->SetLineStyle(2);
4127    center->SetLineColor(kBlue);
# Line 3087 | Line 4144 | void zjets_prediction_comparison(string
4144    TH1F *RcorrJZBem       = systsamples.Draw("RcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4145    TH1F *LcorrJZBem       = systsamples.Draw("LcorrJZBem",var,binning, "JZB [GeV]", "events",cutmass&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4146  
3090  cout << __LINE__ << endl;
4147    TH1F *RcorrJZBSBem;
4148    TH1F *LcorrJZBSBem;
4149    TH1F *RcorrJZBSBeemm;
4150    TH1F *LcorrJZBSBeemm;
4151  
3096  cout << __LINE__ << endl;
4152    if(PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) {
4153      RcorrJZBSBem   = systsamples.Draw("RcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kPos&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
4154      LcorrJZBSBem   = systsamples.Draw("LcorrJZBSBem",var,binning, "JZB [GeV]", "events",sidebandcut&&cutOSOF&&reducedNJets&&ee_mm_tautau&&kNeg&&massregioncut,mc,simulatedlumi,systsamples.FindSample("/DY"));
# Line 3116 | Line 4171 | void zjets_prediction_comparison(string
4171    
4172    Bpred->SetLineColor(kRed);
4173  
3119  cout << __LINE__ << endl;
4174    TAUhJZBpos->SetLineColor(kBlack);
4175    Bpred->SetLineColor(kRed);
4176    
# Line 3173 | Line 4227 | void zjets_prediction_comparison(string
4227    
4228    delete zcan;
4229    cutWeight=weightbackup;
3176
3177  cout << __LINE__ << endl;
4230   }
4231  
4232  
# Line 3292 | Line 4344 | void make_table(samplecollection &coll,
4344   }
4345  
4346   void met_jzb_cut(string datajzb, string mcjzb, vector<float> jzb_cut) {
4347 +  cout << "You probably don't want --met, you want --metplots ... " << endl;
4348 +  assert(0);
4349    /*we want a table like this:
4350      __________________     50   |   100  | ...
4351      | Data prediction |  a vs b | a vs b | ...
# Line 3525 | Line 4579 | void qcd_plots(string datajzb, string mc
4579    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
4580    string ytitle("ratio");
4581    if ( use_data==1 ) ytitle = "data/pred";
4582 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
4582 >  Save_With_Ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
4583 >  delete kinpad;
4584    
4585    TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
4586    TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);
# Line 3762 | Line 4817 | void met_vs_jzb_plots(string datajzb, st
4817    lg->SetHeader("DY");
4818    
4819    lg->Draw();
4820 <  save_with_ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
4820 >  Save_With_Ratio(metright,metleft,metpad->cd(),"METvsJZBplots/ComparingLeftToRightinMETspectrum");
4821    
4822    TPad *metpad3 = new TPad("metpad3","metpad3",0,0,1,1);
4823    metpad3->cd();
# Line 3780 | Line 4835 | void met_vs_jzb_plots(string datajzb, st
4835  
4836    lg2->Draw();
4837    
4838 <  save_with_ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
4838 >  Save_With_Ratio(obs,Bpred,metpad3->cd(),"METvsJZBplots/ComparingPredObsinMET");
4839    
4840    TPad *metpad2 = new TPad("metpad2","metpad2",0,0,1,1);
4841    metpad2->cd();
# Line 3799 | Line 4854 | void met_vs_jzb_plots(string datajzb, st
4854    metlefta->Draw("histo");
4855    metrighta->Draw("same");
4856    lg->Draw();
4857 <  save_with_ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
4857 >  Save_With_Ratio(metrighta,metlefta,metpad2->cd(),"METvsJZBplots/ComparingLeftToRightinMET_type1_spectrum");
4858    
4859    delete Bpred;
4860    delete obs;
# Line 3826 | Line 4881 | void met_vs_jzb_plots(string datajzb, st
4881    aobs->Draw("same");
4882    lg->SetHeader("All MC");
4883    lg->Draw();
4884 <  save_with_ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
4884 >  Save_With_Ratio(aobs,aBpred,metpad4->cd(),"METvsJZBplots/ComparingPredObsinMET_ALLSAMPLES");
4885    
4886    
4887    delete lg;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines