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.48 by buchmann, Wed Aug 15 09:18:07 2012 UTC vs.
Revision 1.49 by fronga, Wed Aug 15 11:46:28 2012 UTC

# Line 358 | Line 358 | void draw_ratio_plot(TH1* hdata, THStack
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) {
361 > float make_one_OFSF_plot(string variable, string addcut, string legendTitle, int nbins, float min, float max, float ymax, bool logscale,
362 >                        string xlabel, string filename, bool plotratio=true, bool loadlastminmax=false, float legendPosition=0.55) {
363  
364    TCut ibasiccut=basiccut;
365    bool draw_separation_lines=false;
366  
367  if(isPF) ibasiccut=basiccut&&"pfjzb[0]>-998";
368
367    if(addcut != "") ibasiccut = ibasiccut && addcut.c_str();
368  
369    TCut cutSF;
370    TCut cutOF;
371  
372 <  cutOF=cutOSOF&&cutnJets&&ibasiccut;
373 <  cutSF=cutOSSF&&cutnJets&&ibasiccut;
376 <
372 >  cutOF = cutOSOF&&cutnJets&&ibasiccut;
373 >  cutSF = cutOSSF&&cutnJets&&ibasiccut;
374  
375    TCanvas *ckin = new TCanvas("ckin","Kinematic Plots (in the making)",600,600);
376    ckin->SetLogy(logscale);
# Line 385 | Line 382 | void make_OFSF_plot(string variable, str
382    (signalsamples.collection)[idx].events->Project("signalhisto",variable.c_str(),cutSF);
383    signalhisto->Scale((signalsamples.collection)[idx].weight*luminosity);
384    signalhisto->SetLineColor((signalsamples.collection)[idx].samplecolor);
385 +  signalhisto->SetLineStyle(2);
386    datahistoSF->SetMarkerSize(DataMarkerSize);
387    datahistoOF->SetLineColor(kRed);
388  
389    if ( !logscale ) {
390      datahistoSF->SetMinimum(0); // Defaults
393    datahistoOF->SetMinimum(0); // Defaults
391    } else {
392      datahistoSF->SetMinimum(0.5);
396    datahistoOF->SetMinimum(0.5);
393    }
394 <  if (logscale) {
395 <    datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
396 <    datahistoOF->SetMaximum(5.3*datahistoSF->GetMaximum());
394 >  if (ymax<0) {
395 >    if ( logscale ) datahistoSF->SetMaximum(5.3*datahistoSF->GetMaximum());
396 >    else datahistoSF->SetMaximum(1.5*datahistoSF->GetMaximum());
397    } else {
398 <    datahistoSF->SetMaximum(2.0*datahistoSF->GetMaximum());
403 <    datahistoOF->SetMaximum(2.0*datahistoOF->GetMaximum());
398 >    datahistoSF->SetMaximum(ymax);
399    }
400  
401 +  float ymaxSet = datahistoSF->GetMaximum();
402 +
403    datahistoSF->GetXaxis()->SetTitle(xlabel.c_str());
404 <  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");
404 >  datahistoSF->GetYaxis()->SetTitle("Events");
405    datahistoSF->GetXaxis()->CenterTitle();
413  datahistoOF->GetXaxis()->CenterTitle();
414  signalhisto->GetXaxis()->CenterTitle();
406    datahistoSF->GetYaxis()->CenterTitle();
416  datahistoOF->GetYaxis()->CenterTitle();
417  signalhisto->GetYaxis()->CenterTitle();
407  
408 <  TLegend *mleg = new TLegend(0.2+legendPosition, 0.72, 0.55+legendPosition, 0.87, legendTitle.c_str());
409 <  mleg->SetFillColor(kWhite);
410 <  mleg->SetTextFont(42);
411 <  mleg->SetTextSize(0.048);
412 <  mleg->SetLineWidth(0);
413 <  mleg->SetBorderSize(0);
414 <  mleg->AddEntry(datahistoSF, "S. Flavor", "PL");
426 <  mleg->AddEntry(datahistoOF, "O. Flavor", "L");
408 >  TLegend *mleg = make_legend(legendTitle.c_str(),legendPosition,0.7,false,legendPosition+0.2);
409 >  mleg->AddEntry(datahistoSF, "Same-flavor", "PL");
410 >  if (datahistoOF->Integral()>0) {
411 >    mleg->AddEntry(datahistoOF, "Opposite-flavor", "L");
412 >  } else {
413 >    mleg->AddEntry((TObject*)0, "", "");
414 >  }
415    mleg->AddEntry(signalhisto, "LM3", "L");
416  
417    datahistoSF->Draw("E1");
418 <  datahistoOF->Draw("HIST,SAMES");
418 >  if (datahistoOF->Integral()>0) datahistoOF->Draw("HIST,SAMES");
419    signalhisto->Draw("HIST,SAMES");
420    mleg->Draw();
421    DrawPrelim();
422 <  CompleteSave(ckin, "./SFOF/" + filename);
422 >  CompleteSave(ckin, "SFOF/" + filename);
423  
424    datahistoSF->Delete();
425    datahistoOF->Delete();
# Line 439 | Line 427 | void make_OFSF_plot(string variable, str
427    delete mleg;
428    delete ckin;
429  
430 +  return ymaxSet;
431 +
432   }
433  
434 + void make_OFSF_plots(string variable, string addcut, int nbins, float min, float max, bool logscale, string xlabel, string filename,
435 +                bool plotratio=true, bool loadlastminmax=false, float legendPosition=0.55) {
436 +
437 +  string mllcuts[] = { "mll>20","mll>20&&mll<70", "mll>70&&mll<110", "mll>110" };
438 +  string mllcutname[] = { "m_{ll} > 20 GeV", "20 < m_{ll} < 70 GeV", "70 < m_{ll} < 110 GeV", "m_{ll} > 110 GeV" };
439 +  string plotname[] = {"_all","_low","_peak","_high"};
440 +  float ymax;
441 +  for ( int i=0; i<4; ++i ) {
442 +    if ( addcut != "" ) mllcuts[i] += "&&"+addcut;
443 +    if ( i==0 ) {
444 +      ymax = make_one_OFSF_plot(variable, mllcuts[i],            mllcutname[i], nbins, min, max, -1, logscale, xlabel,
445 +                         filename+plotname[i], plotratio, loadlastminmax, legendPosition );
446 +    } else {
447 +      make_one_OFSF_plot(variable, mllcuts[i],            mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
448 +                         filename+plotname[i], plotratio, loadlastminmax, legendPosition );
449 +    }
450 +    make_one_OFSF_plot(variable, "id1==1&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
451 +                       filename+plotname[i]+"_mm", plotratio, loadlastminmax, legendPosition );
452 +    make_one_OFSF_plot(variable, "id1==0&&id1==id2&&"+mllcuts[i], mllcutname[i], nbins, min, max, ymax, logscale, xlabel,
453 +                       filename+plotname[i]+"_ee", plotratio, loadlastminmax, legendPosition );
454 +  }
455 +
456 + }
457  
458  
459   float lastrange_min=0;
# Line 660 | Line 673 | void do_kinematic_plots(string mcjzb, st
673          mll_hi=300;
674    }
675  
676 <  /*
677 <  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);
678 <  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);
679 <  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);
680 <  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);
681 <  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);
682 <  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);
683 <  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);
684 <  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);
685 <  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);
686 <  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);
687 <  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);
688 <  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);
689 <  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);
690 <  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);
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", "20 GeV < mll < 40 GeV", 16, 0, 3.2, false, "Min(|#Delta#phi(jet,MET)|)", "dphijcLow", false, false, false, 0.2);
692 <  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 <
676 >  make_OFSF_plots("mll", "met[4]>100", 60, 20., 320., false, "m_{ll}", "mll", false, false);
677 >  make_OFSF_plots("pfJetGoodNum40", "met[4]>100", 7, 3, 10, true, "#(jets)", "njets", false, false);
678 >  make_OFSF_plots("pt1",  "met[4]>100", 30, 0., 300., true, "p_{T,1}", "pt1", false, false);
679 >  make_OFSF_plots("pt2",  "met[4]>100", 22, 0., 220., true, "p_{T,2}", "pt2", false, false);
680 >  make_OFSF_plots("eta1", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{1}", "eta1", false, false, 0.15);
681 >  make_OFSF_plots("eta2", "met[4]>100", 10, -2.5, 2.5, false, "#eta_{2}", "eta2", false, false, 0.15);
682 >  make_OFSF_plots("phi1", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{1}", "phi1", false, false, 0.2);
683 >  make_OFSF_plots("phi2", "met[4]>100", 10, -TMath::Pi(), TMath::Pi(), false, "#phi_{2}", "phi2", false, false, 0.2);
684 >  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);
685 >  make_OFSF_plots("TMath::Abs(pfJetDphiMet[0])", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(jet1,MET)|", "dphij1met", false, false, 0.0);
686 >  make_OFSF_plots("TMath::Abs(dphi)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,l2)|", "dphi", false, false, 0.2);
687 >  make_OFSF_plots("TMath::Abs(dphiMet1)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l1,MET)|", "dphiMet1", false, false, 0.2);
688 >  make_OFSF_plots("TMath::Abs(dphiMet2)", "met[4]>100", 16, 0, 3.2, false, "|#Delta#phi(l2,MET)|", "dphiMet2", false, false, 0.2);
689 >  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);
690 >  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);
691 >  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);
692 >  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);
693  
694    make_kin_plot("met[4]","",70,0,350,dolog,"MET [GeV]","met",doPF,true);
687
695    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll",doPF,true);
696    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_osof",doPF,true,true);
697    make_kin_plot("mll","",(int)((mll_hi-mll_low)/5),mll_low,mll_hi,dolog,"m_{ll} [GeV]","mll_ee",doPF,true);
# 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");
745  */
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"};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines