Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:32:02

0001 #include "TStyle.h"
0002 #include "TROOT.h"
0003 #include "TLatex.h"
0004 
0005 // tdrGrid: Turns the grid lines on (true) or off (false)

0006 
0007 void tdrGrid(bool gridOn) {
0008   TStyle *tdrStyle = (TStyle*)gROOT->FindObject("tdrStyle"); assert(tdrStyle);
0009   tdrStyle->SetPadGridX(gridOn);
0010   tdrStyle->SetPadGridY(gridOn);
0011 }
0012 
0013 // fixOverlay: Redraws the axis

0014 void fixOverlay() {
0015   gPad->RedrawAxis();
0016 }
0017 
0018 void setTDRStyle() {
0019   TStyle *tdrStyle = new TStyle("tdrStyle","Style for P-TDR");
0020 
0021 // For the canvas:

0022   tdrStyle->SetCanvasBorderMode(0);
0023   tdrStyle->SetCanvasColor(kWhite);
0024   tdrStyle->SetCanvasDefH(600); //Height of canvas

0025   tdrStyle->SetCanvasDefW(600); //Width of canvas

0026   tdrStyle->SetCanvasDefX(0);   //POsition on screen

0027   tdrStyle->SetCanvasDefY(0);
0028 
0029 // For the Pad:

0030   tdrStyle->SetPadBorderMode(0);
0031   // tdrStyle->SetPadBorderSize(Width_t size = 1);

0032   tdrStyle->SetPadColor(kWhite);
0033   tdrStyle->SetPadGridX(false);
0034   tdrStyle->SetPadGridY(false);
0035   tdrStyle->SetGridColor(0);
0036   tdrStyle->SetGridStyle(3);
0037   tdrStyle->SetGridWidth(1);
0038 
0039 // For the frame:

0040   tdrStyle->SetFrameBorderMode(0);
0041   tdrStyle->SetFrameBorderSize(1);
0042  tdrStyle->SetFrameFillColor(0);
0043   tdrStyle->SetFrameFillStyle(0);
0044   tdrStyle->SetFrameLineColor(1);
0045   tdrStyle->SetFrameLineStyle(1);
0046   tdrStyle->SetFrameLineWidth(1);
0047 
0048 // For the histo:

0049   // tdrStyle->SetHistFillColor(1);

0050   // tdrStyle->SetHistFillStyle(0);

0051   tdrStyle->SetHistLineColor(1);
0052   tdrStyle->SetHistLineStyle(0);
0053   tdrStyle->SetHistLineWidth(1);
0054   // tdrStyle->SetLegoInnerR(Float_t rad = 0.5);

0055   // tdrStyle->SetNumberContours(Int_t number = 20);

0056 
0057   tdrStyle->SetEndErrorSize(2);
0058 //  tdrStyle->SetErrorMarker(20);

0059   tdrStyle->SetErrorX(0.);
0060   
0061   tdrStyle->SetMarkerStyle(20);
0062 
0063 //For the fit/function:

0064   tdrStyle->SetOptFit(1);
0065   tdrStyle->SetFitFormat("5.4g");
0066   tdrStyle->SetFuncColor(2);
0067   tdrStyle->SetFuncStyle(1);
0068   tdrStyle->SetFuncWidth(1);
0069 
0070 //For the date:

0071   tdrStyle->SetOptDate(0);
0072   // tdrStyle->SetDateX(Float_t x = 0.01);

0073   // tdrStyle->SetDateY(Float_t y = 0.01);

0074 
0075 // For the statistics box:

0076   tdrStyle->SetOptFile(0);
0077   tdrStyle->SetOptStat(000001111); // To display the mean and RMS:   SetOptStat("mr");

0078   tdrStyle->SetStatColor(kWhite);
0079   tdrStyle->SetStatFont(42);
0080   tdrStyle->SetStatFontSize(0.025);
0081   tdrStyle->SetStatTextColor(1);
0082   tdrStyle->SetStatFormat("6.4g");
0083   tdrStyle->SetStatBorderSize(1);
0084   tdrStyle->SetStatH(0.1);
0085   tdrStyle->SetStatW(0.15);
0086   // tdrStyle->SetStatStyle(Style_t style = 1001);

0087   // tdrStyle->SetStatX(Float_t x = 0);

0088   // tdrStyle->SetStatY(Float_t y = 0);

0089 
0090 // Margins:

0091   tdrStyle->SetPadTopMargin(0.10);
0092   tdrStyle->SetPadBottomMargin(0.15);//0.13);

0093   tdrStyle->SetPadLeftMargin(0.15);//0.16);

0094   tdrStyle->SetPadRightMargin(0.13);//0.02);

0095 
0096 // For the Global title:

0097 
0098   tdrStyle->SetOptTitle(1);
0099   tdrStyle->SetTitleFont(42);
0100   tdrStyle->SetTitleColor(1);
0101   tdrStyle->SetTitleTextColor(1);
0102   tdrStyle->SetTitleFillColor(10);
0103   tdrStyle->SetTitleFontSize(0.05);
0104   // tdrStyle->SetTitleH(0); // Set the height of the title box

0105   // tdrStyle->SetTitleW(0); // Set the width of the title box

0106   tdrStyle->SetTitleX(.15); // Set the position of the title box

0107   // tdrStyle->SetTitleY(0.985); // Set the position of the title box

0108   // tdrStyle->SetTitleStyle(Style_t style = 1001);

0109   tdrStyle->SetTitleBorderSize(0);
0110 
0111 // For the axis titles:

0112 
0113   tdrStyle->SetTitleColor(1, "XYZ");
0114   tdrStyle->SetTitleFont(42, "XYZ");
0115   tdrStyle->SetTitleSize(0.06, "XYZ");
0116   // tdrStyle->SetTitleXSize(Float_t size = 0.02); // Another way to set the size?

0117   // tdrStyle->SetTitleYSize(Float_t size = 0.02);

0118   tdrStyle->SetTitleXOffset(1.1);//0.9);

0119   tdrStyle->SetTitleYOffset(1.25); // => 1.15 if exponents

0120   // tdrStyle->SetTitleOffset(1.1, "Y"); // Another way to set the Offset

0121 
0122 // For the axis labels:

0123 
0124   tdrStyle->SetLabelColor(1, "XYZ");
0125   tdrStyle->SetLabelFont(42, "XYZ");
0126   tdrStyle->SetLabelOffset(0.007, "XYZ");
0127   tdrStyle->SetLabelSize(0.05, "XYZ");
0128 
0129 // For the axis:

0130 
0131   tdrStyle->SetAxisColor(1, "XYZ");
0132   tdrStyle->SetStripDecimals(kTRUE);
0133   tdrStyle->SetTickLength(0.03, "XYZ");
0134   tdrStyle->SetNdivisions(510, "XYZ");
0135   tdrStyle->SetPadTickX(1);  // To get tick marks on the opposite side of the frame

0136   tdrStyle->SetPadTickY(1);
0137 
0138 // Change for log plots:

0139   tdrStyle->SetOptLogx(0);
0140   tdrStyle->SetOptLogy(0);
0141   tdrStyle->SetOptLogz(0);
0142 
0143 // Postscript options:

0144   tdrStyle->SetPaperSize(20.,20.);
0145   // tdrStyle->SetLineScalePS(Float_t scale = 3);

0146   // tdrStyle->SetLineStyleString(Int_t i, const char* text);

0147   // tdrStyle->SetHeaderPS(const char* header);

0148   // tdrStyle->SetTitlePS(const char* pstitle);

0149 
0150   // tdrStyle->SetBarOffset(Float_t baroff = 0.5);

0151   // tdrStyle->SetBarWidth(Float_t barwidth = 0.5);

0152   // tdrStyle->SetPaintTextFormat(const char* format = "g");

0153   tdrStyle->SetPalette(1);
0154   // tdrStyle->SetTimeOffset(Double_t toffset);

0155   // tdrStyle->SetHistMinimumZero(kTRUE);

0156 
0157   // Additional settings for QCD-10-011

0158   tdrStyle->SetLegendBorderSize(0);
0159 
0160   tdrStyle->cd();
0161 
0162 }
0163 
0164 
0165 void cmsPrel(double intLumi=-1, bool wide = false) {
0166 
0167   TLatex *latex = new TLatex();
0168   latex->SetNDC();
0169   latex->SetTextSize(0.045);
0170   
0171   latex->SetTextAlign(31); // align right

0172   latex->DrawLatex(wide ? 0.98 : 0.95, 0.96, "#sqrt{s} = 7 TeV");
0173   if (intLumi > 0.) {
0174     latex->SetTextAlign(11); // align left

0175     //latex->DrawLatex(0.15,0.96,Form("CMS preliminary, %.2g nb^{-1}",intLumi));

0176     latex->DrawLatex(wide ? 0.06 : 0.15, 0.96,
0177              Form("CMS preliminary, %.2g pb^{-1}",intLumi));
0178   }
0179   else if (intLumi==0) { // simulation

0180     latex->SetTextAlign(11); // align left

0181     latex->DrawLatex(wide ? 0.06 : 0.15, 0.96, "CMS simulation (Fall10 QCD)");
0182   }
0183   else {
0184     latex->SetTextAlign(11); // align left

0185     latex->DrawLatex(0.15,0.96,"CMS preliminary 2010");
0186   }
0187 } // cmsPrel

0188 
0189 //cmsPrel(); // to print just CMS and \sqrt{s}

0190 //cmsPrel(400);  // to print also the integrated luminosity.