109 :
TGraph(
np,
x,
y), fNYErrors(1), fSumErrorsMode(
m)
157 :
TGraph(
np,
x,
y), fNYErrors(1), fSumErrorsMode(
m)
207 std::vector<std::vector<Float_t>>
eyH,
Int_t m)
246 std::vector<std::vector<Float_t>>
eyL, std::vector<std::vector<Float_t>>
eyH,
261 std::vector<std::vector<Double_t>>
eyH,
Int_t m)
302 std::vector<std::vector<Double_t>>
eyL, std::vector<std::vector<Double_t>>
eyH,
409 std::vector<TArrayD>
eyL, std::vector<TArrayD>
eyH,
Int_t m)
425 :
TGraph(), fNYErrors(1), fSumErrorsMode(
m)
464 :
TGraph(), fNYErrors(1), fSumErrorsMode(
m)
502 :
TGraph(), fNYErrors(
ne), fSumErrorsMode(
m)
541 :
TGraph(), fNYErrors(
ne), fSumErrorsMode(
m)
648 fEyL[0][i] =
h->GetBinError(i + 1);
649 fEyH[0][i] =
h->GetBinError(i + 1);
671 Error(
"TGraphMultiErrors",
"Invalid histogram pointers");
678 std::string
sname =
"divide_" + std::string(
pass->GetName()) +
"_by_" + std::string(
total->GetName());
683 pass->TAttLine::Copy(*
this);
684 pass->TAttFill::Copy(*
this);
685 pass->TAttMarker::Copy(*
this);
846 for (
Int_t i = 0; i <
tgme->GetN(); i++) {
858 Warning(
"DoMerge",
"Merging a %s is not compatible with a TGraphMultiErrors - Errors will be ignored",
859 tg->IsA()->GetName());
891 [begin = low, &
sorting_indices,
this]()
mutable { return fExL[sorting_indices[begin++]]; });
893 [begin = low, &
sorting_indices,
this]()
mutable { return fExH[sorting_indices[begin++]]; });
903 [begin = low, &
sorting_indices, &
j,
this]()
mutable { return fEyL[j].GetArray()[sorting_indices[begin++]]; });
905 [begin = low, &
sorting_indices, &
j,
this]()
mutable { return fEyL[j].GetArray()[sorting_indices[begin++]]; });
1005 Error(
"Divide",
"one of the passed pointers is zero");
1010 if ((
pass->GetDimension() > 1) || (
total->GetDimension() > 1)) {
1011 Error(
"Divide",
"passed histograms are not one-dimensional");
1022 if (
pass->GetSumw2()->fN > 0) {
1023 for (
int i = 0; i <
pass->GetNbinsX(); ++i) {
1036 if (
total->GetSumw2()->fN > 0) {
1037 for (
int i = 0; i <
total->GetNbinsX(); ++i) {
1071 if (
option.Contains(
"v")) {
1072 option.ReplaceAll(
"v",
"");
1075 Info(
"Divide",
"weight will be considered in the Histogram Ratio");
1079 if (
option.Contains(
"cl=")) {
1083 if ((level > 0) && (level < 1))
1086 Warning(
"Divide",
"given confidence level %.3lf is invalid", level);
1087 option.ReplaceAll(
"cl=",
"");
1091 if (
option.Contains(
"n")) {
1092 option.ReplaceAll(
"n",
"");
1097 if (
option.Contains(
"cp")) {
1098 option.ReplaceAll(
"cp",
"");
1103 if (
option.Contains(
"w")) {
1104 option.ReplaceAll(
"w",
"");
1109 if (
option.Contains(
"ac")) {
1110 option.ReplaceAll(
"ac",
"");
1114 if (
option.Contains(
"fc")) {
1115 option.ReplaceAll(
"fc",
"");
1119 if (
option.Contains(
"midp")) {
1120 option.ReplaceAll(
"midp",
"");
1125 if (
option.Contains(
"b(")) {
1132 Warning(
"Divide",
"given shape parameter for alpha %.2lf is invalid",
a);
1136 Warning(
"Divide",
"given shape parameter for beta %.2lf is invalid",
b);
1137 option.ReplaceAll(
"b(",
"");
1145 option.ReplaceAll(
"mode",
"");
1149 if (
option.Contains(
"e0")) {
1151 option.ReplaceAll(
"e0",
"");
1161 if (
option.Contains(
"pois")) {
1163 option.ReplaceAll(
"pois",
"");
1169 Warning(
"Divide",
"Histograms have weights: only Normal or Bayesian error calculation is supported");
1170 Info(
"Divide",
"Using now the Normal approximation for weighted histograms");
1174 if (
pass->GetDimension() !=
total->GetDimension()) {
1175 Error(
"Divide",
"passed histograms are not of the same dimension");
1180 Error(
"Divide",
"passed histograms are not consistent");
1186 Error(
"Divide",
"passed histograms are not consistent");
1206 for (
Int_t b = 1;
b <= nbins; ++
b) {
1223 if (
pw == 0 &&
pw2 == 0)
1228 if (
tw == 0 &&
tw2 == 0)
1233 if (
pw > 0 &&
tw > 0)
1236 else if (
pw == 0 &&
tw > 0)
1240 else if (
tw == 0 &&
pw > 0)
1286 double norm =
tw /
tw2;
1287 aa =
pw * norm + alpha;
1288 bb = (
tw -
pw) * norm + beta;
1342 low = low / (1. - low);
1356 pass->GetBinLowEdge(
b) -
pass->GetBinCenter(
b) +
pass->GetBinWidth(
b));
1364 Warning(
"Divide",
"Number of graph points is different than histogram bins - %d points have been skipped",
1368 Info(
"Divide",
"made a graph with %d points from %d bins",
npoint, nbins);
1369 Info(
"Divide",
"used confidence level: %.2lf\n",
conf);
1371 Info(
"Divide",
"used prior probability ~ beta(%.2lf,%.2lf)", alpha, beta);
1604 return fEyL[
e].GetArray();
1615 return fEyH[
e].GetArray();
1711 printf(
"x[%d]=%g, y[%d]=%g", i,
fX[i], i,
fY[i]);
1731 out <<
" " << std::endl;
1738 out <<
" TGraphMultiErrors* ";
1740 out <<
"tgme = new TGraphMultiErrors(" <<
fNpoints <<
", " <<
fNYErrors <<
");" << std::endl;
1748 out <<
" tgme->SetPoint(" << i <<
", " <<
fX[i] <<
", " <<
fY[i] <<
");" << std::endl;
1749 out <<
" tgme->SetPointEX(" << i <<
", " <<
fExL[i] <<
", " <<
fExH[i] <<
");" << std::endl;
1752 out <<
" tgme->SetPointEY(" << i <<
", " <<
j <<
", " <<
fEyL[
j][i] <<
", " <<
fEyH[
j][i] <<
");"
1779 for (
size_t d=0;
d<
fEyL.size();
d++)
1782 for (
size_t d=0;
d<
fEyH.size();
d++)
1797 Error(
"SetPointError",
"Cannot be used without gPad, requires last mouse position");
2021 taf->TAttFill::Copy(*
this);
2032 taf->TAttLine::Copy(*
this);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
static unsigned int total
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t SetLineWidth
Option_t Option_t SetFillStyle
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t SetLineColor
Option_t Option_t SetFillColor
R__EXTERN TStyle * gStyle
const_iterator begin() const
const_iterator end() const
Array of doubles (64 bits per element).
Fill Area Attributes class.
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
static Double_t BetaMode(Double_t alpha, Double_t beta)
Compute the mode of the beta distribution.
static Bool_t BetaShortestInterval(Double_t level, Double_t alpha, Double_t beta, Double_t &lower, Double_t &upper)
Calculates the boundaries for a shortest confidence interval for a Beta distribution.
static Double_t BetaMean(Double_t alpha, Double_t beta)
Compute the mean (average) of the beta distribution.
static Double_t AgrestiCoull(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Calculates the boundaries for the frequentist Agresti-Coull interval.
static Double_t FeldmanCousins(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Calculates the boundaries for the frequentist Feldman-Cousins interval.
static Bool_t CheckBinning(const TH1 &pass, const TH1 &total)
Checks binning for each axis.
static Double_t BetaCentralInterval(Double_t level, Double_t alpha, Double_t beta, Bool_t bUpper)
Calculates the boundaries for a central confidence interval for a Beta distribution.
static Double_t Normal(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Returns the confidence limits for the efficiency supposing that the efficiency follows a normal distr...
static Double_t Wilson(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Calculates the boundaries for the frequentist Wilson interval.
static Bool_t CheckConsistency(const TH1 &pass, const TH1 &total, Option_t *opt="")
Checks the consistence of the given histograms.
static Double_t ClopperPearson(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Calculates the boundaries for the frequentist Clopper-Pearson interval.
TGraph with asymmetric error bars and multiple y error dimensions.
Double_t * fEyLSum
! Array of summed Y low errors for fitting
virtual Color_t GetFillColor() const
Return the fill area color.
Double_t * GetEYhigh() const override
Get all high errors on y coordinates as an array summed according to fSumErrorsMode.
Double_t GetErrorX(Int_t i) const override
Get error on x coordinate for point i.
virtual Style_t GetFillStyle() const
Return the fill area style.
Double_t GetErrorXhigh(Int_t i) const override
Get high error on x coordinate for point i.
virtual void SetPointError(Double_t exL, Double_t exH, Double_t eyL1, Double_t eyH1, Double_t eyL2=0., Double_t eyH2=0., Double_t eyL3=0., Double_t eyH3=0.)
Set ex and ey values for point pointed by the mouse.
virtual TAttLine * GetAttLine(Int_t e)
Get AttLine pointer for specified error dimension.
virtual void SetFillColorAlpha(Int_t e, Color_t fcolor, Float_t falpha)
Set Fill Color and Alpha of error e (-1 = Global and x errors).
virtual Color_t GetLineColor() const
Return the line color.
Double_t GetErrorYlow(Int_t i) const override
Get low error on y coordinate for point i.
void Divide(const TH1 *pass, const TH1 *total, Option_t *opt="cp")
This function was adapted from the TGraphAsymmErrors class.
std::vector< TAttLine > fAttLine
The AttLine attributes of the different errors.
virtual void AddYError(Int_t np, const Double_t *eyL=nullptr, const Double_t *eyH=nullptr)
Add a new y error to the graph and fill it with the values from eyL and eyH
Double_t GetErrorXlow(Int_t i) const override
Get low error on x coordinate for point i.
TGraphMultiErrors()
TGraphMultiErrors default constructor.
virtual void SetEY(Int_t e, Int_t np, const Double_t *eyL, const Double_t *eyH)
Set error e ey values.
virtual void SetSumErrorsMode(Int_t m)
Set the sum errors mode and recalculate summed errors.
virtual void BayesDivide(const TH1 *pass, const TH1 *total, Option_t *opt="")
This function is only kept for backward compatibility.
void Print(Option_t *chopt="") const override
Print graph and errors values.
TGraphMultiErrors & operator=(const TGraphMultiErrors &tgme)
TGraphMultiErrors assignment operator.
void CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin) override
Copy and release.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Int_t fSumErrorsMode
How y errors are summed: kOnlyFirst = Only First; kSquareSum = Squared Sum; kSum = Absolute Addition.
virtual Width_t GetLineWidth() const
Return the line width.
Double_t * GetEXhigh() const override
@ kAbsSum
Calculate the absolute sum of all errors.
@ kSquareSum
Calculate the square sum of all errors.
@ kOnlyFirst
Only take errors from first dimension.
virtual TAttFill * GetAttFill(Int_t e)
Get AttFill pointer for specified error dimension.
virtual void SetLineStyle(Int_t e, Style_t lstyle)
Set Line Style of error e (-1 = Global and x errors).
Bool_t CopyPoints(Double_t **arrays, Int_t ibegin, Int_t iend, Int_t obegin) override
Copy errors from fE*** to arrays[***] or to f*** Copy points.
virtual void SetPointEXhigh(Int_t i, Double_t exH)
Set exH value for point i.
Double_t * fExL
[fNpoints] array of X low errors
void FillZero(Int_t begin, Int_t end, Bool_t from_ctor=kTRUE) override
Set zero values for point arrays in the range [begin, end].
virtual void SetLineWidth(Int_t e, Width_t lwidth)
Set Line Width of error e (-1 = Global and x errors).
std::vector< TArrayD > fEyH
Two dimensional array of Y high errors.
virtual Style_t GetLineStyle() const
Return the line style.
virtual void SetPointEX(Int_t i, Double_t exL, Double_t exH)
Set ex values for point i.
virtual void SetPointEYlow(Int_t i, Int_t ne, const Double_t *eyL)
Set eyL values for point i.
void Scale(Double_t c1=1., Option_t *option="y") override
Multiply the values and errors of a TGraphMultiErrors by a constant c1.
virtual void SetLineColorAlpha(Int_t e, Color_t lcolor, Float_t lalpha)
Set Line Color and Alpha of error e (-1 = Global and x errors).
virtual void SetFillColor(Int_t e, Color_t fcolor)
Set Fill Color of error e (-1 = Global and x errors).
Double_t * GetEXlow() const override
void CalcYErrorsSum() const
Recalculates the summed y error arrays.
~TGraphMultiErrors() override
TGraphMultiErrors default destructor.
virtual void SetAttLine(Int_t e, TAttLine *tal)
Set TAttLine parameters of error e by copying from another TAttLine (-1 = Global and x errors).
Double_t * fEyHSum
! Array of summed Y high errors for fitting
Double_t * GetEYlow() const override
Get all low errors on y coordinates as an array summed according to fSumErrorsMode.
virtual void DeleteYError(Int_t e)
Deletes the y error with the index e.
void Apply(TF1 *f) override
Apply a function to all data points .
virtual void SetFillStyle(Int_t e, Style_t fstyle)
Set Fill Style of error e (-1 = Global and x errors).
virtual void SetEYhigh(Int_t e, Int_t np, const Double_t *eyH)
Set error e eyH values.
void SwapPoints(Int_t pos1, Int_t pos2) override
Swap points.
virtual void SetAttFill(Int_t e, TAttFill *taf)
Set TAttFill parameters of error e by copying from another TAttFill (-1 = Global and x errors).
virtual void SetEYlow(Int_t e, Int_t np, const Double_t *eyL)
Set error e eyL values.
std::vector< TAttFill > fAttFill
The AttFill attributes of the different errors.
void UpdateArrays(const std::vector< Int_t > &sorting_indices, Int_t numSortedPoints, Int_t low) override
Update the fX, fY, fExL, fExH, fEyL and fEyH arrays with the sorted values.
Bool_t CtorAllocate()
Should be called from ctors after fNpoints has been set Note: This function should be called only fro...
Double_t * fExH
[fNpoints] array of X high errors
virtual void SetPointEY(Int_t i, Int_t ne, const Double_t *eyL, const Double_t *eyH)
Set ey values for point i.
virtual void SetLineColor(Int_t e, Color_t lcolor)
Set Line Color of error e (-1 = Global and x errors).
virtual void SetPointEXlow(Int_t i, Double_t exL)
Set exL value for point i.
virtual void SetPointEYhigh(Int_t i, Int_t ne, const Double_t *eyH)
Set eyH values for point i.
void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const override
Compute Range.
Int_t fNYErrors
The amount of different y-errors.
std::vector< TArrayD > fEyL
Two dimensional array of Y low errors.
Double_t GetErrorY(Int_t i) const override
Get error on y coordinate for point i.
Double_t ** Allocate(Int_t size) override
Allocate internal data structures for size points.
Bool_t DoMerge(const TGraph *tg) override
Protected function to perform the merge operation of a graph with multiple asymmetric errors.
Double_t GetErrorYhigh(Int_t i) const override
Get high error on y coordinate for point i.
A TGraph is an object made of two arrays X and Y with npoints each.
Int_t fNpoints
Number of points <= fMaxSize.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Int_t fMaxSize
!Current dimension of arrays fX and fY
void SaveHistogramAndFunctions(std::ostream &out, const char *varname, Int_t &frameNumber, Option_t *option)
Save histogram and list of functions of TGraph as C++ statement Used in all TGraph-derived classes.
TH1F * fHistogram
Pointer to histogram used for drawing axis.
virtual void UpdateArrays(const std::vector< Int_t > &sorting_indices, Int_t numSortedPoints, Int_t low)
Update the fX and fY arrays with the sorted values.
Double_t * fY
[fNpoints] array of Y points
Bool_t CtorAllocate()
In constructors set fNpoints than call this method.
virtual void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
Compute the x/y range of the points in this graph.
Double_t ** AllocateArrays(Int_t Narrays, Int_t arraySize)
Allocate arrays.
virtual void Scale(Double_t c1=1., Option_t *option="y")
Multiply the values of a TGraph by a constant c1.
static void SwapValues(Double_t *arr, Int_t pos1, Int_t pos2)
Swap values.
virtual Bool_t DoMerge(const TGraph *g)
protected function to perform the merge operation of a graph
void SetName(const char *name="") override
Set graph name.
virtual void SwapPoints(Int_t pos1, Int_t pos2)
Swap points.
virtual void FillZero(Int_t begin, Int_t end, Bool_t from_ctor=kTRUE)
Set zero values for point arrays in the range [begin, end) Should be redefined in descendant classes.
Double_t * fX
[fNpoints] array of X points
void SetTitle(const char *title="") override
Change (i.e.
void SetNameTitle(const char *name="", const char *title="") override
Set graph name and title.
virtual void Set(Int_t n)
Set number of points in the graph Existing coordinates are preserved New coordinates above fNpoints a...
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
Get x and y values for point number i.
virtual Bool_t CopyPoints(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin)
Copy points from fX and fY to arrays[0] and arrays[1] or to fX and fY if arrays == 0 and ibegin !...
TGraph & operator=(const TGraph &)
Equal operator for this graph.
TH1 is the base class of all histogram classes in ROOT.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
void ToLower()
Change string to lower-case.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Float_t GetErrorX() const
double normal_quantile_c(double z, double sigma)
Inverse ( ) of the cumulative distribution function of the upper tail of the normal (Gaussian) distri...
Int_t Nint(T x)
Round to nearest integer. Rounds half integers to the nearest even integer.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Int_t Finite(Double_t x)
Check if it is finite with a mask in order to be consistent in presence of fast math.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
static uint64_t sum(uint64_t i)