CMS 3D CMS Logo

JDrawer.h
Go to the documentation of this file.
1 #ifndef ALIGNMENT_OFFLINEVALIDATION_JDRAWER_H
2 #define ALIGNMENT_OFFLINEVALIDATION_JDRAWER_H
3 
4 // C++ includes
5 #include <iostream>
6 
7 // Root includes
8 #include "TROOT.h"
9 #include "TStyle.h"
10 #include "TCanvas.h"
11 #include "TPad.h"
12 #include "TString.h"
13 #include "TH1.h"
14 #include "TF1.h"
15 #include "TH2.h"
16 #include "TAxis.h"
17 #include "TGraph.h"
18 #include "TLegend.h"
19 
20 /*
21  * Class for drawing histograms and graphs in the standard style of the group
22  */
23 class JDrawer {
24 private:
25  // Margins for the drawn canvases
26  double fMarginLeft; // left margin for the canvas
27  double fMarginRight; // right margin for the canvas
28  double fMarginBottom; // bottom margin for the canvas
29  double fMarginTop; // top margin for the canvas
30 
31  // Place and size for the canvas
32  int fTopLeftX; // Number of pixels the the canvas is out of the top left corner of the screen in x-direction
33  int fTopLeftY; // Number of pixels the the canvas is out of the top left corner of the screen in y-direction
34  int fCanvasWidth; // Width of the canvas
35  int fCanvasHeight; // Height of the canvas
36 
37  // Appearance settings for histogram
38  double fTitleOffsetX; // Offset of the x-axis title
39  double fTitleOffsetY; // Offset of the y-axis title
40  double fTitleOffsetZ; // Offset of the z-axis title
41  double fTitleSizeX; // Size of the x-axis title
42  double fTitleSizeY; // Size of the y-axis title
43  double fTitleSizeZ; // Size of the z-axis title
44  double fLabelOffsetX; // Offset of the x-axis label
45  double fLabelOffsetY; // Offset of the y-axis label
46  double fLabelOffsetZ; // Offset of the z-axis label
47  double fLabelSizeX; // Size of the x-axis label
48  double fLabelSizeY; // Size of the y-axis label
49  double fLabelSizeZ; // Size of the z-axis label
50  double fDivisionsX; // The number of divisions in x-axis
51  double fDivisionsY; // The number of divisions in y-axis
52  int fFont; // Font index for titles and labels
53 
54  // TPad appearance settings
55  int fLogX; // 1: Logarithmic x-axis, 0: linear x-axis
56  int fLogY; // 1: Logarithmic y-axis, 0: linear y-axis
57  int fLogZ; // 1: Logarithmic z-axis, 0: linear z-axis
58  int fGridX; // 1: Grid in x-axis, 0: no grid
59  int fGridY; // 1: Grid in y-axis, 0: no grid
60  int fTickX; // 1: Ticks in x-axis, 0: no ticks
61  int fTickY; // 1: Ticks in y-axis, 0: no ticks
62 
63  // Canvas displacement settings
64  int fCanvasDisplacementX; // Displacement of the canvas for one index in x-direction
65  int fCanvasDisplacementY; // Displacement of the canvas for one index in y-direction
66  int fCanvasesInOneRow; // Number of canvases in a row before a new row is started
67 
68  // Handles needed for custom canvas creation
69  TCanvas *fCanvas; // If only a custom canvas is drawn, we need to keep on handle on that
70  TPad *fSinglePad; // Single pad for single canvas
71  TPad *fUpperSplitPad; // Upper pad in split canvas
72  TPad *fLowerSplitPad; // Lower pad in split canvas
73  TPad *fLeftRowPad; // Left pad in a row of three pads
74  TPad *fMiddleRowPad; // Middle pad in a row of three pads
75  TPad *fRightRowPad; // Right pad in the row of three pads
76 
77  // Settings for canvas splitting
78  double fSplitRatio; // The percentage of the lower pad from the total canvas when splitting the canvas
79 
80  // Index for generating names
81  int fNameIndex; // Names for canvases and pads are generated using this index. Static so that unique naming is ensured
82  // This used to be static, but for some reason does not compile if defined as static. Should work like this also though
83  // Remember: static means that only one fNameIndex is used by all the JDrawers that are created in the code
84 
85  /*
86  * Trim the styles of given axes
87  *
88  * TAxis *xAxis = The styled x-axis
89  * TAxis *yAxis = The styled y-axis
90  * TAxis *zAxis = The styled z-axis
91  * TString xtit = Title of the x-axis
92  * TString ytit = Title of the y-axis
93  */
94  void SetAxisStyles(TAxis *xAxis, TAxis *yAxis, TAxis *zAxis, TString xtit, TString ytit) {
95  xAxis->CenterTitle(true); // Axis titles are centered
96  yAxis->CenterTitle(true); // Axis titles are centered
97  if (zAxis)
98  zAxis->CenterTitle(true); // Axis titles are centered
99 
100  xAxis->SetTitleOffset(fTitleOffsetX); // Give a small offset to the title so that it does overlap with axis
101  yAxis->SetTitleOffset(fTitleOffsetY); // Give a small offset to the title so that it does overlap with axis
102  if (zAxis)
103  zAxis->SetTitleOffset(fTitleOffsetZ); // Give a small offset to the title so that it does overlap with axis
104 
105  xAxis->SetTitleSize(fTitleSizeX); // Define the size of the title
106  yAxis->SetTitleSize(fTitleSizeY); // Define the size of the title
107  if (zAxis)
108  zAxis->SetTitleSize(fTitleSizeZ); // Define the size of the title
109 
110  xAxis->SetLabelOffset(fLabelOffsetX); // Give a small offset to the label so that it does overlap with axis
111  yAxis->SetLabelOffset(fLabelOffsetY); // Give a small offset to the label so that it does overlap with axis
112  if (zAxis)
113  zAxis->SetLabelOffset(fLabelOffsetZ); // Give a small offset to the label so that it does overlap with axis
114 
115  xAxis->SetLabelSize(fLabelSizeX); // Define the sixe of the label
116  yAxis->SetLabelSize(fLabelSizeY); // Define the sixe of the label
117  if (zAxis)
118  zAxis->SetLabelSize(fLabelSizeZ); // Define the sixe of the label
119 
120  xAxis->SetNdivisions(fDivisionsX); // Set the number of division markers
121  yAxis->SetNdivisions(fDivisionsY); // Set the number of division markers
122 
123  xAxis->SetTitle(xtit); // Set the axis title
124  yAxis->SetTitle(ytit); // Set the axis title
125 
126  xAxis->SetLabelFont(fFont); // Set the label font
127  yAxis->SetLabelFont(fFont); // Set the label font
128  if (zAxis)
129  zAxis->SetLabelFont(fFont); // Set the label font
130  xAxis->SetTitleFont(fFont); // Set the title font
131  yAxis->SetTitleFont(fFont); // Set the title font
132  if (zAxis)
133  zAxis->SetTitleFont(fFont); // Set the title font
134  }
135 
136  /*
137  * Trim the style of a histogram using the defined style values
138  *
139  * TH1 *hid = Histogram which is styled
140  * TString xtit = Title of the x-axis
141  * TString ytit = Title of the y-axis
142  */
143  void SetHistogramStyle(TH1 *hid, TString xtit, TString ytit) {
144  SetAxisStyles(hid->GetXaxis(), hid->GetYaxis(), hid->GetZaxis(), xtit, ytit);
145  }
146 
147  /*
148  * Trim the style of a function using the defined style values
149  *
150  * TF1 *hid = Function which is styled
151  * TString xtit = Title of the x-axis
152  * TString ytit = Title of the y-axis
153  */
154  void SetFunctionStyle(TF1 *hid, TString xtit, TString ytit) {
155  SetAxisStyles(hid->GetXaxis(), hid->GetYaxis(), hid->GetZaxis(), xtit, ytit);
156  }
157 
158  /*
159  * Trim the style of a graph using the defined style values
160  *
161  * TGraph *hid = Histogram which is styled
162  * TString xtit = Title of the x-axis
163  * TString ytit = Title of the y-axis
164  */
165  void SetGraphStyle(TGraph *hid, TString xtit, TString ytit) {
166  SetAxisStyles(hid->GetXaxis(), hid->GetYaxis(), nullptr, xtit, ytit);
167  }
168 
169  /*
170  * Set the pad specific values to the given pad
171  */
172  void SetPadValues(TPad *pad) {
173  pad->SetLogy(fLogY);
174  pad->SetLogx(fLogX);
175  pad->SetLogz(fLogZ);
176  pad->SetGridx(fGridX);
177  pad->SetGridy(fGridY);
178  pad->SetTickx(fTickX);
179  pad->SetTicky(fTickY);
180  }
181 
182  /*
183  * Generate a name for an object that does not exist yet
184  */
185  TString GenerateName(const char *objectName) {
186  TString name = Form("%s%d%d%d", objectName, fNameIndex++, fTopLeftX, fTopLeftY);
187  return name.Data();
188  }
189 
190  /*
191  * Generate a name for a canvas
192  */
194  TString name;
195  name = Form("canvas%d%d", fTopLeftX, fTopLeftY);
196  while (true) {
197  // If a canvas with a specified name does not exist, accept the name
198  if (gROOT->GetListOfCanvases()->FindObject(name) == nullptr) {
199  return name.Data();
200  }
201 
202  // If a canvas with a specified name does exist, try a new name
203  name = Form("canvas%d%d%d", fTopLeftX, fTopLeftY, fNameIndex++);
204  }
205  }
206 
207 public:
208  /*
209  * Constructor for JDrawer
210  */
212  Reset(); // Set all the style values to default
213  fNameIndex = 0;
214  }
215 
216  /*
217  * Destructor for JDrawer
218  */
219  ~JDrawer() = default;
220 
221  /*
222  * Draw a histogram to a canvas
223  *
224  * TH1 *histo = histogram to be drawn
225  * char *xTitle = title for the x-axis
226  * char *yTitle = title for the y-axis
227  * char *title = title of the histogram
228  * char *drawOption = options for drawing given in root documentation
229  */
231  TH1 *histo, const char *xTitle, const char *yTitle, const char *title = "", const char *drawOption = "") {
232  // If no titles are given, keep the original ones
233  if (strcmp(xTitle, "") == 0)
234  xTitle = histo->GetXaxis()
235  ->GetTitle(); // To compare char*:s we need to use strcmp function provided by <cstring> library
236  if (strcmp(yTitle, "") == 0)
237  yTitle = histo->GetYaxis()->GetTitle();
238  if (strcmp(title, "") == 0)
239  title = histo->GetTitle();
240 
241  // Set up the histogram and draw it to current canvas
242  histo->SetTitle(title);
243  SetHistogramStyle(histo, xTitle, yTitle);
244  histo->Draw(drawOption);
245  }
246 
247  /*
248  * Draw a histogram to a canvas
249  *
250  * TH1 *histo = histogram to be drawn
251  * char *xTitle = title for the x-axis
252  * char *yTitle = title for the y-axis
253  * char *title = title of the histogram
254  * char *drawOption = options for drawing given in root documentation
255  */
257  TH1 *histo, const char *xTitle, const char *yTitle, const char *title = "", const char *drawOption = "") {
258  // If no titles are given, keep the original ones
259  if (strcmp(xTitle, "") == 0)
260  xTitle = histo->GetXaxis()
261  ->GetTitle(); // To compare char*:s we need to use strcmp function provided by <cstring> library
262  if (strcmp(yTitle, "") == 0)
263  yTitle = histo->GetYaxis()->GetTitle();
264  if (strcmp(title, "") == 0)
265  title = histo->GetTitle();
266 
267  // Set up the histogram and draw it to canvas
268  CreateCanvas();
269  histo->SetTitle(title);
270  SetHistogramStyle(histo, xTitle, yTitle);
271  histo->Draw(drawOption);
272  }
273 
274  /*
275  * Draw histogram without changing the titles
276  *
277  * TH1 *histo = histogram to be drawn
278  * char *drawOption = options for drawing given in root documentation
279  */
280  void DrawHistogram(TH1 *histo, const char *drawOption = "") { DrawHistogram(histo, "", "", "", drawOption); }
281 
282  /*
283  * Draw a histogram to a pad of a split canvas
284  *
285  * TH1 *histo = histogram to be drawn
286  * char *xTitle = title for the x-axis
287  * char *yTitle = title for the y-axis
288  * char *title = title of the histogram
289  * char *drawOption = options for drawing given in root documentation
290  */
292  TPad *drawPad,
293  const char *xTitle = "",
294  const char *yTitle = "",
295  const char *title = "",
296  const char *drawOption = "") {
297  // If no titles are given, keep the original ones
298  if (strcmp(xTitle, "") == 0)
299  xTitle = histo->GetXaxis()
300  ->GetTitle(); // To compare char*:s we need to use strcmp function provided by <cstring> library
301  if (strcmp(yTitle, "") == 0)
302  yTitle = histo->GetYaxis()->GetTitle();
303  if (strcmp(title, "") == 0)
304  title = histo->GetTitle();
305 
306  // Change to the desired pad
307  SetPadValues(drawPad);
308  drawPad->cd();
309 
310  // Remove statistics box and title
311  gStyle->SetOptStat(0);
312  gStyle->SetOptTitle(0);
313 
314  // Set up the histogram and draw it to the pad
315  histo->SetTitle(title);
316  SetHistogramStyle(histo, xTitle, yTitle);
317  histo->Draw(drawOption);
318  }
319 
320  /*
321  * Draw a histogram to an upper pad of a split canvas
322  *
323  * TH1 *histo = histogram to be drawn
324  * char *xTitle = title for the x-axis
325  * char *yTitle = title for the y-axis
326  * char *title = title of the histogram
327  * char *drawOption = options for drawing given in root documentation
328  */
330  const char *xTitle = "",
331  const char *yTitle = "",
332  const char *title = "",
333  const char *drawOption = "") {
334  // If there is no upper pad, create one
335  if (fUpperSplitPad == nullptr) {
336  //SetDefaultAppearanceSplitCanvas();
338  }
339 
341  }
342 
343  /*
344  * Draw a histogram to an upper pad of a split canvas
345  *
346  * TH1 *histo = histogram to be drawn
347  * char *xTitle = title for the x-axis
348  * char *yTitle = title for the y-axis
349  * char *title = title of the histogram
350  * char *drawOption = options for drawing given in root documentation
351  */
353  const char *xTitle = "",
354  const char *yTitle = "",
355  const char *title = "",
356  const char *drawOption = "") {
357  // If there is no lower pad, create one
358  if (fLowerSplitPad == nullptr) {
359  //SetDefaultAppearanceSplitCanvas();
361  }
362 
364  }
365 
366  /*
367  * Draw a graph to a canvas
368  *
369  * TGraph *graph = graph to be drawn
370  * double xlow = lowest x-axis value drawn
371  * double xhigh = highest x-axis value drawn
372  * double ylow = lowest y-axis value drawn
373  * double yhigh = highest y-axis value drawn
374  * char *xTitle = title for the x-axis
375  * char *yTitle = title for the y-axis
376  * char *title = title of the histogram
377  * char *drawOption = options for drawing given in root documentation
378  */
379  void DrawGraph(TGraph *graph,
380  double xlow,
381  double xhigh,
382  double ylow,
383  double yhigh,
384  const char *xTitle = "",
385  const char *yTitle = "",
386  const char *title = "",
387  const char *drawOption = "") {
388  // Create the canvas with right specs and a graph into it
389  CreateCanvas(xlow, xhigh, ylow, yhigh, xTitle, yTitle, title);
390  graph->Draw(drawOption);
391  }
392 
393  /*
394  * Draw a graph to a canvas. Notice that with custom axes the option "a" should be given for the first graph in each canvas.
395  *
396  * TGraph *graph = graph to be drawn
397  * double xlow = lowest x-axis value drawn
398  * double xhigh = highest x-axis value drawn
399  * double ylow = lowest y-axis value drawn
400  * double yhigh = highest y-axis value drawn
401  * char *xTitle = title for the x-axis
402  * char *yTitle = title for the y-axis
403  * char *title = title of the histogram
404  * char *drawOption = options for drawing given in root documentation
405  */
406  void DrawGraphCustomAxes(TGraph *graph,
407  double xlow,
408  double xhigh,
409  double ylow,
410  double yhigh,
411  const char *xTitle = "",
412  const char *yTitle = "",
413  const char *title = "",
414  const char *drawOption = "") {
415  // If no titles are given, keep the original ones
416  if (strcmp(xTitle, "") == 0)
417  xTitle = graph->GetXaxis()
418  ->GetTitle(); // To compare char*:s we need to use strcmp function provided by <cstring> library
419  if (strcmp(yTitle, "") == 0)
420  yTitle = graph->GetYaxis()->GetTitle();
421  if (strcmp(title, "") == 0)
422  title = graph->GetTitle();
423 
424  // Set up the histogram and draw it to canvas
425  CreateCanvas();
426  graph->SetTitle(title);
427  graph->GetXaxis()->SetRangeUser(xlow, xhigh);
428  graph->GetYaxis()->SetRangeUser(ylow, yhigh);
429  SetGraphStyle(graph, xTitle, yTitle);
430  graph->Draw(drawOption);
431  }
432 
433  /*
434  * Draw a function to a canvas
435  *
436  * TF1 *myFun = histogram to be drawn
437  * char *xTitle = title for the x-axis
438  * char *yTitle = title for the y-axis
439  * char *title = title of the histogram
440  * char *drawOption = options for drawing given in root documentation
441  */
443  TF1 *myFun, const char *xTitle, const char *yTitle, const char *title = "", const char *drawOption = "") {
444  // If no titles are given, keep the original ones
445  if (strcmp(xTitle, "") == 0)
446  xTitle = myFun->GetXaxis()
447  ->GetTitle(); // To compare char*:s we need to use strcmp function provided by <cstring> library
448  if (strcmp(yTitle, "") == 0)
449  yTitle = myFun->GetYaxis()->GetTitle();
450  if (strcmp(title, "") == 0)
451  title = myFun->GetTitle();
452 
453  // Set up the histogram and draw it to canvas
454  CreateCanvas();
455  myFun->SetTitle(title);
456  SetFunctionStyle(myFun, xTitle, yTitle);
457  myFun->Draw(drawOption);
458  }
459 
460  /*
461  * Draw histogram without changing the titles
462  *
463  * TF1 *myFun = function to be drawn
464  * char *drawOption = options for drawing given in root documentation
465  */
466  void DrawFunction(TF1 *myFun, const char *drawOption = "") { DrawFunction(myFun, "", "", "", drawOption); }
467 
468  /*
469  * Set all the values back to default
470  */
471  void Reset() {
472  // Set default values for margins
473  fMarginLeft = 0.15; // left margin
474  fMarginRight = 0.06; // right margin
475  fMarginBottom = 0.15; // bottom margin
476  fMarginTop = 0.06; // top margin
477 
478  // Set default values for the size and place of the canvas
479  fTopLeftX = 10; // Number of pixels the the canvas is out of the top left corner of the screen in x-direction
480  fTopLeftY = 10; // Number of pixels the the canvas is out of the top left corner of the screen in y-direction
481  fCanvasWidth = 700; // Width of the canvas
482  fCanvasHeight = 500; // Height of the canvas
483 
484  // Set default values for histogram appearance settings
485  fTitleOffsetX = 1.1; // Offset of the x-axis title
486  fTitleOffsetY = 1.1; // Offset of the y-axis title
487  fTitleOffsetZ = 1.3; // Pffset of the z-axis title
488  fTitleSizeX = 0.06; // Size of the x-axis title
489  fTitleSizeY = 0.06; // Size of the y-axis title
490  fTitleSizeZ = 0.06; // Size of the z-axis title
491  fLabelOffsetX = 0.01; // Offset of the x-axis label
492  fLabelOffsetY = 0.001; // Offset of the y-axis label
493  fLabelOffsetZ = 0.001; // Offset of the z-axis label
494  fLabelSizeX = 0.05; // Size of the x-axis label
495  fLabelSizeY = 0.05; // Size of the y-axis label
496  fLabelSizeZ = 0.05; // Size of the z-axis label
497  fDivisionsX = 505; // The number of divisions in x-axis
498  fDivisionsY = 505; // The number of divisions in y-axis
499  fFont = 42; // Font index for titles and labels
500 
501  // Axes are linear by default
502  fLogX = 0; // 1: Logarithmic x-axis, 0: linear x-axis
503  fLogY = 0; // 1: Logarithmic y-axis, 0: linear y-axis
504  fLogZ = 0; // 1: Logarithmic z-axis, 0: linear z-axis
505 
506  // Set default values for canves displacement information
507  fCanvasDisplacementX = 100; // Displacement of the canvas for one index in x-direction
508  fCanvasDisplacementY = 100; // Displacement of the canvas for one index in y-direction
509  fCanvasesInOneRow = 10; // Number of canvases in a row before a new row is started
510 
511  // Set defauls values for pad properties
512  fGridX = 0; // 1: Grid in x-axis, 0: no grid
513  fGridY = 0; // 1: Grid in y-axis, 0: no grid
514  fTickX = 1; // 1: Ticks in x-axis, 0: no ticks
515  fTickY = 1; // 1: Ticks in y-axis, 0: no ticks
516 
517  // Default setting values for splitted canvas
518  fSplitRatio = 0.4; // The percentage of the lower pad from the total canvas when splitting the canvas
519 
520  // Set the canvas handles to null
521  fCanvas = nullptr;
522  fSinglePad = nullptr;
523  fUpperSplitPad = nullptr;
524  fLowerSplitPad = nullptr;
525  fLeftRowPad = nullptr;
526  fMiddleRowPad = nullptr;
527  fRightRowPad = nullptr;
528  }
529 
530  /*
531  * Create a canvas and one pad to it
532  */
533  void CreateCanvas() {
534  // Create a canvas and set up its appearance
535  gStyle->SetOptStat(0); // remove statistics box
536  TString cname = GenerateNameForCanvas();
537  fCanvas = new TCanvas(cname.Data(), cname.Data(), fTopLeftX, fTopLeftY, fCanvasWidth, fCanvasHeight);
538  fSinglePad = new TPad("pad", "pad", 0.01, 0.01, 0.99, 0.99, 0, 0, 0);
539  fSinglePad->SetLeftMargin(fMarginLeft);
540  fSinglePad->SetBottomMargin(fMarginBottom);
541  fSinglePad->SetTopMargin(fMarginTop);
542  fSinglePad->SetRightMargin(fMarginRight);
544  fSinglePad->Draw();
545  fSinglePad->cd();
546  }
547 
548  /*
549  * Create a canvas with a grid of desired size and titles
550  *
551  * double xlow = lowest x-axis value drawn
552  * double xhigh = highest x-axis value drawn
553  * double ylow = lowest y-axis value drawn
554  * double yhigh = highest y-axis value drawn
555  * char *xTitle = title for the x-axis
556  * char *yTitle = title for the y-axis
557  * char *title = title of the histogram
558  */
559  void CreateCanvas(double xlow,
560  double xhigh,
561  double ylow,
562  double yhigh,
563  const char *xTitle = "",
564  const char *yTitle = "",
565  const char *title = "") {
566  // First make a canvas
567  CreateCanvas();
568 
569  // Create a dummy 2D-histogram to set the drawing ranges and titles
570  TString dummyName = GenerateName("histo");
571  TH2F *dummyHisto = new TH2F(dummyName.Data(), title, 10, xlow, xhigh, 10, ylow, yhigh);
572  SetHistogramStyle(dummyHisto, xTitle, yTitle);
573  dummyHisto->Draw();
574  }
575 
576  /*
577  * Create a canvas that is split to two pads that are on top of each other
578  */
580  TString dummyName; // dummy name generator
581  dummyName = GenerateNameForCanvas();
582 
583  // Create the canvas
584  fCanvas = new TCanvas(dummyName.Data(), dummyName.Data(), fTopLeftX, fTopLeftY, fCanvasWidth, fCanvasHeight);
585  fCanvas->SetFillStyle(4000); // The created canvas is completely transparent
586  fCanvas->SetFillColor(10); // Canvas is filled with white color
587  gStyle->SetOptStat(0); // Disable the drawing of the statistics box to the canvas
588  gStyle->SetOptTitle(0); // Disable the drawing of titles to the canvas
589  fCanvas->SetMargin(0, 0, 0, 0); // Remove the margins from the bottom canvas
590  fCanvas->Draw(); // Draw the canvas to the screen
591 
592  // ---- Create the two pads to the canvas ----
593 
594  // The upper pad stretches from the top of the canvas to the defined split ratio
595  dummyName = GenerateName("UpperPad");
596  fUpperSplitPad = new TPad(dummyName.Data(), dummyName.Data(), 0, fSplitRatio, 1, 1, 0);
597  fUpperSplitPad->SetTopMargin(fMarginTop / (1 - fSplitRatio)); // Adjust top margin according to the split ratio
598  fUpperSplitPad->SetBottomMargin(
599  0.0015); // Make the bottom margin small so that the pads fit nicely on top of each other
600  fUpperSplitPad->SetLeftMargin(fMarginLeft);
601  fUpperSplitPad->SetRightMargin(fMarginRight);
602  fUpperSplitPad->Draw();
603 
604  // The lower pad stretches from the defined split ratio to the bottom of the canvas
605  dummyName = GenerateName("LowerPad");
606  fLowerSplitPad = new TPad(dummyName.Data(), dummyName.Data(), 0, 0, 1, fSplitRatio, 0);
607  fLowerSplitPad->SetTopMargin(0.0015); // Make the top margin small so that the pads fit nicely on top of each other
608  fLowerSplitPad->SetBottomMargin(fMarginBottom / fSplitRatio); // Adjust bottom margin according to the split ratio
609  fLowerSplitPad->SetLeftMargin(fMarginLeft);
610  fLowerSplitPad->SetRightMargin(fMarginRight);
611  fLowerSplitPad->Draw();
612  }
613 
614  /*
615  * Create a canvas where three graphs can be drawn in one row (to show all xlong bins in one figure for example)
616  */
618  TString dummyName; // dummy name generator
619  dummyName = GenerateNameForCanvas();
620 
621  // Create the canvas
622  fCanvas = new TCanvas(dummyName.Data(), dummyName.Data(), fTopLeftX, fTopLeftY, fCanvasWidth, fCanvasHeight);
623  fCanvas->SetFillStyle(4000); // The created canvas is completely transparent
624  fCanvas->SetFillColor(10); // Canvas is filled with white color
625  gStyle->SetOptStat(0); // Disable the drawing of the statistics box to the canvas
626  gStyle->SetOptTitle(0); // Disable the drawing of titles to the canvas
627  fCanvas->SetMargin(0, 0, 0, 0); // Remove the margins from the bottom canvas
628  fCanvas->Draw(); // Draw the canvas to the screen
629 
630  // ---- Create the two pads to the canvas ----
631 
632  // First, find the correct relation between different pads based on the required margins
633  double smallMargin = 0.0006;
634  double evenSmallerMargin = 0.0002;
635  double relativePlotSizeLeftPad = 1 - (fMarginLeft + evenSmallerMargin);
636  double relativePlotSizeMiddlePad = 1 - (2 * smallMargin);
637  double relativePlotSizeRightPad = 1 - (fMarginRight + smallMargin);
638  double firstSeparator = 1 / (1 + relativePlotSizeLeftPad / relativePlotSizeMiddlePad +
639  relativePlotSizeLeftPad / relativePlotSizeRightPad);
640  double secondSeparator = firstSeparator + (relativePlotSizeLeftPad / relativePlotSizeMiddlePad) * firstSeparator;
641 
642  // The first pad stretches from the left corner 1/3 of the total horizontal space, taking into account marginals
643  dummyName = GenerateName("LeftPad");
644  fLeftRowPad = new TPad(dummyName.Data(), dummyName.Data(), 0, 0, firstSeparator, 1, 0);
645  fLeftRowPad->SetTopMargin(fMarginTop);
646  fLeftRowPad->SetBottomMargin(fMarginBottom);
647  fLeftRowPad->SetLeftMargin(fMarginLeft);
648  fLeftRowPad->SetRightMargin(
649  evenSmallerMargin); // Make the right margin small so that the pads fit nicely on top of each other
651  fLeftRowPad->Draw();
652 
653  // The second pad stretches from 1/3 of the total horizontal space to 2/3, taking into account marginals
654  dummyName = GenerateName("MiddlePad");
655  fMiddleRowPad = new TPad(dummyName.Data(), dummyName.Data(), firstSeparator, 0, secondSeparator, 1, 0);
656  fMiddleRowPad->SetTopMargin(fMarginTop);
657  fMiddleRowPad->SetBottomMargin(fMarginBottom);
658  fMiddleRowPad->SetLeftMargin(
659  smallMargin); // Make the left margin small so that the pads fit nicely on top of each other
660  fMiddleRowPad->SetRightMargin(
661  smallMargin); // Make the right margin small so that the pads fit nicely on top of each other
663  fMiddleRowPad->Draw();
664 
665  // The third pad stretches from 2/3 of the total horizontal space right corner, taking into account marginals
666  dummyName = GenerateName("RightPad");
667  fRightRowPad = new TPad(dummyName.Data(), dummyName.Data(), secondSeparator, 0, 1, 1, 0);
668  fRightRowPad->SetTopMargin(fMarginTop);
669  fRightRowPad->SetBottomMargin(fMarginBottom);
670  fRightRowPad->SetLeftMargin(
671  smallMargin); // Make the left margin small so that the pads fit nicely on top of each other
672  fRightRowPad->SetRightMargin(fMarginRight);
674  fRightRowPad->Draw();
675  }
676 
677  /*
678  * Create a canvas with a grid of desired size and titles
679  *
680  * double xlow = lowest x-axis value drawn
681  * double xhigh = highest x-axis value drawn
682  * double ylow = lowest y-axis value drawn
683  * double yhigh = highest y-axis value drawn
684  * char *xTitle = title for the x-axis
685  * char *yTitle = title for the y-axis
686  * char *title = title of the histogram
687  */
688  void CreateCanvasGraphRow(double xlow,
689  double xhigh,
690  double ylow,
691  double yhigh,
692  const char *xTitle = "",
693  const char *yTitle = "",
694  const char *title = "") {
695  // First make a canvas
697 
698  // Create a dummy 2D-histogram to set the drawing ranges and titles
699  SelectPad(0);
700  TString dummyName = GenerateName("histo");
701  TH2F *dummyHisto = new TH2F(dummyName.Data(), "", 10, xlow, xhigh, 10, ylow, yhigh);
702  SetHistogramStyle(dummyHisto, xTitle, yTitle);
703  dummyHisto->Draw();
704 
705  // Create a dummy 2D-histogram to set the drawing ranges and titles
706  SelectPad(1);
707  dummyName = GenerateName("histo");
708  dummyHisto = new TH2F(dummyName.Data(), title, 10, xlow, xhigh, 10, ylow, yhigh);
709  SetHistogramStyle(dummyHisto, xTitle, "");
710  dummyHisto->Draw();
711 
712  // Create a dummy 2D-histogram to set the drawing ranges and titles
713  SelectPad(2);
714  dummyName = GenerateName("histo");
715  dummyHisto = new TH2F(dummyName.Data(), "", 10, xlow, xhigh, 10, ylow, yhigh);
716  SetHistogramStyle(dummyHisto, xTitle, "");
717  dummyHisto->Draw();
718  }
719 
720  /*
721  * Create split canvas with default settings defining the canvas displacement info
722  *
723  * int canvasIndex = index number for the canvas, this is used to calculate the canvas displacement
724  * int canvasesInRow = number of canvases in a row before the next row is started
725  */
726  void CreateSplitCanvas(int canvasIndex, int canvasesInRow) {
728  SetNumberOfCanvasesInOneRow(canvasesInRow);
729  SetCanvasDisplacement(canvasIndex);
731  }
732 
733  // Setter for left margin
735 
736  // Setter for right margin
738 
739  // Setter for bottom margin
741 
742  // Setter for top margin
743  void SetTopMargin(double margin) { fMarginTop = margin; }
744 
745  /*
746  * Set all the margins for canvas
747  *
748  * double left = new left margin
749  * double right = new right margin
750  * double top = new top margin
751  * doulbe bottom = new bottom margin
752  */
753  void SetMargins(double left, double right, double top, double bottom) {
754  fMarginLeft = left;
755  fMarginRight = right;
756  fMarginTop = top;
757  fMarginBottom = bottom;
758  }
759 
760  // Setter for x-axis title offset
762 
763  // Setter for y-axis title offset
765 
766  // Setter for x-axis title size
767  void SetTitleSizeX(double size) { fTitleSizeX = size; }
768 
769  // Setter for y-axis title size
770  void SetTitleSizeY(double size) { fTitleSizeY = size; }
771 
772  // Setter for x-axis label offset
774 
775  // Setter for y-axis label offset
777 
778  // Setter for x-axis label size
779  void SetLabelSizeX(double size) { fLabelSizeX = size; }
780 
781  // Setter for y-axis label size
782  void SetLabelSizeY(double size) { fLabelSizeY = size; }
783 
784  // Setter for number of divisions in x-axis
785  void SetNDivisionsX(int div) { fDivisionsX = div; }
786 
787  // Setter for number of divisions in y-axis
788  void SetNDivisionsY(int div) { fDivisionsY = div; }
789 
790  // Setter for the font
791  void SetFont(int fontIndex) { fFont = fontIndex; }
792 
793  /*
794  * Apply the settings that are given to JDrawer to a given histogram
795  *
796  * TH1 *histo = Histogram that is styled
797  * TString xTitle = title for the x axis
798  * TString yTitle = title for the y axis
799  */
800  void ApplyStyleSettings(TH1 *histo, TString xTitle = "", TString yTitle = "") {
801  SetHistogramStyle(histo, xTitle, yTitle);
802  }
803 
804  /*
805  * Set all the appearance factors for the histogram
806  *
807  * double titoffx = Offset of the x-axis title
808  * double titoffy = Offset of the y-axis title
809  * double titsizex = Size of the x-axis title
810  * double titsizey = Size of the y-axis title
811  * double labeloffx = Offset of the x-axis label
812  * double labeloffy = Offset of the y-axis label
813  * double labelsizex = Size of the x-axis label
814  * double labelsizey = Size of the y-axis label
815  * int divx = The number of divisions in x-axis
816  * int divy = The number of divisions in y-axis
817  * int fontIndex = Font index for titles and labels
818  */
819  void SetHistogramAppearance(double titoffx,
820  double titoffy,
821  double titsizex,
822  double titsizey,
823  double labeloffx,
824  double labeloffy,
825  double labelsizex,
826  double labelsizey,
827  int divx,
828  int divy,
829  int fontIndex) {
830  fTitleOffsetX = titoffx; // Offset of the x-axis title
831  fTitleOffsetY = titoffy; // Offset of the y-axis title
832  fTitleSizeX = titsizex; // Size of the x-axis title
833  fTitleSizeY = titsizey; // Size of the y-axis title
834  fLabelOffsetX = labeloffx; // Offset of the x-axis label
835  fLabelOffsetY = labeloffy; // Offset of the y-axis label
836  fLabelSizeX = labelsizex; // Size of the x-axis label
837  fLabelSizeY = labelsizey; // Size of the y-axis label
838  fDivisionsX = divx; // The number of divisions in x-axis
839  fDivisionsY = divy; // The number of divisions in y-axis
840  fFont = fontIndex; // Font index for titles and labels
841  }
842 
843  /*
844  * Setter for the scale of the x-axis
845  *
846  * bool log = true, if logarithmic axis, false if linear axis
847  */
848  void SetLogX(bool log = true) {
849  if (log) {
850  fLogX = 1;
851  } else {
852  fLogX = 0;
853  }
854  }
855 
856  /*
857  * Setter for the scale of the y-axis
858  *
859  * bool log = true, if logarithmic axis, false if linear axis
860  */
861  void SetLogY(bool log = true) {
862  if (log) {
863  fLogY = 1;
864  } else {
865  fLogY = 0;
866  }
867  }
868 
869  /*
870  * Setter for the scale of the z-axis
871  *
872  * bool log = true, if logarithmic axis, false if linear axis
873  */
874  void SetLogZ(bool log = true) {
875  if (log) {
876  fLogZ = 1;
877  } else {
878  fLogZ = 0;
879  }
880  }
881 
882  // Getter for the displacement of the drawn canvas in x-direction
884 
885  // Getter for the displacement of the drawn canvas in y-direction
887 
888  // Setter for the displacement of the drawn canvas in x-direction
889  void SetCanvasDisplacementX(int displacement) { fTopLeftX = displacement; }
890 
891  // Setter for the displacement of the drawn canvas in y-direction
892  void SetCanvasDisplacementY(int displacement) { fTopLeftY = displacement; }
893 
894  /*
895  * Setter for the displacement of the canvas from the top left corner
896  *
897  * int x = displacement in x-direction
898  * int y = displacement in y-direction
899  */
900  void SetCanvasDisplacement(int x, int y) {
903  }
904 
905  /*
906  * Setter for displacement using an index
907  *
908  * int index = index number for the canvas
909  *
910  * The position of the canvas is decided in the following way:
911  * The displacement of two consecutive canvases in the x-direction is fCanvasDisplacementX.
912  * The canvases are put it one row, until there is fCanvasesInOneRow canvases in that row.
913  * After this, the next canvas is put in the next row fCanvasDisplacementY under the first
914  * canvas in the preceeding row. Then the next row is filled as the previous.
915  */
919  }
920 
921  /*
922  * Setter for canvas displacement settings
923  *
924  * int displacementX = Displacement of the canvas for one index in x-direction
925  * int displacementY = Displacement of the canvas for one index in y-direction
926  * int canvasesInRow = Number of canvases in a row before a new row is started
927  */
928  void SetCanvasDisplacementSettings(int displacementX, int displacementY, int canvasesInRow) {
929  fCanvasDisplacementX = displacementX;
930  fCanvasDisplacementY = displacementY;
931  fCanvasesInOneRow = canvasesInRow;
932  }
933 
934  /*
935  * Setter for number of canvases in one row
936  *
937  * int canvasesInRow = Number of canvases in a row before a new row is started
938  */
939  void SetNumberOfCanvasesInOneRow(int canvasesInRow) { fCanvasesInOneRow = canvasesInRow; }
940 
941  /*
942  * Setter for the size of the drawn canvas
943  *
944  * int width = width of the canvas
945  * int height = height of the canvas
946  */
947  void SetCanvasSize(int width, int height) {
949  fCanvasHeight = height;
950  }
951 
952  /*
953  * Setter for grid in x-axis
954  */
955  void SetGridX(bool grid = true) {
956  if (grid) {
957  fGridX = 1;
958  } else {
959  fGridX = 0;
960  }
961  }
962 
963  /*
964  * Setter for grid in y-axis
965  */
966  void SetGridY(bool grid = true) {
967  if (grid) {
968  fGridY = 1;
969  } else {
970  fGridY = 0;
971  }
972  }
973 
974  /*
975  * Setter for grids in both axes
976  */
977  void SetGrid(int gridX, int gridY) {
978  SetGridX(gridX);
979  SetGridY(gridY);
980  }
981 
982  /*
983  * Setter for grid in x-axis
984  */
985  void SetTickX(bool tick = true) {
986  if (tick) {
987  fTickX = 1;
988  } else {
989  fTickX = 0;
990  }
991  }
992 
993  /*
994  * Setter for grid in y-axis
995  */
996  void SetTickY(bool tick = true) {
997  if (tick) {
998  fTickY = 1;
999  } else {
1000  fTickY = 0;
1001  }
1002  }
1003 
1004  /*
1005  * Setter for grids in both axes
1006  */
1007  void SetTick(int tickX, int tickY) {
1008  SetTickX(tickX);
1009  SetTickY(tickY);
1010  }
1011 
1012  /*
1013  * Setter for split ratio
1014  */
1015  void SetSplitRatio(double split) { fSplitRatio = split; }
1016 
1017  /*
1018  * Set the appearance values for splitted canvas as their default values
1019  * Different values than for single canvas are needed, so there is a different setter too
1020  *
1021  * Note: SetHistogramAppearance(titoffx, titoffy, titsizex, titsizey, labeloffx, labeloffy, labelsizex, labelsizey, divx, divy, fontIndex)
1022  */
1024  Reset();
1025  //SetHistogramAppearance(2.5, 2.5, 20, 20, 0.01, 0.001, 16, 16, 505, 505, 43); // Smaller label size for axes
1026  SetHistogramAppearance(2.5, 2.3, 25, 25, 0.01, 0.001, 20, 20, 505, 505, 43); // Increased label size for axes
1027  SetSplitRatio(0.4);
1028  SetRelativeCanvasSize(1.1, 0.7);
1029  SetMargins(0.21, 0.05, 0.09, 0.1); // Left, right, top, bottom
1030  }
1031 
1032  /*
1033  * Set the appearance values for graph to default values
1034  */
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  * Set the appearance values for row of graphs
1044  */
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  * Getter for pad according to the ID number
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  * Getter for pad according to the ID number
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  * Getter for the upper pad
1110  */
1111  TPad *GetUpperPad() { return fUpperSplitPad; }
1112 
1113  /*
1114  * Getter for the lower pad
1115  */
1116  TPad *GetLowerPad() { return fLowerSplitPad; }
1117 
1118  /*
1119  * Select the upper pad
1120  */
1121  void SelectUpperPad() { fUpperSplitPad->cd(); }
1122 
1123  /*
1124  * Select the upper pad
1125  */
1126  void SelectLowerPad() { fLowerSplitPad->cd(); }
1127 
1128  /*
1129  * Set the canvas size using scaling factor and aspect ratio
1130  *
1131  * double relativeSize = multiplication factor for the default canvas height of 600 pixels
1132  * double aspectRatio = the ratio canvas width / canvas height
1133  */
1134  void SetRelativeCanvasSize(double relativeSize, double aspectRatio) {
1135  fCanvasHeight = 600 * relativeSize;
1136  fCanvasWidth = aspectRatio * fCanvasHeight;
1137  }
1138 
1139  /*
1140  * Get the name of the considered canvas
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  * Set the drawing range for a pad to draw geometric objects to it
1153  *
1154  * double xLow = minimum x-axis range
1155  * double yLow = minimum y-axis range
1156  * double xHigh = maximum x-axis range
1157  * double yHigh = maximum y-axis range
1158  */
1159  void SetPadRange(double xLow, double yLow, double xHigh, double yHigh) {
1160  // TODO: Setting range also for split canvas
1161  fSinglePad->Range(xLow, yLow, xHigh, yHigh);
1162  fSinglePad->Clear();
1163  }
1164 };
1165 
1166 #endif
void SetSplitRatio(double split)
Definition: JDrawer.h:1015
size
Write out results.
int fTickX
Definition: JDrawer.h:60
void CreateSplitCanvas(int canvasIndex, int canvasesInRow)
Definition: JDrawer.h:726
int fTopLeftX
Definition: JDrawer.h:32
double fDivisionsY
Definition: JDrawer.h:51
double fMarginBottom
Definition: JDrawer.h:28
void SetGridX(bool grid=true)
Definition: JDrawer.h:955
void DrawHistogramToLowerPad(TH1 *histo, const char *xTitle="", const char *yTitle="", const char *title="", const char *drawOption="")
Definition: JDrawer.h:352
void DrawFunction(TF1 *myFun, const char *xTitle, const char *yTitle, const char *title="", const char *drawOption="")
Definition: JDrawer.h:442
TPad * fUpperSplitPad
Definition: JDrawer.h:71
void SetCanvasSize(int width, int height)
Definition: JDrawer.h:947
void SetRelativeCanvasSize(double relativeSize, double aspectRatio)
Definition: JDrawer.h:1134
TPad * fLeftRowPad
Definition: JDrawer.h:73
void SetLabelOffsetX(double offset)
Definition: JDrawer.h:773
void DrawHistogramToUpperPad(TH1 *histo, const char *xTitle="", const char *yTitle="", const char *title="", const char *drawOption="")
Definition: JDrawer.h:329
int fCanvasHeight
Definition: JDrawer.h:35
void SetCanvasDisplacement(int x, int y)
Definition: JDrawer.h:900
void DrawGraph(TGraph *graph, double xlow, double xhigh, double ylow, double yhigh, const char *xTitle="", const char *yTitle="", const char *title="", const char *drawOption="")
Definition: JDrawer.h:379
void SetLeftMargin(double margin)
Definition: JDrawer.h:734
void SetNumberOfCanvasesInOneRow(int canvasesInRow)
Definition: JDrawer.h:939
int GetCanvasDisplacementX()
Definition: JDrawer.h:883
void SetCanvasDisplacementSettings(int displacementX, int displacementY, int canvasesInRow)
Definition: JDrawer.h:928
void SetDefaultAppearanceSplitCanvas()
Definition: JDrawer.h:1023
int fGridY
Definition: JDrawer.h:59
void SetLabelSizeY(double size)
Definition: JDrawer.h:782
int fTickY
Definition: JDrawer.h:61
void SetTick(int tickX, int tickY)
Definition: JDrawer.h:1007
void SelectLowerPad()
Definition: JDrawer.h:1126
void SelectPad(int padNumber)
Definition: JDrawer.h:1080
double fTitleSizeY
Definition: JDrawer.h:42
double fMarginTop
Definition: JDrawer.h:29
void SetGraphStyle(TGraph *hid, TString xtit, TString ytit)
Definition: JDrawer.h:165
void CreateCanvas()
Definition: JDrawer.h:533
void SetAxisStyles(TAxis *xAxis, TAxis *yAxis, TAxis *zAxis, TString xtit, TString ytit)
Definition: JDrawer.h:94
void SetCanvasDisplacementX(int displacement)
Definition: JDrawer.h:889
void CreateSplitCanvas()
Definition: JDrawer.h:579
void Reset()
Definition: JDrawer.h:471
TPad * GetPad(int padNumber)
Definition: JDrawer.h:1055
void SetNDivisionsY(int div)
Definition: JDrawer.h:788
int fNameIndex
Definition: JDrawer.h:81
void SetPadRange(double xLow, double yLow, double xHigh, double yHigh)
Definition: JDrawer.h:1159
void SetCanvasDisplacementY(int displacement)
Definition: JDrawer.h:892
double fTitleSizeX
Definition: JDrawer.h:41
double fTitleOffsetZ
Definition: JDrawer.h:40
double fMarginRight
Definition: JDrawer.h:27
void SetGrid(int gridX, int gridY)
Definition: JDrawer.h:977
void SetTickY(bool tick=true)
Definition: JDrawer.h:996
int fFont
Definition: JDrawer.h:52
void SetLabelSizeX(double size)
Definition: JDrawer.h:779
void SetLogX(bool log=true)
Definition: JDrawer.h:848
int GetCanvasDisplacementY()
Definition: JDrawer.h:886
void ApplyStyleSettings(TH1 *histo, TString xTitle="", TString yTitle="")
Definition: JDrawer.h:800
void SetTitleOffsetY(double offset)
Definition: JDrawer.h:764
double fLabelOffsetY
Definition: JDrawer.h:45
void SetTitleSizeX(double size)
Definition: JDrawer.h:767
void DrawGraphCustomAxes(TGraph *graph, double xlow, double xhigh, double ylow, double yhigh, const char *xTitle="", const char *yTitle="", const char *title="", const char *drawOption="")
Definition: JDrawer.h:406
TPad * fMiddleRowPad
Definition: JDrawer.h:74
int fLogY
Definition: JDrawer.h:56
int fLogZ
Definition: JDrawer.h:57
void SetTopMargin(double margin)
Definition: JDrawer.h:743
void SetTitleSizeY(double size)
Definition: JDrawer.h:770
~JDrawer()=default
void SetBottomMargin(double margin)
Definition: JDrawer.h:740
Double_t margin
void SetTickX(bool tick=true)
Definition: JDrawer.h:985
double fTitleSizeZ
Definition: JDrawer.h:43
TCanvas * fCanvas
Definition: JDrawer.h:69
double fLabelOffsetZ
Definition: JDrawer.h:46
TPad * GetUpperPad()
Definition: JDrawer.h:1111
void SetHistogramAppearance(double titoffx, double titoffy, double titsizex, double titsizey, double labeloffx, double labeloffy, double labelsizex, double labelsizey, int divx, int divy, int fontIndex)
Definition: JDrawer.h:819
void CreateCanvasGraphRow()
Definition: JDrawer.h:617
double fLabelSizeX
Definition: JDrawer.h:47
double fLabelSizeZ
Definition: JDrawer.h:49
void SetRightMargin(double margin)
Definition: JDrawer.h:737
void DrawHistogramToCurrentCanvas(TH1 *histo, const char *xTitle, const char *yTitle, const char *title="", const char *drawOption="")
Definition: JDrawer.h:230
void SetFunctionStyle(TF1 *hid, TString xtit, TString ytit)
Definition: JDrawer.h:154
void DrawHistogram(TH1 *histo, const char *drawOption="")
Definition: JDrawer.h:280
void SetHistogramStyle(TH1 *hid, TString xtit, TString ytit)
Definition: JDrawer.h:143
void CreateCanvas(double xlow, double xhigh, double ylow, double yhigh, const char *xTitle="", const char *yTitle="", const char *title="")
Definition: JDrawer.h:559
double fLabelSizeY
Definition: JDrawer.h:48
void SelectUpperPad()
Definition: JDrawer.h:1121
double fMarginLeft
Definition: JDrawer.h:26
int fCanvasDisplacementX
Definition: JDrawer.h:64
double fDivisionsX
Definition: JDrawer.h:50
TString GenerateName(const char *objectName)
Definition: JDrawer.h:185
int fCanvasesInOneRow
Definition: JDrawer.h:66
double fTitleOffsetX
Definition: JDrawer.h:38
void SetDefaultAppearanceGraph()
Definition: JDrawer.h:1035
TPad * GetLowerPad()
Definition: JDrawer.h:1116
void SetLogY(bool log=true)
Definition: JDrawer.h:861
double fLabelOffsetX
Definition: JDrawer.h:44
TPad * fRightRowPad
Definition: JDrawer.h:75
void SetNDivisionsX(int div)
Definition: JDrawer.h:785
void SetMargins(double left, double right, double top, double bottom)
Definition: JDrawer.h:753
void SetCanvasDisplacement(int index)
Definition: JDrawer.h:916
double fSplitRatio
Definition: JDrawer.h:78
int fTopLeftY
Definition: JDrawer.h:33
void SetLabelOffsetY(double offset)
Definition: JDrawer.h:776
void DrawHistogramToPad(TH1 *histo, TPad *drawPad, const char *xTitle="", const char *yTitle="", const char *title="", const char *drawOption="")
Definition: JDrawer.h:291
TPad * fSinglePad
Definition: JDrawer.h:70
int fCanvasWidth
Definition: JDrawer.h:34
void SetTitleOffsetX(double offset)
Definition: JDrawer.h:761
void SetDefaultAppearanceGraphRow()
Definition: JDrawer.h:1045
TString GenerateNameForCanvas()
Definition: JDrawer.h:193
double fTitleOffsetY
Definition: JDrawer.h:39
void DrawHistogram(TH1 *histo, const char *xTitle, const char *yTitle, const char *title="", const char *drawOption="")
Definition: JDrawer.h:256
TString GetCanvasName()
Definition: JDrawer.h:1142
void SetLogZ(bool log=true)
Definition: JDrawer.h:874
void CreateCanvasGraphRow(double xlow, double xhigh, double ylow, double yhigh, const char *xTitle="", const char *yTitle="", const char *title="")
Definition: JDrawer.h:688
int fLogX
Definition: JDrawer.h:55
void SetPadValues(TPad *pad)
Definition: JDrawer.h:172
int fCanvasDisplacementY
Definition: JDrawer.h:65
JDrawer()
Definition: JDrawer.h:211
void SetFont(int fontIndex)
Definition: JDrawer.h:791
int fGridX
Definition: JDrawer.h:58
void DrawFunction(TF1 *myFun, const char *drawOption="")
Definition: JDrawer.h:466
void SetGridY(bool grid=true)
Definition: JDrawer.h:966
TPad * fLowerSplitPad
Definition: JDrawer.h:72