141 if (exl)
fEXlow[i] = exl[i];
145 if (eyl)
fEYlow[i] = eyl[i];
164 if(exl) { memcpy(
fEXlow, exl, n);
165 }
else { memset(
fEXlow, 0, n); }
166 if(exh) { memcpy(
fEXhigh, exh, n);
167 }
else { memset(
fEXhigh, 0, n); }
168 if(eyl) { memcpy(
fEYlow, eyl, n);
169 }
else { memset(
fEYlow, 0, n); }
170 if(eyh) { memcpy(
fEYhigh, eyh, n);
171 }
else { memset(
fEYhigh, 0, n); }
195 fX[i] = vx(i+ivxlow);
196 fY[i] = vy(i+ivylow);
197 fEXlow[i] = vexl(i+ivexllow);
198 fEYlow[i] = veyl(i+iveyllow);
225 fX[i] = vx(i+ivxlow);
226 fY[i] = vy(i+ivylow);
227 fEXlow[i] = vexl(i+ivexllow);
228 fEYlow[i] = veyl(i+iveyllow);
258 :
TGraph((pass)?pass->GetNbinsX():0)
260 if (!pass || !total) {
261 Error(
"TGraphAsymmErrors",
"Invalid histogram pointers");
266 std::string
sname =
"divide_" + std::string(pass->
GetName()) +
"_by_" +
272 pass->TAttLine::Copy(*
this);
273 pass->TAttFill::Copy(*
this);
274 pass->TAttMarker::Copy(*
this);
276 Divide(pass, total, option);
305 Double_t x,
y,exl,exh,eyl,eyh,eyl_new,eyh_new,fxy;
323 if (f->
Eval(x,y-eyl)<f->
Eval(x,y+eyh)) {
346 Divide(pass,total,
"cl=0.683 b(1,1) mode");
422 if(!pass || !total) {
423 Error(
"Divide",
"one of the passed pointers is zero");
429 Error(
"Divide",
"passed histograms are not one-dimensional");
435 Bool_t bEffective =
false;
460 Double_t conf = 0.682689492137;
462 Bool_t bIsBayesian =
false;
476 sscanf(strstr(option.
Data(),
"cl="),
"cl=%lf",&level);
477 if((level > 0) && (level < 1))
480 Warning(
"Divide",
"given confidence level %.3lf is invalid",level);
522 sscanf(strstr(option.
Data(),
"b("),
"b(%lf,%lf)",&a,&b);
526 Warning(
"Divide",
"given shape parameter for alpha %.2lf is invalid",a);
530 Warning(
"Divide",
"given shape parameter for beta %.2lf is invalid",b);
536 Bool_t usePosteriorMode =
false;
537 if(bIsBayesian && option.
Contains(
"mode") ) {
538 usePosteriorMode =
true;
548 Bool_t useShortestInterval =
false;
549 if (bIsBayesian && ( option.
Contains(
"sh") || (usePosteriorMode && !option.
Contains(
"cen") ) ) ) {
550 useShortestInterval =
true;
554 Bool_t bPoissonRatio =
false;
556 bPoissonRatio =
true;
563 Warning(
"Divide",
"Histograms have weights: only Normal or Bayesian error calculation is supported");
564 Info(
"Divide",
"Using now the Normal approximation for weighted histograms");
570 Error(
"Divide",
"passed histograms are not of the same dimension");
575 Error(
"Divide",
"passed histograms are not consistent");
583 Error(
"Divide",
"passed histograms are not consistent");
598 double eff, low,
upper;
602 Double_t
t = 0 , p = 0;
603 Double_t tw = 0, tw2 = 0, pw = 0, pw2 = 0, wratio = 1;
625 if (pw == 0 && pw2 == 0)
630 if (tw == 0 && tw2 == 0)
636 wratio = (pw*
t)/(p * tw);
637 else if (p == 0 && tw > 0)
643 if (!plot0Bins)
continue;
649 if (tw <= 0 && !plot0Bins)
continue;
661 if(bPoissonRatio) t += p;
663 if (!t && !plot0Bins)
continue;
671 if ((bEffective && !bPoissonRatio) && tw2 <= 0) {
674 low = eff; upper = eff;
678 if (bEffective && !bPoissonRatio) {
680 double norm = tw/tw2;
681 aa = pw * norm + alpha;
682 bb = (tw - pw) * norm + beta;
688 if (usePosteriorMode)
693 if (useShortestInterval) {
704 if (bEffective && !bPoissonRatio) {
713 double variance = ( pw2 * (1. - 2 * eff) + tw2 * eff *eff ) / ( tw * tw) ;
716 double prob = 0.5 * (1.-conf);
720 if (low < 0) low = 0;
721 if (upper > 1) upper = 1.;
729 low = pBound(t,p,conf,
false);
730 upper = pBound(t,p,conf,
true);
736 Double_t ratio = eff/(1 - eff);
738 low = low/(1. - low);
739 upper = upper/(1.-
upper);
759 Warning(
"Divide",
"Number of graph points is different than histogram bins - %d points have been skipped",nbins-npoint);
763 Info(
"Divide",
"made a graph with %d points from %d bins",npoint,nbins);
764 Info(
"Divide",
"used confidence level: %.2lf\n",conf);
766 Info(
"Divide",
"used prior probability ~ beta(%.2lf,%.2lf)",alpha,beta);
836 memmove(&arrays[0][obegin], &
fEXlow[ibegin], n);
837 memmove(&arrays[1][obegin], &
fEXhigh[ibegin], n);
838 memmove(&arrays[2][obegin], &
fEYlow[ibegin], n);
839 memmove(&arrays[3][obegin], &
fEYhigh[ibegin], n);
882 if (exl == 0 || exh == 0 || eyl == 0 || eyh == 0) {
884 Warning(
"DoMerge",
"Merging a %s is not compatible with a TGraphAsymmErrors - errors will be ignored",g->IsA()->
GetName());
908 memset(
fEXlow + begin, 0, n);
910 memset(
fEYlow + begin, 0, n);
921 if (i < 0 || i >=
fNpoints)
return -1;
936 if (i < 0 || i >=
fNpoints)
return -1;
1000 "Cannot merge - an object which doesn't inherit from TGraph found in the list");
1004 int n1 = n0+g->
GetN();
1012 for (
Int_t i = 0 ; i < g->
GetN(); i++) {
1014 if (exlow)
fEXlow[n0+i] = exlow[i];
1015 if (exhigh)
fEXhigh[n0+i] = exhigh[i];
1016 if (eylow)
fEYlow[n0+i] = eylow[i];
1017 if (eyhigh)
fEYhigh[n0+i] = eyhigh[i];
1029 printf(
"x[%d]=%g, y[%d]=%g, exl[%d]=%g, exh[%d]=%g, eyl[%d]=%g, eyh[%d]=%g\n"
1030 ,i,
fX[i],i,
fY[i],i,
fEXlow[i],i,
fEXhigh[i],i,
fEYlow[i],i,
fEYhigh[i]);
1041 out <<
" " << std::endl;
1042 static Int_t frameNumber = 3000;
1052 out <<
" Double_t " << fXName <<
"[" <<
fNpoints <<
"] = {" << std::endl;
1053 for (i = 0; i <
fNpoints-1; i++) out <<
" " <<
fX[i] <<
"," << std::endl;
1054 out <<
" " <<
fX[fNpoints-1] <<
"};" << std::endl;
1055 out <<
" Double_t " << fYName <<
"[" << fNpoints <<
"] = {" << std::endl;
1056 for (i = 0; i < fNpoints-1; i++) out <<
" " <<
fY[i] <<
"," << std::endl;
1057 out <<
" " <<
fY[fNpoints-1] <<
"};" << std::endl;
1058 out <<
" Double_t " << fElXName <<
"[" << fNpoints <<
"] = {" << std::endl;
1059 for (i = 0; i < fNpoints-1; i++) out <<
" " <<
fEXlow[i] <<
"," << std::endl;
1060 out <<
" " <<
fEXlow[fNpoints-1] <<
"};" << std::endl;
1061 out <<
" Double_t " << fElYName <<
"[" << fNpoints <<
"] = {" << std::endl;
1062 for (i = 0; i < fNpoints-1; i++) out <<
" " <<
fEYlow[i] <<
"," << std::endl;
1063 out <<
" " <<
fEYlow[fNpoints-1] <<
"};" << std::endl;
1064 out <<
" Double_t " << fEhXName <<
"[" << fNpoints <<
"] = {" << std::endl;
1065 for (i = 0; i < fNpoints-1; i++) out <<
" " <<
fEXhigh[i] <<
"," << std::endl;
1066 out <<
" " <<
fEXhigh[fNpoints-1] <<
"};" << std::endl;
1067 out <<
" Double_t " << fEhYName <<
"[" << fNpoints <<
"] = {" << std::endl;
1068 for (i = 0; i < fNpoints-1; i++) out <<
" " <<
fEYhigh[i] <<
"," << std::endl;
1069 out <<
" " <<
fEYhigh[fNpoints-1] <<
"};" << std::endl;
1072 else out <<
" TGraphAsymmErrors *";
1073 out <<
"grae = new TGraphAsymmErrors("<< fNpoints <<
","
1074 << fXName <<
"," << fYName <<
","
1075 << fElXName <<
"," << fEhXName <<
","
1076 << fElYName <<
"," << fEhYName <<
");"
1079 out <<
" grae->SetName(" << quote <<
GetName() << quote <<
");" << std::endl;
1080 out <<
" grae->SetTitle(" << quote <<
GetTitle() << quote <<
");" << std::endl;
1088 hname += frameNumber;
1092 out<<
" "<<std::endl;
1098 while ((obj =
next())) {
1101 out <<
" grae->GetListOfFunctions()->Add(ptstats);" << std::endl;
1102 out <<
" ptstats->SetParent(grae->GetListOfFunctions());" << std::endl;
1104 out <<
" grae->GetListOfFunctions()->Add("
1105 <<
Form(
"%s%d",obj->
GetName(),frameNumber) <<
");" << std::endl;
1109 const char *
l = strstr(option,
"multigraph");
1111 out<<
" multigraph->Add(grae,"<<quote<<l+10<<quote<<
");"<<std::endl;
1113 out<<
" grae->Draw("<<quote<<option<<quote<<
");"<<std::endl;
1132 if (dpx*dpx+dpy*dpy < 25) {ipoint = i;
break;}
1134 if (ipoint == -2)
return;
1220 void TGraphAsymmErrors::Streamer(
TBuffer &b)
1230 TGraph::Streamer(b);
virtual Double_t * GetEYlow() const
Double_t GetErrorYhigh(Int_t i) const
Get high error on Y.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Int_t fNpoints
Current dimension of arrays fX and fY.
Double_t At(Int_t i) const
virtual const char * GetTitle() const
Returns title of object.
virtual Bool_t CopyPoints(Double_t **arrays, Int_t ibegin, Int_t iend, Int_t obegin)
Copy errors from fE*** to arrays[***] or to f*** Copy points.
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
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.
virtual void GetStats(Double_t *stats) const
fill the array stats from the contents of this histogram The array stats must be correctly dimensione...
double normal_quantile_c(double z, double sigma)
Inverse ( ) of the cumulative distribution function of the upper tail of the normal (Gaussian) distri...
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual void CopyAndRelease(Double_t **newarrays, Int_t ibegin, Int_t iend, Int_t obegin)
Copy and release.
R__EXTERN TStyle * gStyle
virtual Int_t GetDimension() const
static Bool_t CheckBinning(const TH1 &pass, const TH1 &total)
Checks binning for each axis.
virtual void SetName(const char *name)
Change (i.e.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Buffer base class used for serializing objects.
virtual Int_t Merge(TCollection *list)
Adds all graphs with asymmetric errors from the collection to this graph.
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
Short_t Min(Short_t a, Short_t b)
void ToLower()
Change string to lower-case.
virtual void SetTitle(const char *title="")
Set graph title.
Bool_t CtorAllocate()
Should be called from ctors after fNpoints has been set Note: This function should be called only fro...
virtual Int_t GetNbinsX() const
Double_t GetErrorXhigh(Int_t i) const
Get high error on X.
double beta(double x, double y)
Calculates the beta function.
virtual Double_t GetBinWidth(Int_t bin) const
return bin width for 1D historam Better to use h1.GetXaxis().GetBinWidth(bin)
const char * Data() const
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 != ie...
TGraph with assymetric error bars.
virtual void Print(Option_t *chopt="") const
Print graph and errors values.
virtual Double_t GetBinLowEdge(Int_t bin) const
return bin lower edge for 1D historam Better to use h1.GetXaxis().GetBinLowEdge(bin) ...
TGraph & operator=(const TGraph &)
Equal operator for this graph.
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.
virtual Double_t * GetEXhigh() const
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
Double_t GetErrorYlow(Int_t i) const
Get low error on Y.
virtual void SetPointEXhigh(Int_t i, Double_t exh)
Set EXhigh for point i.
virtual void SetPointEYlow(Int_t i, Double_t eyl)
Set EYlow for point i.
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.
virtual Bool_t DoMerge(const TGraph *g)
protected function to perform the merge operation of a graph with asymmetric errors ...
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual void Apply(TF1 *f)
apply a function to all data points y = f(x,y)
virtual TArrayD * GetSumw2()
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
Compute Range.
virtual ~TGraphAsymmErrors()
TGraphAsymmErrors default destructor.
static Double_t BetaMean(Double_t alpha, Double_t beta)
Compute the mean (average) of the beta distribution.
static Double_t MidPInterval(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Calculates the boundaries using the mid-P binomial interval (Lancaster method) from B...
Bool_t CtorAllocate()
In constructors set fNpoints than call this method.
virtual void BayesDivide(const TH1 *pass, const TH1 *total, Option_t *opt="")
This function is only kept for backward compatibility.
virtual Double_t GetBinCenter(Int_t bin) const
return bin center for 1D historam Better to use h1.GetXaxis().GetBinCenter(bin)
virtual Double_t * GetEYhigh() const
virtual void SwapPoints(Int_t pos1, Int_t pos2)
Swap points.
virtual void SwapPoints(Int_t pos1, Int_t pos2)
Swap points.
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 void SwapValues(Double_t *arr, Int_t pos1, Int_t pos2)
Swap values.
Collection abstract base class.
virtual Bool_t DoMerge(const TGraph *g)
protected function to perform the merge operation of a graph
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
char * Form(const char *fmt,...)
virtual void Divide(const TH1 *pass, const TH1 *total, Option_t *opt="cp")
Fill this TGraphAsymmErrors by dividing two 1-dimensional histograms pass/total.
virtual const char * GetName() const
Returns name of object.
virtual void ReadFastArray(Bool_t *b, Int_t n)=0
Float_t GetErrorX() const
virtual void SetName(const char *name)
Change the name of this histogram.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
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)
TGraphAsymmErrors & operator=(const TGraphAsymmErrors &gr)
TGraphAsymmErrors assignment operator.
virtual const char * GetName() const
Returns name of object.
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
Get x and y values for point number i.
virtual void SetPointEXlow(Int_t i, Double_t exl)
Set EXlow for point i.
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.
Mother of all ROOT objects.
virtual Double_t * GetEXlow() const
Double_t GetErrorX(Int_t bin) const
This function is called by GraphFitChisquare.
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...
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
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.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
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.
A Graph is a graphics object made of two arrays X and Y with npoints each.
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Double_t Sqrt(Double_t x)
virtual void Set(Int_t n)
Set number of points in the graph Existing coordinates are preserved New coordinates above fNpoints a...
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
double norm(double *x, double *p)
virtual void SetPointEYhigh(Int_t i, Double_t eyh)
Set EYhigh for point i.
static Double_t BetaMode(Double_t alpha, Double_t beta)
Compute the mode of the beta distribution.
static Double_t Wilson(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Calculates the boundaries for the frequentist Wilson interval.
Double_t GetErrorY(Int_t bin) const
This function is called by GraphFitChisquare.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
static Bool_t CheckConsistency(const TH1 &pass, const TH1 &total, Option_t *opt="")
Checks the consistence of the given histograms.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual void SetPointError(Double_t exl, Double_t exh, Double_t eyl, Double_t eyh)
Set ex and ey values for point pointed by the mouse.
Double_t GetErrorXlow(Int_t i) const
Get low error on X.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.