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.50 by buchmann, Wed Aug 15 13:52:12 2012 UTC vs.
Revision 1.52 by buchmann, Thu Aug 16 14:30:32 2012 UTC

# Line 357 | Line 357 | void draw_ratio_plot(TH1* hdata, THStack
357    oneline->SetLineWidth(1);
358    oneline->Draw("same");
359   }
360 <
361 < void make_OFSF_plot(string variable, string addcut, string legendTitle, int nbins, float min, float max, bool logscale,
362 <                   string xlabel, string filename, bool isPF=true, bool plotratio=true, bool loadlastminmax=false, float legendPosition=0.3) {
360 > float make_one_OFSF_plot(string variable, string addcut, string legendTitle, int nbins, float min, float max, float ymax, bool logscale,
361 >                        string xlabel, string filename, bool plotratio=true, bool loadlastminmax=false, float legendPosition=0.55) {
362  
363    TCut ibasiccut=basiccut;
364    bool draw_separation_lines=false;
365  
367  if(isPF) ibasiccut=basiccut&&"pfjzb[0]>-998";
368
366    if(addcut != "") ibasiccut = ibasiccut && addcut.c_str();
367  
368    TCut cutSF;
369    TCut cutOF;
370  
371 <  cutOF=cutOSOF&&cutnJets&&ibasiccut;
372 <  cutSF=cutOSSF&&cutnJets&&ibasiccut;
376 <
371 >  cutOF = cutOSOF&&cutnJets&&ibasiccut;
372 >  cutSF = cutOSSF&&cutnJets&&ibasiccut;
373  
374    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
375    ckin->SetLogy(logscale);
# Line 385 | Line 381 | void make_OFSF_plot(string variable, str
381    (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cutSF);
382    signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
383    signalhisto->SetLineColor((signalsamples.collection)[idx].samplecolor);
384 +  signalhisto->SetLineStyle(2);
385    datahistoSF->SetMarkerSize(DataMarkerSize);
386    datahistoOF->SetLineColor(kRed);
387  
388    if ( !logscale ) {
389      datahistoSF->SetMinimum(0); // Defaults
393    datahistoOF->SetMinimum(0); // Defaults
390    } else {
391      datahistoSF->SetMinimum(0.5);
396    datahistoOF->SetMinimum(0.5);
392    }
393 <  if (logscale) {
394 <    datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
395 <    datahistoOF->SetMaximum(5.3*datahistoSF->GetMaximum());
393 >  if (ymax<0) {
394 >    if ( logscale ) datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
395 >    else datahistoSF->SetMaximum(1.5*datahistoSF->GetMaximum());
396    } else {
397 <    datahistoSF->SetMaximum(2.0*datahistoSF->GetMaximum());
403 <    datahistoOF->SetMaximum(2.0*datahistoOF->GetMaximum());
397 >    datahistoSF->SetMaximum(ymax);
398    }
399  
400 +  float ymaxSet = datahistoSF->GetMaximum();
401 +
402    datahistoSF->GetXaxis()->SetTitle(xlabel.c_str());
403 <  datahistoOF->GetXaxis()->SetTitle(xlabel.c_str());
408 <  signalhisto->GetXaxis()->SetTitle(xlabel.c_str());
409 <  datahistoSF->GetYaxis()->SetTitle("N. Events");
410 <  datahistoOF->GetYaxis()->SetTitle("N. Events");
411 <  signalhisto->GetYaxis()->SetTitle("N. Events");
403 >  datahistoSF->GetYaxis()->SetTitle("Events");
404    datahistoSF->GetXaxis()->CenterTitle();
413  datahistoOF->GetXaxis()->CenterTitle();
414  signalhisto->GetXaxis()->CenterTitle();
405    datahistoSF->GetYaxis()->CenterTitle();
416  datahistoOF->GetYaxis()->CenterTitle();
417  signalhisto->GetYaxis()->CenterTitle();
406  
407 <  TLegend *mleg = new TLegend(0.2+legendPosition, 0.72, 0.55+legendPosition, 0.87, legendTitle.c_str());
408 <  mleg->SetFillColor(kWhite);
409 <  mleg->SetTextFont(42);
410 <  mleg->SetTextSize(0.048);
411 <  mleg->SetLineWidth(0);
412 <  mleg->SetBorderSize(0);
413 <  mleg->AddEntry(datahistoSF, "S. Flavor", "PL");
426 <  mleg->AddEntry(datahistoOF, "O. Flavor", "L");
407 >  TLegend *mleg = make_legend(legendTitle.c_str(),legendPosition,0.7,false,legendPosition+0.2);
408 >  mleg->AddEntry(datahistoSF, "Same-flavor", "PL");
409 >  if (datahistoOF->Integral()>0) {
410 >    mleg->AddEntry(datahistoOF, "Opposite-flavor", "L");
411 >  } else {
412 >    mleg->AddEntry((TObject*)0, "", "");
413 >  }
414    mleg->AddEntry(signalhisto, "LM3", "L");
415  
416    datahistoSF->Draw("E1");
417 <  datahistoOF->Draw("HIST,SAMES");
417 >  if (datahistoOF->Integral()>0) datahistoOF->Draw("HIST,SAMES");
418    signalhisto->Draw("HIST,SAMES");
419    mleg->Draw();
420    DrawPrelim();
421 <  CompleteSave(ckin, "./SFOF/" + filename);
421 >  CompleteSave(ckin, "SFOF/" + filename);
422  
423    datahistoSF->Delete();
424    datahistoOF->Delete();
# Line 439 | Line 426 | void make_OFSF_plot(string variable, str
426    delete mleg;
427    delete ckin;
428  
429 +  return ymaxSet;
430 +
431   }
432  
433 + void make_OFSF_plots(string variable, string addcut, int nbins, float min, float max, bool logscale, string xlabel, string filename,
434 +                bool plotratio=true, bool loadlastminmax=false, float legendPosition=0.55) {
435 +
436 +  string mllcuts[] = { "mll>20","mll>20&&mll<70", "mll>70&&mll<110", "mll>110" };
437 +  string mllcutname[] = { "m_{ll} > 20 GeV", "20 < m_{ll} < 70 GeV", "70 < m_{ll} < 110 GeV", "m_{ll} > 110 GeV" };
438 +  string plotname[] = {"_all","_low","_peak","_high"};
439 +  float ymax;
440 +  for ( int i=0; i<4; ++i ) {
441 +    if ( addcut != "" ) mllcuts[i] += "&&"+addcut;
442 +    if ( i==0 ) {
443 +      ymax = make_one_OFSF_plot(variable, mllcuts[i],            mllcutname[i], nbins, min, max, -1, logscale, xlabel,
444 +                         filename+plotname[i], plotratio, loadlastminmax, legendPosition );
445 +    } else {
446 +      make_one_OFSF_plot(variable, mllcuts[i],            mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
447 +                         filename+plotname[i], plotratio, loadlastminmax, legendPosition );
448 +    }
449 +    make_one_OFSF_plot(variable, "id1==1&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
450 +                       filename+plotname[i]+"_mm", plotratio, loadlastminmax, legendPosition );
451 +    make_one_OFSF_plot(variable, "id1==0&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
452 +                       filename+plotname[i]+"_ee", plotratio, loadlastminmax, legendPosition );
453 +  }
454 +
455 + }
456  
457  
458   float lastrange_min=0;
# Line 659 | Line 671 | void do_kinematic_plots(string mcjzb, st
671          mll_low=20;
672          mll_hi=300;
673    }
674 <
675 <  /*
676 <  make_OFSF_plot("pfJetGoodNum40", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 5, 3, 8, true, "N. jets", "njetsLow", false, false, false, 0.2);
677 <  make_OFSF_plot("pfJetGoodNum40", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 5, 3, 8, true, "N. jets", "njetsMed", false, false, false, 0.2);
678 <  make_OFSF_plot("pfJetGoodPt[0]/pfJetGoodPt[1]", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2Low", false, false, false, 0.2);
679 <  make_OFSF_plot("pfJetGoodPt[0]/pfJetGoodPt[1]", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2Med", false, false, false, 0.2);
680 <  make_OFSF_plot("TMath::Abs(pfJetDphiMet[0])", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphijetmetLow", false, false, false, 0.0);
681 <  make_OFSF_plot("TMath::Abs(pfJetDphiMet[0])", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphijetmetMed", false, false, false, 0.0);
682 <  make_OFSF_plot("TMath::Abs(dphi)", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphiLow", false, false, false, 0.2);
683 <  make_OFSF_plot("TMath::Abs(dphi)", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphiMed", false, false, false, 0.2);
684 <  make_OFSF_plot("TMath::Abs(dphiMet1)", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1Low", false, false, false, 0.2);
685 <  make_OFSF_plot("TMath::Abs(dphiMet1)", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1Med", false, false, false, 0.2);
686 <  make_OFSF_plot("TMath::Abs(dphiMet2)", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2Low", false, false, false, 0.2);
687 <  make_OFSF_plot("TMath::Abs(dphiMet2)", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2Med", false, false, false, 0.2);
688 <  make_OFSF_plot("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", "dphilcLow", false, false, false, 0.2);
689 <  make_OFSF_plot("TMath::Min(TMath::Abs(dphiMet1), TMath::Abs(dphiMet2))", "mll>40&&mll<70&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(l,MET)|)", "dphilcMed", false, false, false, 0.2);
690 <  make_OFSF_plot("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijcLow", false, false, false, 0.2);
691 <  make_OFSF_plot("TMath::Min(TMath::Abs(pfJetDphiMet[0]), TMath::Min(TMath::Abs(pfJetDphiMet[1]), TMath::Abs(pfJetDphiMet[2])))", "mll>20&&mll<40&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijcMed", false, false, false, 0.2);
680 <  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(l,MET)|)", "dphilcoLow", false, false, false, 0.2);
681 <  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(dphiMet1)), (TMath::Pi() - TMath::Abs(dphiMet2)))", "mll>20&&mll<40&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(l,MET)|)", "dphilcoMed", false, false, false, 0.2);
682 <  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", "mll>20&&mll<40&&met[4]>100", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(jet,MET)|)", "dphijcoLow", false, false, false, 0.2);
683 <  make_OFSF_plot("TMath::Min((TMath::Pi()-TMath::Abs(pfJetDphiMet[0])), TMath::Min( (TMath::Pi()-TMath::Abs(pfJetDphiMet[1])), (TMath::Pi() - TMath::Abs(pfJetDphiMet[2]))))", "mll>20&&mll<40&&met[4]>100", "40 GeV < mll < 70 GeV", 16, 0, 3.2, false, "Min(#Pi - |#Delta#phi(jet,MET)|)", "dphijcoMed", false, false, false, 0.2);
684 <
674 > /*
675 >  make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll", false, false);
676 >  make_OFSF_plots("pfJetGoodNum40", "met[4]>100", 7, 3, 10, true, "#(jets)", "njets", false, false);
677 >  make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1", false, false);
678 >  make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2", false, false);
679 >  make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", false, false, 0.15);
680 >  make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", false, false, 0.15);
681 >  make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", false, false, 0.2);
682 >  make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", false, false, 0.2);
683 >  make_OFSF_plots("pfJetGoodPt[0]/pfJetGoodPt[1]", "met[4]>100", 20, 1, 10, true, "pt_{j}^{1}/pt_{j}^{2}", "jpt1pt2", false, false, 0.2);
684 >  make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", false, false, 0.0);
685 >  make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", false, false, 0.2);
686 >  make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", false, false, 0.2);
687 >  make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", false, false, 0.2);
688 >  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", false, false, 0.2);
689 >  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", false, false, 0.2);
690 >  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", false, false, 0.2);
691 >  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", false, false, 0.2);
692  
693    make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
687
694    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
695    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
696    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
# Line 706 | Line 712 | void do_kinematic_plots(string mcjzb, st
712    make_kin_plot("numVtx","",(int)(30.5-(-0.5)),-0.5,30.5,nolog,"N(Vtx)","numVtx",doPF);
713   //  make_kin_plot("jetpt[0]","",40,0,200,dolog,"leading jet p_{T} [GeV]","pfJetGoodPt_0",doPF);
714   //  make_kin_plot("jeteta[0]","",40,-5,5,nolog,"leading jet #eta","pfJetGoodEta_0",doPF);
715 +  */
716    make_kin_plot("pt","",50,0,500,dolog,"Z p_{T} [GeV]","Zpt",doPF);
717    make_kin_plot("pt1","",50,0,200,nolog,"p_{T} [GeV]","pt1",doPF);
718    make_kin_plot("pt2","",50,0,200,nolog,"p_{T} [GeV]","pt2",doPF);
# Line 730 | Line 737 | void do_kinematic_plots(string mcjzb, st
737    make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_ee_aboveJZB50",doPF,true);  
738    make_kin_plot("mll",jzbcut3.str(),(int)((mll_hi-mll_low)/5),mll_low,mll_hi,nolog,"m_{ll} [GeV]","mll_mm_aboveJZB50",doPF,true);  
739  
740 <  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",doPF,true);
740 >  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);
741 >  //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);
742 >  //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);
743  
744    make_special_obs_pred_mll_plot(datajzb,mcjzb,0);
745    make_special_obs_pred_mll_plot(datajzb,mcjzb,50);
# Line 742 | Line 751 | void do_kinematic_plots(string mcjzb, st
751  
752    make_JES_plot(cutmass&&cutOSSF&&basiccut,"_ossf");
753    make_JES_plot(cutmass&&cutOSOF&&basiccut,"_osof");
754 <  */
746 <  
754 >
755    string regioncut[4] =    {"mll>0&&","mll>20&&mll<70&&","mll>70&&mll<110&&","mll>110&&"};
756    string regionname[4] = {"global","lowmass","Zregion","highmass"};
757    bool StoreRatioPlots=false;
# Line 2599 | Line 2607 | void save_template(string mcjzb, string
2607    configfile<<"\n\n";
2608    configfile<<"luminosity="<<luminosity<<";\n";
2609    configfile<<"RestrictToMassPeak="<<RestrictToMassPeak<<";//defines the type of analysis we're running\n";
2610 +  configfile<<"UseSidebandsForcJZB="<<UseSidebandsForcJZB<<";//tells us whether to use the sidebands or not\n";
2611    
2612    configfile<<"\n\ncout << \"Configuration successfully loaded!\" << endl; \n \n } \n \n";
2613    
# Line 2747 | Line 2756 | void ttbar_sidebands_comparison(string m
2756    }
2757    
2758    float linepos=emuncertONPEAK;
2759 <  if(!PlottingSetup::RestrictToMassPeak&&PlottingSetup::UseSidebandsForcJZB) linepos=emuncertOFFPEAK;
2759 >  if(!PlottingSetup::RestrictToMassPeak) linepos=emuncertOFFPEAK;
2760    
2761    TLine *top = new TLine(binning[0],1.0+linepos,binning[binning.size()-1],1.0+linepos);
2762    TLine *center = new TLine(binning[0],1.0,binning[binning.size()-1],1.0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines