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

Comparing UserCode/cbrown/Development/Plotting/Modules/EdgeLimit.C (file contents):
Revision 1.26 by buchmann, Fri Jun 21 12:44:46 2013 UTC vs.
Revision 1.27 by buchmann, Wed Jun 26 11:08:31 2013 UTC

# Line 29 | Line 29
29   #include "RooStats/HypoTestInverterOriginal.h"
30  
31   //#include "ParametrizedEdge.C"
32 + #include "ExtendedMath.C"
33   #include "EdgeModules/RooSUSYTPdf.cxx"
34   #include "EdgeModules/RooSUSYBkgPdf.cxx"
35 + #include "EdgeModules/RooSUSYCompleteBkgPdf.cxx"
36 +
37  
38   #include "md5/md5.h"
39   #include "md5/md5.C"
# Line 80 | Line 83 | namespace EdgeFitter {
83    RooDataSet* AllData;
84    RooDataSet* eeSample;
85    RooDataSet* mmSample;
86 <  RooDataSet* OFSample;
86 >  RooDataSet* OFSample;
87 >  RooDataSet* SFSample;
88    
89    bool MarcoDebug=true;
90    
# Line 425 | Line 429 | void EdgeFitter::PrepareDatasets(int is_
429    EdgeFitter::eeSample = (RooDataSet*)LAllData.reduce("id1==id2&&id1==0");
430    EdgeFitter::mmSample = (RooDataSet*)LAllData.reduce("id1==id2&&id1==1");
431    EdgeFitter::OFSample = (RooDataSet*)LAllData.reduce("id1!=id2");
432 +  EdgeFitter::SFSample = (RooDataSet*)LAllData.reduce("id1==id2");
433    EdgeFitter::AllData  = (RooDataSet*)LAllData.reduce("id1!=id2||id1==id2");
434    
435 +  
436    eeSample->SetName("eeSample");
437    mmSample->SetName("mmSample");
438    OFSample->SetName("OFSample");
439 +  SFSample->SetName("SFSample");
440    AllData->SetName("AllData");
441    
442 +  eeSample->SetTitle("eeSample");
443 +  mmSample->SetTitle("mmSample");
444 +  OFSample->SetTitle("OFSample");
445 +  SFSample->SetTitle("SFSample");
446 +  AllData->SetTitle("AllData");
447 +  
448    if(EdgeFitter::MarcoDebug) {
449      dout << "Number of (weighted) events in full sample = " << AllData->sumEntries() << " (raw events : " << AllData->numEntries() << ")" <<  endl;
450      dout << "Number of (weighted) events in ee sample = " << eeSample->sumEntries() << " (raw events : " << eeSample->numEntries() << ")" <<  endl;
451      dout << "Number of (weighted) events in mm sample = " << mmSample->sumEntries() << " (raw events : " << mmSample->numEntries() << ")" <<  endl;
452 +    dout << "Number of (weighted) events in SF sample = " << SFSample->sumEntries() << " (raw events : " << SFSample->numEntries() << ")" <<  endl;
453      dout << "Number of (weighted) events in em sample = " << OFSample->sumEntries() << " (raw events : " << OFSample->numEntries() << ")" <<  endl;
454    }
455    
# Line 448 | Line 462 | void EdgeFitter::DrawDatasetContent(int
462    RooPlot* frame1 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("ee sample")) ;
463    frame1->GetXaxis()->CenterTitle(1);
464    frame1->GetYaxis()->CenterTitle(1);
465 <  eeSample->plotOn(frame1,RooFit::Name("eedata")) ;
465 >  eeSample->plotOn(frame1,RooFit::Name("eedata"));
466    
467    RooPlot* frame2 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("mm sample")) ;
468    frame2->GetXaxis()->CenterTitle(1);
469    frame2->GetYaxis()->CenterTitle(1);
470 <  mmSample->plotOn(frame2,RooFit::Name("mmdata")) ;
470 >  mmSample->plotOn(frame2,RooFit::Name("mmdata"));
471    
472    RooPlot* frame3 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("OF sample")) ;
473    frame3->GetXaxis()->CenterTitle(1);
474    frame3->GetYaxis()->CenterTitle(1);
475 <  OFSample->plotOn(frame3,RooFit::Name("OFdata")) ;
475 >  OFSample->plotOn(frame3,RooFit::Name("OFdata"));
476    
477    TH1F *ee_ref = allsamples.Draw("ee_ref","mll",int((mllmax-mllmin)/5.0),mllmin,mllmax, "m_{ll} [GeV]", "events", cut&&TCut("id1==id2&&id1==0"),is_data, luminosity);
478    TH1F *mm_ref = allsamples.Draw("mm_ref","mll",int((mllmax-mllmin)/5.0),mllmin,mllmax, "m_{ll} [GeV]", "events", cut&&TCut("id1==id2&&id1==1"),is_data, luminosity);
# Line 569 | Line 583 | void EdgeFitter::DoFit(int is_data, floa
583    
584    prefix << EdgeFitter::Mode << "_" << jzb_cut;
585    
586 +  if(!EdgeFitter::AllowTriangle && EdgeFitter::FixedMEdge>=0) prefix << "__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge);
587 +  
588    if(EdgeFitter::AllowTriangle) prefix << "__H1";
589    else prefix << "__H0";
590    
# Line 578 | Line 594 | void EdgeFitter::DoFit(int is_data, floa
594    sample.defineType("ee");
595    sample.defineType("mm");
596    sample.defineType("OF");
597 +  sample.defineType("SF");
598    
599 <  RooDataSet combData("combData","combined data",RooArgSet(mll,edgeWeight),RooFit::Index(sample),RooFit::Import("ee",*eeSample),RooFit::Import("mm",*mmSample),RooFit::Import("OF",*OFSample),RooFit::WeightVar(edgeWeight));
599 >  RooDataSet combData("combData","combined data",RooArgSet(mll,edgeWeight),RooFit::Index(sample),RooFit::Import("ee",*eeSample),RooFit::Import("mm",*mmSample),RooFit::Import("OF",*OFSample),RooFit::Import("SF",*SFSample),RooFit::WeightVar(edgeWeight));
600    
601    //------------------------------------------------------------------------------------------------------------------------------------
602    //    _____ _               __
# Line 625 | Line 642 | void EdgeFitter::DoFit(int is_data, floa
642    frameO->Draw();
643    if(is_data==data) DrawPrelim();
644    else DrawPrelim(PlottingSetup::luminosity,true);
645 <  if(EdgeFitter::FixedMEdge>=0) CompleteSave(pof,"Edge/OF__OFFitonly_"+prefix.str()+"__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false);
629 <  else CompleteSave(pof,"Edge/OF__OFFitonly_"+prefix.str(),false,false);
645 >  CompleteSave(pof,"Edge/OF__OFFitonly_"+prefix.str(),false,false);
646    delete pof;
647    
648    TCanvas* pof2 = new TCanvas("pof2","pof2") ;
# Line 649 | Line 665 | void EdgeFitter::DoFit(int is_data, floa
665    OFFitinfobox->Draw();
666  
667    
668 <  if(EdgeFitter::FixedMEdge>=0) CompleteSave(pof2,"Edge/OF__OFFitonly_"+prefix.str()+"__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge)+"__INFO",false,false);
653 <  else CompleteSave(pof2,"Edge/OF__OFFitonly_"+prefix.str()+"__INFO",false,false);
668 >  CompleteSave(pof2,"Edge/OF__OFFitonly_"+prefix.str()+"__INFO",false,false);
669    
670    delete pof2;
671      
# Line 674 | Line 689 | void EdgeFitter::DoFit(int is_data, floa
689    //                 | |          
690    //                 |_|          
691    //    
692 <  // This is where the actual simultaneous fitting happens
692 >  // Set up all the models
693    
694    
695    // Step 2a: set up edge position (if fixed), and maximum Z yield
# Line 687 | Line 702 | void EdgeFitter::DoFit(int is_data, floa
702    dout << "maxZ was set to " << maxZ << endl;
703    delete ZDataSet;
704    
705 +  RooRealVar JustOne("JustOne","Just One",1) ;
706 +
707    
708    // Step 2b: set up the models!
709 <  
710 <  RooRealVar eefrac("eefrac","eefrac",eeSample->sumEntries()/(eeSample->sumEntries()+mmSample->sumEntries()),0.1,1.0);
709 >  write_info(__FUNCTION__,"ee & mm fractions fixed");
710 > /*  RooRealVar eefrac("eefrac","eefrac",eeSample->sumEntries()/(eeSample->sumEntries()+mmSample->sumEntries()),0.1,1.0);
711 >  RooFormulaVar mmfrac("mmfrac","1-eefrac",RooArgSet(eefrac));*/
712 >  RooRealVar eefrac("eefrac","eefrac",eeSample->sumEntries()/(eeSample->sumEntries()+mmSample->sumEntries()));
713    RooFormulaVar mmfrac("mmfrac","1-eefrac",RooArgSet(eefrac));
714    
715    RooRealVar rOneOverEMFrac("rOneOverEMFrac","rOneOverEMFrac",1.02,1.02-0.07,1.02+0.07);
# Line 711 | Line 730 | void EdgeFitter::DoFit(int is_data, floa
730    
731    RooVoigtian zee("zee", "zee", mll, meanz, widthz, sigmazee);
732    RooVoigtian zmm("zmm", "zmm", mll, meanz, widthz, sigmazmm);
733 <  RooAddPdf zSF("zSF","zSF",RooArgList(zee,zmm));
733 >  RooAddPdf zSF("zSF","zSF",RooArgList(zee,zmm),RooArgList(fzee,fzmm));
734    
735    
736    //SECOND: Flavor-Symmetry contribution. Only relative fraction is different, all other parameters are the same;
# Line 721 | Line 740 | void EdgeFitter::DoFit(int is_data, floa
740    RooSUSYBkgPdf ttbaree("ttbaree","ttbaree", mll , par1ttbarOF, par2ttbarOF, par3ttbarOF, par4ttbarOF);
741    RooSUSYBkgPdf ttbarmm("ttbarmm","ttbarmm", mll , par1ttbarOF, par2ttbarOF, par3ttbarOF, par4ttbarOF);
742    RooAddPdf ttbarSF("ttbarSF","ttbarSF", RooArgList(ttbaree,ttbarmm), RooArgList(fttbaree,fttbarmm));
743 +  RooAddPdf ttbarSFOne("ttbarSF","ttbarSF", RooArgList(ttbaree,ttbarmm), RooArgList(JustOne,JustOne));
744    
745    
746    //for signal only the resolution and absolute fraction are different for ee / mm
# Line 744 | Line 764 | void EdgeFitter::DoFit(int is_data, floa
764    }
765    
766    
767 +  write_error(__FUNCTION__,"RnD version: fixing most parameters so the fit works very quickly (only one parameters instead of eight) !");
768 + //          fttbarOF.setConstant(1);
769 +            fzSF.setConstant(1);
770 +            meanz.setConstant(1);
771 +            par1ttbarOF.setConstant(1);
772 +            par3ttbarOF.setConstant(1);
773 +            sigmazee.setConstant(1);
774 +            sigmazmm.setConstant(1);
775 +  
776 +  
777    //COMPLETE MODEL:
778  
779    RooAddPdf model_ee("model_ee","model_ee", RooArgList(zee, ttbaree, signalee), RooArgList(fzee, fttbaree, fsignalee));
780    RooAddPdf model_mm("model_mm","model_mm", RooArgList(zmm, ttbarmm, signalmm), RooArgList(fzmm, fttbarmm, fsignalmm));
781   //  RooAddPdf model_SF("model_SF","model_SF", RooArgList(zSF, ttbarSF, signalSF), RooArgList(fzSF, fttbarSF, fsignalSF));
782 <  RooAddPdf model_SF("model_SF","model_SF",RooArgList(model_ee,model_mm));
782 >  RooAddPdf model_SF("model_SF","model_SF",RooArgList(model_ee,model_mm),RooArgList(JustOne,JustOne));
783 >  
784 >  
785 >  //    _____ _               ____  
786 >  //   / ____| |             |___ \
787 >  //  | (___ | |_ ___ _ __     __) |
788 >  //   \___ \| __/ _ \ '_ \   |__ <
789 >  //   ____) | ||  __/ |_) |  ___) |
790 >  //  |_____/ \__\___| .__/  |____/
791 >  //                 | |            
792 >  //                 |_|            
793 >  //  
794 >  //  Fitting
795    
796    RooSimultaneous simPdf("simPdf","simultaneous pdf",sample) ;
797    simPdf.addPdf(model_ee,"ee") ;
# Line 772 | Line 814 | void EdgeFitter::DoFit(int is_data, floa
814    result->Print();
815    dout << "============================= < /Full results > =============================" << endl;
816  
817 <
817 >  //    _____ _               _  _  
818 >  //   / ____| |             | || |  
819 >  //  | (___ | |_ ___ _ __   | || |_
820 >  //   \___ \| __/ _ \ '_ \  |__   _|
821 >  //   ____) | ||  __/ |_) |    | |  
822 >  //  |_____/ \__\___| .__/     |_|  
823 >  //                 | |            
824 >  //                 |_|            
825 >  //
826 >  //   Present results
827    
828    RooPlot* frame1 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("EE sample")) ;
829    frame1->GetXaxis()->CenterTitle(1);
# Line 802 | Line 853 | void EdgeFitter::DoFit(int is_data, floa
853    simPdf.plotOn(frame3,RooFit::Slice(sample,"OF"),RooFit::Name("TTbarOFonly"),RooFit::Components("ttbarOF"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ;
854    simPdf.plotOn(frame3,RooFit::Slice(sample,"OF"),RooFit::Name("DYOFonly"),RooFit::Components("zOF"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kRed));
855  
856 +  RooAbsPdf *ee_result = simPdf.getPdf("ee");
857 +  RooAbsPdf *mm_result = simPdf.getPdf("mm");
858 +  RooAddPdf SF_result("SF_result","SF_result",RooArgList(*ee_result,*mm_result));
859 +  
860 +  
861 +  TCanvas* g = new TCanvas("g","g") ;
862    
863    RooPlot* frame4 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("SF sample")) ;
864    frame4->GetXaxis()->CenterTitle(1);
865    frame4->GetYaxis()->CenterTitle(1);
866 <  combData.plotOn(frame4,RooFit::Name("SFdata"),RooFit::Cut("sample==sample::ee||sample==sample::mm")) ;
867 <  simPdf.plotOn(frame4,RooFit::Slice(sample,"ee"),RooFit::Name("FullFitSFee"),RooFit::ProjWData(sample,combData),RooFit::LineColor(kRed),RooFit::LineStyle(kDashed));
868 <  simPdf.plotOn(frame4,RooFit::Slice(sample,"ee"),RooFit::Slice(sample,"mm"),RooFit::Name("FullFitSF"),RooFit::ProjWData(sample,combData),RooFit::LineColor(kRed));
869 <  simPdf.plotOn(frame4,RooArgSet(RooFit::Slice(sample,"ee"),RooFit::Slice(sample,"mm")),RooFit::Name("FullFitSF"),RooFit::ProjWData(sample,combData),RooFit::LineColor(kGreen),RooFit::LineStyle(kDotted)));
870 <  simPdf.plotOn(frame4,RooFit::Slice(sample,"mm"),RooFit::Name("FullFitSFmm"),RooFit::ProjWData(sample,combData),RooFit::LineColor(kBlue),RooFit::LineStyle(kDotted));
814 <  simPdf.plotOn(frame4,RooFit::Components(RooArgSet(ttbaree,ttbarmm)),RooFit::LineStyle(kDotted));
815 <  simPdf.plotOn(frame4,RooFit::Components(RooArgSet(zee,zmm)),RooFit::LineStyle(kDotted));
816 < //  model_SF.plotOn(frame4);
817 < // ttbarSF.plotOn(frame4,RooFit::LineStyle(kDashed));
818 < // zSF.plotOn(frame4,RooFit::LineStyle(kDashed), RooFit::LineColor(kRed));
819 <  if(EdgeFitter::AllowTriangle) signalSF.plotOn(frame4,RooFit::LineStyle(kDashed), RooFit::LineColor(kGreen));
820 <
866 >  EdgeFitter::SFSample->plotOn(frame4,RooFit::Name("SFdata")) ;
867 >  SF_result.plotOn(frame4,RooFit::Name("FullFitSF"),RooFit::ProjWData(*EdgeFitter::SFSample),RooFit::LineColor(kBlack));
868 >  SF_result.plotOn(frame4,RooFit::Name("TTbarSFonly"),RooFit::ProjWData(*EdgeFitter::SFSample),RooFit::Components("ttbaree,ttbarmm"),RooFit::LineColor(kBlue),RooFit::LineStyle(kDashed));
869 >  SF_result.plotOn(frame4,RooFit::Name("DYSFonly"),RooFit::ProjWData(*EdgeFitter::SFSample),RooFit::Components("zmm,zee"), RooFit::LineStyle(kDashed), RooFit::LineColor(kRed));
870 >  if(EdgeFitter::AllowTriangle) SF_result.plotOn(frame4,RooFit::Name("SignalSFonly"),RooFit::Components("signalSF"), RooFit::ProjWData(*EdgeFitter::SFSample), RooFit::LineStyle(kDashed), RooFit::LineColor(kGreen));  
871    
872   /// ********************************************************************************************************************************
873    TCanvas* c = new TCanvas("rf501_simultaneouspdf","rf403_simultaneouspdf") ;
# Line 827 | Line 877 | void EdgeFitter::DoFit(int is_data, floa
877    frame1->Draw();
878    if(is_data==data) DrawPrelim();
879    else DrawPrelim(PlottingSetup::luminosity,true);
880 <  if(EdgeFitter::FixedMEdge>=0) CompleteSave(c,"Edge/"+prefix.str()+"_ee__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false);
831 <  else CompleteSave(c,"Edge/"+prefix.str()+"_ee",false,false);
880 >  CompleteSave(c,"Edge/"+prefix.str()+"_ee",false,false);
881    
882    c->cd() ;
883    gPad->SetLeftMargin(0.15);
# Line 836 | Line 885 | void EdgeFitter::DoFit(int is_data, floa
885    frame2->Draw();
886    if(is_data==data) DrawPrelim();
887    else DrawPrelim(PlottingSetup::luminosity,true);
888 <  if(EdgeFitter::FixedMEdge>=0) CompleteSave(c,"Edge/"+prefix.str()+"_mm__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false);
840 <  else CompleteSave(c,"Edge/"+prefix.str()+"_mm",false,false);
888 >  CompleteSave(c,"Edge/"+prefix.str()+"_mm",false,false);
889    
890    c->cd() ;
891    gPad->SetLeftMargin(0.15);
# Line 845 | Line 893 | void EdgeFitter::DoFit(int is_data, floa
893    frame3->Draw();
894    if(is_data==data) DrawPrelim();
895    else DrawPrelim(PlottingSetup::luminosity,true);
896 <  if(EdgeFitter::FixedMEdge>=0) CompleteSave(c,"Edge/"+prefix.str()+"_OF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false);
849 <  else CompleteSave(c,"Edge/"+prefix.str()+"_OF",false,false);
896 >  CompleteSave(c,"Edge/"+prefix.str()+"_OF",false,false);
897  
898    c->cd() ;
899    gPad->SetLeftMargin(0.15);
# Line 854 | Line 901 | void EdgeFitter::DoFit(int is_data, floa
901    frame4->Draw();
902    if(is_data==data) DrawPrelim();
903    else DrawPrelim(PlottingSetup::luminosity,true);
904 <  if(EdgeFitter::FixedMEdge>=0) CompleteSave(c,"Edge/"+prefix.str()+"_SF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false);
858 <  else CompleteSave(c,"Edge/"+prefix.str()+"_SF",false,false);
904 >  CompleteSave(c,"Edge/"+prefix.str()+"_SF",false,false);
905  
906    delete c;
907   /// ********************************************************************************************************************************
# Line 887 | Line 933 | void EdgeFitter::DoEdgeFit(string mcjzb,
933    EdgeFitter::AllowTriangle=false;
934    EdgeFitter::DoFit(is_data, jzb_cut);
935    
890  write_info(__FUNCTION__,"TAKING SHORTCUT");return;
891  
936    EdgeFitter::AllowTriangle=true;
937    
938    bool ScanMassRange=false;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines