Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooAbsTestStatistic.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 RooAbsTestStatistic.cxx
19\class RooAbsTestStatistic
20\ingroup Roofitcore
21
22Abstract base class for all test
23statistics. Test statistics that evaluate the PDF at each data
24point should inherit from the RooAbsOptTestStatistic class which
25implements several generic optimizations that can be done for such
26quantities.
27
28This test statistic base class organizes calculation of test
29statistic values for RooSimultaneous PDF as a combination of test
30statistic values for the PDF components of the simultaneous PDF and
31organizes multi-processor parallel calculation of test statistic
32values. For the latter, the test statistic value is calculated in
33partitions in parallel executing processes and a posteriori
34combined in the main thread.
35**/
36
37#include "RooAbsTestStatistic.h"
38
39#include "RooAbsPdf.h"
40#include "RooSimultaneous.h"
41#include "RooAbsData.h"
42#include "RooArgSet.h"
43#include "RooRealVar.h"
44#include "RooRealMPFE.h"
45#include "RooErrorHandler.h"
46#include "RooMsgService.h"
48#include "RooFitImplHelpers.h"
50#include "RooCategory.h"
51
52#include "TTimeStamp.h"
53#include "TClass.h"
54#include <string>
55#include <stdexcept>
56
57using namespace std;
58
60
61
62////////////////////////////////////////////////////////////////////////////////
63/// Create a test statistic from the given function and the data.
64/// \param[in] name Name of the test statistic
65/// \param[in] title Title (for plotting)
66/// \param[in] real Function to be used for tests
67/// \param[in] data Data to fit function to
68/// \param[in] projDeps A set of projected observables
69/// \param[in] cfg statistic configuration object
70///
71/// cfg contains:
72/// - rangeName Fit data only in range with given name
73/// - addCoefRangeName If not null, all RooAddPdf components of `real` will be instructed to fix their fraction definitions to the given named range.
74/// - nCPU If larger than one, the test statistic calculation will be parallelized over multiple processes.
75/// By default the data is split with 'bulk' partitioning (each process calculates a contiguous block of fraction 1/nCPU
76/// of the data). For binned data this approach may be suboptimal as the number of bins with >0 entries
77/// in each processing block many vary greatly thereby distributing the workload rather unevenly.
78/// - interleave is set to true, the interleave partitioning strategy is used where each partition
79/// i takes all bins for which (ibin % ncpu == i) which is more likely to result in an even workload.
80/// - verbose Be more verbose.
81/// - splitCutRange If true, a different rangeName constructed as rangeName_{catName} will be used
82/// as range definition for each index state of a RooSimultaneous. This means that a different range can be defined
83/// for each category such as
84/// ```
85/// myVariable.setRange("range_pi0", 135, 210);
86/// myVariable.setRange("range_gamma", 50, 210);
87/// ```
88/// if the categories are called "pi0" and "gamma".
89
91 const RooArgSet& projDeps, RooAbsTestStatistic::Configuration const& cfg) :
92 RooAbsReal(name,title),
93 _paramSet("paramSet","Set of parameters",this),
94 _func(&real),
95 _data(&data),
96 _projDeps((RooArgSet*)projDeps.Clone()),
97 _rangeName(cfg.rangeName),
98 _addCoefRangeName(cfg.addCoefRangeName),
99 _splitRange(cfg.splitCutRange),
100 _verbose(cfg.verbose),
101 // Determine if RooAbsReal is a RooSimultaneous
102 _gofOpMode{(cfg.nCPU>1 || cfg.nCPU==-1) ? MPMaster : (dynamic_cast<RooSimultaneous*>(_func) ? SimMaster : Slave)},
103 _nEvents{data.numEntries()},
104 _nCPU(cfg.nCPU != -1 ? cfg.nCPU : 1),
105 _mpinterl(cfg.interleave),
106 _takeGlobalObservablesFromData{cfg.takeGlobalObservablesFromData}
107{
108 // Register all parameters as servers
109 _paramSet.add(*std::unique_ptr<RooArgSet>{real.getParameters(&data)});
110}
111
112
113
114////////////////////////////////////////////////////////////////////////////////
115/// Copy constructor
116
118 RooAbsReal(other,name),
119 _paramSet("paramSet","Set of parameters",this),
120 _func(other._func),
121 _data(other._data),
122 _projDeps((RooArgSet*)other._projDeps->Clone()),
123 _rangeName(other._rangeName),
124 _addCoefRangeName(other._addCoefRangeName),
125 _splitRange(other._splitRange),
126 _verbose(other._verbose),
127 // Determine if RooAbsReal is a RooSimultaneous
128 _gofOpMode{(other._nCPU>1 || other._nCPU==-1) ? MPMaster : (dynamic_cast<RooSimultaneous*>(_func) ? SimMaster : Slave)},
129 _nEvents{_data->numEntries()},
130 _nCPU(other._nCPU != -1 ? other._nCPU : 1),
131 _mpinterl(other._mpinterl),
132 _doOffset(other._doOffset),
133 _takeGlobalObservablesFromData{other._takeGlobalObservablesFromData},
134 _offset(other._offset),
135 _evalCarry(other._evalCarry)
136{
137 // Our parameters are those of original
138 _paramSet.add(other._paramSet) ;
139}
140
141
142
143////////////////////////////////////////////////////////////////////////////////
144/// Destructor
145
147{
148 if (MPMaster == _gofOpMode && _init) {
149 for (Int_t i = 0; i < _nCPU; ++i) delete _mpfeArray[i];
150 delete[] _mpfeArray ;
151 }
152
153 delete _projDeps ;
154}
155
156
157
158////////////////////////////////////////////////////////////////////////////////
159/// Calculate and return value of test statistic. If the test statistic
160/// is calculated from a RooSimultaneous, the test statistic calculation
161/// is performed separately on each simultaneous p.d.f component and associated
162/// data, and then combined. If the test statistic calculation is parallelized,
163/// partitions are calculated in nCPU processes and combined a posteriori.
164
166{
167 // One-time Initialization
168 if (!_init) {
169 const_cast<RooAbsTestStatistic*>(this)->initialize() ;
170 }
171
172 if (SimMaster == _gofOpMode) {
173 // Evaluate array of owned GOF objects
174 double ret = 0.;
175
177 ret = combinedValue(reinterpret_cast<RooAbsReal**>(const_cast<std::unique_ptr<RooAbsTestStatistic>*>(_gofArray.data())),_gofArray.size());
178 } else {
179 double sum = 0., carry = 0.;
180 int i = 0;
181 for (auto& gof : _gofArray) {
182 if (i % _numSets == _setNum || (_mpinterl==RooFit::Hybrid && gof->_mpinterl != RooFit::SimComponents )) {
183 double y = gof->getValV();
184 carry += gof->getCarry();
185 y -= carry;
186 const double t = sum + y;
187 carry = (t - sum) - y;
188 sum = t;
189 }
190 ++i;
191 }
192 ret = sum ;
193 _evalCarry = carry;
194 }
195
196 // Only apply global normalization if SimMaster doesn't have MP master
197 if (numSets()==1) {
198 const double norm = globalNormalization();
199 ret /= norm;
200 _evalCarry /= norm;
201 }
202
203 return ret ;
204
205 } else if (MPMaster == _gofOpMode) {
206
207 // Start calculations in parallel
208 for (Int_t i = 0; i < _nCPU; ++i) _mpfeArray[i]->calculate();
209
210
211 double sum(0), carry = 0.;
212 for (Int_t i = 0; i < _nCPU; ++i) {
213 double y = _mpfeArray[i]->getValV();
214 carry += _mpfeArray[i]->getCarry();
215 y -= carry;
216 const double t = sum + y;
217 carry = (t - sum) - y;
218 sum = t;
219 }
220
221 double ret = sum ;
222 _evalCarry = carry;
223
224 const double norm = globalNormalization();
225 ret /= norm;
226 _evalCarry /= norm;
227
228 return ret ;
229
230 } else {
231
232 // Evaluate as straight FUNC
233 Int_t nFirst(0), nLast(_nEvents), nStep(1) ;
234
235 switch (_mpinterl) {
237 nFirst = _nEvents * _setNum / _numSets ;
238 nLast = _nEvents * (_setNum+1) / _numSets ;
239 nStep = 1 ;
240 break;
241
243 nFirst = _setNum ;
244 nLast = _nEvents ;
245 nStep = _numSets ;
246 break ;
247
249 nFirst = 0 ;
250 nLast = _nEvents ;
251 nStep = 1 ;
252 break ;
253
254 case RooFit::Hybrid:
255 throw std::logic_error("this should never happen");
256 break ;
257 }
258
259 runRecalculateCache(nFirst, nLast, nStep);
260 double ret = evaluatePartition(nFirst,nLast,nStep);
261
262 if (numSets()==1) {
263 const double norm = globalNormalization();
264 ret /= norm;
265 _evalCarry /= norm;
266 }
267
268 return ret ;
269
270 }
271}
272
273
274
275////////////////////////////////////////////////////////////////////////////////
276/// One-time initialization of the test statistic. Setup
277/// infrastructure for simultaneous p.d.f processing and/or
278/// parallelized processing if requested
279
281{
282 if (_init) return false;
283
284 if (MPMaster == _gofOpMode) {
286 } else if (SimMaster == _gofOpMode) {
288 }
289 _init = true;
290 return false;
291}
292
293
294
295////////////////////////////////////////////////////////////////////////////////
296/// Forward server redirect calls to component test statistics
297
298bool RooAbsTestStatistic::redirectServersHook(const RooAbsCollection& newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive)
299{
300 if (SimMaster == _gofOpMode) {
301 // Forward to slaves
302 for(auto& gof : _gofArray) {
303 gof->recursiveRedirectServers(newServerList,mustReplaceAll,nameChange);
304 }
305 } else if (MPMaster == _gofOpMode&& _mpfeArray) {
306 // Forward to slaves
307 for (Int_t i = 0; i < _nCPU; ++i) {
308 if (_mpfeArray[i]) {
309 _mpfeArray[i]->recursiveRedirectServers(newServerList,mustReplaceAll,nameChange);
310// cout << "redirecting servers on " << _mpfeArray[i]->GetName() << endl;
311 }
312 }
313 }
314 return RooAbsReal::redirectServersHook(newServerList, mustReplaceAll, nameChange, isRecursive);
315}
316
317
318
319////////////////////////////////////////////////////////////////////////////////
320/// Add extra information on component test statistics when printing
321/// itself as part of a tree structure
322
324{
325 if (SimMaster == _gofOpMode) {
326 // Forward to slaves
327 os << indent << "RooAbsTestStatistic begin GOF contents" << endl ;
328 for (std::size_t i = 0; i < _gofArray.size(); ++i) {
329 TString indent2(indent);
330 indent2 += "[" + std::to_string(i) + "] ";
331 _gofArray[i]->printCompactTreeHook(os,indent2);
332 }
333 os << indent << "RooAbsTestStatistic end GOF contents" << endl;
334 } else if (MPMaster == _gofOpMode) {
335 // WVE implement this
336 }
337}
338
339
340
341////////////////////////////////////////////////////////////////////////////////
342/// Forward constant term optimization management calls to component
343/// test statistics
344
346{
347 initialize();
348 if (SimMaster == _gofOpMode) {
349 // Forward to slaves
350 int i = 0;
351 for (auto& gof : _gofArray) {
352 // In SimComponents Splitting strategy only constOptimize the terms that are actually used
353 RooFit::MPSplit effSplit = (_mpinterl!=RooFit::Hybrid) ? _mpinterl : gof->_mpinterl;
354 if ( (i % _numSets == _setNum) || (effSplit != RooFit::SimComponents) ) {
355 gof->constOptimizeTestStatistic(opcode,doAlsoTrackingOpt);
356 }
357 ++i;
358 }
359 } else if (MPMaster == _gofOpMode) {
360 for (Int_t i = 0; i < _nCPU; ++i) {
361 _mpfeArray[i]->constOptimizeTestStatistic(opcode,doAlsoTrackingOpt);
362 }
363 }
364}
365
366
367
368////////////////////////////////////////////////////////////////////////////////
369/// Set MultiProcessor set number identification of this instance
370
372{
373 _setNum = inSetNum; _numSets = inNumSets;
375
376 if (SimMaster == _gofOpMode) {
377 // Forward to slaves
378 initialize();
379 for(auto& gof : _gofArray) {
380 gof->setMPSet(inSetNum,inNumSets);
381 }
382 }
383}
384
385
386
387////////////////////////////////////////////////////////////////////////////////
388/// Initialize multi-processor calculation mode. Create component test statistics in separate
389/// processed that are connected to this process through a RooAbsRealMPFE front-end class.
390
391void RooAbsTestStatistic::initMPMode(RooAbsReal* real, RooAbsData* data, const RooArgSet* projDeps, std::string const& rangeName, std::string const& addCoefRangeName)
392{
394
395 // Create proto-goodness-of-fit
396 Configuration cfg;
397 cfg.rangeName = rangeName;
398 cfg.addCoefRangeName = addCoefRangeName;
399 cfg.nCPU = 1;
400 cfg.interleave = _mpinterl;
401 cfg.verbose = _verbose;
404 // This configuration parameter is stored in the RooAbsOptTestStatistic.
405 // It would have been cleaner to move the member variable into RooAbsTestStatistic,
406 // but to avoid incrementing the class version we do the dynamic_cast trick.
407 if(auto thisAsRooAbsOptTestStatistic = dynamic_cast<RooAbsOptTestStatistic const*>(this)) {
408 cfg.integrateOverBinsPrecision = thisAsRooAbsOptTestStatistic->_integrateBinsPrecision;
409 }
410 RooAbsTestStatistic* gof = create(GetName(),GetTitle(),*real,*data,*projDeps,cfg);
412
413 for (Int_t i = 0; i < _nCPU; ++i) {
414 gof->setMPSet(i,_nCPU);
415 gof->SetName(Form("%s_GOF%d",GetName(),i));
416 gof->SetTitle(Form("%s_GOF%d",GetTitle(),i));
417
418 ccoutD(Eval) << "RooAbsTestStatistic::initMPMode: starting remote server process #" << i << endl;
419 _mpfeArray[i] = new RooRealMPFE(Form("%s_%zx_MPFE%d",GetName(),(size_t)this,i),Form("%s_%zx_MPFE%d",GetTitle(),(size_t)this,i),*gof,false);
420 //_mpfeArray[i]->setVerbose(true,true);
422 if (i > 0) {
424 }
425 }
427 coutI(Eval) << "RooAbsTestStatistic::initMPMode: started " << _nCPU << " remote server process." << endl;
428 //cout << "initMPMode --- done" << endl ;
429 return ;
430}
431
432
433
434////////////////////////////////////////////////////////////////////////////////
435/// Initialize simultaneous p.d.f processing mode. Strip simultaneous
436/// p.d.f into individual components, split dataset in subset
437/// matching each component and create component test statistics for
438/// each of them.
439
441 const RooArgSet* projDeps,
442 std::string const& rangeName, std::string const& addCoefRangeName)
443{
444
445 RooAbsCategoryLValue& simCat = const_cast<RooAbsCategoryLValue&>(simpdf->indexCat());
446
447 std::unique_ptr<TList> dsetList{const_cast<RooAbsData*>(data)->split(*simpdf,processEmptyDataSets())};
448
449 // Create array of regular fit contexts, containing subset of data and single fitCat PDF
450 for (const auto& catState : simCat) {
451 const std::string& catName = catState.first;
452 RooAbsCategory::value_type catIndex = catState.second;
453
454 // If the channel is not in the selected range of the category variable, we
455 // won't create a slave calculator for this channel.
456 if(!rangeName.empty()) {
457 // Only the RooCategory supports ranges, not the other
458 // RooAbsCategoryLValue-derived classes.
459 auto simCatAsRooCategory = dynamic_cast<RooCategory*>(&simCat);
460 if(simCatAsRooCategory && !simCatAsRooCategory->isStateInRange(rangeName.c_str(), catIndex)) {
461 continue;
462 }
463 }
464
465 // Retrieve the PDF for this simCat state
466 RooAbsPdf* pdf = simpdf->getPdf(catName.c_str());
467 RooAbsData* dset = (RooAbsData*) dsetList->FindObject(catName.c_str());
468
469 if (pdf && dset && (0. != dset->sumEntries() || processEmptyDataSets())) {
470 ccoutI(Fitting) << "RooAbsTestStatistic::initSimMode: creating slave calculator #" << _gofArray.size() << " for state " << catName
471 << " (" << dset->numEntries() << " dataset entries)" << endl;
472
473
474 // *** START HERE
475 // WVE HACK determine if we have a RooRealSumPdf and then treat it like a binned likelihood
476 auto binnedInfo = RooHelpers::getBinnedL(*pdf);
477 RooAbsReal &actualPdf = binnedInfo.binnedPdf ? *binnedInfo.binnedPdf : *pdf;
478 // WVE END HACK
479 // Below here directly pass binnedPdf instead of PROD(binnedPdf,constraints) as constraints are evaluated elsewhere anyway
480 // and omitting them reduces model complexity and associated handling/cloning times
481 Configuration cfg;
482 cfg.addCoefRangeName = addCoefRangeName;
483 cfg.interleave = _mpinterl;
484 cfg.verbose = _verbose;
486 cfg.binnedL = binnedInfo.isBinnedL;
488 // This configuration parameter is stored in the RooAbsOptTestStatistic.
489 // It would have been cleaner to move the member variable into RooAbsTestStatistic,
490 // but to avoid incrementing the class version we do the dynamic_cast trick.
491 if(auto thisAsRooAbsOptTestStatistic = dynamic_cast<RooAbsOptTestStatistic const*>(this)) {
492 cfg.integrateOverBinsPrecision = thisAsRooAbsOptTestStatistic->_integrateBinsPrecision;
493 }
495 cfg.nCPU = _nCPU;
496 _gofArray.emplace_back(create(catName.c_str(),catName.c_str(),actualPdf,*dset,*projDeps,cfg));
497 // *** END HERE
498
499 // Fill per-component split mode with Bulk Partition for now so that Auto will map to bulk-splitting of all components
501 _gofArray.back()->_mpinterl = dset->numEntries()<10 ? RooFit::SimComponents : RooFit::BulkPartition;
502 }
503
504 // Servers may have been redirected between instantiation and (deferred) initialization
505
506 RooArgSet actualParams;
507 actualPdf.getParameters(dset->get(), actualParams);
508 RooArgSet selTargetParams;
509 _paramSet.selectCommon(actualParams, selTargetParams);
510
511 _gofArray.back()->recursiveRedirectServers(selTargetParams);
512 }
513 }
514 for(auto& gof : _gofArray) {
515 gof->setSimCount(_gofArray.size());
516 }
517 coutI(Fitting) << "RooAbsTestStatistic::initSimMode: created " << _gofArray.size() << " slave calculators." << endl;
518
519 dsetList->Delete(); // delete the content.
520}
521
522
523////////////////////////////////////////////////////////////////////////////////
524/// Change dataset that is used to given one. If cloneData is true, a clone of
525/// in the input dataset is made. If the test statistic was constructed with
526/// a range specification on the data, the cloneData argument is ignored and
527/// the data is always cloned.
528bool RooAbsTestStatistic::setData(RooAbsData& indata, bool cloneData)
529{
530 // Trigger refresh of likelihood offsets
531 if (isOffsetting()) {
532 enableOffsetting(false);
533 enableOffsetting(true);
534 }
535
536 switch(operMode()) {
537 case Slave:
538 // Delegate to implementation
539 return setDataSlave(indata, cloneData);
540 case SimMaster:
541 // Forward to slaves
542 if (indata.canSplitFast()) {
543 for(auto& gof : _gofArray) {
544 RooAbsData* compData = indata.getSimData(gof->GetName());
545 gof->setDataSlave(*compData, cloneData);
546 }
547 } else if (0 == indata.numEntries()) {
548 // For an unsplit empty dataset, simply assign empty dataset to each component
549 for(auto& gof : _gofArray) {
550 gof->setDataSlave(indata, cloneData);
551 }
552 } else {
553 std::unique_ptr<TList> dlist{indata.split(*static_cast<RooSimultaneous*>(_func), processEmptyDataSets())};
554 if (!dlist) {
555 coutE(Fitting) << "RooAbsTestStatistic::initSimMode(" << GetName() << ") ERROR: index category of simultaneous pdf is missing in dataset, aborting" << endl;
556 throw std::runtime_error("RooAbsTestStatistic::initSimMode() ERROR, index category of simultaneous pdf is missing in dataset, aborting");
557 }
558
559 for(auto& gof : _gofArray) {
560 if (auto compData = static_cast<RooAbsData*>(dlist->FindObject(gof->GetName()))) {
561 gof->setDataSlave(*compData,false,true);
562 } else {
563 coutE(DataHandling) << "RooAbsTestStatistic::setData(" << GetName() << ") ERROR: Cannot find component data for state " << gof->GetName() << endl;
564 }
565 }
566 }
567 break;
568 case MPMaster:
569 // Not supported
570 coutF(DataHandling) << "RooAbsTestStatistic::setData(" << GetName() << ") FATAL: setData() is not supported in multi-processor mode" << endl;
571 throw std::runtime_error("RooAbsTestStatistic::setData is not supported in MPMaster mode");
572 break;
573 }
574
575 return true;
576}
577
578
579
581{
582 // Apply internal value offsetting to control numeric precision
583 if (!_init) {
584 const_cast<RooAbsTestStatistic*>(this)->initialize() ;
585 }
586
587 switch(operMode()) {
588 case Slave:
589 _doOffset = flag ;
590 // Clear offset if feature is disabled to that it is recalculated next time it is enabled
591 if (!_doOffset) {
593 }
594 setValueDirty() ;
595 break ;
596 case SimMaster:
597 _doOffset = flag;
598 for(auto& gof : _gofArray) {
599 gof->enableOffsetting(flag);
600 }
601 break ;
602 case MPMaster:
603 _doOffset = flag;
604 for (Int_t i = 0; i < _nCPU; ++i) {
606 }
607 break;
608 }
609}
610
611
613{ return _evalCarry; }
#define coutI(a)
#define coutF(a)
#define coutE(a)
#define ccoutI(a)
#define ccoutD(a)
#define ClassImp(name)
Definition Rtypes.h:377
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
Definition TGX11.cxx:110
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2467
The Kahan summation is a compensated summation algorithm, which significantly reduces numerical error...
Definition Util.h:122
bool recursiveRedirectServers(const RooAbsCollection &newServerList, bool mustReplaceAll=false, bool nameChange=false, bool recurseInNewSet=true)
Recursively replace all servers with the new servers in newSet.
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...
void SetName(const char *name) override
Set the name of the TNamed.
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Definition RooAbsArg.h:490
Abstract base class for objects that represent a discrete value that can be set from the outside,...
Abstract container object that can hold multiple RooAbsArg objects.
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:57
virtual double sumEntries() const =0
Return effective number of entries in dataset, i.e., sum all weights.
virtual const RooArgSet * get() const
Definition RooAbsData.h:101
virtual RooFit::OwningPtr< TList > split(const RooAbsCategory &splitCat, bool createEmptyDataSets=false) const
Split the dataset into subsets based on states of a categorical variable in this dataset.
bool canSplitFast() const
RooAbsData * getSimData(const char *idxstate)
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
RooAbsOptTestStatistic is the abstract base class for test statistics objects that evaluate a functio...
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursiveStep) override
Function that is called at the end of redirectServers().
Abstract base class for all test statistics.
Int_t _setNum
Partition number of this instance in parallel calculation mode.
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)=0
virtual bool processEmptyDataSets() const
double _evalCarry
! carry of Kahan sum in evaluatePartition
std::string _addCoefRangeName
Name of reference to be used for RooAddPdf components.
Int_t _nEvents
Total number of events in test statistic calculation.
GOFOpMode operMode() const
Int_t _nCPU
Number of processors to use in parallel calculation mode.
RooSetProxy _paramSet
Parameters of the test statistic (=parameters of the input function)
virtual double globalNormalization() const
RooAbsReal * _func
Pointer to original input function.
bool setData(RooAbsData &data, bool cloneData=true) override
Change dataset that is used to given one.
void printCompactTreeHook(std::ostream &os, const char *indent="") override
Add extra information on component test statistics when printing itself as part of a tree structure.
Int_t _numSets
Total number of partitions in parallel calculation mode.
RooFit::MPSplit _mpinterl
Use interleaving strategy rather than N-wise split for partitioning of dataset for multiprocessor-spl...
bool isOffsetting() const override
double evaluate() const override
Calculate and return value of test statistic.
GOFOpMode _gofOpMode
Operation mode of test statistic instance.
virtual bool setDataSlave(RooAbsData &, bool=true, bool=false)
void initMPMode(RooAbsReal *real, RooAbsData *data, const RooArgSet *projDeps, std::string const &rangeName, std::string const &addCoefRangeName)
Initialize multi-processor calculation mode.
std::string _rangeName
Name of range in which to calculate test statistic.
RooAbsTestStatistic(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)
Create a test statistic from the given function and the data.
void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTrackingOpt=true) override
Forward constant term optimization management calls to component test statistics.
bool _init
! Is object initialized
ROOT::Math::KahanSum< double > _offset
! Offset as KahanSum to avoid loss of precision
virtual void runRecalculateCache(std::size_t, std::size_t, std::size_t) const
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.
const RooArgSet * _projDeps
Pointer to set with projected observables.
void initSimMode(RooSimultaneous *pdf, RooAbsData *data, const RooArgSet *projDeps, std::string const &rangeName, std::string const &addCoefRangeName)
Initialize simultaneous p.d.f processing mode.
~RooAbsTestStatistic() override
Destructor.
virtual double getCarry() const
bool _verbose
Verbose messaging if true.
void enableOffsetting(bool flag) override
virtual double evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const =0
bool _splitRange
Split rangeName in RooSimultaneous index labels if true.
virtual double combinedValue(RooAbsReal **gofArray, Int_t nVal) const =0
pRooRealMPFE * _mpfeArray
! Array of parallel execution frond ends
bool _doOffset
Apply interval value offset to control numeric precision?
RooAbsData * _data
Pointer to original input dataset.
const bool _takeGlobalObservablesFromData
If the global observable values are taken from data.
void setMPSet(Int_t setNum, Int_t numSets)
Set MultiProcessor set number identification of this instance.
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive) override
Forward server redirect calls to component test statistics.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
Object to represent discrete states.
Definition RooCategory.h:28
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
Multi-processor front-end for parallel calculation of RooAbsReal objects.
Definition RooRealMPFE.h:29
void initialize()
Initialize the remote process and message passing pipes between current process and remote process.
void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTracking=true) override
Intercept call to optimize constant term in test statistics and forward it to object on server side.
virtual double getCarry() const
void enableOffsetting(bool flag) override
Control verbose messaging related to inter process communication on both client and server side.
void followAsSlave(RooRealMPFE &master)
Definition RooRealMPFE.h:47
double getValV(const RooArgSet *nset=nullptr) const override
If value needs recalculation and calculation has not been started with a call to calculate() start it...
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
RooAbsPdf * getPdf(RooStringView catName) const
Return the p.d.f associated with the given index category name.
const RooAbsCategoryLValue & indexCat() const
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition TObject.cxx:403
Basic string class.
Definition TString.h:139
Double_t y[n]
Definition legend1.C:17
@ SimComponents
@ BulkPartition
std::string getRangeNameForSimComponent(std::string const &rangeName, bool splitRange, std::string const &catName)
BinnedLOutput getBinnedL(RooAbsPdf const &pdf)
std::string rangeName
Stores the configuration parameters for RooAbsTestStatistic.
static uint64_t sum(uint64_t i)
Definition Factory.cxx:2345