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 "RooFit.h"
40#include "RooAbsPdf.h"
41#include "RooSimultaneous.h"
42#include "RooAbsData.h"
43#include "RooArgSet.h"
44#include "RooRealVar.h"
45#include "RooNLLVar.h"
46#include "RooRealMPFE.h"
47#include "RooErrorHandler.h"
48#include "RooMsgService.h"
49#include "RooProdPdf.h"
50#include "RooRealSumPdf.h"
52
53#include "TTimeStamp.h"
54#include "TClass.h"
55#include <string>
56
57using namespace std;
58
60
61////////////////////////////////////////////////////////////////////////////////
62/// Default constructor
63
65 _func(0), _data(0), _projDeps(0), _splitRange(0), _simCount(0),
66 _verbose(kFALSE), _init(kFALSE), _gofOpMode(Slave), _nEvents(0), _setNum(0),
67 _numSets(0), _extSet(0), _nGof(0), _gofArray(0), _nCPU(1), _mpfeArray(0),
68 _mpinterl(RooFit::BulkPartition), _doOffset(kFALSE), _offset(0),
69 _offsetCarry(0), _evalCarry(0)
70{
71}
72
73
74
75////////////////////////////////////////////////////////////////////////////////
76/// Create a test statistic from the given function and the data.
77/// \param[in] name Name of the test statistic
78/// \param[in] title Title (for plotting)
79/// \param[in] real Function to be used for tests
80/// \param[in] data Data to fit function to
81/// \param[in] projDeps A set of projected observables
82/// \param[in] rangeName Fit data only in range with given name
83/// \param[in] addCoefRangeName If not null, all RooAddPdf components of `real` will be instructed to fix their fraction definitions to the given named range.
84/// \param[in] nCPU If larger than one, the test statistic calculation will be parallelized over multiple processes.
85/// By default the data is split with 'bulk' partitioning (each process calculates a contigious block of fraction 1/nCPU
86/// of the data). For binned data this approach may be suboptimal as the number of bins with >0 entries
87/// in each processing block many vary greatly thereby distributing the workload rather unevenly.
88/// \param[in] interleave is set to true, the interleave partitioning strategy is used where each partition
89/// i takes all bins for which (ibin % ncpu == i) which is more likely to result in an even workload.
90/// \param[in] verbose Be more verbose.
91/// \param[in] splitCutRange If true, a different rangeName constructed as rangeName_{catName} will be used
92/// as range definition for each index state of a RooSimultaneous. This means that a different range can be defined
93/// for each category such as
94/// ```
95/// myVariable.setRange("range_pi0", 135, 210);
96/// myVariable.setRange("range_gamma", 50, 210);
97/// ```
98/// if the categories are called "pi0" and "gamma".
99
100RooAbsTestStatistic::RooAbsTestStatistic(const char *name, const char *title, RooAbsReal& real, RooAbsData& data,
101 const RooArgSet& projDeps, const char* rangeName, const char* addCoefRangeName,
102 Int_t nCPU, RooFit::MPSplit interleave, Bool_t verbose, Bool_t splitCutRange) :
103 RooAbsReal(name,title),
104 _paramSet("paramSet","Set of parameters",this),
105 _func(&real),
106 _data(&data),
107 _projDeps((RooArgSet*)projDeps.Clone()),
108 _rangeName(rangeName?rangeName:""),
109 _addCoefRangeName(addCoefRangeName?addCoefRangeName:""),
110 _splitRange(splitCutRange),
111 _simCount(1),
112 _verbose(verbose),
113 _nGof(0),
114 _gofArray(0),
115 _nCPU(nCPU),
116 _mpfeArray(0),
117 _mpinterl(interleave),
118 _doOffset(kFALSE),
119 _offset(0),
120 _offsetCarry(0),
121 _evalCarry(0)
122{
123 // Register all parameters as servers
124 RooArgSet* params = real.getParameters(&data) ;
125 _paramSet.add(*params) ;
126 delete params ;
127
128 if (_nCPU>1 || _nCPU==-1) {
129
130 if (_nCPU==-1) {
131 _nCPU=1 ;
132 }
133
135
136 } else {
137
138 // Determine if RooAbsReal is a RooSimultaneous
139 Bool_t simMode = dynamic_cast<RooSimultaneous*>(&real)?kTRUE:kFALSE ;
140
141 if (simMode) {
143 } else {
144 _gofOpMode = Slave ;
145 }
146 }
147
148 _setNum = 0 ;
149 _extSet = 0 ;
150 _numSets = 1 ;
151 _init = kFALSE ;
152 _nEvents = data.numEntries() ;
153}
154
155
156
157////////////////////////////////////////////////////////////////////////////////
158/// Copy constructor
159
161 RooAbsReal(other,name),
162 _paramSet("paramSet","Set of parameters",this),
163 _func(other._func),
164 _data(other._data),
165 _projDeps((RooArgSet*)other._projDeps->Clone()),
166 _rangeName(other._rangeName),
167 _addCoefRangeName(other._addCoefRangeName),
168 _splitRange(other._splitRange),
169 _simCount(1),
170 _verbose(other._verbose),
171 _nGof(0),
172 _gofArray(0),
173 _gofSplitMode(other._gofSplitMode),
174 _nCPU(other._nCPU),
175 _mpfeArray(0),
176 _mpinterl(other._mpinterl),
177 _doOffset(other._doOffset),
178 _offset(other._offset),
179 _offsetCarry(other._offsetCarry),
180 _evalCarry(other._evalCarry)
181{
182 // Our parameters are those of original
183 _paramSet.add(other._paramSet) ;
184
185 if (_nCPU>1 || _nCPU==-1) {
186
187 if (_nCPU==-1) {
188 _nCPU=1 ;
189 }
190
192
193 } else {
194
195 // Determine if RooAbsReal is a RooSimultaneous
196 Bool_t simMode = dynamic_cast<RooSimultaneous*>(_func)?kTRUE:kFALSE ;
197
198 if (simMode) {
200 } else {
201 _gofOpMode = Slave ;
202 }
203 }
204
205 _setNum = 0 ;
206 _extSet = 0 ;
207 _numSets = 1 ;
208 _init = kFALSE ;
210
211
212}
213
214
215
216////////////////////////////////////////////////////////////////////////////////
217/// Destructor
218
220{
221 if (MPMaster == _gofOpMode && _init) {
222 for (Int_t i = 0; i < _nCPU; ++i) delete _mpfeArray[i];
223 delete[] _mpfeArray ;
224 }
225
226 if (SimMaster == _gofOpMode && _init) {
227 for (Int_t i = 0; i < _nGof; ++i) delete _gofArray[i];
228 delete[] _gofArray ;
229 }
230
231 delete _projDeps ;
232
233}
234
235
236
237////////////////////////////////////////////////////////////////////////////////
238/// Calculate and return value of test statistic. If the test statistic
239/// is calculated from a RooSimultaneous, the test statistic calculation
240/// is performed separately on each simultaneous p.d.f component and associated
241/// data, and then combined. If the test statistic calculation is parallelized,
242/// partitions are calculated in nCPU processes and combined a posteriori.
243
245{
246 // One-time Initialization
247 if (!_init) {
248 const_cast<RooAbsTestStatistic*>(this)->initialize() ;
249 }
250
251 if (SimMaster == _gofOpMode) {
252 // Evaluate array of owned GOF objects
253 Double_t ret = 0.;
254
257 } else {
258 Double_t sum = 0., carry = 0.;
259 for (Int_t i = 0 ; i < _nGof; ++i) {
261 Double_t y = _gofArray[i]->getValV();
262 carry += _gofArray[i]->getCarry();
263 y -= carry;
264 const Double_t t = sum + y;
265 carry = (t - sum) - y;
266 sum = t;
267 }
268 }
269 ret = sum ;
270 _evalCarry = carry;
271 }
272
273 // Only apply global normalization if SimMaster doesn't have MP master
274 if (numSets()==1) {
275 const Double_t norm = globalNormalization();
276 ret /= norm;
277 _evalCarry /= norm;
278 }
279
280 return ret ;
281
282 } else if (MPMaster == _gofOpMode) {
283
284 // Start calculations in parallel
285 for (Int_t i = 0; i < _nCPU; ++i) _mpfeArray[i]->calculate();
286
287
288 Double_t sum(0), carry = 0.;
289 for (Int_t i = 0; i < _nCPU; ++i) {
291 carry += _mpfeArray[i]->getCarry();
292 y -= carry;
293 const Double_t t = sum + y;
294 carry = (t - sum) - y;
295 sum = t;
296 }
297
298 Double_t ret = sum ;
299 _evalCarry = carry;
300 return ret ;
301
302 } else {
303
304 // Evaluate as straight FUNC
305 Int_t nFirst(0), nLast(_nEvents), nStep(1) ;
306
307 switch (_mpinterl) {
309 nFirst = _nEvents * _setNum / _numSets ;
310 nLast = _nEvents * (_setNum+1) / _numSets ;
311 nStep = 1 ;
312 break;
313
315 nFirst = _setNum ;
316 nLast = _nEvents ;
317 nStep = _numSets ;
318 break ;
319
321 nFirst = 0 ;
322 nLast = _nEvents ;
323 nStep = 1 ;
324 break ;
325
326 case RooFit::Hybrid:
327 throw(std::string("this should never happen")) ;
328 break ;
329 }
330
331 Double_t ret = evaluatePartition(nFirst,nLast,nStep);
332
333 if (numSets()==1) {
334 const Double_t norm = globalNormalization();
335 ret /= norm;
336 _evalCarry /= norm;
337 }
338
339 return ret ;
340
341 }
342}
343
344
345
346////////////////////////////////////////////////////////////////////////////////
347/// One-time initialization of the test statistic. Setup
348/// infrastructure for simultaneous p.d.f processing and/or
349/// parallelized processing if requested
350
352{
353 if (_init) return kFALSE;
354
355 if (MPMaster == _gofOpMode) {
357 } else if (SimMaster == _gofOpMode) {
359 }
360 _init = kTRUE;
361 return kFALSE;
362}
363
364
365
366////////////////////////////////////////////////////////////////////////////////
367/// Forward server redirect calls to component test statistics
368
369Bool_t RooAbsTestStatistic::redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t)
370{
371 if (SimMaster == _gofOpMode && _gofArray) {
372 // Forward to slaves
373 for (Int_t i = 0; i < _nGof; ++i) {
374 if (_gofArray[i]) {
375 _gofArray[i]->recursiveRedirectServers(newServerList,mustReplaceAll,nameChange);
376 }
377 }
378 } else if (MPMaster == _gofOpMode&& _mpfeArray) {
379 // Forward to slaves
380 for (Int_t i = 0; i < _nCPU; ++i) {
381 if (_mpfeArray[i]) {
382 _mpfeArray[i]->recursiveRedirectServers(newServerList,mustReplaceAll,nameChange);
383// cout << "redirecting servers on " << _mpfeArray[i]->GetName() << endl;
384 }
385 }
386 }
387 return kFALSE;
388}
389
390
391
392////////////////////////////////////////////////////////////////////////////////
393/// Add extra information on component test statistics when printing
394/// itself as part of a tree structure
395
397{
398 if (SimMaster == _gofOpMode) {
399 // Forward to slaves
400 os << indent << "RooAbsTestStatistic begin GOF contents" << endl ;
401 for (Int_t i = 0; i < _nGof; ++i) {
402 if (_gofArray[i]) {
403 TString indent2(indent);
404 indent2 += Form("[%d] ",i);
405 _gofArray[i]->printCompactTreeHook(os,indent2);
406 }
407 }
408 os << indent << "RooAbsTestStatistic end GOF contents" << endl;
409 } else if (MPMaster == _gofOpMode) {
410 // WVE implement this
411 }
412}
413
414
415
416////////////////////////////////////////////////////////////////////////////////
417/// Forward constant term optimization management calls to component
418/// test statistics
419
421{
422 initialize();
423 if (SimMaster == _gofOpMode) {
424 // Forward to slaves
425 for (Int_t i = 0; i < _nGof; ++i) {
426 // In SimComponents Splitting strategy only constOptimize the terms that are actually used
428 if ( (i % _numSets == _setNum) || (effSplit != RooFit::SimComponents) ) {
429 if (_gofArray[i]) _gofArray[i]->constOptimizeTestStatistic(opcode,doAlsoTrackingOpt);
430 }
431 }
432 } else if (MPMaster == _gofOpMode) {
433 for (Int_t i = 0; i < _nCPU; ++i) {
434 _mpfeArray[i]->constOptimizeTestStatistic(opcode,doAlsoTrackingOpt);
435 }
436 }
437}
438
439
440
441////////////////////////////////////////////////////////////////////////////////
442/// Set MultiProcessor set number identification of this instance
443
445{
446 _setNum = inSetNum; _numSets = inNumSets;
448
449 if (SimMaster == _gofOpMode) {
450 // Forward to slaves
451 initialize();
452 for (Int_t i = 0; i < _nGof; ++i) {
453 if (_gofArray[i]) _gofArray[i]->setMPSet(inSetNum,inNumSets);
454 }
455 }
456}
457
458
459
460////////////////////////////////////////////////////////////////////////////////
461/// Initialize multi-processor calculation mode. Create component test statistics in separate
462/// processed that are connected to this process through a RooAbsRealMPFE front-end class.
463
464void RooAbsTestStatistic::initMPMode(RooAbsReal* real, RooAbsData* data, const RooArgSet* projDeps, const char* rangeName, const char* addCoefRangeName)
465{
467
468 // Create proto-goodness-of-fit
469 RooAbsTestStatistic* gof = create(GetName(),GetTitle(),*real,*data,*projDeps,rangeName,addCoefRangeName,1,_mpinterl,_verbose,_splitRange);
471
472 for (Int_t i = 0; i < _nCPU; ++i) {
473 gof->setMPSet(i,_nCPU);
474 gof->SetName(Form("%s_GOF%d",GetName(),i));
475 gof->SetTitle(Form("%s_GOF%d",GetTitle(),i));
476
477 ccoutD(Eval) << "RooAbsTestStatistic::initMPMode: starting remote server process #" << i << endl;
478 _mpfeArray[i] = new RooRealMPFE(Form("%s_%lx_MPFE%d",GetName(),(ULong_t)this,i),Form("%s_%lx_MPFE%d",GetTitle(),(ULong_t)this,i),*gof,false);
479 //_mpfeArray[i]->setVerbose(kTRUE,kTRUE);
481 if (i > 0) {
483 }
484 }
486 coutI(Eval) << "RooAbsTestStatistic::initMPMode: started " << _nCPU << " remote server process." << endl;
487 //cout << "initMPMode --- done" << endl ;
488 return ;
489}
490
491
492
493////////////////////////////////////////////////////////////////////////////////
494/// Initialize simultaneous p.d.f processing mode. Strip simultaneous
495/// p.d.f into individual components, split dataset in subset
496/// matching each component and create component test statistics for
497/// each of them.
498
500 const RooArgSet* projDeps, const char* rangeName, const char* addCoefRangeName)
501{
502
504
505 TString simCatName(simCat.GetName());
506 TList* dsetList = const_cast<RooAbsData*>(data)->split(simCat,processEmptyDataSets());
507 if (!dsetList) {
508 coutE(Fitting) << "RooAbsTestStatistic::initSimMode(" << GetName() << ") ERROR: index category of simultaneous pdf is missing in dataset, aborting" << endl;
509 throw std::string("RooAbsTestStatistic::initSimMode() ERROR, index category of simultaneous pdf is missing in dataset, aborting");
510 //RooErrorHandler::softAbort() ;
511 }
512
513 // Count number of used states
514 Int_t n = 0;
515 _nGof = 0;
516
517 for (const auto& catState : simCat) {
518 // Retrieve the PDF for this simCat state
519 RooAbsPdf* pdf = simpdf->getPdf(catState.first.c_str());
520 RooAbsData* dset = (RooAbsData*) dsetList->FindObject(catState.first.c_str());
521
522 if (pdf && dset && (0. != dset->sumEntries() || processEmptyDataSets())) {
523 ++_nGof;
524 }
525 }
526
527 // Allocate arrays
529 _gofSplitMode.resize(_nGof);
530
531 // Create array of regular fit contexts, containing subset of data and single fitCat PDF
532 for (const auto& catState : simCat) {
533 const std::string& catName = catState.first;
534 // Retrieve the PDF for this simCat state
535 RooAbsPdf* pdf = simpdf->getPdf(catName.c_str());
536 RooAbsData* dset = (RooAbsData*) dsetList->FindObject(catName.c_str());
537
538 if (pdf && dset && (0. != dset->sumEntries() || processEmptyDataSets())) {
539 ccoutI(Fitting) << "RooAbsTestStatistic::initSimMode: creating slave calculator #" << n << " for state " << catName
540 << " (" << dset->numEntries() << " dataset entries)" << endl;
541
542
543 // *** START HERE
544 // WVE HACK determine if we have a RooRealSumPdf and then treat it like a binned likelihood
545 RooAbsPdf* binnedPdf = 0 ;
546 Bool_t binnedL = kFALSE ;
547 if (pdf->getAttribute("BinnedLikelihood") && pdf->IsA()->InheritsFrom(RooRealSumPdf::Class())) {
548 // Simplest case: top-level of component is a RRSP
549 binnedPdf = pdf ;
550 binnedL = kTRUE ;
551 } else if (pdf->IsA()->InheritsFrom(RooProdPdf::Class())) {
552 // Default case: top-level pdf is a product of RRSP and other pdfs
553 RooFIter iter = ((RooProdPdf*)pdf)->pdfList().fwdIterator() ;
554 RooAbsArg* component ;
555 while ((component = iter.next())) {
556 if (component->getAttribute("BinnedLikelihood") && component->IsA()->InheritsFrom(RooRealSumPdf::Class())) {
557 binnedPdf = (RooAbsPdf*) component ;
558 binnedL = kTRUE ;
559 }
560 if (component->getAttribute("MAIN_MEASUREMENT")) {
561 // not really a binned pdf, but this prevents a (potentially) long list of subsidiary measurements to be passed to the slave calculator
562 binnedPdf = (RooAbsPdf*) component ;
563 }
564 }
565 }
566 // WVE END HACK
567 // Below here directly pass binnedPdf instead of PROD(binnedPdf,constraints) as constraints are evaluated elsewhere anyway
568 // and omitting them reduces model complexity and associated handling/cloning times
569 if (_splitRange && rangeName) {
570 _gofArray[n] = create(catName.c_str(), catName.c_str(),(binnedPdf?*binnedPdf:*pdf),*dset,*projDeps,
571 Form("%s_%s",rangeName,catName.c_str()),addCoefRangeName,_nCPU*(_mpinterl?-1:1),_mpinterl,_verbose,_splitRange,binnedL);
572 } else {
573 _gofArray[n] = create(catName.c_str(),catName.c_str(),(binnedPdf?*binnedPdf:*pdf),*dset,*projDeps,
574 rangeName,addCoefRangeName,_nCPU,_mpinterl,_verbose,_splitRange,binnedL);
575 }
577 // *** END HERE
578
579 // Fill per-component split mode with Bulk Partition for now so that Auto will map to bulk-splitting of all components
581 if (dset->numEntries()<10) {
582 //cout << "RAT::initSim("<< GetName() << ") MP mode is auto, setting split mode for component "<< n << " to SimComponents"<< endl ;
585 } else {
586 //cout << "RAT::initSim("<< GetName() << ") MP mode is auto, setting split mode for component "<< n << " to BulkPartition"<< endl ;
589 }
590 }
591
592 // Servers may have been redirected between instantiation and (deferred) initialization
593
594 RooArgSet *actualParams = binnedPdf ? binnedPdf->getParameters(dset) : pdf->getParameters(dset);
595 RooArgSet* selTargetParams = (RooArgSet*) _paramSet.selectCommon(*actualParams);
596
597 _gofArray[n]->recursiveRedirectServers(*selTargetParams);
598
599 delete selTargetParams;
600 delete actualParams;
601
602 ++n;
603
604 } else {
605 if ((!dset || (0. != dset->sumEntries() && !processEmptyDataSets())) && pdf) {
606 if (_verbose) {
607 ccoutD(Fitting) << "RooAbsTestStatistic::initSimMode: state " << catName
608 << " has no data entries, no slave calculator created" << endl;
609 }
610 }
611 }
612 }
613 coutI(Fitting) << "RooAbsTestStatistic::initSimMode: created " << n << " slave calculators." << endl;
614
615 dsetList->Delete(); // delete the content.
616 delete dsetList;
617}
618
619
620////////////////////////////////////////////////////////////////////////////////
621/// Change dataset that is used to given one. If cloneData is kTRUE, a clone of
622/// in the input dataset is made. If the test statistic was constructed with
623/// a range specification on the data, the cloneData argument is ignored and
624/// the data is always cloned.
626{
627 // Trigger refresh of likelihood offsets
628 if (isOffsetting()) {
631 }
632
633 switch(operMode()) {
634 case Slave:
635 // Delegate to implementation
636 return setDataSlave(indata, cloneData);
637 case SimMaster:
638 // Forward to slaves
639 // cout << "RATS::setData(" << GetName() << ") SimMaster, calling setDataSlave() on slave nodes" << endl;
640 if (indata.canSplitFast()) {
641 for (Int_t i = 0; i < _nGof; ++i) {
642 RooAbsData* compData = indata.getSimData(_gofArray[i]->GetName());
643 _gofArray[i]->setDataSlave(*compData, cloneData);
644 }
645 } else if (0 == indata.numEntries()) {
646 // For an unsplit empty dataset, simply assign empty dataset to each component
647 for (Int_t i = 0; i < _nGof; ++i) {
648 _gofArray[i]->setDataSlave(indata, cloneData);
649 }
650 } else {
651 const RooAbsCategoryLValue& indexCat = static_cast<RooSimultaneous*>(_func)->indexCat();
652 TList* dlist = indata.split(indexCat, kTRUE);
653 if (!dlist) {
654 coutF(DataHandling) << "Tried to split '" << indata.GetName() << "' into categories of '" << indexCat.GetName()
655 << "', but splitting failed. Input data:" << std::endl;
656 indata.Print("V");
657 throw std::runtime_error("Error when setting up test statistic: dataset couldn't be split into categories.");
658 }
659
660 for (Int_t i = 0; i < _nGof; ++i) {
661 RooAbsData* compData = (RooAbsData*) dlist->FindObject(_gofArray[i]->GetName());
662 // cout << "component data for index " << _gofArray[i]->GetName() << " is " << compData << endl;
663 if (compData) {
664 _gofArray[i]->setDataSlave(*compData,kFALSE,kTRUE);
665 } else {
666 coutE(DataHandling) << "RooAbsTestStatistic::setData(" << GetName() << ") ERROR: Cannot find component data for state " << _gofArray[i]->GetName() << endl;
667 }
668 }
669 }
670 break;
671 case MPMaster:
672 // Not supported
673 coutF(DataHandling) << "RooAbsTestStatistic::setData(" << GetName() << ") FATAL: setData() is not supported in multi-processor mode" << endl;
674 throw std::runtime_error("RooAbsTestStatistic::setData is not supported in MPMaster mode");
675 break;
676 }
677
678 return kTRUE;
679}
680
681
682
684{
685 // Apply internal value offsetting to control numeric precision
686 if (!_init) {
687 const_cast<RooAbsTestStatistic*>(this)->initialize() ;
688 }
689
690 switch(operMode()) {
691 case Slave:
692 _doOffset = flag ;
693 // Clear offset if feature is disabled to that it is recalculated next time it is enabled
694 if (!_doOffset) {
695 _offset = 0 ;
696 _offsetCarry = 0;
697 }
698 setValueDirty() ;
699 break ;
700 case SimMaster:
701 _doOffset = flag;
702 for (Int_t i = 0; i < _nGof; ++i) {
703 _gofArray[i]->enableOffsetting(flag);
704 }
705 break ;
706 case MPMaster:
707 _doOffset = flag;
708 for (Int_t i = 0; i < _nCPU; ++i) {
710 }
711 break;
712 }
713}
714
715
717{ return _evalCarry; }
void Class()
Definition: Class.C:29
#define coutI(a)
Definition: RooMsgService.h:30
#define coutF(a)
Definition: RooMsgService.h:34
#define coutE(a)
Definition: RooMsgService.h:33
#define ccoutI(a)
Definition: RooMsgService.h:38
#define ccoutD(a)
Definition: RooMsgService.h:37
const Bool_t kFALSE
Definition: RtypesCore.h:90
unsigned long ULong_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
static void indent(ostringstream &buf, int indent_level)
char name[80]
Definition: TGX11.cxx:109
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:73
RooArgSet * getParameters(const RooAbsData *data, Bool_t stripDisconnected=kTRUE) 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:544
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Definition: RooAbsArg.h:487
Bool_t addOwnedComponents(const RooArgSet &comps)
Take ownership of the contents of 'comps'.
Definition: RooAbsArg.cxx:2107
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
Definition: RooAbsArg.cxx:280
Bool_t recursiveRedirectServers(const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE)
Definition: RooAbsArg.cxx:1064
void SetName(const char *name)
Set the name of the TNamed.
Definition: RooAbsArg.cxx:2216
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.
RooAbsCollection * selectCommon(const RooAbsCollection &refColl) 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:44
virtual TList * split(const RooAbsCategory &splitCat, Bool_t createEmptyDataSets=kFALSE) const
Split dataset into subsets based on states of given splitCat in this dataset.
virtual Double_t sumEntries() const =0
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
Definition: RooAbsData.h:175
RooAbsData * getSimData(const char *idxstate)
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:306
Bool_t canSplitFast() const
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:60
virtual Double_t getValV(const RooArgSet *normalisationSet=nullptr) const
Return value of object.
Definition: RooAbsReal.cxx:270
RooAbsTestStatistic is the abstract base class for all test statistics.
virtual Bool_t processEmptyDataSets() const
Int_t _nGof
Number of designated set to calculated extended term.
GOFOpMode operMode() const
void initSimMode(RooSimultaneous *pdf, RooAbsData *data, const RooArgSet *projDeps, const char *rangeName, const char *addCoefRangeName)
Initialize simultaneous p.d.f processing mode.
Int_t _nCPU
GOF MP Split mode specified by component (when Auto is active)
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, const char *rangeName=0, const char *addCoefRangeName=0, Int_t nCPU=1, RooFit::MPSplit interleave=RooFit::BulkPartition, Bool_t verbose=kTRUE, Bool_t splitCutRange=kFALSE, Bool_t binnedL=kFALSE)=0
RooFit::MPSplit _mpinterl
Array of parallel execution frond ends.
virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE)
Forward constant term optimization management calls to component test statistics.
pRooAbsTestStatistic * _gofArray
virtual Double_t globalNormalization() const
Bool_t setData(RooAbsData &data, Bool_t cloneData=kTRUE)
Change dataset that is used to given one.
void enableOffsetting(Bool_t flag)
GOFOpMode _gofOpMode
Is object initialized
RooAbsTestStatistic()
Default constructor.
void setSimCount(Int_t simCount)
virtual Bool_t redirectServersHook(const RooAbsCollection &newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive)
Forward server redirect calls to component test statistics.
virtual Double_t getCarry() const
virtual Double_t evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const =0
virtual Bool_t setDataSlave(RooAbsData &, Bool_t=kTRUE, Bool_t=kFALSE)
virtual ~RooAbsTestStatistic()
Destructor.
const RooArgSet * _projDeps
virtual Double_t combinedValue(RooAbsReal **gofArray, Int_t nVal) const =0
virtual Double_t evaluate() const
Calculate and return value of test statistic.
Bool_t isOffsetting() const
Double_t _evalCarry
avoids loss of precision
void initMPMode(RooAbsReal *real, RooAbsData *data, const RooArgSet *projDeps, const char *rangeName, const char *addCoefRangeName)
Initialize multi-processor calculation mode.
std::vector< RooFit::MPSplit > _gofSplitMode
Array of sub-contexts representing part of the combined test statistic.
Double_t _offsetCarry
Offset.
virtual void printCompactTreeHook(std::ostream &os, const char *indent="")
Add extra information on component test statistics when printing itself as part of a tree structure.
void setMPSet(Int_t setNum, Int_t numSets)
Set MultiProcessor set number identification of this instance.
Bool_t initialize()
One-time initialization of the test statistic.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
RooProdPdf is an efficient implementation of a product of PDFs of the form.
Definition: RooProdPdf.h:31
RooRealMPFE is the multi-processor front-end for parallel calculation of RooAbsReal objects.
Definition: RooRealMPFE.h:30
virtual Double_t getCarry() const
void initialize()
Initialize the remote process and message passing pipes between current process and remote process.
void enableOffsetting(Bool_t flag)
Control verbose messaging related to inter process communication on both client and server side.
virtual Double_t getValV(const RooArgSet *nset=0) const
If value needs recalculation and calculation has not beed started with a call to calculate() start it...
virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTracking=kTRUE)
Intercept call to optimize constant term in test statistics and forward it to object on server side.
void followAsSlave(RooRealMPFE &master)
Definition: RooRealMPFE.h:48
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...
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.
A doubly linked list.
Definition: TList.h:44
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:577
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:469
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
Basic string class.
Definition: TString.h:131
Double_t y[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
@ SimComponents
Definition: RooGlobalFunc.h:70
@ Interleave
Definition: RooGlobalFunc.h:70
@ BulkPartition
Definition: RooGlobalFunc.h:70
@ DataHandling
Definition: RooGlobalFunc.h:69
static long int sum(long int i)
Definition: Factory.cxx:2275