change library dependencies and paths to the new places of the analysis under PWGGA...
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / macros / PlottingGammaConversionHistos.h
CommitLineData
dab7b5d6 1/***********************************************************************************************
5fdef45d 2*** provided by Gamma Conversion Group, PWGGA, ******
dab7b5d6 3*** Friederike Bock, fbock@physi.uni-heidelberg.de *** ******
4************************************************************************************************/
5
6
7/************************************************************************************************
8/************************************************************************************************
9/* This header was created to make things easier with making plots for the gamma conversion group.
10 it offers you several functions for drawing and styling your histogramms.
11/************************************************************************************************
12/************************************************************************************************
13
14 The functions are
15 - StyleSettingsThesis
16 - StyleSettings
17 - GammaScalingHistogramm
18
19 - DrawAutoGammaHistos
20 - DrawAutoGammaHisto
21 - DrawAutoGammaHisto2D
22
23 - DrawRatioGammaHisto
24
25 - DrawCutGammaHisto
26 - DrawCutGammaHistos
27
28 - DrawGammaLines
29*/
30
31#include <Riostream.h>
32
77ac6f3e 33//extern TRandom *kgRandom;
34//extern TBenchmark *kgBenchmark;
35//extern TSystem *kgSystem;
dab7b5d6 36
37
38// ---------------------------- Function definiton --------------------------------------------------------------------------------------------
39
40
41/* StyleSettingsThesis will make some standard settings for gStyle
42*/
43void StyleSettingsThesis(){
44 //gStyle->SetOptTitle(kFALSE);
45 gStyle->SetOptDate(0); //show day and time
46 gStyle->SetOptStat(0); //show statistic
47 gStyle->SetPalette(1,0);
48 gStyle->SetFrameBorderMode(0);
49 gStyle->SetFrameFillColor(0);
50 gStyle->SetTitleFillColor(0);
51 gStyle->SetTextSize(0.5);
52 gStyle->SetLabelSize(0.03,"xyz");
53 gStyle->SetLabelOffset(0.002,"xyz");
54 gStyle->SetTitleFontSize(0.04);
55 gStyle->SetTitleOffset(1,"y");
56 gStyle->SetTitleOffset(0.7,"x");
57 gStyle->SetCanvasColor(0);
58 gStyle->SetPadTickX(1);
59 gStyle->SetPadTickY(1);
60 gStyle->SetLineWidth(0.01);
61
62 gStyle->SetPadTopMargin(0.03);
63 gStyle->SetPadBottomMargin(0.09);
64 gStyle->SetPadRightMargin(0.03);
65 gStyle->SetPadLeftMargin(0.13);
66
67
68 TGaxis::SetMaxDigits(3);
69}
70
71
72/* StyleSettings will make some standard settings for gStyle
73*/
74void StyleSettings(){
75 //gStyle->SetOptTitle(kFALSE);
76 gStyle->SetOptDate(0); //show day and time
77 gStyle->SetOptStat(0); //show statistic
78 gStyle->SetPalette(1,0);
79 gStyle->SetFrameBorderMode(0);
80 gStyle->SetFrameFillColor(0);
81 gStyle->SetTitleFillColor(0);
82 gStyle->SetTextSize(0.5);
83 gStyle->SetLabelSize(0.03,"xyz");
84 gStyle->SetLabelOffset(0.002,"xyz");
85 gStyle->SetTitleFontSize(0.04);
86 gStyle->SetTitleOffset(1,"y");
87 gStyle->SetTitleOffset(0.7,"x");
88 gStyle->SetCanvasColor(0);
89 gStyle->SetPadTickX(1);
90 gStyle->SetPadTickY(1);
91 gStyle->SetLineWidth(0.01);
92
93 gStyle->SetPadTopMargin(0.1);
94 gStyle->SetPadBottomMargin(0.1);
95 gStyle->SetPadRightMargin(0.08);
96 gStyle->SetPadLeftMargin(0.12);
97
98
99 TGaxis::SetMaxDigits(3);
100}
101
102
77ac6f3e 103void SetPlotStyle() {
104 const Int_t nRGBs = 5;
105 const Int_t nCont = 255;
dab7b5d6 106
77ac6f3e 107 Double_t stops[nRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
108 Double_t red[nRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
109 Double_t green[nRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
110 Double_t blue[nRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
111 TColor::CreateGradientColorTable(nRGBs, stops, red, green, blue, nCont);
112 gStyle->SetNumberContours(nCont);
dab7b5d6 113}
114
115
116
117
118// GammaScalingHistogram will scale the histogram by "Factor"
119void GammaScalingHistogramm(TH1 *histo, Float_t Factor){
120 histo->Sumw2();
121 histo->Scale(Factor);
122}
123
124// GammaScalingHistogram will scale the histogram by "Factor"
125void GammaScalingHistogramm(TH2 *histo, Float_t Factor){
126 histo->Sumw2();
127 histo->Scale(Factor);
128}
129
130void StylingSliceHistos(TH1 *histo, Float_t markersize){
131 histo->SetMarkerStyle(22);
132 histo->SetMarkerSize(markersize);
133}
134
135
136
137/************************************ OLD VERSION ************************************
138
139/*void DrawAutoGammaHistos( TH1* histo1,
140 TH1*histo2,
141 const char *Title, const char *XTitle, const char *YTitle,
142 Bool_t YRangeMax, Float_t YMaxFactor, Float_t YMinimum,
143 Bool_t YRange, Float_t YMin ,Float_t YMax,
144 Bool_t XRange, Float_t XMin, Float_t XMax) {
145 if (YRangeMax && !XRange){
146 YRange = kFALSE;
77ac6f3e 147 Double_t maxRangeR = histo1->GetMaximum();
148 if(maxRangeR < histo2->GetMaximum()){
149 maxRangeR = histo2->GetMaximum();
dab7b5d6 150 }
77ac6f3e 151 Double_t minRangeR = histo1->GetMinimum();
152 if(minRangeR > histo2->GetMinimum()){
153 minRangeR = histo2->GetMinimum();
dab7b5d6 154 }
77ac6f3e 155 if(YMinimum > minRangeR){minRangeR = YMinimum;}
156 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 157 }
158 if (YRangeMax && XRange){
159 YRange = kFALSE;
77ac6f3e 160 Double_t maxRangeR = histo1->GetMaximum();
161 if(maxRangeR < histo2->GetMaximum()){
162 maxRangeR = histo2->GetMaximum();
dab7b5d6 163 }
77ac6f3e 164 Double_t minRangeR = histo1->GetMinimum();
165 if(minRangeR > histo2->GetMinimum()){
166 minRangeR = histo2->GetMinimum();
dab7b5d6 167 }
77ac6f3e 168 if(YMinimum > minRangeR){minRangeR = YMinimum;}
169 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 170 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
171 }
172 if (YRange && XRange){
173 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
174 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
175 }
176 if (!YRangeMax && !YRange && XRange){
177 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
178 }
179 if (YRange && !XRange){
180 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
181 }
182
183 if(Title != ""){
184 histo1->SetTitle(Title);
185 }
186 if(XTitle ! =""){
187 histo1->SetXTitle(XTitle);
188 }
189 if(YTitle ! =""){
190 histo1->SetYTitle(YTitle);
191 }
192 histo1->GetYaxis()->SetLabelSize(0.02);
193 histo1->GetYaxis()->SetTitleSize(0.025);
194 histo1->GetYaxis()->SetDecimals();
195 histo1->GetYaxis()->SetTitleOffset(1.8);
196 histo1->GetXaxis()->SetTitleSize(0.025);
197 histo1->GetXaxis()->SetLabelSize(0.02);
198 histo1->DrawCopy("e,hist");
199 histo2->SetLineColor(2);
200 histo2->DrawCopy("e,hist,same");
201 leg1 = new TLegend( 0.6,0.82,0.92,0.9);
202 leg1->SetTextSize(0.04);
203 leg1->SetFillColor(0);
204 leg1->AddEntry(histo1,("Data"));
205 leg1->AddEntry(histo2,("MC"));
206 leg1->Draw();
207
208}
209*/
210
211
212/* DrawAutoGammaHistos is function used for styling the histograms of the gamma conversion group for two histos and standart settings
213 * histo1 - first histogram (Data)
214 * histo2 - second histogram (MC)
215 * Title - histogram title
216 * XTitle - X-axis title
217 * YTitle - Y-axis title
218 * YRangeMax = kTRUE will scale by Maximum and Minimum Range in Y
219 *YMaxFactor - will MaximumY by this factor if YRangeMay = kTRUE
220 *YMinimum - this will be used if YRangeMax is set
221 *YRange = kTRUE will Cut y-axis by YMin and YMax
222 - will be set to kFAlSE if YRangeMax is set
223 *YMin - minimum Y
224 *YMax - maximum Y
225 *XRange = kTRUE will Cut x-axis by XMin and XMax
226 *XMin - minimum Y
227 *XMax - maximum Y
228*/
229
230void DrawAutoGammaHistos( TH1* histo1,
231 TH1*histo2,
232 const char *Title, const char *XTitle, const char *YTitle,
233 Bool_t YRangeMax, Float_t YMaxFactor, Float_t YMinimum,
234 Bool_t YRange, Float_t YMin ,Float_t YMax,
235 Bool_t XRange, Float_t XMin, Float_t XMax) {
236 if (YRangeMax && !XRange){
237 YRange = kFALSE;
77ac6f3e 238 Double_t maxRangeR = histo1->GetMaximum();
239 if(maxRangeR < histo2->GetMaximum()){
240 maxRangeR = histo2->GetMaximum();
dab7b5d6 241 }
77ac6f3e 242 Double_t minRangeR = histo1->GetMinimum();
243 if(minRangeR > histo2->GetMinimum()){
244 minRangeR = histo2->GetMinimum();
dab7b5d6 245 }
77ac6f3e 246 if(YMinimum > minRangeR){minRangeR = YMinimum;}
247 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 248 }
249 if (YRangeMax && XRange){
250 YRange = kFALSE;
77ac6f3e 251 Double_t maxRangeR = histo1->GetMaximum();
252 if(maxRangeR < histo2->GetMaximum()){
253 maxRangeR = histo2->GetMaximum();
dab7b5d6 254 }
77ac6f3e 255 Double_t minRangeR = histo1->GetMinimum();
256 if(minRangeR > histo2->GetMinimum()){
257 minRangeR = histo2->GetMinimum();
dab7b5d6 258 }
77ac6f3e 259 if(YMinimum > minRangeR){minRangeR = YMinimum;}
260 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 261 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
262 }
263 if (YRange && XRange){
264 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
265 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
266 }
267 if (!YRangeMax && !YRange && XRange){
268 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
269 }
270 if (YRange && !XRange){
271 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
272 }
273
274 if(Title != ""){
275 histo1->SetTitle(Title);
276 }else{histo1->SetTitle();
277 histo2->SetTitle();}
278 if(XTitle ! =""){
279 histo1->SetXTitle(XTitle);
280 }
281 if(YTitle ! =""){
282 histo1->SetYTitle(YTitle);
283 }
284 histo1->GetYaxis()->SetLabelSize(0.035);
285 histo1->GetYaxis()->SetTitleSize(0.04);
286 histo1->GetYaxis()->SetDecimals();
287 histo1->GetYaxis()->SetTitleOffset(1.8);
288 histo1->GetXaxis()->SetTitleSize(0.04);
289 histo1->GetXaxis()->SetLabelSize(0.035);
290 histo1->DrawCopy("e,hist");
291 histo2->SetLineColor(2);
292 histo2->DrawCopy("e,hist,same");
293 leg1 = new TLegend( 0.7,0.87,0.97,0.97);
294 leg1->SetTextSize(0.04);
295 leg1->SetFillColor(0);
296 leg1->AddEntry(histo1,("Data"));
297 leg1->AddEntry(histo2,("MC"));
298 leg1->Draw();
299
300}
301
302
303/* DrawAutoGammaHisto is function used for styling a histograma of the gamma conversion group with standart settings
304 * histo1 - first histogram (Data)
305 * Title - histogram title
306 * XTitle - X-axis title
307 * YTitle - Y-axis title
308 * YRangeMax = kTRUE will scale by Maximum and Minimum Range in Y
309 *YMaxFactor - will MaximumY by this factor if YRangeMay = kTRUE
310 *YMinimum - this will be used if YRangeMax is set
311 *YRange = kTRUE will Cut y-axis by YMin and YMax
312 - will be set to kFAlSE if YRangeMax is set
313 *YMin - minimum Y
314 *YMax - maximum Y
315 *XRange = kTRUE will Cut x-axis by XMin and XMax
316 *XMin - minimum Y
317 *XMax - maximum Y
318*/
319void DrawAutoGammaHisto( TH1* histo1,
320 const char *Title, const char *XTitle, const char *YTitle,
321 Bool_t YRangeMax, Float_t YMaxFactor, Float_t YMinimum,
322 Bool_t YRange, Float_t YMin ,Float_t YMax,
323 Bool_t XRange, Float_t XMin, Float_t XMax) {
324 if (YRangeMax && !XRange){
325 YRange = kFALSE;
77ac6f3e 326 Double_t maxRangeR = histo1->GetMaximum();
327 Double_t minRangeR = histo1->GetMinimum();
328 if(YMinimum > minRangeR){minRangeR = YMinimum;}
329 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 330 }
331 if (YRangeMax && XRange){
332 YRange = kFALSE;
77ac6f3e 333 Double_t maxRangeR = histo1->GetMaximum();
334 Double_t minRangeR = histo1->GetMinimum();
335 if(YMinimum > minRangeR){minRangeR = YMinimum;}
336 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 337 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
338 }
339 if (YRange && XRange){
340 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
341 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
342 }
343 if (!YRangeMax && !YRange && XRange){
344 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
345 }
346
347 if (YRange && !XRange){
348 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
349 }
350
351 if(Title != ""){
352 histo1->SetTitle(Title);
353 }
354 if(XTitle ! =""){
355 histo1->SetXTitle(XTitle);
356 }
357 if(YTitle ! =""){
358 histo1->SetYTitle(YTitle);
359 }
360 histo1->GetYaxis()->SetLabelSize(0.02);
361 histo1->GetYaxis()->SetTitleSize(0.025);
362 histo1->GetYaxis()->SetDecimals();
363 histo1->GetYaxis()->SetTitleOffset(1.8);
364 histo1->GetXaxis()->SetTitleSize(0.025);
365 histo1->GetXaxis()->SetLabelSize(0.02);
366 histo1->DrawCopy("e,hist");
367}
368
369/*DrawAutoGammaHisto2D is a function for drawing a 2D-histogram of the gamma conversion group
370 * histo - histogramm which need to be drawn
371 * Title - histogram title
372 * XTitle - X- axis-title
373 * YTitle - Y-axis-title
374 * Input - Legend
375 * YRange - if kTRUE will scale by YMin and YMay
376 * YMin - Y minimum
377 * YMax - Y maximum
378 * XRange - if kTRUE will scale by XMin and XMax
379 * XMin - X minimum
380 * XMax - X maximum
381*/
382void DrawAutoGammaHisto2D( TH2 *histo,
383 const char *Title, const char *XTitle, const char *YTitle, const char *Input,
384 Bool_t YRange, Float_t YMin ,Float_t YMax,
385 Bool_t XRange, Float_t XMin, Float_t XMax) {
386
387
388 if (YRange && XRange){
389 histo->GetYaxis()->SetRangeUser(YMin, YMax);
390 histo->GetXaxis()->SetRangeUser(XMin, XMax);
391 }
392 if ( !YRange && XRange){
393 histo->GetXaxis()->SetRangeUser(XMin, XMax);
394 }
395
396 if (YRange && !XRange){
397 histo->GetYaxis()->SetRangeUser(YMin, YMax);
398 }
399
400 if(Title != ""){
401 histo->SetTitle(Title);
402 }
403 if(XTitle ! =""){
404 histo->SetXTitle(XTitle);
405 }
406 if(YTitle ! =""){
407 histo->SetYTitle(YTitle);
408 }
409 histo->GetYaxis()->SetTitleSize(0.025);
410 histo->GetYaxis()->SetLabelSize(0.02);
411 histo->GetXaxis()->SetLabelSize(0.02);
412 histo->GetYaxis()->SetDecimals();
413 histo->GetYaxis()->SetTitleOffset(1.8);
414 histo->GetXaxis()->SetTitleSize(0.025);
415 histo->DrawCopy("colz");
416 if(Input!=""){
417 leg2 = new TLegend(0.6,0.82,0.83,0.9);
418 leg2->SetTextSize(0.04);
419 leg2->SetFillColor(0);
420 leg2->AddEntry(histo,(Input));
421 leg2->Draw("same");
422 }
423}
424
425
426/* DrawRatioGammaHisto is function used for styling the ratio-histograms of the gamma conversion group
427 * histo1 - histogram
428 * Title - histogram title
429 * XTitle - X-axis title
430 * YTitle - Y-axis title
431 * YRangeMax = kTRUE will scale by Maximum and Minimum Range in Y
432 *YMaxFactor - will MaximumY by this factor if YRangeMay = kTRUE
433 *YMinimum - this will be used if YRangeMax is set
434 *YRange = kTRUE will Cut y-axis by YMin and YMax
435 - will be set to kFAlSE if YRangeMax is set
436 *YMin - minimum Y
437 *YMax - maximum Y
438 *XRange = kTRUE will Cut x-axis by XMin and XMax
439 *XMin - minimum Y
440 *XMax - maximum Y
441*/
442void DrawRatioGammaHisto( TH1* histo1,
443 const char *Title, const char *XTitle, const char *YTitle,
444 Bool_t YRangeMax, Float_t YMaxFactor, Float_t YMinimum,
445 Bool_t YRange, Float_t YMin ,Float_t YMax,
446 Bool_t XRange, Float_t XMin, Float_t XMax) {
447 if (YRangeMax && !XRange){
448 YRange = kFALSE;
77ac6f3e 449 Double_t maxRangeR = histo1->GetMaximum();
450 Double_t minRangeR = histo1->GetMinimum();
451 if(YMinimum > minRangeR){minRangeR = YMinimum;}
452 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 453 }
454 if (YRangeMax && XRange){
455 YRange = kFALSE;
77ac6f3e 456 Double_t maxRangeR = histo1->GetMaximum();
457 Double_t minRangeR = histo1->GetMinimum();
458 if(YMinimum > minRangeR){minRangeR = YMinimum;}
459 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 460 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
461 }
462 if (YRange && XRange){
463 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
464 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
465 }
466 if (!YRangeMax && !YRange && XRange){
467 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
468 }
469
470 if (YRange && !XRange){
471 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
472 }
473
474 if(Title != ""){ histo1->SetTitle(Title);
475 }else{ histo1->SetTitle();}
476
477 if(XTitle ! =""){
478 histo1->SetXTitle(XTitle);
479 }
480 if(YTitle ! =""){
481 histo1->SetYTitle(YTitle);
482 }
483 histo1->GetYaxis()->SetTitleSize(0.04);
484 histo1->GetYaxis()->SetLabelSize(0.03);
485 histo1->GetYaxis()->SetDecimals();
486 histo1->GetYaxis()->SetTitleOffset(1.3);
487 histo1->GetXaxis()->SetTitleOffset(1.1);
488 histo1->GetXaxis()->SetTitleSize(0.04);
489 histo1->GetXaxis()->SetLabelSize(0.03);
490 histo1->DrawCopy("e");
491}
492
493/* DrawCutGammaHistos is function used for styling the Cut-histograms of the gamma conversion group for 4 histos combined
494 * histo1 - histogram Data
495 * histo2 - histogram Data Comparision
496 * histo3 - histogram MC
497 * histo4 - histogram MC Comparision
498 * Title - histogram title
499 * XTitle - X-axis title
500 * YTitle - Y-axis title
501 * Legend1 - additional Legend for histo2
502 * Legend2 - additional Legend for histo4
503 * YRangeMax = kTRUE will scale by Maximum and Minimum Range in Y
504 *YMaxFactor - will MaximumY by this factor if YRangeMay = kTRUE
505 *YMinimum - this will be used if YRangeMax is set
506 *YRange = kTRUE will Cut y-axis by YMin and YMax
507 - will be set to kFAlSE if YRangeMax is set
508 *YMin - minimum Y
509 *YMax - maximum Y
510 *XRange = kTRUE will Cut x-axis by XMin and XMax
511 *XMin - minimum Y
512 *XMax - maximum Y
513*/
514void DrawCutGammaHistos( TH1* histo1, TH1* histo2,
515 TH1* histo3, TH1*histo4,
516 const char *Title, const char *XTitle, const char *YTitle, const char *Legend1, const char *Legend2,
517 Bool_t YRangeMax, Float_t YMaxFactor, Float_t YMinimum,
518 Bool_t YRange, Float_t YMin ,Float_t YMax,
519 Bool_t XRange, Float_t XMin, Float_t XMax) {
520 if (YRangeMax && !XRange){
521 YRange = kFALSE;
77ac6f3e 522 Double_t maxRangeR = histo2->GetMaximum();
523 if(maxRangeR < histo4->GetMaximum()){
524 maxRangeR = histo4->GetMaximum();
dab7b5d6 525 }
77ac6f3e 526 Double_t minRangeR = histo2->GetMinimum();
527 if(minRangeR > histo4->GetMinimum()){
528 minRangeR = histo4->GetMinimum();
dab7b5d6 529 }
77ac6f3e 530 if(YMinimum > minRangeR){minRangeR = YMinimum;}
531 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 532 }
533 if (YRangeMax && XRange){
534 YRange = kFALSE;
77ac6f3e 535 Double_t maxRangeR = histo2->GetMaximum();
536 if(maxRangeR < histo4->GetMaximum()){
537 maxRangeR = histo4->GetMaximum();
dab7b5d6 538 }
77ac6f3e 539 Double_t minRangeR = histo2->GetMinimum();
540 if(minRangeR > histo4->GetMinimum()){
541 minRangeR = histo4->GetMinimum();
dab7b5d6 542 }
77ac6f3e 543 if(YMinimum > minRangeR){minRangeR = YMinimum;}
544 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 545 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
546 }
547 if (YRange && XRange){
548 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
549 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
550 }
551 if (!YRangeMax && !YRange && XRange){
552 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
553 }
554 if (YRange && !XRange){
555 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
556 }
557
558 if(Title != ""){
559 histo1->SetTitle(Title);
560 }
561 if(XTitle ! =""){
562 histo1->SetXTitle(XTitle);
563 }
564 if(YTitle ! =""){
565 histo1->SetYTitle(YTitle);
566 }
567 histo1->GetYaxis()->SetTitleSize(0.025);
568 histo1->GetYaxis()->SetLabelSize(0.02);
569 histo1->GetYaxis()->SetDecimals();
570 histo1->GetYaxis()->SetTitleOffset(1.8);
571 histo1->GetXaxis()->SetLabelSize(0.02);
572 histo1->GetXaxis()->SetTitleSize(0.025);
573 histo1->Draw("e,hist");
574
575 histo2->SetLineColor(15);
576 histo2->Draw("e,hist,same");
577
578 histo3->SetLineColor(2);
579 histo3->Draw("e,hist,same");
580
581 histo4->SetLineColor(46);
582 histo4->Draw("e,hist,same");
583
584 leg1 = new TLegend( 0.6,0.82,0.92,0.9);
585 leg1->SetTextSize(0.02);
586 leg1->SetFillColor(0);
587 leg1->AddEntry(histo1,("Data"));
588 leg1->AddEntry(histo2,(Legend1));
589 leg1->AddEntry(histo3,("MC"));
590 leg1->AddEntry(histo4,(Legend2));
591
592 leg1->Draw();
593
594
595}
596
597/* DrawCutGammaHisto is function used for styling the Cut-histograms of the gamma conversion group for 2 histos combined
598 * histo1 - histogram Data
599 * histo2 - histogram Data Comparision
600 * Title - histogram title
601 * XTitle - X-axis title
602 * YTitle - Y-axis title
603 * Legend - additional Legend for histo2
604 * YRangeMax = kTRUE will scale by Maximum and Minimum Range in Y
605 *YMaxFactor - will MaximumY by this factor if YRangeMay = kTRUE
606 *YMinimum - this will be used if YRangeMax is set
607 *YRange = kTRUE will Cut y-axis by YMin and YMax
608 - will be set to kFAlSE if YRangeMax is set
609 *YMin - minimum Y
610 *YMax - maximum Y
611 *XRange = kTRUE will Cut x-axis by XMin and XMax
612 *XMin - minimum Y
613 *XMax - maximum Y
614*/
615void DrawCutGammaHisto( TH1* histo1, TH1* histo2,
616 const char *Title, const char *XTitle, const char *YTitle, const char *Legend,
617 Bool_t YRangeMax, Float_t YMaxFactor, Float_t YMinimum,
618 Bool_t YRange, Float_t YMin ,Float_t YMax,
619 Bool_t XRange, Float_t XMin, Float_t XMax) {
620 if (YRangeMax && !XRange){
621 YRange = kFALSE;
77ac6f3e 622 Double_t maxRangeR = histo2->GetMaximum();
623 Double_t minRangeR = histo2->GetMinimum();
624 if(YMinimum > minRangeR){minRangeR = YMinimum;}
625 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 626 }
627 if (YRangeMax && XRange){
628 YRange = kFALSE;
77ac6f3e 629 Double_t maxRangeR = histo2->GetMaximum();
630 Double_t minRangeR = histo2->GetMinimum();
631 if(YMinimum > minRangeR){minRangeR = YMinimum;}
632 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 633 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
634 }
635 if (YRange && XRange){
636 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
637 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
638 }
639 if (!YRangeMax && !YRange && XRange){
640 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
641 }
642 if (YRange && !XRange){
643 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
644 }
645
646 if(Title != ""){
647 histo1->SetTitle(Title);
648 }
649 if(XTitle ! =""){
650 histo1->SetXTitle(XTitle);
651 }
652 if(YTitle ! =""){
653 histo1->SetYTitle(YTitle);
654 }
655 histo1->GetYaxis()->SetTitleSize(0.025);
656 histo1->GetYaxis()->SetLabelSize(0.02);
657 histo1->GetYaxis()->SetDecimals();
658 histo1->GetYaxis()->SetTitleOffset(1.8);
659 histo1->GetXaxis()->SetLabelSize(0.02);
660 histo1->GetXaxis()->SetTitleSize(0.025);
661 histo1->Draw("e,hist");
662
663 histo2->SetLineColor(15);
664 histo2->Draw("e,hist,same");
665
666 leg1 = new TLegend( 0.6,0.82,0.92,0.9);
667 leg1->SetTextSize(0.04);
668 leg1->SetFillColor(0);
669 leg1->AddEntry(histo1,("Data"));
670 leg1->AddEntry(histo2,(Legend));
671 leg1->Draw();
672
673}
674
675/* DrawRatioGammaHisto is function used for styling the ratio-histograms of the gamma conversion group
676 * histo1 - histogram
677 * Title - histogram title
678 * XTitle - X-axis title
679 * YTitle - Y-axis title
680 * YRangeMax = kTRUE will scale by Maximum and Minimum Range in Y
681 *YMaxFactor - will MaximumY by this factor if YRangeMay = kTRUE
682 *YMinimum - this will be used if YRangeMax is set
683 *YRange = kTRUE will Cut y-axis by YMin and YMax
684 - will be set to kFAlSE if YRangeMax is set
685 *YMin - minimum Y
686 *YMax - maximum Y
687 *XRange = kTRUE will Cut x-axis by XMin and XMax
688 *XMin - minimum Y
689 *XMax - maximum Y
690*/
691void DrawResolutionGammaHisto( TH1* histo1,
692 const char *Title, const char *XTitle, const char *YTitle,
693 Bool_t YRangeMax, Float_t YMaxFactor, Float_t YMinimum,
694 Bool_t YRange, Float_t YMin ,Float_t YMax,
695 Bool_t XRange, Float_t XMin, Float_t XMax) {
696 if (YRangeMax && !XRange){
697 YRange = kFALSE;
77ac6f3e 698 Double_t maxRangeR = histo1->GetMaximum();
699 Double_t minRangeR = histo1->GetMinimum();
700 if(YMinimum > minRangeR){minRangeR = YMinimum;}
701 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 702 }
703 if (YRangeMax && XRange){
704 YRange = kFALSE;
77ac6f3e 705 Double_t maxRangeR = histo1->GetMaximum();
706 Double_t minRangeR = histo1->GetMinimum();
707 if(YMinimum > minRangeR){minRangeR = YMinimum;}
708 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
dab7b5d6 709 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
710 }
711 if (YRange && XRange){
712 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
713 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
714 }
715 if (!YRangeMax && !YRange && XRange){
716 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
717 }
718
719 if (YRange && !XRange){
720 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
721 }
722
723 if(Title != ""){
724 histo1->SetTitle(Title);
725 }else { histo1->SetTitle();}
726
727 if(XTitle ! =""){
728 histo1->SetXTitle(XTitle);
729 }
730 if(YTitle ! =""){
731 histo1->SetYTitle(YTitle);
732 }
733 histo1->GetYaxis()->SetTitleSize(0.04);
734 histo1->GetYaxis()->SetLabelSize(0.03);
735 histo1->GetYaxis()->SetDecimals();
736 histo1->GetYaxis()->SetTitleOffset(1.3);
737 histo1->GetXaxis()->SetTitleOffset(1.1);
738 histo1->GetXaxis()->SetTitleSize(0.04);
739 histo1->GetXaxis()->SetLabelSize(0.03);
740 histo1->DrawCopy("e");
741}
742
743/*DrawAutoGammaHisto2Dres is a function for drawing a resolution 2D-histogram of the gamma conversion group
744 * histo - histogramm which need to be drawn
745 * Title - histogram title
746 * XTitle - X- axis-title
747 * YTitle - Y-axis-title
748 * Input - Legend
749 * YRange - if kTRUE will scale by YMin and YMay
750 * YMin - Y minimum
751 * YMax - Y maximum
752 * XRange - if kTRUE will scale by XMin and XMax
753 * XMin - X minimum
754 * XMax - X maximum
755*/
756void DrawAutoGammaHisto2DRes( TH2 *histo,
757 const char *Title, const char *XTitle, const char *YTitle, const char *Input,
758 Bool_t YRange, Float_t YMin ,Float_t YMax,
759 Bool_t XRange, Float_t XMin, Float_t XMax) {
760
761
762 if (YRange && XRange){
763 histo->GetYaxis()->SetRangeUser(YMin, YMax);
764 histo->GetXaxis()->SetRangeUser(XMin, XMax);
765 }
766 if ( !YRange && XRange){
767 histo->GetXaxis()->SetRangeUser(XMin, XMax);
768 }
769
770 if (YRange && !XRange){
771 histo->GetYaxis()->SetRangeUser(YMin, YMax);
772 }
773
774 if(Title != ""){
775 histo->SetTitle(Title);
776 }
777 if(XTitle ! =""){
778 histo->SetXTitle(XTitle);
779 }
780 if(YTitle ! =""){
781 histo->SetYTitle(YTitle);
782 }
783 histo->GetYaxis()->SetTitleSize(0.045);
784 histo->GetYaxis()->SetLabelSize(0.03);
785 histo->GetXaxis()->SetLabelSize(0.03);
786 histo->GetYaxis()->SetDecimals();
787 histo->GetYaxis()->SetTitleOffset(1.5);
788 histo->GetXaxis()->SetTitleSize(0.045);
789 histo->GetYaxis()->SetTitleOffset(1.5);
790 histo->DrawCopy("colz");
791 if(Input!=""){
792 leg2 = new TLegend(0.6,0.82,0.83,0.9);
793 leg2->SetTextSize(0.04);
794 leg2->SetFillColor(0);
795 leg2->AddEntry(histo,(Input));
796 leg2->Draw("same");
797 }
798}
799
77ac6f3e 800
801/* DrawAutoGammaMesonHistos is function used for styling the histograms of the gamma conversion group for two histos and standart settings
802* histo1 - first histogram
803* Title - histogram title
804* XTitle - X-axis title
805* YTitle - Y-axis title
806* YRangeMax = kTRUE will scale by Maximum and Minimum Range in Y
807*YMaxFactor - will MaximumY by this factor if YRangeMay = kTRUE
808*YMinimum - this will be used if YRangeMax is set
809*YRange = kTRUE will Cut y-axis by YMin and YMax
810- will be set to kFAlSE if YRangeMax is set
811*YMin - minimum Y
812*YMax - maximum Y
813*XRange = kTRUE will Cut x-axis by XMin and XMax
814*XMin - minimum Y
815*XMax - maximum Y
816*/
817
818void DrawAutoGammaMesonHistos( TH1* histo1,
819 const char *Title, const char *XTitle, const char *YTitle,
820 Bool_t YRangeMax, Float_t YMaxFactor, Float_t YMinimum,
821 Bool_t YRange, Float_t YMin ,Float_t YMax,
822 Bool_t XRange, Float_t XMin, Float_t XMax) {
823 if (YRangeMax && !XRange){
824 YRange = kFALSE;
825 Double_t maxRangeR = histo1->GetMaximum();
826 Double_t minRangeR = histo1->GetMinimum();
827 if(YMinimum > minRangeR){minRangeR = YMinimum;}
828 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
829 }
830 if (YRangeMax && XRange){
831 YRange = kFALSE;
832 Double_t maxRangeR = histo1->GetMaximum();
833 Double_t minRangeR = histo1->GetMinimum();
834 if(YMinimum > minRangeR){minRangeR = YMinimum;}
835 histo1->GetYaxis()->SetRangeUser(minRangeR, maxRangeR*YMaxFactor);
836 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
837 }
838 if (YRange && XRange){
839 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
840 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
841 }
842 if (!YRangeMax && !YRange && XRange){
843 histo1->GetXaxis()->SetRangeUser(XMin, XMax);
844 }
845 if (YRange && !XRange){
846 histo1->GetYaxis()->SetRangeUser(YMin, YMax);
847 }
848
849 if(Title != ""){
850 histo1->SetTitle(Title);
851 }else{
852 histo1->SetTitle();
853 }
854 if(XTitle ! =""){
855 histo1->SetXTitle(XTitle);
856 }
857 if(YTitle ! =""){
858 histo1->SetYTitle(YTitle);
859 }
860 histo1->GetYaxis()->SetLabelSize(0.03);
861 histo1->GetYaxis()->SetTitleSize(0.04);
862 histo1->GetYaxis()->SetDecimals();
863 histo1->GetYaxis()->SetTitleOffset(1.2);
864 histo1->GetXaxis()->SetTitleSize(0.04);
865 histo1->GetXaxis()->SetLabelSize(0.03);
866
867 histo1->DrawCopy("e1,p");
868
869}
870
871void DrawGammaSetMarker( TH1* histo1,
872 Style_t MarkerStyle, Size_t MarkerSize, Color_t MarkerColor, Color_t LineColor ) {
873 histo1->SetMarkerStyle(MarkerStyle);
874 histo1->SetMarkerSize(MarkerSize);
875 histo1->SetMarkerColor(MarkerColor);
876 histo1->SetLineColor(LineColor);
877}
878
879void DrawGammaCanvasSettings( TCanvas* c1, Double_t LeftMargin, Double_t RightMargin, Double_t TopMargin, Double_t BottomMargin){
880 c1->SetTickx();
881 c1->SetTicky();
882 c1->SetGridx(0);
883 c1->SetGridy(0);
884 c1->SetLogy(0);
885 c1->SetLeftMargin(LeftMargin);
886 c1->SetRightMargin(RightMargin);
887 c1->SetTopMargin(TopMargin);
888 c1->SetBottomMargin(BottomMargin);
889 c1->SetFillColor(0);
890}
891
892void DrawGammaPadSettings( TPad* pad1, Double_t LeftMargin, Double_t RightMargin, Double_t TopMargin, Double_t BottomMargin){
893 pad1->SetFillColor(0);
894 pad1->GetFrame()->SetFillColor(0);
895 pad1->SetBorderMode(0);
896 pad1->SetLeftMargin(LeftMargin);
897 pad1->SetBottomMargin(BottomMargin);
898 pad1->SetRightMargin(RightMargin);
899 pad1->SetTopMargin(TopMargin);
900 pad1->SetTickx();
901 pad1->SetTicky();
902
903}
904
905void DrawGammaSetMarkerTGraph( TGraph* graph,
906 Style_t MarkerStyle, Size_t MarkerSize, Color_t MarkerColor, Color_t LineColor ) {
907 graph->SetMarkerStyle(MarkerStyle);
908 graph->SetMarkerSize(MarkerSize);
909 graph->SetMarkerColor(MarkerColor);
910 graph->SetLineColor(LineColor);
911}
912
913void DrawGammaSetMarkerTGraphErr( TGraphErrors* graph,
914 Style_t MarkerStyle, Size_t MarkerSize, Color_t MarkerColor, Color_t LineColor ) {
915 graph->SetMarkerStyle(MarkerStyle);
916 graph->SetMarkerSize(MarkerSize);
917 graph->SetMarkerColor(MarkerColor);
918 graph->SetLineColor(LineColor);
919}
920
921
922void DrawGammaSetMarkerTGraphAsym( TGraphAsymmErrors* graph,
923 Style_t MarkerStyle, Size_t MarkerSize, Color_t MarkerColor, Color_t LineColor ) {
924 graph->SetMarkerStyle(MarkerStyle);
925 graph->SetMarkerSize(MarkerSize);
926 graph->SetMarkerColor(MarkerColor);
927 graph->SetLineColor(LineColor);
928}
929
930
931void DrawGammaSetMarkerTF1( TF1* fit1,
932 Style_t LineStyle, Size_t LineWidth, Color_t LineColor ) {
933 fit1->SetLineColor(LineColor);
934 fit1->SetLineStyle(LineStyle);
935 fit1->SetLineWidth(LineWidth);
936}