CbmRoot
PairAnalysisStyler.cxx
Go to the documentation of this file.
1 // //
3 // //
4 // Authors:
5 // Julian Book <Julian.Book@cern.ch>
6 /*
7 
8  This class provides a common TStyle for all PAPa plots including
9  usefull functions to automatically set (predefined) styles:
10  SetStyle(), SetForceLineStyle(), SetPalette(), SetLegendAttributes()
11  place legends SetLegendAlign().
12 
13  The PAPa style can be replaced by the method call SetStyle(TStyle *userStyle).
14 
15 */
16 // //
18 
19 #include <TAttFill.h>
20 #include <TAttLine.h>
21 #include <TAttMarker.h>
22 #include <TCollection.h>
23 #include <TColor.h>
24 #include <TError.h>
25 #include <TGaxis.h>
26 #include <TGraph.h>
27 #include <TH1.h>
28 #include <THStack.h>
29 #include <TLatex.h>
30 #include <TLegend.h>
31 #include <TLegendEntry.h>
32 #include <TPad.h>
33 #include <TROOT.h>
34 #include <TStyle.h>
35 
36 #include "PairAnalysisStyleDefs.h"
37 #include "PairAnalysisStyler.h"
38 
39 //_____________________________________________________________________________
40 void PairAnalysisStyler::SetStyle(TStyle* userStyle) {
41  //
42  // set and load user defined style
43  //
44  fUserDielStyle = userStyle;
45  LoadStyle();
46 }
47 
48 //_____________________________________________________________________________
50  //
51  // load style
52  //
53 
54  // define nice colors
55  // new TColor(2001, (66./255.), (98./255.), (255. /255.) );
56  // new TColor(2002, (255./255.), (89./255.), (74. /255.));
57  // new TColor(2003, (51./255.), (204./255.), (51. /255.));
58  // new TColor(2004, (255./255.), (204./255.), (0. /255.));
59  // new TColor(2005, (0./255.), (204./255.), (255. /255.) );
60 
61  // return;
62  // load style defined by the user
63  if (fUserDielStyle) {
64  fUserDielStyle->cd();
65  gROOT->ForceStyle();
66  } else {
67 
68  Int_t font = 42;
69  Int_t bgrdcolor = 0; // set to -1 for transparaent, will causes warnings
70 
71  TStyle* defaultSty = new TStyle("default", "default");
72  defaultSty->SetPaperSize(TStyle::kA4);
73  defaultSty->SetTextFont(font);
74 
75  // For the canvas:
76  defaultSty->SetCanvasBorderMode(0);
77  defaultSty->SetCanvasColor(bgrdcolor); //transparent
78  defaultSty->SetCanvasDefH(600); //Height of canvas
79  defaultSty->SetCanvasDefW(600); //Width of canvas
80  defaultSty->SetCanvasDefX(0); //POsition on screen
81  defaultSty->SetCanvasDefY(0);
82 
83  // For the Pad:
84  defaultSty->SetPadBorderMode(0);
85  // defaultSty->SetPadBorderSize(Width_t size = 1);
86  defaultSty->SetPadColor(bgrdcolor); //transparent
87  defaultSty->SetPadGridX(false);
88  defaultSty->SetPadGridY(false);
89  defaultSty->SetGridColor(0);
90  defaultSty->SetGridStyle(3);
91  defaultSty->SetGridWidth(1);
92 
93  // For the frame:
94  defaultSty->SetFrameBorderMode(0);
95  defaultSty->SetFrameBorderSize(1);
96  defaultSty->SetFrameFillColor(bgrdcolor); //transparent
97  defaultSty->SetFrameFillStyle(0);
98  defaultSty->SetFrameLineColor(1);
99  defaultSty->SetFrameLineStyle(1);
100  defaultSty->SetFrameLineWidth(1);
101 
102  // Margins:
103  defaultSty->SetPadTopMargin(0.075);
104  defaultSty->SetPadBottomMargin(0.18);
105  defaultSty->SetPadLeftMargin(0.18); //0.13
106  defaultSty->SetPadRightMargin(0.075);
107 
108  // For the histo:
109  defaultSty->SetHistFillColor(bgrdcolor); //transparent
110  // defaultSty->SetHistFillStyle(0);
111  defaultSty->SetHatchesSpacing(2.); // spacing between hatches, def.=1.
112  defaultSty->SetHatchesLineWidth(2); // hatches line width.
113  defaultSty->SetHistLineColor(1);
114  defaultSty->SetHistLineStyle(0);
115  defaultSty->SetHistLineWidth(2);
116  // defaultSty->SetLegoInnerR(Float_t rad = 0.5);
117  defaultSty->SetHistMinimumZero();
118  // defaultSty->SetEndErrorSize(2);
119  defaultSty->SetErrorX(0.0);
120  defaultSty->SetLineColor(1);
121  defaultSty->SetMarkerColor(1);
122  defaultSty->SetMarkerStyle(kFullCircle); // Kind of dot used for points
123  defaultSty->SetMarkerSize(1.5);
124 
125 
126  //For the fit/function:
127  defaultSty->SetOptFit(1);
128  defaultSty->SetFitFormat("5.4g");
129  defaultSty->SetFuncColor(2);
130  defaultSty->SetFuncStyle(1);
131  defaultSty->SetFuncWidth(1);
132 
133  //For the date:
134  defaultSty->SetOptDate(22); // bottom right only date
135  // defaultSty->SetDateX(Float_t x = 0.01);
136  // defaultSty->SetDateY(Float_t y = 0.01);
137  defaultSty->GetAttDate()->SetTextColor(kGray);
138  defaultSty->GetAttDate()->SetTextFont(font);
139  defaultSty->GetAttDate()->SetTextSize(0.02);
140 
141  // For the statistics box:
142  defaultSty->SetOptFile(0);
143  defaultSty->SetOptStat(
144  0); // To display the mean and RMS: SetOptStat("mr");
145  // defaultSty->SetOptStat("n"); // only name
146  defaultSty->SetStatColor(kWhite);
147  defaultSty->SetStatFont(font);
148  defaultSty->SetStatFontSize(0.02);
149  defaultSty->SetStatTextColor(kGray);
150  defaultSty->SetStatFormat("6.4g");
151  defaultSty->SetStatBorderSize(1);
152  defaultSty->SetStatH(0.1);
153  defaultSty->SetStatW(0.5);
154  defaultSty->SetStatStyle(kFEmpty);
155  defaultSty->SetStatX(0.01);
156  defaultSty->SetStatY(0.01);
157 
158  // For the Global title:
159  defaultSty->SetOptTitle(0);
160  defaultSty->SetTitleFont(font, "T");
161  defaultSty->SetTitleSize(0.05, "T");
162  defaultSty->SetTitleColor(bgrdcolor, "T");
163  defaultSty->SetTitleTextColor(1);
164  defaultSty->SetTitleFillColor(bgrdcolor); //transparent
165  defaultSty->SetTitleFontSize(0.06);
166  // defaultSty->SetTitleH(0); // Set the height of the title box
167  defaultSty->SetTitleW(0.5); // Set the width of the title box
168  defaultSty->SetTitleX(0.25); // Set the position of the title box
169  // defaultSty->SetTitleY(0.985); // Set the position of the title box
170  defaultSty->SetTitleStyle(kFEmpty);
171  // defaultSty->SetTitleBorderSize(2);
172  defaultSty->SetPaintTextFormat(
173  ".3f"); // format if you plot with TEXT option
174 
175  // for Paves and boxes
176  // defaultSty->SetFillColor(bgrdcolor); // this makes palettes unicolored
177  defaultSty->SetFillStyle(kFEmpty);
178  defaultSty->SetLineColor(0);
179  defaultSty->SetLineWidth(0);
180  defaultSty->SetLineStyle(1);
181 
182  // For the axis titles:
183  defaultSty->SetTitleColor(1, "XYZ");
184  defaultSty->SetTitleFont(font, "XYZ");
185  defaultSty->SetTitleSize(0.06, "XYZ"); //
186  // defaultSty->SetTitleXSize(Float_t size = 0.02); // Another way to set the size?
187  // defaultSty->SetTitleYSize(Float_t size = 0.02);
188  defaultSty->SetTitleXOffset(1.0); // defaultSty->SetTitleXOffset(1.08);
189  defaultSty->SetTitleYOffset(1.25); // defaultSty->SetTitleYOffset(1.5);
190  //defaultSty->SetTitleOffset(1.0, "XYZ"); // Another way to set the Offset
191 
192  // For the axis labels:
193  defaultSty->SetLabelColor(1, "XYZ");
194  defaultSty->SetLabelFont(font, "XYZ");
195  defaultSty->SetLabelOffset(0.007, "XYZ");
196  defaultSty->SetLabelSize(0.04,
197  "XYZ"); // defaultSty->SetLabelSize(0.06, "XYZ");
198  defaultSty->SetLabelSize(0.03,
199  "Z"); // defaultSty->SetLabelSize(0.06, "XYZ");
200 
201  // For the axis:
202  defaultSty->SetHistMinimumZero();
203  defaultSty->SetAxisColor(1, "XYZ");
204  // defaultSty->SetStripDecimals(kTRUE);
205  // defaultSty->SetTickLength(0.03, "XYZ");
206  defaultSty->SetNdivisions(
207  810, "XYZ"); // defaultSty->SetNdivisions(505, "XYZ");
208  defaultSty->SetPadTickX(
209  1); // To get tick marks on the opposite side of the frame
210  defaultSty->SetPadTickY(1);
211 
212  // Change for log plots:
213  defaultSty->SetOptLogx(0);
214  defaultSty->SetOptLogy(0);
215  defaultSty->SetOptLogz(0);
216 
217  // For the colored palette
218  // defaultSty->SetPalette(1,0);
219  const Int_t NRGBs = 5;
220  const Int_t NCont = 255;
221  // beautiful colors blue to red
222  Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
223  Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
224  // Double_t green[NRGBs] = { 0.20, 0.81, 1.00, 0.20, 0.00};
225  //Double_t blue[NRGBs] = { 0.0, 0.00, 0.0, 0.00, 0.00};
226  Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
227  Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
228  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
229  defaultSty->SetNumberContours(NCont);
230 
231 
232  // For the legends:
233  defaultSty->SetLegendFillColor(bgrdcolor);
234  //defaultSty->SetLegendFillColor(kWhite);
235  defaultSty->SetLegendFont(font);
236  // defaultSty->SetLegendTextSize(0.02); //for root>v6??
237 
238  // Additions -- transparent style
239  defaultSty->SetFillStyle(4000);
240  defaultSty->SetStatStyle(0);
241  defaultSty->SetTitleStyle(0);
242  defaultSty->SetCanvasBorderSize(0);
243  defaultSty->SetFrameBorderSize(0);
244  defaultSty->SetLegendBorderSize(0);
245  defaultSty->SetStatBorderSize(0);
246  defaultSty->SetTitleBorderSize(0);
247 
248  // set current style to default
249  // gROOT->SetStyle(sty);
250  defaultSty->cd();
251  gROOT->ForceStyle();
252  fUserDielStyle = defaultSty;
253 
254  // axis
255  // TGaxis::SetMaxDigits(4);
256  TGaxis::SetMaxDigits(3);
257  TGaxis::SetExponentOffset(-1. * 0.06, 0., "y");
258  }
259 }
260 
261 //_____________________________________________________________________________
262 void PairAnalysisStyler::Style(TObject* obj, Int_t idx) {
263  //
264  // style object according to index
265  //
266  // Int_t id=0;
267  if (!obj) return;
268 
269  // axis attributes
270  if (obj->InheritsFrom(TH1::Class()) && gPad) {
271  // reset axis names in order to allow repositioning of exponents
272  dynamic_cast<TH1*>(obj)->GetXaxis()->SetName("xaxis");
273  dynamic_cast<TH1*>(obj)->GetYaxis()->SetName("yaxis");
274  // logarithmic labels
275  if (gPad->GetLogx()) {
276  dynamic_cast<TH1*>(obj)->GetXaxis()->SetMoreLogLabels(kTRUE);
277  dynamic_cast<TH1*>(obj)->GetXaxis()->SetNoExponent(kTRUE);
278  }
279  if (gPad->GetLogy()) {
280  dynamic_cast<TH1*>(obj)->GetYaxis()->SetMoreLogLabels(kTRUE);
281  dynamic_cast<TH1*>(obj)->GetYaxis()->SetNoExponent(kTRUE);
282  }
283  if (gPad->GetLogz()) {
284  dynamic_cast<TH1*>(obj)->GetZaxis()->SetMoreLogLabels(kTRUE);
285  dynamic_cast<TH1*>(obj)->GetZaxis()->SetNoExponent(kTRUE);
286  }
287  }
288 
289  // marker attributes
290  if (obj->InheritsFrom(TAttMarker::Class())) {
291  if (idx >= 100) { // predefined styles
292  dynamic_cast<TAttMarker*>(obj)->SetMarkerSize(fSze[idx - kRaw]);
293  dynamic_cast<TAttMarker*>(obj)->SetMarkerStyle(fMrk[idx - kRaw]);
294  dynamic_cast<TAttMarker*>(obj)->SetMarkerColor(fCol[idx - kRaw]);
295  } else {
296  dynamic_cast<TAttMarker*>(obj)->SetMarkerSize(1.5);
297  dynamic_cast<TAttMarker*>(obj)->SetMarkerStyle(Marker[idx % kNMaxMarker]);
298  dynamic_cast<TAttMarker*>(obj)->SetMarkerColor(Color[idx % kNMaxColor]);
299  if (idx >= kNMaxColor && idx < kNMaxColor * 2) {
300  idx = idx % kNMaxColor;
301  dynamic_cast<TAttMarker*>(obj)->SetMarkerColor(
302  TColor::GetColorDark(Color[idx]));
303  } else if (idx >= kNMaxColor * 2) {
304  idx = idx % (2 * kNMaxColor);
305  dynamic_cast<TAttMarker*>(obj)->SetMarkerColor(
306  TColor::GetColorBright(Color[idx]));
307  }
308  }
309  }
310 
311  // line attributes
312  if (obj->InheritsFrom(TAttLine::Class())) {
313  // printf("index %d for %s \n",idx,obj->GetName());
314  if (idx >= 100) { // predefined styles
315  dynamic_cast<TAttLine*>(obj)->SetLineWidth(fWdt[idx - kRaw]);
316  dynamic_cast<TAttLine*>(obj)->SetLineStyle(fLne[idx - kRaw]);
317  dynamic_cast<TAttLine*>(obj)->SetLineColor(fCol[idx - kRaw]);
318  } else {
319  dynamic_cast<TAttLine*>(obj)->SetLineWidth(2);
320  dynamic_cast<TAttLine*>(obj)->SetLineStyle(Line[idx % kNMaxLine]);
321  dynamic_cast<TAttLine*>(obj)->SetLineColor(Color[idx % kNMaxColor]);
322  if (idx >= kNMaxColor && idx < kNMaxColor * 2) {
323  idx = idx % kNMaxColor;
324  dynamic_cast<TAttLine*>(obj)->SetLineColor(
325  TColor::GetColorDark(Color[idx]));
326  } else if (idx >= kNMaxColor * 2) {
327  idx = idx % (2 * kNMaxColor);
328  dynamic_cast<TAttLine*>(obj)->SetLineColor(
329  TColor::GetColorBright(Color[idx]));
330  }
331  }
332  }
333 
334  // fill attributes, only used if fill style is set (default: not)
335  if (obj->InheritsFrom(TAttFill::Class())) {
336  // printf("fill style %d for index: %d \n",Fill[0],idx);
337  if (idx >= 100 && fFll[idx - kRaw] >= 0) { // predefined styles
338  dynamic_cast<TAttFill*>(obj)->SetFillColor(fCol[idx - kRaw]);
339  dynamic_cast<TAttFill*>(obj)->SetFillStyle(fFll[idx - kRaw]);
340  } else if (Fill[0] >= 0) {
341  dynamic_cast<TAttFill*>(obj)->SetFillColor(Color[idx % kNMaxColor]);
342  if (idx >= kNMaxColor && idx < kNMaxColor * 2) {
343  idx = idx % kNMaxColor;
344  dynamic_cast<TAttFill*>(obj)->SetFillColor(
345  TColor::GetColorDark(Color[idx]));
346  } else if (idx >= kNMaxColor * 2) {
347  idx = idx % (2 * kNMaxColor);
348  dynamic_cast<TAttFill*>(obj)->SetFillColor(
349  TColor::GetColorBright(Color[idx]));
350  }
351  dynamic_cast<TAttFill*>(obj)->SetFillStyle(Fill[0]);
352  }
353  }
354 }
355 
356 //_____________________________________________________________________________
358  //
359  // force a certain line style
360  //
361  for (Int_t i = 0; i < kNMaxLine; i++) {
362  Line[i] = line;
363  }
364 }
365 
366 //_____________________________________________________________________________
368  //
369  // force a certain color
370  //
371  for (Int_t i = 0; i < kNMaxColor; i++) {
372  Color[i] = color;
373  }
374 }
375 
376 //_____________________________________________________________________________
378  //
379  // force a certain color
380  //
381  for (Int_t i = 0; i < (kNidx - kRaw); i++) {
382  fFll[i] = fill;
383  }
384  Fill[0] = fill;
385 }
386 
387 //_____________________________________________________________________________
389  //
390  // force a certain marker fill style
391  //
392  for (Int_t i = 0; i < kNMaxMarker; i++) {
393 
394  switch (Marker[i]) {
395  case kOpenCircle:
396  if (fill == kFullMarker) Marker[i] = kFullCircle;
397  break;
398  case kOpenSquare:
399  if (fill == kFullMarker) Marker[i] = kFullSquare;
400  break;
401  case kOpenTriangleUp:
402  if (fill == kFullMarker) Marker[i] = kFullTriangleUp;
403  break;
404  case kOpenTriangleDown:
405  if (fill == kFullMarker) Marker[i] = kFullTriangleDown;
406  break;
407  case kOpenStar:
408  if (fill == kFullMarker) Marker[i] = kFullStar;
409  break;
410  case kOpenDiamond:
411  if (fill == kFullMarker) Marker[i] = kFullDiamond;
412  break;
413  case kOpenCross:
414  if (fill == kFullMarker) Marker[i] = kFullCross;
415  break;
416  case kFullCircle:
417  if (fill == kOpenMarker) Marker[i] = kOpenCircle;
418  break;
419  case kFullSquare:
420  if (fill == kOpenMarker) Marker[i] = kOpenSquare;
421  break;
422  case kFullTriangleUp:
423  if (fill == kOpenMarker) Marker[i] = kOpenTriangleUp;
424  break;
425  case kFullTriangleDown:
426  if (fill == kOpenMarker) Marker[i] = kOpenTriangleDown;
427  break;
428  case kFullStar:
429  if (fill == kOpenMarker) Marker[i] = kOpenStar;
430  break;
431  case kFullDiamond:
432  if (fill == kOpenMarker) Marker[i] = kOpenDiamond;
433  break;
434  case kFullCross:
435  if (fill == kOpenMarker) Marker[i] = kOpenCross;
436  break;
437  }
438  }
439 }
440 
441 
442 //_____________________________________________________________________________
444  Int_t col,
445  Int_t marker,
446  Double_t size,
447  Int_t line,
448  Double_t width,
449  Int_t fill) {
450  //
451  // change predefined style "idx" according to arguments
452  //
453  fCol[idx - kRaw] = col;
454  fMrk[idx - kRaw] = marker;
455  fSze[idx - kRaw] = size;
456  fLne[idx - kRaw] = line;
457  fWdt[idx - kRaw] = width;
458  fFll[idx - kRaw] = fill;
459 }
460 
461 
462 //_____________________________________________________________________________
463 void PairAnalysisStyler::SetLegendAlign(UInt_t align) { fLegAlign = align; }
464 
465 //_____________________________________________________________________________
466 void PairAnalysisStyler::SetLegendAttributes(TLegend* leg, Bool_t fill) {
467  //
468  // set/update legend cooordinates according to alignement (stored in uniqueID)
469  // and "fill" a legend with white background color
470  //
471 
472  // if(leg->GetUniqueID()==0) leg->SetUniqueID(fLegAlign);
473  // UInt_t fLegAlign = leg->GetUniqueID();
474 
475  // printf("CURRENT leg coordinates: x1 %f x2 %f \t",leg->GetX1(),leg->GetX2());
476  // printf(" y1 %f y2 %f \n",leg->GetY1(),leg->GetY2());
477 
478  Double_t maxhgth = 0.0;
479  Double_t symblwdth = 0.065; //ndc
480  Double_t txtsze = 0.04; //0.025; //gStyle->GetLegendTextSize());
481  // Double_t charwdth = 0.01;//0.01; // own defintion
482  Double_t entrysep = 1.25; //1.25; //entry seperation
483 
484  // calculate get legend width
485  Double_t maxwdth = 0.0;
486  TList* llist = leg->GetListOfPrimitives();
487  Int_t nent = llist->GetEntries();
488 
489  if (nent > 5) txtsze = 0.03; //0.025
490  leg->SetTextSize(txtsze); // this should switch off the autosize
491  // leg->SetTextAlign(11);
492 
493 
494  for (Int_t il = 0; il < nent; il++) {
495  TLegendEntry* lent = static_cast<TLegendEntry*>(llist->At(il));
496  TString lst(lent->GetLabel());
497  // lent->SetTextSize(20);
498  // /* lst.ReplaceAll("#it","");
499  lst.ReplaceAll("{", "");
500  lst.ReplaceAll("}", "");
501  lst.ReplaceAll("^", "");
502  lst.ReplaceAll("_", "");
503  lst.ReplaceAll("#LT", "#");
504  lst.ReplaceAll("#GT", "#");
505  lst.ReplaceAll("#phi", "#");
506  lst.ReplaceAll("#rho", "#");
507  lst.ReplaceAll("#omega", "#");
508  lst.ReplaceAll("#eta", "#");
509  lst.ReplaceAll("#epsilon", "#");
510  lst.ReplaceAll("#psi", "#");
511  lst.ReplaceAll("#pi", "#");
512  lst.ReplaceAll("#alpha", "#");
513  lst.ReplaceAll("#gamma", "#");
514  lst.ReplaceAll("#rightarrow", "#");
515  // */
516  // lst.ReplaceAll(" ","");
517  TLatex entrytex(0., 0., lst.Data());
518  entrytex.SetNDC(kTRUE);
519  entrytex.SetTextSize(txtsze);
520  entrytex.SetTextFont(gStyle->GetLegendFont());
521  //entrytex.SetTextFont(lent->GetTextFont());
522  Double_t wdth = entrytex.GetXsize();
523  Double_t hgth = entrytex.GetYsize();
524  //wdth = lst.Length()*charwdth;
525  if (maxwdth < wdth) maxwdth = wdth;
526  // Printf("wdth %f and height %f for '%s' \t max width: %f by textsize %f for nchars %d --> own wdth %f \n",
527  // wdth,entrytex.GetYsize(),entrytex.GetTitle(),maxwdth, entrytex.GetTextSize(),lst.Length(),lst.Length()*charwdth);
528  maxhgth += hgth;
529  }
530 
531  maxhgth = nent * txtsze * entrysep;
532  // Bool_t addhdr = !(((TString)leg->GetHeader()).IsNull());
533  // maxhgth = (maxhgth/nent)*entrysep*(nent+1); // add legend header height
534 
535  // set legend coordinates
536  if (fLegAlign == 12 || fLegAlign == 22) { //top
537  leg->SetY2(1. - gPad->GetTopMargin() - gStyle->GetTickLength("X"));
538  leg->SetY1(leg->GetY2() - maxhgth);
539  } else { // bottom
540  leg->SetY1(0. + gPad->GetBottomMargin() + gStyle->GetTickLength("X"));
541  leg->SetY2(leg->GetY1() + maxhgth);
542  }
543  if (fLegAlign == 22 || fLegAlign == 21) { //right
544  leg->SetX2(1. - gPad->GetRightMargin()
545  - gStyle->GetTickLength("Y") * 1.0); //x2.0 ticklength
546  leg->SetX1(leg->GetX2() - maxwdth * 1.0 - symblwdth);
547  } else if (fLegAlign == 12 || fLegAlign == 11) { //left
548  leg->SetX1(0. + gPad->GetLeftMargin() + gStyle->GetTickLength("Y"));
549  leg->SetX2(leg->GetX1() + maxwdth * 1.0 + symblwdth);
550  }
551 
552  // fix margin such that lines allways have the same length
553  leg->SetMargin(symblwdth / (leg->GetX2() - leg->GetX1()));
554  leg->SetEntrySeparation(entrysep - 1.);
555 
556  // styling
557  if (fill)
558  leg->SetFillStyle(1001); // solid
559  else
560  leg->SetFillStyle(kFEmpty); // empty
561  // leg->SetFillColorAlpha(gStyle->GetLegendFillColor(), 0.8);
562  // leg->SetFillColorAlpha(gStyle->GetLegendFillColor(), 0.8);
563 
564  // printf("FINAL leg coordinates: x1 %f x2 %f \t",leg->GetX1(),leg->GetX2());
565  // printf(" y1 %f y2 %f \n",leg->GetY1(),leg->GetY2());
566 }
567 
568 void PairAnalysisStyler::SetPalette(Epalette colors, Bool_t reverse) {
569  //
570  // use own definition of color palettes for zaxis
571  //
572 
573  const Int_t NRGBs = 5;
574  const Int_t NCont = 255;
575  Double_t stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
576 
577  switch (colors) {
578  case kDefault: {
579  Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
580  Double_t green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
581  Double_t blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
582  if (reverse)
583  TColor::CreateGradientColorTable(NRGBs, stops, blue, green, red, NCont);
584  else
585  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
586  break;
587  }
588  case kGoodBad: {
589  Double_t red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.36};
590  Double_t green[NRGBs] = {0.20, 0.81, 1.00, 0.20, 0.00};
591  Double_t blue[NRGBs] = {0.00, 0.00, 0.00, 0.00, 0.00};
592  if (reverse)
593  TColor::CreateGradientColorTable(NRGBs, stops, green, red, blue, NCont);
594  else
595  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
596  break;
597  }
598  }
599 
600 
601  gStyle->SetNumberContours(NCont);
602 }
603 
604 //_____________________________________________________________________________
606  //
607  // get the first histogram drawn on the pad
608  // this can be modified in the usual way
609  //
610  if (!gPad) {
611  Error("GetFirstHistogram", "No pad found, return NULL pointer!!");
612  return 0x0;
613  }
614 
615  TIter nextObj(gPad->GetListOfPrimitives());
616  TObject* obj;
617  while ((obj = nextObj())) {
618  if (obj->InheritsFrom(TH1::Class())) { return (static_cast<TH1*>(obj)); }
619  if (obj->InheritsFrom(TGraph::Class())) {
620  return (static_cast<TH1*>(static_cast<TGraph*>(obj)->GetHistogram()));
621  }
622  if (obj->InheritsFrom(THStack::Class())) {
623  return (static_cast<TH1*>(static_cast<THStack*>(obj)->GetHistogram()));
624  }
625  }
626  return 0x0;
627 }
628 
629 //_____________________________________________________________________________
630 TLegendEntry* PairAnalysisStyler::GetLegendEntry(Int_t idx) {
631  //
632  // TODO
633  //
634  //
635  if (!gPad) {
636  Error("GetLegendEntry", "No pad found, return NULL pointer!!");
637  return 0x0;
638  }
639 
640  TList* prim = gPad->GetListOfPrimitives();
641  if (!prim) return NULL;
642  TLegend* leg = dynamic_cast<TLegend*>(prim->FindObject("TPave"));
643  if (!leg) return NULL;
644  TList* entries = leg->GetListOfPrimitives();
645  if (!entries) return NULL;
646  return (dynamic_cast<TLegendEntry*>(entries->At(idx)));
647 }
PairAnalysisStyler::Epalette
Epalette
Definition: PairAnalysisStyler.h:26
PairAnalysisStyler::fLegAlign
static UInt_t fLegAlign
Definition: PairAnalysisStyleDefs.h:84
PairAnalysisStyler::Eidx
Eidx
Definition: PairAnalysisStyler.h:25
PairAnalysisStyler::fCol
static Int_t fCol[kNidx - kRaw]
Definition: PairAnalysisStyleDefs.h:29
PairAnalysisStyler::fSze
static Double_t fSze[kNidx - kRaw]
Definition: PairAnalysisStyleDefs.h:39
PairAnalysisStyler::kDefault
@ kDefault
Definition: PairAnalysisStyler.h:26
PairAnalysisStyler::SetLegendAttributes
void SetLegendAttributes(TLegend *leg, Bool_t fill=kFALSE)
Definition: PairAnalysisStyler.cxx:466
PairAnalysisStyleDefs.h
PairAnalysisStyler::kFullMarker
@ kFullMarker
Definition: PairAnalysisStyler.h:27
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
PairAnalysisStyler::kRaw
@ kRaw
Definition: PairAnalysisStyler.h:25
PairAnalysisStyler::fLne
static Int_t fLne[kNidx - kRaw]
Definition: PairAnalysisStyleDefs.h:40
PairAnalysisStyler::kNMaxLine
@ kNMaxLine
Definition: PairAnalysisStyler.h:28
PairAnalysisStyler::SetPalette
void SetPalette(Epalette colors=kDefault, Bool_t reverse=kFALSE)
Definition: PairAnalysisStyler.cxx:568
PairAnalysisStyler::fMrk
static Int_t fMrk[kNidx - kRaw]
Definition: PairAnalysisStyleDefs.h:34
PairAnalysisStyler::SetForceLineStyle
void SetForceLineStyle(Int_t line=kSolid)
Definition: PairAnalysisStyler.cxx:357
PairAnalysisStyler::Color
static Int_t Color[]
Definition: PairAnalysisStyleDefs.h:64
PairAnalysisStyler::EfillMark
EfillMark
Definition: PairAnalysisStyler.h:27
PairAnalysisStyler::SetForceMarkerFillStyle
void SetForceMarkerFillStyle(EfillMark fill)
Definition: PairAnalysisStyler.cxx:388
PairAnalysisStyler::kNMaxColor
@ kNMaxColor
Definition: PairAnalysisStyler.h:28
Line
Definition: CbmGlobalTrackingTof.cxx:96
PairAnalysisStyler::kOpenMarker
@ kOpenMarker
Definition: PairAnalysisStyler.h:27
PairAnalysisStyler::fUserDielStyle
static TStyle * fUserDielStyle
Definition: PairAnalysisStyleDefs.h:86
PairAnalysisStyler::SetForceFillStyle
void SetForceFillStyle(Int_t fill=kFSolid)
Definition: PairAnalysisStyler.cxx:377
PairAnalysisStyler::Marker
static Int_t Marker[]
Definition: PairAnalysisStyleDefs.h:44
PairAnalysisStyler::kNidx
@ kNidx
Definition: PairAnalysisStyler.h:25
PairAnalysisStyler::LoadStyle
void LoadStyle()
Definition: PairAnalysisStyler.cxx:49
PairAnalysisStyler.h
PairAnalysisStyler::SetStyle
void SetStyle(TStyle *userStyle)
Definition: PairAnalysisStyler.cxx:40
PairAnalysisStyler::SetForceColor
void SetForceColor(Int_t color=kBlack)
Definition: PairAnalysisStyler.cxx:367
PairAnalysisStyler::GetFirstHistogram
TH1 * GetFirstHistogram()
Definition: PairAnalysisStyler.cxx:605
PairAnalysisStyler::kGoodBad
@ kGoodBad
Definition: PairAnalysisStyler.h:26
PairAnalysisStyler::kNMaxMarker
@ kNMaxMarker
Definition: PairAnalysisStyler.h:28
PairAnalysisStyler::fWdt
static Double_t fWdt[kNidx - kRaw]
Definition: PairAnalysisStyleDefs.h:41
PairAnalysisStyler::fFll
static Int_t fFll[kNidx - kRaw]
Definition: PairAnalysisStyleDefs.h:42
PairAnalysisStyler::GetLegendEntry
TLegendEntry * GetLegendEntry(Int_t idx)
Definition: PairAnalysisStyler.cxx:630
PairAnalysisStyler::Style
void Style(TObject *obj, Int_t idx=0)
Definition: PairAnalysisStyler.cxx:262
PairAnalysisStyler::SetLegendAlign
void SetLegendAlign(UInt_t align)
Definition: PairAnalysisStyler.cxx:463
PairAnalysisStyler::Fill
static Int_t Fill[]
Definition: PairAnalysisStyleDefs.h:82