Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:59:45

0001 //
0002 // TDR style macro for plots in ROOT
0003 // .L tdrstyle.C
0004 // setTDRStyle()
0005 //
0006 #include "TStyle.h"
0007 #include "TPad.h"
0008 
0009 /*
0010 // tdrGrid: Turns the grid lines on (true) or off (false)
0011 
0012 void tdrGrid(bool gridOn) {
0013   tdrStyle->SetPadGridX(gridOn);
0014   tdrStyle->SetPadGridY(gridOn);
0015 }
0016 */
0017 
0018 // fixOverlay: Redraws the axis
0019 
0020 void fixOverlay() {
0021   gPad->RedrawAxis();
0022 }
0023 
0024 void setTDRStyle() {
0025 //   TStyle *tdrStyle = new TStyle("tdrStyle","Style for P-TDR");
0026 
0027 // For the canvas:
0028   gStyle->SetCanvasBorderMode(0);
0029   gStyle->SetCanvasColor(kWhite);
0030   gStyle->SetCanvasDefH(600); //Height of canvas
0031   gStyle->SetCanvasDefW(600); //Width of canvas
0032   gStyle->SetCanvasDefX(0);   //POsition on screen
0033   gStyle->SetCanvasDefY(0);
0034 
0035 // For the Pad:
0036   gStyle->SetPadBorderMode(0);
0037   // gStyle->SetPadBorderSize(Width_t size = 1);
0038   gStyle->SetPadColor(kWhite);
0039   gStyle->SetPadGridX(false);
0040   gStyle->SetPadGridY(false);
0041   gStyle->SetGridColor(0);
0042   gStyle->SetGridStyle(3);
0043   gStyle->SetGridWidth(1);
0044 
0045 // For the frame:
0046   gStyle->SetFrameBorderMode(0);
0047   gStyle->SetFrameBorderSize(1);
0048   gStyle->SetFrameFillColor(0);
0049   gStyle->SetFrameFillStyle(0);
0050   gStyle->SetFrameLineColor(1);
0051   gStyle->SetFrameLineStyle(1);
0052   gStyle->SetFrameLineWidth(1);
0053 
0054 // For the histo:
0055   // gStyle->SetHistFillColor(1);
0056   // gStyle->SetHistFillStyle(0);
0057   gStyle->SetHistLineColor(1);
0058   gStyle->SetHistLineStyle(0);
0059   gStyle->SetHistLineWidth(1);
0060   // gStyle->SetLegoInnerR(Float_t rad = 0.5);
0061   // gStyle->SetNumberContours(Int_t number = 20);
0062 
0063   gStyle->SetEndErrorSize(2);
0064   //gStyle->SetErrorMarker(20);
0065   gStyle->SetErrorX(0.);
0066   
0067   gStyle->SetMarkerStyle(20);
0068 
0069 //For the fit/function:
0070   gStyle->SetOptFit(1);
0071   gStyle->SetFitFormat("5.4g");
0072   gStyle->SetFuncColor(2);
0073   gStyle->SetFuncStyle(1);
0074   gStyle->SetFuncWidth(1);
0075 
0076 //For the date:
0077   gStyle->SetOptDate(0);
0078   // gStyle->SetDateX(Float_t x = 0.01);
0079   // gStyle->SetDateY(Float_t y = 0.01);
0080 
0081 // For the statistics box:
0082   gStyle->SetOptFile(0);
0083   //gStyle->SetOptStat(0);
0084   gStyle->SetOptStat("mr");
0085   gStyle->SetStatColor(kWhite);
0086   gStyle->SetStatFont(42);
0087   gStyle->SetStatFontSize(0.04);///---> gStyle->SetStatFontSize(0.025);
0088   gStyle->SetStatTextColor(1);
0089   gStyle->SetStatFormat("6.4g");
0090   gStyle->SetStatBorderSize(1);
0091   gStyle->SetStatH(0.1);
0092   gStyle->SetStatW(0.2);///---> gStyle->SetStatW(0.15);
0093 
0094   // gStyle->SetStatStyle(Style_t style = 1001);
0095   // gStyle->SetStatX(Float_t x = 0);
0096   // gStyle->SetStatY(Float_t y = 0);
0097 
0098 // Margins:
0099   gStyle->SetPadTopMargin(0.05);
0100   gStyle->SetPadBottomMargin(0.13);
0101   gStyle->SetPadLeftMargin(0.16);
0102   gStyle->SetPadRightMargin(0.02);
0103 
0104 // For the Global title:
0105 
0106   gStyle->SetOptTitle(0);
0107   gStyle->SetTitleFont(42);
0108   gStyle->SetTitleColor(1);
0109   gStyle->SetTitleTextColor(1);
0110   gStyle->SetTitleFillColor(10);
0111   gStyle->SetTitleFontSize(0.05);
0112   // gStyle->SetTitleH(0); // Set the height of the title box
0113   // gStyle->SetTitleW(0); // Set the width of the title box
0114   // gStyle->SetTitleX(0); // Set the position of the title box
0115   // gStyle->SetTitleY(0.985); // Set the position of the title box
0116   // gStyle->SetTitleStyle(Style_t style = 1001);
0117   // gStyle->SetTitleBorderSize(2);
0118 
0119 // For the axis titles:
0120 
0121   gStyle->SetTitleColor(1, "XYZ");
0122   gStyle->SetTitleFont(42, "XYZ");
0123   gStyle->SetTitleSize(0.06, "XYZ");
0124   // gStyle->SetTitleXSize(Float_t size = 0.02); // Another way to set the size?
0125   // gStyle->SetTitleYSize(Float_t size = 0.02);
0126   gStyle->SetTitleXOffset(0.9);
0127   gStyle->SetTitleYOffset(1.25);
0128   // gStyle->SetTitleOffset(1.1, "Y"); // Another way to set the Offset
0129 
0130 // For the axis labels:
0131 
0132   gStyle->SetLabelColor(1, "XYZ");
0133   gStyle->SetLabelFont(42, "XYZ");
0134   gStyle->SetLabelOffset(0.007, "XYZ");
0135   gStyle->SetLabelSize(0.05, "XYZ");
0136 
0137 // For the axis:
0138 
0139   gStyle->SetAxisColor(1, "XYZ");
0140   gStyle->SetStripDecimals(kTRUE);
0141   gStyle->SetTickLength(0.03, "XYZ");
0142   gStyle->SetNdivisions(510, "XYZ");
0143   gStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame
0144   gStyle->SetPadTickY(1);
0145 
0146 // Change for log plots:
0147   gStyle->SetOptLogx(0);
0148   gStyle->SetOptLogy(0);
0149   gStyle->SetOptLogz(0);
0150 
0151 // Postscript options:
0152   gStyle->SetPaperSize(20.,20.);
0153   // gStyle->SetLineScalePS(Float_t scale = 3);
0154   // gStyle->SetLineStyleString(Int_t i, const char* text);
0155   // gStyle->SetHeaderPS(const char* header);
0156   // gStyle->SetTitlePS(const char* pstitle);
0157 
0158   // gStyle->SetBarOffset(Float_t baroff = 0.5);
0159   // gStyle->SetBarWidth(Float_t barwidth = 0.5);
0160   // gStyle->SetPaintTextFormat(const char* format = "g");
0161   // gStyle->SetPalette(Int_t ncolors = 0, Int_t* colors = 0);
0162   // gStyle->SetTimeOffset(Double_t toffset);
0163   // gStyle->SetHistMinimumZero(kTRUE);
0164 
0165 //   gStyle->cd();
0166 
0167   gROOT->ForceStyle();
0168 
0169 }