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