91 auto biter = boundaries->begin() ;
92 _binw.reserve(boundaries->size()-1) ;
93 double lastBound = (*biter) ;
95 while (biter!=boundaries->end()) {
96 _binw.push_back((*biter) - lastBound);
97 lastBound = (*biter) ;
133 auto testStat =
new RooNLLVar(
name, title, thePdf, adata, projDeps, extendedPdf, cfg);
149 for (
int i=0 ; i<
_nCPU ; i++)
175 double sumWeight{0.0};
183 for (
auto i=firstEvent ; i<lastEvent ; i+=stepSize) {
191 double N = eventWeight ;
198 logEvalError(
Form(
"Observed %f events in bin %lu with zero event yield",
N,(
unsigned long)i)) ;
200 }
else if (std::abs(mu)<1
e-10 && std::abs(
N)<1
e-10) {
209 term -= -mu +
N +
N * (std::log(mu) - std::log(
N));
214 sumWeightKahanSum += eventWeight;
219 sumWeight = sumWeightKahanSum.Sum();
252 coutI(Minimization) <<
"RooNLLVar::evaluatePartition(" <<
GetName() <<
") first = "<< firstEvent <<
" last = " << lastEvent <<
" Likelihood offset now set to " <<
result.Sum() << std::endl ;
270 RooArgSet *normSet,
bool weightSq, std::size_t stepSize,
271 std::size_t firstEvent, std::size_t lastEvent,
RooAbsPdf const* offsetPdf)
277 for (
auto i=firstEvent; i<lastEvent; i+=stepSize) {
280 double weight = dataClone->
weight();
282 if (0. == weight * weight) continue ;
285 double logProba = pdfClone->
getLogVal(normSet);
288 logProba -= offsetPdf->
getLogVal(normSet);
291 const double term = -weight * logProba;
293 kahanWeight.
Add(weight);
303 return {kahanProb, kahanWeight.
Sum()};
325 bool needsResetting =
true;
333 needsResetting =
false;
337 for (
int i = 0; i <
_nCPU; ++i) {
340 needsResetting =
false;
349 std::string
name = std::string{
GetName()} +
"_offsetPdf";
350 std::unique_ptr<RooDataHist> dataTemplate;
352 dataTemplate = std::make_unique<RooDataHist>(*dh);
354 dataTemplate = std::unique_ptr<RooDataHist>(
static_cast<RooDataSet const &
>(*_dataClone).
binnedClone());
RooAbsReal * _funcClone
Pointer to internal clone of input function.
bool _weightSq
Apply weights squared?
std::vector< double > _binw
!
ROOT::Math::KahanSum< double > _offsetSaveW2
!
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 result
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
void Add(T x)
Single-element accumulation. Will not vectorise.
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
Storage_t::size_type size() const
RooAbsArg * first() const
Abstract base class for binned and unbinned datasets.
virtual double weight() const =0
virtual const RooArgSet * get() const
virtual double weightSquared() const =0
Abstract base class for test statistics objects that evaluate a function or PDF at each point of a gi...
bool setDataSlave(RooAbsData &data, bool cloneData=true, bool ownNewDataAnyway=false) override
Change dataset that is used to given one.
RooAbsReal * _funcClone
Pointer to internal clone of input function.
bool _skipZeroWeights
! Whether to skip entries with weight zero in the evaluation
RooArgSet * _funcObsSet
List of observables in the pdf expression.
RooArgSet * _normSet
Pointer to set with observables used for normalization.
RooAbsData * _dataClone
Pointer to internal clone if input data.
Abstract interface for all probability density functions.
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
virtual double getLogVal(const RooArgSet *set=nullptr) const
Return the log of the current value with given normalization An error message is printed if the argum...
Abstract base class for objects that represent a real value and implements functionality common to al...
virtual std::list< double > * binBoundaries(RooAbsRealLValue &obs, double xlo, double xhi) const
Retrieve bin boundaries if this distribution is binned in obs.
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
void logEvalError(const char *message, const char *serverValueString=nullptr) const
Log evaluation error message.
Abstract base class for all test statistics.
Int_t _setNum
Partition number of this instance in parallel calculation mode.
double _evalCarry
! carry of Kahan sum in evaluatePartition
GOFOpMode operMode() const
Int_t _nCPU
Number of processors to use in parallel calculation mode.
GOFOpMode _gofOpMode
Operation mode of test statistic instance.
bool _init
! Is object initialized
Int_t _simCount
Total number of component p.d.f.s in RooSimultaneous (if any)
ROOT::Math::KahanSum< double > _offset
! Offset as KahanSum to avoid loss of precision
Int_t _extSet
! Number of designated set to calculated extended term
std::vector< std::unique_ptr< RooAbsTestStatistic > > _gofArray
! Array of sub-contexts representing part of the combined test statistic
bool initialize()
One-time initialization of the test statistic.
pRooRealMPFE * _mpfeArray
! Array of parallel execution frond ends
bool _doOffset
Apply interval value offset to control numeric precision?
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Container class to hold N-dimensional binned data.
Container class to hold unbinned data.
RooFit::OwningPtr< RooDataHist > binnedClone(const char *newName=nullptr, const char *newTitle=nullptr) const
Return binned clone of this dataset.
Implements a -log(likelihood) calculation from a dataset and a PDF.
ComputeResult computeScalar(std::size_t stepSize, std::size_t firstEvent, std::size_t lastEvent) const
std::unique_ptr< RooAbsPdf > _offsetPdf
! An optional per-bin likelihood offset
static RooNLLVar::ComputeResult computeScalarFunc(const RooAbsPdf *pdfClone, RooAbsData *dataClone, RooArgSet *normSet, bool weightSq, std::size_t stepSize, std::size_t firstEvent, std::size_t lastEvent, RooAbsPdf const *offsetPdf=nullptr)
ROOT::Math::KahanSum< double > _offsetSaveW2
!
void applyWeightSquared(bool flag) override
Disables or enables the usage of squared weights.
std::vector< double > _binw
!
std::pair< ROOT::Math::KahanSum< double >, double > ComputeResult
bool setDataSlave(RooAbsData &data, bool cloneData=true, bool ownNewDataAnyway=false) override
Change dataset that is used to given one.
RooNLLVar(const char *name, const char *title, RooAbsPdf &pdf, RooAbsData &data, bool extended, RooAbsTestStatistic::Configuration const &cfg=RooAbsTestStatistic::Configuration{})
Construct likelihood from given p.d.f and (binned or unbinned dataset) For internal use.
RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &pdf, RooAbsData &adata, const RooArgSet &projDeps, RooAbsTestStatistic::Configuration const &cfg) override
Create a test statistic using several properties of the current instance.
void enableBinOffsetting(bool on=true)
bool _weightSq
Apply weights squared?
double evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const override
Calculate and return likelihood on subset of data.
Implements a PDF constructed from a sum of functions:
Variable that can be changed from the outside.
const char * GetName() const override
Returns name of object.
Double_t LnGamma(Double_t z)
Computation of ln[gamma(z)] for all z.
Little struct that can pack a float into the unused bits of the mantissa of a NaN double.
float getPayload() const
Retrieve packed float.
double getNaNWithPayload() const
Retrieve a NaN with the current float payload packed into the mantissa.
void accumulate(double val)
Accumulate a packed float from another NaN into this.