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