AliRoot Core  3dc7879 (3dc7879)
AliDrawStyleTest.C
Go to the documentation of this file.
1 
12 #include "Rtypes.h"
13 #include "TMath.h"
14 #include "TStyle.h"
15 #include "TPaveText.h"
16 #include "AliDrawStyle.h"
17 #include "Riostream.h"
18 #include <iostream>
19 #include "TSystem.h"
20 #include "TStopwatch.h"
21 #include "TROOT.h"
22 #include "TH1.h"
23 #include "TGraph.h"
24 #include "TRandom.h"
25 #include "TCanvas.h"
26 #include "TSystem.h"
27 #include "TPad.h"
28 #include "TLegend.h"
29 #include "AliPainter.h"
30 
38 // void AliDrawStyleTest_CSSReadWrite();
41 TCanvas *MakeTestPlot(Int_t nHis);
43 
52 // // AliDrawStyleTest_CSSReadWrite();
56 }
57 
59  Int_t result=0;
60  result = AliDrawStyle::GetMarkerStyle("1;2,3;4",0);
61  if (result!=1) {
62  ::Error("AliDrawStyleTest","AliDrawStyle::GetMarkerStyle(\"1;2,3;4\",0)==%d should be 1-FAILED\n",result);
63  }else{
64  ::Info("AliDrawStyleTest","AliDrawStyle::GetMarkerStyle(\"1;2,3;4\",0)- IsOK");
65  }
66  result = AliDrawStyle::GetMarkerStyle("1;2,3;4",1);
67  if (result!=2) {
68  ::Error("AliDrawStyleTest","AliDrawStyle::GetMarkerStyle(\"1;2,3;4\",1)==%d should be 2-FAILED\n",result);
69  }else{
70  ::Info("AliDrawStyleTest","AliDrawStyle::GetMarkerStyle(\"1;2,3;4\",1)- IsOK");
71  }
72  result = AliDrawStyle::GetMarkerStyle("1;2,3;4",0);
73  if (result!=1) {
74  ::Error("AliDrawStyleTest","AliDrawStyle::GetMarkerStyle(\"1;2,3;4\",0)==%d should be 1-FAILED\n",result);
75  }else{
76  ::Info("AliDrawStyleTest","AliDrawStyle::GetMarkerStyle(\"1;2,3;4\",0)- IsOK");
77  }
78 }
79 
81  TString input="{marker-style:25,21,22,23; marker-color:1,2,4,5;}";
82  if ( AliDrawStyle::ParseDeclaration(input,"marker-color").Contains("1,2,4,5")) {
83  ::Info("AliDrawStyleTest","AliDrawStyle::ParseDeclaration(%s, \"marker-color\")- IsOK", input.Data());
84  }else{
85  ::Error("AliDrawStyleTest","AliDrawStyle::ParseDeclaration(%s, \"marker-color\")- FAILED", input.Data());
86  }
87  if ( AliDrawStyle::ParseDeclaration(input,"marker-style").Contains("25,21,22,23")) {
88  ::Info("AliDrawStyleTest","AliDrawStyle::ParseDeclaration(%s, \"marker-style\")- IsOK", input.Data());
89  }else{
90  ::Error("AliDrawStyleTest","AliDrawStyle::ParseDeclaration(%s, \"marker-style\")- FAILED", input.Data());
91  }
92 }
93 
95  TString input="25";
96  Bool_t status;
97  if ( AliDrawStyle::ConvertColor(input.Data()) == 25) {
98  ::Info("AliDrawStyleTest","AliDrawStyle::ConvertColor(\"%s\")- IsOK", input.Data());
99  }else{
100  ::Error("AliDrawStyleTest","AliDrawStyle::ConvertColor(\"%s\")- FAILED", input.Data());
101  }
102  input = "rgb(0,0,0)";
103  if ( AliDrawStyle::ConvertColor(input.Data()) == 1) {
104  ::Info("AliDrawStyleTest","AliDrawStyle::ConvertColor(\"%s\")- IsOK", input.Data());
105  }else{
106  ::Error("AliDrawStyleTest","AliDrawStyle::ConvertColor(\"%s\")- FAILED", input.Data());
107  }
108  input = "#0000FF";
109  if ( AliDrawStyle::ConvertColor(input.Data()) == 4) {
110  ::Info("AliDrawStyleTest","AliDrawStyle::ConvertColor(\"%s\")- IsOK", input.Data());
111  }else{
112  ::Error("AliDrawStyleTest","AliDrawStyle::ConvertColor(\"%s\")- FAILED", input.Data());
113  }
114  input = "5";
115  if ( AliDrawStyle::ConvertColor(input.Data()) == 5) {
116  ::Info("AliDrawStyleTest","AliDrawStyle::ConvertColor(\"%s\")- IsOK", input.Data());
117  }else{
118  ::Error("AliDrawStyleTest","AliDrawStyle::ConvertColor(\"%s\")- FAILED", input.Data());
119  }
120  input = "rgb(255,255,0)";
121  if ( AliDrawStyle::ConvertColor(input.Data()) == 5) {
122  ::Info("AliDrawStyleTest","AliDrawStyle::ConvertColor(\"%s\")- IsOK", input.Data());
123  }else{
124  ::Error("AliDrawStyleTest","AliDrawStyle::ConvertColor(\"%s\")- FAILED", input.Data());
125  }
126  input = "#00FFFF";
127  if ( AliDrawStyle::ConvertColor(input.Data()) == 7) {
128  ::Info("AliDrawStyleTest","AliDrawStyle::ConvertColor(\"%s\")- IsOK", input.Data());
129  }else{
130  ::Error("AliDrawStyleTest","AliDrawStyle::ConvertColor(\"%s\")- FAILED", input.Data());
131  }
132 }
133 
135  TString input="{marker_style:25,21,22,23; marker-color:1,2,4,5,rgb(123,123,123),#dfdfdf;}";
136  Bool_t status;
137  if ( AliDrawStyle::GetNamedTypeAt(input,status, 0, "marker-color") == 1) {
138  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 0, \"marker-color\")- IsOK", input.Data(), status);
139  } else{
140  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 0, \"marker-color\")- FAILED", input.Data(), status);
141  }
142  if ( AliDrawStyle::GetNamedTypeAt(input,status, 1, "marker-color") == 2) {
143  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 1, \"marker-color\")- IsOK", input.Data(), status);
144  }else{
145  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 1, \"marker-color\")- FAILED", input.Data(), status);
146  }
147  if ( AliDrawStyle::GetNamedTypeAt(input,status, 2, "marker-color") == 4) {
148  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 2, \"marker-color\")- IsOK", input.Data(), status);
149  }else{
150  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 2, \"marker-color\")- FAILED", input.Data(), status);
151  }
152  if ( AliDrawStyle::GetNamedTypeAt(input,status, 3, "marker-color") == 5) {
153  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 3, \"marker-color\")- IsOK", input.Data(), status);
154  }else{
155  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 3, \"marker-color\")- FAILED", input.Data(), status);
156  }
157  if ( AliDrawStyle::GetNamedTypeAt(input,status, 0, "marker_style") == 25) {
158  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 0, \"marker_style\")- IsOK", input.Data(), status);
159  }else{
160  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 0, \"marker_style\")- FAILED", input.Data(), status);
161  }
162  if ( AliDrawStyle::GetNamedTypeAt(input,status, 1, "marker_style") == 21) {
163  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 1, \"marker_style\")- IsOK", input.Data(), status);
164  }else{
165  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 1, \"marker_style\")- FAILED", input.Data(), status);
166  }
167  if ( AliDrawStyle::GetNamedTypeAt(input,status, 2, "marker_style") == 22) {
168  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 2, \"marker_style\")- IsOK", input.Data(), status);
169  }else{
170  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 2, \"marker_style\")- FAILED", input.Data(), status);
171  }
172  if ( AliDrawStyle::GetNamedTypeAt(input,status, 3, "marker_style") == 23) {
173  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 3, \"marker_style\")- IsOK", input.Data(), status);
174  }else{
175  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 3, \"marker_style\")- FAILED", input.Data(), status);
176  }
177  if ( AliDrawStyle::GetNamedTypeAt(input,status, 4, "marker-color") == 202 || AliDrawStyle::GetNamedTypeAt(input,status, 4, "marker-color") == 14) {
178  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 4, \"marker-color\")- IsOK", input.Data(), status);
179  }else{
180  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 4, \"marker-color\")- FAILED", input.Data(), status);
181  }
182  if ( AliDrawStyle::GetNamedTypeAt(input,status, 5, "marker-color") == 1179 || AliDrawStyle::GetNamedTypeAt(input,status, 5, "marker-color") == 924 || AliDrawStyle::GetNamedTypeAt(input,status, 5, "marker-color") == 18) {
183  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 5, \"marker-color\")- IsOK", input.Data(), status);
184  }else{
185  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(%s, %d, 5, \"marker-color\")- FAILED", input.Data(), status);
186  }
187 }
188 
190  TString input="{margin-top:300%,474px,5; marker-size:8px,2,4,500%;}";
191  Bool_t status;
192 
193  if ( AliDrawStyle::GetNamedTypeAt(input,status,0, "marker-size") - 1 <= 0.01) {
194  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 0, \"marker-size\")- IsOK", input.Data(), status);
195  }else{
196  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 0, \"marker-size\")- FAILED", input.Data(), status);
197  }
198  if ( AliDrawStyle::GetNamedTypeAt(input,status,1, "marker-size") - 2 <= 0.01) {
199  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 1, \"marker-size\")- IsOK", input.Data(), status);
200  }else{
201  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 1, \"marker-size\")- FAILED", input.Data(), status);
202  }
203  if (AliDrawStyle::GetNamedTypeAt(input,status,2, "marker-size") - 4 <= 0.01) {
204  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 2, \"marker-size\")- IsOK", input.Data(), status);
205  }else{
206  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 2, \"marker-size\")- FAILED", input.Data(), status);
207  }
208  if ( AliDrawStyle::GetNamedTypeAt(input,status,3, "marker-size") - 5 <= 0.01) {
209  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 3, \"marker-size\")- IsOK", input.Data(), status);
210  }else{
211  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 3, \"marker-size\")- FAILED", input.Data(), status);
212  }
213  TCanvas *exampleCanvas = new TCanvas("c1", "The AliDrawStyle::ApplyCssStyle example", 200, 10, 1200, 900);
214  TPad *pad = new TPad("testPad", "testPad",0,0,1,1);
215  pad->Draw();
216  if ( AliDrawStyle::GetNamedTypeAt(input,status,0, "margin-top") - 3 <= 0.01) {
217  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 0, \"margin-top\")- IsOK", input.Data(), status);
218  }else{
219  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 0, \"margin-top\")- FAILED", input.Data(), status);
220  }
221  if ( AliDrawStyle::GetNamedTypeAt(input,status,1, "margin-top") - 1 <= 0.01) {
222  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 1, \"margin-top\")- IsOK", input.Data(), status);
223  }else{
224  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 1, \"margin-top\")- FAILED", input.Data(), status);
225  }
226  if ( AliDrawStyle::GetNamedTypeAt(input,status,2, "margin-top") - 5 <= 0.01) {
227  ::Info("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 2, \"margin-top\")- IsOK", input.Data(), status);
228  }else{
229  ::Error("AliDrawStyleTest","AliDrawStyle::GetNamedTypeAt(\"%s\", %d, 2, \"margin-top\")- FAILED", input.Data(), status);
230  }
231 }
232 
234  TString selectors = "TH1.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\t .deadBand";
235 
236  if (!AliDrawStyle::IsSelected(selectors, "TH1", "deadBand", "")) {
237  ::Info("AliDrawStyleTest","!AliDrawStyle::IsSelected(\"%s\",\"TH1\", \"deadBand\", \"\")- IsOK", selectors.Data());
238  } else{
239  ::Error("AliDrawStyleTest","!AliDrawStyle::IsSelected(\"%s\",\"TH1\", \"deadBand\", \"\")- FAILED", selectors.Data());
240  }
241  if(AliDrawStyle::IsSelected(selectors, "TGraph", "deadBand", "")) {
242  ::Info("AliDrawStyleTest","AliDrawStyle::IsSelected(\"%s\",\"TGraph\", \"deadBand\", \"\")- IsOK", selectors.Data());
243  } else{
244  ::Error("AliDrawStyleTest","AliDrawStyle::IsSelected(\"%s\",\"TGraph\", \"deadBand\", \"\")- FAILED", selectors.Data());
245  }
246  if(AliDrawStyle::IsSelected(selectors, "", "deadBand", "")) {
247  ::Info("AliDrawStyleTest","AliDrawStyle::IsSelected(\"%s\",\"\", \"deadBand\", \"\")- IsOK", selectors.Data());
248  } else{
249  ::Error("AliDrawStyleTest","AliDrawStyle::IsSelected(\"%s\",\"\", \"deadBand\", \"\")- FAILED", selectors.Data());
250  }
251  if(AliDrawStyle::IsSelected(selectors, "", "deadBand2", "")) {
252  ::Info("AliDrawStyleTest","AliDrawStyle::IsSelected(\"%s\",\"\", \"deadBand2\", \"\")- IsOK", selectors.Data());
253  } else{
254  ::Error("AliDrawStyleTest","AliDrawStyle::IsSelected(\"%s\",\"\", \"deadBand2\", \"\")- FAILED", selectors.Data());
255  }
256  if(!AliDrawStyle::IsSelected(selectors, "TH1", "deadBand2", "")) {
257  ::Info("AliDrawStyleTest","!AliDrawStyle::IsSelected(\"%s\",\"TH1\", \"deadBand2\", \"\")- IsOK", selectors.Data());
258  } else{
259  ::Error("AliDrawStyleTest","!AliDrawStyle::IsSelected(\"%s\",\"TH1\", \"deadBand2\", \"\")- FAILED", selectors.Data());
260  }
261  if(AliDrawStyle::IsSelected(selectors, "TGraph", "Status", "")) {
262  ::Info("AliDrawStyleTest","AliDrawStyle::IsSelected(\"%s\",\"TGraph\", \"Status\", \"\")- IsOK", selectors.Data());
263  } else{
264  ::Error("AliDrawStyleTest","AliDrawStyle::IsSelected(\"%s\",\"TGraph\", \"Status\", \"\")- FAILED", selectors.Data());
265  }
266  if(!AliDrawStyle::IsSelected(selectors, "TGraph", "Warning", "obj3")) {
267  ::Info("AliDrawStyleTest","!AliDrawStyle::IsSelected(\"%s\",\"TGraph\", \"Warning\", \"obj3\")- IsOK", selectors.Data());
268  } else{
269  ::Error("AliDrawStyleTest","!AliDrawStyle::IsSelected(\"%s\",\"TGraph\", \"Warning\", \"obj3\")- FAILED", selectors.Data());
270  }
271 }
272 
274  TString elementID = "";
275  TString classID = "";
276  TString objectID = "";
277  TString styleID = "";
278 
279  TH1F *his = new TH1F("his1.style(345)", "title", 100,-5,5);
280  TObject *obj = (TObject *) his;
281  AliDrawStyle::GetIds(obj, elementID, classID, objectID, styleID);
282  if(elementID == TString("TH1F") && classID == TString("") && objectID == TString("his1") && styleID == TString("345")) {
283  ::Info("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- IsOK", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
284  } else{
285  ::Error("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- FAILED", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
286  }
287 
288  TH1F *his8 = new TH1F("his1.class(123)", "title", 100,-5,5);
289  obj = (TObject *) his8;
290  AliDrawStyle::GetIds(obj, elementID, classID, objectID, styleID);
291  if(elementID == TString("TH1F") && classID == TString("123") && objectID == TString("his1") && styleID == TString("")) {
292  ::Info("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- IsOK", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
293  } else{
294  ::Error("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- FAILED", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
295  }
296 
297  elementID = "";
298  classID = "";
299  objectID = "";
300  styleID = "";
301  TH1F *his2 = new TH1F("his1.class(123).style(345)", "title", 100,-5,5);
302  obj = (TObject *) his2;
303  AliDrawStyle::GetIds(obj, elementID, classID, objectID, styleID);
304  if(elementID == TString("TH1F") && classID == TString("123") && objectID == TString("his1") && styleID == TString("345")) {
305  ::Info("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- IsOK", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
306  } else{
307  ::Error("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- FAILED", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
308  }
309 
310  elementID = "";
311  classID = "";
312  objectID = "";
313  styleID = "";
314  TH1F *his3 = new TH1F("his1.TPC.RAW.class(123).style(345)", "title", 100,-5,5);
315  obj = (TObject *) his3;
316  AliDrawStyle::GetIds(obj, elementID, classID, objectID, styleID);
317  if(elementID == TString("TH1F") && classID == TString("123") && objectID == TString("his1.TPC.RAW") && styleID == TString("345")) {
318  ::Info("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- IsOK", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
319  } else{
320  ::Error("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- FAILED", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
321  }
322 
323  elementID = "";
324  classID = "";
325  objectID = "";
326  styleID = "";
327  TH1F *his4 = new TH1F("his1.TPC.RAW.style(345).class(123)", "title", 100,-5,5);
328  obj = (TObject *) his4;
329  AliDrawStyle::GetIds(obj, elementID, classID, objectID, styleID);
330  if(elementID == TString("TH1F") && classID == TString("123") && objectID == TString("his1.TPC.RAW") && styleID == TString("345")) {
331  ::Info("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- IsOK", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
332  } else{
333  ::Error("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- FAILED", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
334  }
335 
336  elementID = "";
337  classID = "";
338  objectID = "";
339  styleID = "";
340  TH1F *his5 = new TH1F("his.TPC.RAW[1].style(345).class(123)", "title", 100,-5,5);
341  obj = (TObject *) his5;
342  AliDrawStyle::GetIds(obj, elementID, classID, objectID, styleID);
343  if(elementID == TString("TH1F") && classID == TString("123") && objectID == TString("his.TPC.RAW") && styleID == TString("345")) {
344  ::Info("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- IsOK", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
345  } else{
346  ::Error("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- FAILED", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
347  }
348 
349  elementID = "";
350  classID = "";
351  objectID = "";
352  styleID = "";
353  TH1F *his6 = new TH1F("his[1]", "title", 100,-5,5);
354  obj = (TObject *) his6;
355  AliDrawStyle::GetIds(obj, elementID, classID, objectID, styleID);
356  if(elementID == TString("TH1F") && classID == TString("") && objectID == TString("his") && styleID == TString("")) {
357  ::Info("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- IsOK", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
358  } else{
359  ::Error("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- FAILED", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
360  }
361 
362  elementID = "";
363  classID = "";
364  objectID = "";
365  styleID = "";
366  TH1F *his7 = new TH1F("his7", "title", 100,-5,5);
367  obj = (TObject *) his7;
368  AliDrawStyle::GetIds(obj, elementID, classID, objectID, styleID);
369  if(elementID == TString("TH1F") && classID == TString("") && objectID == TString("his7") && styleID == TString("")) {
370  ::Info("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- IsOK", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
371  } else{
372  ::Error("AliDrawStyleTest","AliDrawStyle::GetIds(\"%s\",\"%s\", \"%s\", \"%s\", \"%s\")- FAILED", obj->GetName(), elementID.Data(), classID.Data(), objectID.Data(), styleID.Data());
373  }
374 
375 }
376 
380 // void AliDrawStyleTest_CSSReadWrite() {
381 //
382 // if (gSystem->GetFromPipe(TString("[ -f ") + TString("$AliRoot_SRC/STAT/test/alirootTestStyle.css") + TString(" ] && echo 1 || echo 0")) == "0") {
383 // std::cout << "File doesn't exist1" << std::endl;
384 // ::Info("AliDrawStyleTest","AliDrawStyleTest_CSSReadWrite()- ");
385 // return;
386 // }
387 // TObjArray *cssArray = AliDrawStyle::ReadCSSFile("$AliRoot_SRC/STAT/test/alirootTestStyle.css",0);
388 // if (cssArray == NULL) {
389 // std::cout << "null-pointer error" << std::endl;
390 // ::Info("AliDrawStyleTest","AliDrawStyleTest_CSSReadWrite()- ");
391 // return;
392 // }
393 // AliDrawStyle::WriteCSSFilecssArray,"$AliRoot_SRC/STAT/test/test.css");
394 // TObjArray *cssArrayFromTest = AliDrawStyle::ReadCSSFile("$AliRoot_SRC/STAT/test/test.css",0);
395 // //AliDrawStyle::WriteCSSFile
396 // //AliDrawStyle::WriteCSSFile
397 //
398 // for (Int_t i = 0; i < cssArray->GetEntriesFast(); i++) {
399 // if ((TString(cssArray->At(i)->GetName()).ReplaceAll("\n", "") == TString(cssArrayFromTest->At(i)->GetName()).ReplaceAll("\n", "")) && TString(cssArray->At(i)->GetTitle()).ReplaceAll("\n", "") == TString(cssArrayFromTest->At(i)->GetTitle()).ReplaceAll("\n", "")) ::Info("AliDrawStyleTest","AliDrawStyleTest_CSSReadWrite()- ");
400 // else ::Info("AliDrawStyleTest","AliDrawStyleTest_CSSReadWrite()- ");
401 //
402 // }
403 // gSystem->GetFromPipe("rm -f $AliRoot_SRC/STAT/test/test.css");
404 //
405 // }
406 
408  AliDrawStyle::RegisterCssStyle("alirootTestStyle.css",AliDrawStyle::ReadCSSFile("$AliRoot_SRC/STAT/test/alirootTestStyle.css",0));
409  if (AliDrawStyle::GetValue("alirootTestStyle.css","marker-size", "TGraph", "Status", "TPC.QA.dcar_posA_1", "") == "1,2,3,4") {
410  ::Info("AliDrawStyleTest","AliDrawStyle::GetValue(\"alirootTestStyle.css\",\"marker-size\", \"TGraph\", \"Status\", \"TPC.QA.dcar_posA_1\", \"\")- IsOK");
411  }else{
412  ::Error("AliDrawStyleTest","AliDrawStyle::GetValue(\"alirootTestStyle.css\",\"marker-size\", \"TGraph\", \"Status\", \"TPC.QA.dcar_posA_1\", \"\")- FAILED");
413  }
414  if (AliDrawStyle::GetValue("alirootTestStyle.css","marker-size", "TF1", "Status", "obj4", "") == "17,18,19,20") {
415  ::Info("AliDrawStyleTest","AliDrawStyle::GetValue(\"alirootTestStyle.css\",\"marker-size\", \"TF1\", \"Status\", \"obj4\", \"\")- IsOK");
416  }else{
417  ::Error("AliDrawStyleTest","AliDrawStyle::GetValue(\"alirootTestStyle.css\",\"marker-size\", \"TF1\", \"Status\", \"obj4\", \"\")- FAILED");
418  }
419  if (AliDrawStyle::GetValue("alirootTestStyle.css","line-color", "TGraphErrors", "Warning", "asdasobj56", "") == "41,42,43,44") {
420  ::Info("AliDrawStyleTest","AliDrawStyle::GetValue(\"alirootTestStyle.css\",\"line-color\", \"TGraphErrors\", \"Warning\", \"asdasobj56\", \"\")- IsOK");
421  }else{
422  ::Error("AliDrawStyleTest","AliDrawStyle::GetValue(\"alirootTestStyle.css\",\"line-color\", \"TGraphErrors\", \"Warning\", \"asdasobj56\", \"\")- FAILED");
423  }
424  if (AliDrawStyle::GetValue("alirootTestStyle.css","marker-color", "TObject", "SomeNotExistingStatus", "obj3", "") == "37,38,39,40") {
425  ::Info("AliDrawStyleTest","AliDrawStyle::GetValue(\"alirootTestStyle.css\",\"marker-color\", \"SomeNotExistingClass\", \"SomeNotExistingStatus\", \"obj3\", \"\")- IsOK");
426  }else{
427  ::Error("AliDrawStyleTest","AliDrawStyle::GetValue(\"alirootTestStyle.css\",\"marker-color\", \"SomeNotExistingClass\", \"SomeNotExistingStatus\", \"obj3\", \"\")- FAILED");
428  }
429  if (AliDrawStyle::GetValue("alirootTestStyle.css","line-color", "TH1", "Warning", "obj1", "") == "57,58,59,60") {
430  ::Info("AliDrawStyleTest","AliDrawStyle::GetValue(\"alirootTestStyle.css\",\"line-color\", \"TH1\", \"Warning\", \"obj1\", \"\")- IsOK");
431  }else{
432  ::Error("AliDrawStyleTest","AliDrawStyle::GetValue(\"alirootTestStyle.css\",\"line-color\", \"TH1\", \"Warning\", \"obj1\", \"\")- FAILED");
433  }
434 }
435 
437  TCanvas *canv = MakeTestPlot(3);
438  AliDrawStyle::RegisterCssStyle("test1",AliDrawStyle::ReadCSSFile("$AliRoot_SRC/STAT/test/test1.css",0));
439  AliDrawStyle::ApplyCssStyle(canv, "test1");
440  canv->Print("test1.xml");
441  AliDrawStyle::RegisterCssStyle("test2",AliDrawStyle::ReadCSSFile("$AliRoot_SRC/STAT/test/test2.css",0));
442  AliDrawStyle::ApplyCssStyle(canv, "test2");
443  AliDrawStyle::ApplyCssStyle(canv, "test1");
444  canv->Print("test2-1.xml");
445  Int_t nDiff = gSystem->GetFromPipe("diff test1.xml test2-1.xml | wc -l").Atoi();
446  if (nDiff - 4 == 0) {
447  ::Info("AliDrawStyleTest","AliDrawStyle::ApplyStyle(\"canv\",\"test1\")- IsOK");
448  }else{
449  ::Error("AliDrawStyleTest","AliDrawStyle::ApplyStyle(\"canv\",\"test1\")- FAILED");
450  }
451 }
452 
453 TCanvas *MakeTestPlot(Int_t nHis) {
454  TRandom r;
455  TCanvas *exampleCanvas = new TCanvas("c1", "The AliDrawStyle::ApplyCssStyle example", 200, 10, 1200, 900);
456  exampleCanvas->Divide(1,2);
457  //AliPainter::DivideTPad("<vertical>[1l,1r]", "Raw", "gridX:0;gridY:0;tickX:0;tickY:0;", exampleCanvas);
458  exampleCanvas->cd(1);
459  TH1F *hisArray[nHis];
460  for (Int_t i = 0; i < nHis; i++) {
461  hisArray[i] = new TH1F(TString::Format("his%d.class(Raw)", i).Data(),
462  TString::Format("his%d.class(Raw)", i).Data(), 100, -5, 5);
463  hisArray[i]->SetStats(0);
464  hisArray[i]->SetTitle(TString::Format("his%d", i).Data());
465  hisArray[i]->SetMarkerStyle(1);
466  hisArray[i]->FillRandom("gaus", 100000 / (i + 2));
467  if (i == 0) hisArray[i]->Draw("err");
468  else hisArray[i]->Draw("SAMEerr");
469  }
470  // gPad->BuildLegend();
471 
472  exampleCanvas->cd(2);
473  const Int_t n = 100;
474  Double_t x[n], y[n];
475  TGraph *grArray[nHis];
476  for (Int_t j = 0; j < n; j++) {
477  x[j] = j * 0.6 + 5;
478  y[j] = (nHis) * log(x[j]);
479  }
480 
481  for (Int_t i = 0; i < nHis; i++) {
482  for (Int_t j = 0; j < n; j++) {
483  x[j] = j * 0.6 + 5;
484  y[j] = log(x[j]) / (i + 1);
485  }
486  grArray[i] = new TGraph(n, x, y);
487  grArray[i]->SetName(TString::Format("graph%d.class(Raw).style(marker-size:%d;marker-color:%d;)", i,i/3 + 1, i + 1).Data());
488  grArray[i]->SetTitle(TString::Format("gr%d", i).Data());
489  if (i == 0) {
490  grArray[i]->SetMinimum(0);
491  grArray[i]->Draw("alp");
492  }
493  else grArray[i]->Draw("lp");
494  }
495  // gPad->BuildLegend();
496  return exampleCanvas;
497 }
498 
500  TCanvas *canvasT = new TCanvas("canvasT", "canvasT", 900, 500);
501  canvasT->Divide(1,1);
502  canvasT->cd(1);
503  TH1F *his1 = new TH1F("his1.class(Error).style(line-color:#f30000;)", "his1", 100, -5, 5);
504  his1->FillRandom("gaus", 15000);
505  his1->SetStats(kFALSE);
506  TH1D *his2 = new TH1D("his2.class(Error)", "his2", 100, -5, 5);
507  his2->FillRandom("gaus", 10000);
508  TH1I *his3 = new TH1I("his3.class(Error)", "his3", 100, -5, 5);
509  his3->FillRandom("gaus", 5000);
510  his1->Draw();
511  his2->Draw("same");
512  his3->Draw("same");
513  gStyle->SetOptTitle(0);
514  TPaveText *pt = new TPaveText(-0.438183, 694.575009, 0.438183, 740.053135);
515  pt->AddText("Example of styling with using AliDrawStyle");
516  pt->SetTextSize(0.04);
517  pt->SetShadowColor(0);
518  pt->SetBorderSize(0);
519  pt->SetFillColor(0);
520  pt->Draw();
521  gPad->BuildLegend();
522  canvasT->SaveAs("$AliRoot_SRC/STAT/imgdoc/AliDrawStyle_h_example1.png");
523  canvasT->Clear();
524 
525  canvasT->Divide(1,1);
526  canvasT->cd(1);
527  his1->Draw();
528  his2->Draw("same");
529  his3->Draw("same");
530  gStyle->SetOptTitle(0);
531  pt->Draw();
532  gPad->BuildLegend();
533 
534  AliDrawStyle::RegisterCssStyle("AliDrawStyleTutor", AliDrawStyle::ReadCSSFile("$AliRoot_SRC/STAT/test/AliDrawStyleTutor.css"));
535  AliDrawStyle::ApplyCssStyle(canvasT, "AliDrawStyleTutor");
536  canvasT->SaveAs("$AliRoot_SRC/STAT/imgdoc/AliDrawStyle_h_example2.png");
537  canvasT->Clear();
538  }
static Bool_t IsSelected(TString selectors, const TString elementID, const TString classID, const TString objectID, Int_t verbose=0)
TStyle * gStyle
void AliDrawStyleTest_GenerateDoxyImages()
void AliDrawStyleTest()
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 TString ParseDeclaration(const char *inputDec, const char *propertyName)
void AliDrawStyleTest_GetIds()
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="()")
TObjArray * hisArray
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...
void AliDrawStyleTest_GetFloatValues()
void AliDrawStyleTest_GetIntValues()
void AliDrawStyleTest_ApplyCssStyle()
static TObjArray * ReadCSSFile(const char *inputName, TObjArray *array=nullptr, Int_t verbose=0)
void AliDrawStyleTest_ConvertColor()
static void RegisterCssStyle(const char *styleName, TObjArray *array)
Definition: AliDrawStyle.h:304
void AliDrawStyleTest_GetValue()
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...
void AliDrawStyleTest_IsSelected()
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 ...
void AliDrawStyleTest_ParseDeclaration()
TCanvas * MakeTestPlot(Int_t nHis)
void AliDrawStyleTest_StyleArray()
test of AliDrawStyleTest macro Example usage
static Int_t GetMarkerStyle(const char *style, Int_t index)