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.16 by buchmann, Mon Apr 30 08:38:11 2012 UTC vs.
Revision 1.27 by buchmann, Mon Jun 18 13:15:39 2012 UTC

# Line 35 | Line 35 | void find_peaks(float &MCPeak,float &MCP
35    // Temporarily switch off PU reweighting, if asked
36    TCut weightbackup=cutWeight;
37    if ( !doPUreweighting ) cutWeight="1.0";
38 <
38 >  
39 >  int nbins=100;
40 >  if(PlottingSetup::DoBTag) nbins=25;
41 >  
42    TCanvas *tempcan = new TCanvas("tempcan","Temporary canvas for peak finding preparations");
43 <  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity);
44 <  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
45 <  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,100,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity);
46 <  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,100, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
43 >  TH1F *rawJZBeemmMC      = allsamples.Draw("rawJZBeemmMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,mc, luminosity);
44 >  TH1F *rawJZBeemmData    = allsamples.Draw("rawJZBeemmData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,data, luminosity);
45 >  TH1F *rawJZBemMC      = allsamples.Draw("rawJZBemMC",jzbvariablemc,nbins,-50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,mc, luminosity);
46 >  TH1F *rawJZBemData    = allsamples.Draw("rawJZBemData",jzbvariabledata,nbins, -50,50, "JZB [GeV]", "events", cutmass&&cutOSOF&&cutnJets,data, luminosity);
47    TH1F *rawttbarjzbeemmMC;
48  
49    if(method==doKM) {
50      //we only need this histo for the KM fitting...
51 <    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,100, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("TTJet"));
51 >    rawttbarjzbeemmMC = allsamples.Draw("rawttbarjzbeemmMC",jzbvariablemc,nbins, -50,50, "JZB [GeV]", "events",cutmass&&cutOSSF&&cutnJets,mc,luminosity,allsamples.FindSample("TTJet"));
52      MCPeak=find_peak(rawJZBeemmMC, rawttbarjzbeemmMC, -40, 40, mc, MCPeakError,MCSigma,method);
53      DataPeak=find_peak(rawJZBeemmData, rawJZBeemmData, -40, 40, data, DataPeakError,DataSigma,method);
54    }
# Line 269 | Line 272 | void make_kin_plot(string variable, stri
272    TCut cut;
273    cut=cutmass&&cutOSSF&&cutnJets&&ibasiccut;
274    if(filename=="nJets") cut=cutmass&&cutOSSF&&ibasiccut;
275 +  if(filename=="nJets_osof") cut=cutmass&&cutOSOF&&ibasiccut;
276    if(filename=="nJets_nocuts_except_mll_ossf") cut=cutmass&&cutOSSF;
277    if(filename=="mll") {
278          cut=cutOSSF&&cutnJets&&ibasiccut;
# Line 296 | Line 300 | void make_kin_plot(string variable, stri
300    THStack mcstack = allsamples.DrawStack("mcstack",variable,nbins,min,max, xlabel, "events",cut,mc,luminosity);
301    if(variable=="pfJetGoodPt[0]") datahisto->SetMaximum(10*datahisto->GetMaximum());
302    if(variable=="pt") datahisto->SetMaximum(10*datahisto->GetMaximum());
303 <  if(filename=="mll_inclusive") datahisto->SetMinimum(1);
303 >  if(filename=="mll_inclusive"||filename=="mll_inclusive_mm"||filename=="mll_inclusive_ee") datahisto->SetMinimum(1);
304    if(filename=="mll_osof") datahisto->SetMaximum(10*datahisto->GetMaximum());
305    if(filename=="mll_osof") datahisto->SetMinimum(9);
302
306    datahisto->SetMaximum(5.3*datahisto->GetMaximum());
307    datahisto->Draw("e1");
308    ckin->Update();
# Line 430 | Line 433 | void do_kinematic_plots(string mcjzb, st
433    bool dolog=true;
434    bool nolog=false;
435    if(doPF) write_warning(__FUNCTION__,"Please use caution when trying to produce PF plots; not all versions of the JZB trees have these variables!");
436 <  float mll_low=40;
436 >  float mll_low=50;
437    float mll_hi=160;
438    if(!PlottingSetup::RestrictToMassPeak) {
439 <        mll_low=10;
439 >        mll_low=20;
440          mll_hi=210;
441    }
442    
443 +  make_kin_plot("met[4]","",40,0,200,dolog,"MET [GeV]","met",doPF,true);
444    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
445    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
446    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
# Line 444 | Line 448 | void do_kinematic_plots(string mcjzb, st
448    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive",doPF,true);
449    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_ee",doPF,true);
450    make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_mm",doPF,true);
451 <  make_kin_plot("mll","",(int)((mll_hi-mll_low)),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
451 >  make_kin_plot("mll","",(int)((mll_hi-mll_low))/2,mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_inclusive_osof",doPF,true);
452    make_kin_plot("mll","",(int)((350-mll_low)),mll_low,350,dolog,"m_{ll} [GeV]","mll_inclusive_highrange",doPF);
453    make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
454 <  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
455 <  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
454 > //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
455 > //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
456    make_kin_plot("pt","",50,0,400,dolog,"Z p_{T} [GeV]","Zpt",doPF);
457    make_kin_plot("pt1","",50,0,100,nolog,"p_{T} [GeV]","pt1",doPF);
458    make_kin_plot("pt2","",50,0,100,nolog,"p_{T} [GeV]","pt2",doPF);
459    make_kin_plot("eta1","",40,-5,5,nolog,"#eta_{l}","eta",doPF);
460    make_kin_plot("jzb[1]","",100,-150,150,dolog,"JZB [GeV]","jzb_ossf",doPF);
461 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets",doPF);
462 <  make_kin_plot("pfJetGoodNum","",8,0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
461 >  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets",doPF);
462 >  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_osof",doPF);
463 >  make_kin_plot("pfJetGoodNum40","",9,-0.5,8.5,dolog,"nJets","nJets_nocuts_except_mll_ossf",doPF);
464    if(!doPF) make_special_mll_plot((int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]");
465    stringstream jzbcut;
466    jzbcut << "((is_data&&("<<datajzb<<")>100)||(!is_data&&("<<mcjzb<<")>100))";
# Line 469 | Line 474 | void do_kinematic_plots(string mcjzb, st
474    make_kin_plot("mll",jzbcut2.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB150",doPF,true);
475    stringstream jzbcut3;
476    jzbcut3 << "((is_data&&("<<datajzb<<")>50)||(!is_data&&("<<mcjzb<<")>50))";
477 <  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);   make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB50",doPF,true,true);
477 >  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_aboveJZB50",doPF,true);  
478 >  make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof_aboveJZB50",doPF,true,true);
479    
480    make_special_obs_pred_mll_plot(mcjzb,0);
481    make_special_obs_pred_mll_plot(mcjzb,50);
# Line 932 | Line 938 | void do_prediction_plot(string jzb, TCan
938      
939    TH1F *Bpred = (TH1F*)LcorrJZBeemm->Clone("Bpred");
940    TH1F *JBpred = (TH1F*)JLcorrJZBeemm->Clone("Bpred");
941 +    
942 +  TH1F *BpredSys = new TH1F("Bpredsys","Bpredsys",PlottingSetup::global_ratio_binning.size()-1,&PlottingSetup::global_ratio_binning[0]);
943 +  ClearHisto(BpredSys);
944 +    
945    if(PlottingSetup::RestrictToMassPeak) {
946      Bpred->Add(RcorrJZBem,1.0/3.);
947      Bpred->Add(LcorrJZBem,-1.0/3.);
# Line 954 | Line 964 | void do_prediction_plot(string jzb, TCan
964      JBpred->Add(JLcorrJZBSBem,-1.0/3.);
965      JBpred->Add(JRcorrJZBSBeemm,1.0/3.);
966      JBpred->Add(JLcorrJZBSBeemm,-1.0/3.);
967 +      
968 +    //Systematics:
969 +    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertONPEAK*zjetsestimateuncertONPEAK);
970 +    AddSquared(BpredSys,JRcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
971 +    AddSquared(BpredSys,JLcorrJZBem,emuncertONPEAK*emuncertONPEAK*(1.0/9));
972 +    AddSquared(BpredSys,JRcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
973 +    AddSquared(BpredSys,JLcorrJZBSBem,emsidebanduncertONPEAK*emsidebanduncertONPEAK*(1.0/9));
974 +    AddSquared(BpredSys,JRcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
975 +    AddSquared(BpredSys,JLcorrJZBSBeemm,eemmsidebanduncertONPEAK*eemmsidebanduncertONPEAK*(1.0/9));
976    } else {
977      Bpred->Add(RcorrJZBem,1.0);
978      Bpred->Add(LcorrJZBem,-1.0);
# Line 963 | Line 982 | void do_prediction_plot(string jzb, TCan
982      //these are for the ratio
983      JBpred->Add(JRcorrJZBem,1.0);
984      JBpred->Add(JLcorrJZBem,-1.0);
985 +      
986 +    //Systematics
987 +    AddSquared(BpredSys,JLcorrJZBeemm,zjetsestimateuncertOFFPEAK*zjetsestimateuncertOFFPEAK);
988 +    AddSquared(BpredSys,JRcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
989 +    AddSquared(BpredSys,JLcorrJZBem,emuncertOFFPEAK*emuncertOFFPEAK);
990 +
991    }
992      
993 <  
993 >  SQRT(BpredSys);
994 >  BpredSys->Divide(JBpred);
995 >
996    
997    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak ---- prediction changed
998    TH1F *Tpred = (TH1F*)RcorrJZBem->Clone("Bpred");
# Line 1022 | Line 1049 | void do_prediction_plot(string jzb, TCan
1049      lm4RcorrJZBeemm->Draw("hist,same");
1050      legBpred->AddEntry(RcorrJZBeemm,"observed","p");
1051      legBpred->AddEntry(Bpred,"predicted","l");
1052 <    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1053 <    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1054 <    if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1052 > //    legBpred->AddEntry(analytical_function[1],"predicted fit","l");
1053 > //    legBpred->AddEntry(analytical_function[2],"stat. uncert.","l");
1054 >    legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1055      legBpred->Draw();
1056      DrawPrelim();
1057  
# Line 1067 | Line 1094 | void do_prediction_plot(string jzb, TCan
1094   //    speciallegBpred->AddEntry(lm4RcorrJZBeemmC,"LM4","l");
1095      speciallegBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
1096      speciallegBpred->Draw();
1097 <    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,use_data!=1,"data/pred");
1097 >    save_with_ratio(JRcorrJZBeemm,JBpred,predcomppad,subdir+"Bpred_Data_____PredictionComposition",true,true,"data/pred",BpredSys);
1098      
1099      TCanvas *specialcanv = new TCanvas("specialcanv","specialcanv");
1100      THStack kostack = allsamples.DrawStack("RcorrJZBeemm",jzb.c_str(),nbins,low,hi, "JZB [GeV]", "events", cutmass&&cutOSSF&&cutnJets,!is_data, luminosity,use_signal);
# Line 1093 | Line 1120 | void do_prediction_plot(string jzb, TCan
1120      Bpred->Draw("hist,same");
1121      RcorrJZBeemm->Draw("e1x0,same");//HAVE IT ON TOP!
1122      legBpred->AddEntry(RcorrJZBeemm,"MC true","p");
1123 <    legBpred->AddEntry(Bpred,"MC predicted","l");
1123 >    legBpred->AddEntry(Bpred,"MC predicted","l");    
1124      if(versok) legBpred->AddEntry((TObject*)0,"",""); // Just for alignment // causes seg fault on root v5.18
1125      if(versok) legBpred->AddEntry((TObject*)0,"",""); // causes seg fault on root v5.18
1126      if ( overlay_signal ) legBpred->AddEntry(lm4RcorrJZBeemm,"LM4","l");
# Line 1145 | Line 1172 | void do_prediction_plot(string jzb, TCan
1172    string ytitle("ratio");
1173    if ( use_data==1 ) ytitle = "data/pred";
1174    //save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,Bpredsaveas,true,use_data!=1,ytitle);
1175 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,false,ytitle);//not extending the y range anymore up to 4
1175 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,subdir+Bpredsaveas,true,true,ytitle,BpredSys);//not extending the y range anymore up to 4
1176  
1177    
1178    flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
1179 <  /// The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1179 >  // The part below is meaningless for the offpeak analysis (it's a comparison of the different estimates but there is but one estimate!)
1180    if(PlottingSetup::RestrictToMassPeak) {
1181      TH1F *Bpredem = (TH1F*)LcorrJZBeemm->Clone("Bpredem");
1182      Bpredem->Add(RcorrJZBem);
# Line 2065 | Line 2092 | void draw_ttbar_and_zjets_shape(string m
2092    draw_ttbar_and_zjets_shape_for_one_configuration(mcjzb,datajzb,all_leptons,threejetswith30gev,true);
2093   }
2094  
2095 < void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2069 <  //first: colorful plots
2095 > float find_one_correction_factor(string FindKeyword, TCut SpecialCut, string SaveAs) {
2096    TCanvas *cancorr = new TCanvas("cancorr","Canvas for Response Correction");
2097    cancorr->SetLogz();
2098    cancorr->SetRightMargin(0.13);
2099 <  flag_this_change(__FUNCTION__,__LINE__,true);//PlottingSetup::RestrictToMassPeak
2100 <  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)");
2099 >  TCut zptforresponsepresentation("pt<600"&&cutmass&&cutOSSF&&"((sumJetPt[1]/pt)<5.0)"&&SpecialCut);
2100 >  if(PlottingSetup::DoBTag) zptforresponsepresentation=zptforresponsepresentation&&PlottingSetup::bTagRequirement;
2101    TH2F *niceresponseplotd = new TH2F("niceresponseplotd","",100,0,600,100,0,5);
2102 <  (allsamples.collection)[allsamples.FindSample("Data")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotd",zptforresponsepresentation);
2102 >  vector<int> SampleIndices=allsamples.FindSample(FindKeyword);
2103 >  for(int iSample=0;iSample<SampleIndices.size();iSample++) {
2104 >    dout << "   Response correction : Using sample " << (allsamples.collection)[SampleIndices[iSample]].filename << endl;
2105 >    (allsamples.collection)[SampleIndices[iSample]].events->Draw("sumJetPt[1]/pt:pt>>+niceresponseplotd",zptforresponsepresentation*cutWeight);
2106 >  }
2107 >    
2108    niceresponseplotd->SetStats(0);
2109    niceresponseplotd->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2110    niceresponseplotd->GetYaxis()->SetTitle("Response");
# Line 2082 | Line 2113 | void find_correction_factors(string &jzb
2113    niceresponseplotd->Draw("COLZ");
2114    TProfile * profd = (TProfile*)niceresponseplotd->ProfileX();
2115    profd->SetMarkerSize(DataMarkerSize);
2116 <  profd->Fit("pol0","","same,e1",30,400);
2116 >  profd->Fit("pol0","","same,e1",100,400);
2117    DrawPrelim();
2118 <  TText* title = write_text(0.5,0.7,"Data");
2118 >  string stitle="Data";
2119 >  if(!Contains(FindKeyword,"Data")) stitle="MC";
2120 >  TText* title = write_text(0.5,0.7,stitle.c_str());
2121    title->SetTextAlign(12);
2122    title->Draw();
2123    TF1 *datapol=(TF1*)profd->GetFunction("pol0");
2124 <  float datacorrection=datapol->GetParameter(0);
2125 <  stringstream dataresstring;
2126 <  dataresstring<<"Response: "<<std::setprecision(2)<<100*datacorrection<<" %";
2127 <  TText* restitle = write_text(0.5,0.65,dataresstring.str());
2124 >  float correction=datapol->GetParameter(0);
2125 >  stringstream resstring;
2126 >  resstring<<"Response: "<<std::setprecision(2)<<100*correction<<" %";
2127 >  TText* restitle = write_text(0.5,0.65,resstring.str());
2128    restitle->SetTextAlign(12);
2129    restitle->SetTextSize(0.03);
2130    restitle->Draw();
2131 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_Data");
2131 >  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_New_"+SaveAs);
2132 >  delete cancorr;
2133 >  delete niceresponseplotd;
2134 >  return correction;
2135 > }
2136 >
2137 > void find_correction_factors(string &jzbvardata,string &jzbvarmc) {
2138    
2139 <  TH2F *niceresponseplotm = new TH2F("niceresponseplotm","",100,0,600,100,0,5);
2140 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt>>niceresponseplotm",zptforresponsepresentation);
2141 <  niceresponseplotm->SetStats(0);
2142 <  niceresponseplotm->GetXaxis()->SetTitle("Z p_{T} [GeV]");
2143 <  niceresponseplotm->GetYaxis()->SetTitle("Response");
2144 <  niceresponseplotm->GetXaxis()->CenterTitle();
2145 <  niceresponseplotm->GetYaxis()->CenterTitle();
2146 <  niceresponseplotm->Draw("COLZ");
2147 <  (allsamples.collection)[allsamples.FindSample("DY")[0]].events->Draw("sumJetPt[1]/pt:pt",zptforresponsepresentation,"PROF,same");
2148 <  TProfile * profm = (TProfile*)niceresponseplotm->ProfileX();
2149 <  profm->SetMarkerSize(DataMarkerSize);
2150 <  profm->Fit("pol0","","same,e1",30,400);
2151 <  DrawMCPrelim();
2152 <  title = write_text(0.5,0.7,"MC simulation");
2153 <  title->SetTextAlign(12);
2154 <  title->Draw();
2155 <  TF1 *mcpol=(TF1*)profm->GetFunction("pol0");
2156 <  float mccorrection=mcpol->GetParameter(0);
2157 <  stringstream mcresstring;
2158 <  mcresstring<<"Response: "<<std::setprecision(2)<<100*mccorrection<<" %";
2120 <  TText* mcrestitle = write_text(0.5,0.65,mcresstring.str());
2121 <  mcrestitle->SetTextAlign(12);
2122 <  mcrestitle->SetTextSize(0.03);
2123 <  mcrestitle->Draw();
2124 <  CompleteSave(cancorr,"ResponseCorrection/Response_Correction_Illustration_MC");
2139 >  //Step 1 : Get results
2140 >  float datacorrection=find_one_correction_factor("Data","","Data");
2141 >  float mccorrection=find_one_correction_factor("DY","","MC");
2142 >  
2143 >  float dataEEcorrection=find_one_correction_factor("Data","id1==0","Data_ee");
2144 >  float mcEEcorrection=find_one_correction_factor("DY","id1==0","MC_ee");
2145 >  
2146 >  float dataMMcorrection=find_one_correction_factor("Data","id1==1","Data_mm");
2147 >  float mcMMcorrection=find_one_correction_factor("DY","id1==1","MC_mm");
2148 >  
2149 >  cout << "Corrections : " << endl;
2150 >  cout << "   Data : " << datacorrection << endl;
2151 >  cout << "     ee (" << dataEEcorrection << ") , mm (" << dataMMcorrection << ")" << endl;
2152 >  cout << "   MC : " << mccorrection << endl;
2153 >  cout << "     ee (" << mcEEcorrection << ") , mm (" << mcMMcorrection << ")" << endl;
2154 >  
2155 >  cout << "        result from new one for data: " << 0.937097 << endl;
2156 >  cout << "        result from old one for data: " << 0.937097 << endl;
2157 >  cout << "        result from new one for MC: " << 0.96848 << endl;
2158 >  cout << "        result from old one for MC: " << 0.963502 << endl;
2159    
2160    
2161 <  //Step 2: Getting the result
2128 < //  TCut zptcutforresponse("pt>30&&pt<300&&TMath::Abs(91.2-mll)<20&&id1==id2&&(ch1*ch2<0)");
2161 >  //Step 2: Processing the result and making it into something useful :-)
2162    stringstream jzbvardatas;
2163 <  if(datacorrection>1) jzbvardatas<<"(jzb[1]-"<<datacorrection-1<<"*pt)";
2164 <  if(datacorrection<1) jzbvardatas<<"(jzb[1]+"<<1-datacorrection<<"*pt)";
2163 >  jzbvardatas << "(";
2164 >  
2165 >  if(dataEEcorrection>=1) jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]-" << dataEEcorrection-1 << "*pt))";
2166 >  if(dataEEcorrection<1)  jzbvardatas<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-dataEEcorrection << "*pt))";
2167 >  
2168 >  if(dataMMcorrection>=1) jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]-" << dataMMcorrection-1 << "*pt))";
2169 >  if(dataMMcorrection<1)  jzbvardatas<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-dataMMcorrection << "*pt))";
2170 >  
2171 >  float averagecorrection=(dataMMcorrection+dataEEcorrection)/2.0;
2172 >  
2173 >  if(averagecorrection>1) jzbvardatas<<"+((id1!=id2)*(jzb[1]-" << averagecorrection-1 << "*pt))";
2174 >  if(averagecorrection<1) jzbvardatas<<"+((id1!=id2)*(jzb[1]-" << 1-averagecorrection << "*pt))";
2175 >  
2176 >  jzbvardatas << ")";
2177    jzbvardata=jzbvardatas.str();
2178 +  
2179    stringstream jzbvarmcs;
2180 <  if(mccorrection>1) jzbvarmcs<<"(jzb[1]-"<<mccorrection-1<<"*pt)";
2181 <  if(mccorrection<1) jzbvarmcs<<"(jzb[1]+"<<1-mccorrection<<"*pt)";
2180 >  jzbvarmcs << "(";
2181 >  
2182 >  if(mcEEcorrection>=1) jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]-" << mcEEcorrection-1 << "*pt))";
2183 >  if(mcEEcorrection<1)  jzbvarmcs<<"((id1==0&&id1==id2)*(jzb[1]+" << 1-mcEEcorrection << "*pt))";
2184 >  
2185 >  if(mcMMcorrection>=1) jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]-" << mcMMcorrection-1 << "*pt))";
2186 >  if(mcMMcorrection<1)  jzbvarmcs<<"+((id1==1&&id1==id2)*(jzb[1]+" << 1-mcMMcorrection << "*pt))";
2187 >  
2188 >  float averagemccorrection=(mcMMcorrection+mcEEcorrection)/2.0;
2189 >  
2190 >  if(averagemccorrection>1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]-" << averagemccorrection-1 << "*pt))";
2191 >  if(averagemccorrection<1) jzbvarmcs<<"+((id1!=id2)*(jzb[1]-" << 1-averagemccorrection << "*pt))";
2192 >  
2193 >  jzbvarmcs << ")";
2194    jzbvarmc=jzbvarmcs.str();
2195 +
2196    dout << "JZB Z pt correction summary : " << endl;
2197    dout << "  Data: The response is " << datacorrection << "  --> jzb variable is now : " << jzbvardata << endl;
2198    dout << "  MC  : The response is " << mccorrection << "  --> jzb variable is now : " << jzbvarmc << endl;
2199 +  
2200   }
2201  
2202   void pick_up_events(string cut) {
# Line 2144 | Line 2204 | void pick_up_events(string cut) {
2204    allsamples.PickUpEvents(cut);
2205   }
2206  
2207 < void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError) {
2207 > void save_template(string mcjzb, string datajzb,vector<float> jzb_cuts,float MCPeakError,float DataPeakError, vector<float> jzb_shape_limit_bins) {
2208    dout << "Saving configuration template!" << endl;
2209    ofstream configfile;
2210    configfile.open("../DistributedModelCalculations/last_configuration.C");
# Line 2164 | Line 2224 | void save_template(string mcjzb, string
2224    configfile<<"string datajzb=\"datajzb_ERROR\";\n";
2225    configfile<<"string mcjzb=\"mcjzb_ERROR\";\n";
2226    configfile<<"vector<float>jzb_cuts;\n";
2227 +  configfile<<"vector<float>jzb_shape_limit_bins;\n";
2228    configfile<<"float MCPeakError=-999;\n";
2229    configfile<<"float DataPeakError=-999;\n";
2230    configfile<<"}\n\n";
# Line 2182 | Line 2243 | void save_template(string mcjzb, string
2243    for(int i=0;i<(int)flippedNobs.size();i++) configfile<<"flippedNobs.push_back("<<flippedNobs[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2244    for(int i=0;i<(int)flippedNpred.size();i++) configfile<<"flippedNpred.push_back("<<flippedNpred[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2245    for(int i=0;i<(int)flippedNprederr.size();i++) configfile<<"flippedNprederr.push_back("<<flippedNprederr[i]<<"); // JZB cut at " << jzb_cuts[i] << "\n";
2246 +  for(int i=0;i<(int)jzb_shape_limit_bins.size();i++) configfile<<"jzb_shape_limit_bins.push_back("<<jzb_shape_limit_bins[i]<<"); // JZB shape bin boundary at " << jzb_shape_limit_bins[i] << "\n";
2247 +  configfile<<"\n\n";
2248    configfile<<"\n\n";
2249    configfile<<"luminosity="<<luminosity<<";\n";
2250    configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
# Line 2227 | Line 2290 | void ttbar_sidebands_comparison(string m
2290    //in the case of the on peak analysis, we compare the 3 control regions to the real value
2291    //in the case of the OFF peak analysis, we compare our control region to the real value
2292    TCut weightbackup=cutWeight;
2293 <  cutWeight="1.0";
2293 > //  cutWeight="1.0";
2294    float simulatedlumi = luminosity; //in pb please - adjust to your likings
2295    
2296  
# Line 2285 | Line 2348 | void ttbar_sidebands_comparison(string m
2348    leg->Draw("same");
2349    DrawMCPrelim(simulatedlumi);
2350    CompleteSave(tcan,"Systematics/"+prestring+"/ttbar_shape_comparison");
2288 cout << __LINE__ << endl;  
2351    TH1F *TZemcopy = (TH1F*)TZem->Clone("TZemcopy");
2290 cout << __LINE__ << endl;  
2352    TH1F *TZeemmcopy = (TH1F*)TZeemm->Clone("TZeemmcopy");
2292 cout << __LINE__ << endl;  
2353    TH1F *TSeemmcopy;
2354    TH1F *TSemcopy;
2355    if(PlottingSetup::RestrictToMassPeak) {
# Line 2480 | Line 2540 | void ttbar_sidebands_comparison(string m
2540   }
2541  
2542  
2543 < void zjets_prediction_comparison() {
2543 > void zjets_prediction_comparison(string mcjzbWithPU) {
2544 >  TCanvas *zcan = new TCanvas("zcan","zcan");  
2545 >  zcan->SetLogy(1);
2546 >  TCut weightbackup=cutWeight;
2547 >
2548 > /*
2549    // Do it without PU re-weighting
2550    float MCPeakNoPU=0,MCPeakErrorNoPU=0,DataPeakNoPU=0,DataPeakErrorNoPU=0,MCSigma=0,DataSigma=0;
2551    stringstream resultsNoPU;
2552  
2553    stringstream mcjzbnoPU;
2554 <  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,false);
2554 >  find_peaks(MCPeakNoPU,MCPeakErrorNoPU, DataPeakNoPU, DataPeakErrorNoPU,MCSigma,DataSigma,resultsNoPU,true);
2555    if(MCPeakNoPU>0) mcjzbnoPU<<"("<<jzbvariablemc<<"-"<<TMath::Abs(MCPeakNoPU)<<")";
2556    else mcjzbnoPU<<"("<<jzbvariablemc<<"+"<<TMath::Abs(MCPeakNoPU)<<")";
2557  
2558    string mcjzb = mcjzbnoPU.str();
2559    dout << "The peak corrected JZB expression for MC without pileup is : " <<  mcjzb << endl;
2560  
2496  TCut weightbackup=cutWeight;
2561    cutWeight="1.0";
2562 <  float sbg_min=0.;
2563 <  float sbg_max=100.;
2564 <  int sbg_nbins=5;
2562 > */
2563 >  string mcjzb = mcjzbWithPU; // this is with PURW, if you want without it you have to uncomment the part above (and comment out this line)
2564 >  
2565 >  vector<float> binning;
2566 >  binning.push_back(0);
2567 >  binning.push_back(20);
2568 >  binning.push_back(40);
2569 >  binning.push_back(60);
2570 >  binning.push_back(80);
2571 >  binning.push_back(100);
2572 > //  float sbg_min=0.;
2573 > //  float sbg_max=100.;
2574 > //  int sbg_nbins=5;
2575    float simulatedlumi = luminosity;//in pb please - adjust to your likings
2576    
2577    TCut kPos((mcjzb+">0").c_str());
2578    TCut kNeg((mcjzb+"<0").c_str());
2579    string var( "abs("+mcjzb+")" );
2580  
2581 <  TCut kcut(cutmass&&cutOSSF&&"pfJetGoodNum>2");
2582 <  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2583 <                                  kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2510 <  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,sbg_nbins,sbg_min,sbg_max, "JZB [GeV]", "events",
2511 <                                  kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2581 >  TCut kcut(cutmass&&cutOSSF&&cutnJets);
2582 >  TH1F *hJZBpos = systsamples.Draw("hJZBpos",var,binning, "JZB [GeV]", "events",kcut&&kPos,mc,simulatedlumi,systsamples.FindSample("/DY"));
2583 >  TH1F *hJZBneg = systsamples.Draw("hJZBneg",var,binning, "JZB [GeV]", "events",kcut&&kNeg,mc,simulatedlumi,systsamples.FindSample("/DY"));
2584    hJZBpos->SetLineColor(kBlack);
2585    hJZBneg->SetLineColor(kRed);
2586    
2587 <  TCanvas *zcan = new TCanvas("zcan","zcan");  
2516 <  zcan->SetLogy(1);
2517 <
2587 >  hJZBpos->SetMinimum(1.0);
2588    hJZBpos->Draw("e1");
2589    hJZBneg->Draw("same,hist");
2590    hJZBpos->Draw("same,e1"); // So it's on top...
# Line 2534 | Line 2604 | void zjets_prediction_comparison() {
2604    hratio->GetYaxis()->SetTitle("Observed/Predicted");
2605    hratio->Draw("e1");
2606    
2607 <  TLine *top = new TLine(sbg_min,1.25,sbg_max,1.25);
2608 <  TLine *center = new TLine(sbg_min,1.0,sbg_max,1.0);
2609 <  TLine *bottom = new TLine(sbg_min,0.75,sbg_max,0.75);
2607 >  TLine *top = new TLine(binning[0],1.25,binning[binning.size()-1],1.25);
2608 >  TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);
2609 >  TLine *bottom = new TLine(binning[0],0.75,binning[binning.size()-1],0.75);
2610    
2611  
2612    top->SetLineColor(kBlue);top->SetLineStyle(2);
# Line 2578 | Line 2648 | void sideband_assessment(string datajzb,
2648    tout << "\\begin{tabular}{l|cc}" << endl;
2649    tout << "\\hline" << endl;
2650    tout << "& {\\OFZP} & {\\OFSB} \\\\\\hline" << endl;
2651 <  tout << "\\#(events) & "<<OFSB<<" & "<<OFZP<<"\\\\ \\hline" << endl;
2651 >  tout << "\\#(events) & "<<OFZP<<" & "<<OFSB<<"\\\\ \\hline" << endl;
2652    tout << "\\end{tabular}" << endl;
2653    tout << "\\end{center}" << endl;
2654    tout << "\\end{table}" << endl;
# Line 2901 | Line 2971 | void qcd_plots(string datajzb, string mc
2971    //3rd last argument: do special bpred ratio, 2nd last argument: extended range!, last: y-axis title
2972    string ytitle("ratio");
2973    if ( use_data==1 ) ytitle = "data/pred";
2974 <  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,use_data!=1,ytitle);
2974 >  save_with_ratio(JRcorrJZBeemm,JBpred,kinpad,"QCD/Bpred",true,false,ytitle);
2975    
2976    TH1F *allevents = qcdsamples.Draw("allevents","pfJetGoodNum",1,0,100, "internal code", "events", "" ,mc, luminosity);
2977    TH1F *ossf = qcdsamples.Draw("ossf","pfJetGoodNum",1,0,100, "internal code", "events", cutOSSF ,mc, luminosity);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines