Back to home page

sPhenix code displayed by LXR

 
 

    


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

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