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 std::endl, std::ostream;
58
59////////////////////////////////////////////////////////////////////////////////
60/// Create a test statistic from the given function and the data.
61/// \param[in] name Name of the test statistic
62/// \param[in] title Title (for plotting)
63/// \param[in] real Function to be used for tests
64/// \param[in] data Data to fit function to
65/// \param[in] projDeps A set of projected observables
66/// \param[in] cfg statistic configuration object
67///
68/// cfg contains:
69/// - rangeName Fit data only in range with given name
70/// - addCoefRangeName If not null, all RooAddPdf components of `real` will be instructed to fix their fraction definitions to the given named range.
71/// - nCPU If larger than one, the test statistic calculation will be parallelized over multiple processes.
72/// By default the data is split with 'bulk' partitioning (each process calculates a contiguous block of fraction 1/nCPU
73/// of the data). For binned data this approach may be suboptimal as the number of bins with >0 entries
74/// in each processing block many vary greatly thereby distributing the workload rather unevenly.
75/// - interleave is set to true, the interleave partitioning strategy is used where each partition
76/// i takes all bins for which (ibin % ncpu == i) which is more likely to result in an even workload.
77/// - verbose Be more verbose.
78/// - splitCutRange If true, a different rangeName constructed as rangeName_{catName} will be used
79/// as range definition for each index state of a RooSimultaneous. This means that a different range can be defined
80/// for each category such as
81/// ```
82/// myVariable.setRange("range_pi0", 135, 210);
83/// myVariable.setRange("range_gamma", 50, 210);
84/// ```
85/// if the categories are called "pi0" and "gamma".
86
88 const RooArgSet& projDeps, RooAbsTestStatistic::Configuration const& cfg) :
89 RooAbsReal(name,title),
90 _paramSet("paramSet","Set of parameters",this),
91 _func(&real),
92 _data(&data),
93 _projDeps(static_cast<RooArgSet*>(projDeps.Clone())),
94 _rangeName(cfg.rangeName),
95 _addCoefRangeName(cfg.addCoefRangeName),
96 _splitRange(cfg.splitCutRange),
97 _verbose(cfg.verbose),
98 // Determine if RooAbsReal is a RooSimultaneous
99 _gofOpMode{(cfg.nCPU>1 || cfg.nCPU==-1) ? MPMaster : (dynamic_cast<RooSimultaneous*>(_func) ? SimMaster : Slave)},
100 _nEvents{data.numEntries()},
101 _nCPU(cfg.nCPU != -1 ? cfg.nCPU : 1),
102 _mpinterl(cfg.interleave),
103 _takeGlobalObservablesFromData{cfg.takeGlobalObservablesFromData}
104{
105 // Register all parameters as servers
106 _paramSet.add(*std::unique_ptr<RooArgSet>{real.getParameters(&data)});
107}
108
109
110
111////////////////////////////////////////////////////////////////////////////////
112/// Copy constructor
113
115 RooAbsReal(other,name),
116 _paramSet("paramSet","Set of parameters",this),
117 _func(other._func),
118 _data(other._data),
119 _projDeps(static_cast<RooArgSet*>(other._projDeps->Clone())),
120 _rangeName(other._rangeName),
121 _addCoefRangeName(other._addCoefRangeName),
122 _splitRange(other._splitRange),
123 _verbose(other._verbose),
124 // Determine if RooAbsReal is a RooSimultaneous
125 _gofOpMode{(other._nCPU>1 || other._nCPU==-1) ? MPMaster : (dynamic_cast<RooSimultaneous*>(_func) ? SimMaster : Slave)},
126 _nEvents{_data->numEntries()},
127 _nCPU(other._nCPU != -1 ? other._nCPU : 1),
128 _mpinterl(other._mpinterl),
129 _doOffset(other._doOffset),
130 _takeGlobalObservablesFromData{other._takeGlobalObservablesFromData},
131 _offset(other._offset),
132 _evalCarry(other._evalCarry)
133{
134 // Our parameters are those of original
135 _paramSet.add(other._paramSet) ;
136}
137
138
139
140////////////////////////////////////////////////////////////////////////////////
141/// Destructor
142
144{
145 if (MPMaster == _gofOpMode && _init) {
146 for (Int_t i = 0; i < _nCPU; ++i) delete _mpfeArray[i];
147 delete[] _mpfeArray ;
148 }
149
150 delete _projDeps ;
151}
152
153
154
155////////////////////////////////////////////////////////////////////////////////
156/// Calculate and return value of test statistic. If the test statistic
157/// is calculated from a RooSimultaneous, the test statistic calculation
158/// is performed separately on each simultaneous p.d.f component and associated
159/// data, and then combined. If the test statistic calculation is parallelized,
160/// partitions are calculated in nCPU processes and combined a posteriori.
161
163{
164 // One-time Initialization
165 if (!_init) {
166 const_cast<RooAbsTestStatistic*>(this)->initialize() ;
167 }
168
169 if (SimMaster == _gofOpMode) {
170 // Evaluate array of owned GOF objects
171 double ret = 0.;
172
174 ret = combinedValue(reinterpret_cast<RooAbsReal**>(const_cast<std::unique_ptr<RooAbsTestStatistic>*>(_gofArray.data())),_gofArray.size());
175 } else {
176 double sum = 0.;
177 double carry = 0.;
178 int i = 0;
179 for (auto& gof : _gofArray) {
180 if (i % _numSets == _setNum || (_mpinterl==RooFit::Hybrid && gof->_mpinterl != RooFit::SimComponents )) {
181 double y = gof->getValV();
182 carry += gof->getCarry();
183 y -= carry;
184 const double t = sum + y;
185 carry = (t - sum) - y;
186 sum = t;
187 }
188 ++i;
189 }
190 ret = sum ;
191 _evalCarry = carry;
192 }
193
194 // Only apply global normalization if SimMaster doesn't have MP master
195 if (numSets()==1) {
196 const double norm = globalNormalization();
197 ret /= norm;
198 _evalCarry /= norm;
199 }
200
201 return ret ;
202
203 } else if (MPMaster == _gofOpMode) {
204
205 // Start calculations in parallel
206 for (Int_t i = 0; i < _nCPU; ++i) _mpfeArray[i]->calculate();
207
208 double sum(0);
209 double carry = 0.;
210 for (Int_t i = 0; i < _nCPU; ++i) {
211 double y = _mpfeArray[i]->getValV();
212 carry += _mpfeArray[i]->getCarry();
213 y -= carry;
214 const double t = sum + y;
215 carry = (t - sum) - y;
216 sum = t;
217 }
218
219 double ret = sum ;
220 _evalCarry = carry;
221
222 const double norm = globalNormalization();
223 ret /= norm;
224 _evalCarry /= norm;
225
226 return ret ;
227
228 } else {
229
230 // Evaluate as straight FUNC
231 Int_t nFirst(0);
232 Int_t nLast(_nEvents);
233 Int_t 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(),reinterpret_cast<size_t>(this),i),Form("%s_%zx_MPFE%d",GetTitle(),reinterpret_cast<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 = static_cast<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)
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:2489
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:431
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.
Storage_t::size_type size() const
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.
Abstract base class for test statistics objects that evaluate a function or PDF at each point of a gi...
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:24
RooArgSet * selectCommon(const RooAbsCollection &refColl) const
Use RooAbsCollection::selecCommon(), but return as RooArgSet.
Definition RooArgSet.h:149
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
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