AliRoot Core  3dc7879 (3dc7879)
AliDrawStyle.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
24 #include "AliDrawStyle.h"
25 #include "TStyle.h"
26 #include "TError.h"
27 #include "TPRegexp.h"
28 #include "TColor.h"
29 #include "TMath.h"
30 #include "TRegexp.h"
31 #include "TObjArray.h"
32 #include "TSystem.h"
33 #include "TPad.h"
34 #include "TCanvas.h"
35 #include "TH1.h"
36 #include "TGraphErrors.h"
37 #include "TF1.h"
38 #include "TClass.h"
39 #include "TLegend.h"
40 #include "TString.h"
41 #include "TList.h"
42 #include "TObject.h"
43 #include "TPad.h"
44 #include "TGraph.h"
45 #include "TMultiGraph.h"
46 #include "TAxis.h"
47 #include <iostream>
48 #include <sstream>
49 #include <fstream>
50 #include <ios>
51 
52 Int_t AliDrawStyle::padNumber = 0;
55 std::map<TString, TString> AliDrawStyle::fLatexAlice;
56 std::map<TString, TStyle*> AliDrawStyle::fStyleAlice;
57 std::map<TString, TObjArray*> AliDrawStyle::fCssStyleAlice; //
58 std::map<TString, std::vector<int> > AliDrawStyle::fMarkerStyles; // PLEASE LEAVE THE UNAESTHETIC SPACE
59 std::map<TString, std::vector<int> > AliDrawStyle::fMarkerColors; // IN ORDER TO MAKE IT WORK WITH THE
60 std::map<TString, std::vector<float> > AliDrawStyle::fMarkerSize; // NATIVE SLC6 COMPILER!!!
61 std::map<TString, std::vector<int> > AliDrawStyle::fFillColors;
62 std::map<TString, std::vector<float> > AliDrawStyle::fLineWidth;
63 std::map<TString, std::vector<float> > AliDrawStyle::fLineStyle;
64 std::map<TString, std::vector<float> > AliDrawStyle::fLineColor;
65 
71 }
72 
76 void AliDrawStyle::SetDefaultStyles(const char * styleName, const char* arrayName){
77  fDefaultTStyleID=styleName;
78  fDefaultArrayStyleID=arrayName;
79 }
80 
81 TStyle* RegisterDefaultStyleFigTemplate(Bool_t grayScale);
82 
86 TString AliDrawStyle::GetLatexAlice(const char * symbol){
87  return fLatexAlice[symbol];
88 }
89 
96 
102 Int_t AliDrawStyle::GetIntegerAt(const char * format, Int_t index, const char * separator ) {
103  if (format==NULL) return -1;
104  if (index<0) return -1;
105  index++;
106  TString sFormat(format);
107  TString token(format);
108  Int_t position=0;
109  Int_t counter=0;
110  while (counter<index) {
111  if (sFormat.Tokenize(token,position,separator)) {
112  counter++;
113  }else{
114  break;
115  }
116  }
117  if (counter==index) return token.Atoi();
118  return -1;
119 }
120 
127 
133 Float_t AliDrawStyle::GetFloatAt(const char * format, Int_t index, const char * separator ) {
134  if (format==NULL) return -1;
135  if (index<0) return -1;
136  index++;
137  TString sFormat(format);
138  TString token(format);
139  Int_t position=0;
140  Int_t counter=0;
141  while (counter<index) {
142  if (sFormat.Tokenize(token,position,separator)) {
143  counter++;
144  }else{
145  break;
146  }
147  }
148  if (counter==index) return token.Atof();
149  return -1;
150 }
151 
152 // GetMarkerStyle associated to the style.
156 Int_t AliDrawStyle::GetMarkerStyle(const char *style, Int_t index){
157  if ((Int_t) AliDrawStyle::fMarkerStyles[style].size() <= index) {
158  return GetIntegerAt(style,index);
159  }
160  return AliDrawStyle::fMarkerStyles[style][index];
161 }
162 
163 // GetLineStyle associated to the style.
167 Int_t AliDrawStyle::GetLineStyle(const char *style, Int_t index){
168  if ((Int_t) AliDrawStyle::fLineStyle[style].size() <= index) {
169  return GetIntegerAt(style,index);
170  }
171  return AliDrawStyle::fLineStyle[style][index];
172 }
173 
174 // GetLineColor associated to the style.
178 Int_t AliDrawStyle::GetLineColor(const char *style, Int_t index){
179  if ((Int_t) AliDrawStyle::fLineColor[style].size() <= index) {
180  return GetIntegerAt(style,index);
181  }
182  return AliDrawStyle::fLineColor[style][index];
183 }
184 
189 Int_t AliDrawStyle::GetMarkerColor(const char *style, Int_t index){
190  if ((Int_t) AliDrawStyle::fMarkerColors[style].size() <= index) {
191  return GetIntegerAt(style,index);
192  }
193  return AliDrawStyle::fMarkerColors[style][index];
194 }
195 
200 Float_t AliDrawStyle::GetMarkerSize(const char *style, Int_t index){
201  if ((Int_t) AliDrawStyle::fMarkerSize[style].size() <= index) {
202  return GetIntegerAt(style,index);
203  }
204  return AliDrawStyle::fMarkerSize[style][index];
205 }
206 
211 Int_t AliDrawStyle::GetFillColor(const char *style, Int_t index){
212  if ((Int_t) AliDrawStyle::fFillColors[style].size() <= index) {
213  return GetIntegerAt(style,index);
214  }
215  return AliDrawStyle::fFillColors[style][index];
216 }
217 
222 Float_t AliDrawStyle::GetLineWidth(const char *style, Int_t index){
223  if ((Int_t) AliDrawStyle::fLineWidth[style].size() <= index) {
224  return GetFloatAt(style,index);
225  }
226  return AliDrawStyle::fLineWidth[style][index];
227 }
228 
229 void AliDrawStyle::PrintLatexSymbols(Option_t */*option*/, TPRegexp& regExp){
230  //print latex symbols
231  typedef std::map<TString,TString>::const_iterator it_type;
232  for(it_type iterator = fLatexAlice.begin(); iterator != fLatexAlice.end(); ++iterator) {
233  if (regExp.Match(iterator->first.Data())==0) continue;
234  std::cout<<iterator->first << " " << iterator->second << "\n";
235  }
236 }
237 
238 void AliDrawStyle::PrintStyles(Option_t *option, TPRegexp& regExp){
239  //print latex symbols
240  typedef std::map<TString,TStyle*>::const_iterator it_type;
241  for(it_type iterator = fStyleAlice.begin(); iterator != fStyleAlice.end(); ++iterator) {
242  if (regExp.Match(iterator->first.Data())==0) continue;
243  if (option==NULL) std::cout << iterator->first << " " << iterator->second << "\n";
244  if (option!=NULL) {
245  iterator->second->Print(option);
246  if (TString(option).Contains("dump")) iterator->second->Dump();
247  }
248  }
249 }
250 
253 void AliDrawStyle::ApplyStyle(const char* styleName){
254  TStyle * style= fStyleAlice[styleName];
255  if (style==NULL){
256  ::Error("AliDrawStyle::ApplyStyle","Invalid style %s",styleName);
257  }else{
258  ::Info("AliDrawStyle::ApplyStyle","%s",styleName);
259  }
260  if (style) style->cd();
261 }
262 
263 
264 void AliDrawStyle::AddLatexSymbol(const char * symbolName, const char * symbolTitle){
265  fLatexAlice[symbolName]=symbolTitle;
266 }
267 
269  fLatexAlice["qpt"]="#it{q}/#it{p}_{T} (GeV/#it{c})^{-1}";
270  fLatexAlice["qpt0"]="#it{q}/#it{p}_{T}";
271  fLatexAlice["pt"]="#it{p}_{T} (GeV/#it{c}) ";
272  fLatexAlice["pt0"]="#it{p}_{T} ";
273  fLatexAlice["sqptmev"]="#sigma_{#it{q}/#it{p}_{T}} (MeV/#it{c})^{-1}";
274  fLatexAlice["pbpb502"]="Pb#font[122]{-}Pb #sqrt{#it{s}_{NN}} =5.02 TeV";
275  fLatexAlice["pp13"]="pp #sqrt{#it{s}} = 13 TeV ";
276  fLatexAlice["drphi"]="#Delta_{#it{r#phi}} (cm)";
277  fLatexAlice["srphi"]="#sigma_{#it{r#phi}} (cm)";
278 }
279 
281  fStyleAlice["figTemplate"]=RegisterDefaultStyleFigTemplate(kFALSE);
282  fStyleAlice["figTemplateGrey"]=RegisterDefaultStyleFigTemplate(kFALSE);
283  TStyle *style=RegisterDefaultStyleFigTemplate(kFALSE);
284  style->SetName("figTemplate2");
285  style->SetTitleXSize(TMath::Power(2,0.5)*style->GetTitleXSize());
286  style->SetTitleYSize(TMath::Power(2,0.5)*style->GetTitleYSize());
287  style->SetLabelSize(TMath::Power(2,0.5)*style->GetLabelSize("X"),"X");
288  style->SetLabelSize(TMath::Power(2,0.5)*style->GetLabelSize("Y"),"Y");
289  style->SetLabelSize(TMath::Power(2,0.5)*style->GetLabelSize("Z"),"Z");
290  fStyleAlice["figTemplate2"]=style;
291  style=RegisterDefaultStyleFigTemplate(kFALSE);
292  style->SetName("figTemplate3");
293  style->SetTitleXSize(TMath::Power(3,0.5)*style->GetTitleXSize());
294  style->SetTitleYSize(TMath::Power(3,0.5)*style->GetTitleYSize());
295  style->SetLabelSize(TMath::Power(3,0.5)*style->GetLabelSize("X"),"X");
296  style->SetLabelSize(TMath::Power(3,0.5)*style->GetLabelSize("Y"),"Y");
297  style->SetLabelSize(TMath::Power(3,0.5)*style->GetLabelSize("Z"),"Z");
298  fStyleAlice["figTemplate3"]=style;
299 }
300 
305  const Int_t fillColors[] = {kGray+1, kRed-10, kBlue-9, kGreen-8, kMagenta-9, kOrange-9,kCyan-8,kYellow-7, kBlack, kRed+1 }; // for systematic bands
306  const Int_t colors[] = {kBlack, kRed+1 , kBlue+1, kGreen+3, kMagenta+1, kOrange-1,kCyan+2,kYellow+2,kGray+1, kRed-10 };
307  const Int_t markers[] = {kFullCircle, kFullSquare,kOpenCircle,kOpenSquare,kOpenDiamond,kOpenCross,kFullCross,kFullDiamond,kFullStar,kOpenStar};
308 
309  (fMarkerStyles["figTemplate"])=std::vector<int>(10);
310  (fMarkerColors["figTemplate"])=std::vector<int>(10);
311  (fMarkerSize["figTemplate"])=std::vector<float>(10);
312  (fFillColors["figTemplate"])=std::vector<int>(10);
313  (fLineWidth["figTemplate"])=std::vector<float>(10);
314  (fLineColor["figTemplate"])=std::vector<float>(10);
315  (fLineStyle["figTemplate"])=std::vector<float>(10);
316  for (Int_t i=0;i<10; i++){
317  (fMarkerStyles["figTemplate"])[i]=markers[i];
318  (fMarkerColors["figTemplate"])[i]=colors[i];
319  (fMarkerSize["figTemplate"])[i]=1;
320  (fFillColors["figTemplate"])[i]=fillColors[i];
321  (fLineWidth["figTemplate"])[i]=0.5;
322  (fLineStyle["figTemplate"])[i]=i+1;
323  (fLineColor["figTemplate"])[i]=colors[i];
324  }
325  // style inspired by TRD performance paper
326  Int_t colorsTRD[12]={0};
327  const Int_t markersTRD[] = {kOpenSquare,kFullSquare, kOpenStar,kFullStar, kOpenCircle,kFullCircle, kOpenDiamond,kFullDiamond, kOpenCross,kFullCross };
328  const Float_t markerTRDSize[] = {1,1, 0.9,0.9, 1.4,1.4, 1.1,1.1, 1.2,1.2 };
329  colorsTRD[0]=TColor::GetColor("#0000DD");
330  colorsTRD[1]=TColor::GetColor("#00EE00");
331  colorsTRD[2]=TColor::GetColor("#FF0000");
332  colorsTRD[3]=TColor::GetColor("#00EEDD");
333  colorsTRD[4]=TColor::GetColor("#FFEE00");
334  colorsTRD[5]=TColor::GetColor("#FF00DD");
335  colorsTRD[6]=TColor::GetColor("#9999DD");
336  colorsTRD[7]=TColor::GetColor("#99EE99");
337  colorsTRD[8]=TColor::GetColor("#FF9999");
338  colorsTRD[9]=TColor::GetColor("#66AADD");
339  colorsTRD[10]=TColor::GetColor("#AAEE66");
340  colorsTRD[11]=TColor::GetColor("#FF66AA");
341  (fMarkerStyles["figTemplateTRD"])=std::vector<int>(10);
342  (fMarkerColors["figTemplateTRD"])=std::vector<int>(10);
343  (fMarkerSize["figTemplateTRD"])=std::vector<float>(10);
344  (fFillColors["figTemplateTRD"])=std::vector<int>(10);
345  (fLineWidth["figTemplateTRD"])=std::vector<float>(10);
346  (fLineStyle["figTemplateTRD"])=std::vector<float>(10);
347  (fMarkerStyles["figTemplateTRDPair"])=std::vector<int>(10);
348  (fMarkerColors["figTemplateTRDPair"])=std::vector<int>(10);
349  (fMarkerSize["figTemplateTRDPair"])=std::vector<float>(10);
350  (fFillColors["figTemplateTRDPair"])=std::vector<int>(10);
351  (fLineWidth["figTemplateTRDPair"])=std::vector<float>(10);
352  (fLineStyle["figTemplateTRDPair"])=std::vector<float>(10);
353  for (Int_t i=0; i<10; i++){
354  (fMarkerStyles["figTemplateTRD"])[i]=markersTRD[i];
355  (fMarkerColors["figTemplateTRD"])[i]=TColor::GetColorDark(colorsTRD[i]);
356  (fMarkerSize["figTemplateTRD"])[i]=markerTRDSize[i];
357  (fFillColors["figTemplateTRD"])[i]=fillColors[i];
358  (fLineWidth["figTemplateTRD"])[i]=0.5;
359 
360  (fMarkerStyles["figTemplateTRDPair"])[i]=markersTRD[i];
361  (fMarkerColors["figTemplateTRDPair"])[i]=TColor::GetColorDark(colorsTRD[i/2]);
362  (fMarkerSize["figTemplateTRDPair"])[i]=markerTRDSize[i];
363  (fFillColors["figTemplateTRDPair"])[i]=fillColors[i/2];
364  (fLineWidth["figTemplateTRDPair"])[i]=0.5;
365  }
366 
367 }
368 
371 // https://twiki.cern.ch/twiki/pub/ALICE/ALICERecommendationsResultPresentationText/figTemplate.C
374 TStyle* RegisterDefaultStyleFigTemplate(Bool_t grayPalette) {
375  TStyle * figStyle = new TStyle;
376  figStyle->Reset("Plain");
377  figStyle->SetOptTitle(0);
378  figStyle->SetOptStat(0);
379 
380  if(grayPalette) figStyle->SetPalette(8,0);
381  else figStyle->SetPalette(1);
382 
383  figStyle->SetCanvasColor(10);
384  figStyle->SetCanvasBorderMode(0);
385  figStyle->SetFrameLineWidth(1);
386  figStyle->SetFrameFillColor(kWhite);
387  figStyle->SetPadColor(10);
388  figStyle->SetPadTickX(1);
389  figStyle->SetPadTickY(1);
390  figStyle->SetPadBottomMargin(0.15);
391  figStyle->SetPadLeftMargin(0.15);
392  figStyle->SetHistLineWidth(1);
393  figStyle->SetHistLineColor(kRed);
394  figStyle->SetFuncWidth(2);
395  figStyle->SetFuncColor(kGreen);
396  figStyle->SetLineWidth(2);
397  figStyle->SetLabelSize(0.045,"xyz");
398  figStyle->SetLabelOffset(0.01,"y");
399  figStyle->SetLabelOffset(0.01,"x");
400  figStyle->SetLabelColor(kBlack,"xyz");
401  figStyle->SetTitleSize(0.05,"xyz");
402  figStyle->SetTitleOffset(1.25,"y");
403  figStyle->SetTitleOffset(1.2,"x");
404  figStyle->SetTitleFillColor(kWhite);
405  figStyle->SetTextSizePixels(26);
406  figStyle->SetTextFont(42);
407  figStyle->SetLegendBorderSize(0);
408  figStyle->SetLegendFillColor(kWhite);
409  figStyle->SetLegendFont(42);
410  return figStyle;
411 }
412 
418 
424 TString AliDrawStyle::ParseDeclaration(const char *inputDec, const char *propertyName) {
425  TString input(inputDec);
426  TPRegexp valPat(":.*;");
427  TString dVal = "";
428  Int_t index0 = input.Index(propertyName);
429  if (index0<0) return "";
430  dVal = TString(input(valPat,index0));
431  Int_t valLength = dVal.Index(';') - dVal.Index(':') -1;
432  return dVal(1,valLength);
433 }
434 
445 
472  Float_t AliDrawStyle::GetNamedTypeAt(const char *inputStr, Bool_t &status, int index, const char *propertyName, Int_t verbose, const char sep, const char *ignoreBrackets) {
473  TString inputTStr;
474  if(TString(propertyName) != TString("")) inputTStr = AliDrawStyle::ParseDeclaration(inputStr,propertyName);
475  else inputTStr = TString(inputStr);
476  Float_t res = -1.;
477  Int_t arg = 0, startIndex = 0;
478  if (TString(inputStr) == TString("")) {
479  ::Error("AliDrawStyle", "AliDrawStyle::GetNamedTypeAt(\"%s\", %d, \"%s\"). Options string should not be empty.", inputStr, index, propertyName);
480  status = kFALSE;
481  return res;
482  }
483  std::vector<TString> values;
484  for (Int_t i = 0; i <= index; i++) values.push_back(TString(""));
485 
486  for (Int_t i = 0; i <= inputTStr.Length(); i++) {
487  if (arg > index) break;
488  if (inputTStr(i) == TString(sep) || i == inputTStr.Length()) {
489  values[arg] = TString(inputTStr(startIndex, i - startIndex));
490  arg++;
491  startIndex = i + 1;
492  } else if (inputTStr(i) == TString(ignoreBrackets)[0]) {
493  i = inputTStr.Index(ignoreBrackets[1], i);
494  continue;
495  }
496  }
497 
498  if (index >= arg && index != 0) return AliDrawStyle::GetNamedTypeAt(inputStr, status, arg-1, propertyName, verbose, sep, ignoreBrackets); // keeping the last index for objects in case index doesn't exist.
499 
500  if (values[index].IsDec() || values[index].IsFloat()) {
501  if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::GetNamedTypeAt(\"%s\",%d,%d,\"%s\") was transformed in %f",inputStr,status,index,propertyName, values[index].Atof());
502  status = kTRUE;
503  return values[index].Atof();
504  }
505  else if (values[index].Contains("%") || values[index].Contains("px")) {
506  Float_t valF = AliDrawStyle::ConvertUnit(values[index].Data(),propertyName);
507  if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::GetNamedTypeAt(\"%s\",%d,%d,\"%s\") was transformed in %f",inputStr,status,index,propertyName, valF);
508  if (valF != -1.0) status = kTRUE;
509  return valF;
510  }
511  else if (values[index].Contains("rgb") || values[index].Contains("#")) {
512  Int_t valI = AliDrawStyle::ConvertColor(values[index]);
513  if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::GetNamedTypeAt(\"%s\",%d,%d,\"%s\") was transformed in %d",inputStr,status,index,propertyName, valI);
514  if (valI != -1) status = kTRUE;
515  return (Float_t) valI;
516  }
517  else {
518  status = kFALSE;
519  if (verbose == 4) ::Error("AliDrawStyle", "Something went wrong in AliDrawStyle::GetNamedTypeAt(\"%s\",%d,%d,\"%s\"). Result string is \"%s\"",inputStr,status,index,propertyName, values[index].Data());
520  return -1.0;
521  }
522 
523  return -1.0;
524 }
525 
539 Float_t AliDrawStyle::PixelsToFloat_t(const char *value, const char *option, Int_t verbose) {
540  TString valStr = TString(value);
541  TString optionT = TString(option);
542  Float_t val = (Float_t) -1.0;
543 
544  if (optionT.Contains("marker")) {
545  val = (Float_t) TString(valStr(0, valStr.Length() - 2)).Atof() / 8;
546  if (verbose == 4)
547  ::Info("AliDrawStyle", "AliDrawStyle::PixelsToFloat_t(\"%s\",\"%s\") transformed into %f.",value, option,val);
548  return val;
549  }
550 
551  if (gPad == nullptr) {
552  ::Error("AliDrawStyle", "AliDrawStyle::PixelsToFloat_t(\"%s\",\"%s\"). For converting of pixels you must have a TPad object.", value, option);
553  return (Float_t) -1.0;
554  }
555  else {
556  if (optionT.Contains("top") || optionT.Contains("bottom")) {
557  val = (Float_t) TString(valStr(0, valStr.Length() - 2)).Atof() / gPad->GetWh();
558  } else if (optionT.Contains("left") || optionT.Contains("right")) {
559  val = (Float_t) TString(valStr(0, valStr.Length() - 2)).Atof() / gPad->GetWw();
560  } else if (optionT.Contains("border")) {
561  val = (Float_t) TString(valStr(0, valStr.Length() - 2)).Atof();
562  }
563  if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::PixelsToFloat_t(\"%s\",\"%s\") transformed into %f. Calculations based on pad - %s", value, option, val, gPad->GetName());
564  }
565 
566  return val;
567 }
568 
573 Float_t AliDrawStyle::PercentToFloat_t(const char *value, Int_t verbose) {
574  TString valStr = TString(value);
575  Float_t val = (Float_t) TString(valStr(0, valStr.Length() - 1)).Atof() / 100;
576  if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::PercentToFloat_t(%s) transformed into %f", valStr.Data(), val);
577  return val;
578 }
579 
588 Float_t AliDrawStyle::ConvertUnit(const char *inputValues, const char *option, Int_t verbose) {
589  TString value = TString(inputValues);
590  if (value.Contains("px") && TString(option) != TString())
591  return AliDrawStyle::PixelsToFloat_t(value, option, verbose);
592  else if (value.Contains("%"))
593  return AliDrawStyle::PercentToFloat_t(value, verbose);
594  else if (value.IsFloat()) return (Float_t) value.Atof();
595  if (verbose == 4) ::Error("AliDrawStyle", "In AliDrawStyle::ConvertUnit(%s,%s) occured the error.", inputValues, option);
596  return (Float_t) -1.0;
597 }
598 
603 
612 Int_t AliDrawStyle::RgbToColor_t(const char *inputString, Int_t verbose) {
613  TString rgbValuesStr = "";
614  TPRegexp rgbPattern("[(].*[)]");
615  TString inputColor = TString(inputString);
616  if (inputColor.CountChar(',') != 2) {
617  ::Error("AliDrawStyle", "AliDrawStyle::RgbToColor_t(%s) - rgb should be rgb(Float_t, Float_t, Float_t)",
618  inputColor.Data());
619  return -1;
620  }
621  rgbValuesStr = TString(inputColor(rgbPattern)).ReplaceAll("(", "");
622  rgbValuesStr = rgbValuesStr.ReplaceAll(")", "");
623  TObjArray *rgbValues = rgbValuesStr.Tokenize(",");
624  if (TString(rgbValues->At(0)->GetName()).IsDec() && TString(rgbValues->At(1)->GetName()).IsDec() &&
625  TString(rgbValues->At(2)->GetName()).IsDec()) {
626  Int_t r = TString(rgbValues->At(0)->GetName()).Atoi();
627  Int_t g = TString(rgbValues->At(1)->GetName()).Atoi();
628  Int_t b = TString(rgbValues->At(2)->GetName()).Atoi();
629  if (verbose == 4)
630  ::Info("AliDrawStyle", "AliDrawStyle::RgbToColor_t(%s) transformed into "
631  "TColor::GetColor(%d, %d, %d) and returned %d", inputColor.Data(), r, g, b,
632  TColor::GetColor(r, g, b));
633  return TColor::GetColor(r, g, b);
634  }
635  else if (TString(rgbValues->At(0)->GetName()).IsFloat() && TString(rgbValues->At(1)->GetName()).IsFloat() &&
636  TString(rgbValues->At(2)->GetName()).IsFloat()) {
637  Float_t r = (Float_t) TString(rgbValues->At(0)->GetName()).Atof();
638  Float_t g = (Float_t) TString(rgbValues->At(1)->GetName()).Atof();
639  Float_t b = (Float_t) TString(rgbValues->At(2)->GetName()).Atof();
640  if (verbose == 4) ::Info("AliDrawStyle","AliDrawStyle::RgbToColor_t(%s) transformed into "
641  "TColor::GetColor(%f, %f, %f) and returned %d", inputColor.Data(),r,g,b,
642  TColor::GetColor(r, g, b));
643  return TColor::GetColor(r, g, b);
644  }
645  if (verbose == 4)
646  ::Warning("AliDrawStyle", "In AliDrawStyle::RgbToColor_t(%s) something went wrong", inputString);
647  return -1;
648 }
649 
654 Int_t AliDrawStyle::HexToColor_t(const char *inputString, Int_t verbose) {
655  TString inputColor = TString(inputString);
656  if (verbose == 4) ::Info("AliDrawStyle","AliDrawStyle::HexToColor_t(%s) transformed into "
657  "TColor::GetColor(%s) and returned %d", inputColor.Data(), inputColor.Data(),
658  TColor::GetColor(inputColor.Data()));
659  return TColor::GetColor(inputColor.Data());
660 }
661 
670 
679 Int_t AliDrawStyle::ConvertColor(const char *inputString, Int_t verbose) {
680  TString value = TString(inputString);
681  Int_t color;
682  if (value(0,3) == TString("rgb"))
683  color = AliDrawStyle::RgbToColor_t(value, verbose);
684  else if (value(0) == TString("#"))
685  color = AliDrawStyle::HexToColor_t(value, verbose);
686  else if (value.IsDec())
687  color = value.Atoi();
688  else {
689  ::Error("AliDrawStyle", "AliDrawStyle::ConvertColor(%s) - something wrong with colors", value.Data());
690  return -1;
691  }
692  if (verbose == 4) ::Info("AliDrawStyle","AliDrawStyle::ConvertColor(%s) transformed into "
693  "returned %d", inputString,color);
694  return color;
695 }
696 
710 //TODO: does it look like godness function? refactor? @Boris
711 //TODO: perhaps I should combine {TString elementID, TString classID, TString objectID, TString localStyle} to the array? @Boris
712 Float_t AliDrawStyle::PrepareValue(const char* styleName, TString propertyName, TString elementID, TString classID, TString objectID, TString localStyle, Bool_t &status, Int_t objNum, Int_t verbose) {
713  TString property = "";
714  TString cProperty = "";
715  Int_t hisNum = -1;
716  status = kFALSE;
717  Float_t value;
718  if (localStyle.Contains(propertyName.Data()) && (propertyName.Contains("size") || propertyName.Contains("margin"))) {
719  property = localStyle;
720  hisNum = 0;
721  cProperty = propertyName;
722  }
723  else if (localStyle.Contains(propertyName.Data())) {
724  property = AliDrawStyle::ParseDeclaration(localStyle.Data(), propertyName.Data());
725  hisNum = 0;
726  cProperty = "";
727  }
728  else if (propertyName.Contains("size") || propertyName.Contains("margin")) {
729  property = AliDrawStyle::GetValue(styleName, "", elementID, classID, objectID, "", verbose);
730  hisNum = objNum;
731  cProperty = propertyName + ":";
732  if (!property.Contains(cProperty)) {
733  return -1.;
734  }
735  }
736  else {
737  property = AliDrawStyle::GetValue(styleName, propertyName, elementID, classID, objectID, localStyle, verbose);
738  hisNum = objNum;
739  cProperty = "";
740  if (property == TString("")) return -1.;
741  }
742 
743  value = AliDrawStyle::GetNamedTypeAt(property.Data(), status, hisNum, cProperty, verbose);
744 
745  if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::PrepareValue(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%d) status is %d and returned value is %f", styleName, propertyName.Data(), elementID.Data(), classID.Data(), objectID.Data(), localStyle.Data(), objNum, status, value);
746  if (status) return value;
747 
748  return -1.0;
749 }
750 
751 //TODO: add test for this @Boris
757 TObjArray *AliDrawStyle::ReadCssString(TString inputCSS, TObjArray *cssArray, Int_t verbose) {
758  while (inputCSS.Index("*/") > 0) {
759  inputCSS = TString(inputCSS(0, inputCSS.Index("/*"))) + TString(inputCSS(inputCSS.Index("*/")+2, inputCSS.Length()));
760  }
761  inputCSS.ReplaceAll("\n", ""); // check performance and implement better variant;
762  TObjArray *tokenArray = inputCSS.Tokenize("{}"); //assuming we can not use {} symbols in the style IDS
763  Int_t entries = tokenArray->GetEntries();
764  if (cssArray==nullptr) {
765  cssArray = new TObjArray(entries / 2);
766  }
767  if (verbose == 4)
768  ::Info("AliDrawStyle::ReadCSSString","In input CSS string %s was parsed to:\n", inputCSS.Data());
769  for (Int_t i = 0; i < entries; i += 2) {
770  if (i + 1 >= entries) continue;
771  TString selector = tokenArray->At(i)->GetName();
772  TString declaration = tokenArray->At(i + 1)->GetName();
773  if (verbose == 4)
774  ::Info("selector: %s\ndeclaration: %s\n", selector.Data(), declaration.Data());
775  cssArray->AddLast(new TNamed(selector.Data(), declaration.Data()));
776  }
777  return cssArray;
778 }
779 
784 TObjArray *AliDrawStyle::ReadCSSFile(const char * inputName, TObjArray * cssArray, Int_t verbose) {
785  TString expInputName(inputName);
786  if (gSystem->ExpandPathName(expInputName)) {
787  ::Error("AliDrawStyle::ReadCSSFile", "Cannot expand some variables in %s", inputName);
788  return nullptr;
789  }
790  if (gSystem->AccessPathName(expInputName.Data())) {
791  ::Error("AliDrawStyle::ReadCSSFile", "File %s doesn't exist", expInputName.Data());
792  return nullptr;
793  }
794  std::ifstream cssFp(expInputName.Data());
795  std::stringstream buf;
796  buf << cssFp.rdbuf();
797  TString inputCSS = buf.str();
798  return AliDrawStyle::ReadCssString(inputCSS, cssArray, verbose);
799 }
800 
805 void AliDrawStyle::WriteCSSFile(TObjArray * cssArray, const char * outputName, std::fstream *pCssOut) {
806 
807  if (pCssOut == nullptr) {
808  pCssOut=new std::fstream;
809  pCssOut->open(outputName, std::ios_base::out|std::ios_base::trunc);
810  }
811  std::fstream &cssOut = *pCssOut;
812  for (Int_t i=0;i<cssArray->GetEntries();i++) {
813  TObject *object = cssArray->At(i);
814  if (object->InheritsFrom("TObjArray")) {
815  AliDrawStyle::WriteCSSFile((TObjArray*)object, nullptr, pCssOut);
816  }else {
817  cssOut << object->GetName();
818  cssOut << "{";
819  cssOut << object->GetTitle();
820  cssOut << "}";
821  }
822  }
823  cssOut<<std::flush;
824  if (outputName!=nullptr) {
825  pCssOut->close();
826  delete pCssOut;
827  }
828 }
829 //TODO: combine ElementSearch, ClassSearch, ObjectSearch into one function
835 Bool_t AliDrawStyle::ElementSearch(const TString selector, const TString elementID, Int_t verbose) {
836  if (selector == TString("")) {
837  ::Error("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\") selector should not be empty", selector.Data(), elementID.Data());
838  return kFALSE;
839  }
840  //impossible for us
841  if (elementID == TString("")) {
842  if (verbose == 4)
843  ::Info("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\") elementID is empty, any element is fine", selector.Data(), elementID.Data());
844  return kTRUE;
845  }
846  TString elementFromSelector = "";
847  Int_t finish = -1;
848  if(selector.Index('#') >= 0) finish = selector.Index('#');
849  if(selector.Index('.') >= 0) finish = selector.Index('.');
850 
851  if (finish == 0) return kTRUE;
852  else if (finish > 0) elementFromSelector = selector(0, finish);
853  else elementFromSelector = selector;
854  if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\"). Selector was transformed to %s", selector.Data(), elementID.Data(), elementFromSelector.Data());
855 
856  if (elementFromSelector.Index('*') >= 0) {
857  elementFromSelector = elementFromSelector.ReplaceAll("*", ".*");
858  TPRegexp elemPattern(elementFromSelector);
859  if (elementID(elemPattern) == elementID || TClass(elementID.Data()).InheritsFrom(TString(elementFromSelector(0,elementFromSelector.Index("."))).Data())) {
860  if (verbose == 4)
861  ::Info("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\") was successful", selector.Data(), elementID.Data());
862  return kTRUE;
863  }
864  else {
865  if (verbose == 4)
866  ::Info("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\") was unsuccessful", selector.Data(), elementID.Data());
867  return kFALSE;
868  }
869  }
870 
871  if (elementFromSelector == elementID) {
872  if (verbose == 4)
873  ::Info("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\") was successful", selector.Data(), elementID.Data());
874  return kTRUE;
875  }
876  if (verbose == 4)
877  ::Info("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\") was unsuccessful", selector.Data(), elementID.Data());
878  return kFALSE;
879 }
880 
886 Bool_t AliDrawStyle::ClassSearch(const TString selector, const TString classID, Int_t verbose) {
887  if (selector == TString("")) {
888  ::Error("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\") selector should not be empty", selector.Data(), classID.Data());
889  return kFALSE;
890  }
891  if (classID == TString("")) {
892  if (verbose == 4)
893  ::Info("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\") classID is empty, any class is fine", selector.Data(), classID.Data());
894  return kTRUE;
895  }
896 
897  TPRegexp classPattern("[.].*#|[.].*");
898  TString classFromSelector = "";
899 
900  classFromSelector = selector(classPattern);
901  if (classFromSelector == TString(""))
902  return kTRUE;
903 
904  if(classFromSelector.Index('#') >= 0) classFromSelector = classFromSelector(1,classFromSelector.Length() - 2);
905  else classFromSelector = classFromSelector(1,classFromSelector.Length());
906  if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\"). Selector was transformed to %s", selector.Data(), classID.Data(), classFromSelector.Data());
907 
908  //for multi classes
909  TObjArray *classIDs = classID.Tokenize(",");
910  Int_t nC = classIDs->GetEntriesFast();;
911  TString tempClassID = "";
912 
913  for (Int_t i = 0; i < nC; i++) {
914  tempClassID = classIDs->At(i)->GetName();
915  if (classFromSelector.Index('*') >= 0) {
916  classFromSelector = classFromSelector.ReplaceAll("*", ".*");
917  TPRegexp classSelPattern(classFromSelector);
918  if (tempClassID(classSelPattern) == tempClassID) {
919  if (verbose == 4)
920  ::Info("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\") was successful", selector.Data(), classID.Data());
921  return kTRUE;
922  }
923  else {
924  ::Info("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\") was unsuccessful", selector.Data(), classID.Data());
925  return kFALSE;
926  }
927  }
928 
929  if (classFromSelector == tempClassID) {
930  if (verbose == 4)
931  ::Info("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\") was successful", selector.Data(), classID.Data());
932  return kTRUE;
933  }
934  }
935  if (verbose == 4)
936  ::Info("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\") was unsuccessful", selector.Data(), classID.Data());
937  return kFALSE;
938 }
939 
945 Bool_t AliDrawStyle::ObjectSearch(const TString selector, const TString objectID, Int_t verbose) {
946  if (selector == TString("")) {
947  ::Error("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\") selector should not be empty", selector.Data(), objectID.Data());
948  return kFALSE;
949  }
950  if (objectID == TString("")) {
951  if (verbose == 4)
952  ::Info("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\") objectID is empty.", selector.Data(), objectID.Data());
953  return kTRUE;
954  }
955 
956  TPRegexp objectPattern("[#].*");
957  TString objectFromSelector = "";
958 
959  objectFromSelector = selector(objectPattern);
960  if (objectFromSelector == TString(""))
961  return kTRUE;
962 
963  objectFromSelector = objectFromSelector(1,objectFromSelector.Length());
964  if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\"). Selector was transformed to %s", selector.Data(), objectID.Data(), objectFromSelector.Data());
965 
966  if (objectFromSelector.Index('*') >= 0) {
967  objectFromSelector = objectFromSelector.ReplaceAll("*", ".*");
968  TPRegexp objectSelPattern(objectFromSelector);
969  if (objectID(objectSelPattern) == objectID) {
970  if (verbose == 4)
971  ::Info("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\") was successful", selector.Data(), objectID.Data());
972  return kTRUE;
973  }
974  else {
975  if (verbose == 4)
976  ::Info("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\") was unsuccessful", selector.Data(), objectID.Data());
977  return kFALSE;
978  }
979  }
980 
981  if (objectFromSelector == objectID) {
982  if (verbose == 4)
983  ::Info("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\") was successful", selector.Data(), objectID.Data());
984  return kTRUE;
985  }
986  if (verbose == 4)
987  ::Info("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\") was unsuccessful", selector.Data(), objectID.Data());
988  return kFALSE;
989 }
990 
997 
1006 Bool_t AliDrawStyle::IsSelected(TString selectors, const TString elementID, const TString classID, const TString objectID, Int_t verbose) {
1007  if (elementID == TString("") && classID == TString("") && objectID == TString("")) {
1008  if (verbose == 4)
1009  ::Info("AliDrawStyle", "AliDrawStyle::IsSelected(\"%s\", \"%s\", \"%s\", \"%s\") returned kFALSE. All elements are empty.", \
1010  selectors.Data(), elementID.Data(), classID.Data(), objectID.Data());
1011  return kFALSE;
1012  }
1013  Ssiz_t fromStart1 = 0;
1014  Ssiz_t fromStart = 0;
1015  TString subSelectors = "";
1016  TString selector = "";
1017  selectors = selectors.ReplaceAll("\n", "");
1018  while (selectors.Tokenize(subSelectors, fromStart1, " \t")) {
1019  fromStart = 0;
1020  while (subSelectors.Tokenize(selector, fromStart, ", ")) {
1021  selector = selector.Strip(TString::kBoth, ' ');
1022  if (ElementSearch(selector, elementID, verbose) && ClassSearch(selector, classID, verbose) && ObjectSearch(selector, objectID, verbose)) {
1023  if (verbose == 4)
1024  ::Info("AliDrawStyle", "AliDrawStyle::IsSelected(\"%s\", \"%s\", \"%s\", \"%s\") returned kTRUE", \
1025  selectors.Data(), elementID.Data(), classID.Data(), objectID.Data());
1026  return kTRUE;
1027  }
1028  }
1029  }
1030  if (verbose == 4)
1031  ::Info("AliDrawStyle", "AliDrawStyle::IsSelected(\"%s\", \"%s\", \"%s\", \"%s\") returned kFALSE", \
1032  selectors.Data(), elementID.Data(), classID.Data(), objectID.Data());
1033  return kFALSE;
1034 }
1035 
1044 
1070 TString AliDrawStyle::GetValue(const char *styleName, TString propertyName, TString elementID, TString classID, TString objectID, TString localStyle, Int_t verbose) {
1071  TString value = "";
1072  if (localStyle.Contains(propertyName.Data()) && propertyName != TString("")) {
1073  value = AliDrawStyle::ParseDeclaration(localStyle.Data(), propertyName.Data());
1074  if (verbose == 4) ::Info("AliDrawStyle","AliDrawStyle::GetValue(\"%s\", \"%s\", \"%s\", \"%s\", \"%s\") was found in local property and was transformed into \"%s\"", styleName, propertyName.Data(), elementID.Data(), classID.Data(), objectID.Data(), value.Data());
1075  return value;
1076  }
1077 
1078  if (fCssStyleAlice[styleName] == nullptr || (elementID == TString("") && classID == TString("") && objectID == TString(""))) return "";
1079 
1080  TString actProperty = "";
1081  Int_t entries = fCssStyleAlice[styleName]->GetEntriesFast();
1082  TString declaration = "";
1083 
1084  for(Int_t i = 0; i < entries; i++) {
1085  if (AliDrawStyle::IsSelected(TString(fCssStyleAlice[styleName]->At(i)->GetName()),
1086  elementID, classID, objectID, verbose)) {
1087  if (propertyName == "") value = fCssStyleAlice[styleName]->At(i)->GetTitle();
1088  else value = AliDrawStyle::ParseDeclaration(fCssStyleAlice[styleName]->At(i)->GetTitle(), propertyName.Data());
1089  if (value != "") actProperty = value.Strip(TString::kBoth, ' ');
1090  }
1091  }
1092  if (verbose == 4 && propertyName != TString("")) {
1093  if (value != TString("")) ::Info("AliDrawStyle","AliDrawStyle::GetValue(\"%s\", \"%s\", \"%s\", \"%s\", \"%s\") was transformed into \"%s\"", styleName, propertyName.Data(), elementID.Data(), classID.Data(), objectID.Data(), actProperty.Data());
1094  else ::Info("AliDrawStyle","AliDrawStyle::GetValue(\"%s\", \"%s\", \"%s\", \"%s\", \"%s\") property not found in css file", styleName, propertyName.Data(), elementID.Data(), classID.Data(), objectID.Data());
1095  }
1096  return actProperty;
1097 }
1098 
1102 
1106 void AliDrawStyle::TGraphApplyStyle(const char* styleName, TGraph *cGraph, Int_t objNum, Int_t verbose) {
1107 
1108  AliDrawStyle::TObjectApplyStyle(styleName, cGraph, objNum, verbose);
1109 
1110  Bool_t status = kFALSE;
1111  TString elementID = "";
1112  TString classID = "";
1113  TString objectID = "";
1114  TString property = "";
1115  TString localStyle = "";
1116  Int_t valueI = 0;
1117  Float_t valueF;
1118 
1119  AliDrawStyle::GetIds(cGraph, elementID, classID, objectID, localStyle, verbose);
1120 
1121  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("axis-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1122  if (status) {
1123  cGraph->GetXaxis()->SetAxisColor((Color_t) valueI);
1124  cGraph->GetYaxis()->SetAxisColor((Color_t) valueI);
1125  }
1126 
1127  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("ndivisions"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1128  if (status) {
1129  cGraph->GetXaxis()->SetNdivisions(valueI);
1130  cGraph->GetYaxis()->SetNdivisions(valueI);
1131  }
1132 
1133  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("x-ndivisions"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1134  if (status)
1135  cGraph->GetXaxis()->SetNdivisions(valueI);
1136 
1137  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("y-ndivisions"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1138  if (status)
1139  cGraph->GetYaxis()->SetNdivisions(valueI);
1140 
1141  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("label-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1142  if (status) {
1143  cGraph->GetXaxis()->SetLabelColor((Color_t) valueI);
1144  cGraph->GetYaxis()->SetLabelColor((Color_t) valueI);
1145  }
1146  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("label-font"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1147  if (status) {
1148  cGraph->GetXaxis()->SetLabelFont((Style_t) valueI);
1149  cGraph->GetYaxis()->SetLabelFont((Style_t) valueI);
1150  }
1151 
1152  valueF = AliDrawStyle::PrepareValue(styleName, TString("label-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1153  if (status) {
1154  cGraph->GetXaxis()->SetLabelSize(valueF);
1155  cGraph->GetYaxis()->SetLabelSize(valueF);
1156  }
1157 
1158  valueF = AliDrawStyle::PrepareValue(styleName, TString("label-offset"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1159  if (status) {
1160  cGraph->GetXaxis()->SetLabelOffset(valueF);
1161  cGraph->GetYaxis()->SetLabelOffset(valueF);
1162  }
1163 
1164  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("title-font"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1165  if (status) {
1166  cGraph->GetXaxis()->SetTitleFont((Style_t) valueI);
1167  cGraph->GetYaxis()->SetTitleFont((Style_t) valueI);
1168  }
1169 
1170  valueF = AliDrawStyle::PrepareValue(styleName, TString("title-offset"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1171  if (status) {
1172  cGraph->GetXaxis()->SetTitleOffset(valueF);
1173  cGraph->GetYaxis()->SetTitleOffset(valueF);
1174  }
1175 
1176  valueF = AliDrawStyle::PrepareValue(styleName, TString("title-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1177  if (status) {
1178  cGraph->GetXaxis()->SetTitleSize(valueF);
1179  cGraph->GetYaxis()->SetTitleSize(valueF);
1180  }
1181 }
1182 
1186 
1190 void AliDrawStyle::TH1ApplyStyle(const char *styleName, TH1 *cHis, Int_t objNum, Int_t verbose) {
1191 
1192  AliDrawStyle::TObjectApplyStyle(styleName, cHis, objNum, verbose);
1193 
1194  Bool_t status = kFALSE;
1195  TString elementID = "";
1196  TString classID = "";
1197  TString objectID = "";
1198  TString property = "";
1199  TString localStyle = "";
1200  Int_t valueI = 0;
1201  Float_t valueF;
1202 
1203  AliDrawStyle::GetIds(cHis, elementID, classID, objectID, localStyle, verbose);
1204 
1205  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("axis-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1206  if (status) cHis->SetAxisColor((Color_t) valueI);
1207 
1208  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("ndivisions"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1209  if (status) {
1210  cHis->GetXaxis()->SetNdivisions(valueI);
1211  cHis->GetYaxis()->SetNdivisions(valueI);
1212  }
1213 
1214  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("x-ndivisions"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1215  if (status)
1216  cHis->GetXaxis()->SetNdivisions(valueI);
1217 
1218  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("y-ndivisions"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1219  if (status)
1220  cHis->GetYaxis()->SetNdivisions(valueI);
1221 
1222  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("label-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1223  if (status) cHis->SetLabelColor((Color_t) valueI, "xyz");
1224 
1225  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("Xlabel-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1226  if (status) cHis->SetLabelColor((Color_t) valueI, "X");
1227 
1228  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("Ylabel-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1229  if (status) cHis->SetLabelColor((Color_t) valueI, "Y");
1230 
1231  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("Zlabel-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1232  if (status) cHis->SetLabelColor((Color_t) valueI, "Y");
1233 
1234  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("label-font"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1235  if (status) cHis->SetLabelFont((Style_t) valueI, "xyz");
1236 
1237  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("Xlabel-font"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1238  if (status) cHis->SetLabelFont((Style_t) valueI, "X");
1239 
1240  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("Ylabel-font"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1241  if (status) cHis->SetLabelFont((Style_t) valueI, "Y");
1242 
1243  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("Zlabel-font"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1244  if (status) cHis->SetLabelFont((Style_t) valueI, "Z");
1245 
1246  valueF = AliDrawStyle::PrepareValue(styleName, TString("label-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1247  if (status) cHis->SetLabelSize(valueF, "xyz");
1248 
1249  valueF = AliDrawStyle::PrepareValue(styleName, TString("Xlabel-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1250  if (status) cHis->SetLabelSize(valueF, "X");
1251 
1252  valueF = AliDrawStyle::PrepareValue(styleName, TString("Ylabel-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1253  if (status) cHis->SetLabelSize(valueF, "Y");
1254 
1255  valueF = AliDrawStyle::PrepareValue(styleName, TString("Zlabel-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1256  if (status) cHis->SetLabelSize(valueF, "Z");
1257 
1258  valueF = AliDrawStyle::PrepareValue(styleName, TString("label-offset"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1259  if (status) cHis->SetLabelOffset(valueF);
1260 
1261  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("title-font"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1262  if (status) cHis->SetTitleFont((Style_t) valueI);
1263 
1264  valueF = AliDrawStyle::PrepareValue(styleName, TString("title-offset"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1265  if (status) cHis->SetTitleOffset(valueF, "xyz");
1266 
1267  valueF = AliDrawStyle::PrepareValue(styleName, TString("Xtitle-offset"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1268  if (status) cHis->SetTitleOffset(valueF, "X");
1269 
1270  valueF = AliDrawStyle::PrepareValue(styleName, TString("Ytitle-offset"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1271  if (status) cHis->SetTitleOffset(valueF, "Y");
1272 
1273  valueF = AliDrawStyle::PrepareValue(styleName, TString("Ztitle-offset"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1274  if (status) cHis->SetTitleOffset(valueF, "Z");
1275 
1276  valueF = AliDrawStyle::PrepareValue(styleName, TString("title-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1277  if (status) cHis->SetTitleSize(valueF, "xyz");
1278 
1279  valueF = AliDrawStyle::PrepareValue(styleName, TString("Xtitle-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1280  if (status) cHis->SetTitleSize(valueF, "X");
1281 
1282  valueF = AliDrawStyle::PrepareValue(styleName, TString("Ytitle-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1283  if (status) cHis->SetTitleSize(valueF, "Y");
1284 
1285  valueF = AliDrawStyle::PrepareValue(styleName, TString("Ztitle-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1286  if (status) cHis->SetTitleSize(valueF, "Z");
1287 
1288  //TODO: how to make it not only for TF1? @Boris
1289  for (Int_t i = 0; i < cHis->GetListOfFunctions()->GetEntries(); i++) {
1290  AliDrawStyle::TObjectApplyStyle(styleName, (TF1 *) cHis->GetListOfFunctions()->At(i), objNum, verbose);
1291  }
1292 
1293 }
1294 
1298 
1303 void AliDrawStyle::TF1ApplyStyle(const char *styleName, TF1 *cFunc, Int_t objNum, Int_t verbose) {
1304 
1305  AliDrawStyle::TObjectApplyStyle(styleName, cFunc, objNum, verbose);
1306 
1307  Bool_t status = false;
1308  TString elementID = "";
1309  TString classID = "";
1310  TString objectID = "";
1311  TString property = "";
1312  TString localStyle = "";
1313  Int_t valueI = 0;
1314 
1315  AliDrawStyle::GetIds(cFunc, elementID, classID, objectID, localStyle, verbose);
1316 
1317  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("axis-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1318  if (status) {
1319  cFunc->GetXaxis()->SetAxisColor((Color_t) valueI);
1320  cFunc->GetYaxis()->SetAxisColor((Color_t) valueI);
1321  if (cFunc->GetZaxis()) cFunc->GetZaxis()->SetAxisColor((Color_t) valueI);
1322  }
1323 
1324  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("ndivisions"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1325  if (status) {
1326  cFunc->GetXaxis()->SetNdivisions(valueI);
1327  cFunc->GetYaxis()->SetNdivisions(valueI);
1328  }
1329 
1330  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("x-ndivisions"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1331  if (status)
1332  cFunc->GetXaxis()->SetNdivisions(valueI);
1333 
1334  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("y-ndivisions"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1335  if (status)
1336  cFunc->GetYaxis()->SetNdivisions(valueI);
1337 
1338  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("label-font"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1339  if (status) {
1340  cFunc->GetXaxis()->SetLabelFont((Style_t) valueI);
1341  cFunc->GetYaxis()->SetLabelFont((Style_t) valueI);
1342  if (cFunc->GetZaxis()) cFunc->GetZaxis()->SetLabelFont((Style_t) valueI);
1343  }
1344 
1345  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("label-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1346  if (status) {
1347  cFunc->GetXaxis()->SetLabelSize(valueI);
1348  cFunc->GetYaxis()->SetLabelSize(valueI);
1349  if (cFunc->GetZaxis()) cFunc->GetZaxis()->SetLabelSize(valueI);
1350  }
1351 
1352  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("label-offset"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1353  if (status) {
1354  cFunc->GetXaxis()->SetLabelOffset(valueI);
1355  cFunc->GetYaxis()->SetLabelOffset(valueI);
1356  if (cFunc->GetZaxis()) cFunc->GetZaxis()->SetLabelOffset(valueI);
1357  }
1358 
1359  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("title-font"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1360  if (status) {
1361  cFunc->GetXaxis()->SetTitleFont((Style_t) valueI);
1362  cFunc->GetYaxis()->SetTitleFont((Style_t) valueI);
1363  if (cFunc->GetZaxis()) cFunc->GetZaxis()->SetTitleFont((Style_t) valueI);
1364  }
1365 
1366  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("title-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1367  if (status) {
1368  cFunc->GetXaxis()->SetTitleSize(valueI);
1369  cFunc->GetYaxis()->SetTitleSize(valueI);
1370  if (cFunc->GetZaxis()) cFunc->GetZaxis()->SetTitleSize(valueI);
1371  }
1372 
1373  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("title-offset"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1374  if (status) {
1375  cFunc->GetXaxis()->SetTitleOffset(valueI);
1376  cFunc->GetYaxis()->SetTitleOffset(valueI);
1377  if (cFunc->GetZaxis()) cFunc->GetZaxis()->SetTitleOffset(valueI);
1378  }
1379 }
1380 
1386 void AliDrawStyle::TLegendApplyStyle(const char *styleName, TLegend *cLegend, Int_t objNum, Int_t verbose) {
1387  Bool_t status = false;
1388  TString elementID = "";
1389  TString classID = "";
1390  TString objectID = "";
1391  TString property = "";
1392  TString localStyle = "";
1393  Int_t valueI;
1394  Float_t valueF;
1395  Double_t valueD;
1396 
1397  AliDrawStyle::GetIds(cLegend, elementID, classID, objectID, localStyle, verbose);
1398 
1399  valueF = AliDrawStyle::PrepareValue(styleName, TString("column-separation"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1400  if (status) cLegend->SetColumnSeparation(valueF);
1401 
1402  valueF = AliDrawStyle::PrepareValue(styleName, TString("margin"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1403  if (status) cLegend->SetMargin(valueF);
1404 
1405  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("ncolumns"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1406  if (status) cLegend->SetNColumns(valueI);
1407 
1408  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("border-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1409  if (status) cLegend->SetBorderSize(valueI);
1410 
1411  valueD = (Double_t) AliDrawStyle::PrepareValue(styleName, TString("corner-radius"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1412  if (status) cLegend->SetCornerRadius(valueD);
1413 
1414  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("shadow-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1415  if (status) cLegend->SetShadowColor(valueI);
1416 
1417  valueD = (Double_t) AliDrawStyle::PrepareValue(styleName, TString("x1-ndc"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1418  if (status) cLegend->SetX1NDC(valueD);
1419 
1420  valueD = (Double_t) AliDrawStyle::PrepareValue(styleName, TString("x2-ndc"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1421  if (status) cLegend->SetX2NDC(valueD);
1422 
1423  valueD = (Double_t) AliDrawStyle::PrepareValue(styleName, TString("y1-ndc"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1424  if (status) cLegend->SetY1NDC(valueD);
1425 
1426  valueD = (Double_t) AliDrawStyle::PrepareValue(styleName, TString("y2-ndc"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1427  if (status) cLegend->SetY2NDC(valueD);
1428 
1429  valueD = (Double_t) AliDrawStyle::PrepareValue(styleName, TString("x1"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1430  if (status) cLegend->SetX1(valueD);
1431 
1432  valueD = (Double_t) AliDrawStyle::PrepareValue(styleName, TString("x2"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1433  if (status) cLegend->SetX2(valueD);
1434 
1435  valueD = (Double_t) AliDrawStyle::PrepareValue(styleName, TString("y1"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1436  if (status) cLegend->SetY1(valueD);
1437 
1438  valueD = (Double_t) AliDrawStyle::PrepareValue(styleName, TString("y2"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1439  if (status) cLegend->SetY2(valueD);
1440 
1441  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("bbox-centerx"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1442  if (status) cLegend->SetBBoxCenterX(valueI);
1443 
1444  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("bbox-centery"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1445  if (status) cLegend->SetBBoxCenterY(valueI);
1446 
1447  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("bbox-x1"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1448  if (status) cLegend->SetBBoxX1(valueI);
1449 
1450  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("bbox-x2"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1451  if (status) cLegend->SetBBoxX2(valueI);
1452 
1453  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("bbox-y1"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1454  if (status) cLegend->SetBBoxY1(valueI);
1455 
1456  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("bbox-y2"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1457  if (status) cLegend->SetBBoxY2(valueI);
1458 
1459  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("line-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1460  if (status) cLegend->SetLineColor((Color_t) valueI);
1461 
1462  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("line-style"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1463  if (status) cLegend->SetLineStyle((Style_t) valueI);
1464 
1465  valueF = AliDrawStyle::PrepareValue(styleName, TString("line-width"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1466  if (status) cLegend->SetLineWidth((Width_t) valueF);
1467 
1468  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("fill-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1469  if (status) cLegend->SetFillColor((Color_t) valueI);
1470 
1471  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("fill-style"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1472  if (status) cLegend->SetFillStyle((Style_t) valueI);
1473 
1474  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("text-align"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1475  if (status) cLegend->SetTextAlign((Short_t) valueI);
1476 
1477  valueF = AliDrawStyle::PrepareValue(styleName, TString("text-angle"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1478  if (status) cLegend->SetTextAngle(valueF);
1479 
1480  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("text-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1481  if (status) cLegend->SetTextColor((Color_t) valueI);
1482 
1483  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("text-font"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1484  if (status) cLegend->SetTextFont((Font_t) valueI);
1485 
1486 
1487  valueF = AliDrawStyle::PrepareValue(styleName, TString("text-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1488  if (status) cLegend->SetTextSize(valueF);
1489 }
1490 
1498 template <typename T>
1499  void AliDrawStyle::TObjectApplyStyle(const char *styleName, T *cObj, Int_t objNum, Int_t verbose) {
1500 
1501  Bool_t status = false;
1502  TString elementID = "";
1503  TString classID = "";
1504  TString objectID = "";
1505  TString property = "";
1506  TString localStyle = "";
1507  Int_t valueI;
1508  Float_t valueF;
1509 
1510  AliDrawStyle::GetIds(cObj, elementID, classID, objectID, localStyle, verbose);
1511 
1512  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("marker-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1513  if (status) cObj->SetMarkerColor((Color_t) valueI);
1514 
1515  valueF = AliDrawStyle::PrepareValue(styleName, TString("marker-size"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1516  if (status) cObj->SetMarkerSize(valueF);
1517 
1518  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("marker-style"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1519  if (status) cObj->SetMarkerStyle((Style_t) valueI);
1520 
1521  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("line-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1522  if (status) cObj->SetLineColor((Color_t) valueI);
1523 
1524  valueF = AliDrawStyle::PrepareValue(styleName, TString("line-width"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1525  if (status) cObj->SetLineWidth((Width_t) valueF);
1526 
1527  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("line-style"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1528  if (status) cObj->SetLineStyle((Style_t) valueI);
1529 
1530  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("fill-color"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1531  if (status) cObj->SetFillColor((Color_t) valueI);
1532 
1533  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("fill-style"), elementID, classID, objectID, localStyle, status, objNum, verbose);
1534  if (status) cObj->SetFillStyle((Style_t) valueI);
1535 }
1536 
1540 
1544 void AliDrawStyle::TPadApplyStyle(const char *styleName, TPad *cPad, Int_t verbose) {
1545 
1546  Bool_t status = false;
1547  TString elementID = "";
1548  TString classID = "";
1549  TString objectID = "";
1550  TString property = "";
1551  TString localStyle = "";
1552  Int_t valueI;
1553  Float_t valueF;
1554 
1555  AliDrawStyle::GetIds(cPad, elementID, classID, objectID, localStyle, verbose);
1556 
1557  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("fill-color"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1558  if (status) cPad->SetFillColor((Color_t) valueI);
1559 
1560  valueF = AliDrawStyle::PrepareValue(styleName, TString("margin"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1561  if (status) {
1562  cPad->SetBottomMargin(valueF);
1563  cPad->SetTopMargin(valueF);
1564  cPad->SetLeftMargin(valueF);
1565  cPad->SetRightMargin(valueF);
1566  }
1567  valueF = AliDrawStyle::PrepareValue(styleName, TString("margin-bottom"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1568  if (status) cPad->SetBottomMargin(valueF);
1569 
1570  valueF = AliDrawStyle::PrepareValue(styleName, TString("margin-top"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1571  if (status) cPad->SetTopMargin(valueF);
1572 
1573  valueF = AliDrawStyle::PrepareValue(styleName, TString("margin-left"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1574  if (status) cPad->SetLeftMargin(valueF);
1575 
1576  valueF = AliDrawStyle::PrepareValue(styleName, TString("margin-right"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1577  if (status) cPad->SetRightMargin(valueF);
1578 
1579  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("border-size"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1580  if (status) cPad->SetBorderSize((Short_t) valueI);
1581 
1582  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("border-mode"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1583  if (status) cPad->SetBorderMode((Short_t) valueI);
1584 
1585  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("gridX"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1586  if (status) cPad->SetGridx((Short_t) valueI);
1587 
1588  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("gridY"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1589  if (status) cPad->SetGridy((Short_t) valueI);
1590 
1591  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("tickX"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1592  if (status) cPad->SetTickx((Short_t) valueI);
1593 
1594  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("tickY"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1595  if (status) cPad->SetTicky((Short_t) valueI);
1596 
1597  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("logX"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1598  if (status) cPad->SetLogx((Short_t) valueI);
1599 
1600  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("logY"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1601  if (status) cPad->SetLogy((Short_t) valueI);
1602 
1603  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("logZ"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1604  if (status) cPad->SetLogz((Short_t) valueI);
1605 }
1606 
1610 
1614 void AliDrawStyle::TCanvasApplyCssStyle(const char *styleName, TCanvas *cCanvas, Int_t verbose) {
1615 
1616  Bool_t status = false;
1617  Bool_t status2 = false;
1618  TString elementID = "";
1619  TString classID = "";
1620  TString objectID = "";
1621  TString property = "";
1622  TString localStyle = "";
1623  Int_t valueI;
1624  Float_t valueF;
1625 
1626  AliDrawStyle::GetIds(cCanvas, elementID, classID, objectID, localStyle, verbose);
1627 
1628  Int_t cWidth = 0;
1629  Int_t cHeight = 0;
1630  property = AliDrawStyle::GetValue(styleName, "width", elementID, classID, objectID, localStyle);
1631  if (property != "") cWidth = (Int_t) AliDrawStyle::GetNamedTypeAt(property, status, 0);
1632  property = AliDrawStyle::GetValue(styleName, "height", elementID, classID, objectID, localStyle);
1633  if (property != "") cHeight = (Int_t) AliDrawStyle::GetNamedTypeAt(property, status2, 0);
1634  if (cWidth * cHeight > 0 && status && status2) cCanvas->SetWindowSize((UInt_t) cWidth, (UInt_t) cHeight);
1635 
1636  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("fill-color"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1637  if (status) cCanvas->SetFillColor((Color_t) valueI);
1638 
1639  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("highlight-color"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1640  if (status) cCanvas->SetHighLightColor((Color_t) valueI);
1641 
1642  valueF = AliDrawStyle::PrepareValue(styleName, TString("margin-bottom"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1643  if (status) cCanvas->SetBottomMargin(valueF);
1644 
1645  valueF = AliDrawStyle::PrepareValue(styleName, TString("margin-top"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1646  if (status) cCanvas->SetTopMargin(valueF);
1647 
1648  valueF = AliDrawStyle::PrepareValue(styleName, TString("margin-left"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1649  if (status) cCanvas->SetLeftMargin(valueF);
1650 
1651  valueF = AliDrawStyle::PrepareValue(styleName, TString("margin-right"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1652  if (status) cCanvas->SetRightMargin(valueF);
1653 
1654  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("border-size"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1655  if (status) cCanvas->SetBorderSize((Short_t) valueI);
1656 
1657  valueI = (Int_t) AliDrawStyle::PrepareValue(styleName, TString("border-mode"), elementID, classID, objectID, localStyle, status, AliDrawStyle::GetPadNumber(), verbose);
1658  if (status) cCanvas->SetBorderMode((Short_t) valueI);
1659 
1660 }
1661 
1679  void
1680  AliDrawStyle::GetIds(TObject *cObject, TString &elementID, TString &classID, TString &objectID, TString &localStyle, Int_t verbose) {
1681 
1682  elementID = cObject->ClassName();
1683  objectID = TString(cObject->GetName());
1684  TPRegexp classPat(".class[(].*?[)]");
1685  TPRegexp stylePat(".style[(].*?[)]");
1686  TString objPatStr = "";
1687  if ((objectID.Index(".class") < objectID.Index(".style") || objectID.Index(".style") == -1) && objectID.Index(".class") > 0)
1688  objPatStr = "^.*[[]|^.*?[.]class|.*";
1689  else if ((objectID.Index(".class") > objectID.Index(".style") || objectID.Index(".class") == -1) && objectID.Index(".style") > 0)
1690  objPatStr = "^.*[[]|^.*?[.]style|.*";
1691  else
1692  objPatStr = "^.*[[]|.*";
1693  TPRegexp objPat(objPatStr);
1694 
1695  classID = objectID(classPat);
1696  localStyle = objectID(stylePat);
1697  Int_t classLength = classID.Index(")") - classID.Index("(") - 1;
1698  Int_t styleLength = localStyle.Index(")") - localStyle.Index("(") - 1;
1699  classID = classID(classID.Index("(") + 1, classLength);
1700  localStyle = localStyle(localStyle.Index("(") + 1, styleLength);
1701  objectID = objectID(objPat);
1702  objectID.ReplaceAll(".class", "");
1703  objectID.ReplaceAll(".style", "");
1704  if (objectID(objectID.Length() - 1) == '[')
1705  objectID = objectID(0,objectID.Length() - 1);
1706  if (verbose == 4)
1707  ::Info("AliDrawStyle", "Object with name \"%s\" was parsed via AliDrawStyle::GetIds() to elementID = \"%s\", classID = \"%s\", objectID = \"%s\", localStyle = \"%s\"", cObject->GetName(), elementID.Data(), classID.Data(), objectID.Data(), localStyle.Data());
1708 }
1709 
1714 
1731 void AliDrawStyle::ApplyCssStyle(TPad *pad, const char *styleName, Int_t verbose) {
1732  if (pad == nullptr) {
1733  ::Error("AliDrawStyle::ApplyCssStyle", "Pad doesn't exist");
1734  return;
1735  }
1736 
1737  TObject *cObj = nullptr;
1738  TList *oList = nullptr;
1739  TString elementID = "";
1740  TString objectID = "";
1741  TString classID = "";
1742  TString localStyle = "";
1743  TPRegexp numPat0("[[].*[]]");
1744  TPRegexp numPat1("[0-9]+");
1745  TString padNumStr;
1746 
1747  oList = pad->GetListOfPrimitives();
1748  GetIds(pad, elementID, classID, objectID, localStyle, verbose);
1749 
1750  if (elementID == "TCanvas") {
1751  AliDrawStyle::TCanvasApplyCssStyle(styleName, (TCanvas *) pad, verbose);
1752  pad->Modified();
1753  for (Int_t c = 0; c < oList->GetEntries() && oList->At(c)->InheritsFrom("TPad"); c++) {
1754  AliDrawStyle::ApplyCssStyle((TPad *) oList->At(c), styleName, verbose);
1755  }
1756  }
1757 
1758 //fixme: for pads we can use indexes only from name
1759  if (elementID == "TPad") {
1760  padNumStr = TString(TString(pad->GetName())(numPat0))(numPat1);
1761  if (padNumStr != TString(""))
1762  AliDrawStyle::SetPadNumber(padNumStr.Atoi());
1763  AliDrawStyle::TPadApplyStyle(styleName, pad, verbose);
1765  }
1766  Int_t objNum = -1, hisCnt = 0, funcCnt = 0, graphCnt = 0, legendCnt = 0;
1767  for (Int_t k = 0; k < oList->GetEntries(); k++) {
1768  cObj = oList->At(k);
1769  if (TString(TString(cObj->GetName())(numPat0))(numPat1) != TString(""))
1770  objNum = TString(TString(TString(cObj->GetName())(numPat0))(numPat1)).Atoi();
1771  if (cObj->InheritsFrom("TH1")) {
1772  if (objNum >= 0) hisCnt = objNum;
1773  AliDrawStyle::TH1ApplyStyle(styleName, (TH1 *) cObj, hisCnt, verbose);
1774  hisCnt++;
1775  }
1776  if (cObj->InheritsFrom("TGraph")) {
1777  if (objNum >= 0) graphCnt = objNum;
1778  AliDrawStyle::TGraphApplyStyle(styleName, (TGraph *) cObj, graphCnt, verbose);
1779  graphCnt++;
1780  }
1781  if (cObj->InheritsFrom("TF1")) {
1782  if (objNum >= 0) funcCnt = objNum;
1783  AliDrawStyle::TF1ApplyStyle(styleName, (TF1 *) cObj, funcCnt, verbose);
1784  funcCnt++;
1785  }
1786  if (cObj->InheritsFrom("TLegend")) {
1787  if (objNum >= 0) legendCnt = objNum;
1788  AliDrawStyle::TLegendApplyStyle(styleName, (TLegend *) cObj, legendCnt, verbose);
1789  legendCnt++;
1790  }
1791  }
1792  pad->Modified();
1793 }
static Float_t PercentToFloat_t(const char *value, Int_t verbose)
converter from percents to float
TBrowser b
Definition: RunAnaESD.C:12
Int_t colors[3]
Definition: CalibCosmic.C:62
static void ApplyStyle(const char *styleName)
static Float_t GetFloatAt(const char *format, Int_t index, const char *separator=";")
static Bool_t ElementSearch(const TString selectors, const TString elementID, Int_t verbose=0)
Checks element id in selector.
static void TF1ApplyStyle(const char *styleName, TF1 *cFunc, Int_t objNum=0, Int_t verbose=0)
static Bool_t IsSelected(TString selectors, const TString elementID, const TString classID, const TString objectID, Int_t verbose=0)
static std::map< TString, std::vector< int > > fMarkerColors
map of predefined colors arrays
Definition: AliDrawStyle.h:291
static void TGraphApplyStyle(const char *styleName, TGraph *cGraph, Int_t objNum=0, Int_t verbose=0)
static void TH1ApplyStyle(const char *styleName, TH1 *cHis, Int_t objNum=0, Int_t verbose=0)
#define TObjArray
static void RegisterDefaultLatexSymbols()
initialize default LatexSymbols
static Int_t GetFillColor(const char *style, Int_t index)
static Int_t GetIntegerAt(const char *format, Int_t index, const char *separator=";")
static void RegisterDefaultMarkers()
initialize default Markers/Colors
static Int_t GetPadNumber()
Definition: AliDrawStyle.h:339
static void TCanvasApplyCssStyle(const char *styleName, TCanvas *cCanvas, Int_t verbose=0)
static std::map< TString, std::vector< float > > fLineWidth
map of predefined line width
Definition: AliDrawStyle.h:294
static TString GetValue(const char *styleName, TString propertyName, TString elementID, TString classID, TString objectID, TString localStyle=TString(""), Int_t verbose=0)
GetValue gets value from css file or local style.
static void SetPadNumber(Int_t num)
Definition: AliDrawStyle.h:338
static TString ParseDeclaration(const char *inputDec, const char *propertyName)
static TString fDefaultTStyleID
ID of the default TStyle.
Definition: AliDrawStyle.h:285
static Float_t GetNamedTypeAt(const char *inputStr, Bool_t &status, Int_t index=0, const char *propertyName="", Int_t verbose=0, const char sep=',', const char *ignoreBrackets="()")
static Bool_t ClassSearch(const TString selectors, const TString classID, Int_t verbose=0)
Checks class in selector.
static std::map< TString, std::vector< float > > fLineColor
map of predefined line color
Definition: AliDrawStyle.h:296
static std::map< TString, std::vector< float > > fLineStyle
map of predefined line style
Definition: AliDrawStyle.h:295
static Int_t ConvertColor(const char *inputString, Int_t verbose=0)
Defines what format of color user used and call appropriate converter Rules for values: *for rgb we a...
static void AddLatexSymbol(const char *symbolName, const char *symbolTitle)
static const std::vector< float > & GetMarkerSize(const char *style)
Definition: AliDrawStyle.h:269
static void WriteCSSFile(TObjArray *cssArray, const char *outputName, std::fstream *cssOut=nullptr)
static std::map< TString, std::vector< int > > fMarkerStyles
map of predefined marker styles arrays
Definition: AliDrawStyle.h:290
static Int_t GetLineColor(const char *style, Int_t index)
static const std::vector< float > & GetLineWidth(const char *style)
Definition: AliDrawStyle.h:271
static std::map< TString, std::vector< float > > fMarkerSize
map of predefined marker sizes ()
Definition: AliDrawStyle.h:292
static void RegisterDefaultStyle()
initialize default TStyles
static void SetDefaultStyles(const char *styleName, const char *arrayName)
static void TPadApplyStyle(const char *styleName, TPad *cPad, Int_t verbose=0)
static void SetDefaults()
SetDefault call RegisterDefaultLatexSymbols(), RegisterDefaultStyle(), RegisterDefaultMarkers();.
static Float_t PixelsToFloat_t(const char *value, const char *option="", Int_t verbose=0)
converter from pixels to float Pixels are relative units, it means that we should have something for ...
static void PrintStyles(Option_t *option, TPRegexp &regExp)
static TObjArray * ReadCSSFile(const char *inputName, TObjArray *array=nullptr, Int_t verbose=0)
static void TObjectApplyStyle(const char *styleName, T *cObj, Int_t objNum=0, Int_t verbose=0)
Common part of TGraphApplyStyle(), TH1ApplyStyle(), TF1ApplyStyle()
static void PrintLatexSymbols(Option_t *option, TPRegexp &regExp)
static Bool_t ObjectSearch(const TString selectors, const TString objectID, Int_t verbose=0)
TStyle * RegisterDefaultStyleFigTemplate(Bool_t grayScale)
Style source:
static Int_t HexToColor_t(const char *inputString, Int_t verbose=0)
converter from HEX to Int_t (root format of colors)
static Int_t GetLineStyle(const char *style, Int_t index)
static std::map< TString, TString > fLatexAlice
map of predefined latex symbols - formatted according ALICE rules
Definition: AliDrawStyle.h:287
static Float_t ConvertUnit(const char *inputValues, const char *option="", Int_t verbose=0)
Defines what units user used and call appropriate converter Rules for values: *for pixels we are usin...
static TString GetLatexAlice(const char *symbol)
static void GetIds(TObject *cObj, TString &elementID, TString &classID, TString &objectID, TString &localStyle, Int_t verbose=0)
Method get IDs from the cObject->GetName() and parse it into input reference. Names of objects should...
static std::map< TString, TObjArray * > fCssStyleAlice
map of Alice predefined styles corresponding to css notation
Definition: AliDrawStyle.h:289
static std::map< TString, TStyle * > fStyleAlice
map of Alice predefined styles (+user defined)
Definition: AliDrawStyle.h:288
static Int_t padNumber
Definition: AliDrawStyle.h:337
static void ApplyCssStyle(TPad *pad, const char *styleName, Int_t verbose=0)
Applies style from css to all objects from Pad or Canvas. In case if pad inherited from TCanvas will ...
static TObjArray * ReadCssString(TString cssString, TObjArray *array=nullptr, Int_t verbose=0)
void res(Char_t i)
Definition: Resolution.C:2
const Int_t markers[5]
Definition: makeBBFit.C:58
static TString fDefaultArrayStyleID
ID of the default array styles.
Definition: AliDrawStyle.h:286
static Float_t PrepareValue(const char *styleName, TString propertyName, TString elementID, TString classID, TString objectID, TString localStyle, Bool_t &status, Int_t objNum=0, Int_t verbose=0)
prepares value for applying. This method defines which value user specified (color, unit, number, etc) and return number with appropriate type Returning value will use in Set methods of objects. (TH1.SetMarkerColor(value)).
static Int_t GetMarkerColor(const char *style, Int_t index)
static Int_t GetMarkerStyle(const char *style, Int_t index)
static void TLegendApplyStyle(const char *styleName, TLegend *cLegend, Int_t objNum=0, Int_t verbose=0)
static Int_t RgbToColor_t(const char *inputString, Int_t verbose=0)
converter from RGB to Int_t (root format of colors)
static std::map< TString, std::vector< int > > fFillColors
map of predefined fill colors arrays
Definition: AliDrawStyle.h:293