Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:33:16

0001 #include "Validation/RecoParticleFlow/interface/NicePlot.h"
0002 
0003 #include <TROOT.h>
0004 #include <TStyle.h>
0005 #include <string>
0006 
0007 using namespace std;
0008 
0009 Styles::Styles() {
0010   gROOT->SetStyle("Plain");
0011   gStyle->SetPalette(1);
0012   gStyle->SetHistMinimumZero(kTRUE);
0013 
0014   s1 = new Style();
0015 
0016   s1->SetLineWidth(2);
0017   s1->SetLineColor(1);
0018 
0019   s2 = new Style();
0020 
0021   s2->SetLineWidth(2);
0022   s2->SetLineColor(4);
0023 
0024   sg1 = new Style();
0025 
0026   sg1->SetMarkerColor(4);
0027   sg1->SetLineColor(4);
0028   sg1->SetLineWidth(2);
0029   sg1->SetMarkerStyle(21);
0030 
0031   sback = new Style();
0032   sback->SetFillStyle(1001);
0033   sback->SetFillColor(5);
0034 
0035   spred = new Style();
0036   spred->SetLineColor(2);
0037   spred->SetLineWidth(2);
0038   spred->SetFillStyle(1001);
0039   spred->SetFillColor(kRed - 8);
0040 
0041   spblue = new Style();
0042   spblue->SetLineColor(4);
0043   spblue->SetLineWidth(2);
0044 
0045   sgr1 = new Style();
0046   sgr1->SetLineWidth(1);
0047   sgr1->SetLineColor(1);
0048 
0049   sgr2 = new Style();
0050   sgr2->SetLineWidth(1);
0051   sgr2->SetLineColor(1);
0052 }
0053 
0054 void Styles::FormatHisto(TH1 *h, const Style *s) {
0055   //  h->SetStats(0);
0056   h->SetTitle("CMS Preliminary");
0057 
0058   h->GetYaxis()->SetTitleSize(0.06);
0059   h->GetYaxis()->SetTitleOffset(1.2);
0060   h->GetXaxis()->SetTitleSize(0.06);
0061   h->GetYaxis()->SetLabelSize(0.045);
0062   h->GetXaxis()->SetLabelSize(0.045);
0063 
0064   h->SetLineWidth(s->GetLineWidth());
0065   h->SetLineColor(s->GetLineColor());
0066   h->SetFillStyle(s->GetFillStyle());
0067   h->SetFillColor(s->GetFillColor());
0068 }
0069 
0070 void Styles::FormatPad(TPad *pad, bool grid, bool logx, bool logy) {
0071   pad->SetGridx(grid);
0072   pad->SetGridy(grid);
0073 
0074   if (logx)
0075     pad->SetLogx();
0076   if (logy)
0077     pad->SetLogy();
0078 
0079   pad->SetBottomMargin(0.14);
0080   pad->SetLeftMargin(0.15);
0081   pad->SetRightMargin(0.05);
0082   pad->Modified();
0083   pad->Update();
0084 }
0085 
0086 void Styles::SavePlot(const char *name, const char *dir) {
0087   string eps = dir;
0088   eps += "/";
0089   eps += name;
0090   eps += ".eps";
0091   gPad->SaveAs(eps.c_str());
0092 
0093   string png = dir;
0094   png += "/";
0095   png += name;
0096   png += ".png";
0097   gPad->SaveAs(png.c_str());
0098 }