69 TGraphAsymmErrors(), _nominalBinWidth(nominalBinWidth), _nSigma(nSigma), _rawEntries(-1)
88 TGraphAsymmErrors(), _nominalBinWidth(nominalBinWidth), _nSigma(nSigma), _rawEntries(-1)
91 throw std::invalid_argument(
92 "To ensure consistent behavior prior releases, it's not possible to create a RooHist from a TH1 with no bin width correction when using Poisson errors.");
101 const TAxis *axis= ((
TH1&)data).GetXaxis();
108 for(
Int_t bin= 1; bin <= nbin; bin++) {
140 TGraphAsymmErrors(), _nominalBinWidth(nominalBinWidth), _nSigma(nSigma), _rawEntries(-1)
148 const TAxis *axis= ((
TH1&)data1).GetXaxis();
162 coutE(InputArguments) <<
"RooHist::RooHist: histograms have different number of bins" << endl;
165 for(
Int_t bin= 1; bin <= nbin; bin++) {
168 coutW(InputArguments) <<
"RooHist::RooHist: histograms have different centers for bin " << bin << endl;
225 coutE(InputArguments) <<
"RooHist::RooHist input histograms have incompatible binning, combined histogram will remain empty" << endl ;
233 if (wgt1!=1.0 || wgt2 != 1.0) {
234 coutW(InputArguments) <<
"RooHist::RooHist: WARNING: Poisson errors of weighted sum of two histograms is not well defined! " << endl
235 <<
" Summed histogram bins will rounded to nearest integer for Poisson confidence interval calculation" << endl ;
240 for(i=0 ; i<
n ; i++) {
253 for(i=0 ; i<
n ; i++) {
260 Double_t dy = sqrt(wgt1*wgt1*dy1*dy1+wgt2*wgt2*dy2*dy2) ;
291 if(0 != strlen(
f.getUnit()) || 0 != strlen(
x.getUnit())) {
293 if(0 != strlen(
f.getUnit())) {
297 if(0 != strlen(
x.getUnit())) {
308 funcPtr=
f.bindVars(
x,normVars,
kTRUE);
311 if(scaleFactor != 1) {
320 int xbins =
x.numBins();
322 if(normVars) nset.
add(*normVars);
323 for(
int i=0; i<xbins; ++i){
324 double xval =
x.getBinning().binCenter(i);
325 double xwidth =
x.getBinning().binWidth(i);
327 double yval = (*funcPtr)(&xval);
328 double yerr = sqrt(yval);
329 if(fr) yerr =
f.getPropagatedError(*fr,nset);
330 addBinWithError(xval_ax,yval,yerr,yerr,xwidth,xErrorFrac,
false,scaleFactor) ;
337 if(rawPtr)
delete rawPtr;
368 for (
int i=0 ; i<
GetN() ; i++) {
373 if (
x>=xlo &&
x<=xhi) {
379 coutW(Plotting) <<
"RooHist::getFitRangeNEvt() WARNING: The number of normalisation events associated to histogram " <<
GetName() <<
" is not equal to number of events in this histogram."
380 <<
"\n\t\t This is due a cut being applied while plotting the data. Automatic normalisation over a sub-range of a plot variable assumes"
381 <<
"\n\t\t that the effect of that cut is uniform across the plot, which may be an incorrect assumption. To obtain a correct normalisation, it needs to be passed explicitly:"
382 <<
"\n\t\t\t data->plotOn(frame01,CutRange(\"SB1\"));"
383 <<
"\n\t\t\t const double nData = data->sumEntries(\"\", \"SB1\"); //or the cut string such as sumEntries(\"x > 0.\");"
384 <<
"\n\t\t\t model.plotOn(frame01, RooFit::Normalization(nData, RooAbsReal::NumEvent), ProjectionRange(\"SB1\"));" << endl ;
410 coutW(Plotting) <<
fName <<
"::roundBin: rounding negative bin contents to zero: " <<
y << endl;
415 coutW(Plotting) <<
fName <<
"::roundBin: rounding non-integer bin contents: " <<
y << endl;
430 coutW(Plotting) <<
"RooHist::addBin(" <<
GetName() <<
") WARNING: negative entry set to zero when Poisson error bars are requested" << endl ;
443 if (fabs((
double)((
n-
Int_t(
n))>1
e-5))) {
445 Double_t ym1(0),yp1(0),ym2(0),yp2(0) ;
450 coutE(Plotting) <<
"RooHist::addBin: unable to add bin with " <<
n <<
" events" << endl;
452 ym = ym1 + (
n-n1)*(ym2-ym1) ;
453 yp = yp1 + (
n-n1)*(yp2-yp1) ;
455 <<
") WARNING: non-integer bin entry " <<
n <<
" with Poisson errors, interpolating between Poisson errors of adjacent integer" << endl ;
459 coutE(Plotting) <<
"RooHist::addBin: unable to add bin with " <<
n <<
" events" << endl;
464 SetPoint(index,binCenter,
n*scale*scaleFactor);
465 SetPointError(index,dx*xErrorFrac,dx*xErrorFrac,scale*(
n-ym)*scaleFactor,scale*(yp-
n)*scaleFactor);
481 if(binWidth > 0 && correctForBinWidth) {
488 SetPoint(index,binCenter,
n*scale*scaleFactor);
489 SetPointError(index,dx*xErrorFrac,dx*xErrorFrac,elow*scale*scaleFactor,ehigh*scale*scaleFactor);
509 SetPointError(index,exlow,exhigh,eylow*scaleFactor,eyhigh*scaleFactor);
531 coutE(Plotting) <<
"RooHist::addAsymmetryBin: unable to calculate binomial error for bin with " << n1 <<
"," << n2 <<
" events" << endl;
537 SetPointError(index,dx*xErrorFrac,dx*xErrorFrac,(
a-ym)*scaleFactor,(yp-
a)*scaleFactor);
558 Double_t error = 2*sqrt( pow(en1,2)*pow(n2,2) + pow(en2,2)*pow(n1,2) ) / pow(n1+n2,2) ;
563 SetPointError(index,dx*xErrorFrac,dx*xErrorFrac,(
a-ym)*scaleFactor,(yp-
a)*scaleFactor);
585 coutE(Plotting) <<
"RooHist::addEfficiencyBin: unable to calculate binomial error for bin with " << n1 <<
"," << n2 <<
" events" << endl;
590 SetPointError(index,dx*xErrorFrac,dx*xErrorFrac,(
a-ym)*scaleFactor,(yp-
a)*scaleFactor);
609 Double_t error = sqrt( pow(en1,2)*pow(n2,2) + pow(en2,2)*pow(n1,2) ) / pow(n1+n2,2) ;
618 SetPointError(index,dx*xErrorFrac,dx*xErrorFrac,(
a-ym)*scaleFactor,(yp-
a)*scaleFactor);
636 for (i=0 ; i<
GetN() ; i++) {
642 if (fabs(
x1-
x2)>1
e-10) {
661 TH1F h_self(
"h_self",
"h_self",
GetN(),0,1) ;
662 TH1F h_other(
"h_other",
"h_other",
GetN(),0,1) ;
673 if(verbose) cout <<
"RooHist::isIdentical() tolerance exceeded M=" << M <<
" (tol=" << tol <<
"), corresponding prob = " << kprob << endl ;
692 os <<
indent <<
"--- RooHist ---" << endl;
694 os <<
indent <<
" Contains " <<
n <<
" bins" << endl;
696 os <<
indent <<
" Errors calculated at" <<
_nSigma <<
"-sigma CL" << endl;
697 os <<
indent <<
" Bin Contents:" << endl;
698 for(
Int_t i= 0; i <
n; i++) {
699 os <<
indent << setw(3) << i <<
") x= " <<
fX[i];
703 os <<
" , y = " <<
fY[i] <<
" +" <<
fEYhigh[i] <<
" -" <<
fEYlow[i] << endl;
735 os << IsA()->GetName() ;
768 if (x<xstart || x>xstop) continue ;
778 yy = point - curve.
average(
x-exl,
x+exh) ;
788 coutW(Plotting) <<
"RooHist::makeResisHist(" <<
GetName() <<
") WARNING: point " << i <<
" has zero error, setting residual to zero" << std::endl;
static const double x2[5]
static const double x1[5]
static void indent(ostringstream &buf, int indent_level)
char * Form(const char *fmt,...)
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
A RooCurve is a one-dimensional graphical representation of a real-valued function.
Double_t average(Double_t lo, Double_t hi) const
Return average curve value in [xFirst,xLast] by integrating curve between points and dividing by xLas...
Double_t interpolate(Double_t x, Double_t tolerance=1e-10) const
Return linearly interpolated value of curve at xvalue.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
static const RooHistError & instance()
Return a reference to a singleton object that is created the first time this method is called.
A RooHist is a graphical representation of binned data based on the TGraphAsymmErrors class.
void addAsymmetryBinWithError(Axis_t binCenter, Double_t n1, Double_t n2, Double_t en1, Double_t en2, Double_t binWidth=0, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0)
Add a bin to this histogram with the value (n1-n2)/(n1+n2) using an error bar calculated with Binomia...
RooHist * makeResidHist(const RooCurve &curve, bool normalize=false, bool useAverage=false) const
Create and return RooHist containing residuals w.r.t to given curve.
Double_t _nominalBinWidth
void addEfficiencyBin(Axis_t binCenter, Int_t n1, Int_t n2, Double_t binWidth=0, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0)
Add a bin to this histogram with the value n1/(n1+n2) using an error bar calculated with Binomial sta...
void fillResidHist(RooHist &residHist, const RooCurve &curve, bool normalize=false, bool useAverage=false) const
Double_t getFitRangeNEvt() const
Return the number of events of the dataset associated with this RooHist.
virtual void printTitle(std::ostream &os) const
Print title of RooHist.
Int_t roundBin(Double_t y)
Return the nearest positive integer to the input value and print a warning if an adjustment is requir...
void initialize()
Perform common initialization for all constructors.
RooHist()
Default constructor.
virtual void printName(std::ostream &os) const
Print name of RooHist.
void addBinWithError(Axis_t binCenter, Double_t n, Double_t elow, Double_t ehigh, Double_t binWidth=0, Double_t xErrorFrac=1.0, Bool_t correctForBinWidth=kTRUE, Double_t scaleFactor=1.0)
Add a bin to this histogram with the specified bin contents and error.
virtual void printMultiline(std::ostream &os, Int_t content, Bool_t verbose=kFALSE, TString indent="") const
Print info about this histogram to the specified output stream.
void addEfficiencyBinWithError(Axis_t binCenter, Double_t n1, Double_t n2, Double_t en1, Double_t en2, Double_t binWidth=0, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0)
Add a bin to this histogram with the value n1/(n1+n2) using an error bar calculated with Binomial sta...
Bool_t isIdentical(const RooHist &other, Double_t tol=1e-6, bool verbose=true) const
Return kTRUE if contents of this RooHist is identical within given relative tolerance to that of 'oth...
void addBin(Axis_t binCenter, Double_t n, Double_t binWidth=0, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0)
Add a bin to this histogram with the specified integer bin contents and using an error bar calculated...
Double_t getNominalBinWidth() const
std::unique_ptr< RooHist > createEmptyResidHist(const RooCurve &curve, bool normalize=false) const
virtual void printClassName(std::ostream &os) const
Print class name of RooHist.
Double_t getFitRangeBinW() const
Return (average) bin width of this RooHist.
void addAsymmetryBin(Axis_t binCenter, Int_t n1, Int_t n2, Double_t binWidth=0, Double_t xErrorFrac=1.0, Double_t scaleFactor=1.0)
Add a bin to this histogram with the value (n1-n2)/(n1+n2) using an error bar calculated with Binomia...
Bool_t hasIdenticalBinning(const RooHist &other) const
Return kTRUE if binning of this RooHist is identical to that of 'other'.
void addBinWithXYError(Axis_t binCenter, Double_t n, Double_t exlow, Double_t exhigh, Double_t eylow, Double_t eyhigh, Double_t scaleFactor=1.0)
Add a bin to this histogram with the specified bin contents and error.
void updateYAxisLimits(Double_t y)
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print detailed information.
void setYAxisLabel(const char *label)
const char * getYAxisLabel() const
Lightweight RooAbsFunction implementation that applies a constant scale factor to another RooAbsFunc.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Class to manage histogram axis.
const char * GetTitle() const
Returns title of object.
TGraph with asymmetric error bars.
Double_t * fEXhigh
[fNpoints] array of X high errors
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 GetErrorYhigh(Int_t i) const
Get high error on Y.
Double_t * fEYhigh
[fNpoints] array of Y high errors
Double_t GetErrorYlow(Int_t i) const
Get low error on Y.
Double_t GetErrorXlow(Int_t i) const
Get low error on X.
Double_t * fEYlow
[fNpoints] array of Y low errors
Double_t GetErrorXhigh(Int_t i) const
Get high error on X.
Double_t * fEXlow
[fNpoints] array of X low errors
Double_t GetErrorY(Int_t bin) const
It returns the error along Y at point i.
Double_t GetErrorX(Int_t bin) const
It returns the error along X at point i.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
virtual void SetName(const char *name="")
Set graph name.
virtual void SetTitle(const char *title="")
Change (i.e.
Double_t * fY
[fNpoints] array of Y points
Double_t * fX
[fNpoints] array of X points
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
Get x and y values for point number i.
1-D histogram with a float per channel (see TH1 documentation)}
TH1 is the base class of all histogram classes in ROOT.
virtual Double_t GetBinCenter(Int_t bin) const
Return bin center for 1D histogram.
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
virtual Int_t GetNbinsX() const
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width for 1D histogram.
virtual Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const
Statistical test of compatibility in shape between this histogram and h2, using Kolmogorov test.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
const char * Data() const
TString & Append(const char *cs)
static uint64_t sum(uint64_t i)