37#include "../RooFit/BatchModeDataHelpers.h"
40namespace TestStatistics {
58 :
RooAbsL(clonePdfData(*pdf, *
data, evalBackend),
data->numEntries(), 1, extended)
61 paramTracker_ = std::make_unique<RooChangeTracker>(
"chtracker",
"change tracker", *params,
true);
69 for (
auto const &item : dataSpans) {
70 evaluator_->setInput(item.first->GetName(), item.second,
false);
77 apply_weight_squared(other.apply_weight_squared),
79 lastSection_(other.lastSection_),
80 cachedResult_(other.cachedResult_),
81 evaluator_(other.evaluator_)
105 std::size_t stepSize, std::size_t firstEvent, std::size_t lastEvent)
111 for (
auto i = firstEvent; i < lastEvent; i += stepSize) {
114 double weight = dataClone->
weight();
116 if (0. == weight * weight)
121 double logProba = std::log(probas[i]);
122 const double term = -weight * logProba;
124 kahanWeight.
Add(weight);
126 packedNaN.accumulate(term);
129 if (packedNaN.getPayload() != 0.) {
134 return {kahanProb, kahanWeight.
Sum()};
163 std::span<const double> probas =
evaluator_->run();
164 std::tie(
result, sumWeight) =
168 std::tie(
result, sumWeight) =
188 pdf_->wireAllCaches();
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 Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
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 > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual double weight() const =0
virtual const RooArgSet * get() const
virtual double weightSquared() const =0
std::shared_ptr< RooAbsData > data_
std::unique_ptr< RooArgSet > normSet_
Pointer to set with observables used for normalization.
std::shared_ptr< RooAbsPdf > pdf_
ROOT::Math::KahanSum< double > cachedResult_
bool setApplyWeightSquared(bool flag)
Returns true if value was changed, false otherwise.
ROOT::Math::KahanSum< double > evaluatePartition(Section events, std::size_t components_begin, std::size_t components_end) override
Calculate and return likelihood on subset of data from firstEvent to lastEvent processed with a step ...
std::unique_ptr< RooChangeTracker > paramTracker_
bool apply_weight_squared
Apply weights squared?
RooUnbinnedL(RooAbsPdf *pdf, RooAbsData *data, RooAbsL::Extended extended=RooAbsL::Extended::Auto, RooFit::EvalBackend evalBackend=RooFit::EvalBackend::Legacy())
std::stack< std::vector< double > > _vectorBuffers
std::shared_ptr< RooFit::Evaluator > evaluator_
! For batched evaluation
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)
std::pair< ROOT::Math::KahanSum< double >, double > ComputeResult
std::map< RooFit::Detail::DataKey, std::span< const double > > getDataSpans(RooAbsData const &data, std::string const &rangeName, RooSimultaneous const *simPdf, bool skipZeroWeights, bool takeGlobalObservablesFromData, std::stack< std::vector< double > > &buffers)
Extract all content from a RooFit datasets as a map of spans.
std::unique_ptr< T > compileForNormSet(T const &arg, RooArgSet const &normSet)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
A part of some range delimited by two fractional points between 0 and 1 (inclusive).
std::size_t begin(std::size_t N_total) const
std::size_t end(std::size_t N_total) const
Little struct that can pack a float into the unused bits of the mantissa of a NaN double.