14 operator int () {
return size; };
15 operator double* () {
return ptr; };
16 operator vector<double> () {
return vec; };
18 noiPtrDbl(TAxis*
ax,
double bin_loc=0.5,
bool get_widths=
false) {
19 int n_bins = ax->GetNbins();
21 for (
int i{1};
i<=n_bins; ++
i)
vec.push_back(ax->GetBinWidth(
i)*bin_loc);
22 }
else if (bin_loc == 0.5) {
23 for (
int i{1};
i<=n_bins; ++
i)
vec.push_back(ax->GetBinCenter(
i));
24 }
else if (bin_loc == 0.) {
25 for (
int i{1};
i<=n_bins; ++
i)
vec.push_back(ax->GetBinLowEdge(
i));
26 }
else if (bin_loc == 1.) {
27 for (
int i{1};
i<=n_bins; ++
i)
vec.push_back(ax->GetBinUpEdge(
i));
29 for (
int i{1};
i<=n_bins; ++
i) {
30 double W = ax->GetBinWidth(
i);
31 double L = ax->GetBinLowEdge(
i);
32 vec.push_back(L+W*bin_loc);
41 for (
auto i{1};
i<= hg->GetXaxis()->GetNbins(); ++
i) {
42 vec.push_back(hg->GetBinError(
i));
45 for (
auto i{1};
i<= hg->GetXaxis()->GetNbins(); ++
i) {
46 vec.push_back(hg->GetBinContent(
i));
55 TGraphAsymmErrors*
TGASE_errors (TH1D* hg, array<double,4> x_rat={-1,-1,0.5}) {
58 noiPtrDbl err_x {hg->GetXaxis(), 0.5,
true};
66 auto tgase =
new TGraphAsymmErrors (
x.size,
x,
y,err_x,err_x,err_y_lo,err_y_hi);
75 double r_left { x_rat[0] };
76 double r_right { x_rat[1] };
77 double r_center { x_rat[2] };
78 double offset_c { x_rat[3] };
80 double*
x = tgase->GetX();
82 double deltaX = tgase->GetErrorXlow(
i) + tgase->GetErrorXhigh(
i);
83 double anchor = x[
i]-tgase->GetErrorXlow(
i);
84 double p_left = anchor + r_left * deltaX;
85 double p_right = anchor + r_right * deltaX;
86 double p_center = anchor + r_center * deltaX + offset_c;
87 tgase->SetPointEXlow (
i, p_center-p_left);
88 tgase->SetPointEXhigh(
i, p_right-p_center);
89 tgase->SetPoint(
i,p_center,tgase->GetY()[
i]);
95 #endif // endif noiclass noibinvec definition