simple-tof-analysis
 All Classes Namespaces Functions Variables Groups Pages
style.h
1 #include <TStyle.h>
2 #include <TColor.h>
3 #include <iostream>
4 #include <TROOT.h>
5 #include <TFrame.h>
6 
21 namespace ShinyStyle
22 {
23 
26  map<string,int> reactionColor;
27 
30  map<string,int> reactionMarker;
31 
34  int colors2[] = {kRed+1, kBlue+1};
37  int colors3[] = {kRed+1, kGreen+2, kBlue+1};
40  int colors4[]={kRed+1,kYellow+1,kGreen+2,kBlue+1};
43  int colors5[]={kRed+1,kYellow+1,kGreen+2,kAzure+1,kBlue+1};
46  int colors6[]={kRed+1,kOrange+7,kYellow+1,kGreen+2,kAzure+1,kBlue+1};
47 
50  const int markers2[] = {kFullSquare,kFullCircle};
53  const int markers3[] = {kFullSquare,kFullCross,kFullCircle};
56  const int markers4[] = {kFullSquare,kFullTriangleUp,kFullTriangleDown,kFullCircle};
59  const int markers5[] = {kFullSquare,kFullTriangleUp,kFullCross,kFullTriangleDown,kFullCircle};
62  const int markers6[] = {kFullSquare,kFullTriangleUp,kFullCross,kFullDoubleDiamond,kFullTriangleDown,kFullCircle};
63 
66  const int markers_open2[] = {kOpenSquare,kOpenCircle};
69  const int markers_open3[] = {kOpenSquare,kOpenCross,kOpenCircle};
72  const int markers_open4[] = {kOpenSquare,kOpenTriangleUp,kOpenTriangleDown,kOpenCircle};
75  const int markers_open5[] = {kOpenSquare,kOpenTriangleUp,kOpenCross,kOpenTriangleDown,kOpenCircle};
78  const int markers_open6[] = {kOpenSquare,kOpenTriangleUp,kOpenCross,kOpenDoubleDiamond,kOpenTriangleDown,kOpenCircle};
79 
80 
83  std::map<int,float> marker_sizes;
84 
85 
89  const int contours=999;
90  const int steps=10;
91  static Int_t colors[contours];
92  static Bool_t initialized = kFALSE;
93 
94  Double_t Red[steps] = { 0.90, 0.80, 0.40, 0.00, 0.25, 0.87, 0.90, 1.00, 0.60, 0.31 };
95  Double_t Green[steps] = { 0.90, 0.80, 0.50, 0.85, 1.00, 1.00, 0.50, 0.20, 0.00, 0.00 };
96  Double_t Blue[steps] = { 1.00, 1.00, 1.00, 0.85, 0.25, 0.12, 0.05, 0.00, 0.00, 0.00 };
97  Double_t Length[steps] = { 0.00, 0.02, 0.15, 0.30, 0.44, 0.58, 0.72, 0.86, 0.98, 1.00 };
98 
99  if(!initialized){
100  Int_t FI = TColor::CreateGradientColorTable(steps,Length,Red,Green,Blue,contours);
101  for (int i=0; i<contours; i++)
102  colors[i] = FI+i;
103  initialized = kTRUE;
104  return;
105  }
106  gStyle->SetPalette(contours,colors);
107  }
108 
109 
113  const int contours=21;
114  const int steps=5;
115  static Int_t colors[contours];
116  static Bool_t initialized = kFALSE;
117  Double_t Red[steps] = {0.00, 0.00, 1.00, 1.00, 0.40};
118  Double_t Green[steps] = {0.00, 0.10, 1.00, 0.10, 0.00};
119  Double_t Blue[steps] = {0.40, 1.00, 1.00, 0.00, 0.00};
120  Double_t Length[steps] = {0.00, 0.10, 0.50, 0.90, 1.00};
121  if(!initialized){
122  Int_t FI = TColor::CreateGradientColorTable(steps,Length,Red,Green,Blue,contours);
123  for (int i=0; i<contours; i++)
124  colors[i] = FI+i;
125  initialized = kTRUE;
126  return;
127  }
128  gStyle->SetPalette(contours,colors);
129  }
130 
134 
135  double color1[] = {0, 66, 157};
136  double color2[] = {86, 129, 185};
137  double color3[] = {147, 196, 210};
138  double color4[] = {255, 255, 224};
139  double color5[] = {255, 165, 158};
140  double color6[] = {221, 76, 101};
141  double color7[] = {147, 0, 58};
142 
143  for(int i=0; i<3; i++){
144  color1[i]/=255.;
145  color2[i]/=255.;
146  color3[i]/=255.;
147  color4[i]/=255.;
148  color5[i]/=255.;
149  color6[i]/=255.;
150  color7[i]/=255.;
151  }
152 
153  const int contours=21;
154  const int steps=7;
155  static Int_t colors[contours];
156  static Bool_t initialized = kFALSE;
157  Double_t Red[steps] = {color1[0],color2[0],color3[0],color4[0],color5[0],color6[0],color7[0]};
158  Double_t Green[steps] = {color1[1],color2[1],color3[1],color4[1],color5[1],color6[1],color7[1]};
159  Double_t Blue[steps] = {color1[2],color2[2],color3[2],color4[2],color5[2],color6[2],color7[2]};
160  Double_t Length[steps] = { 0.00, 0.16, 0.33, 0.50, 0.66, 0.84, 1.00};
161 
162 
163  if(!initialized){
164  Int_t FI = TColor::CreateGradientColorTable(steps,Length,Red,Green,Blue,contours);
165  for (int i=0; i<contours; i++)
166  colors[i] = FI+i;
167  initialized = kTRUE;
168  return;
169  }
170  gStyle->SetPalette(contours,colors);
171  }
172 
176 
177  double c1[] = {10, 10, 23, 1};
178  double c2[] = {23, 38, 90, 1};
179  double c3[] = {29, 58, 120, 1};
180  double c4[] = {35, 96, 153, 1};
181  double c5[] = {86, 168, 164, 1};
182 
183  //double color6[] = {234, 244, 250, 1};
184  double c6[] = {250, 244, 234, 1};
185  double c7[] = {245., 245., 245.};
186 
187  double c8[] = {228., 205., 128.};
188  double c9[] = {228., 167., 55.};
189  double c10[]= {224., 127., 22.};
190  double c11[]= {212., 79., 16.};
191  double c12[]= {173., 47., 43.};
192  double c13[]= {119., 30., 75.};
193  double c14[]= {48., 13., 68.};
194 
195  for(int i=0; i<3; i++){
196  c1[i]/=255.;
197  c2[i]/=255.;
198  c3[i]/=255.;
199  c4[i]/=255.;
200  c5[i]/=255.;
201  c6[i]/=255.;
202  c7[i]/=255.;
203  c8[i]/=255.;
204  c9[i]/=255.;
205  c10[i]/=255.;
206  c11[i]/=255.;
207  c12[i]/=255.;
208  c13[i]/=255.;
209  c14[i]/=255.;
210  }
211 
212  const int contours=21;
213  const int steps=11;
214  static Int_t colors[contours];
215  static Bool_t initialized = kFALSE;
216  //Double_t Red[steps] = {c1[0],c2[0],c3[0],c4[0],c5[0], c6[0] ,c7[0],c8[0],c9[0],c10[0],c11[0],c12[0],c13[0],c14[0]};
217  //Double_t Green[steps] = {c1[1],c2[1],c3[1],c4[1],c5[1], c6[1] ,c7[1],c8[1],c9[1],c10[1],c11[1],c12[1],c13[1],c14[1]};
218  //Double_t Blue[steps] = {c1[2],c2[2],c3[2],c4[2],c5[2], c6[2] ,c7[2],c8[2],c9[2],c10[2],c11[2],c12[2],c13[2],c14[2]};
219  //Double_t Length[steps]= { 0.00, 0.10, 0.20, 0.30, 0.40, 0.50 , 0.56, 0.62, 0.68, 0.74, 0.80, 0.86, 0.93, 1.00};
220  Double_t Red[steps] = {c2[0],c3[0],c4[0],c5[0], c6[0] ,c8[0],c9[0],c10[0],c11[0],c12[0],c13[0]};
221  Double_t Green[steps] = {c2[1],c3[1],c4[1],c5[1], c6[1] ,c8[1],c9[1],c10[1],c11[1],c12[1],c13[1]};
222  Double_t Blue[steps] = {c2[2],c3[2],c4[2],c5[2], c6[2] ,c8[2],c9[2],c10[2],c11[2],c12[2],c13[2]};
223  Double_t Length[steps]= { 0.00, 0.10, 0.20, 0.30, 0.50 , 0.60, 0.65, 0.71, 0.78, 0.90, 1.00};
224 
225 
226  if(!initialized){
227  Int_t FI = TColor::CreateGradientColorTable(steps,Length,Red,Green,Blue,contours);
228  for (int i=0; i<contours; i++)
229  colors[i] = FI+i;
230  initialized = kTRUE;
231  return;
232  }
233  gStyle->SetPalette(contours,colors);
234  //gPad->Update();
235  //gPad->GetFrame()->SetFillColorAlpha(kBlack,0.1);
236  //gPad->GetFrame()->SetFillStyle(3544);
237  }
238 
241  void PaletteGreen() {
242 
243 
244  double color1[] = {10, 10, 23, 1};
245  double color2[] = {20, 48, 89, 1};
246  double color3[] = {41, 90, 23, 1};
247  double color4[] = {96, 153, 45, 1};
248  double color5[] = {168, 194, 86, 1};
249  double color6[] = {250, 244, 234, 1};
250 
251  for(int i=0; i<3; i++){
252  color1[i]/=255.;
253  color2[i]/=255.;
254  color3[i]/=255.;
255  color4[i]/=255.;
256  color5[i]/=255.;
257  color6[i]/=255.;
258  }
259 
260  const int contours=99;
261  const int steps=6;
262  static Int_t colors[contours];
263  static Bool_t initialized = kFALSE;
264  Double_t Red[steps] = {color1[0],color2[0],color3[0],color4[0],color5[0],color6[0]};
265  Double_t Green[steps] = {color1[1],color2[1],color3[1],color4[1],color5[1],color6[1]};
266  Double_t Blue[steps] = {color1[2],color2[2],color3[2],color4[2],color5[2],color6[2]};
267  Double_t Length[steps] = { 0.00, 0.15, 0.32, 0.55, 0.80, 1.00};
268  if(!initialized){
269  Int_t FI = TColor::CreateGradientColorTable(steps,Length,Red,Green,Blue,contours);
270  for (int i=0; i<contours; i++)
271  colors[i] = FI+contours-i-1;
272  initialized = kTRUE;
273  return;
274  }
275  gStyle->SetPalette(contours,colors);
276 
277  }
278 
281  void PaletteBlue() {
282 
283  double color1[] = {10, 10, 23, 1};
284  double color2[] = {23, 38, 90, 1};
285  double color3[] = {29, 58, 120, 1};
286  double color4[] = {35, 96, 153, 1};
287  double color5[] = {86, 168, 164, 1};
288  double color6[] = {234, 244, 250, 1};
289 
290  for(int i=0; i<3; i++){
291  color1[i]/=255.;
292  color2[i]/=255.;
293  color3[i]/=255.;
294  color4[i]/=255.;
295  color5[i]/=255.;
296  color6[i]/=255.;
297  }
298 
299  const int contours=99;
300  const int steps=6;
301  static Int_t colors[contours];
302  static Bool_t initialized = kFALSE;
303  Double_t Red[steps] = {color1[0],color2[0],color3[0],color4[0],color5[0],color6[0]};
304  Double_t Green[steps] = {color1[1],color2[1],color3[1],color4[1],color5[1],color6[1]};
305  Double_t Blue[steps] = {color1[2],color2[2],color3[2],color4[2],color5[2],color6[2]};
306  Double_t Length[steps] = { 0.00, 0.12, 0.25, 0.45, 0.80, 1.00};
307  if(!initialized){
308  Int_t FI = TColor::CreateGradientColorTable(steps,Length,Red,Green,Blue,contours);
309  for (int i=0; i<contours; i++)
310  colors[i] = FI+contours-i-1;
311  initialized = kTRUE;
312  return;
313  }
314  gStyle->SetPalette(contours,colors);
315 
316  }
317 
321  gStyle->SetPalette(kSunset);
322  static bool inverted=false;
323  if(!inverted)
324  TColor::InvertPalette();
325  }
326 
330 
331  const int steps=9;
332  const int contours=99;
333  static Int_t colors[contours];
334  static Bool_t initialized = kFALSE;
335 
336  Double_t Red[steps] = { 0./255., 48./255., 119./255., 173./255., 212./255., 224./255., 228./255., 228./255., 245./255.};
337  Double_t Green[steps] = { 0./255., 13./255., 30./255., 47./255., 79./255., 127./255., 167./255., 205./255., 245./255.};
338  Double_t Blue[steps] = { 0./255., 68./255., 75./255., 43./255., 16./255., 22./255., 55./255., 128./255., 245./255.};
339  Double_t Length[steps] = { 0.0000, 0.1250, 0.2500, 0.3750, 0.5000, 0.6250, 0.7500, 0.8750, 1.0000};
340 
341  if(!initialized){
342  Int_t FI = TColor::CreateGradientColorTable(steps,Length,Red,Green,Blue,contours);
343  for (int i=0; i<contours; i++)
344  colors[i] = FI+contours-i-1;
345  initialized = kTRUE;
346  return;
347  }
348  gStyle->SetPalette(contours,colors);
349  }
350 
351 
352 
355  void set_NA61_style() {
356 
357  const Style_t font = 133; // fonts: 132 = serif, 62 = default
358  //const Style_t font = 43; // fonts: 132 = serif, 62 = default
359  // 133,63 = fonts with constant size, independent of the pad size
360  const double LEGEND_SIZE = 20;
361 
362  gStyle->Reset();
363 
364  gStyle->SetCanvasDefH(550);
365  gStyle->SetCanvasDefW(650);
366 
367  gStyle->SetTitleFont(font, "xy");
368  gStyle->SetTitleSize(LEGEND_SIZE, "xy");
369  gStyle->SetLabelFont(font, "xy");
370  gStyle->SetLabelSize(0.8*LEGEND_SIZE, "xy");
371 
372  // for some mysterious reason z axis text is fatter O_o
373  gStyle->SetTitleFont(font, "z");
374  gStyle->SetTitleSize(LEGEND_SIZE*0.95, "z");
375  gStyle->SetLabelFont(font, "z");
376  gStyle->SetLabelSize(0.75*LEGEND_SIZE, "z");
377 
378  //gStyle->SetTextFont(font);
379  gStyle->SetTextSize(LEGEND_SIZE);
380  gStyle->SetLegendFont(font);
381 
382  //dimensions
383  gStyle->SetPadTopMargin(0.1);
384  gStyle->SetPadBottomMargin(0.15);
385  gStyle->SetPadLeftMargin(0.2);
386  gStyle->SetPadRightMargin(0.2);
387 
388  //make all white:
389  gStyle->SetCanvasColor(0);
390  gStyle->SetPadColor(kWhite);
391  gStyle->SetFrameFillColor(0);
392  gStyle->SetFrameLineColor(kBlack);
393  gStyle->SetFrameBorderMode(0);
394  gStyle->SetCanvasBorderMode(0);
395  gStyle->SetPadBorderMode(0);
396 
397 
398  //statbox
399  gStyle->SetOptStat(0);
400  gStyle->SetOptFit(0);
401 
402  //label
403  gStyle->SetLegendBorderSize(1);
404  gStyle->SetLegendFillColor(0); //does nothing?!
405  gStyle->SetFillStyle(0);
406 
407  gStyle->SetNdivisions(505);
408 
409  //title
410  // -this:
411  gStyle->SetOptTitle(0);
412  // -or this:
413  /*gStyle->SetTitleBorderSize(0);
414  gStyle->SetTitleX(0.2);
415  gStyle->SetTitleY(0.975f);
416  gStyle->SetTitleH(0.05f);*/
417  // due to limited/complicated control over histograms titles drawing it is advised to draw titles with TLatex if needed
418 
419  // gStyle->SetErrorX(0.); //no horizontal errorbars. I don't want this by default because I can miss empty bins this way
420 
421  // gROOT->ForceStyle(); // no need to invoke this
422 
423  // Enables using transparency of colors, e. g. SetLineColorAlpha(color,alpha)
424  // (among other things)
425  gStyle->SetCanvasPreferGL(kTRUE);
426 
427  gStyle->SetNumberContours(999);
428 
429  reactionColor["pp"]=kBlue+1; // #0000cc
430  reactionColor["BeBe"]=kGreen+2; // #009900
431  reactionColor["ArSc"]=kOrange+8; // #ff6633
432  reactionColor["XeLa"]=kViolet; // #cc00ff
433  reactionColor["PbPb"]=kRed+1; // #cc0000
434 
435  reactionMarker["pp"]=kFullCircle; // 20
436  reactionMarker["BeBe"]=kFullDiamond; // 33
437  reactionMarker["ArSc"]=kFullTriangleDown; // 23
438  reactionMarker["XeLa"]=kFullCross; // 34
439  reactionMarker["PbPb"]=kFullSquare; // 21
440 
441 
442  marker_sizes[kFullSquare]=1.0;
443  marker_sizes[kFullCircle]=1.2;
444  marker_sizes[kFullTriangleUp]=1.2;
445  marker_sizes[kFullTriangleDown]=1.2;
446  marker_sizes[kFullCross]=1.5;
447  marker_sizes[kFullDoubleDiamond]=1.7;
448  marker_sizes[kFullDiamond]=1.7;
449  marker_sizes[kOpenSquare]=1.0;
450  marker_sizes[kOpenCircle]=1.2;
451  marker_sizes[kOpenTriangleUp]=1.2;
452  marker_sizes[kOpenTriangleDown]=1.2;
453  marker_sizes[kOpenCross]=1.5;
454  marker_sizes[kOpenDoubleDiamond]=1.7;
455  marker_sizes[kOpenDiamond]=1.7;
456 
457  }
458 
461  void set_style2D() {
462  gStyle->SetTitleOffset(2.1, "x");
463  gStyle->SetTitleOffset(2.1, "y");
464  gStyle->SetTitleOffset(2.1, "z");
465  //gStyle->SetLabelOffset(0.015, "xy");
466  gStyle->SetPadTopMargin(0.06);
467  gStyle->SetPadBottomMargin(0.16);
468  gStyle->SetPadLeftMargin(0.20);
469  gStyle->SetPadRightMargin(0.20);
470  }
471 
474  void set_style1D() {
475  gStyle->SetLabelSize(20, "xy");
476  gStyle->SetTitleSize(25, "xy");
477  gStyle->SetTitleOffset(1.1, "x");
478  gStyle->SetTitleOffset(1.0, "y");
479  gStyle->SetLabelOffset(0.01, "xy");
480  gStyle->SetPadTopMargin(0.06);
481  gStyle->SetPadBottomMargin(0.15);
482  gStyle->SetPadLeftMargin(0.13);
483  gStyle->SetPadRightMargin(0.04);
484  }
485 
490  colors2[0]=kOrange+10;colors2[1]=kAzure-6;
491  colors3[0]=kOrange+10;colors3[1]=kYellow-3;colors3[2]=kAzure-6;
492  colors4[0]=kOrange+10;colors4[1]=kYellow-3;colors4[2]=kMagenta+1;colors4[3]=kAzure-6;
493  colors5[0]=kOrange+10;colors5[1]=kYellow-3;colors5[2]=kMagenta+1;colors5[3]=kCyan+1;colors5[4]=kAzure-6;
494  colors6[0]=kOrange+10;colors6[1]=kYellow-3;colors6[2]=kMagenta+1;colors6[3]=kGreen+2;colors6[4]=kCyan+1;colors6[5]=kAzure-6;
495  }
496 
497  void fill_background(int fill_style=3544, int fill_color=1, float fill_alpha=0.1) {
498  gPad->Update();
499  gPad->GetFrame()->SetFillColorAlpha(fill_color,fill_alpha);
500  gPad->GetFrame()->SetFillStyle(fill_style);
501  }
502 
503 } // End namespace ShinyStyle
504 
map< string, int > reactionColor
Definition: style.h:26
int colors6[]
Definition: style.h:46
void PaletteSunsetInverted()
Definition: style.h:329
const int markers3[]
Definition: style.h:53
void PaletteDivergingSunset()
Definition: style.h:175
const int markers6[]
Definition: style.h:62
const int markers5[]
Definition: style.h:59
const int markers4[]
Definition: style.h:56
int colors5[]
Definition: style.h:43
map< string, int > reactionMarker
Definition: style.h:30
const int markers_open3[]
Definition: style.h:69
int colors4[]
Definition: style.h:40
const int markers_open2[]
Definition: style.h:66
void set_style1D()
Definition: style.h:474
void PaletteBlue()
Definition: style.h:281
void PaletteAntoniStandard()
Definition: style.h:88
const int markers_open5[]
Definition: style.h:75
std::map< int, float > marker_sizes
Definition: style.h:83
void PaletteGreen()
Definition: style.h:241
void PaletteSunsetInverted_old()
Definition: style.h:320
void PaletteDivergingWhite()
Definition: style.h:112
void set_style2D()
Definition: style.h:461
void PaletteDivergingPastel()
Definition: style.h:133
void set_NA61_style()
Definition: style.h:355
int colors3[]
Definition: style.h:37
const int markers2[]
Definition: style.h:50
const int markers_open6[]
Definition: style.h:78
const int markers_open4[]
Definition: style.h:72
int colors2[]
Definition: style.h:34
void use_alternative_colors()
Definition: style.h:489