TkN 2.1
Toolkit for Nuclei
tknuclear_chart.h
1#ifndef __TKNUCLEAR_CHART_H
2#define __TKNUCLEAR_CHART_H
3
4#include "Rtypes.h"
5
6#include "TMultiGraph.h"
7#include "TCanvas.h"
8#include "TAxis.h"
9#include "TGaxis.h"
10#include "TH2.h"
11
12namespace tkn{
26{
27 TMultiGraph mgrn, mgrz;
28 TH2F hzn, hz, hn;
29 TString chart_title;
30 TList linesp1, linesp2, linesp3;
31
32 int width = 900;
33 int height = 900;
34 double xratio = 1;
35 double xoffset = 0.;
36
37 double min_val = 9999999.;
38 double max_val = -9999999.;
39 double min_z = 9999999.;
40 double min_n = 9999999.;
41 double max_z = -9999999.;
42 double max_n = -9999999.;
43
44 bool fset_min_val=false;
45 double min_val_histo=0.;
46
47 bool autofit;
48 TCanvas* cc{};
49 TPad *p1{}, *p2{}, *p3{}, *p4{};
50
51 TGaxis* axX{}, *axY{}, *axZz{}, *axZn{};
52 int ndivx, ndivy, ndivz;
53
54 int odd_col = kRed;
55 int even_col = kBlack;
56
57 TLatex *ftitletex = nullptr;
58
59 int fsaved_emptybins_color{};
60
61 int kLineWidth = 1;
62
63public:
64
68 kOdd
69 };
70
72 tknuclear_chart(const char* title, int type=kAll, bool autofit=false);
74 tknuclear_chart(const char* title, int type=kAll, double _min_val_histo=0, bool autofit=false);
75 virtual ~tknuclear_chart() {}
76
78 void set_size(int _width, int _height);
79
81 void set_value(int _zz, int _nn, double _val);
83 double get_value(int _zz, int _nn);
84
86 void fill(int _zz, int _nn, double _val);
88 void fill(int _zz, int _nn) {fill(_zz,_nn,1.);}
89
91 void update() {draw(true);}
93 void draw(bool _update_only=false);
94
96 void set_odd_color(int _col) {odd_col = _col;}
98 void set_even_color(int _col){even_col = _col;}
99
101 void set_log_scale(bool _log=true);
103 void set_editables(bool _ed=true);
104
106 void set_ndivisions_x(int _ndiv);
108 void set_ndivisions_y(int _ndiv);
110 void set_ndivisions_z(int _ndiv);
111
113 void reset();
114
116 void set_title(TString _title) {chart_title = _title;}
117
119 void save_as(const char* file_name);
120
122 void hide_empty_bins();
123
126
128 void set_line_width(int _width){kLineWidth = _width;}
129
131 TH2 *get_histo() {return &hzn;}
132
133protected:
134 void draw_lines(int nz);
135 void draw_line(int nz, double min, double max, bool onx=true);
136 void draw_canvas();
137 void draw_axes();
138 void set_axis_att(TAxis* _ax, bool _show_labels=false);
139 void style_axis(TGaxis *_ax);
140
141 void calculate_projections();
142
143 ClassDef(tknuclear_chart,1)//nuclear chart
144};
145}
146#endif
nuclear chart plot with ROOT
tknuclear_chart(const char *title, int type=kAll, bool autofit=false)
default constructor
void show_empty_bins()
show color on empty bins
void set_title(TString _title)
define the nuclear chart title
void set_odd_color(int _col)
define the color of the projections for odd nuclei
void fill(int _zz, int _nn, double _val)
fill the bin for a given nucleus (increment by _val)
void set_ndivisions_y(int _ndiv)
define the number of tics on the y axis
void set_ndivisions_x(int _ndiv)
define the number of tics on the x axis
void set_line_width(int _width)
set magic numbers lines width
void draw(bool _update_only=false)
draw the tknucleus chart
void save_as(const char *file_name)
save the nuclear chart in the file file_name
void set_ndivisions_z(int _ndiv)
define the number of tics on the z axis
void set_even_color(int _col)
define the color of the projections for even nuclei
void set_value(int _zz, int _nn, double _val)
set the bin value for a given nucleus
void fill(int _zz, int _nn)
fill the bin for a given nucleus (increment by 1)
void set_size(int _width, int _height)
set the canvas size in pixels (default 900x900)
void update()
update the tknucleus chart
double get_value(int _zz, int _nn)
get the bin content for a given nucleus
void reset()
reset the tknuclear chart
TH2 * get_histo()
get the underlying histogram
void set_log_scale(bool _log=true)
print the tknuclear chart in log scale
void set_editables(bool _ed=true)
allow to edit the canvases
void hide_empty_bins()
remove color on empty bins (usefull for plot with negative and positive values)
Definition: tklog.cpp:39