71 bool correctForBinWidth,
double scaleFactor)
75 throw std::invalid_argument(
76 "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.");
123 double xErrorFrac,
bool efficiency,
double scaleFactor)
146 coutE(InputArguments) <<
"RooHist::RooHist: histograms have different number of bins" << std::endl;
151 if(std::abs(
data2.GetBinCenter(
bin)-
x)>1
e-10) {
152 coutW(InputArguments) <<
"RooHist::RooHist: histograms have different centers for bin " <<
bin << std::endl;
197 : _nominalBinWidth(
hist1._nominalBinWidth), _nSigma(
hist1._nSigma), _rawEntries(-1)
209 coutE(InputArguments) <<
"RooHist::RooHist input histograms have incompatible binning, combined histogram will remain empty" << std::endl ;
218 coutW(InputArguments) <<
"RooHist::RooHist: WARNING: Poisson errors of weighted sum of two histograms is not well defined! " << std::endl
219 <<
" Summed histogram bins will rounded to nearest integer for Poisson confidence interval calculation" << std::endl ;
225 for(i=0 ; i<
n ; i++) {
243 for(i=0 ; i<
n ; i++) {
281 : _nSigma(1), _rawEntries(-1)
285 std::string title{
f.GetTitle()};
291 title +=
f.getUnit();
296 title +=
x.getUnit();
312 if (
x.numBins() == 0) {
319 for(
int i=0; i<xbins; ++i){
325 if(fr)
yerr =
f.getPropagatedError(*fr,nset);
359 for (
int i=0 ; i<
GetN() ; i++) {
365 if (
x>=xlo &&
x<=xhi) {
376 coutW(Plotting) <<
"RooHist::getFitRangeNEvt() WARNING: The number of normalisation events associated to histogram " <<
GetName() <<
" is not equal to number of events in this histogram."
377 <<
"\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"
378 <<
"\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:"
379 <<
"\n\t\t\t data->plotOn(frame01,CutRange(\"SB1\"));"
380 <<
"\n\t\t\t const double nData = data->sumEntries(\"\", \"SB1\"); //or the cut string such as sumEntries(\"x > 0.\");"
381 <<
"\n\t\t\t model.plotOn(frame01, RooFit::Normalization(nData, RooAbsReal::NumEvent), ProjectionRange(\"SB1\"));" << std::endl ;
396 coutW(Plotting) <<
fName <<
"::roundBin: rounding negative bin contents to zero: " <<
y << std::endl;
400 if(std::abs(
y-
n)>1
e-6) {
401 coutW(Plotting) <<
fName <<
"::roundBin: rounding non-integer bin contents: " <<
y << std::endl;
413 if(std::abs(
yscale) < 0) {
438 coutW(Plotting) <<
"RooHist::addBin(" <<
GetName() <<
") WARNING: negative entry set to zero when Poisson error bars are requested" << std::endl ;
450 double dx(0.5 * binWidth);
452 if (std::abs((
double)((
n-
Int_t(
n))>1
e-5))) {
462 coutE(Plotting) <<
"RooHist::addBin: unable to add bin with " <<
n <<
" events" << std::endl;
467 <<
") WARNING: non-integer bin entry " <<
n <<
" with Poisson errors, interpolating between Poisson errors of adjacent integer" << std::endl ;
471 coutE(Plotting) <<
"RooHist::addBin: unable to add bin with " <<
n <<
" events" << std::endl;
487 double xErrorFrac,
bool correctForBinWidth,
double scaleFactor)
490 if(binWidth > 0 && correctForBinWidth) {
495 double dx(0.5*binWidth) ;
528 double dx(0.5 * binWidth);
530 coutE(Plotting) <<
"RooHist::addAsymmetryBin: unable to calculate binomial error for bin with " <<
n1 <<
"," <<
n2 <<
" events" << std::endl;
535 double a = 0 == denominator ? 0. : (
double)(
n1 -
n2) / (denominator);
550 double dx(0.5 * binWidth);
553 double error = 2*sqrt( pow(
en1,2)*pow(
n2,2) + pow(
en2,2)*pow(
n1,2) ) / pow(
n1+
n2,2) ;
573 double dx(0.5 * binWidth);
575 coutE(Plotting) <<
"RooHist::addEfficiencyBin: unable to calculate binomial error for bin with " <<
n1 <<
"," <<
n2 <<
" events" << std::endl;
592 double error = sqrt( pow(
en1,2)*pow(
n2,2) + pow(
en2,2)*pow(
n1,2) ) / pow(
n1+
n2,2) ;
597 double dx(0.5 * binWidth);
618 for (i=0 ; i<
GetN() ; i++) {
657 if(verbose) std::cout <<
"RooHist::isIdentical() tolerance exceeded M=" << M <<
" (tol=" <<
tol <<
"), corresponding prob = " <<
kprob << std::endl ;
676 os <<
indent <<
"--- RooHist ---" << std::endl;
678 os <<
indent <<
" Contains " <<
n <<
" bins" << std::endl;
680 os <<
indent <<
" Errors calculated at" <<
_nSigma <<
"-sigma CL" << std::endl;
681 os <<
indent <<
" Bin Contents:" << std::endl;
682 for(
Int_t i= 0; i <
n; i++) {
683 os <<
indent << std::setw(3) << i <<
") x= " <<
fX[i];
687 os <<
" , y = " <<
fY[i] <<
" +" <<
fEYhigh[i] <<
" -" <<
fEYlow[i] << std::endl;
728 const std::string title =
GetTitle() + std::string(
" and ") +
curve.GetTitle();
729 hist->SetName(((normalize ?
"pull_" :
"resid_") +
name).c_str()) ;
730 hist->SetTitle(((normalize ?
"Pull of " :
"Residual of ") + title).c_str()) ;
772 coutW(Plotting) <<
"RooHist::makeResisHist(" <<
GetName() <<
") WARNING: point " << i <<
" has zero error, setting residual to zero" << std::endl;
int Int_t
Signed integer 4 bytes (int)
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t SetMarkerStyle
Option_t Option_t TPoint TPoint const char y1
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Abstract base class for RooRealVar binning definitions.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
static constexpr int DefaultNBins
Historical default number of bins, injected by routines that need a concrete bin count when a variabl...
Abstract base class for objects that represent a real value and implements functionality common to al...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
One-dimensional graphical representation of a real-valued function.
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.
Graphical representation of binned data based on the TGraphAsymmErrors class.
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 _nominalBinWidth
Average bin width.
double _rawEntries
Number of entries in source dataset.
void printClassName(std::ostream &os) const override
Print class name of RooHist.
void addEfficiencyBin(Axis_t binCenter, Int_t n1, Int_t n2, double binWidth=0, double xErrorFrac=1.0, double 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
void initialize()
Perform common initialization for all constructors.
void addBinWithError(Axis_t binCenter, double n, double elow, double ehigh, double binWidth=0, double xErrorFrac=1.0, bool correctForBinWidth=true, double scaleFactor=1.0)
Add a bin to this histogram with the specified bin contents and error.
void addEfficiencyBinWithError(Axis_t binCenter, double n1, double n2, double en1, double en2, double binWidth=0, double xErrorFrac=1.0, double scaleFactor=1.0)
Add a bin to this histogram with the value n1/(n1+n2) using an error bar calculated with Binomial sta...
void printName(std::ostream &os) const override
Print name of RooHist.
void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const override
Print info about this histogram to the specified output stream.
std::unique_ptr< RooHist > createEmptyResidHist(const RooCurve &curve, bool normalize=false) const
void printTitle(std::ostream &os) const override
Print title of RooHist.
std::vector< double > _originalWeights
The original bin weights that were passed to the RooHist::addBin functions before scaling and bin wid...
double getNominalBinWidth() const
void addAsymmetryBinWithError(Axis_t binCenter, double n1, double n2, double en1, double en2, double binWidth=0, double xErrorFrac=1.0, double scaleFactor=1.0)
Add a bin to this histogram with the value (n1-n2)/(n1+n2) using an error bar calculated with Binomia...
double _entries
Number of entries in histogram.
Int_t roundBin(double y)
Return the nearest positive integer to the input value and print a warning if an adjustment is requir...
bool isIdentical(const RooHist &other, double tol=1e-6, bool verbose=true) const
Return true if contents of this RooHist is identical within given relative tolerance to that of 'othe...
void addAsymmetryBin(Axis_t binCenter, Int_t n1, Int_t n2, double binWidth=0, double xErrorFrac=1.0, double scaleFactor=1.0)
Add a bin to this histogram with the value (n1-n2)/(n1+n2) using an error bar calculated with Binomia...
double _nSigma
Number of 'sigmas' error bars represent.
void addBin(Axis_t binCenter, double n, double binWidth=0, double xErrorFrac=1.0, double scaleFactor=1.0)
Add a bin to this histogram with the specified integer bin contents and using an error bar calculated...
void addPoint(Axis_t binCenter, double y, double yscale, double exlow, double exhigh, double eylow, double eyhigh)
bool hasIdenticalBinning(const RooHist &other) const
Return true if binning of this RooHist is identical to that of 'other'.
double getFitRangeNEvt() const override
Return the number of events of the dataset associated with this RooHist.
void addBinWithXYError(Axis_t binCenter, double n, double exlow, double exhigh, double eylow, double eyhigh, double scaleFactor=1.0)
Add a bin to this histogram with the specified bin contents and error.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print detailed information.
void updateYAxisLimits(double y)
void setYAxisLabel(const char *label)
Represents the product of a given set of RooAbsReal objects.
Class to manage histogram axis.
TDirectory::TContext keeps track and restore the current directory.
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 GetErrorXhigh(Int_t i) const override
Get high error on X.
Double_t * fEYhigh
[fNpoints] array of Y high errors
Double_t GetErrorYhigh(Int_t i) const override
Get high error on Y.
Double_t GetErrorXlow(Int_t i) const override
Get low error on X.
Double_t * fEYlow
[fNpoints] array of Y low errors
Double_t * fEXlow
[fNpoints] array of X low errors
Double_t GetErrorYlow(Int_t i) const override
Get low error on Y.
Double_t GetErrorX(Int_t bin) const override
Returns the combined error along X at point i by computing the average of the lower and upper varianc...
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Double_t * fY
[fNpoints] array of Y points
void SetName(const char *name="") override
Set graph name.
Double_t * fX
[fNpoints] array of X points
void SetTitle(const char *title="") override
Change (i.e.
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.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
RooConstVar & RooConst(double val)
static uint64_t sum(uint64_t i)