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  */
220  if (fCanvas)
221  delete fCanvas;
222  if (fSinglePad)
223  delete fSinglePad;
224  if (fUpperSplitPad)
225  delete fUpperSplitPad;
226  if (fLowerSplitPad)
227  delete fLowerSplitPad;
228  if (fLeftRowPad)
229  delete fLeftRowPad;
230  if (fMiddleRowPad)
231  delete fMiddleRowPad;
232  if (fRightRowPad)
233  delete fRightRowPad;
234  }
235 
236  /*
237  * Draw a histogram to a canvas
238  *
239  * TH1 *histo = histogram to be drawn
240  * char *xTitle = title for the x-axis
241  * char *yTitle = title for the y-axis
242  * char *title = title of the histogram
243  * char *drawOption = options for drawing given in root documentation
244  */
246  TH1 *histo, const char *xTitle, const char *yTitle, const char *title = "", const char *drawOption = "") {
247  // If no titles are given, keep the original ones
248  if (strcmp(xTitle, "") == 0)
249  xTitle = histo->GetXaxis()
250  ->GetTitle(); // To compare char*:s we need to use strcmp function provided by <cstring> library
251  if (strcmp(yTitle, "") == 0)
252  yTitle = histo->GetYaxis()->GetTitle();
253  if (strcmp(title, "") == 0)
254  title = histo->GetTitle();
255 
256  // Set up the histogram and draw it to current canvas
257  histo->SetTitle(title);
258  SetHistogramStyle(histo, xTitle, yTitle);
259  histo->Draw(drawOption);
260  }
261 
262  /*
263  * Draw a histogram to a canvas
264  *
265  * TH1 *histo = histogram to be drawn
266  * char *xTitle = title for the x-axis
267  * char *yTitle = title for the y-axis
268  * char *title = title of the histogram
269  * char *drawOption = options for drawing given in root documentation
270  */
272  TH1 *histo, const char *xTitle, const char *yTitle, const char *title = "", const char *drawOption = "") {
273  // If no titles are given, keep the original ones
274  if (strcmp(xTitle, "") == 0)
275  xTitle = histo->GetXaxis()
276  ->GetTitle(); // To compare char*:s we need to use strcmp function provided by <cstring> library
277  if (strcmp(yTitle, "") == 0)
278  yTitle = histo->GetYaxis()->GetTitle();
279  if (strcmp(title, "") == 0)
280  title = histo->GetTitle();
281 
282  // Set up the histogram and draw it to canvas
283  CreateCanvas();
284  histo->SetTitle(title);
285  SetHistogramStyle(histo, xTitle, yTitle);
286  histo->Draw(drawOption);
287  }
288 
289  /*
290  * Draw histogram without changing the titles
291  *
292  * TH1 *histo = histogram to be drawn
293  * char *drawOption = options for drawing given in root documentation
294  */
295  void DrawHistogram(TH1 *histo, const char *drawOption = "") { DrawHistogram(histo, "", "", "", drawOption); }
296 
297  /*
298  * Draw a histogram to a pad of a split canvas
299  *
300  * TH1 *histo = histogram to be drawn
301  * char *xTitle = title for the x-axis
302  * char *yTitle = title for the y-axis
303  * char *title = title of the histogram
304  * char *drawOption = options for drawing given in root documentation
305  */
307  TPad *drawPad,
308  const char *xTitle = "",
309  const char *yTitle = "",
310  const char *title = "",
311  const char *drawOption = "") {
312  // If no titles are given, keep the original ones
313  if (strcmp(xTitle, "") == 0)
314  xTitle = histo->GetXaxis()
315  ->GetTitle(); // To compare char*:s we need to use strcmp function provided by <cstring> library
316  if (strcmp(yTitle, "") == 0)
317  yTitle = histo->GetYaxis()->GetTitle();
318  if (strcmp(title, "") == 0)
319  title = histo->GetTitle();
320 
321  // Change to the desired pad
322  SetPadValues(drawPad);
323  drawPad->cd();
324 
325  // Remove statistics box and title
326  gStyle->SetOptStat(0);
327  gStyle->SetOptTitle(0);
328 
329  // Set up the histogram and draw it to the pad
330  histo->SetTitle(title);
331  SetHistogramStyle(histo, xTitle, yTitle);
332  histo->Draw(drawOption);
333  }
334 
335  /*
336  * Draw a histogram to an upper pad of a split canvas
337  *
338  * TH1 *histo = histogram to be drawn
339  * char *xTitle = title for the x-axis
340  * char *yTitle = title for the y-axis
341  * char *title = title of the histogram
342  * char *drawOption = options for drawing given in root documentation
343  */
345  const char *xTitle = "",
346  const char *yTitle = "",
347  const char *title = "",
348  const char *drawOption = "") {
349  // If there is no upper pad, create one
350  if (fUpperSplitPad == nullptr) {
351  //SetDefaultAppearanceSplitCanvas();
353  }
354 
356  }
357 
358  /*
359  * Draw a histogram to an upper pad of a split canvas
360  *
361  * TH1 *histo = histogram to be drawn
362  * char *xTitle = title for the x-axis
363  * char *yTitle = title for the y-axis
364  * char *title = title of the histogram
365  * char *drawOption = options for drawing given in root documentation
366  */
368  const char *xTitle = "",
369  const char *yTitle = "",
370  const char *title = "",
371  const char *drawOption = "") {
372  // If there is no lower pad, create one
373  if (fLowerSplitPad == nullptr) {
374  //SetDefaultAppearanceSplitCanvas();
376  }
377 
379  }
380 
381  /*
382  * Draw a graph to a canvas
383  *
384  * TGraph *graph = graph to be drawn
385  * double xlow = lowest x-axis value drawn
386  * double xhigh = highest x-axis value drawn
387  * double ylow = lowest y-axis value drawn
388  * double yhigh = highest y-axis value drawn
389  * char *xTitle = title for the x-axis
390  * char *yTitle = title for the y-axis
391  * char *title = title of the histogram
392  * char *drawOption = options for drawing given in root documentation
393  */
394  void DrawGraph(TGraph *graph,
395  double xlow,
396  double xhigh,
397  double ylow,
398  double yhigh,
399  const char *xTitle = "",
400  const char *yTitle = "",
401  const char *title = "",
402  const char *drawOption = "") {
403  // Create the canvas with right specs and a graph into it
404  CreateCanvas(xlow, xhigh, ylow, yhigh, xTitle, yTitle, title);
405  graph->Draw(drawOption);
406  }
407 
408  /*
409  * Draw a graph to a canvas. Notice that with custom axes the option "a" should be given for the first graph in each canvas.
410  *
411  * TGraph *graph = graph to be drawn
412  * double xlow = lowest x-axis value drawn
413  * double xhigh = highest x-axis value drawn
414  * double ylow = lowest y-axis value drawn
415  * double yhigh = highest y-axis value drawn
416  * char *xTitle = title for the x-axis
417  * char *yTitle = title for the y-axis
418  * char *title = title of the histogram
419  * char *drawOption = options for drawing given in root documentation
420  */
421  void DrawGraphCustomAxes(TGraph *graph,
422  double xlow,
423  double xhigh,
424  double ylow,
425  double yhigh,
426  const char *xTitle = "",
427  const char *yTitle = "",
428  const char *title = "",
429  const char *drawOption = "") {
430  // If no titles are given, keep the original ones
431  if (strcmp(xTitle, "") == 0)
432  xTitle = graph->GetXaxis()
433  ->GetTitle(); // To compare char*:s we need to use strcmp function provided by <cstring> library
434  if (strcmp(yTitle, "") == 0)
435  yTitle = graph->GetYaxis()->GetTitle();
436  if (strcmp(title, "") == 0)
437  title = graph->GetTitle();
438 
439  // Set up the histogram and draw it to canvas
440  CreateCanvas();
441  graph->SetTitle(title);
442  graph->GetXaxis()->SetRangeUser(xlow, xhigh);
443  graph->GetYaxis()->SetRangeUser(ylow, yhigh);
444  SetGraphStyle(graph, xTitle, yTitle);
445  graph->Draw(drawOption);
446  }
447 
448  /*
449  * Draw a function to a canvas
450  *
451  * TF1 *myFun = histogram to be drawn
452  * char *xTitle = title for the x-axis
453  * char *yTitle = title for the y-axis
454  * char *title = title of the histogram
455  * char *drawOption = options for drawing given in root documentation
456  */
458  TF1 *myFun, const char *xTitle, const char *yTitle, const char *title = "", const char *drawOption = "") {
459  // If no titles are given, keep the original ones
460  if (strcmp(xTitle, "") == 0)
461  xTitle = myFun->GetXaxis()
462  ->GetTitle(); // To compare char*:s we need to use strcmp function provided by <cstring> library
463  if (strcmp(yTitle, "") == 0)
464  yTitle = myFun->GetYaxis()->GetTitle();
465  if (strcmp(title, "") == 0)
466  title = myFun->GetTitle();
467 
468  // Set up the histogram and draw it to canvas
469  CreateCanvas();
470  myFun->SetTitle(title);
471  SetFunctionStyle(myFun, xTitle, yTitle);
472  myFun->Draw(drawOption);
473  }
474 
475  /*
476  * Draw histogram without changing the titles
477  *
478  * TF1 *myFun = function to be drawn
479  * char *drawOption = options for drawing given in root documentation
480  */
481  void DrawFunction(TF1 *myFun, const char *drawOption = "") { DrawFunction(myFun, "", "", "", drawOption); }
482 
483  /*
484  * Set all the values back to default
485  */
486  void Reset() {
487  // Set default values for margins
488  fMarginLeft = 0.15; // left margin
489  fMarginRight = 0.06; // right margin
490  fMarginBottom = 0.15; // bottom margin
491  fMarginTop = 0.06; // top margin
492 
493  // Set default values for the size and place of the canvas
494  fTopLeftX = 10; // Number of pixels the the canvas is out of the top left corner of the screen in x-direction
495  fTopLeftY = 10; // Number of pixels the the canvas is out of the top left corner of the screen in y-direction
496  fCanvasWidth = 700; // Width of the canvas
497  fCanvasHeight = 500; // Height of the canvas
498 
499  // Set default values for histogram appearance settings
500  fTitleOffsetX = 1.1; // Offset of the x-axis title
501  fTitleOffsetY = 1.1; // Offset of the y-axis title
502  fTitleOffsetZ = 1.3; // Pffset of the z-axis title
503  fTitleSizeX = 0.06; // Size of the x-axis title
504  fTitleSizeY = 0.06; // Size of the y-axis title
505  fTitleSizeZ = 0.06; // Size of the z-axis title
506  fLabelOffsetX = 0.01; // Offset of the x-axis label
507  fLabelOffsetY = 0.001; // Offset of the y-axis label
508  fLabelOffsetZ = 0.001; // Offset of the z-axis label
509  fLabelSizeX = 0.05; // Size of the x-axis label
510  fLabelSizeY = 0.05; // Size of the y-axis label
511  fLabelSizeZ = 0.05; // Size of the z-axis label
512  fDivisionsX = 505; // The number of divisions in x-axis
513  fDivisionsY = 505; // The number of divisions in y-axis
514  fFont = 42; // Font index for titles and labels
515 
516  // Axes are linear by default
517  fLogX = 0; // 1: Logarithmic x-axis, 0: linear x-axis
518  fLogY = 0; // 1: Logarithmic y-axis, 0: linear y-axis
519  fLogZ = 0; // 1: Logarithmic z-axis, 0: linear z-axis
520 
521  // Set default values for canves displacement information
522  fCanvasDisplacementX = 100; // Displacement of the canvas for one index in x-direction
523  fCanvasDisplacementY = 100; // Displacement of the canvas for one index in y-direction
524  fCanvasesInOneRow = 10; // Number of canvases in a row before a new row is started
525 
526  // Set defauls values for pad properties
527  fGridX = 0; // 1: Grid in x-axis, 0: no grid
528  fGridY = 0; // 1: Grid in y-axis, 0: no grid
529  fTickX = 1; // 1: Ticks in x-axis, 0: no ticks
530  fTickY = 1; // 1: Ticks in y-axis, 0: no ticks
531 
532  // Default setting values for splitted canvas
533  fSplitRatio = 0.4; // The percentage of the lower pad from the total canvas when splitting the canvas
534 
535  // Set the canvas handles to null
536  fCanvas = nullptr;
537  fSinglePad = nullptr;
538  fUpperSplitPad = nullptr;
539  fLowerSplitPad = nullptr;
540  fLeftRowPad = nullptr;
541  fMiddleRowPad = nullptr;
542  fRightRowPad = nullptr;
543  }
544 
545  /*
546  * Create a canvas and one pad to it
547  */
548  void CreateCanvas() {
549  // Create a canvas and set up its appearance
550  gStyle->SetOptStat(0); // remove statistics box
551  TString cname = GenerateNameForCanvas();
552  fCanvas = new TCanvas(cname.Data(), cname.Data(), fTopLeftX, fTopLeftY, fCanvasWidth, fCanvasHeight);
553  fSinglePad = new TPad("pad", "pad", 0.01, 0.01, 0.99, 0.99, 0, 0, 0);
554  fSinglePad->SetLeftMargin(fMarginLeft);
555  fSinglePad->SetBottomMargin(fMarginBottom);
556  fSinglePad->SetTopMargin(fMarginTop);
557  fSinglePad->SetRightMargin(fMarginRight);
559  fSinglePad->Draw();
560  fSinglePad->cd();
561  }
562 
563  /*
564  * Create a canvas with a grid of desired size and titles
565  *
566  * double xlow = lowest x-axis value drawn
567  * double xhigh = highest x-axis value drawn
568  * double ylow = lowest y-axis value drawn
569  * double yhigh = highest y-axis value drawn
570  * char *xTitle = title for the x-axis
571  * char *yTitle = title for the y-axis
572  * char *title = title of the histogram
573  */
574  void CreateCanvas(double xlow,
575  double xhigh,
576  double ylow,
577  double yhigh,
578  const char *xTitle = "",
579  const char *yTitle = "",
580  const char *title = "") {
581  // First make a canvas
582  CreateCanvas();
583 
584  // Create a dummy 2D-histogram to set the drawing ranges and titles
585  TString dummyName = GenerateName("histo");
586  TH2F *dummyHisto = new TH2F(dummyName.Data(), title, 10, xlow, xhigh, 10, ylow, yhigh);
587  SetHistogramStyle(dummyHisto, xTitle, yTitle);
588  dummyHisto->Draw();
589  }
590 
591  /*
592  * Create a canvas that is split to two pads that are on top of each other
593  */
595  TString dummyName; // dummy name generator
596  dummyName = GenerateNameForCanvas();
597 
598  // Create the canvas
599  fCanvas = new TCanvas(dummyName.Data(), dummyName.Data(), fTopLeftX, fTopLeftY, fCanvasWidth, fCanvasHeight);
600  fCanvas->SetFillStyle(4000); // The created canvas is completely transparent
601  fCanvas->SetFillColor(10); // Canvas is filled with white color
602  gStyle->SetOptStat(0); // Disable the drawing of the statistics box to the canvas
603  gStyle->SetOptTitle(0); // Disable the drawing of titles to the canvas
604  fCanvas->SetMargin(0, 0, 0, 0); // Remove the margins from the bottom canvas
605  fCanvas->Draw(); // Draw the canvas to the screen
606 
607  // ---- Create the two pads to the canvas ----
608 
609  // The upper pad stretches from the top of the canvas to the defined split ratio
610  dummyName = GenerateName("UpperPad");
611  fUpperSplitPad = new TPad(dummyName.Data(), dummyName.Data(), 0, fSplitRatio, 1, 1, 0);
612  fUpperSplitPad->SetTopMargin(fMarginTop / (1 - fSplitRatio)); // Adjust top margin according to the split ratio
613  fUpperSplitPad->SetBottomMargin(
614  0.0015); // Make the bottom margin small so that the pads fit nicely on top of each other
615  fUpperSplitPad->SetLeftMargin(fMarginLeft);
616  fUpperSplitPad->SetRightMargin(fMarginRight);
617  fUpperSplitPad->Draw();
618 
619  // The lower pad stretches from the defined split ratio to the bottom of the canvas
620  dummyName = GenerateName("LowerPad");
621  fLowerSplitPad = new TPad(dummyName.Data(), dummyName.Data(), 0, 0, 1, fSplitRatio, 0);
622  fLowerSplitPad->SetTopMargin(0.0015); // Make the top margin small so that the pads fit nicely on top of each other
623  fLowerSplitPad->SetBottomMargin(fMarginBottom / fSplitRatio); // Adjust bottom margin according to the split ratio
624  fLowerSplitPad->SetLeftMargin(fMarginLeft);
625  fLowerSplitPad->SetRightMargin(fMarginRight);
626  fLowerSplitPad->Draw();
627  }
628 
629  /*
630  * Create a canvas where three graphs can be drawn in one row (to show all xlong bins in one figure for example)
631  */
633  TString dummyName; // dummy name generator
634  dummyName = GenerateNameForCanvas();
635 
636  // Create the canvas
637  fCanvas = new TCanvas(dummyName.Data(), dummyName.Data(), fTopLeftX, fTopLeftY, fCanvasWidth, fCanvasHeight);
638  fCanvas->SetFillStyle(4000); // The created canvas is completely transparent
639  fCanvas->SetFillColor(10); // Canvas is filled with white color
640  gStyle->SetOptStat(0); // Disable the drawing of the statistics box to the canvas
641  gStyle->SetOptTitle(0); // Disable the drawing of titles to the canvas
642  fCanvas->SetMargin(0, 0, 0, 0); // Remove the margins from the bottom canvas
643  fCanvas->Draw(); // Draw the canvas to the screen
644 
645  // ---- Create the two pads to the canvas ----
646 
647  // First, find the correct relation between different pads based on the required margins
648  double smallMargin = 0.0006;
649  double evenSmallerMargin = 0.0002;
650  double relativePlotSizeLeftPad = 1 - (fMarginLeft + evenSmallerMargin);
651  double relativePlotSizeMiddlePad = 1 - (2 * smallMargin);
652  double relativePlotSizeRightPad = 1 - (fMarginRight + smallMargin);
653  double firstSeparator = 1 / (1 + relativePlotSizeLeftPad / relativePlotSizeMiddlePad +
654  relativePlotSizeLeftPad / relativePlotSizeRightPad);
655  double secondSeparator = firstSeparator + (relativePlotSizeLeftPad / relativePlotSizeMiddlePad) * firstSeparator;
656 
657  // The first pad stretches from the left corner 1/3 of the total horizontal space, taking into account marginals
658  dummyName = GenerateName("LeftPad");
659  fLeftRowPad = new TPad(dummyName.Data(), dummyName.Data(), 0, 0, firstSeparator, 1, 0);
660  fLeftRowPad->SetTopMargin(fMarginTop);
661  fLeftRowPad->SetBottomMargin(fMarginBottom);
662  fLeftRowPad->SetLeftMargin(fMarginLeft);
663  fLeftRowPad->SetRightMargin(
664  evenSmallerMargin); // Make the right margin small so that the pads fit nicely on top of each other
666  fLeftRowPad->Draw();
667 
668  // The second pad stretches from 1/3 of the total horizontal space to 2/3, taking into account marginals
669  dummyName = GenerateName("MiddlePad");
670  fMiddleRowPad = new TPad(dummyName.Data(), dummyName.Data(), firstSeparator, 0, secondSeparator, 1, 0);
671  fMiddleRowPad->SetTopMargin(fMarginTop);
672  fMiddleRowPad->SetBottomMargin(fMarginBottom);
673  fMiddleRowPad->SetLeftMargin(
674  smallMargin); // Make the left margin small so that the pads fit nicely on top of each other
675  fMiddleRowPad->SetRightMargin(
676  smallMargin); // Make the right margin small so that the pads fit nicely on top of each other
678  fMiddleRowPad->Draw();
679 
680  // The third pad stretches from 2/3 of the total horizontal space right corner, taking into account marginals
681  dummyName = GenerateName("RightPad");
682  fRightRowPad = new TPad(dummyName.Data(), dummyName.Data(), secondSeparator, 0, 1, 1, 0);
683  fRightRowPad->SetTopMargin(fMarginTop);
684  fRightRowPad->SetBottomMargin(fMarginBottom);
685  fRightRowPad->SetLeftMargin(
686  smallMargin); // Make the left margin small so that the pads fit nicely on top of each other
687  fRightRowPad->SetRightMargin(fMarginRight);
689  fRightRowPad->Draw();
690  }
691 
692  /*
693  * Create a canvas with a grid of desired size and titles
694  *
695  * double xlow = lowest x-axis value drawn
696  * double xhigh = highest x-axis value drawn
697  * double ylow = lowest y-axis value drawn
698  * double yhigh = highest y-axis value drawn
699  * char *xTitle = title for the x-axis
700  * char *yTitle = title for the y-axis
701  * char *title = title of the histogram
702  */
703  void CreateCanvasGraphRow(double xlow,
704  double xhigh,
705  double ylow,
706  double yhigh,
707  const char *xTitle = "",
708  const char *yTitle = "",
709  const char *title = "") {
710  // First make a canvas
712 
713  // Create a dummy 2D-histogram to set the drawing ranges and titles
714  SelectPad(0);
715  TString dummyName = GenerateName("histo");
716  TH2F *dummyHisto = new TH2F(dummyName.Data(), "", 10, xlow, xhigh, 10, ylow, yhigh);
717  SetHistogramStyle(dummyHisto, xTitle, yTitle);
718  dummyHisto->Draw();
719 
720  // Create a dummy 2D-histogram to set the drawing ranges and titles
721  SelectPad(1);
722  dummyName = GenerateName("histo");
723  dummyHisto = new TH2F(dummyName.Data(), title, 10, xlow, xhigh, 10, ylow, yhigh);
724  SetHistogramStyle(dummyHisto, xTitle, "");
725  dummyHisto->Draw();
726 
727  // Create a dummy 2D-histogram to set the drawing ranges and titles
728  SelectPad(2);
729  dummyName = GenerateName("histo");
730  dummyHisto = new TH2F(dummyName.Data(), "", 10, xlow, xhigh, 10, ylow, yhigh);
731  SetHistogramStyle(dummyHisto, xTitle, "");
732  dummyHisto->Draw();
733  }
734 
735  /*
736  * Create split canvas with default settings defining the canvas displacement info
737  *
738  * int canvasIndex = index number for the canvas, this is used to calculate the canvas displacement
739  * int canvasesInRow = number of canvases in a row before the next row is started
740  */
741  void CreateSplitCanvas(int canvasIndex, int canvasesInRow) {
743  SetNumberOfCanvasesInOneRow(canvasesInRow);
744  SetCanvasDisplacement(canvasIndex);
746  }
747 
748  // Setter for left margin
750 
751  // Setter for right margin
753 
754  // Setter for bottom margin
756 
757  // Setter for top margin
758  void SetTopMargin(double margin) { fMarginTop = margin; }
759 
760  /*
761  * Set all the margins for canvas
762  *
763  * double left = new left margin
764  * double right = new right margin
765  * double top = new top margin
766  * doulbe bottom = new bottom margin
767  */
768  void SetMargins(double left, double right, double top, double bottom) {
769  fMarginLeft = left;
770  fMarginRight = right;
771  fMarginTop = top;
772  fMarginBottom = bottom;
773  }
774 
775  // Setter for x-axis title offset
777 
778  // Setter for y-axis title offset
780 
781  // Setter for x-axis title size
782  void SetTitleSizeX(double size) { fTitleSizeX = size; }
783 
784  // Setter for y-axis title size
785  void SetTitleSizeY(double size) { fTitleSizeY = size; }
786 
787  // Setter for x-axis label offset
789 
790  // Setter for y-axis label offset
792 
793  // Setter for x-axis label size
794  void SetLabelSizeX(double size) { fLabelSizeX = size; }
795 
796  // Setter for y-axis label size
797  void SetLabelSizeY(double size) { fLabelSizeY = size; }
798 
799  // Setter for number of divisions in x-axis
800  void SetNDivisionsX(int div) { fDivisionsX = div; }
801 
802  // Setter for number of divisions in y-axis
803  void SetNDivisionsY(int div) { fDivisionsY = div; }
804 
805  // Setter for the font
806  void SetFont(int fontIndex) { fFont = fontIndex; }
807 
808  /*
809  * Apply the settings that are given to JDrawer to a given histogram
810  *
811  * TH1 *histo = Histogram that is styled
812  * TString xTitle = title for the x axis
813  * TString yTitle = title for the y axis
814  */
815  void ApplyStyleSettings(TH1 *histo, TString xTitle = "", TString yTitle = "") {
816  SetHistogramStyle(histo, xTitle, yTitle);
817  }
818 
819  /*
820  * Set all the appearance factors for the histogram
821  *
822  * double titoffx = Offset of the x-axis title
823  * double titoffy = Offset of the y-axis title
824  * double titsizex = Size of the x-axis title
825  * double titsizey = Size of the y-axis title
826  * double labeloffx = Offset of the x-axis label
827  * double labeloffy = Offset of the y-axis label
828  * double labelsizex = Size of the x-axis label
829  * double labelsizey = Size of the y-axis label
830  * int divx = The number of divisions in x-axis
831  * int divy = The number of divisions in y-axis
832  * int fontIndex = Font index for titles and labels
833  */
834  void SetHistogramAppearance(double titoffx,
835  double titoffy,
836  double titsizex,
837  double titsizey,
838  double labeloffx,
839  double labeloffy,
840  double labelsizex,
841  double labelsizey,
842  int divx,
843  int divy,
844  int fontIndex) {
845  fTitleOffsetX = titoffx; // Offset of the x-axis title
846  fTitleOffsetY = titoffy; // Offset of the y-axis title
847  fTitleSizeX = titsizex; // Size of the x-axis title
848  fTitleSizeY = titsizey; // Size of the y-axis title
849  fLabelOffsetX = labeloffx; // Offset of the x-axis label
850  fLabelOffsetY = labeloffy; // Offset of the y-axis label
851  fLabelSizeX = labelsizex; // Size of the x-axis label
852  fLabelSizeY = labelsizey; // Size of the y-axis label
853  fDivisionsX = divx; // The number of divisions in x-axis
854  fDivisionsY = divy; // The number of divisions in y-axis
855  fFont = fontIndex; // Font index for titles and labels
856  }
857 
858  /*
859  * Setter for the scale of the x-axis
860  *
861  * bool log = true, if logarithmic axis, false if linear axis
862  */
863  void SetLogX(bool log = true) {
864  if (log) {
865  fLogX = 1;
866  } else {
867  fLogX = 0;
868  }
869  }
870 
871  /*
872  * Setter for the scale of the y-axis
873  *
874  * bool log = true, if logarithmic axis, false if linear axis
875  */
876  void SetLogY(bool log = true) {
877  if (log) {
878  fLogY = 1;
879  } else {
880  fLogY = 0;
881  }
882  }
883 
884  /*
885  * Setter for the scale of the z-axis
886  *
887  * bool log = true, if logarithmic axis, false if linear axis
888  */
889  void SetLogZ(bool log = true) {
890  if (log) {
891  fLogZ = 1;
892  } else {
893  fLogZ = 0;
894  }
895  }
896 
897  // Getter for the displacement of the drawn canvas in x-direction
899 
900  // Getter for the displacement of the drawn canvas in y-direction
902 
903  // Setter for the displacement of the drawn canvas in x-direction
904  void SetCanvasDisplacementX(int displacement) { fTopLeftX = displacement; }
905 
906  // Setter for the displacement of the drawn canvas in y-direction
907  void SetCanvasDisplacementY(int displacement) { fTopLeftY = displacement; }
908 
909  /*
910  * Setter for the displacement of the canvas from the top left corner
911  *
912  * int x = displacement in x-direction
913  * int y = displacement in y-direction
914  */
915  void SetCanvasDisplacement(int x, int y) {
918  }
919 
920  /*
921  * Setter for displacement using an index
922  *
923  * int index = index number for the canvas
924  *
925  * The position of the canvas is decided in the following way:
926  * The displacement of two consecutive canvases in the x-direction is fCanvasDisplacementX.
927  * The canvases are put it one row, until there is fCanvasesInOneRow canvases in that row.
928  * After this, the next canvas is put in the next row fCanvasDisplacementY under the first
929  * canvas in the preceeding row. Then the next row is filled as the previous.
930  */
934  }
935 
936  /*
937  * Setter for canvas displacement settings
938  *
939  * int displacementX = Displacement of the canvas for one index in x-direction
940  * int displacementY = Displacement of the canvas for one index in y-direction
941  * int canvasesInRow = Number of canvases in a row before a new row is started
942  */
943  void SetCanvasDisplacementSettings(int displacementX, int displacementY, int canvasesInRow) {
944  fCanvasDisplacementX = displacementX;
945  fCanvasDisplacementY = displacementY;
946  fCanvasesInOneRow = canvasesInRow;
947  }
948 
949  /*
950  * Setter for number of canvases in one row
951  *
952  * int canvasesInRow = Number of canvases in a row before a new row is started
953  */
954  void SetNumberOfCanvasesInOneRow(int canvasesInRow) { fCanvasesInOneRow = canvasesInRow; }
955 
956  /*
957  * Setter for the size of the drawn canvas
958  *
959  * int width = width of the canvas
960  * int height = height of the canvas
961  */
962  void SetCanvasSize(int width, int height) {
964  fCanvasHeight = height;
965  }
966 
967  /*
968  * Setter for grid in x-axis
969  */
970  void SetGridX(bool grid = true) {
971  if (grid) {
972  fGridX = 1;
973  } else {
974  fGridX = 0;
975  }
976  }
977 
978  /*
979  * Setter for grid in y-axis
980  */
981  void SetGridY(bool grid = true) {
982  if (grid) {
983  fGridY = 1;
984  } else {
985  fGridY = 0;
986  }
987  }
988 
989  /*
990  * Setter for grids in both axes
991  */
992  void SetGrid(int gridX, int gridY) {
993  SetGridX(gridX);
994  SetGridY(gridY);
995  }
996 
997  /*
998  * Setter for grid in x-axis
999  */
1000  void SetTickX(bool tick = true) {
1001  if (tick) {
1002  fTickX = 1;
1003  } else {
1004  fTickX = 0;
1005  }
1006  }
1007 
1008  /*
1009  * Setter for grid in y-axis
1010  */
1011  void SetTickY(bool tick = true) {
1012  if (tick) {
1013  fTickY = 1;
1014  } else {
1015  fTickY = 0;
1016  }
1017  }
1018 
1019  /*
1020  * Setter for grids in both axes
1021  */
1022  void SetTick(int tickX, int tickY) {
1023  SetTickX(tickX);
1024  SetTickY(tickY);
1025  }
1026 
1027  /*
1028  * Setter for split ratio
1029  */
1030  void SetSplitRatio(double split) { fSplitRatio = split; }
1031 
1032  /*
1033  * Set the appearance values for splitted canvas as their default values
1034  * Different values than for single canvas are needed, so there is a different setter too
1035  *
1036  * Note: SetHistogramAppearance(titoffx, titoffy, titsizex, titsizey, labeloffx, labeloffy, labelsizex, labelsizey, divx, divy, fontIndex)
1037  */
1039  Reset();
1040  //SetHistogramAppearance(2.5, 2.5, 20, 20, 0.01, 0.001, 16, 16, 505, 505, 43); // Smaller label size for axes
1041  SetHistogramAppearance(2.5, 2.3, 25, 25, 0.01, 0.001, 20, 20, 505, 505, 43); // Increased label size for axes
1042  SetSplitRatio(0.4);
1043  SetRelativeCanvasSize(1.1, 0.7);
1044  SetMargins(0.21, 0.05, 0.09, 0.1); // Left, right, top, bottom
1045  }
1046 
1047  /*
1048  * Set the appearance values for graph to default values
1049  */
1051  Reset();
1052  SetHistogramAppearance(0.9, 1.3, 0.06, 0.05, 0.01, 0.001, 0.05, 0.05, 505, 505, 42);
1053  SetRelativeCanvasSize(0.8, 1);
1054  SetLeftMargin(0.17);
1055  }
1056 
1057  /*
1058  * Set the appearance values for row of graphs
1059  */
1061  Reset();
1062  SetHistogramAppearance(0.9, 1.3, 0.06, 0.05, 0.01, 0.001, 0.05, 0.05, 505, 505, 42);
1063  SetRelativeCanvasSize(0.8, 3);
1064  SetLeftMargin(0.17);
1065  }
1066 
1067  /*
1068  * Getter for pad according to the ID number
1069  */
1070  TPad *GetPad(int padNumber) {
1071  switch (padNumber) {
1072  case 0:
1073  return fLeftRowPad;
1074 
1075  case 1:
1076  return fMiddleRowPad;
1077 
1078  case 2:
1079  return fRightRowPad;
1080 
1081  case 3:
1082  return fUpperSplitPad;
1083 
1084  case 4:
1085  return fLowerSplitPad;
1086 
1087  default:
1088  return nullptr;
1089  }
1090  }
1091 
1092  /*
1093  * Getter for pad according to the ID number
1094  */
1095  void SelectPad(int padNumber) {
1096  switch (padNumber) {
1097  case 0:
1098  fLeftRowPad->cd();
1099  break;
1100 
1101  case 1:
1102  fMiddleRowPad->cd();
1103  break;
1104 
1105  case 2:
1106  fRightRowPad->cd();
1107  break;
1108 
1109  case 3:
1110  fUpperSplitPad->cd();
1111  break;
1112 
1113  case 4:
1114  fLowerSplitPad->cd();
1115  break;
1116 
1117  default:
1118  std::cout << "Pad " << padNumber << " not found" << std::endl;
1119  break;
1120  }
1121  }
1122 
1123  /*
1124  * Getter for the upper pad
1125  */
1126  TPad *GetUpperPad() { return fUpperSplitPad; }
1127 
1128  /*
1129  * Getter for the lower pad
1130  */
1131  TPad *GetLowerPad() { return fLowerSplitPad; }
1132 
1133  /*
1134  * Select the upper pad
1135  */
1136  void SelectUpperPad() { fUpperSplitPad->cd(); }
1137 
1138  /*
1139  * Select the upper pad
1140  */
1141  void SelectLowerPad() { fLowerSplitPad->cd(); }
1142 
1143  /*
1144  * Set the canvas size using scaling factor and aspect ratio
1145  *
1146  * double relativeSize = multiplication factor for the default canvas height of 600 pixels
1147  * double aspectRatio = the ratio canvas width / canvas height
1148  */
1149  void SetRelativeCanvasSize(double relativeSize, double aspectRatio) {
1150  fCanvasHeight = 600 * relativeSize;
1151  fCanvasWidth = aspectRatio * fCanvasHeight;
1152  }
1153 
1154  /*
1155  * Get the name of the considered canvas
1156  */
1157  TString GetCanvasName() {
1158  if (fCanvas == nullptr) {
1159  std::cout << "Error: No canvas defined! Cannot return name." << std::endl;
1160  return "";
1161  }
1162  TString name = Form("%s", fCanvas->GetName());
1163  return name;
1164  }
1165 
1166  /*
1167  * Set the drawing range for a pad to draw geometric objects to it
1168  *
1169  * double xLow = minimum x-axis range
1170  * double yLow = minimum y-axis range
1171  * double xHigh = maximum x-axis range
1172  * double yHigh = maximum y-axis range
1173  */
1174  void SetPadRange(double xLow, double yLow, double xHigh, double yHigh) {
1175  // TODO: Setting range also for split canvas
1176  fSinglePad->Range(xLow, yLow, xHigh, yHigh);
1177  fSinglePad->Clear();
1178  }
1179 };
1180 
1181 #endif
void SetSplitRatio(double split)
Definition: JDrawer.h:1030
size
Write out results.
int fTickX
Definition: JDrawer.h:60
void CreateSplitCanvas(int canvasIndex, int canvasesInRow)
Definition: JDrawer.h:741
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:970
void DrawHistogramToLowerPad(TH1 *histo, const char *xTitle="", const char *yTitle="", const char *title="", const char *drawOption="")
Definition: JDrawer.h:367
void DrawFunction(TF1 *myFun, const char *xTitle, const char *yTitle, const char *title="", const char *drawOption="")
Definition: JDrawer.h:457
TPad * fUpperSplitPad
Definition: JDrawer.h:71
void SetCanvasSize(int width, int height)
Definition: JDrawer.h:962
void SetRelativeCanvasSize(double relativeSize, double aspectRatio)
Definition: JDrawer.h:1149
TPad * fLeftRowPad
Definition: JDrawer.h:73
void SetLabelOffsetX(double offset)
Definition: JDrawer.h:788
void DrawHistogramToUpperPad(TH1 *histo, const char *xTitle="", const char *yTitle="", const char *title="", const char *drawOption="")
Definition: JDrawer.h:344
int fCanvasHeight
Definition: JDrawer.h:35
void SetCanvasDisplacement(int x, int y)
Definition: JDrawer.h:915
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:394
void SetLeftMargin(double margin)
Definition: JDrawer.h:749
void SetNumberOfCanvasesInOneRow(int canvasesInRow)
Definition: JDrawer.h:954
int GetCanvasDisplacementX()
Definition: JDrawer.h:898
void SetCanvasDisplacementSettings(int displacementX, int displacementY, int canvasesInRow)
Definition: JDrawer.h:943
void SetDefaultAppearanceSplitCanvas()
Definition: JDrawer.h:1038
int fGridY
Definition: JDrawer.h:59
void SetLabelSizeY(double size)
Definition: JDrawer.h:797
int fTickY
Definition: JDrawer.h:61
void SetTick(int tickX, int tickY)
Definition: JDrawer.h:1022
void SelectLowerPad()
Definition: JDrawer.h:1141
void SelectPad(int padNumber)
Definition: JDrawer.h:1095
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:548
void SetAxisStyles(TAxis *xAxis, TAxis *yAxis, TAxis *zAxis, TString xtit, TString ytit)
Definition: JDrawer.h:94
void SetCanvasDisplacementX(int displacement)
Definition: JDrawer.h:904
void CreateSplitCanvas()
Definition: JDrawer.h:594
void Reset()
Definition: JDrawer.h:486
TPad * GetPad(int padNumber)
Definition: JDrawer.h:1070
void SetNDivisionsY(int div)
Definition: JDrawer.h:803
int fNameIndex
Definition: JDrawer.h:81
void SetPadRange(double xLow, double yLow, double xHigh, double yHigh)
Definition: JDrawer.h:1174
void SetCanvasDisplacementY(int displacement)
Definition: JDrawer.h:907
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:992
void SetTickY(bool tick=true)
Definition: JDrawer.h:1011
int fFont
Definition: JDrawer.h:52
void SetLabelSizeX(double size)
Definition: JDrawer.h:794
void SetLogX(bool log=true)
Definition: JDrawer.h:863
~JDrawer()
Definition: JDrawer.h:219
int GetCanvasDisplacementY()
Definition: JDrawer.h:901
void ApplyStyleSettings(TH1 *histo, TString xTitle="", TString yTitle="")
Definition: JDrawer.h:815
void SetTitleOffsetY(double offset)
Definition: JDrawer.h:779
double fLabelOffsetY
Definition: JDrawer.h:45
void SetTitleSizeX(double size)
Definition: JDrawer.h:782
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:421
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:758
void SetTitleSizeY(double size)
Definition: JDrawer.h:785
void SetBottomMargin(double margin)
Definition: JDrawer.h:755
Double_t margin
void SetTickX(bool tick=true)
Definition: JDrawer.h:1000
double fTitleSizeZ
Definition: JDrawer.h:43
TCanvas * fCanvas
Definition: JDrawer.h:69
double fLabelOffsetZ
Definition: JDrawer.h:46
TPad * GetUpperPad()
Definition: JDrawer.h:1126
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:834
void CreateCanvasGraphRow()
Definition: JDrawer.h:632
double fLabelSizeX
Definition: JDrawer.h:47
double fLabelSizeZ
Definition: JDrawer.h:49
void SetRightMargin(double margin)
Definition: JDrawer.h:752
void DrawHistogramToCurrentCanvas(TH1 *histo, const char *xTitle, const char *yTitle, const char *title="", const char *drawOption="")
Definition: JDrawer.h:245
void SetFunctionStyle(TF1 *hid, TString xtit, TString ytit)
Definition: JDrawer.h:154
void DrawHistogram(TH1 *histo, const char *drawOption="")
Definition: JDrawer.h:295
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:574
double fLabelSizeY
Definition: JDrawer.h:48
void SelectUpperPad()
Definition: JDrawer.h:1136
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:1050
TPad * GetLowerPad()
Definition: JDrawer.h:1131
void SetLogY(bool log=true)
Definition: JDrawer.h:876
double fLabelOffsetX
Definition: JDrawer.h:44
TPad * fRightRowPad
Definition: JDrawer.h:75
void SetNDivisionsX(int div)
Definition: JDrawer.h:800
void SetMargins(double left, double right, double top, double bottom)
Definition: JDrawer.h:768
void SetCanvasDisplacement(int index)
Definition: JDrawer.h:931
double fSplitRatio
Definition: JDrawer.h:78
int fTopLeftY
Definition: JDrawer.h:33
void SetLabelOffsetY(double offset)
Definition: JDrawer.h:791
void DrawHistogramToPad(TH1 *histo, TPad *drawPad, const char *xTitle="", const char *yTitle="", const char *title="", const char *drawOption="")
Definition: JDrawer.h:306
TPad * fSinglePad
Definition: JDrawer.h:70
int fCanvasWidth
Definition: JDrawer.h:34
void SetTitleOffsetX(double offset)
Definition: JDrawer.h:776
void SetDefaultAppearanceGraphRow()
Definition: JDrawer.h:1060
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:271
TString GetCanvasName()
Definition: JDrawer.h:1157
void SetLogZ(bool log=true)
Definition: JDrawer.h:889
void CreateCanvasGraphRow(double xlow, double xhigh, double ylow, double yhigh, const char *xTitle="", const char *yTitle="", const char *title="")
Definition: JDrawer.h:703
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:806
int fGridX
Definition: JDrawer.h:58
void DrawFunction(TF1 *myFun, const char *drawOption="")
Definition: JDrawer.h:481
void SetGridY(bool grid=true)
Definition: JDrawer.h:981
TPad * fLowerSplitPad
Definition: JDrawer.h:72