Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooNLLVar.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooNLLVar.cxx
19\class RooNLLVar
20\ingroup Roofitcore
21
22Class RooNLLVar implements a -log(likelihood) calculation from a dataset
23and a PDF. The NLL is calculated as
24\f[
25 \sum_\mathrm{data} -\log( \mathrm{pdf}(x_\mathrm{data}))
26\f]
27In extended mode, a
28\f$ N_\mathrm{expect} - N_\mathrm{observed}*log(N_\mathrm{expect}) \f$ term is added.
29**/
30
31#include "RooNLLVar.h"
32
33#include "RooAbsData.h"
34#include "RooAbsPdf.h"
35#include "RooCmdConfig.h"
36#include "RooMsgService.h"
37#include "RooAbsDataStore.h"
38#include "RooRealMPFE.h"
39#include "RooRealSumPdf.h"
40#include "RooRealVar.h"
41#include "RooProdPdf.h"
42#include "RooNaNPacker.h"
43#include "RunContext.h"
44
45#ifdef ROOFIT_CHECK_CACHED_VALUES
46#include <iomanip>
47#endif
48
49#include "TMath.h"
50#include "Math/Util.h"
51
52#include <algorithm>
53
54namespace {
55 template<class ...Args>
56 RooAbsTestStatistic::Configuration makeRooAbsTestStatisticCfg(Args const& ... args) {
58 cfg.rangeName = RooCmdConfig::decodeStringOnTheFly("RooNLLVar::RooNLLVar","RangeWithName",0,"",args...);
59 cfg.addCoefRangeName = RooCmdConfig::decodeStringOnTheFly("RooNLLVar::RooNLLVar","AddCoefRange",0,"",args...);
60 cfg.nCPU = RooCmdConfig::decodeIntOnTheFly("RooNLLVar::RooNLLVar","NumCPU",0,1,args...);
62 cfg.verbose = static_cast<bool>(RooCmdConfig::decodeIntOnTheFly("RooNLLVar::RooNLLVar","Verbose",0,1,args...));
63 cfg.splitCutRange = static_cast<bool>(RooCmdConfig::decodeIntOnTheFly("RooNLLVar::RooNLLVar","SplitRange",0,0,args...));
64 cfg.cloneInputData = static_cast<bool>(RooCmdConfig::decodeIntOnTheFly("RooNLLVar::RooNLLVar","CloneData",0,1,args...));
65 cfg.integrateOverBinsPrecision = RooCmdConfig::decodeDoubleOnTheFly("RooNLLVar::RooNLLVar", "IntegrateBins", 0, -1., {args...});
66 return cfg;
67 }
68}
69
71
74
76
77////////////////////////////////////////////////////////////////////////////////
78/// Construct likelihood from given p.d.f and (binned or unbinned dataset)
79///
80/// Argument | Description
81/// -------------------------|------------
82/// Extended() | Include extended term in calculation
83/// NumCPU() | Activate parallel processing feature
84/// Range() | Fit only selected region
85/// SumCoefRange() | Set the range in which to interpret the coefficients of RooAddPdf components
86/// SplitRange() | Fit range is split by index category of simultaneous PDF
87/// ConditionalObservables() | Define conditional observables
88/// Verbose() | Verbose output of GOF framework classes
89/// CloneData() | Clone input dataset for internal use (default is true)
90/// BatchMode() | Evaluate batches of data events (faster if PDFs support it)
91/// IntegrateBins() | Integrate PDF within each bin. This sets the desired precision. Only useful for binned fits.
92RooNLLVar::RooNLLVar(const char *name, const char* title, RooAbsPdf& pdf, RooAbsData& indata,
93 const RooCmdArg& arg1, const RooCmdArg& arg2,const RooCmdArg& arg3,
94 const RooCmdArg& arg4, const RooCmdArg& arg5,const RooCmdArg& arg6,
95 const RooCmdArg& arg7, const RooCmdArg& arg8,const RooCmdArg& arg9) :
96 RooAbsOptTestStatistic(name,title,pdf,indata,
97 *static_cast<const RooArgSet*>(RooCmdConfig::decodeObjOnTheFly(
98 "RooNLLVar::RooNLLVar","ProjectedObservables",0,&_emptySet,
99 arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)),
100 makeRooAbsTestStatisticCfg(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9))
101{
102 RooCmdConfig pc("RooNLLVar::RooNLLVar") ;
103 pc.allowUndefined() ;
104 pc.defineInt("extended","Extended",0,false) ;
105 pc.defineInt("BatchMode", "BatchMode", 0, false);
106
107 pc.process(arg1) ; pc.process(arg2) ; pc.process(arg3) ;
108 pc.process(arg4) ; pc.process(arg5) ; pc.process(arg6) ;
109 pc.process(arg7) ; pc.process(arg8) ; pc.process(arg9) ;
110
111 _extended = pc.getInt("extended") ;
112 _batchEvaluations = pc.getInt("BatchMode");
113}
114
115
116////////////////////////////////////////////////////////////////////////////////
117/// Construct likelihood from given p.d.f and (binned or unbinned dataset)
118/// For internal use.
119
120RooNLLVar::RooNLLVar(const char *name, const char *title, RooAbsPdf& pdf, RooAbsData& indata,
121 bool extended, RooAbsTestStatistic::Configuration const& cfg) :
122 RooNLLVar{name, title, pdf, indata, RooArgSet(), extended, cfg} {}
123
124
125////////////////////////////////////////////////////////////////////////////////
126/// Construct likelihood from given p.d.f and (binned or unbinned dataset)
127/// For internal use.
128
129RooNLLVar::RooNLLVar(const char *name, const char *title, RooAbsPdf& pdf, RooAbsData& indata,
130 const RooArgSet& projDeps,
131 bool extended, RooAbsTestStatistic::Configuration const& cfg) :
132 RooAbsOptTestStatistic(name,title,pdf,indata,projDeps, cfg),
133 _extended(extended)
134{
135 // If binned likelihood flag is set, pdf is a RooRealSumPdf representing a yield vector
136 // for a binned likelihood calculation
137 _binnedPdf = cfg.binnedL ? static_cast<RooRealSumPdf*>(_funcClone) : nullptr ;
138
139 // Retrieve and cache bin widths needed to convert un-normalized binnedPdf values back to yields
140 if (_binnedPdf) {
141
142 // The Active label will disable pdf integral calculations
143 _binnedPdf->setAttribute("BinnedLikelihoodActive") ;
144
145 RooArgSet obs;
147 if (obs.size()!=1) {
148 _binnedPdf = nullptr;
149 } else {
150 auto* var = static_cast<RooRealVar*>(obs.first());
151 std::unique_ptr<std::list<Double_t>> boundaries{_binnedPdf->binBoundaries(*var,var->getMin(),var->getMax())};
152 auto biter = boundaries->begin() ;
153 _binw.reserve(boundaries->size()-1) ;
154 double lastBound = (*biter) ;
155 ++biter ;
156 while (biter!=boundaries->end()) {
157 _binw.push_back((*biter) - lastBound);
158 lastBound = (*biter) ;
159 ++biter ;
160 }
161 }
162 }
163}
164
165
166
167////////////////////////////////////////////////////////////////////////////////
168/// Copy constructor
169
170RooNLLVar::RooNLLVar(const RooNLLVar& other, const char* name) :
172 _extended(other._extended),
173 _batchEvaluations(other._batchEvaluations),
174 _weightSq(other._weightSq),
175 _offsetSaveW2(other._offsetSaveW2),
176 _binw(other._binw),
177 _binnedPdf{other._binnedPdf}
178{
179}
180
181
182////////////////////////////////////////////////////////////////////////////////
183/// Create a test statistic using several properties of the current instance. This is used to duplicate
184/// the test statistic in multi-processing scenarios.
185RooAbsTestStatistic* RooNLLVar::create(const char *name, const char *title, RooAbsReal& pdf, RooAbsData& adata,
186 const RooArgSet& projDeps, RooAbsTestStatistic::Configuration const& cfg) {
187 RooAbsPdf & thePdf = dynamic_cast<RooAbsPdf&>(pdf);
188 // check if pdf can be extended
189 bool extendedPdf = _extended && thePdf.canBeExtended();
190
191 auto testStat = new RooNLLVar(name, title, thePdf, adata, projDeps, extendedPdf, cfg);
192 testStat->batchMode(_batchEvaluations);
193 return testStat;
194}
195
196
197////////////////////////////////////////////////////////////////////////////////
198
200{
201 if (_gofOpMode==Slave) {
202 if (flag != _weightSq) {
203 _weightSq = flag;
204 std::swap(_offset, _offsetSaveW2);
205 }
207 } else if ( _gofOpMode==MPMaster) {
208 for (int i=0 ; i<_nCPU ; i++)
209 _mpfeArray[i]->applyNLLWeightSquared(flag);
210 } else if ( _gofOpMode==SimMaster) {
211 for (int i=0 ; i<_nGof ; i++)
212 static_cast<RooNLLVar*>(_gofArray[i])->applyWeightSquared(flag);
213 }
214}
215
216
217////////////////////////////////////////////////////////////////////////////////
218/// Calculate and return likelihood on subset of data.
219/// \param[in] firstEvent First event to be processed.
220/// \param[in] lastEvent First event not to be processed, any more.
221/// \param[in] stepSize Steps between events.
222/// \note For batch computations, the step size **must** be one.
223///
224/// If this an extended likelihood, the extended term is added to the return likelihood
225/// in the batch that encounters the event with index 0.
226
227Double_t RooNLLVar::evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const
228{
229 // Throughout the calculation, we use Kahan's algorithm for summing to
230 // prevent loss of precision - this is a factor four more expensive than
231 // straight addition, but since evaluating the PDF is usually much more
232 // expensive than that, we tolerate the additional cost...
234 double sumWeight{0.0};
235
236 auto * pdfClone = static_cast<RooAbsPdf*>(_funcClone);
237
238 // cout << "RooNLLVar::evaluatePartition(" << GetName() << ") projDeps = " << (_projDeps?*_projDeps:RooArgSet()) << endl ;
239
240 _dataClone->store()->recalculateCache( _projDeps, firstEvent, lastEvent, stepSize, (_binnedPdf?false:true) ) ;
241
242
243
244 // If pdf is marked as binned - do a binned likelihood calculation here (sum of log-Poisson for each bin)
245 if (_binnedPdf) {
246 ROOT::Math::KahanSum<double> sumWeightKahanSum{0.0};
247 for (auto i=firstEvent ; i<lastEvent ; i+=stepSize) {
248
249 _dataClone->get(i) ;
250
251 if (!_dataClone->valid()) continue;
252
253 double eventWeight = _dataClone->weight();
254
255
256 // Calculate log(Poisson(N|mu) for this bin
257 double N = eventWeight ;
258 double mu = _binnedPdf->getVal()*_binw[i] ;
259 //cout << "RooNLLVar::binnedL(" << GetName() << ") N=" << N << " mu = " << mu << endl ;
260
261 if (mu<=0 && N>0) {
262
263 // Catch error condition: data present where zero events are predicted
264 logEvalError(Form("Observed %f events in bin %lu with zero event yield",N,(unsigned long)i)) ;
265
266 } else if (std::abs(mu)<1e-10 && std::abs(N)<1e-10) {
267
268 // Special handling of this case since log(Poisson(0,0)=0 but can't be calculated with usual log-formula
269 // since log(mu)=0. No update of result is required since term=0.
270
271 } else {
272
273 result += -1*(-mu + N * std::log(mu) - TMath::LnGamma(N+1));
274 sumWeightKahanSum += eventWeight;
275
276 }
277 }
278
279 sumWeight = sumWeightKahanSum.Sum();
280
281 } else { //unbinned PDF
282
283 if (_batchEvaluations) {
284 std::tie(result, sumWeight) = computeBatched(stepSize, firstEvent, lastEvent);
285#ifdef ROOFIT_CHECK_CACHED_VALUES
286
287 ROOT::Math::KahanSum<double> resultScalar, sumWeightScalar;
288 std::tie(resultScalar, sumWeightScalar) = computeScalar(stepSize, firstEvent, lastEvent);
289 double carryScalar = resultScalar.Carry();
290
291 constexpr bool alwaysPrint = false;
292
293 if (alwaysPrint || std::abs(result - resultScalar)/resultScalar > 5.E-15) {
294 std::cerr << "RooNLLVar: result is off\n\t" << std::setprecision(15) << result
295 << "\n\t" << resultScalar << std::endl;
296 }
297
298 if (alwaysPrint || std::abs(carry - carryScalar)/carryScalar > 500.) {
299 std::cerr << "RooNLLVar: carry is far off\n\t" << std::setprecision(15) << carry
300 << "\n\t" << carryScalar << std::endl;
301 }
302
303 if (alwaysPrint || std::abs(sumWeight - sumWeightScalar)/sumWeightScalar > 1.E-15) {
304 std::cerr << "RooNLLVar: sumWeight is off\n\t" << std::setprecision(15) << sumWeight
305 << "\n\t" << sumWeightScalar << std::endl;
306 }
307
308#endif
309 } else { //scalar mode
310 std::tie(result, sumWeight) = computeScalar(stepSize, firstEvent, lastEvent);
311 }
312
313 // include the extended maximum likelihood term, if requested
314 if(_extended && _setNum==_extSet) {
315 result += pdfClone->extendedTerm(*_dataClone, _weightSq);
316 }
317 } //unbinned PDF
318
319
320 // If part of simultaneous PDF normalize probability over
321 // number of simultaneous PDFs: -sum(log(p/n)) = -sum(log(p)) + N*log(n)
322 if (_simCount>1) {
323 result += sumWeight * std::log(static_cast<double>(_simCount));
324 }
325
326
327 // At the end of the first full calculation, wire the caches
328 if (_first) {
329 _first = false ;
331 }
332
333
334 // Check if value offset flag is set.
335 if (_doOffset) {
336
337 // If no offset is stored enable this feature now
338 if (_offset==0 && result !=0 ) {
339 coutI(Minimization) << "RooNLLVar::evaluatePartition(" << GetName() << ") first = "<< firstEvent << " last = " << lastEvent << " Likelihood offset now set to " << result << std::endl ;
340 _offset = result ;
341 }
342
343 // Subtract offset
344 result -= _offset;
345 }
346
347 _evalCarry = result.Carry();
348 return result.Sum() ;
349}
350
351
352////////////////////////////////////////////////////////////////////////////////
353/// Compute probabilites of all data events. Use faster batch interface.
354/// \param[in] stepSize Stride when moving through the dataset.
355/// \note For batch computations, the step size **must** be one.
356/// \param[in] firstEvent First event to be processed.
357/// \param[in] lastEvent First event not to be processed.
358/// \return Tuple with (Kahan sum of probabilities, carry of kahan sum, sum of weights)
359RooNLLVar::ComputeResult RooNLLVar::computeBatched(std::size_t stepSize, std::size_t firstEvent, std::size_t lastEvent) const
360{
361 auto pdfClone = static_cast<const RooAbsPdf*>(_funcClone);
362 return computeBatchedFunc(pdfClone, _dataClone, _evalData, _normSet, _weightSq, stepSize, firstEvent, lastEvent);
363}
364
365// static function, also used from TestStatistics::RooUnbinnedL
367 std::unique_ptr<RooBatchCompute::RunContext> &evalData,
368 RooArgSet *normSet, bool weightSq, std::size_t stepSize,
369 std::size_t firstEvent, std::size_t lastEvent)
370{
371 const auto nEvents = lastEvent - firstEvent;
372
373 if (stepSize != 1) {
374 throw std::invalid_argument(std::string("Error in ") + __FILE__ + ": Step size for batch computations can only be 1.");
375 }
376
377 // Create a RunContext that will own the memory where computation results are stored.
378 // Holding on to this struct in between function calls will make sure that the memory
379 // is only allocated once.
380 if (!evalData) {
381 evalData.reset(new RooBatchCompute::RunContext);
382 }
383 evalData->clear();
384 evalData->spans = dataClone->getBatches(firstEvent, nEvents);
385
386 auto results = pdfClone->getLogProbabilities(*evalData, normSet);
387
388#ifdef ROOFIT_CHECK_CACHED_VALUES
389
390 for (std::size_t evtNo = firstEvent; evtNo < std::min(lastEvent, firstEvent + 10); ++evtNo) {
391 dataClone->get(evtNo);
392 if (dataClone->weight() == 0.) // 0-weight events are not cached, so cannot compare against them.
393 continue;
394
395 assert(dataClone->valid());
396 try {
397 // Cross check results with strict tolerance and complain
398 BatchInterfaceAccessor::checkBatchComputation(*pdfClone, *evalData, evtNo-firstEvent, normSet, 1.E-13);
399 } catch (std::exception& e) {
400 std::cerr << __FILE__ << ":" << __LINE__ << " ERROR when checking batch computation for event " << evtNo << ":\n"
401 << e.what() << std::endl;
402
403 // It becomes a real problem if it's very wrong. We fail in this case:
404 try {
405 BatchInterfaceAccessor::checkBatchComputation(*pdfClone, *evalData, evtNo-firstEvent, normSet, 1.E-9);
406 } catch (std::exception& e2) {
407 assert(false);
408 }
409 }
410 }
411
412#endif
413
414
415 // Compute sum of event weights. First check if we need squared weights
416 const RooSpan<const double> eventWeights = dataClone->getWeightBatch(firstEvent, nEvents, weightSq);
417
418 //Sum the event weights and probabilities
420 double uniformSingleEventWeight{0.0};
421 double sumOfWeights;
422 if (eventWeights.empty()) {
423 uniformSingleEventWeight = weightSq ? dataClone->weightSquared() : dataClone->weight();
424 sumOfWeights = nEvents * uniformSingleEventWeight;
425 for (std::size_t i = 0; i < results.size(); ++i) { //CHECK_VECTORISE
426 kahanProb.AddIndexed(-uniformSingleEventWeight * results[i], i);
427 }
428 } else {
429 assert(results.size() == eventWeights.size());
431 for (std::size_t i = 0; i < results.size(); ++i) { //CHECK_VECTORISE
432 const double weight = eventWeights[i];
433 kahanProb.AddIndexed(-weight * results[i], i);
434 kahanWeight.AddIndexed(weight, i);
435 }
436 sumOfWeights = kahanWeight.Sum();
437 }
438
439 if (std::isnan(kahanProb.Sum())) {
440 // Special handling of evaluation errors.
441 // We can recover if the bin/event that results in NaN has a weight of zero:
443 RooNaNPacker nanPacker;
444 for (std::size_t i = 0; i < results.size(); ++i) {
445 double weight = eventWeights.empty() ? uniformSingleEventWeight : eventWeights[i];
446
447 if (weight == 0.)
448 continue;
449
450 if (std::isnan(results[i])) {
451 nanPacker.accumulate(results[i]);
452 } else {
453 kahanSanitised += -weight * results[i];
454 }
455 }
456
457 // Some events with evaluation errors. Return "badness" of errors.
458 if (nanPacker.getPayload() > 0.) {
459 return {{nanPacker.getNaNWithPayload()}, sumOfWeights};
460 } else {
461 return {kahanSanitised, sumOfWeights};
462 }
463 }
464
465 return {kahanProb, sumOfWeights};
466}
467
468
469RooNLLVar::ComputeResult RooNLLVar::computeScalar(std::size_t stepSize, std::size_t firstEvent, std::size_t lastEvent) const {
470 auto pdfClone = static_cast<const RooAbsPdf*>(_funcClone);
471 return computeScalarFunc(pdfClone, _dataClone, _normSet, _weightSq, stepSize, firstEvent, lastEvent);
472}
473
474// static function, also used from TestStatistics::RooUnbinnedL
476 RooArgSet *normSet, bool weightSq, std::size_t stepSize,
477 std::size_t firstEvent, std::size_t lastEvent)
478{
481 RooNaNPacker packedNaN(0.f);
482
483 for (auto i=firstEvent; i<lastEvent; i+=stepSize) {
484 dataClone->get(i) ;
485
486 if (!dataClone->valid()) continue;
487
488 double eventWeight = dataClone->weight(); //FIXME
489 if (0. == eventWeight * eventWeight) continue ;
490 if (weightSq) eventWeight = dataClone->weightSquared() ;
491
492 const double term = -eventWeight * pdfClone->getLogVal(normSet);
493
494 kahanWeight.Add(eventWeight);
495 kahanProb.Add(term);
496 packedNaN.accumulate(term);
497 }
498
499 if (packedNaN.getPayload() != 0.) {
500 // Some events with evaluation errors. Return "badness" of errors.
501 return {{packedNaN.getNaNWithPayload()}, kahanWeight.Sum()};
502 }
503
504 return {kahanProb, kahanWeight.Sum()};
505}
#define e(i)
Definition RSha256.hxx:103
#define coutI(a)
double Double_t
Definition RtypesCore.h:59
#define ClassImp(name)
Definition Rtypes.h:364
#define N
char name[80]
Definition TGX11.cxx:110
char * Form(const char *fmt,...)
static void checkBatchComputation(const RooAbsReal &theReal, const RooBatchCompute::RunContext &evalData, std::size_t evtNo, const RooArgSet *normSet=nullptr, double relAccuracy=1.E-13)
Definition RooAbsReal.h:595
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
Definition Util.h:122
T Sum() const
Definition Util.h:240
T Carry() const
Definition Util.h:255
void AddIndexed(T input, std::size_t index)
Add input to the sum.
Definition Util.h:231
void Add(T x)
Single-element accumulation. Will not vectorise.
Definition Util.h:165
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Given a set of possible observables, return the observables that this PDF depends on.
Definition RooAbsArg.h:309
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
void wireAllCaches()
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Definition RooAbsArg.h:505
Storage_t::size_type size() const
RooAbsArg * first() const
virtual void recalculateCache(const RooArgSet *, Int_t, Int_t, Int_t, Bool_t)
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:82
virtual const RooArgSet * get() const
Definition RooAbsData.h:128
RooAbsDataStore * store()
Definition RooAbsData.h:104
virtual Bool_t valid() const
Definition RooAbsData.h:134
RealSpans getBatches(std::size_t first=0, std::size_t len=std::numeric_limits< std::size_t >::max()) const
Write information to retrieve data columns into evalData.spans.
virtual Double_t weight() const =0
virtual Double_t weightSquared() const =0
virtual RooSpan< const double > getWeightBatch(std::size_t first, std::size_t len, bool sumW2=false) const =0
Return event weights of all events in range [first, first+len).
RooAbsOptTestStatistic is the abstract base class for test statistics objects that evaluate a functio...
RooSpan< const double > getLogProbabilities(RooBatchCompute::RunContext &evalData, const RooArgSet *normSet=nullptr) const
Compute the log-likelihoods for all events in the requested batch.
Bool_t canBeExtended() const
If true, PDF can provide extended likelihood term.
Definition RooAbsPdf.h:262
virtual Double_t getLogVal(const RooArgSet *set=0) const
Return the log of the current value with given normalization An error message is printed if the argum...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:64
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:94
void logEvalError(const char *message, const char *serverValueString=0) const
Log evaluation error message.
RooAbsTestStatistic is the abstract base class for all test statistics.
Int_t _nGof
Number of designated set to calculated extended term.
Int_t _nCPU
GOF MP Split mode specified by component (when Auto is active)
pRooAbsTestStatistic * _gofArray
GOFOpMode _gofOpMode
Is object initialized
ROOT::Math::KahanSum< double > _offset
Double_t _evalCarry
Offset as KahanSum to avoid loss of precision.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:35
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition RooCmdArg.h:27
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
Bool_t defineInt(const char *name, const char *argName, Int_t intNum, Int_t defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
static std::string decodeStringOnTheFly(const char *callerID, const char *cmdArgName, Int_t intIdx, const char *defVal, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Static decoder function allows to retrieve string property from set of RooCmdArgs For use in base mem...
static Int_t decodeIntOnTheFly(const char *callerID, const char *cmdArgName, Int_t intIdx, Int_t defVal, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Static decoder function allows to retrieve integer property from set of RooCmdArgs For use in base me...
Int_t getInt(const char *name, Int_t defaultValue=0)
Return integer property registered with name 'name'.
void allowUndefined(Bool_t flag=kTRUE)
static double decodeDoubleOnTheFly(const char *callerID, const char *cmdArgName, int idx, double defVal, std::initializer_list< std::reference_wrapper< const RooCmdArg > > args)
Find a given double in a list of RooCmdArg.
Bool_t process(const RooCmdArg &arg)
Process given RooCmdArg.
Class RooNLLVar implements a -log(likelihood) calculation from a dataset and a PDF.
Definition RooNLLVar.h:30
ComputeResult computeScalar(std::size_t stepSize, std::size_t firstEvent, std::size_t lastEvent) const
void applyWeightSquared(bool flag)
Disables or enables the usage of squared weights.
RooRealSumPdf * _binnedPdf
Definition RooNLLVar.h:92
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)
ROOT::Math::KahanSum< double > _offsetSaveW2
Definition RooNLLVar.h:89
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)
Bool_t _extended
Definition RooNLLVar.h:85
bool _batchEvaluations
Definition RooNLLVar.h:86
static RooArgSet _emptySet
Definition RooNLLVar.h:79
virtual ~RooNLLVar()
Definition RooNLLVar.cxx:73
Bool_t _first
Definition RooNLLVar.h:88
std::pair< ROOT::Math::KahanSum< double >, double > ComputeResult
Definition RooNLLVar.h:64
std::vector< Double_t > _binw
Definition RooNLLVar.h:91
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &pdf, RooAbsData &adata, const RooArgSet &projDeps, RooAbsTestStatistic::Configuration const &cfg)
Create a test statistic using several properties of the current instance.
virtual Double_t evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const
Calculate and return likelihood on subset of data.
std::unique_ptr< RooBatchCompute::RunContext > _evalData
Definition RooNLLVar.h:93
Bool_t _weightSq
Definition RooNLLVar.h:87
ComputeResult computeBatched(std::size_t stepSize, std::size_t firstEvent, std::size_t lastEvent) const
Compute probabilites of all data events.
The class RooRealSumPdf implements a PDF constructed from a sum of functions:
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
Retrieve bin boundaries if this distribution is binned in obs.
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:39
A simple container to hold a batch of data values.
Definition RooSpan.h:34
constexpr std::span< T >::index_type size() const noexcept
Definition RooSpan.h:121
constexpr bool empty() const noexcept
Definition RooSpan.h:125
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
@ BulkPartition
Double_t LnGamma(Double_t z)
Computation of ln[gamma(z)] for all z.
Definition TMath.cxx:486
std::string rangeName
Stores the configuration parameters for RooAbsTestStatistic.
This struct enables passing computation data around between elements of a computation graph.
Definition RunContext.h:32
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.