File indexing completed on 2024-04-06 11:56:54
0001 #ifndef ALIGNMENT_OFFLINEVALIDATION_JDRAWER_H
0002 #define ALIGNMENT_OFFLINEVALIDATION_JDRAWER_H
0003
0004
0005 #include <iostream>
0006
0007
0008 #include "TROOT.h"
0009 #include "TStyle.h"
0010 #include "TCanvas.h"
0011 #include "TPad.h"
0012 #include "TString.h"
0013 #include "TH1.h"
0014 #include "TF1.h"
0015 #include "TH2.h"
0016 #include "TAxis.h"
0017 #include "TGraph.h"
0018 #include "TLegend.h"
0019
0020
0021
0022
0023 class JDrawer {
0024 private:
0025
0026 double fMarginLeft;
0027 double fMarginRight;
0028 double fMarginBottom;
0029 double fMarginTop;
0030
0031
0032 int fTopLeftX;
0033 int fTopLeftY;
0034 int fCanvasWidth;
0035 int fCanvasHeight;
0036
0037
0038 double fTitleOffsetX;
0039 double fTitleOffsetY;
0040 double fTitleOffsetZ;
0041 double fTitleSizeX;
0042 double fTitleSizeY;
0043 double fTitleSizeZ;
0044 double fLabelOffsetX;
0045 double fLabelOffsetY;
0046 double fLabelOffsetZ;
0047 double fLabelSizeX;
0048 double fLabelSizeY;
0049 double fLabelSizeZ;
0050 double fDivisionsX;
0051 double fDivisionsY;
0052 int fFont;
0053
0054
0055 int fLogX;
0056 int fLogY;
0057 int fLogZ;
0058 int fGridX;
0059 int fGridY;
0060 int fTickX;
0061 int fTickY;
0062
0063
0064 int fCanvasDisplacementX;
0065 int fCanvasDisplacementY;
0066 int fCanvasesInOneRow;
0067
0068
0069 TCanvas *fCanvas;
0070 TPad *fSinglePad;
0071 TPad *fUpperSplitPad;
0072 TPad *fLowerSplitPad;
0073 TPad *fLeftRowPad;
0074 TPad *fMiddleRowPad;
0075 TPad *fRightRowPad;
0076
0077
0078 double fSplitRatio;
0079
0080
0081 int fNameIndex;
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 void SetAxisStyles(TAxis *xAxis, TAxis *yAxis, TAxis *zAxis, TString xtit, TString ytit) {
0095 xAxis->CenterTitle(true);
0096 yAxis->CenterTitle(true);
0097 if (zAxis)
0098 zAxis->CenterTitle(true);
0099
0100 xAxis->SetTitleOffset(fTitleOffsetX);
0101 yAxis->SetTitleOffset(fTitleOffsetY);
0102 if (zAxis)
0103 zAxis->SetTitleOffset(fTitleOffsetZ);
0104
0105 xAxis->SetTitleSize(fTitleSizeX);
0106 yAxis->SetTitleSize(fTitleSizeY);
0107 if (zAxis)
0108 zAxis->SetTitleSize(fTitleSizeZ);
0109
0110 xAxis->SetLabelOffset(fLabelOffsetX);
0111 yAxis->SetLabelOffset(fLabelOffsetY);
0112 if (zAxis)
0113 zAxis->SetLabelOffset(fLabelOffsetZ);
0114
0115 xAxis->SetLabelSize(fLabelSizeX);
0116 yAxis->SetLabelSize(fLabelSizeY);
0117 if (zAxis)
0118 zAxis->SetLabelSize(fLabelSizeZ);
0119
0120 xAxis->SetNdivisions(fDivisionsX);
0121 yAxis->SetNdivisions(fDivisionsY);
0122
0123 xAxis->SetTitle(xtit);
0124 yAxis->SetTitle(ytit);
0125
0126 xAxis->SetLabelFont(fFont);
0127 yAxis->SetLabelFont(fFont);
0128 if (zAxis)
0129 zAxis->SetLabelFont(fFont);
0130 xAxis->SetTitleFont(fFont);
0131 yAxis->SetTitleFont(fFont);
0132 if (zAxis)
0133 zAxis->SetTitleFont(fFont);
0134 }
0135
0136
0137
0138
0139
0140
0141
0142
0143 void SetHistogramStyle(TH1 *hid, TString xtit, TString ytit) {
0144 SetAxisStyles(hid->GetXaxis(), hid->GetYaxis(), hid->GetZaxis(), xtit, ytit);
0145 }
0146
0147
0148
0149
0150
0151
0152
0153
0154 void SetFunctionStyle(TF1 *hid, TString xtit, TString ytit) {
0155 SetAxisStyles(hid->GetXaxis(), hid->GetYaxis(), hid->GetZaxis(), xtit, ytit);
0156 }
0157
0158
0159
0160
0161
0162
0163
0164
0165 void SetGraphStyle(TGraph *hid, TString xtit, TString ytit) {
0166 SetAxisStyles(hid->GetXaxis(), hid->GetYaxis(), nullptr, xtit, ytit);
0167 }
0168
0169
0170
0171
0172 void SetPadValues(TPad *pad) {
0173 pad->SetLogy(fLogY);
0174 pad->SetLogx(fLogX);
0175 pad->SetLogz(fLogZ);
0176 pad->SetGridx(fGridX);
0177 pad->SetGridy(fGridY);
0178 pad->SetTickx(fTickX);
0179 pad->SetTicky(fTickY);
0180 }
0181
0182
0183
0184
0185 TString GenerateName(const char *objectName) {
0186 TString name = Form("%s%d%d%d", objectName, fNameIndex++, fTopLeftX, fTopLeftY);
0187 return name.Data();
0188 }
0189
0190
0191
0192
0193 TString GenerateNameForCanvas() {
0194 TString name;
0195 name = Form("canvas%d%d", fTopLeftX, fTopLeftY);
0196 while (true) {
0197
0198 if (gROOT->GetListOfCanvases()->FindObject(name) == nullptr) {
0199 return name.Data();
0200 }
0201
0202
0203 name = Form("canvas%d%d%d", fTopLeftX, fTopLeftY, fNameIndex++);
0204 }
0205 }
0206
0207 public:
0208
0209
0210
0211 JDrawer() {
0212 Reset();
0213 fNameIndex = 0;
0214 }
0215
0216
0217
0218
0219 ~JDrawer() = default;
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230 void DrawHistogramToCurrentCanvas(
0231 TH1 *histo, const char *xTitle, const char *yTitle, const char *title = "", const char *drawOption = "") {
0232
0233 if (strcmp(xTitle, "") == 0)
0234 xTitle = histo->GetXaxis()
0235 ->GetTitle();
0236 if (strcmp(yTitle, "") == 0)
0237 yTitle = histo->GetYaxis()->GetTitle();
0238 if (strcmp(title, "") == 0)
0239 title = histo->GetTitle();
0240
0241
0242 histo->SetTitle(title);
0243 SetHistogramStyle(histo, xTitle, yTitle);
0244 histo->Draw(drawOption);
0245 }
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256 void DrawHistogram(
0257 TH1 *histo, const char *xTitle, const char *yTitle, const char *title = "", const char *drawOption = "") {
0258
0259 if (strcmp(xTitle, "") == 0)
0260 xTitle = histo->GetXaxis()
0261 ->GetTitle();
0262 if (strcmp(yTitle, "") == 0)
0263 yTitle = histo->GetYaxis()->GetTitle();
0264 if (strcmp(title, "") == 0)
0265 title = histo->GetTitle();
0266
0267
0268 CreateCanvas();
0269 histo->SetTitle(title);
0270 SetHistogramStyle(histo, xTitle, yTitle);
0271 histo->Draw(drawOption);
0272 }
0273
0274
0275
0276
0277
0278
0279
0280 void DrawHistogram(TH1 *histo, const char *drawOption = "") { DrawHistogram(histo, "", "", "", drawOption); }
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291 void DrawHistogramToPad(TH1 *histo,
0292 TPad *drawPad,
0293 const char *xTitle = "",
0294 const char *yTitle = "",
0295 const char *title = "",
0296 const char *drawOption = "") {
0297
0298 if (strcmp(xTitle, "") == 0)
0299 xTitle = histo->GetXaxis()
0300 ->GetTitle();
0301 if (strcmp(yTitle, "") == 0)
0302 yTitle = histo->GetYaxis()->GetTitle();
0303 if (strcmp(title, "") == 0)
0304 title = histo->GetTitle();
0305
0306
0307 SetPadValues(drawPad);
0308 drawPad->cd();
0309
0310
0311 gStyle->SetOptStat(0);
0312 gStyle->SetOptTitle(0);
0313
0314
0315 histo->SetTitle(title);
0316 SetHistogramStyle(histo, xTitle, yTitle);
0317 histo->Draw(drawOption);
0318 }
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329 void DrawHistogramToUpperPad(TH1 *histo,
0330 const char *xTitle = "",
0331 const char *yTitle = "",
0332 const char *title = "",
0333 const char *drawOption = "") {
0334
0335 if (fUpperSplitPad == nullptr) {
0336
0337 CreateSplitCanvas();
0338 }
0339
0340 DrawHistogramToPad(histo, fUpperSplitPad, xTitle, yTitle, title, drawOption);
0341 }
0342
0343
0344
0345
0346
0347
0348
0349
0350
0351
0352 void DrawHistogramToLowerPad(TH1 *histo,
0353 const char *xTitle = "",
0354 const char *yTitle = "",
0355 const char *title = "",
0356 const char *drawOption = "") {
0357
0358 if (fLowerSplitPad == nullptr) {
0359
0360 CreateSplitCanvas();
0361 }
0362
0363 DrawHistogramToPad(histo, fLowerSplitPad, xTitle, yTitle, title, drawOption);
0364 }
0365
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378
0379 void DrawGraph(TGraph *graph,
0380 double xlow,
0381 double xhigh,
0382 double ylow,
0383 double yhigh,
0384 const char *xTitle = "",
0385 const char *yTitle = "",
0386 const char *title = "",
0387 const char *drawOption = "") {
0388
0389 CreateCanvas(xlow, xhigh, ylow, yhigh, xTitle, yTitle, title);
0390 graph->Draw(drawOption);
0391 }
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406 void DrawGraphCustomAxes(TGraph *graph,
0407 double xlow,
0408 double xhigh,
0409 double ylow,
0410 double yhigh,
0411 const char *xTitle = "",
0412 const char *yTitle = "",
0413 const char *title = "",
0414 const char *drawOption = "") {
0415
0416 if (strcmp(xTitle, "") == 0)
0417 xTitle = graph->GetXaxis()
0418 ->GetTitle();
0419 if (strcmp(yTitle, "") == 0)
0420 yTitle = graph->GetYaxis()->GetTitle();
0421 if (strcmp(title, "") == 0)
0422 title = graph->GetTitle();
0423
0424
0425 CreateCanvas();
0426 graph->SetTitle(title);
0427 graph->GetXaxis()->SetRangeUser(xlow, xhigh);
0428 graph->GetYaxis()->SetRangeUser(ylow, yhigh);
0429 SetGraphStyle(graph, xTitle, yTitle);
0430 graph->Draw(drawOption);
0431 }
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442 void DrawFunction(
0443 TF1 *myFun, const char *xTitle, const char *yTitle, const char *title = "", const char *drawOption = "") {
0444
0445 if (strcmp(xTitle, "") == 0)
0446 xTitle = myFun->GetXaxis()
0447 ->GetTitle();
0448 if (strcmp(yTitle, "") == 0)
0449 yTitle = myFun->GetYaxis()->GetTitle();
0450 if (strcmp(title, "") == 0)
0451 title = myFun->GetTitle();
0452
0453
0454 CreateCanvas();
0455 myFun->SetTitle(title);
0456 SetFunctionStyle(myFun, xTitle, yTitle);
0457 myFun->Draw(drawOption);
0458 }
0459
0460
0461
0462
0463
0464
0465
0466 void DrawFunction(TF1 *myFun, const char *drawOption = "") { DrawFunction(myFun, "", "", "", drawOption); }
0467
0468
0469
0470
0471 void Reset() {
0472
0473 fMarginLeft = 0.15;
0474 fMarginRight = 0.06;
0475 fMarginBottom = 0.15;
0476 fMarginTop = 0.06;
0477
0478
0479 fTopLeftX = 10;
0480 fTopLeftY = 10;
0481 fCanvasWidth = 700;
0482 fCanvasHeight = 500;
0483
0484
0485 fTitleOffsetX = 1.1;
0486 fTitleOffsetY = 1.1;
0487 fTitleOffsetZ = 1.3;
0488 fTitleSizeX = 0.06;
0489 fTitleSizeY = 0.06;
0490 fTitleSizeZ = 0.06;
0491 fLabelOffsetX = 0.01;
0492 fLabelOffsetY = 0.001;
0493 fLabelOffsetZ = 0.001;
0494 fLabelSizeX = 0.05;
0495 fLabelSizeY = 0.05;
0496 fLabelSizeZ = 0.05;
0497 fDivisionsX = 505;
0498 fDivisionsY = 505;
0499 fFont = 42;
0500
0501
0502 fLogX = 0;
0503 fLogY = 0;
0504 fLogZ = 0;
0505
0506
0507 fCanvasDisplacementX = 100;
0508 fCanvasDisplacementY = 100;
0509 fCanvasesInOneRow = 10;
0510
0511
0512 fGridX = 0;
0513 fGridY = 0;
0514 fTickX = 1;
0515 fTickY = 1;
0516
0517
0518 fSplitRatio = 0.4;
0519
0520
0521 fCanvas = nullptr;
0522 fSinglePad = nullptr;
0523 fUpperSplitPad = nullptr;
0524 fLowerSplitPad = nullptr;
0525 fLeftRowPad = nullptr;
0526 fMiddleRowPad = nullptr;
0527 fRightRowPad = nullptr;
0528 }
0529
0530
0531
0532
0533 void CreateCanvas() {
0534
0535 gStyle->SetOptStat(0);
0536 TString cname = GenerateNameForCanvas();
0537 fCanvas = new TCanvas(cname.Data(), cname.Data(), fTopLeftX, fTopLeftY, fCanvasWidth, fCanvasHeight);
0538 fSinglePad = new TPad("pad", "pad", 0.01, 0.01, 0.99, 0.99, 0, 0, 0);
0539 fSinglePad->SetLeftMargin(fMarginLeft);
0540 fSinglePad->SetBottomMargin(fMarginBottom);
0541 fSinglePad->SetTopMargin(fMarginTop);
0542 fSinglePad->SetRightMargin(fMarginRight);
0543 SetPadValues(fSinglePad);
0544 fSinglePad->Draw();
0545 fSinglePad->cd();
0546 }
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559 void CreateCanvas(double xlow,
0560 double xhigh,
0561 double ylow,
0562 double yhigh,
0563 const char *xTitle = "",
0564 const char *yTitle = "",
0565 const char *title = "") {
0566
0567 CreateCanvas();
0568
0569
0570 TString dummyName = GenerateName("histo");
0571 TH2F *dummyHisto = new TH2F(dummyName.Data(), title, 10, xlow, xhigh, 10, ylow, yhigh);
0572 SetHistogramStyle(dummyHisto, xTitle, yTitle);
0573 dummyHisto->Draw();
0574 }
0575
0576
0577
0578
0579 void CreateSplitCanvas() {
0580 TString dummyName;
0581 dummyName = GenerateNameForCanvas();
0582
0583
0584 fCanvas = new TCanvas(dummyName.Data(), dummyName.Data(), fTopLeftX, fTopLeftY, fCanvasWidth, fCanvasHeight);
0585 fCanvas->SetFillStyle(4000);
0586 fCanvas->SetFillColor(10);
0587 gStyle->SetOptStat(0);
0588 gStyle->SetOptTitle(0);
0589 fCanvas->SetMargin(0, 0, 0, 0);
0590 fCanvas->Draw();
0591
0592
0593
0594
0595 dummyName = GenerateName("UpperPad");
0596 fUpperSplitPad = new TPad(dummyName.Data(), dummyName.Data(), 0, fSplitRatio, 1, 1, 0);
0597 fUpperSplitPad->SetTopMargin(fMarginTop / (1 - fSplitRatio));
0598 fUpperSplitPad->SetBottomMargin(
0599 0.0015);
0600 fUpperSplitPad->SetLeftMargin(fMarginLeft);
0601 fUpperSplitPad->SetRightMargin(fMarginRight);
0602 fUpperSplitPad->Draw();
0603
0604
0605 dummyName = GenerateName("LowerPad");
0606 fLowerSplitPad = new TPad(dummyName.Data(), dummyName.Data(), 0, 0, 1, fSplitRatio, 0);
0607 fLowerSplitPad->SetTopMargin(0.0015);
0608 fLowerSplitPad->SetBottomMargin(fMarginBottom / fSplitRatio);
0609 fLowerSplitPad->SetLeftMargin(fMarginLeft);
0610 fLowerSplitPad->SetRightMargin(fMarginRight);
0611 fLowerSplitPad->Draw();
0612 }
0613
0614
0615
0616
0617 void CreateCanvasGraphRow() {
0618 TString dummyName;
0619 dummyName = GenerateNameForCanvas();
0620
0621
0622 fCanvas = new TCanvas(dummyName.Data(), dummyName.Data(), fTopLeftX, fTopLeftY, fCanvasWidth, fCanvasHeight);
0623 fCanvas->SetFillStyle(4000);
0624 fCanvas->SetFillColor(10);
0625 gStyle->SetOptStat(0);
0626 gStyle->SetOptTitle(0);
0627 fCanvas->SetMargin(0, 0, 0, 0);
0628 fCanvas->Draw();
0629
0630
0631
0632
0633 double smallMargin = 0.0006;
0634 double evenSmallerMargin = 0.0002;
0635 double relativePlotSizeLeftPad = 1 - (fMarginLeft + evenSmallerMargin);
0636 double relativePlotSizeMiddlePad = 1 - (2 * smallMargin);
0637 double relativePlotSizeRightPad = 1 - (fMarginRight + smallMargin);
0638 double firstSeparator = 1 / (1 + relativePlotSizeLeftPad / relativePlotSizeMiddlePad +
0639 relativePlotSizeLeftPad / relativePlotSizeRightPad);
0640 double secondSeparator = firstSeparator + (relativePlotSizeLeftPad / relativePlotSizeMiddlePad) * firstSeparator;
0641
0642
0643 dummyName = GenerateName("LeftPad");
0644 fLeftRowPad = new TPad(dummyName.Data(), dummyName.Data(), 0, 0, firstSeparator, 1, 0);
0645 fLeftRowPad->SetTopMargin(fMarginTop);
0646 fLeftRowPad->SetBottomMargin(fMarginBottom);
0647 fLeftRowPad->SetLeftMargin(fMarginLeft);
0648 fLeftRowPad->SetRightMargin(
0649 evenSmallerMargin);
0650 SetPadValues(fLeftRowPad);
0651 fLeftRowPad->Draw();
0652
0653
0654 dummyName = GenerateName("MiddlePad");
0655 fMiddleRowPad = new TPad(dummyName.Data(), dummyName.Data(), firstSeparator, 0, secondSeparator, 1, 0);
0656 fMiddleRowPad->SetTopMargin(fMarginTop);
0657 fMiddleRowPad->SetBottomMargin(fMarginBottom);
0658 fMiddleRowPad->SetLeftMargin(
0659 smallMargin);
0660 fMiddleRowPad->SetRightMargin(
0661 smallMargin);
0662 SetPadValues(fMiddleRowPad);
0663 fMiddleRowPad->Draw();
0664
0665
0666 dummyName = GenerateName("RightPad");
0667 fRightRowPad = new TPad(dummyName.Data(), dummyName.Data(), secondSeparator, 0, 1, 1, 0);
0668 fRightRowPad->SetTopMargin(fMarginTop);
0669 fRightRowPad->SetBottomMargin(fMarginBottom);
0670 fRightRowPad->SetLeftMargin(
0671 smallMargin);
0672 fRightRowPad->SetRightMargin(fMarginRight);
0673 SetPadValues(fRightRowPad);
0674 fRightRowPad->Draw();
0675 }
0676
0677
0678
0679
0680
0681
0682
0683
0684
0685
0686
0687
0688 void CreateCanvasGraphRow(double xlow,
0689 double xhigh,
0690 double ylow,
0691 double yhigh,
0692 const char *xTitle = "",
0693 const char *yTitle = "",
0694 const char *title = "") {
0695
0696 CreateCanvasGraphRow();
0697
0698
0699 SelectPad(0);
0700 TString dummyName = GenerateName("histo");
0701 TH2F *dummyHisto = new TH2F(dummyName.Data(), "", 10, xlow, xhigh, 10, ylow, yhigh);
0702 SetHistogramStyle(dummyHisto, xTitle, yTitle);
0703 dummyHisto->Draw();
0704
0705
0706 SelectPad(1);
0707 dummyName = GenerateName("histo");
0708 dummyHisto = new TH2F(dummyName.Data(), title, 10, xlow, xhigh, 10, ylow, yhigh);
0709 SetHistogramStyle(dummyHisto, xTitle, "");
0710 dummyHisto->Draw();
0711
0712
0713 SelectPad(2);
0714 dummyName = GenerateName("histo");
0715 dummyHisto = new TH2F(dummyName.Data(), "", 10, xlow, xhigh, 10, ylow, yhigh);
0716 SetHistogramStyle(dummyHisto, xTitle, "");
0717 dummyHisto->Draw();
0718 }
0719
0720
0721
0722
0723
0724
0725
0726 void CreateSplitCanvas(int canvasIndex, int canvasesInRow) {
0727 SetDefaultAppearanceSplitCanvas();
0728 SetNumberOfCanvasesInOneRow(canvasesInRow);
0729 SetCanvasDisplacement(canvasIndex);
0730 CreateSplitCanvas();
0731 }
0732
0733
0734 void SetLeftMargin(double margin) { fMarginLeft = margin; }
0735
0736
0737 void SetRightMargin(double margin) { fMarginRight = margin; }
0738
0739
0740 void SetBottomMargin(double margin) { fMarginBottom = margin; }
0741
0742
0743 void SetTopMargin(double margin) { fMarginTop = margin; }
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753 void SetMargins(double left, double right, double top, double bottom) {
0754 fMarginLeft = left;
0755 fMarginRight = right;
0756 fMarginTop = top;
0757 fMarginBottom = bottom;
0758 }
0759
0760
0761 void SetTitleOffsetX(double offset) { fTitleOffsetX = offset; }
0762
0763
0764 void SetTitleOffsetY(double offset) { fTitleOffsetY = offset; }
0765
0766
0767 void SetTitleSizeX(double size) { fTitleSizeX = size; }
0768
0769
0770 void SetTitleSizeY(double size) { fTitleSizeY = size; }
0771
0772
0773 void SetLabelOffsetX(double offset) { fLabelOffsetX = offset; }
0774
0775
0776 void SetLabelOffsetY(double offset) { fLabelOffsetY = offset; }
0777
0778
0779 void SetLabelSizeX(double size) { fLabelSizeX = size; }
0780
0781
0782 void SetLabelSizeY(double size) { fLabelSizeY = size; }
0783
0784
0785 void SetNDivisionsX(int div) { fDivisionsX = div; }
0786
0787
0788 void SetNDivisionsY(int div) { fDivisionsY = div; }
0789
0790
0791 void SetFont(int fontIndex) { fFont = fontIndex; }
0792
0793
0794
0795
0796
0797
0798
0799
0800 void ApplyStyleSettings(TH1 *histo, TString xTitle = "", TString yTitle = "") {
0801 SetHistogramStyle(histo, xTitle, yTitle);
0802 }
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817
0818
0819 void SetHistogramAppearance(double titoffx,
0820 double titoffy,
0821 double titsizex,
0822 double titsizey,
0823 double labeloffx,
0824 double labeloffy,
0825 double labelsizex,
0826 double labelsizey,
0827 int divx,
0828 int divy,
0829 int fontIndex) {
0830 fTitleOffsetX = titoffx;
0831 fTitleOffsetY = titoffy;
0832 fTitleSizeX = titsizex;
0833 fTitleSizeY = titsizey;
0834 fLabelOffsetX = labeloffx;
0835 fLabelOffsetY = labeloffy;
0836 fLabelSizeX = labelsizex;
0837 fLabelSizeY = labelsizey;
0838 fDivisionsX = divx;
0839 fDivisionsY = divy;
0840 fFont = fontIndex;
0841 }
0842
0843
0844
0845
0846
0847
0848 void SetLogX(bool log = true) {
0849 if (log) {
0850 fLogX = 1;
0851 } else {
0852 fLogX = 0;
0853 }
0854 }
0855
0856
0857
0858
0859
0860
0861 void SetLogY(bool log = true) {
0862 if (log) {
0863 fLogY = 1;
0864 } else {
0865 fLogY = 0;
0866 }
0867 }
0868
0869
0870
0871
0872
0873
0874 void SetLogZ(bool log = true) {
0875 if (log) {
0876 fLogZ = 1;
0877 } else {
0878 fLogZ = 0;
0879 }
0880 }
0881
0882
0883 int GetCanvasDisplacementX() { return fTopLeftX; }
0884
0885
0886 int GetCanvasDisplacementY() { return fTopLeftY; }
0887
0888
0889 void SetCanvasDisplacementX(int displacement) { fTopLeftX = displacement; }
0890
0891
0892 void SetCanvasDisplacementY(int displacement) { fTopLeftY = displacement; }
0893
0894
0895
0896
0897
0898
0899
0900 void SetCanvasDisplacement(int x, int y) {
0901 SetCanvasDisplacementX(x);
0902 SetCanvasDisplacementY(y);
0903 }
0904
0905
0906
0907
0908
0909
0910
0911
0912
0913
0914
0915
0916 void SetCanvasDisplacement(int index) {
0917 SetCanvasDisplacementX(fCanvasDisplacementX * (index % fCanvasesInOneRow) + 10);
0918 SetCanvasDisplacementY(fCanvasDisplacementY * (index - index % fCanvasesInOneRow) / fCanvasesInOneRow + 10);
0919 }
0920
0921
0922
0923
0924
0925
0926
0927
0928 void SetCanvasDisplacementSettings(int displacementX, int displacementY, int canvasesInRow) {
0929 fCanvasDisplacementX = displacementX;
0930 fCanvasDisplacementY = displacementY;
0931 fCanvasesInOneRow = canvasesInRow;
0932 }
0933
0934
0935
0936
0937
0938
0939 void SetNumberOfCanvasesInOneRow(int canvasesInRow) { fCanvasesInOneRow = canvasesInRow; }
0940
0941
0942
0943
0944
0945
0946
0947 void SetCanvasSize(int width, int height) {
0948 fCanvasWidth = width;
0949 fCanvasHeight = height;
0950 }
0951
0952
0953
0954
0955 void SetGridX(bool grid = true) {
0956 if (grid) {
0957 fGridX = 1;
0958 } else {
0959 fGridX = 0;
0960 }
0961 }
0962
0963
0964
0965
0966 void SetGridY(bool grid = true) {
0967 if (grid) {
0968 fGridY = 1;
0969 } else {
0970 fGridY = 0;
0971 }
0972 }
0973
0974
0975
0976
0977 void SetGrid(int gridX, int gridY) {
0978 SetGridX(gridX);
0979 SetGridY(gridY);
0980 }
0981
0982
0983
0984
0985 void SetTickX(bool tick = true) {
0986 if (tick) {
0987 fTickX = 1;
0988 } else {
0989 fTickX = 0;
0990 }
0991 }
0992
0993
0994
0995
0996 void SetTickY(bool tick = true) {
0997 if (tick) {
0998 fTickY = 1;
0999 } else {
1000 fTickY = 0;
1001 }
1002 }
1003
1004
1005
1006
1007 void SetTick(int tickX, int tickY) {
1008 SetTickX(tickX);
1009 SetTickY(tickY);
1010 }
1011
1012
1013
1014
1015 void SetSplitRatio(double split) { fSplitRatio = split; }
1016
1017
1018
1019
1020
1021
1022
1023 void SetDefaultAppearanceSplitCanvas() {
1024 Reset();
1025
1026 SetHistogramAppearance(2.5, 2.3, 25, 25, 0.01, 0.001, 20, 20, 505, 505, 43);
1027 SetSplitRatio(0.4);
1028 SetRelativeCanvasSize(1.1, 0.7);
1029 SetMargins(0.21, 0.05, 0.09, 0.1);
1030 }
1031
1032
1033
1034
1035 void SetDefaultAppearanceGraph() {
1036 Reset();
1037 SetHistogramAppearance(0.9, 1.3, 0.06, 0.05, 0.01, 0.001, 0.05, 0.05, 505, 505, 42);
1038 SetRelativeCanvasSize(0.8, 1);
1039 SetLeftMargin(0.17);
1040 }
1041
1042
1043
1044
1045 void SetDefaultAppearanceGraphRow() {
1046 Reset();
1047 SetHistogramAppearance(0.9, 1.3, 0.06, 0.05, 0.01, 0.001, 0.05, 0.05, 505, 505, 42);
1048 SetRelativeCanvasSize(0.8, 3);
1049 SetLeftMargin(0.17);
1050 }
1051
1052
1053
1054
1055 TPad *GetPad(int padNumber) {
1056 switch (padNumber) {
1057 case 0:
1058 return fLeftRowPad;
1059
1060 case 1:
1061 return fMiddleRowPad;
1062
1063 case 2:
1064 return fRightRowPad;
1065
1066 case 3:
1067 return fUpperSplitPad;
1068
1069 case 4:
1070 return fLowerSplitPad;
1071
1072 default:
1073 return nullptr;
1074 }
1075 }
1076
1077
1078
1079
1080 void SelectPad(int padNumber) {
1081 switch (padNumber) {
1082 case 0:
1083 fLeftRowPad->cd();
1084 break;
1085
1086 case 1:
1087 fMiddleRowPad->cd();
1088 break;
1089
1090 case 2:
1091 fRightRowPad->cd();
1092 break;
1093
1094 case 3:
1095 fUpperSplitPad->cd();
1096 break;
1097
1098 case 4:
1099 fLowerSplitPad->cd();
1100 break;
1101
1102 default:
1103 std::cout << "Pad " << padNumber << " not found" << std::endl;
1104 break;
1105 }
1106 }
1107
1108
1109
1110
1111 TPad *GetUpperPad() { return fUpperSplitPad; }
1112
1113
1114
1115
1116 TPad *GetLowerPad() { return fLowerSplitPad; }
1117
1118
1119
1120
1121 void SelectUpperPad() { fUpperSplitPad->cd(); }
1122
1123
1124
1125
1126 void SelectLowerPad() { fLowerSplitPad->cd(); }
1127
1128
1129
1130
1131
1132
1133
1134 void SetRelativeCanvasSize(double relativeSize, double aspectRatio) {
1135 fCanvasHeight = 600 * relativeSize;
1136 fCanvasWidth = aspectRatio * fCanvasHeight;
1137 }
1138
1139
1140
1141
1142 TString GetCanvasName() {
1143 if (fCanvas == nullptr) {
1144 std::cout << "Error: No canvas defined! Cannot return name." << std::endl;
1145 return "";
1146 }
1147 TString name = Form("%s", fCanvas->GetName());
1148 return name;
1149 }
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159 void SetPadRange(double xLow, double yLow, double xHigh, double yHigh) {
1160
1161 fSinglePad->Range(xLow, yLow, xHigh, yHigh);
1162 fSinglePad->Clear();
1163 }
1164 };
1165
1166 #endif