Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:11:10

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