CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Validation/RecoParticleFlow/src/NicePlot.cc

Go to the documentation of this file.
00001 #include "Validation/RecoParticleFlow/interface/NicePlot.h"
00002 
00003 #include <TROOT.h>
00004 #include <TStyle.h>
00005 #include <string>
00006 
00007 
00008 using namespace std; 
00009 
00010 
00011 Styles::Styles() {
00012 
00013   gROOT->SetStyle("Plain");
00014   gStyle->SetPalette(1);
00015   gStyle->SetHistMinimumZero(kTRUE);
00016 
00017   s1 = new Style(); 
00018 
00019   s1->SetLineWidth(2);   
00020   s1->SetLineColor(1);   
00021 
00022   s2 = new Style(); 
00023 
00024   s2->SetLineWidth(2);   
00025   s2->SetLineColor(4);   
00026 
00027   sg1 = new Style();
00028 
00029   sg1->SetMarkerColor(4);
00030   sg1->SetLineColor(4);
00031   sg1->SetLineWidth(2);  
00032   sg1->SetMarkerStyle(21);
00033 
00034   sback =  new Style();
00035   sback->SetFillStyle(1001);  
00036   sback->SetFillColor(5);  
00037  
00038   spred = new Style();
00039   spred->SetLineColor(2); 
00040   spred->SetLineWidth(2);  
00041   spred->SetFillStyle(1001); 
00042   spred->SetFillColor(kRed-8); 
00043 
00044   spblue = new Style();
00045   spblue->SetLineColor(4); 
00046   spblue->SetLineWidth(2);
00047 
00048   sgr1 = new Style();
00049   sgr1->SetLineWidth(1);
00050   sgr1->SetLineColor(1);
00051 
00052   sgr2 = new Style(); 
00053   sgr2->SetLineWidth(1);
00054   sgr2->SetLineColor(1);
00055 
00056 }
00057 
00058 void Styles::FormatHisto( TH1* h, const Style* s ) {
00059   //  h->SetStats(0);
00060   h->SetTitle("CMS Preliminary");
00061 
00062   h->GetYaxis()->SetTitleSize(0.06);
00063   h->GetYaxis()->SetTitleOffset(1.2);
00064   h->GetXaxis()->SetTitleSize(0.06);
00065   h->GetYaxis()->SetLabelSize(0.045);
00066   h->GetXaxis()->SetLabelSize(0.045);
00067 
00068   h->SetLineWidth( s->GetLineWidth() );
00069   h->SetLineColor( s->GetLineColor() );
00070   h->SetFillStyle( s->GetFillStyle() );
00071   h->SetFillColor( s->GetFillColor() );
00072 }
00073 
00074 void Styles::FormatPad( TPad* pad, bool grid, bool logx, bool logy) {
00075   
00076   
00077   pad->SetGridx(grid);
00078   pad->SetGridy(grid);
00079 
00080   if (logx) pad->SetLogx();
00081   if (logy) pad->SetLogy();
00082 
00083   pad->SetBottomMargin(0.14);
00084   pad->SetLeftMargin(0.15);
00085   pad->SetRightMargin(0.05);
00086   pad->Modified();
00087   pad->Update();
00088 }
00089 
00090 
00091 void Styles::SavePlot(const char* name, const char* dir) {
00092   string eps = dir;
00093   eps += "/";
00094   eps += name;
00095   eps += ".eps";
00096   gPad->SaveAs( eps.c_str() );
00097 
00098   string png = dir;
00099   png += "/";
00100   png += name;
00101   png += ".png";
00102   gPad->SaveAs( png.c_str() );
00103 
00104 }