Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:24:05

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