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
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(static_cast<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(static_cast<RooArgSet*>(other._projDeps->Clone())),
123 _rangeName(other._rangeName),
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),
134 _offset(other._offset),
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.;
180 double carry = 0.;
181 int i = 0;
182 for (auto& gof : _gofArray) {
183 if (i % _numSets == _setNum || (_mpinterl==RooFit::Hybrid && gof->_mpinterl != RooFit::SimComponents )) {
184 double y = gof->getValV();
185 carry += gof->getCarry();
186 y -= carry;
187 const double t = sum + y;
188 carry = (t - sum) - y;
189 sum = t;
190 }
191 ++i;
192 }
193 ret = sum ;
194 _evalCarry = carry;
195 }
196
197 // Only apply global normalization if SimMaster doesn't have MP master
198 if (numSets()==1) {
199 const double norm = globalNormalization();
200 ret /= norm;
201 _evalCarry /= norm;
202 }
203
204 return ret ;
205
206 } else if (MPMaster == _gofOpMode) {
207
208 // Start calculations in parallel
209 for (Int_t i = 0; i < _nCPU; ++i) _mpfeArray[i]->calculate();
210
211 double sum(0);
212 double carry = 0.;
213 for (Int_t i = 0; i < _nCPU; ++i) {
214 double y = _mpfeArray[i]->getValV();
215 carry += _mpfeArray[i]->getCarry();
216 y -= carry;
217 const double t = sum + y;
218 carry = (t - sum) - y;
219 sum = t;
220 }
221
222 double ret = sum ;
223 _evalCarry = carry;
224
225 const double norm = globalNormalization();
226 ret /= norm;
227 _evalCarry /= norm;
228
229 return ret ;
230
231 } else {
232
233 // Evaluate as straight FUNC
234 Int_t nFirst(0);
235 Int_t nLast(_nEvents);
236 Int_t nStep(1);
237
238 switch (_mpinterl) {
240 nFirst = _nEvents * _setNum / _numSets ;
241 nLast = _nEvents * (_setNum+1) / _numSets ;
242 nStep = 1 ;
243 break;
244
246 nFirst = _setNum ;
247 nLast = _nEvents ;
248 nStep = _numSets ;
249 break ;
250
252 nFirst = 0 ;
253 nLast = _nEvents ;
254 nStep = 1 ;
255 break ;
256
257 case RooFit::Hybrid:
258 throw std::logic_error("this should never happen");
259 break ;
260 }
261
262 runRecalculateCache(nFirst, nLast, nStep);
263 double ret = evaluatePartition(nFirst,nLast,nStep);
264
265 if (numSets()==1) {
266 const double norm = globalNormalization();
267 ret /= norm;
268 _evalCarry /= norm;
269 }
270
271 return ret ;
272
273 }
274}
275
276
277
278////////////////////////////////////////////////////////////////////////////////
279/// One-time initialization of the test statistic. Setup
280/// infrastructure for simultaneous p.d.f processing and/or
281/// parallelized processing if requested
282
284{
285 if (_init) return false;
286
287 if (MPMaster == _gofOpMode) {
289 } else if (SimMaster == _gofOpMode) {
291 }
292 _init = true;
293 return false;
294}
295
296
297
298////////////////////////////////////////////////////////////////////////////////
299/// Forward server redirect calls to component test statistics
300
301bool RooAbsTestStatistic::redirectServersHook(const RooAbsCollection& newServerList, bool mustReplaceAll, bool nameChange, bool isRecursive)
302{
303 if (SimMaster == _gofOpMode) {
304 // Forward to slaves
305 for(auto& gof : _gofArray) {
306 gof->recursiveRedirectServers(newServerList,mustReplaceAll,nameChange);
307 }
308 } else if (MPMaster == _gofOpMode&& _mpfeArray) {
309 // Forward to slaves
310 for (Int_t i = 0; i < _nCPU; ++i) {
311 if (_mpfeArray[i]) {
312 _mpfeArray[i]->recursiveRedirectServers(newServerList,mustReplaceAll,nameChange);
313// cout << "redirecting servers on " << _mpfeArray[i]->GetName() << endl;
314 }
315 }
316 }
317 return RooAbsReal::redirectServersHook(newServerList, mustReplaceAll, nameChange, isRecursive);
318}
319
320
321
322////////////////////////////////////////////////////////////////////////////////
323/// Add extra information on component test statistics when printing
324/// itself as part of a tree structure
325
327{
328 if (SimMaster == _gofOpMode) {
329 // Forward to slaves
330 os << indent << "RooAbsTestStatistic begin GOF contents" << endl ;
331 for (std::size_t i = 0; i < _gofArray.size(); ++i) {
332 TString indent2(indent);
333 indent2 += "[" + std::to_string(i) + "] ";
334 _gofArray[i]->printCompactTreeHook(os,indent2);
335 }
336 os << indent << "RooAbsTestStatistic end GOF contents" << endl;
337 } else if (MPMaster == _gofOpMode) {
338 // WVE implement this
339 }
340}
341
342
343
344////////////////////////////////////////////////////////////////////////////////
345/// Forward constant term optimization management calls to component
346/// test statistics
347
349{
350 initialize();
351 if (SimMaster == _gofOpMode) {
352 // Forward to slaves
353 int i = 0;
354 for (auto& gof : _gofArray) {
355 // In SimComponents Splitting strategy only constOptimize the terms that are actually used
356 RooFit::MPSplit effSplit = (_mpinterl!=RooFit::Hybrid) ? _mpinterl : gof->_mpinterl;
357 if ( (i % _numSets == _setNum) || (effSplit != RooFit::SimComponents) ) {
358 gof->constOptimizeTestStatistic(opcode,doAlsoTrackingOpt);
359 }
360 ++i;
361 }
362 } else if (MPMaster == _gofOpMode) {
363 for (Int_t i = 0; i < _nCPU; ++i) {
364 _mpfeArray[i]->constOptimizeTestStatistic(opcode,doAlsoTrackingOpt);
365 }
366 }
367}
368
369
370
371////////////////////////////////////////////////////////////////////////////////
372/// Set MultiProcessor set number identification of this instance
373
375{
376 _setNum = inSetNum; _numSets = inNumSets;
378
379 if (SimMaster == _gofOpMode) {
380 // Forward to slaves
381 initialize();
382 for(auto& gof : _gofArray) {
383 gof->setMPSet(inSetNum,inNumSets);
384 }
385 }
386}
387
388
389
390////////////////////////////////////////////////////////////////////////////////
391/// Initialize multi-processor calculation mode. Create component test statistics in separate
392/// processed that are connected to this process through a RooAbsRealMPFE front-end class.
393
394void RooAbsTestStatistic::initMPMode(RooAbsReal* real, RooAbsData* data, const RooArgSet* projDeps, std::string const& rangeName, std::string const& addCoefRangeName)
395{
397
398 // Create proto-goodness-of-fit
399 Configuration cfg;
400 cfg.rangeName = rangeName;
401 cfg.addCoefRangeName = addCoefRangeName;
402 cfg.nCPU = 1;
403 cfg.interleave = _mpinterl;
404 cfg.verbose = _verbose;
407 // This configuration parameter is stored in the RooAbsOptTestStatistic.
408 // It would have been cleaner to move the member variable into RooAbsTestStatistic,
409 // but to avoid incrementing the class version we do the dynamic_cast trick.
410 if(auto thisAsRooAbsOptTestStatistic = dynamic_cast<RooAbsOptTestStatistic const*>(this)) {
411 cfg.integrateOverBinsPrecision = thisAsRooAbsOptTestStatistic->_integrateBinsPrecision;
412 }
413 RooAbsTestStatistic* gof = create(GetName(),GetTitle(),*real,*data,*projDeps,cfg);
415
416 for (Int_t i = 0; i < _nCPU; ++i) {
417 gof->setMPSet(i,_nCPU);
418 gof->SetName(Form("%s_GOF%d",GetName(),i));
419 gof->SetTitle(Form("%s_GOF%d",GetTitle(),i));
420
421 ccoutD(Eval) << "RooAbsTestStatistic::initMPMode: starting remote server process #" << i << endl;
422 _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);
423 //_mpfeArray[i]->setVerbose(true,true);
425 if (i > 0) {
427 }
428 }
430 coutI(Eval) << "RooAbsTestStatistic::initMPMode: started " << _nCPU << " remote server process." << endl;
431 //cout << "initMPMode --- done" << endl ;
432 return ;
433}
434
435
436
437////////////////////////////////////////////////////////////////////////////////
438/// Initialize simultaneous p.d.f processing mode. Strip simultaneous
439/// p.d.f into individual components, split dataset in subset
440/// matching each component and create component test statistics for
441/// each of them.
442
444 const RooArgSet* projDeps,
445 std::string const& rangeName, std::string const& addCoefRangeName)
446{
447
448 RooAbsCategoryLValue& simCat = const_cast<RooAbsCategoryLValue&>(simpdf->indexCat());
449
450 std::unique_ptr<TList> dsetList{const_cast<RooAbsData*>(data)->split(*simpdf,processEmptyDataSets())};
451
452 // Create array of regular fit contexts, containing subset of data and single fitCat PDF
453 for (const auto& catState : simCat) {
454 const std::string& catName = catState.first;
455 RooAbsCategory::value_type catIndex = catState.second;
456
457 // If the channel is not in the selected range of the category variable, we
458 // won't create a slave calculator for this channel.
459 if(!rangeName.empty()) {
460 // Only the RooCategory supports ranges, not the other
461 // RooAbsCategoryLValue-derived classes.
462 auto simCatAsRooCategory = dynamic_cast<RooCategory*>(&simCat);
463 if(simCatAsRooCategory && !simCatAsRooCategory->isStateInRange(rangeName.c_str(), catIndex)) {
464 continue;
465 }
466 }
467
468 // Retrieve the PDF for this simCat state
469 RooAbsPdf* pdf = simpdf->getPdf(catName.c_str());
470 RooAbsData* dset = static_cast<RooAbsData*>(dsetList->FindObject(catName.c_str()));
471
472 if (pdf && dset && (0. != dset->sumEntries() || processEmptyDataSets())) {
473 ccoutI(Fitting) << "RooAbsTestStatistic::initSimMode: creating slave calculator #" << _gofArray.size() << " for state " << catName
474 << " (" << dset->numEntries() << " dataset entries)" << endl;
475
476
477 // *** START HERE
478 // WVE HACK determine if we have a RooRealSumPdf and then treat it like a binned likelihood
479 auto binnedInfo = RooHelpers::getBinnedL(*pdf);
480 RooAbsReal &actualPdf = binnedInfo.binnedPdf ? *binnedInfo.binnedPdf : *pdf;
481 // WVE END HACK
482 // Below here directly pass binnedPdf instead of PROD(binnedPdf,constraints) as constraints are evaluated elsewhere anyway
483 // and omitting them reduces model complexity and associated handling/cloning times
484 Configuration cfg;
485 cfg.addCoefRangeName = addCoefRangeName;
486 cfg.interleave = _mpinterl;
487 cfg.verbose = _verbose;
489 cfg.binnedL = binnedInfo.isBinnedL;
491 // This configuration parameter is stored in the RooAbsOptTestStatistic.
492 // It would have been cleaner to move the member variable into RooAbsTestStatistic,
493 // but to avoid incrementing the class version we do the dynamic_cast trick.
494 if(auto thisAsRooAbsOptTestStatistic = dynamic_cast<RooAbsOptTestStatistic const*>(this)) {
495 cfg.integrateOverBinsPrecision = thisAsRooAbsOptTestStatistic->_integrateBinsPrecision;
496 }
498 cfg.nCPU = _nCPU;
499 _gofArray.emplace_back(create(catName.c_str(),catName.c_str(),actualPdf,*dset,*projDeps,cfg));
500 // *** END HERE
501
502 // Fill per-component split mode with Bulk Partition for now so that Auto will map to bulk-splitting of all components
504 _gofArray.back()->_mpinterl = dset->numEntries()<10 ? RooFit::SimComponents : RooFit::BulkPartition;
505 }
506
507 // Servers may have been redirected between instantiation and (deferred) initialization
508
509 RooArgSet actualParams;
510 actualPdf.getParameters(dset->get(), actualParams);
511 RooArgSet selTargetParams;
512 _paramSet.selectCommon(actualParams, selTargetParams);
513
514 _gofArray.back()->recursiveRedirectServers(selTargetParams);
515 }
516 }
517 for(auto& gof : _gofArray) {
518 gof->setSimCount(_gofArray.size());
519 }
520 coutI(Fitting) << "RooAbsTestStatistic::initSimMode: created " << _gofArray.size() << " slave calculators." << endl;
521
522 dsetList->Delete(); // delete the content.
523}
524
525
526////////////////////////////////////////////////////////////////////////////////
527/// Change dataset that is used to given one. If cloneData is true, a clone of
528/// in the input dataset is made. If the test statistic was constructed with
529/// a range specification on the data, the cloneData argument is ignored and
530/// the data is always cloned.
531bool RooAbsTestStatistic::setData(RooAbsData& indata, bool cloneData)
532{
533 // Trigger refresh of likelihood offsets
534 if (isOffsetting()) {
535 enableOffsetting(false);
536 enableOffsetting(true);
537 }
538
539 switch(operMode()) {
540 case Slave:
541 // Delegate to implementation
542 return setDataSlave(indata, cloneData);
543 case SimMaster:
544 // Forward to slaves
545 if (indata.canSplitFast()) {
546 for(auto& gof : _gofArray) {
547 RooAbsData* compData = indata.getSimData(gof->GetName());
548 gof->setDataSlave(*compData, cloneData);
549 }
550 } else if (0 == indata.numEntries()) {
551 // For an unsplit empty dataset, simply assign empty dataset to each component
552 for(auto& gof : _gofArray) {
553 gof->setDataSlave(indata, cloneData);
554 }
555 } else {
556 std::unique_ptr<TList> dlist{indata.split(*static_cast<RooSimultaneous*>(_func), processEmptyDataSets())};
557 if (!dlist) {
558 coutE(Fitting) << "RooAbsTestStatistic::initSimMode(" << GetName() << ") ERROR: index category of simultaneous pdf is missing in dataset, aborting" << endl;
559 throw std::runtime_error("RooAbsTestStatistic::initSimMode() ERROR, index category of simultaneous pdf is missing in dataset, aborting");
560 }
561
562 for(auto& gof : _gofArray) {
563 if (auto compData = static_cast<RooAbsData*>(dlist->FindObject(gof->GetName()))) {
564 gof->setDataSlave(*compData,false,true);
565 } else {
566 coutE(DataHandling) << "RooAbsTestStatistic::setData(" << GetName() << ") ERROR: Cannot find component data for state " << gof->GetName() << endl;
567 }
568 }
569 }
570 break;
571 case MPMaster:
572 // Not supported
573 coutF(DataHandling) << "RooAbsTestStatistic::setData(" << GetName() << ") FATAL: setData() is not supported in multi-processor mode" << endl;
574 throw std::runtime_error("RooAbsTestStatistic::setData is not supported in MPMaster mode");
575 break;
576 }
577
578 return true;
579}
580
581
582
584{
585 // Apply internal value offsetting to control numeric precision
586 if (!_init) {
587 const_cast<RooAbsTestStatistic*>(this)->initialize() ;
588 }
589
590 switch(operMode()) {
591 case Slave:
592 _doOffset = flag ;
593 // Clear offset if feature is disabled to that it is recalculated next time it is enabled
594 if (!_doOffset) {
596 }
597 setValueDirty() ;
598 break ;
599 case SimMaster:
600 _doOffset = flag;
601 for(auto& gof : _gofArray) {
602 gof->enableOffsetting(flag);
603 }
604 break ;
605 case MPMaster:
606 _doOffset = flag;
607 for (Int_t i = 0; i < _nCPU; ++i) {
609 }
610 break;
611 }
612}
613
614
616{ return _evalCarry; }
RooArgSet * _projDeps
Set of projected observable.
const bool _takeGlobalObservablesFromData
If the global observable values are taken from data.
bool _splitRange
Split rangeName in RooSimultaneous index labels if true.
bool _doOffset
Apply interval value offset to control numeric precision?
bool _verbose
Verbose messaging if true.
RooFit::MPSplit _mpinterl
Use interleaving strategy rather than N-wise split for partitioning of dataset for multiprocessor-spl...
Int_t _nCPU
Number of processors to use in parallel calculation mode.
std::string _addCoefRangeName
Name of reference to be used for RooAddPdf components.
@ SimMaster
RooAbsData * _data
Pointer to original input dataset.
ROOT::Math::KahanSum< double > _offset
! Offset as KahanSum to avoid loss of precision
RooSetProxy _paramSet
Parameters of the test statistic (=parameters of the input function)
RooAbsReal * _func
Pointer to original input function.
std::string _rangeName
Name of range in which to calculate test statistic.
Int_t _nEvents
Total number of events in test statistic calculation.
double _evalCarry
! carry of Kahan sum in evaluatePartition
GOFOpMode _gofOpMode
Operation mode of test statistic instance.
#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: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:488
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:55
RooArgSet * selectCommon(const RooAbsCollection &refColl) const
Use RooAbsCollection::selecCommon(), but return as RooArgSet.
Definition RooArgSet.h:186
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