Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:26

0001 #ifndef MACRO_SPHENIXSTYLE_C
0002 #define MACRO_SPHENIXSTYLE_C
0003 
0004 //
0005 // sPHENIX Style, based on a style file from BaBar, v0.1
0006 //
0007 
0008 #include "sPhenixStyle.h"
0009 
0010 #include <TColor.h>
0011 #include <TROOT.h>
0012 
0013 #include <iostream>
0014 
0015 void SetsPhenixStyle()
0016 {
0017   static TStyle* sphenixStyle = 0;
0018   std::cout << "sPhenixStyle: Applying nominal settings." << std::endl;
0019   if (sphenixStyle == 0) sphenixStyle = sPhenixStyle();
0020   gROOT->SetStyle("sPHENIX");
0021   gROOT->ForceStyle();
0022 }
0023 
0024 TStyle* sPhenixStyle()
0025 {
0026   TStyle* sphenixStyle = new TStyle("sPHENIX", "sPHENIX style");
0027 
0028   // use plain black on white colors
0029   Int_t icol = 0;  // WHITE
0030   sphenixStyle->SetFrameBorderMode(icol);
0031   sphenixStyle->SetFrameFillColor(icol);
0032   sphenixStyle->SetCanvasBorderMode(icol);
0033   sphenixStyle->SetCanvasColor(icol);
0034   sphenixStyle->SetPadBorderMode(icol);
0035   sphenixStyle->SetPadColor(icol);
0036   sphenixStyle->SetStatColor(icol);
0037   //sphenixStyle->SetFillColor(icol); // don't use: white fill color for *all* objects
0038 
0039   // set the paper & margin sizes
0040   sphenixStyle->SetPaperSize(20, 26);
0041 
0042   // set margin sizes
0043   sphenixStyle->SetPadTopMargin(0.05);
0044   sphenixStyle->SetPadRightMargin(0.05);
0045   sphenixStyle->SetPadBottomMargin(0.16);
0046   sphenixStyle->SetPadLeftMargin(0.16);
0047 
0048   // set title offsets (for axis label)
0049   sphenixStyle->SetTitleXOffset(1.4);
0050   sphenixStyle->SetTitleYOffset(1.4);
0051 
0052   // use large fonts
0053   //Int_t font=72; // Helvetica italics
0054   Int_t font = 42;  // Helvetica
0055   Double_t tsize = 0.05;
0056   sphenixStyle->SetTextFont(font);
0057 
0058   sphenixStyle->SetTextSize(tsize);
0059   sphenixStyle->SetLabelFont(font, "x");
0060   sphenixStyle->SetTitleFont(font, "x");
0061   sphenixStyle->SetLabelFont(font, "y");
0062   sphenixStyle->SetTitleFont(font, "y");
0063   sphenixStyle->SetLabelFont(font, "z");
0064   sphenixStyle->SetTitleFont(font, "z");
0065 
0066   sphenixStyle->SetLabelSize(tsize, "x");
0067   sphenixStyle->SetTitleSize(tsize, "x");
0068   sphenixStyle->SetLabelSize(tsize, "y");
0069   sphenixStyle->SetTitleSize(tsize, "y");
0070   sphenixStyle->SetLabelSize(tsize, "z");
0071   sphenixStyle->SetTitleSize(tsize, "z");
0072 
0073   // use bold lines and markers
0074   sphenixStyle->SetMarkerStyle(20);
0075   sphenixStyle->SetMarkerSize(1.2);
0076   sphenixStyle->SetHistLineWidth(2.);
0077   sphenixStyle->SetLineStyleString(2, "[12 12]");  // postscript dashes
0078 
0079   // get rid of X error bars
0080   //sphenixStyle->SetErrorX(0.001);
0081   // get rid of error bar caps
0082   sphenixStyle->SetEndErrorSize(0.);
0083 
0084   // do not display any of the standard histogram decorations
0085   sphenixStyle->SetOptTitle(0);
0086   //sphenixStyle->SetOptStat(1111);
0087   sphenixStyle->SetOptStat(0);
0088   //sphenixStyle->SetOptFit(1111);
0089   sphenixStyle->SetOptFit(0);
0090 
0091   // put tick marks on top and RHS of plots
0092   sphenixStyle->SetPadTickX(1);
0093   sphenixStyle->SetPadTickY(1);
0094 
0095   // legend modificatin
0096   sphenixStyle->SetLegendBorderSize(0);
0097   sphenixStyle->SetLegendFillColor(0);
0098   sphenixStyle->SetLegendFont(font);
0099 
0100 #if ROOT_VERSION_CODE >= ROOT_VERSION(6, 00, 0)
0101   std::cout << "sPhenixStyle: ROOT6 mode" << std::endl;
0102   sphenixStyle->SetLegendTextSize(tsize);
0103   sphenixStyle->SetPalette(kBird);
0104 #else
0105   std::cout << "sPhenixStyle: ROOT5 mode" << std::endl;
0106   // color palette - manually define 'kBird' palette only available in ROOT 6
0107   Int_t alpha = 0;
0108   Double_t stops[9] = {0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000};
0109   Double_t red[9] = {0.2082, 0.0592, 0.0780, 0.0232, 0.1802, 0.5301, 0.8186, 0.9956, 0.9764};
0110   Double_t green[9] = {0.1664, 0.3599, 0.5041, 0.6419, 0.7178, 0.7492, 0.7328, 0.7862, 0.9832};
0111   Double_t blue[9] = {0.5293, 0.8684, 0.8385, 0.7914, 0.6425, 0.4662, 0.3499, 0.1968, 0.0539};
0112   TColor::CreateGradientColorTable(9, stops, red, green, blue, 255, alpha);
0113 #endif
0114 
0115   sphenixStyle->SetNumberContours(80);
0116 
0117   return sphenixStyle;
0118 }
0119 
0120 #endif