37namespace TestStatistics {
40 bool useBatchedEvaluations)
42 useBatchedEvaluations_(useBatchedEvaluations)
45 paramTracker_ = std::make_unique<RooChangeTracker>(
"chtracker",
"change tracker",*params,
true);
49 :
RooAbsL(other), apply_weight_squared(other.apply_weight_squared), _first(other._first),
50 useBatchedEvaluations_(other.useBatchedEvaluations_)
96 std::unique_ptr<RooBatchCompute::RunContext> evalData;
113 if (eventWeights.
empty()) {
117 for (std::size_t i = 0; i < eventWeights.
size(); ++i) {
118 kahanWeight.
AddIndexed(eventWeights[i] * eventWeights[i], i);
120 sumW2 = kahanWeight.
Sum();
124 for (
Int_t i = 0; i <
data_->numEntries(); i++) {
126 sumW2KahanSum +=
data_->weightSquared();
128 sumW2 = sumW2KahanSum.
Sum();
148 Double_t expectedW2 = expected * sumW2 /
data_->sumEntries();
149 Double_t extra = expectedW2 - sumW2 * log(expected);
168 pdf_->wireAllCaches();
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
void AddIndexed(T input, std::size_t index)
Add input to the sum.
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.
std::shared_ptr< RooAbsData > data_
std::unique_ptr< RooArgSet > normSet_
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 ...
void setUseBatchedEvaluations(bool flag)
std::unique_ptr< RooChangeTracker > paramTracker_
bool apply_weight_squared
bool useBatchedEvaluations_
RooUnbinnedL(RooAbsPdf *pdf, RooAbsData *data, RooAbsL::Extended extended=RooAbsL::Extended::Auto, bool useBatchedEvaluations=false)
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)
static RooNLLVar::ComputeResult computeBatchedFunc(const RooAbsPdf *pdfClone, RooAbsData *dataClone, std::unique_ptr< RooBatchCompute::RunContext > &evalData, RooArgSet *normSet, bool weightSq, std::size_t stepSize, std::size_t firstEvent, std::size_t lastEvent)
A simple container to hold a batch of data values.
constexpr std::span< T >::index_type size() const noexcept
constexpr bool empty() const noexcept
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Convenience wrapper class used to distinguish between pdf/data owning and non-owning constructors.
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