NAGASH 0.9.8
Next Generation Analysis System
Loading...
Searching...
No Matches
FigureTool.h
Go to the documentation of this file.
1//***************************************************************************************
4//***************************************************************************************
5
6#pragma once
7
8#include "NAGASH/Global.h"
9#include "NAGASH/Tool.h"
10
11namespace NAGASH
12{
14 {
15 public:
16 int LB_X = 0;
17 int LB_Y = 0;
18 int RT_X = 0;
19 int RT_Y = 0;
20 };
21
22 class FigureTool;
23 class FigureCanvas;
24 class FigurePad;
25 class FigureHist1D;
26 class FigureHist2D;
27 class FigureHStack;
28 class FigureFunc1D;
29 class FigureGraph1D;
30 class FigureLatex;
31
35 {
36 public:
37 FigureStyleHelper(std::shared_ptr<MSGTool> MSG);
38 virtual void SetPadStyle(FigurePad *pad);
39 virtual void SetHist1DStyle(FigureHist1D *hist);
40 virtual void SetHist1DGraphStyle(FigureHist1D *hist);
41 virtual void SetGraph1DStyle(FigureGraph1D *graph);
42 virtual void SetFunc1DStyle(FigureFunc1D *func);
43 virtual void SetHist2DStyle(FigureHist2D *hist);
44 virtual void SetLatexStyle(FigureLatex *latex);
45 virtual ~FigureStyleHelper();
46 std::shared_ptr<MSGTool> MSGUser();
47
48 double TITLE_MARGIN_PERCENT = 0.15;
49 double COLZ_MARGIN_PERCENT = 0.05;
52
53 double TICK_LENGTH_PERCENT = 0.03;
54 double TEXT_SIZE_PERCENT = 0.035;
55 double LEGEND_TEXT_SIZE_PERCENT = 0.055;
56
57 int TEXT_FONT = 4;
58
59 int DIVISION_N1 = 20;
60 int DIVISION_N2 = 5;
61 int DIVISION_N3 = 0;
62
64
65 double LeftPercentage = 0.07;
66
67 private:
68 std::shared_ptr<MSGTool> msg;
69
71 };
72
73 inline std::shared_ptr<MSGTool> FigureStyleHelper::MSGUser() { return msg; }
74
75 // base class for different figure elements
77 {
78 public:
79 FigureElement(std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper, const TString &elementname, const TString &tyname, FigureElement *mother = 0);
80 void Draw();
81 virtual void CD();
82 virtual void DrawElement();
83 virtual void SetStyle();
84 // find the element from the root element
85 std::shared_ptr<FigureElement> TraceElement(const TString &name);
86 // find the element from this node
87 std::shared_ptr<FigureElement> FindLinkElement(const TString &name);
88 // get the ith element in this link only
89 std::shared_ptr<FigureElement> GetLinkElement(int index);
91 bool IsType(const TString &tyname);
92 TString GetName();
93 TString GetTypeName();
94 int GetLinkIndex(const TString &name);
96 int GetNLinkElement();
97
99
100 protected:
101 bool CheckDuplicate(const TString &name);
102 std::shared_ptr<MSGTool> MSGUser();
103 std::shared_ptr<FigureStyleHelper> StyleUser();
104
105 bool Contain(std::shared_ptr<FigureElement> subelement);
107
108 std::vector<FigureSquareRange> Range_vec;
109
110 std::deque<std::shared_ptr<FigureElement>> LinkedElement;
111 std::map<TString, uint64_t> MapLinkedElement;
113
114 private:
115 std::shared_ptr<MSGTool> msg;
116 std::shared_ptr<FigureStyleHelper> stylehelper;
117 TString name;
118 TString castname = "FigureElement";
119 };
120
121 inline std::shared_ptr<MSGTool> FigureElement::MSGUser() { return msg; }
122 inline std::shared_ptr<FigureStyleHelper> FigureElement::StyleUser() { return stylehelper; }
123 inline TString FigureElement::GetName() { return name; }
124 inline TString FigureElement::GetTypeName() { return castname; }
125 inline bool FigureElement::IsType(const TString &tyname) { return castname.TString::EqualTo(tyname); }
127 inline int FigureElement::GetNLinkElement() { return LinkedElement.size(); }
128
132 {
133 friend class FigureHStack;
134 friend class FigurePad;
135 friend class FigureCanvas;
136 friend class FigureStyleHelper;
137
138 public:
139 virtual ~FigureHist1D();
140 void Scale(double);
141 void Rebin(int);
142
143 private:
145 std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper, const TString &elementname, TH1D *hist, const TString &option, FigureElement *mother, std::function<void(TH1D *)> optionfunc = [](TH1D *) {});
147 std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper, const TString &elementname, const TString &linkinfo, const TString &option, FigureElement *mother, std::function<void(TH1D *)> optionfunc = [](TH1D *) {});
148 FigureHist1D(
149 std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper, const TString &elementname, TH1D *hist, const TString &option, FigureElement *mother, std::function<void(TGraph *)> optionfunc);
150 FigureHist1D(
151 std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper, const TString &elementname, const TString &linkinfo, const TString &option, FigureElement *mother, std::function<void(TGraph *)> optionfunc);
152
153 std::pair<double, double> GetMinAndMax(double, double);
154 TH1D *GetHist();
156 virtual void DrawElement() override;
157 virtual void SetStyle() override;
158
159 TH1D *myhist = nullptr;
160 TGraphErrors *mygraph = nullptr;
161 TString DrawOption;
162 std::function<void(TH1D *)> OptionFunc;
163 std::function<void(TGraph *)> TGraphOptionFunc;
164 bool DrawAsTGraph = false;
165 bool FromHistLink = false;
166 bool ForHStack = false;
167 TString LinkInfo;
168
170
171 TString GetLinkMode();
172 std::vector<TString> GetLinkObject();
173 };
174
175 inline TH1D *FigureHist1D::GetHist() { return myhist; }
176
180 {
181 friend class FigurePad;
182 friend class FigureCanvas;
183 friend class FigureStyleHelper;
184
185 public:
186 virtual void DrawElement() override;
187 virtual void SetStyle() override;
188 virtual ~FigureHStack();
189
190 void Scale(double);
191 void Rebin(int);
192 void DrawTotalHist(
193 const TString &option, std::function<void(TH1D *)> optionfunc = [](TH1D *) {});
194
195 TH1D *GetTotalHist();
196
197 private:
198 FigureHStack(std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper, const TString &elementname, const std::vector<TString> &linkhists, const TString &option, FigureElement *mother);
199 THStack *GetHist();
200 std::pair<double, double> GetMinAndMax(double, double);
201 void CalculateTotalHist();
202
203 THStack *myhstack = nullptr;
204 TString DrawOption;
205 std::vector<TString> LinkedHists;
206
207 // for adjusting the axis
208 TH1D *empty_hist = nullptr;
209 TH1D *total_hist = nullptr;
210 TGraphErrors *total_hist_graph = nullptr;
211
212 bool draw_total_hist = false;
214 std::function<void(TH1D *)> total_hist_optionfunc;
215 };
216
217 inline THStack *FigureHStack::GetHist() { return myhstack; }
218
222 {
223 friend class FigurePad;
224 friend class FigureCanvas;
225 friend class FigureStyleHelper;
226
227 public:
229 virtual void DrawElement() override;
230 virtual void SetStyle() override;
231 virtual ~FigureGraph1D();
232
233 private:
235 std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper, const TString &elementname, TGraph *graph, const TString &option, FigureElement *mother, std::function<void(TGraph *)> optionfunc = [](TGraph *) {});
236 TGraph *GetGraph();
237 std::pair<double, double> GetMinAndMax(double, double);
238
239 TGraph *mygraph = nullptr;
240 TString DrawOption;
241 std::function<void(TGraph *)> OptionFunc;
243 };
244
245 inline TGraph *FigureGraph1D::GetGraph() { return mygraph; }
246
250 {
251 friend class FigurePad;
252 friend class FigureCanvas;
253 friend class FigureStyleHelper;
254
255 public:
256 virtual void DrawElement() override;
257 virtual void SetStyle() override;
258 virtual ~FigureFunc1D();
259
260 private:
262 std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper, const TString &elementname, TF1 *func, const TString &option, FigureElement *mother, std::function<void(TF1 *)> optionfunc = [](TF1 *) {});
263 TF1 *GetFunc();
264 std::pair<double, double> GetMinAndMax(double, double);
265
266 TF1 *myfunc = nullptr;
267 TString DrawOption;
268 std::function<void(TF1 *)> OptionFunc;
270 };
271
272 inline TF1 *FigureFunc1D::GetFunc() { return myfunc; }
273
277 {
278 friend class FigurePad;
279 friend class FigureCanvas;
280 friend class FigureStyleHelper;
281
282 public:
283 virtual void DrawElement() override;
284 virtual void SetStyle() override;
285 virtual ~FigureHist2D();
286
287 private:
289 std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper, const TString &elementname, TH2D *hist, const TString &option, FigureElement *mother, std::function<void(TH2D *)> optionfunc = [](TH2D *) {});
290 TH2D *GetHist();
291 void Rebin(int, int);
292 void Scale(double);
293
294 TH2D *myhist;
295 TString DrawOption;
296 std::function<void(TH2D *)> OptionFunc;
298 };
299
300 inline TH2D *FigureHist2D::GetHist() { return myhist; }
301
305 {
306 friend class FigurePad;
307 friend class FigureCanvas;
308 friend class FigureStyleHelper;
309
310 public:
311 virtual void DrawElement() override;
312 virtual void SetStyle() override;
313 virtual ~FigureLatex();
314
315 private:
317 std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper,
318 const TString &content, double posx, double poxy, Color_t color, FigureElement *mother, std::function<void(TLatex *)> optionfunc = [](TLatex *) {});
319
320 TLatex *mylatex;
321 std::function<void(TLatex *)> OptionFunc;
322 };
323
329 {
330 friend class FigureStyleHelper;
331 friend class FigureCanvas;
332
333 public:
334 virtual void DrawElement() override;
335 virtual void CD() override;
336 virtual void SetStyle() override;
337 virtual ~FigurePad();
338
339 // set input elements
340 std::shared_ptr<FigurePad> BookPad(
341 const TString &padname, int lbx, int lby, int rtx, int rty, std::function<void(TPad *)> optionfunc = [](TPad *) {});
342 std::shared_ptr<FigureHist1D> SetInputHist1D(
343 const TString &elementname, TH1D *hist, const TString &option, std::function<void(TH1D *)> optionfunc = [](TH1D *) {});
344 std::shared_ptr<FigureHist1D> SetInputHist1D(
345 const TString &elementname, const TString &linkinfo, const TString &option, std::function<void(TH1D *)> optionfunc = [](TH1D *) {});
346 std::shared_ptr<FigureHist1D> SetInputHist1DGraph(
347 const TString &elementname, TH1D *hist, const TString &option, std::function<void(TGraph *)> optionfunc = [](TGraph *) {});
348 std::shared_ptr<FigureHist1D> SetInputHist1DGraph(
349 const TString &elementname, const TString &linkinfo, const TString &option, std::function<void(TGraph *)> optionfunc = [](TGraph *) {});
350 std::shared_ptr<FigureGraph1D> SetInputGraph1D(
351 const TString &elementname, TGraph *graph, const TString &option, std::function<void(TGraph *)> optionfunc = [](TGraph *) {});
352 std::shared_ptr<FigureFunc1D> SetInputFunc1D(
353 const TString &elementname, TF1 *func, const TString &option, std::function<void(TF1 *)> optionfunc = [](TF1 *) {});
354 std::shared_ptr<FigureHist2D> SetInputHist2D(
355 const TString &elementname, TH2D *hist, const TString &option, std::function<void(TH2D *)> optionfunc = [](TH2D *) {});
356 void SetLatex(
357 const TString &content, double posx, double poxy, Color_t color = 1, std::function<void(TLatex *)> optionfunc = [](TLatex *) {});
358 void DrawATLASLabel(const TString &content, double posx, double poxy, Color_t color = 1, double space = -1);
359
360 std::shared_ptr<FigureHStack> SetHStack(const TString &elementname, const std::vector<TString> &linkinfo, const TString &option);
361
362 // normalization
363 void Norm(const TString &, const TString &, double xmin = 0, double xmax = 0);
364
365 // set legend
366 void SetLegend(const TString &header = "", const TString &option = "");
367 void SetLegend(const TString &header, const TString &option, double, double, double, double);
368 void SetLegendColumn(int);
369 void SetLegendEntries(const std::vector<TString> &entries, const std::vector<TString> &options);
370
371 // set pad style
372 void SetAxisTitle(const TString &xname = "UNKNOWN", const TString &yname = "UNKNOWN", const TString &zname = "UNKNOWN");
373 void SetAxisTitleOffset(double off_x = 1.4, double off_y = 1.4, double off_z = 1);
374 void SetAxisStyle(std::function<void(TAxis *, TAxis *, TAxis *)>);
375 void SetGridx(bool gridx = true);
376 void SetGridy(bool gridy = true);
377 void SetLogx(int value = 1);
378 void SetLogy(int value = 1);
379 void SetLogz(int value = 1);
380 void SetXaxisRange(double min, double max);
381 void SetYaxisRange(double min, double max);
382 void SetZaxisRange(double min, double max);
383
384 bool NeedLeftMargin();
385 bool NeedRightMargin();
386 bool NeedBottomMargin();
387 TString GetXTitle();
388 TString GetYTitle();
389 TString GetZTitle();
390 double GetXTitleOffset();
391 double GetYTitleOffset();
392 double GetZTitleOffset();
393 int GetNColoredObjects();
394
395 private:
396 FigurePad(
397 std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper, const TString &elementname, int lbx, int lby, int rtx, int rty, FigureElement *mother, std::function<void(TPad *)> optionfunc = [](TPad *) {});
398 TPad *mypad = nullptr;
399 TPad *GetPad();
400
401 std::function<void(TPad *)> OptionFunc;
402 std::function<void(TAxis *, TAxis *, TAxis *)> AxisOptionFunc;
403
404 bool waitforfirstlink = true;
405 bool hashstack = false;
407 TString xtitle = "UNKNOWN";
408 TString ytitle = "UNKNOWN";
409 TString ztitle = "UNKNOWN";
410
411 double xoffset = 4.2;
412 double yoffset = 4.5;
413 double zoffset = 1;
414
416
417 bool user_set_rangex = false;
418 bool user_set_rangey = false;
419 bool user_set_rangez = false;
420
421 double max_xaxis = 0;
422 double min_xaxis = 0;
423 double max_yaxis = 0;
424 double min_yaxis = 0;
425 double max_zaxis = 0;
426 double min_zaxis = 0;
427
428 // legend parameters
429 TLegend *legend = nullptr;
430 bool plot_legend = false;
431 std::vector<TString> legend_entries;
432 std::vector<TString> legend_options;
436 double legend_xmin = 0;
437 double legend_ymin = 0;
438 double legend_xmax = 0;
439 double legend_ymax = 0;
441 };
442
443 inline bool FigurePad::NeedLeftMargin() { return !(ytitle.EqualTo("UNKNOWN")); }
444 inline bool FigurePad::NeedRightMargin() { return !(ztitle.EqualTo("UNKNOWN")); }
445 inline bool FigurePad::NeedBottomMargin() { return !(xtitle.EqualTo("UNKNOWN")); }
446 inline TString FigurePad::GetXTitle() { return xtitle; }
447 inline TString FigurePad::GetYTitle() { return ytitle; }
448 inline TString FigurePad::GetZTitle() { return ztitle; }
449 inline double FigurePad::GetXTitleOffset() { return xoffset; }
450 inline double FigurePad::GetYTitleOffset() { return yoffset; }
451 inline double FigurePad::GetZTitleOffset() { return zoffset; }
452 inline TPad *FigurePad::GetPad() { return mypad; }
454
459 inline void FigurePad::SetAxisTitleOffset(double off_x, double off_y, double off_z)
460 {
462 xoffset = off_x;
463 yoffset = off_y;
464 zoffset = off_z;
465 }
466
471 inline void FigurePad::SetAxisTitle(const TString &xname, const TString &yname, const TString &zname)
472 {
473 xtitle = xname;
474 ytitle = yname;
475 ztitle = zname;
476 }
477
480 inline void FigurePad::SetAxisStyle(std::function<void(TAxis *, TAxis *, TAxis *)> func)
481 {
482 AxisOptionFunc = func;
483 }
484
490 {
491 friend class FigureTool;
492
493 public:
494 virtual void DrawElement() override;
495 virtual void CD() override;
496 void SaveAs(const TString &filename);
497 virtual ~FigureCanvas();
498
499 std::shared_ptr<FigurePad> BookPad(
500 const TString &padname, int lbx, int lby, int rtx, int rty, std::function<void(TPad *)> optionfunc = [](TPad *) {});
501 std::shared_ptr<FigurePad> BookPadNDC(
502 const TString &padname, double lbx, double lby, double rtx, double rty, std::function<void(TPad *)> optionfunc = [](TPad *) {});
503
504 private:
505 FigureCanvas(std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper, const TString &elementname, int npx, int npy);
506 TCanvas *mycanvas = nullptr;
507 };
508
509 inline void FigureCanvas::SaveAs(const TString &filename) { mycanvas->SaveAs(filename.TString::Data()); }
510
511 class FigureTool : public Tool
512 {
513 public:
514 FigureTool(std::shared_ptr<MSGTool> MSG);
515 FigureTool(std::shared_ptr<MSGTool> MSG, std::shared_ptr<FigureStyleHelper> shelper);
516 std::shared_ptr<FigureCanvas> BookFigure(const TString &figurename, int size_x, int size_y);
517 std::shared_ptr<FigureCanvas> BookATLASSquare(const TString &figurename);
518 std::shared_ptr<FigureCanvas> BookATLASRectangular(const TString &figurename);
519 void DrawFigures();
520 void SetFigureDirectory(const TString &dirname);
521 std::shared_ptr<FigureStyleHelper> GetFigureStyleHelper();
522
523 private:
524 // All Figures
525 std::shared_ptr<FigureStyleHelper> stylehelper;
526 std::map<TString, std::shared_ptr<FigureCanvas>> BookedFigure;
527 TString figuredir = ".";
528 };
529
530 inline void FigureTool::SetFigureDirectory(const TString &dirname) { figuredir = dirname; }
531 inline std::shared_ptr<FigureStyleHelper> FigureTool::GetFigureStyleHelper() { return stylehelper; }
532} // namespace NAGASH
Some global definitions.
Figure class for TCanvas. A canvas is the base of your figure where you can define multiple NAGASH::F...
Definition FigureTool.h:490
std::shared_ptr< FigurePad > BookPad(const TString &padname, int lbx, int lby, int rtx, int rty, std::function< void(TPad *)> optionfunc=[](TPad *) {})
Book a FigurePad in this canvas.
std::shared_ptr< FigurePad > BookPadNDC(const TString &padname, double lbx, double lby, double rtx, double rty, std::function< void(TPad *)> optionfunc=[](TPad *) {})
Book a FigurePad in this canvas. The position is given in relative coordinates.
void SaveAs(const TString &filename)
Definition FigureTool.h:509
virtual void CD() override
virtual void DrawElement() override
std::vector< FigureSquareRange > Range_vec
Definition FigureTool.h:108
std::shared_ptr< MSGTool > MSGUser()
Definition FigureTool.h:121
std::shared_ptr< MSGTool > msg
Definition FigureTool.h:115
virtual void SetStyle()
std::deque< std::shared_ptr< FigureElement > > LinkedElement
Definition FigureTool.h:110
std::shared_ptr< FigureElement > GetLinkElement(int index)
std::map< TString, uint64_t > MapLinkedElement
Definition FigureTool.h:111
std::shared_ptr< FigureStyleHelper > StyleUser()
Definition FigureTool.h:122
FigureElement * GetRootElement()
FigureElement * MotherElement
Definition FigureTool.h:112
FigureElement * GetMotherElement()
Definition FigureTool.h:126
FigureSquareRange Range_Total
Definition FigureTool.h:98
bool Contain(std::shared_ptr< FigureElement > subelement)
std::shared_ptr< FigureElement > FindLinkElement(const TString &name)
virtual void DrawElement()
bool IsType(const TString &tyname)
Definition FigureTool.h:125
int GetLinkIndex(const TString &name)
std::shared_ptr< FigureElement > TraceElement(const TString &name)
std::shared_ptr< FigureStyleHelper > stylehelper
Definition FigureTool.h:116
bool CheckDuplicate(const TString &name)
Figure class for TF1.
Definition FigureTool.h:250
std::function< void(TF1 *)> OptionFunc
Definition FigureTool.h:268
std::pair< double, double > GetMinAndMax(double, double)
virtual void DrawElement() override
virtual void SetStyle() override
Figure class for TGraph.
Definition FigureTool.h:222
std::pair< double, double > GetMinAndMax(double, double)
std::function< void(TGraph *)> OptionFunc
Definition FigureTool.h:241
virtual void DrawElement() override
virtual void SetStyle() override
Figure class for THStack.
Definition FigureTool.h:180
THStack * GetHist()
Definition FigureTool.h:217
void Scale(double)
Scale the histogram.
std::vector< TString > LinkedHists
Definition FigureTool.h:205
void DrawTotalHist(const TString &option, std::function< void(TH1D *)> optionfunc=[](TH1D *) {})
Whether draw the total hist of the hstack.
std::function< void(TH1D *)> total_hist_optionfunc
Definition FigureTool.h:214
virtual void DrawElement() override
TGraphErrors * total_hist_graph
Definition FigureTool.h:210
virtual void SetStyle() override
void Rebin(int)
Rebin the histogram.
std::pair< double, double > GetMinAndMax(double, double)
TString total_hist_drawoption
Definition FigureTool.h:213
Figure class for TH1D.
Definition FigureTool.h:132
std::pair< double, double > GetMinAndMax(double, double)
virtual void SetStyle() override
std::vector< TString > GetLinkObject()
std::function< void(TH1D *)> OptionFunc
Definition FigureTool.h:162
std::function< void(TGraph *)> TGraphOptionFunc
Definition FigureTool.h:163
virtual void DrawElement() override
void Rebin(int)
Rebin the histogram.
TGraphErrors * mygraph
Definition FigureTool.h:160
void Scale(double)
Scale the histogram.
Figure class for TH2D.
Definition FigureTool.h:277
virtual void SetStyle() override
std::function< void(TH2D *)> OptionFunc
Definition FigureTool.h:296
virtual void DrawElement() override
void Rebin(int, int)
Figure class for TLatex.
Definition FigureTool.h:305
std::function< void(TLatex *)> OptionFunc
Definition FigureTool.h:321
virtual void DrawElement() override
virtual void SetStyle() override
Figure class for TPad. This is the class for drawing all the other elements(histograms,...
Definition FigureTool.h:329
TString GetXTitle()
Definition FigureTool.h:446
std::shared_ptr< FigurePad > BookPad(const TString &padname, int lbx, int lby, int rtx, int rty, std::function< void(TPad *)> optionfunc=[](TPad *) {})
Book a new pad in this pad.
void SetLogy(int value=1)
Set y-axis to be drawn in logarithmic scale.
std::shared_ptr< FigureGraph1D > SetInputGraph1D(const TString &elementname, TGraph *graph, const TString &option, std::function< void(TGraph *)> optionfunc=[](TGraph *) {})
Book a new FigureGraph1D on this pad.
TString legend_header
Definition FigureTool.h:433
void Norm(const TString &, const TString &, double xmin=0, double xmax=0)
Normalize one element to another.
std::function< void(TAxis *, TAxis *, TAxis *)> AxisOptionFunc
Definition FigureTool.h:402
void SetLegend(const TString &header="", const TString &option="")
Set the legend of this pad.
void SetAxisStyle(std::function< void(TAxis *, TAxis *, TAxis *)>)
Set the style of the axis manually.
Definition FigureTool.h:480
double GetZTitleOffset()
Definition FigureTool.h:451
virtual void DrawElement() override
void SetGridy(bool gridy=true)
Draw grids on y axis.
void SetGridx(bool gridx=true)
Draw grids on x axis.
void SetAxisTitle(const TString &xname="UNKNOWN", const TString &yname="UNKNOWN", const TString &zname="UNKNOWN")
Set the axis title.
Definition FigureTool.h:471
std::shared_ptr< FigureHist1D > SetInputHist1DGraph(const TString &elementname, TH1D *hist, const TString &option, std::function< void(TGraph *)> optionfunc=[](TGraph *) {})
Book a FigureHist1D on this pad, the histogram will be converted to a TGraphErrors object when drawin...
bool user_set_legend_position
Definition FigureTool.h:435
std::shared_ptr< FigureHStack > SetHStack(const TString &elementname, const std::vector< TString > &linkinfo, const TString &option)
Book a new THStack on this pad, note that only one NAGASH::FigureHStack can be booked in a pad.
void SetXaxisRange(double min, double max)
Set the range of the x-axis to be drawn.
void SetLogz(int value=1)
Set z-axis to be drawn in logarithmic scale.
TString GetZTitle()
Definition FigureTool.h:448
FigurePad(std::shared_ptr< MSGTool > MSG, std::shared_ptr< FigureStyleHelper > shelper, const TString &elementname, int lbx, int lby, int rtx, int rty, FigureElement *mother, std::function< void(TPad *)> optionfunc=[](TPad *) {})
virtual void CD() override
void SetLogx(int value=1)
Set x-axis to be drawn in logarithmic scale.
void SetZaxisRange(double min, double max)
Set the range of the z-axis to be drawn.
std::shared_ptr< FigureHist2D > SetInputHist2D(const TString &elementname, TH2D *hist, const TString &option, std::function< void(TH2D *)> optionfunc=[](TH2D *) {})
Book a new FigureHist2D on this pad.
void SetLegendColumn(int)
Set the column number of the legend.
double GetXTitleOffset()
Definition FigureTool.h:449
std::vector< TString > legend_entries
Definition FigureTool.h:431
std::function< void(TPad *)> OptionFunc
Definition FigureTool.h:401
void SetLatex(const TString &content, double posx, double poxy, Color_t color=1, std::function< void(TLatex *)> optionfunc=[](TLatex *) {})
Book a new FigureLatex on this pad.
TString legend_header_option
Definition FigureTool.h:434
TString GetYTitle()
Definition FigureTool.h:447
double GetYTitleOffset()
Definition FigureTool.h:450
virtual void SetStyle() override
std::shared_ptr< FigureHist1D > SetInputHist1D(const TString &elementname, TH1D *hist, const TString &option, std::function< void(TH1D *)> optionfunc=[](TH1D *) {})
Book a FigureHist1D on this pad.
void SetLegendEntries(const std::vector< TString > &entries, const std::vector< TString > &options)
Set the entries passed to the legend, if this function is not called, all the elements in the pad wil...
void SetAxisTitleOffset(double off_x=1.4, double off_y=1.4, double off_z=1)
Set the offset of the axis title manually.
Definition FigureTool.h:459
void SetYaxisRange(double min, double max)
Set the range of the y-axis to be drawn.
std::vector< TString > legend_options
Definition FigureTool.h:432
std::shared_ptr< FigureFunc1D > SetInputFunc1D(const TString &elementname, TF1 *func, const TString &option, std::function< void(TF1 *)> optionfunc=[](TF1 *) {})
Book a new FigureFunc1D on this pad.
bool NeedBottomMargin()
Definition FigureTool.h:445
void DrawATLASLabel(const TString &content, double posx, double poxy, Color_t color=1, double space=-1)
Draw a "ATLAS" plus the given content like ATLAS Internal, the ATLAS text will be drawn slanted.
Class for control the style of the FigureTool, you can define your own FigureStyleHelper by inheritin...
Definition FigureTool.h:35
std::shared_ptr< MSGTool > MSGUser()
Definition FigureTool.h:73
virtual void SetPadStyle(FigurePad *pad)
virtual void SetLatexStyle(FigureLatex *latex)
virtual void SetFunc1DStyle(FigureFunc1D *func)
int DIVISION_N1
The number of primary divisions on the axis.
Definition FigureTool.h:59
double TITLE_MARGIN_PERCENT
The margin size for the title(left and bottom).
Definition FigureTool.h:48
virtual void SetHist1DGraphStyle(FigureHist1D *hist)
std::shared_ptr< MSGTool > msg
Definition FigureTool.h:68
virtual void SetGraph1DStyle(FigureGraph1D *graph)
double LEGEND_TEXT_SIZE_PERCENT
The size of the legend text as well as other text in the pad.
Definition FigureTool.h:55
virtual void SetHist2DStyle(FigureHist2D *hist)
double RIGHT_BLANK_MARGIN_PERCENT
The margin size on the right.
Definition FigureTool.h:51
double COLZ_MARGIN_PERCENT
The margin size for the z axis for 2D histogram COLZ draw option.
Definition FigureTool.h:49
virtual void SetHist1DStyle(FigureHist1D *hist)
double LeftPercentage
Control the left space to automatically place the legend.
Definition FigureTool.h:65
int DIVISION_N2
The number of secondary divisions on the axis.
Definition FigureTool.h:60
double TOP_BLANK_MARGIN_PERCENT
The margin size on the top.
Definition FigureTool.h:50
double TEXT_SIZE_PERCENT
The size of the text on the axis.
Definition FigureTool.h:54
double TICK_LENGTH_PERCENT
The length of the tick on the axis.
Definition FigureTool.h:53
int DIVISION_N3
The number of tertiary divisions on the axis.
Definition FigureTool.h:61
int TEXT_FONT
The font for the text.
Definition FigureTool.h:57
Class for plotting variaous types of figures.
Definition FigureTool.h:512
std::shared_ptr< FigureCanvas > BookFigure(const TString &figurename, int size_x, int size_y)
Book a new FigureCanvas as a new figure.
void DrawFigures()
Draw all the figures booked in this tool.
std::shared_ptr< FigureCanvas > BookATLASSquare(const TString &figurename)
Book a new FigureCanvas as a new figure. The size is 600*600 as recommended by ATLAS.
std::shared_ptr< FigureCanvas > BookATLASRectangular(const TString &figurename)
Book a new FigureCanvas as a new figure. The size is 800*600 as recommended by ATLAS.
std::shared_ptr< FigureStyleHelper > GetFigureStyleHelper()
Return the style helper of this tool.
Definition FigureTool.h:531
std::map< TString, std::shared_ptr< FigureCanvas > > BookedFigure
Definition FigureTool.h:526
void SetFigureDirectory(const TString &dirname)
Set the output directory of the figures produced by this tool.
Definition FigureTool.h:530
std::shared_ptr< FigureStyleHelper > stylehelper
Definition FigureTool.h:525
Provide interface for all tools in NAGASH.
Definition Tool.h:72