ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/UHHAnalysis/SFramePlotter/SPlotter.cxx
(Generate patch)

Comparing UserCode/UHHAnalysis/SFramePlotter/SPlotter.cxx (file contents):
Revision 1.2 by peiffer, Mon Nov 12 13:26:25 2012 UTC vs.
Revision 1.3 by rkogler, Mon Nov 12 14:32:12 2012 UTC

# Line 20 | Line 20 | SPlotter::SPlotter()
20    m_ps_name = "default.ps";
21  
22    m_pad1 = NULL;
23  m_rp1  = NULL;
23    m_pad2 = NULL;
24 +
25 +  m_rp1_top = NULL;
26 +  m_rp1  = NULL;
27 +  m_rp2_top = NULL;
28    m_rp2  = NULL;
29  
30    m_page       = 0;
# Line 291 | Line 294 | void SPlotter::SetupCanvas()
294                                                  //     x1            x2
295  
296  
297 <  if (bPlotRatio){
297 >  //  if (bPlotRatio){
298        
299 <    m_pad1 = new TPad("pad1", "Control Plots 1", x1, y5, x2, y6);
299 >    m_rp1_top = new TPad("pad1", "Control Plots 1", x1, y5, x2, y6);
300      m_rp1 = new TPad("rp1", "Ratio1", x1, y4, x2, y5);
301      
302 <    m_pad2 = new TPad("pad2", "Control Plots 2", x1, y2, x2, y3);
302 >    m_rp2_top = new TPad("pad2", "Control Plots 2", x1, y2, x2, y3);
303      m_rp2 = new TPad("rp2", "Ratio2", x1, y1, x2, y2);
304    
305 <  } else {
305 >    //  } else {
306  
307      m_pad1 = new TPad("pad1", "Control Plots 1", x1, y4, x2, y6);
308      m_pad2 = new TPad("pad2", "Control Plots 2", x1, y1, x2, y3);
309  
310 <  }
310 >    //  }
311  
312    // set margins for portrait mode
313    if (bPortrait){
314  
315      m_pad1->SetTopMargin(0.05); m_pad1->SetBottomMargin(0.13);  m_pad1->SetLeftMargin(0.19); m_pad1->SetRightMargin(0.05);
316      m_pad2->SetTopMargin(0.05); m_pad2->SetBottomMargin(0.13);  m_pad2->SetLeftMargin(0.19); m_pad2->SetRightMargin(0.05);
317 <    if (bPlotRatio){
318 <      m_pad1->SetTopMargin(0.02); m_pad1->SetBottomMargin(0.0);  m_pad1->SetLeftMargin(0.19); m_pad1->SetRightMargin(0.05);
319 <      m_pad2->SetTopMargin(0.02); m_pad2->SetBottomMargin(0.0);  m_pad2->SetLeftMargin(0.19); m_pad2->SetRightMargin(0.05);
317 >
318 >    //if (bPlotRatio){
319 >      m_rp1_top->SetTopMargin(0.02); m_rp1_top->SetBottomMargin(0.0);  m_rp1_top->SetLeftMargin(0.19); m_rp1_top->SetRightMargin(0.05);
320 >      m_rp2_top->SetTopMargin(0.02); m_rp2_top->SetBottomMargin(0.0);  m_rp2_top->SetLeftMargin(0.19); m_rp2_top->SetRightMargin(0.05);
321        m_rp1->SetTopMargin(0.0);    m_rp1->SetBottomMargin(0.35);  m_rp1->SetLeftMargin(0.19);  m_rp1->SetRightMargin(0.05);
322        m_rp2->SetTopMargin(0.0);    m_rp2->SetBottomMargin(0.35);  m_rp2->SetLeftMargin(0.19);  m_rp2->SetRightMargin(0.05);
323 <    }
323 >      //}
324              
325    // margins for landscape
326    } else {
327  
328 <    m_pad1->SetTopMargin(0.02); m_pad1->SetBottomMargin(0.0);  m_pad1->SetLeftMargin(0.13); m_pad1->SetRightMargin(0.05);        
329 <    m_pad2->SetTopMargin(0.02); m_pad2->SetBottomMargin(0.0);  m_pad2->SetLeftMargin(0.13); m_pad2->SetRightMargin(0.05);
328 >    m_rp1_top->SetTopMargin(0.02); m_rp1_top->SetBottomMargin(0.0);  m_rp1_top->SetLeftMargin(0.13); m_rp1_top->SetRightMargin(0.05);        
329 >    m_rp2_top->SetTopMargin(0.02); m_rp2_top->SetBottomMargin(0.0);  m_rp2_top->SetLeftMargin(0.13); m_rp2_top->SetRightMargin(0.05);
330      
331      if (bPlotRatio){
332        m_rp1->SetTopMargin(0.0);    m_rp1->SetBottomMargin(0.35);  m_rp1->SetLeftMargin(0.13);  m_rp1->SetRightMargin(0.05);
# Line 333 | Line 337 | void SPlotter::SetupCanvas()
337  
338    
339    if (debug){
340 <    m_pad1->SetFillColor(kYellow);
341 <    m_pad2->SetFillColor(kOrange);
340 >    m_rp1_top->SetFillColor(kYellow);
341 >    m_rp2_top->SetFillColor(kOrange);
342      if (bPlotRatio){
343        m_rp1->SetFillColor(kGray);
344        m_rp2->SetFillColor(kGray);
345      }
346    }
347  
348 <  m_pad1->Draw();
348 >  m_pad1->Draw();
349    m_pad2->Draw();
350 +
351 +  m_rp1_top->Draw();
352 +  m_rp2_top->Draw();
353    
354    if (bPlotRatio){
355      m_rp1->Draw();
# Line 458 | Line 465 | void SPlotter::ProcessAndPlot(std::vecto
465      // cosmetics
466      DoCosmetics(hists);
467  
468 <    // do what we set out to do: plot!
469 <    PlotHists(hists, ipad);
470 <    // draw a legend    
471 <    if (bleg){
472 <      DrawLegend(GetHistsAtIndex(histarr, i));
473 <      if (!bDrawLegend) bleg = false;
474 <    }
475 <    // draw lumi information
476 <    if (bDrawLumi) DrawLumi();
477 <    // draw the ratio
478 <    if (bPlotRatio) PlotRatios(hists, ipad);
468 >    // ---------- do what we set out to do: plot! ----------------
469 >
470 >    if (hists[0]->IsYieldPlot()){  // special treatment for lumi yield plot
471 >    
472 >      PlotLumiYield(hists[0], ipad);
473 >
474 >    } else { // usual plots
475 >
476 >      PlotHists(hists, ipad);
477 >      // draw a legend    
478 >      if (bleg){
479 >        DrawLegend(GetHistsAtIndex(histarr, i));
480 >        if (!bDrawLegend) bleg = false;
481 >      }
482 >      // draw lumi information
483 >      if (bDrawLumi) DrawLumi();
484 >      // draw the ratio
485 >      if (bPlotRatio) PlotRatios(hists, ipad);
486 >    
487 >    }
488  
489  
490      ++iplot;
# Line 481 | Line 497 | void SPlotter::ProcessAndPlot(std::vecto
497    
498   }
499  
500 < void SPlotter::PlotHists(vector<SHist*> hists, int ipad)
500 > void SPlotter::PlotLumiYield(SHist* hist, int ipad)
501   {
502 <  // plot all histograms in the array
502 >  // plot the lumi yield histogram
503  
504    if (ipad==1) m_pad1->cd();
505    if (ipad==2) m_pad2->cd();
506  
507 +  hist->Draw();
508 +  return;
509 +
510 + }
511 +
512 +
513 + void SPlotter::PlotHists(vector<SHist*> hists, int ipad)
514 + {
515 +  // plot all histograms in the array
516 +
517 +  if (ipad==1){
518 +    if (bPlotRatio) m_rp1_top->cd();
519 +    else m_pad1->cd();
520 +  }
521 +  if (ipad==2){
522 +    if (bPlotRatio) m_rp2_top->cd();
523 +    else m_pad2->cd();
524 +  }
525 +
526    bool isok = SetMinMax(hists);
527    if (isok) SetLogAxes(hists);
528  
# Line 628 | Line 663 | void SPlotter::DrawLegend(vector<SHist*>
663    float yfrac = 0.06;
664    if (!bPlotRatio) yfrac = 0.05;
665    float top = 0.92;
666 +  if (!bPlotRatio && bDrawLumi) top = 0.86;
667    float ysize = yfrac*narr;
668 <  float xleft = 0.65;
668 >  float xleft = 0.7;
669    float xright = 0.92;
670    if (!bPortrait){
671      top = 0.99;
# Line 692 | Line 728 | void SPlotter::DrawLegend(vector<SHist*>
728  
729   void SPlotter::DrawLumi()
730   {
731 <  float lumi = 5.2;
696 <  TString infotext = TString::Format("CMS Preliminary, %3.1f fb^{-1} at #sqrt{s} = 8 TeV", lumi);
731 >  TString infotext = TString::Format("CMS Preliminary, %3.1f fb^{-1} at #sqrt{s} = 8 TeV", m_lumi);
732    TLatex *text1 = new TLatex(3.5, 24, infotext);
733    text1->SetNDC();
734    text1->SetTextAlign(13);
735    text1->SetX(0.22);
701  text1->SetY(0.94);
736    text1->SetTextFont(42);
737 <  text1->SetTextSize(0.06);
737 >  if (bPlotRatio){
738 >    text1->SetTextSize(0.06);
739 >    text1->SetY(0.94);
740 >  } else {
741 >    text1->SetTextSize(0.05);
742 >    text1->SetY(0.92);
743 >  }
744    text1->Draw();
745    
706  //  TLatex *text2 = new TLatex(3.5,23,"5.2 fb^{-1} at #sqrt{s} = 8 TeV");
707  //text2->SetNDC();
708  //text2->SetTextAlign(13);
709  //text2->SetX(0.22);
710  //text2->SetY(0.89);
711  //text2->SetTextFont(42);
712  //text2->SetTextSizePixels(40);
713  //text2->Draw();
746   }
747  
748   void SPlotter::DoCosmetics(vector<SHist*> hists)
# Line 724 | Line 756 | void SPlotter::DoCosmetics(vector<SHist*
756      GeneralCosmetics(sh->GetHist());
757      if (bPortrait) PortraitCosmetics(sh->GetHist());
758      if (!bPortrait) LandscapeCosmetics(sh->GetHist());
759 +    if (sh->IsYieldPlot()) YieldCosmetics(sh->GetHist());
760    }
761  
762   }
# Line 865 | Line 898 | vector<SHist*> SPlotter::GetPlottableHis
898    TString process = hist->GetProcessName();
899    if (process.Contains("data",TString::kIgnoreCase)
900        && name.Contains("_perlumibin", TString::kIgnoreCase)){
901 +    hist->SetIsYieldPlot(true);
902      hists.push_back(hist);
903      return hists;
904    }
# Line 993 | Line 1027 | void SPlotter::PortraitCosmetics(TH1* hi
1027    
1028   }
1029  
1030 + void SPlotter::YieldCosmetics(TH1* hist)
1031 + {
1032 +  // cosmetics for the lumi yield histogram
1033 +    hist->GetXaxis()->SetLabelSize(0.05);
1034 +    hist->GetXaxis()->SetLabelOffset(0.008);
1035 +    hist->GetXaxis()->SetTickLength(0.03);
1036 +    hist->GetXaxis()->SetTitleSize(0.05);
1037 +    hist->GetXaxis()->SetTitleOffset(1.2);
1038 +    
1039 +    hist->GetYaxis()->SetTitleOffset(1.2);
1040 +    hist->GetYaxis()->SetTitleSize(0.06);
1041 +    hist->GetYaxis()->SetLabelSize(0.045);
1042 +    hist->GetYaxis()->SetTickLength(0.02);
1043 +    hist->GetYaxis()->SetLabelOffset(0.011);
1044 +
1045 +    hist->GetXaxis()->SetTitle("time (constant luminosity)");
1046 +    hist->GetYaxis()->SetTitle("events per luminosity");
1047 +  
1048 + }
1049 +
1050   void SPlotter::LandscapeCosmetics(TH1* hist)
1051   {
1052  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines