forked from alisw/AliRoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AliDrawStyle.cxx
1719 lines (1515 loc) · 77.3 KB
/
AliDrawStyle.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* *
* Author: The ALICE Off-line Project. *
* Contributors are mentioned in the code where appropriate. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation strictly for non-commercial purposes is hereby granted *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
#include "AliDrawStyle.h"
#include "TStyle.h"
#include "TError.h"
#include "TPRegexp.h"
#include "TColor.h"
#include "TMath.h"
#include "TRegexp.h"
#include "TObjArray.h"
#include "TSystem.h"
#include "TPad.h"
#include "TCanvas.h"
#include "TH1.h"
#include "TGraphErrors.h"
#include "TF1.h"
#include "TClass.h"
#include "TLegend.h"
#include "TString.h"
#include "TList.h"
#include "TObject.h"
#include "TPad.h"
#include "TGraph.h"
#include "TMultiGraph.h"
#include "TAxis.h"
#include "TList.h"
#include <iostream>
#include <fstream>
#include <ios>
using namespace std;
//
TString AliDrawStyle::fDefaultTStyleID; ///< ID of the default TStyle
TString AliDrawStyle::fDefaultArrayStyleID; ///< ID of the default array styles
std::map<TString, TString> AliDrawStyle::fLatexAlice;
std::map<TString, TStyle*> AliDrawStyle::fStyleAlice;
std::map<TString, TObjArray*> AliDrawStyle::fCssStyleAlice; //
std::map<TString, std::vector<int> > AliDrawStyle::fMarkerStyles; // PLEASE LEAVE THE UNAESTHETIC SPACE
std::map<TString, std::vector<int> > AliDrawStyle::fMarkerColors; // IN ORDER TO MAKE IT WORK WITH THE
std::map<TString, std::vector<float> > AliDrawStyle::fMarkerSize; // NATIVE SLC6 COMPILER!!!
std::map<TString, std::vector<int> > AliDrawStyle::fFillColors;
std::map<TString, std::vector<float> > AliDrawStyle::fLineWidth;
std::map<TString, std::vector<float> > AliDrawStyle::fLineStyle;
std::map<TString, std::vector<float> > AliDrawStyle::fLineColor;
Int_t AliDrawStyle::padNumber = 0;
/// SetDefault call RegisterDefaultLatexSymbols(), RegisterDefaultStyle(), RegisterDefaultMarkers();
void AliDrawStyle::SetDefaults(){
AliDrawStyle::RegisterDefaultLatexSymbols();
AliDrawStyle::RegisterDefaultStyle();
AliDrawStyle::RegisterDefaultMarkers();
}
/// set AliDrawStyle::SetDefaultStyles
/// \param styleName - default style to be used class function in case of empty style selection
/// \param arrayName - default style to be used class function in case of empty array style selection
void AliDrawStyle::SetDefaultStyles(const char * styleName, const char* arrayName){
fDefaultTStyleID=styleName;
fDefaultArrayStyleID=arrayName;
}
TStyle* RegisterDefaultStyleFigTemplate(Bool_t grayScale);
/// Latex symbol section
/// \param symbol -id name of latex symbol
/// \return latex symbol to be used in ROOT latex
TString AliDrawStyle::GetLatexAlice(const char * symbol){
return fLatexAlice[symbol];
}
/// Get integer from string at index
/// \param format - array string
/// \param index - element index
/// \param separator - array separator
/// TODO: using TString - to be replaced by faster variant with rough pointers (make it faster as possible)
/// Example usage:
/*!
\code
AliDrawStyle::GetIntegerAt("1:4:8",1,":"); // return 4
AliDrawStyle::GetIntegerAt("1;4;8",2,";"); // return 8
\endcode
*/
Int_t AliDrawStyle::GetIntegerAt(const char * format, Int_t index, const char * separator ) {
if (format==NULL) return -1;
if (index<0) return -1;
index++;
TString sFormat(format);
TString token(format);
Int_t position=0;
Int_t counter=0;
while (counter<index) {
if (sFormat.Tokenize(token,position,separator)) {
counter++;
}else{
break;
}
}
if (counter==index) return token.Atoi();
return -1;
}
/// Get integer from string
/// \param format - array string
/// \param index - element index
/// \param separator - array separator
/// TODO: using TString - to be replaced by faster variant with rough pointers (Boris check)
/// Example usage:
/*!
\code
AliDrawStyle::GetFloatAt("1.1:4.1:8.1",1,":"); // return 4.1
AliDrawStyle::GetFloatAt("1.1;4.1;8.1",2,";"); // return 8.1
\endcode
*/
Float_t AliDrawStyle::GetFloatAt(const char * format, Int_t index, const char * separator ) {
if (format==NULL) return -1;
if (index<0) return -1;
index++;
TString sFormat(format);
TString token(format);
Int_t position=0;
Int_t counter=0;
while (counter<index) {
if (sFormat.Tokenize(token,position,separator)) {
counter++;
}else{
break;
}
}
if (counter==index) return token.Atof();
return -1;
}
// GetMarkerStyle associated to the style.
/// \param style - name of style used
/// \param index - marker index
/// \return marker style for given styleName, index
Int_t AliDrawStyle::GetMarkerStyle(const char *style, Int_t index){
if (AliDrawStyle::fMarkerStyles[style].size() <= index) {
return GetIntegerAt(style,index);
}
return AliDrawStyle::fMarkerStyles[style][index];
}
// GetLineStyle associated to the style.
/// \param style - name of style used
/// \param index - marker index
/// \return marker style for given styleName, index
Int_t AliDrawStyle::GetLineStyle(const char *style, Int_t index){
if (AliDrawStyle::fLineStyle[style].size() <= index) {
return GetIntegerAt(style,index);
}
return AliDrawStyle::fLineStyle[style][index];
}
// GetLineColor associated to the style.
/// \param style - name of style used
/// \param index - marker index
/// \return marker style for given styleName, index
Int_t AliDrawStyle::GetLineColor(const char *style, Int_t index){
if (AliDrawStyle::fLineColor[style].size() <= index) {
return GetIntegerAt(style,index);
}
return AliDrawStyle::fLineColor[style][index];
}
/// GetMarkerColor associated to the style.
/// \param style - name of style used
/// \param index - marker index
/// \return marker color for given styleName, index
Int_t AliDrawStyle::GetMarkerColor(const char *style, Int_t index){
if (AliDrawStyle::fMarkerColors[style].size() <= index) {
return GetIntegerAt(style,index);
}
return AliDrawStyle::fMarkerColors[style][index];
}
/// GetMarkerSize associated to the style.
/// \param style - name of style used
/// \param index - marker index
/// \return marker color for given styleName, index
Float_t AliDrawStyle::GetMarkerSize(const char *style, Int_t index){
if (AliDrawStyle::fMarkerSize[style].size() <= index) {
return GetIntegerAt(style,index);
}
return AliDrawStyle::fMarkerSize[style][index];
}
/// GetFillColor associated to the style.
/// \param style - name of style used
/// \param index - marker index
/// \return fill color for given styleName, index
Int_t AliDrawStyle::GetFillColor(const char *style, Int_t index){
if (AliDrawStyle::fFillColors[style].size() <= index) {
return GetIntegerAt(style,index);
}
return AliDrawStyle::fFillColors[style][index];
}
/// GetLineWidth associated to the style.
/// \param style - name of style used
/// \param index - marker index
/// \return fill color for given styleName, index
Float_t AliDrawStyle::GetLineWidth(const char *style, Int_t index){
if (AliDrawStyle::fLineWidth[style].size() <= index) {
return GetFloatAt(style,index);
}
return AliDrawStyle::fLineWidth[style][index];
}
void AliDrawStyle::PrintLatexSymbols(Option_t */*option*/, TPRegexp& regExp){
//print latex symbols
typedef std::map<TString,TString>::const_iterator it_type;
for(it_type iterator = fLatexAlice.begin(); iterator != fLatexAlice.end(); ++iterator) {
if (regExp.Match(iterator->first.Data())==0) continue;
std::cout<<iterator->first << " " << iterator->second << "\n";
}
}
void AliDrawStyle::PrintStyles(Option_t *option, TPRegexp& regExp){
//print latex symbols
typedef std::map<TString,TStyle*>::const_iterator it_type;
for(it_type iterator = fStyleAlice.begin(); iterator != fStyleAlice.end(); ++iterator) {
if (regExp.Match(iterator->first.Data())==0) continue;
if (option==NULL) std::cout << iterator->first << " " << iterator->second << "\n";
if (option!=NULL) {
iterator->second->Print(option);
if (TString(option).Contains("dump")) iterator->second->Dump();
}
}
}
///
/// \param styleName
void AliDrawStyle::ApplyStyle(const char* styleName){
//
// Apply registered style
//
TStyle * style= fStyleAlice[styleName];
if (style==NULL){
::Error("AliDrawStyle::ApplyStyle","Invalid style %s",styleName);
}else{
::Info("AliDrawStyle::ApplyStyle","%s",styleName);
}
if (style) style->cd();
}
void AliDrawStyle::AddLatexSymbol(const char * symbolName, const char * symbolTitle){
fLatexAlice[symbolName]=symbolTitle;
}
void AliDrawStyle::RegisterDefaultLatexSymbols(){
//
// Set default AliRoot/Latex/root shortcuts
//
fLatexAlice["qpt"]="#it{q}/#it{p}_{T} (GeV/#it{c})^{-1}";
fLatexAlice["qpt0"]="#it{q}/#it{p}_{T}";
fLatexAlice["pt"]="#it{p}_{T} (GeV/#it{c}) ";
fLatexAlice["pt0"]="#it{p}_{T} ";
fLatexAlice["sqptmev"]="#sigma_{#it{q}/#it{p}_{T}} (MeV/#it{c})^{-1}";
fLatexAlice["pbpb502"]="Pb#font[122]{-}Pb #sqrt{#it{s}_{NN}} =5.02 TeV";
fLatexAlice["pp13"]="pp #sqrt{#it{s}} = 13 TeV ";
fLatexAlice["drphi"]="#Delta_{#it{r#phi}} (cm)";
fLatexAlice["srphi"]="#sigma_{#it{r#phi}} (cm)";
}
void AliDrawStyle::RegisterDefaultStyle(){
//
fStyleAlice["figTemplate"]=RegisterDefaultStyleFigTemplate(kFALSE);
fStyleAlice["figTemplateGrey"]=RegisterDefaultStyleFigTemplate(kFALSE);
//
TStyle *style=RegisterDefaultStyleFigTemplate(kFALSE);
style->SetName("figTemplate2");
style->SetTitleXSize(TMath::Power(2,0.5)*style->GetTitleXSize());
style->SetTitleYSize(TMath::Power(2,0.5)*style->GetTitleYSize());
style->SetLabelSize(TMath::Power(2,0.5)*style->GetLabelSize("X"),"X");
style->SetLabelSize(TMath::Power(2,0.5)*style->GetLabelSize("Y"),"Y");
style->SetLabelSize(TMath::Power(2,0.5)*style->GetLabelSize("Z"),"Z");
fStyleAlice["figTemplate2"]=style;
//
style=RegisterDefaultStyleFigTemplate(kFALSE);
style->SetName("figTemplate3");
style->SetTitleXSize(TMath::Power(3,0.5)*style->GetTitleXSize());
style->SetTitleYSize(TMath::Power(3,0.5)*style->GetTitleYSize());
style->SetLabelSize(TMath::Power(3,0.5)*style->GetLabelSize("X"),"X");
style->SetLabelSize(TMath::Power(3,0.5)*style->GetLabelSize("Y"),"Y");
style->SetLabelSize(TMath::Power(3,0.5)*style->GetLabelSize("Z"),"Z");
fStyleAlice["figTemplate3"]=style;
}
void AliDrawStyle::RegisterDefaultMarkers(){
//
// Style source:
// https://twiki.cern.ch/twiki/pub/ALICE/ALICERecommendationsResultPresentationText/figTemplate.C
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
const Int_t colors[] = {kBlack, kRed+1 , kBlue+1, kGreen+3, kMagenta+1, kOrange-1,kCyan+2,kYellow+2,kGray+1, kRed-10 };
const Int_t markers[] = {kFullCircle, kFullSquare,kOpenCircle,kOpenSquare,kOpenDiamond,kOpenCross,kFullCross,kFullDiamond,kFullStar,kOpenStar};
//
(fMarkerStyles["figTemplate"])=std::vector<int>(10);
(fMarkerColors["figTemplate"])=std::vector<int>(10);
(fMarkerSize["figTemplate"])=std::vector<float>(10);
(fFillColors["figTemplate"])=std::vector<int>(10);
(fLineWidth["figTemplate"])=std::vector<float>(10);
(fLineColor["figTemplate"])=std::vector<float>(10);
(fLineStyle["figTemplate"])=std::vector<float>(10);
for (Int_t i=0;i<10; i++){
(fMarkerStyles["figTemplate"])[i]=markers[i];
(fMarkerColors["figTemplate"])[i]=colors[i];
(fMarkerSize["figTemplate"])[i]=1;
(fFillColors["figTemplate"])[i]=fillColors[i];
(fLineWidth["figTemplate"])[i]=0.5;
(fLineStyle["figTemplate"])[i]=i+1;
(fLineColor["figTemplate"])[i]=colors[i];
}
// style inspired by TRD performance paper
Int_t colorsTRD[12]={0};
const Int_t markersTRD[] = {kOpenSquare,kFullSquare, kOpenStar,kFullStar, kOpenCircle,kFullCircle, kOpenDiamond,kFullDiamond, kOpenCross,kFullCross };
const Float_t markerTRDSize[] = {1,1, 0.9,0.9, 1.4,1.4, 1.1,1.1, 1.2,1.2 };
colorsTRD[0]=TColor::GetColor("#0000DD");
colorsTRD[1]=TColor::GetColor("#00EE00");
colorsTRD[2]=TColor::GetColor("#FF0000");
colorsTRD[3]=TColor::GetColor("#00EEDD");
colorsTRD[4]=TColor::GetColor("#FFEE00");
colorsTRD[5]=TColor::GetColor("#FF00DD");
colorsTRD[6]=TColor::GetColor("#9999DD");
colorsTRD[7]=TColor::GetColor("#99EE99");
colorsTRD[8]=TColor::GetColor("#FF9999");
colorsTRD[9]=TColor::GetColor("#66AADD");
colorsTRD[10]=TColor::GetColor("#AAEE66");
colorsTRD[11]=TColor::GetColor("#FF66AA");
(fMarkerStyles["figTemplateTRD"])=std::vector<int>(10);
(fMarkerColors["figTemplateTRD"])=std::vector<int>(10);
(fMarkerSize["figTemplateTRD"])=std::vector<float>(10);
(fFillColors["figTemplateTRD"])=std::vector<int>(10);
(fLineWidth["figTemplateTRD"])=std::vector<float>(10);
(fLineStyle["figTemplateTRD"])=std::vector<float>(10);
(fMarkerStyles["figTemplateTRDPair"])=std::vector<int>(10);
(fMarkerColors["figTemplateTRDPair"])=std::vector<int>(10);
(fMarkerSize["figTemplateTRDPair"])=std::vector<float>(10);
(fFillColors["figTemplateTRDPair"])=std::vector<int>(10);
(fLineWidth["figTemplateTRDPair"])=std::vector<float>(10);
(fLineStyle["figTemplateTRDPair"])=std::vector<float>(10);
for (Int_t i=0; i<10; i++){
(fMarkerStyles["figTemplateTRD"])[i]=markersTRD[i];
(fMarkerColors["figTemplateTRD"])[i]=TColor::GetColorDark(colorsTRD[i]);
(fMarkerSize["figTemplateTRD"])[i]=markerTRDSize[i];
(fFillColors["figTemplateTRD"])[i]=fillColors[i];
(fLineWidth["figTemplateTRD"])[i]=0.5;
//
(fMarkerStyles["figTemplateTRDPair"])[i]=markersTRD[i];
(fMarkerColors["figTemplateTRDPair"])[i]=TColor::GetColorDark(colorsTRD[i/2]);
(fMarkerSize["figTemplateTRDPair"])[i]=markerTRDSize[i];
(fFillColors["figTemplateTRDPair"])[i]=fillColors[i/2];
(fLineWidth["figTemplateTRDPair"])[i]=0.5;
}
}
TStyle* RegisterDefaultStyleFigTemplate(Bool_t grayPalette) {
// Style source:
// https://twiki.cern.ch/twiki/pub/ALICE/ALICERecommendationsResultPresentationText/figTemplate.C
//
TStyle * figStyle = new TStyle;
figStyle->Reset("Plain");
figStyle->SetOptTitle(0);
figStyle->SetOptStat(0);
if(grayPalette) figStyle->SetPalette(8,0);
else figStyle->SetPalette(1);
figStyle->SetCanvasColor(10);
figStyle->SetCanvasBorderMode(0);
figStyle->SetFrameLineWidth(1);
figStyle->SetFrameFillColor(kWhite);
figStyle->SetPadColor(10);
figStyle->SetPadTickX(1);
figStyle->SetPadTickY(1);
figStyle->SetPadBottomMargin(0.15);
figStyle->SetPadLeftMargin(0.15);
figStyle->SetHistLineWidth(1);
figStyle->SetHistLineColor(kRed);
figStyle->SetFuncWidth(2);
figStyle->SetFuncColor(kGreen);
figStyle->SetLineWidth(2);
figStyle->SetLabelSize(0.045,"xyz");
figStyle->SetLabelOffset(0.01,"y");
figStyle->SetLabelOffset(0.01,"x");
figStyle->SetLabelColor(kBlack,"xyz");
figStyle->SetTitleSize(0.05,"xyz");
figStyle->SetTitleOffset(1.25,"y");
figStyle->SetTitleOffset(1.2,"x");
figStyle->SetTitleFillColor(kWhite);
figStyle->SetTextSizePixels(26);
figStyle->SetTextFont(42);
figStyle->SetLegendBorderSize(0);
figStyle->SetLegendFillColor(kWhite);
figStyle->SetLegendFont(42);
return figStyle;
}
/// AliDrawStyle::ParseDeclaration parse input declaration and return values
/// \param input - input string
/// \param propertyName - name of property to find
/// \return - property propertyName from the input string using CSS like parsing, empty string in case not found
///
/*!
#### Example use:
TString input="{\nmarker-style:25,21,22,23; \nmarker-color:1,2,4,5; \n}";
AliDrawStyle::ParseDeclaration(input.Data(),"marker-style"); // return "25,21,22,23"
AliDrawStyle::ParseDeclaration(input.Data(),"marker-color"); // return "1,2,4,5"
*/
TString AliDrawStyle::ParseDeclaration(const char *inputDec, const char *propertyName) {
TString input(inputDec);
TPRegexp valPat(":.*;");
TString dVal = "";
Int_t index0 = input.Index(propertyName);
if (index0<0) return "";
dVal = TString(input(valPat,index0));
Int_t valLength = dVal.Index(';') - dVal.Index(':') -1;
return dVal(1,valLength);
}
/// \brief Method returns type of input number
/// \tparam T - type of return value could be any number format from c++
/// \param inputStr - input string could be declaration from css or only string with values
/// \param index - the number of returning value, by default - 0
/// \param sep - separator from input string. by default - ";"
/// \param ignoreBrackets - separators inside this brackets will be ignore. by default "()"
/// \param verbose
/// \return - number of type T or -1 if something went wrong
/*!
#### Example use:
\code
1.
Bool_t status;
AliDrawStyle::GetNamedTypeAt<int>("11,13,14", status)
(int) 11
2.
Bool_t status;
AliDrawStyle::GetNamedTypeAt<int>("11,13,14", status, 1)
(int) 12
3.
Bool_t status;
AliDrawStyle::GetNamedTypeAt<int>("rgb(12,12,12),#dfdfdf,14", status)
(int) 1179
4.
Bool_t status;
AliDrawStyle::GetNamedTypeAt<int>("rgb(12,12,12),#dfdfdf,14", status, 1)
(int) 1180
5. Bool_t status;
AliDrawStyle::GetNamedTypeAt<int>("marker-color:rgb(12,12,12),#dfdfdf,14;marker-size:1,2,3,4;", status,2,"marker-size")
(int) 3
6. Bool_t status;
AliDrawStyle::GetNamedTypeAt<int>("marker-color:rgb[12,12,12],#dfdfdf,14;marker-size:1,2,3,4;", status,2,"marker-color", 0, ',',"[]")
(int) 14
\endcode
*/
template <typename T>
T AliDrawStyle::GetNamedTypeAt(const char *inputStr, Bool_t &status, int index, const char *propertyName, Int_t verbose, const char sep, const char *ignoreBrackets) {
TString inputTStr;
if(TString(propertyName) != TString("")) inputTStr = AliDrawStyle::ParseDeclaration(inputStr,propertyName);
else inputTStr = TString(inputStr);
T res = T();
Int_t arg = 0, startIndex = 0;
if (TString(inputStr) == TString("")) {
::Error("AliDrawStyle", "AliDrawStyle::GetNamedTypeAt(\"%s\", %d, \"%s\"). Options string should not be empty.", inputStr, index, propertyName);
status = kFALSE;
return res;
}
std::vector<TString> values;
for (Int_t i = 0; i <= index; i++) values.push_back(TString(""));
for (Int_t i = 0; i <= inputTStr.Length(); i++) {
if (arg > index) break;
if (inputTStr(i) == TString(sep) || i == inputTStr.Length()) {
values[arg] = TString(inputTStr(startIndex, i - startIndex));
arg++;
startIndex = i + 1;
} else if (inputTStr(i) == TString(ignoreBrackets)[0]) {
i = inputTStr.Index(ignoreBrackets[1], i);
continue;
}
}
if (index >= arg && index != 0) return AliDrawStyle::GetNamedTypeAt<T>(inputStr, status, arg-1, propertyName, verbose, sep, ignoreBrackets); // keeping the last index for objects in case index doesn't exist.
if (values[index].IsDec()) {
status = kTRUE;
if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::GetNamedTypeAt<>(\"%s\",%d,%d,\"%s\") was transformed in %d",inputStr,status,index,propertyName, values[index].Atoi());
return values[index].Atoi();
}
else if (values[index].IsFloat()) {
if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::GetNamedTypeAt<>(\"%s\",%d,%d,\"%s\") was transformed in %f",inputStr,status,index,propertyName, values[index].Atof());
status = kTRUE;
return values[index].Atof();
}
else if (values[index].Contains("%") || values[index].Contains("px")) {
Float_t valF = AliDrawStyle::ConvertUnit(values[index].Data(),propertyName);
if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::GetNamedTypeAt<>(\"%s\",%d,%d,\"%s\") was transformed in %f",inputStr,status,index,propertyName, valF);
if (valF != -1.0) status = kTRUE;
return valF;
}
else if (values[index].Contains("rgb") || values[index].Contains("#")) {
Int_t valI = AliDrawStyle::ConvertColor(values[index]);
if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::GetNamedTypeAt<>(\"%s\",%d,%d,\"%s\") was transformed in %d",inputStr,status,index,propertyName, valI);
if (valI != -1) status = kTRUE;
return valI;
}
else {
status = kFALSE;
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());
return (T) -1.0;
}
return T();
}
/// \brief converter from pixels to float
/// Pixels are relative units, it means that we should have something for converting from it.
/// * In case margins we use gPad->GetWw() for left-right margin, and gPad->GetWh() for top-bottom margins.
/// * In case markers-size we use this:
/// The marker size does not refer to any coordinate systems, it is an absolute value.
/// Therefore the marker size is not affected by any change in TPad's scale.
/// A marker size equl to 1 correspond to 8 pixels. That is, a square marker with size 1
/// will be drawn with a side equal to 8 pixels on the screen.
/// https://root.cern.ch/root/html600/TAttMarker.html
/// \param value - value for converting
/// \param option - sets way of the converting
/// \param verbose
/// \return - Float_t number or -1.0 if something went wrong
Float_t AliDrawStyle::PixelsToFloat_t(const char *value, const char *option, Int_t verbose) {
TString valStr = TString(value);
TString optionT = TString(option);
Float_t val = (Float_t) -1.0;
if (optionT.Contains("marker")) {
val = (Float_t) TString(valStr(0, valStr.Length() - 2)).Atof() / 8;
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::PixelsToFloat_t(\"%s\",\"%s\") transformed into %f.",value, option,val);
return val;
}
if (gPad == nullptr) {
::Error("AliDrawStyle", "AliDrawStyle::PixelsToFloat_t(\"%s\",\"%s\"). For converting of pixels you must have a TPad object.", value, option);
return (Float_t) -1.0;
}
else {
if (optionT.Contains("top") || optionT.Contains("bottom")) {
val = (Float_t) TString(valStr(0, valStr.Length() - 2)).Atof() / gPad->GetWh();
} else if (optionT.Contains("left") || optionT.Contains("right")) {
val = (Float_t) TString(valStr(0, valStr.Length() - 2)).Atof() / gPad->GetWw();
} else if (optionT.Contains("border")) {
val = (Float_t) TString(valStr(0, valStr.Length() - 2)).Atof();
}
if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::PixelsToFloat_t(\"%s\",\"%s\") transformed into %f. Calculations based on pad - %s", value, option, val, gPad->GetName());
}
return val;
}
/// \brief converter from percents to float
/// \param value - value for converting
/// \param verbose
/// \return - Float_t number or -1.0 if something went wrong
Float_t AliDrawStyle::PercentToFloat_t(const char *value, Int_t verbose) {
TString valStr = TString(value);
Float_t val = (Float_t) TString(valStr(0, valStr.Length() - 1)).Atof() / 100;
if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::PercentToFloat_t(%s) transformed into %f", valStr.Data(), val);
return val;
}
/// \brief Defines what units user used and call appropriate converter
/// Rules for values:
/// *for pixels we are using "px" in the end of value, so if you want to recieve 300 pixels, just set "300px"
/// as input value
/// * for percents use %. "30%"
/// \param value - value for convert
/// \param option
/// \return \return - Float_t number or -1.0 if something went wrong
Float_t AliDrawStyle::ConvertUnit(const char *inputValues, const char *option, Int_t verbose) {
TString value = TString(inputValues);
if (value.Contains("px") && option != "")
return AliDrawStyle::PixelsToFloat_t(value, option, verbose);
else if (value.Contains("%"))
return AliDrawStyle::PercentToFloat_t(value, verbose);
else if (value.IsFloat()) return (Float_t) value.Atof();
if (verbose == 4) ::Error("AliDrawStyle", "In AliDrawStyle::ConvertUnit(%s,%s) occured the error.", inputValues, option);
return (Float_t) -1.0;
}
/// \brief converter from RGB to Int_t (root format of colors)
/// \param inputColor
/// \param verbose
/// \return
/*!
#### Example use:
\code
AliDrawStyle::RgbToColor_t("rgb(0,0,0)")
(int) 1
AliDrawStyle::RgbToColor_t("rgb(255,255,255)")
(int) 0
\endcode
*/
Int_t AliDrawStyle::RgbToColor_t(const char *inputString, Int_t verbose) {
TString rgbValuesStr = "";
TPRegexp rgbPattern("[(].*[)]");
TString inputColor = TString(inputString);
if (inputColor.CountChar(',') != 2) {
::Error("AliDrawStyle", "AliDrawStyle::RgbToColor_t(%s) - rgb should be rgb(Float_t, Float_t, Float_t)",
inputColor.Data());
return -1;
}
rgbValuesStr = TString(inputColor(rgbPattern)).ReplaceAll("(", "");
rgbValuesStr = rgbValuesStr.ReplaceAll(")", "");
TObjArray *rgbValues = rgbValuesStr.Tokenize(",");
if (TString(rgbValues->At(0)->GetName()).IsDec() && TString(rgbValues->At(1)->GetName()).IsDec() &&
TString(rgbValues->At(2)->GetName()).IsDec()) {
Int_t r = TString(rgbValues->At(0)->GetName()).Atoi();
Int_t g = TString(rgbValues->At(1)->GetName()).Atoi();
Int_t b = TString(rgbValues->At(2)->GetName()).Atoi();
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::RgbToColor_t(%s) transformed into "
"TColor::GetColor(%d, %d, %d) and returned %d", inputColor.Data(), r, g, b,
TColor::GetColor(r, g, b));
return TColor::GetColor(r, g, b);
}
else if (TString(rgbValues->At(0)->GetName()).IsFloat() && TString(rgbValues->At(1)->GetName()).IsFloat() &&
TString(rgbValues->At(2)->GetName()).IsFloat()) {
Float_t r = (Float_t) TString(rgbValues->At(0)->GetName()).Atof();
Float_t g = (Float_t) TString(rgbValues->At(1)->GetName()).Atof();
Float_t b = (Float_t) TString(rgbValues->At(2)->GetName()).Atof();
if (verbose == 4) ::Info("AliDrawStyle","AliDrawStyle::RgbToColor_t(%s) transformed into "
"TColor::GetColor(%f, %f, %f) and returned %d", inputColor.Data(),r,g,b,
TColor::GetColor(r, g, b));
return TColor::GetColor(r, g, b);
}
if (verbose == 4)
::Warning("AliDrawStyle", "In AliDrawStyle::RgbToColor_t(%s) something went wrong", inputString);
return -1;
}
/// \brief converter from HEX to Int_t (root format of colors)
/// \param inputColor
/// \param verbose
/// \return
Int_t AliDrawStyle::HexToColor_t(const char *inputString, Int_t verbose) {
TString inputColor = TString(inputString);
if (verbose == 4) ::Info("AliDrawStyle","AliDrawStyle::HexToColor_t(%s) transformed into "
"TColor::GetColor(%s) and returned %d", inputColor.Data(), inputColor.Data(),
TColor::GetColor(inputColor.Data()));
return TColor::GetColor(inputColor.Data());
}
/// \brief Defines what format of color user used and call appropriate converter
/// Rules for values:
/// *for rgb we are using "rgb()" in the end of value, so if you want to recieve red color, just set "rgb(255,0,0)"
/// as input value
/// * for hex use "#ff0000"
/// \param inputString - string of input values ("#000000", "rgb(0,0,0)", "0")
/// \param verbose
/// \return - TColor::GetColor(value)
/*!
#### Example use:
\code
AliDrawStyle::HexToColor_t("#ff0000")
(int) 2
AliDrawStyle::HexToColor_t("#00ff00")
(int) 3
\endcode
*/
Int_t AliDrawStyle::ConvertColor(const char *inputString, Int_t verbose) {
TString value = TString(inputString);
Int_t color;
if (value(0,3) == TString("rgb"))
color = AliDrawStyle::RgbToColor_t(value, verbose);
else if (value(0) == TString("#"))
color = AliDrawStyle::HexToColor_t(value, verbose);
else if (value.IsDec())
color = value.Atoi();
else {
::Error("AliDrawStyle", "AliDrawStyle::ConvertColor(%s) - something wrong with colors", value.Data());
return -1;
}
if (verbose == 4) ::Info("AliDrawStyle","AliDrawStyle::ConvertColor(%s) transformed into "
"returned %d", inputString,color);
return color;
}
/// \brief 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)).
/// \tparam T
/// \param styleName - name of preloading style
/// \param propertyName - name of property which you want to change
/// \param elementID - root class of object
/// \param classID - tag or user predefined class
/// \param objectID - name of root-object
/// \param localStyle - local style from name of object with high priority
/// \param objNum - number of object in pad
/// \param verbose
/// \return
template <typename T>
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) {
TString property = "";
TString cProperty = "";
Int_t hisNum = -1;
status = kFALSE;
T value;
if (localStyle.Contains(propertyName.Data()) && (propertyName.Contains("size") || propertyName.Contains("margin"))) {
property = localStyle;
hisNum = 0;
cProperty = propertyName;
if (verbose == 4) ::Info("AliDrawStyle", "1.AliDrawStyle::PrepareValue(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%d) provided value = \"%s\" ", styleName, propertyName.Data(), elementID.Data(), classID.Data(), objectID.Data(), localStyle.Data(), objNum, property.Data());
}
else if (localStyle.Contains(propertyName.Data())) {
property = AliDrawStyle::ParseDeclaration(localStyle.Data(), propertyName.Data());
hisNum = 0;
cProperty = "";
if (verbose == 4) ::Info("AliDrawStyle", "2.AliDrawStyle::PrepareValue(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%d) provided value = \"%s\" ", styleName, propertyName.Data(), elementID.Data(), classID.Data(), objectID.Data(), localStyle.Data(), objNum, property.Data());
}
else if (propertyName.Contains("size") || propertyName.Contains("margin")) {
property = AliDrawStyle::GetValue(styleName, "", elementID, classID, objectID, "", verbose);
hisNum = objNum;
cProperty = propertyName;
if (!property.Contains(cProperty)) {
if (verbose == 4) ::Info("AliDrawStyle","AliDrawStyle::PrepareValue(\"%s\", \"%s\", \"%s\", \"%s\", \"%s\") property not found in css file", styleName, propertyName.Data(), elementID.Data(), classID.Data(), objectID.Data());
return T();
}
if (verbose == 4) ::Info("AliDrawStyle", "3.AliDrawStyle::PrepareValue(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%d) provided value = \"%s\" ", styleName, propertyName.Data(), elementID.Data(), classID.Data(), objectID.Data(), localStyle.Data(), objNum, property.Data());
}
else {
property = AliDrawStyle::GetValue(styleName, propertyName, elementID, classID, objectID, localStyle, verbose);
hisNum = objNum;
cProperty = "";
if (property == TString("")) return T();
if (verbose == 4) ::Info("AliDrawStyle", "4.AliDrawStyle::PrepareValue(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%d) provided value = \"%s\" ", styleName, propertyName.Data(), elementID.Data(), classID.Data(), objectID.Data(), localStyle.Data(), objNum, property.Data());
}
value = AliDrawStyle::GetNamedTypeAt<T>(property.Data(), status, hisNum, cProperty, verbose);
if (verbose == 4) ::Info("AliDrawStyle", "5.AliDrawStyle::PrepareValue(\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",%d) status is %d and returned value", styleName, propertyName.Data(), elementID.Data(), classID.Data(), objectID.Data(), localStyle.Data(), objNum, status);
if (status) return value;
return T();
}
/// Read CSS html like files (*see also AliRoot modification in CSS)
/// TODO:
/// * proper exception handling (Boris)
/// * code should not fail
/// * return 0 pointer if inconsistent content
/// * Use ::Error verbosity according debug level
/// * include CSS files (should be included as )
/// \param inputName - input file to read
/// \param verbose - specify verbose level for ::error and ::info (Int_t should be interpreted as an bit-mask)
/// \return - TObjArray with the pairs TNamed of the CSS <Selector, declaration> or TObjArray (recursive structure like includes)
TObjArray *AliDrawStyle::ReadCSSFile(const char * inputName, TObjArray * cssArray, Int_t verbose) {
//check file exist
if (gSystem->GetFromPipe(TString("[ -f ") + TString(inputName) + TString(" ] && echo 1 || echo 0")) == "0") {
::Error("AliDrawStyle::ReadCSSFile","File %s doesn't exist", inputName);
return nullptr;
}
TString inputCSS = gSystem->GetFromPipe(TString::Format("cat %s",inputName).Data()); // I expect this variable is defined
//remove comments:
while (inputCSS.Index("*/") > 0) {
inputCSS = inputCSS(0, inputCSS.Index("/*")) + inputCSS(inputCSS.Index("*/")+2, inputCSS.Length());
}
//inputCSS.ReplaceAll("\n", ""); // check performance and implement better variant;
TObjArray *tokenArray = inputCSS.Tokenize("{}"); //assuming we can not use {} symbols in the style IDS
Int_t entries = tokenArray->GetEntries();
if (cssArray==nullptr) {
cssArray = new TObjArray(entries / 2);
}
for (Int_t i = 0; i < entries; i += 2) {
if (i + 1 >= entries) continue;
TString selector = tokenArray->At(i)->GetName();
TString declaration = tokenArray->At(i + 1)->GetName();
cssArray->AddLast(new TNamed(selector.Data(), declaration.Data()));
}
return cssArray;
}
/// Write cssArray to the file as a plain array (recursive function)
/// \param cssArray - input css array to write
/// \param outputName - output file
/// \param pCssOut - output stream ( )
void AliDrawStyle::WriteCSSFile(TObjArray * cssArray, const char * outputName, std::fstream *pCssOut) {
if (pCssOut == nullptr) {
pCssOut=new std::fstream;
pCssOut->open(outputName, ios_base::out|ios_base::trunc);
}
std::fstream &cssOut = *pCssOut;
for (Int_t i=0;i<cssArray->GetEntries();i++) {
TObject *object = cssArray->At(i);
if (object->InheritsFrom("TObjArray")) {
AliDrawStyle::WriteCSSFile((TObjArray*)object, nullptr, pCssOut);
}else {
cssOut << object->GetName();
cssOut << "{";
cssOut << object->GetTitle();
cssOut << "}";
}
}
cssOut<<std::flush;
if (outputName!=nullptr) {
pCssOut->close();
delete pCssOut;
}
}
/// \brief Checks element id in selector
/// \param selector - input string with selectors
/// \param elementID
/// \param verbose
/// \return true if element was found
Bool_t AliDrawStyle::ElementSearch(const TString selector, const TString elementID, Int_t verbose) {
if (selector == TString("")) {
::Error("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\") selector should not be empty", selector.Data(), elementID.Data());
return kFALSE;
}
//impossible for us
if (elementID == TString("")) {
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\") elementID is empty, any element is fine", selector.Data(), elementID.Data());
return kTRUE;
}
TString elementFromSelector = "";
Int_t finish = -1;
if(selector.Index('#') >= 0) finish = selector.Index('#');
if(selector.Index('.') >= 0) finish = selector.Index('.');
if (finish == 0) return kTRUE;
else if (finish > 0) elementFromSelector = selector(0, finish);
else elementFromSelector = selector;
if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\"). Selector was transformed to %s", selector.Data(), elementID.Data(), elementFromSelector.Data());
if (elementFromSelector.Index('*') >= 0) {
elementFromSelector = elementFromSelector.ReplaceAll("*", ".*");
TPRegexp elemPattern(elementFromSelector);
if (elementID(elemPattern) == elementID || TClass(elementID.Data()).InheritsFrom(TString(elementFromSelector(0,elementFromSelector.Index("."))).Data())) {
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\") was successful", selector.Data(), elementID.Data());
return kTRUE;
}
else {
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\") was unsuccessful", selector.Data(), elementID.Data());
return kFALSE;
}
}
if (elementFromSelector == elementID) {
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\") was successful", selector.Data(), elementID.Data());
return kTRUE;
}
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ElementSearch(\"%s\", \"%s\") was unsuccessful", selector.Data(), elementID.Data());
return kFALSE;
}
/// \brief Checks class in selector
/// \param selector - input string with selectors
/// \param classID
/// \param verbose
/// \return true if class was found
Bool_t AliDrawStyle::ClassSearch(const TString selector, const TString classID, Int_t verbose) {
if (selector == TString("")) {
::Error("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\") selector should not be empty", selector.Data(), classID.Data());
return kFALSE;
}
if (classID == TString("")) {
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\") classID is empty, any class is fine", selector.Data(), classID.Data());
return kTRUE;
}
TPRegexp classPattern("[.].*#|[.].*");
TString classFromSelector = "";
classFromSelector = selector(classPattern);
if (classFromSelector == TString(""))
return kTRUE;
if(classFromSelector.Index('#') >= 0) classFromSelector = classFromSelector(1,classFromSelector.Length() - 2);
else classFromSelector = classFromSelector(1,classFromSelector.Length());
if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\"). Selector was transformed to %s", selector.Data(), classID.Data(), classFromSelector.Data());
//for multi classes
TObjArray *classIDs = classID.Tokenize(",");
Int_t nC = classIDs->GetEntriesFast();;
TString tempClassID = "";
for (Int_t i = 0; i < nC; i++) {
tempClassID = classIDs->At(i)->GetName();
if (classFromSelector.Index('*') >= 0) {
classFromSelector = classFromSelector.ReplaceAll("*", ".*");
TPRegexp classSelPattern(classFromSelector);
if (tempClassID(classSelPattern) == tempClassID) {
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\") was successful", selector.Data(), classID.Data());
return kTRUE;
}
else {
::Info("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\") was unsuccessful", selector.Data(), classID.Data());
return kFALSE;
}
}
if (classFromSelector == tempClassID) {
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\") was successful", selector.Data(), classID.Data());
return kTRUE;
}
}
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ClassSearch(\"%s\", \"%s\") was unsuccessful", selector.Data(), classID.Data());
return kFALSE;
}
/// Checks object in selector
/// \param selector
/// \param objectID
/// \param verbose
/// \return true if object was found
Bool_t AliDrawStyle::ObjectSearch(const TString selector, const TString objectID, Int_t verbose) {
if (selector == TString("")) {
::Error("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\") selector should not be empty", selector.Data(), objectID.Data());
return kFALSE;
}
if (objectID == TString("")) {
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\") objectID is empty.", selector.Data(), objectID.Data());
return kTRUE;
}
TPRegexp objectPattern("[#].*");
TString objectFromSelector = "";
objectFromSelector = selector(objectPattern);
if (objectFromSelector == TString(""))
return kTRUE;
objectFromSelector = objectFromSelector(1,objectFromSelector.Length());
if (verbose == 4) ::Info("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\"). Selector was transformed to %s", selector.Data(), objectID.Data(), objectFromSelector.Data());
if (objectFromSelector.Index('*') >= 0) {
objectFromSelector = objectFromSelector.ReplaceAll("*", ".*");
TPRegexp objectSelPattern(objectFromSelector);
if (objectID(objectSelPattern) == objectID) {
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\") was successful", selector.Data(), objectID.Data());
return kTRUE;
}
else {
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\") was unsuccessful", selector.Data(), objectID.Data());
return kFALSE;
}
}
if (objectFromSelector == objectID) {
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\") was successful", selector.Data(), objectID.Data());
return kTRUE;
}
if (verbose == 4)
::Info("AliDrawStyle", "AliDrawStyle::ObjectSearch(\"%s\", \"%s\") was unsuccessful", selector.Data(), objectID.Data());
return kFALSE;
}
/// Function of checking the match between "CSS" selector and object parameters: elementID, classID, objectID
/// \param selectors - selector ID
/// \param elementName - name of element
/// \param className - name of class
/// \param objectName - object name
/// \return - kTRUE if selector match class name and object name
/*!
#### Example use:
\code
TString selectors = "\n\n\nTH1.Status#obj1, TH1.Warning#obj1, TH1.Warning#obj3 \tTGraph#obj1, TGraph.Status#TPC.QA.dcar_posA_1 \tTGraph.Warning#TPC.QA.dcar_posA_2 \tTF1.Status, .Status#obj1, #obj3";
AliDrawStyle::IsSelected(selectors, "", "", "obj3") // return true
AliDrawStyle::IsSelected(selectors, "TF1", "Warning", "obj3") // return true
AliDrawStyle::IsSelected(selectors, "TH1C", "Warning", "obj1") // return false
\endcode
*/
Bool_t AliDrawStyle::IsSelected(TString selectors, const TString elementID, const TString classID, const TString objectID, Int_t verbose) {
if (elementID == TString("") && classID == TString("") && objectID == TString("")) {
if (verbose == 4)