Logo ROOT  
Reference Guide
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
22RooAbsTestStatistic is the abstract 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 "RooHelpers.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 contigious 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 double ret = evaluatePartition(nFirst,nLast,nStep);
260
261 if (numSets()==1) {
262 const double norm = globalNormalization();
263 ret /= norm;
264 _evalCarry /= norm;
265 }
266
267 return ret ;
268
269 }
270}
271
272
273
274////////////////////////////////////////////////////////////////////////////////
275/// One-time initialization of the test statistic. Setup
276/// infrastructure for simultaneous p.d.f processing and/or
277/// parallelized processing if requested
278
280{
281 if (_init) return false;
282
283 if (MPMaster == _gofOpMode) {
285 } else if (SimMaster == _gofOpMode) {
287 }
288 _init = true;
289 return false;
290}
291
292
293
294////////////////////////////////////////////////////////////////////////////////
295/// Forward server redirect calls to component test statistics
296
297bool RooAbsTestStatistic::redirectServersHook(const RooAbsCollection& newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive)
298{
299 if (SimMaster == _gofOpMode) {
300 // Forward to slaves
301 for(auto& gof : _gofArray) {
302 gof->recursiveRedirectServers(newServerList,mustReplaceAll,nameChange);
303 }
304 } else if (MPMaster == _gofOpMode&& _mpfeArray) {
305 // Forward to slaves
306 for (Int_t i = 0; i < _nCPU; ++i) {
307 if (_mpfeArray[i]) {
308 _mpfeArray[i]->recursiveRedirectServers(newServerList,mustReplaceAll,nameChange);
309// cout << "redirecting servers on " << _mpfeArray[i]->GetName() << endl;
310 }
311 }
312 }
313 return RooAbsReal::redirectServersHook(newServerList, mustReplaceAll, nameChange, isRecursive);
314}
315
316
317
318////////////////////////////////////////////////////////////////////////////////
319/// Add extra information on component test statistics when printing
320/// itself as part of a tree structure
321
323{
324 if (SimMaster == _gofOpMode) {
325 // Forward to slaves
326 os << indent << "RooAbsTestStatistic begin GOF contents" << endl ;
327 for (std::size_t i = 0; i < _gofArray.size(); ++i) {
328 TString indent2(indent);
329 indent2 += "[" + std::to_string(i) + "] ";
330 _gofArray[i]->printCompactTreeHook(os,indent2);
331 }
332 os << indent << "RooAbsTestStatistic end GOF contents" << endl;
333 } else if (MPMaster == _gofOpMode) {
334 // WVE implement this
335 }
336}
337
338
339
340////////////////////////////////////////////////////////////////////////////////
341/// Forward constant term optimization management calls to component
342/// test statistics
343
345{
346 initialize();
347 if (SimMaster == _gofOpMode) {
348 // Forward to slaves
349 int i = 0;
350 for (auto& gof : _gofArray) {
351 // In SimComponents Splitting strategy only constOptimize the terms that are actually used
352 RooFit::MPSplit effSplit = (_mpinterl!=RooFit::Hybrid) ? _mpinterl : gof->_mpinterl;
353 if ( (i % _numSets == _setNum) || (effSplit != RooFit::SimComponents) ) {
354 gof->constOptimizeTestStatistic(opcode,doAlsoTrackingOpt);
355 }
356 ++i;
357 }
358 } else if (MPMaster == _gofOpMode) {
359 for (Int_t i = 0; i < _nCPU; ++i) {
360 _mpfeArray[i]->constOptimizeTestStatistic(opcode,doAlsoTrackingOpt);
361 }
362 }
363}
364
365
366
367////////////////////////////////////////////////////////////////////////////////
368/// Set MultiProcessor set number identification of this instance
369
371{
372 _setNum = inSetNum; _numSets = inNumSets;
374
375 if (SimMaster == _gofOpMode) {
376 // Forward to slaves
377 initialize();
378 for(auto& gof : _gofArray) {
379 gof->setMPSet(inSetNum,inNumSets);
380 }
381 }
382}
383
384
385
386////////////////////////////////////////////////////////////////////////////////
387/// Initialize multi-processor calculation mode. Create component test statistics in separate
388/// processed that are connected to this process through a RooAbsRealMPFE front-end class.
389
390void RooAbsTestStatistic::initMPMode(RooAbsReal* real, RooAbsData* data, const RooArgSet* projDeps, std::string const& rangeName, std::string const& addCoefRangeName)
391{
393
394 // Create proto-goodness-of-fit
395 Configuration cfg;
396 cfg.rangeName = rangeName;
397 cfg.addCoefRangeName = addCoefRangeName;
398 cfg.nCPU = 1;
399 cfg.interleave = _mpinterl;
400 cfg.verbose = _verbose;
403 // This configuration parameter is stored in the RooAbsOptTestStatistic.
404 // It would have been cleaner to move the member variable into RooAbsTestStatistic,
405 // but to avoid incrementing the class version we do the dynamic_cast trick.
406 if(auto thisAsRooAbsOptTestStatistic = dynamic_cast<RooAbsOptTestStatistic const*>(this)) {
407 cfg.integrateOverBinsPrecision = thisAsRooAbsOptTestStatistic->_integrateBinsPrecision;
408 }
409 RooAbsTestStatistic* gof = create(GetName(),GetTitle(),*real,*data,*projDeps,cfg);
411
412 for (Int_t i = 0; i < _nCPU; ++i) {
413 gof->setMPSet(i,_nCPU);
414 gof->SetName(Form("%s_GOF%d",GetName(),i));
415 gof->SetTitle(Form("%s_GOF%d",GetTitle(),i));
416
417 ccoutD(Eval) << "RooAbsTestStatistic::initMPMode: starting remote server process #" << i << endl;
418 _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);
419 //_mpfeArray[i]->setVerbose(true,true);
421 if (i > 0) {
423 }
424 }
426 coutI(Eval) << "RooAbsTestStatistic::initMPMode: started " << _nCPU << " remote server process." << endl;
427 //cout << "initMPMode --- done" << endl ;
428 return ;
429}
430
431
432
433////////////////////////////////////////////////////////////////////////////////
434/// Initialize simultaneous p.d.f processing mode. Strip simultaneous
435/// p.d.f into individual components, split dataset in subset
436/// matching each component and create component test statistics for
437/// each of them.
438
440 const RooArgSet* projDeps,
441 std::string const& rangeName, std::string const& addCoefRangeName)
442{
443
444 RooAbsCategoryLValue& simCat = const_cast<RooAbsCategoryLValue&>(simpdf->indexCat());
445
446 std::unique_ptr<TList> dsetList{const_cast<RooAbsData*>(data)->split(*simpdf,processEmptyDataSets())};
447
448 // Create array of regular fit contexts, containing subset of data and single fitCat PDF
449 for (const auto& catState : simCat) {
450 const std::string& catName = catState.first;
451 RooAbsCategory::value_type catIndex = catState.second;
452
453 // If the channel is not in the selected range of the category variable, we
454 // won't create a slave calculator for this channel.
455 if(!rangeName.empty()) {
456 // Only the RooCategory supports ranges, not the other
457 // RooAbsCategoryLValue-derived classes.
458 auto simCatAsRooCategory = dynamic_cast<RooCategory*>(&simCat);
459 if(simCatAsRooCategory && !simCatAsRooCategory->isStateInRange(rangeName.c_str(), catIndex)) {
460 continue;
461 }
462 }
463
464 // Retrieve the PDF for this simCat state
465 RooAbsPdf* pdf = simpdf->getPdf(catName.c_str());
466 RooAbsData* dset = (RooAbsData*) dsetList->FindObject(catName.c_str());
467
468 if (pdf && dset && (0. != dset->sumEntries() || processEmptyDataSets())) {
469 ccoutI(Fitting) << "RooAbsTestStatistic::initSimMode: creating slave calculator #" << _gofArray.size() << " for state " << catName
470 << " (" << dset->numEntries() << " dataset entries)" << endl;
471
472
473 // *** START HERE
474 // WVE HACK determine if we have a RooRealSumPdf and then treat it like a binned likelihood
475 auto binnedInfo = RooHelpers::getBinnedL(*pdf);
476 // WVE END HACK
477 // Below here directly pass binnedPdf instead of PROD(binnedPdf,constraints) as constraints are evaluated elsewhere anyway
478 // and omitting them reduces model complexity and associated handling/cloning times
479 Configuration cfg;
480 cfg.addCoefRangeName = addCoefRangeName;
481 cfg.interleave = _mpinterl;
482 cfg.verbose = _verbose;
484 cfg.binnedL = binnedInfo.isBinnedL;
486 // This configuration parameter is stored in the RooAbsOptTestStatistic.
487 // It would have been cleaner to move the member variable into RooAbsTestStatistic,
488 // but to avoid incrementing the class version we do the dynamic_cast trick.
489 if(auto thisAsRooAbsOptTestStatistic = dynamic_cast<RooAbsOptTestStatistic const*>(this)) {
490 cfg.integrateOverBinsPrecision = thisAsRooAbsOptTestStatistic->_integrateBinsPrecision;
491 }
493 cfg.nCPU = _nCPU;
494 _gofArray.emplace_back(create(catName.c_str(),catName.c_str(),(binnedInfo.binnedPdf?*binnedInfo.binnedPdf:*pdf),*dset,*projDeps,cfg));
495 // *** END HERE
496
497 // Fill per-component split mode with Bulk Partition for now so that Auto will map to bulk-splitting of all components
499 _gofArray.back()->_mpinterl = dset->numEntries()<10 ? RooFit::SimComponents : RooFit::BulkPartition;
500 }
501
502 // Servers may have been redirected between instantiation and (deferred) initialization
503
504 RooArgSet *actualParams = binnedInfo.binnedPdf ? binnedInfo.binnedPdf->getParameters(dset) : pdf->getParameters(dset);
505 RooArgSet* selTargetParams = (RooArgSet*) _paramSet.selectCommon(*actualParams);
506
507 _gofArray.back()->recursiveRedirectServers(*selTargetParams);
508
509 delete selTargetParams;
510 delete actualParams;
511 }
512 }
513 for(auto& gof : _gofArray) {
514 gof->setSimCount(_gofArray.size());
515 }
516 coutI(Fitting) << "RooAbsTestStatistic::initSimMode: created " << _gofArray.size() << " slave calculators." << endl;
517
518 dsetList->Delete(); // delete the content.
519}
520
521
522////////////////////////////////////////////////////////////////////////////////
523/// Change dataset that is used to given one. If cloneData is true, a clone of
524/// in the input dataset is made. If the test statistic was constructed with
525/// a range specification on the data, the cloneData argument is ignored and
526/// the data is always cloned.
527bool RooAbsTestStatistic::setData(RooAbsData& indata, bool cloneData)
528{
529 // Trigger refresh of likelihood offsets
530 if (isOffsetting()) {
531 enableOffsetting(false);
532 enableOffsetting(true);
533 }
534
535 switch(operMode()) {
536 case Slave:
537 // Delegate to implementation
538 return setDataSlave(indata, cloneData);
539 case SimMaster:
540 // Forward to slaves
541 if (indata.canSplitFast()) {
542 for(auto& gof : _gofArray) {
543 RooAbsData* compData = indata.getSimData(gof->GetName());
544 gof->setDataSlave(*compData, cloneData);
545 }
546 } else if (0 == indata.numEntries()) {
547 // For an unsplit empty dataset, simply assign empty dataset to each component
548 for(auto& gof : _gofArray) {
549 gof->setDataSlave(indata, cloneData);
550 }
551 } else {
552 std::unique_ptr<TList> dlist{indata.split(*static_cast<RooSimultaneous*>(_func), processEmptyDataSets())};
553 if (!dlist) {
554 coutE(Fitting) << "RooAbsTestStatistic::initSimMode(" << GetName() << ") ERROR: index category of simultaneous pdf is missing in dataset, aborting" << endl;
555 throw std::runtime_error("RooAbsTestStatistic::initSimMode() ERROR, index category of simultaneous pdf is missing in dataset, aborting");
556 }
557
558 for(auto& gof : _gofArray) {
559 if (auto compData = static_cast<RooAbsData*>(dlist->FindObject(gof->GetName()))) {
560 gof->setDataSlave(*compData,false,true);
561 } else {
562 coutE(DataHandling) << "RooAbsTestStatistic::setData(" << GetName() << ") ERROR: Cannot find component data for state " << gof->GetName() << endl;
563 }
564 }
565 }
566 break;
567 case MPMaster:
568 // Not supported
569 coutF(DataHandling) << "RooAbsTestStatistic::setData(" << GetName() << ") FATAL: setData() is not supported in multi-processor mode" << endl;
570 throw std::runtime_error("RooAbsTestStatistic::setData is not supported in MPMaster mode");
571 break;
572 }
573
574 return true;
575}
576
577
578
580{
581 // Apply internal value offsetting to control numeric precision
582 if (!_init) {
583 const_cast<RooAbsTestStatistic*>(this)->initialize() ;
584 }
585
586 switch(operMode()) {
587 case Slave:
588 _doOffset = flag ;
589 // Clear offset if feature is disabled to that it is recalculated next time it is enabled
590 if (!_doOffset) {
591 _offset = 0 ;
592 }
593 setValueDirty() ;
594 break ;
595 case SimMaster:
596 _doOffset = flag;
597 for(auto& gof : _gofArray) {
598 gof->enableOffsetting(flag);
599 }
600 break ;
601 case MPMaster:
602 _doOffset = flag;
603 for (Int_t i = 0; i < _nCPU; ++i) {
605 }
606 break;
607 }
608}
609
610
612{ return _evalCarry; }
#define coutI(a)
Definition: RooMsgService.h:34
#define coutF(a)
Definition: RooMsgService.h:38
#define coutE(a)
Definition: RooMsgService.h:37
#define ccoutI(a)
Definition: RooMsgService.h:42
#define ccoutD(a)
Definition: RooMsgService.h:41
#define ClassImp(name)
Definition: Rtypes.h:375
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:2456
bool recursiveRedirectServers(const RooAbsCollection &newServerList, bool mustReplaceAll=false, bool nameChange=false, bool recurseInNewSet=true)
Recursively replace all servers with the new servers in newSet.
Definition: RooAbsArg.cxx:1165
void SetName(const char *name) override
Set the name of the TNamed.
Definition: RooAbsArg.cxx:2314
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
Definition: RooAbsArg.cxx:2185
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Definition: RooAbsArg.h:490
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...
Definition: RooAbsArg.cxx:541
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
RooAbsCollection is an 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...
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:62
virtual double sumEntries() const =0
Return effective number of entries in dataset, i.e., sum all weights.
bool canSplitFast() const
RooAbsData * getSimData(const char *idxstate)
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Definition: RooAbsData.cxx:374
virtual TList * split(const RooAbsCategory &splitCat, bool createEmptyDataSets=false) const
Split dataset into subsets based on states of given splitCat in this dataset.
RooAbsOptTestStatistic is the abstract base class for test statistics objects that evaluate a functio...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:62
bool redirectServersHook(const RooAbsCollection &newServerList, bool mustReplaceAll, bool nameChange, bool isRecursiveStep) override
A buffer for reading values from trees.
RooAbsTestStatistic is the 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 partioning of dataset for multiprocessor-split...
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.
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
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:56
RooCategory is an 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...
RooRealMPFE is the multi-processor front-end for parallel calculation of RooAbsReal objects.
Definition: RooRealMPFE.h:30
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:48
double getValV(const RooArgSet *nset=nullptr) const override
If value needs recalculation and calculation has not beed started with a call to calculate() start it...
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
const RooAbsCategoryLValue & indexCat() const
RooAbsPdf * getPdf(const char *catName) const
Return the p.d.f associated with the given index category name.
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:404
Basic string class.
Definition: TString.h:136
Double_t y[n]
Definition: legend1.C:17
@ SimComponents
Definition: RooGlobalFunc.h:64
@ Interleave
Definition: RooGlobalFunc.h:64
@ BulkPartition
Definition: RooGlobalFunc.h:64
@ DataHandling
Definition: RooGlobalFunc.h:63
BinnedLOutput getBinnedL(RooAbsPdf &pdf)
Definition: RooHelpers.cxx:301
std::string getRangeNameForSimComponent(std::string const &rangeName, bool splitRange, std::string const &catName)
Definition: RooHelpers.cxx:286
std::string rangeName
Stores the configuration parameters for RooAbsTestStatistic.
static uint64_t sum(uint64_t i)
Definition: Factory.cxx:2345