Logo ROOT   6.18/05
Reference Guide
ToyMCSampler.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Author: Sven Kreiss June 2010
3// Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
4/*************************************************************************
5 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class RooStats::NuisanceParametersSampler
13 \ingroup Roostats
14
15Helper class for ToyMCSampler. Handles all of the nuisance parameter related
16functions. Once instantiated, it gives a new nuisance parameter point
17at each call to nextPoint(...).
18Only used inside ToyMCSampler, ie "private" in the cxx file
19*/
20
21/** \class RooStats::ToyMCSampler
22 \ingroup Roostats
23
24ToyMCSampler is an implementation of the TestStatSampler interface.
25It generates Toy Monte Carlo for a given parameter point and evaluates a
26TestStatistic.
27
28For parallel runs, ToyMCSampler can be given an instance of ProofConfig
29and then run in parallel using proof or proof-lite. Internally, it uses
30ToyMCStudy with the RooStudyManager.
31*/
32
34
35#include "RooMsgService.h"
36
37#include "RooDataHist.h"
38
39#include "RooRealVar.h"
40
41#include "TCanvas.h"
42#include "RooPlot.h"
43#include "RooRandom.h"
44
45#include "RooStudyManager.h"
46#include "RooStats/ToyMCStudy.h"
49#include "RooSimultaneous.h"
50#include "RooCategory.h"
51
52#include "TMath.h"
53
54
55using namespace RooFit;
56using namespace std;
57
58
60
61namespace RooStats {
62
63////////////////////////////////////////////////////////////////////////////////
64/// Assigns new nuisance parameter point to members of nuisPoint.
65/// nuisPoint can be more objects than just the nuisance
66/// parameters.
67
69
70 // check whether to get new set of nuisanceParPoints
71 if (fIndex >= fNToys) {
72 Refresh();
73 fIndex = 0;
74 }
75
76 // get value
77 nuisPoint = *fPoints->get(fIndex++);
78 weight = fPoints->weight();
79
80 // check whether result will have any influence
81 if(fPoints->weight() == 0.0) {
82 oocoutI((TObject*)NULL,Generation) << "Weight 0 encountered. Skipping." << endl;
83 NextPoint(nuisPoint, weight);
84 }
85}
86
87////////////////////////////////////////////////////////////////////////////////
88/// Creates the initial set of nuisance parameter points. It also refills the
89/// set with new parameter points if called repeatedly. This helps with
90/// adaptive sampling as the required number of nuisance parameter points
91/// might increase during the run.
92
94
95 if (!fPrior || !fParams) return;
96
97 if (fPoints) delete fPoints;
98
99 if (fExpected) {
100 // UNDER CONSTRUCTION
101 oocoutI((TObject*)NULL,InputArguments) << "Using expected nuisance parameters." << endl;
102
103 int nBins = fNToys;
104
105 // From FeldmanCousins.cxx:
106 // set nbins for the POI
108 RooRealVar *myarg2;
109 while ((myarg2 = dynamic_cast<RooRealVar*>(it2.Next()))) {
110 myarg2->setBins(nBins);
111 }
112
113
115 *fParams,
116 AllBinned(),
117 ExpectedData(),
118 NumEvents(1) // for Asimov set, this is only a scale factor
119 );
120 if(fPoints->numEntries() != fNToys) {
123 "Adjusted number of toys to number of bins of nuisance parameters: " << fNToys << endl;
124 }
125
126/*
127 // check
128 TCanvas *c1 = new TCanvas;
129 RooPlot *p = dynamic_cast<RooRealVar*>(fParams->first())->frame();
130 fPoints->plotOn(p);
131 p->Draw();
132 for(int x=0; x < fPoints->numEntries(); x++) {
133 fPoints->get(x)->Print("v");
134 cout << fPoints->weight() << endl;
135 }
136*/
137
138 }else{
139 oocoutI((TObject*)NULL,InputArguments) << "Using randomized nuisance parameters." << endl;
140
142 }
143}
144
146
147////////////////////////////////////////////////////////////////////////////////
148
150
151////////////////////////////////////////////////////////////////////////////////
152/// Proof constructor. Do not use.
153
154ToyMCSampler::ToyMCSampler() : fSamplingDistName("SD"), fNToys(1)
155{
156
157 fPdf = NULL;
158 fPriorNuisance = NULL;
159 fNuisancePars = NULL;
160 fObservables = NULL;
161 fGlobalObservables = NULL;
162
163 fSize = 0.05;
164 fNEvents = 0;
169
170 fToysInTails = 0.0;
174
175 fProtoData = NULL;
176
177 fProofConfig = NULL;
179
180 _allVars = NULL ;
181 _gs1 = NULL ;
182 _gs2 = NULL ;
183 _gs3 = NULL ;
184 _gs4 = NULL ;
185
186 //suppress messages for num integration of Roofit
188
190}
191
192////////////////////////////////////////////////////////////////////////////////
193
194ToyMCSampler::ToyMCSampler(TestStatistic &ts, Int_t ntoys) : fSamplingDistName(ts.GetVarName().Data()), fNToys(ntoys)
195{
196 fPdf = NULL;
197 fPriorNuisance = NULL;
198 fNuisancePars = NULL;
199 fObservables = NULL;
200 fGlobalObservables = NULL;
201
202 fSize = 0.05;
203 fNEvents = 0;
208
209 fToysInTails = 0.0;
213
214 fProtoData = NULL;
215
216 fProofConfig = NULL;
218
219 _allVars = NULL ;
220 _gs1 = NULL ;
221 _gs2 = NULL ;
222 _gs3 = NULL ;
223 _gs4 = NULL ;
224
225 //suppress messages for num integration of Roofit
227
229
230 AddTestStatistic(&ts);
231}
232
233////////////////////////////////////////////////////////////////////////////////
234
237
238 ClearCache();
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// only checks, no guessing/determination (do this in calculators,
243/// e.g. using ModelConfig::GuessObsAndNuisance(...))
244
246 bool goodConfig = true;
247
248 if(fTestStatistics.size() == 0 || fTestStatistics[0] == NULL) { ooccoutE((TObject*)NULL,InputArguments) << "Test statistic not set." << endl; goodConfig = false; }
249 if(!fObservables) { ooccoutE((TObject*)NULL,InputArguments) << "Observables not set." << endl; goodConfig = false; }
250 if(!fParametersForTestStat) { ooccoutE((TObject*)NULL,InputArguments) << "Parameter values used to evaluate the test statistic are not set." << endl; goodConfig = false; }
251 if(!fPdf) { ooccoutE((TObject*)NULL,InputArguments) << "Pdf not set." << endl; goodConfig = false; }
252
253
254 //ooccoutI((TObject*)NULL,InputArguments) << "ToyMCSampler configuration:" << endl;
255 //ooccoutI((TObject*)NULL,InputArguments) << "Pdf from SetPdf: " << fPdf << endl;
256 // for( unsigned int i=0; i < fTestStatistics.size(); i++ ) {
257 // ooccoutI((TObject*)NULL,InputArguments) << "test statistics["<<i<<"]: " << fTestStatistics[i] << endl;
258 // }
259 //ooccoutI((TObject*)NULL,InputArguments) << endl;
260
261 return goodConfig;
262}
263
264////////////////////////////////////////////////////////////////////////////////
265/// Evaluate all test statistics, returning result and any detailed output.
266/// PDF parameter values are saved in case they are modified by
267/// TestStatistic::Evaluate (eg. SimpleLikelihoodRatioTestStat).
268
270 DetailedOutputAggregator detOutAgg;
271 const RooArgList* allTS = EvaluateAllTestStatistics(data, poi, detOutAgg);
272 if (!allTS) return 0;
273 // no need to delete allTS, it is deleted in destructor of detOutAgg
274 return dynamic_cast<RooArgList*>(allTS->snapshot());
275}
276
277////////////////////////////////////////////////////////////////////////////////
278
280 RooArgSet *allVars = fPdf ? fPdf->getVariables() : 0;
281 RooArgSet *saveAll = allVars ? dynamic_cast<RooArgSet*>(allVars->snapshot()) : 0;
282 for( unsigned int i = 0; i < fTestStatistics.size(); i++ ) {
283 if( fTestStatistics[i] == NULL ) continue;
284 TString name( TString::Format("%s_TS%u", fSamplingDistName.c_str(), i) );
285 RooArgSet* parForTS = dynamic_cast<RooArgSet*>(poi.snapshot());
286 RooRealVar ts( name, fTestStatistics[i]->GetVarName(), fTestStatistics[i]->Evaluate( data, *parForTS ) );
287 RooArgList tset(ts);
288 detOutAgg.AppendArgSet(&tset);
289 delete parForTS;
290 if (const RooArgSet* detOut = fTestStatistics[i]->GetDetailedOutput()) {
291 name.Append("_");
292 detOutAgg.AppendArgSet(detOut, name);
293 }
294 if (saveAll) *allVars = *saveAll; // restore values, perhaps modified by fTestStatistics[i]->Evaluate()
295 }
296 delete saveAll;
297 delete allVars;
298 return detOutAgg.GetAsArgList();
299}
300
301////////////////////////////////////////////////////////////////////////////////
302
304 if(fTestStatistics.size() > 1) {
305 oocoutW((TObject*)NULL, InputArguments) << "Multiple test statistics defined, but only one distribution will be returned." << endl;
306 for( unsigned int i=0; i < fTestStatistics.size(); i++ ) {
307 oocoutW((TObject*)NULL, InputArguments) << " \t test statistic: " << fTestStatistics[i] << endl;
308 }
309 }
310
311 RooDataSet* r = GetSamplingDistributions(paramPointIn);
312 if(r == NULL || r->numEntries() == 0) {
313 oocoutW((TObject*)NULL, Generation) << "no sampling distribution generated" << endl;
314 return NULL;
315 }
316
318 delete r;
319 return samp;
320}
321
322////////////////////////////////////////////////////////////////////////////////
323/// Use for serial and parallel runs.
324
326{
327
328 // ======= S I N G L E R U N ? =======
329 if(!fProofConfig)
330 return GetSamplingDistributionsSingleWorker(paramPointIn);
331
332 // ======= P A R A L L E L R U N =======
333 if (!CheckConfig()){
335 << "Bad COnfiguration in ToyMCSampler "
336 << endl;
337 return nullptr;
338 }
339
340 // turn adaptive sampling off if given
341 if(fToysInTails) {
342 fToysInTails = 0;
344 << "Adaptive sampling in ToyMCSampler is not supported for parallel runs."
345 << endl;
346 }
347
348 // adjust number of toys on the slaves to keep the total number of toys constant
349 Int_t totToys = fNToys;
350 fNToys = (int)ceil((double)fNToys / (double)fProofConfig->GetNExperiments()); // round up
351
352 // create the study instance for parallel processing
353 ToyMCStudy* toymcstudy = new ToyMCStudy ;
354 toymcstudy->SetToyMCSampler(*this);
355 toymcstudy->SetParamPoint(paramPointIn);
357
358 // temporary workspace for proof to avoid messing with TRef
360 RooStudyManager studymanager(w, *toymcstudy);
362
363 RooDataSet* output = toymcstudy->merge();
364
365 // reset the number of toys
366 fNToys = totToys;
367
368 delete toymcstudy;
369 return output;
370}
371
372////////////////////////////////////////////////////////////////////////////////
373/// This is the main function for serial runs. It is called automatically
374/// from inside GetSamplingDistribution when no ProofConfig is given.
375/// You should not call this function yourself. This function should
376/// be used by ToyMCStudy on the workers (ie. when you explicitly want
377/// a serial run although ProofConfig is present).
378///
379/// Make sure the cache is clear. It is important to clear it hear, because
380/// the cache might be invalid even when just the firstPOI was changed, for which
381/// no accessor has to be called. (Fixes a bug when ToyMCSampler is
382/// used with the Neyman Construction)
383
385{
386 ClearCache();
387
388 if (!CheckConfig()){
390 << "Bad COnfiguration in ToyMCSampler "
391 << endl;
392 return nullptr;
393 }
394
395 // important to cache the paramPoint b/c test statistic might
396 // modify it from event to event
397 RooArgSet *paramPoint = (RooArgSet*) paramPointIn.snapshot();
398 RooArgSet *allVars = fPdf->getVariables();
399 RooArgSet *saveAll = (RooArgSet*) allVars->snapshot();
400
401
402 DetailedOutputAggregator detOutAgg;
403
404 // counts the number of toys in the limits set for adaptive sampling
405 // (taking weights into account; always on first test statistic)
406 Double_t toysInTails = 0.0;
407
408 for (Int_t i = 0; i < fMaxToys; ++i) {
409 // need to check at the beginning for case that zero toys are requested
410 if (toysInTails >= fToysInTails && i+1 > fNToys) break;
411
412 // status update
413 if ( i% 500 == 0 && i>0 ) {
414 oocoutP((TObject*)0,Generation) << "generated toys: " << i << " / " << fNToys;
415 if (fToysInTails) ooccoutP((TObject*)0,Generation) << " (tails: " << toysInTails << " / " << fToysInTails << ")" << std::endl;
416 else ooccoutP((TObject*)0,Generation) << endl;
417 }
418
419 // TODO: change this treatment to keep track of all values so that the threshold
420 // for adaptive sampling is counted for all distributions and not just the
421 // first one.
422 Double_t valueFirst = -999.0, weight = 1.0;
423
424 // set variables to requested parameter point
425 *allVars = *saveAll; // important for example for SimpleLikelihoodRatioTestStat
426
427 RooAbsData* toydata = GenerateToyData(*paramPoint, weight);
428
429 *allVars = *fParametersForTestStat;
430
431 const RooArgList* allTS = EvaluateAllTestStatistics(*toydata, *fParametersForTestStat, detOutAgg);
432 if (allTS->getSize() > Int_t(fTestStatistics.size()))
433 detOutAgg.AppendArgSet( fGlobalObservables, "globObs_" );
434 if (RooRealVar* firstTS = dynamic_cast<RooRealVar*>(allTS->first()))
435 valueFirst = firstTS->getVal();
436
437 delete toydata;
438
439 // check for nan
440 if(valueFirst != valueFirst) {
441 oocoutW((TObject*)NULL, Generation) << "skip: " << valueFirst << ", " << weight << endl;
442 continue;
443 }
444
445 detOutAgg.CommitSet(weight);
446
447 // adaptive sampling checks
448 if (valueFirst <= fAdaptiveLowLimit || valueFirst >= fAdaptiveHighLimit) {
449 if(weight >= 0.) toysInTails += weight;
450 else toysInTails += 1.;
451 }
452 }
453
454 // clean up
455 *allVars = *saveAll;
456 delete saveAll;
457 delete allVars;
458 delete paramPoint;
459
461}
462
463////////////////////////////////////////////////////////////////////////////////
464
466
467
469 ooccoutE((TObject*)NULL,InputArguments) << "Global Observables not set." << endl;
470 return;
471 }
472
473
475
476 // generate one set of global observables and assign it
477 // has problem for sim pdfs
478 RooSimultaneous* simPdf = dynamic_cast<RooSimultaneous*>( &pdf );
479 if (!simPdf) {
480 RooDataSet *one = pdf.generate(*fGlobalObservables, 1);
481
482 const RooArgSet *values = one->get(0);
483 if (!_allVars) {
484 _allVars = pdf.getVariables();
485 }
486 *_allVars = *values;
487 delete one;
488
489 } else {
490
491 if (_pdfList.size() == 0) {
492 RooCategory& channelCat = (RooCategory&)simPdf->indexCat();
493 int nCat = channelCat.numTypes();
494 for (int i=0; i < nCat; ++i){
495 channelCat.setIndex(i);
496 RooAbsPdf* pdftmp = simPdf->getPdf(channelCat.getLabel());
497 assert(pdftmp);
498 RooArgSet* globtmp = pdftmp->getObservables(*fGlobalObservables);
499 RooAbsPdf::GenSpec* gs = pdftmp->prepareMultiGen(*globtmp, NumEvents(1));
500 _pdfList.push_back(pdftmp);
501 _obsList.push_back(globtmp);
502 _gsList.push_back(gs);
503 }
504 }
505
506 list<RooArgSet*>::iterator oiter = _obsList.begin();
507 list<RooAbsPdf::GenSpec*>::iterator giter = _gsList.begin();
508 for (list<RooAbsPdf*>::iterator iter = _pdfList.begin(); iter != _pdfList.end(); ++iter, ++giter, ++oiter) {
509 //RooDataSet* tmp = (*iter)->generate(**oiter,1) ;
510 RooDataSet* tmp = (*iter)->generate(**giter);
511 **oiter = *tmp->get(0);
512 delete tmp;
513 }
514 }
515
516
517 } else {
518
519 // not using multigen for global observables
521 const RooArgSet *values = one->get(0);
522 RooArgSet* allVars = pdf.getVariables();
523 *allVars = *values;
524 delete allVars;
525 delete one;
526
527 }
528}
529
530////////////////////////////////////////////////////////////////////////////////
531/// This method generates a toy data set for the given parameter point taking
532/// global observables into account.
533/// The values of the generated global observables remain in the pdf's variables.
534/// They have to have those values for the subsequent evaluation of the
535/// test statistics.
536
537RooAbsData* ToyMCSampler::GenerateToyData(RooArgSet& paramPoint, double& weight, RooAbsPdf& pdf) const {
538
539 if(!fObservables) {
540 ooccoutE((TObject*)NULL,InputArguments) << "Observables not set." << endl;
541 return NULL;
542 }
543
544 // assign input paramPoint
545 RooArgSet* allVars = fPdf->getVariables();
546 *allVars = paramPoint;
547
548
549 // create nuisance parameter points
553 oocoutI((TObject*)NULL,InputArguments) << "Cannot use multigen when nuisance parameters vary for every toy" << endl;
554 }
555
556 // generate global observables
557 RooArgSet observables(*fObservables);
559 observables.remove(*fGlobalObservables);
561 }
562
563 // save values to restore later.
564 // but this must remain after(!) generating global observables
565 const RooArgSet* saveVars = (const RooArgSet*)allVars->snapshot();
566
567 if(fNuisanceParametersSampler) { // use nuisance parameters?
568 // Construct a set of nuisance parameters that has the parameters
569 // in the input paramPoint removed. Therefore, no parameter in
570 // paramPoint is randomized.
571 // Therefore when a parameter is given (should be held fixed),
572 // but is also in the list of nuisance parameters, the parameter
573 // will be held fixed. This is useful for debugging to hold single
574 // parameters fixed although under "normal" circumstances it is
575 // randomized.
576 RooArgSet allVarsMinusParamPoint(*allVars);
577 allVarsMinusParamPoint.remove(paramPoint, kFALSE, kTRUE); // match by name
578
579 // get nuisance parameter point and weight
580 fNuisanceParametersSampler->NextPoint(allVarsMinusParamPoint, weight);
581
582
583 }else{
584 weight = 1.0;
585 }
586
587 RooAbsData *data = Generate(pdf, observables);
588
589 // We generated the data with the randomized nuisance parameter (if hybrid)
590 // but now we are setting the nuisance parameters back to where they were.
591 *allVars = *saveVars;
592 delete allVars;
593 delete saveVars;
594
595 return data;
596}
597
598////////////////////////////////////////////////////////////////////////////////
599/// This is the generate function to use in the context of the ToyMCSampler
600/// instead of the standard RooAbsPdf::generate(...).
601/// It takes into account whether the number of events is given explicitly
602/// or whether it should use the expected number of events. It also takes
603/// into account the option to generate a binned data set (ie RooDataHist).
604
605RooAbsData* ToyMCSampler::Generate(RooAbsPdf &pdf, RooArgSet &observables, const RooDataSet* protoData, int forceEvents) const {
606
607 if(fProtoData) {
608 protoData = fProtoData;
609 forceEvents = protoData->numEntries();
610 }
611
612 RooAbsData *data = NULL;
613 int events = forceEvents;
614 if(events == 0) events = fNEvents;
615
616 // cannot use multigen when the nuisance parameters change for every toy
618
619 if(events == 0) {
620 if( pdf.canBeExtended() && pdf.expectedEvents(observables) > 0) {
621 if(fGenerateBinned) {
622 if(protoData) data = pdf.generate(observables, AllBinned(), Extended(), ProtoData(*protoData, true, true));
623 else data = pdf.generate(observables, AllBinned(), Extended());
624 }else{
625 if(protoData) {
626 if (useMultiGen) {
627 if (!_gs2) { _gs2 = pdf.prepareMultiGen(observables, Extended(), AutoBinned(fGenerateAutoBinned), GenBinned(fGenerateBinnedTag), ProtoData(*protoData, true, true)) ; }
628 data = pdf.generate(*_gs2) ;
629 } else {
630 data = pdf.generate (observables, Extended(), AutoBinned(fGenerateAutoBinned), GenBinned(fGenerateBinnedTag), ProtoData(*protoData, true, true));
631 }
632 }
633 else {
634 if (useMultiGen) {
636 data = pdf.generate(*_gs1) ;
637 } else {
639 }
640
641 }
642 }
643 }else{
645 << "ToyMCSampler: Error : pdf is not extended and number of events per toy is zero"
646 << endl;
647 }
648 }else{
649 if(fGenerateBinned) {
650 if(protoData) data = pdf.generate(observables, events, AllBinned(), ProtoData(*protoData, true, true));
651 else data = pdf.generate(observables, events, AllBinned());
652 }else{
653 if(protoData) {
654 if (useMultiGen) {
655 if (!_gs3) { _gs3 = pdf.prepareMultiGen(observables, NumEvents(events), AutoBinned(fGenerateAutoBinned), GenBinned(fGenerateBinnedTag), ProtoData(*protoData, true, true)); }
656 data = pdf.generate(*_gs3) ;
657 } else {
658 data = pdf.generate (observables, NumEvents(events), AutoBinned(fGenerateAutoBinned), GenBinned(fGenerateBinnedTag), ProtoData(*protoData, true, true));
659 }
660 } else {
661 if (useMultiGen) {
663 data = pdf.generate(*_gs4) ;
664 } else {
665 data = pdf.generate (observables, NumEvents(events), AutoBinned(fGenerateAutoBinned), GenBinned(fGenerateBinnedTag));
666 }
667 }
668 }
669 }
670
671 // in case of number counting print observables
672 // if (data->numEntries() == 1) {
673 // std::cout << "generate observables : ";
674 // RooStats::PrintListContent(*data->get(0), std::cout);
675 // }
676
677 return data;
678}
679
680////////////////////////////////////////////////////////////////////////////////
681/// Extended interface to append to sampling distribution more samples
682
684 RooArgSet& allParameters,
686 Int_t additionalMC)
687{
688 Int_t tmp = fNToys;
689 fNToys = additionalMC;
690 SamplingDistribution* newSamples = GetSamplingDistribution(allParameters);
691 fNToys = tmp;
692
693 if(last){
694 last->Add(newSamples);
695 delete newSamples;
696 return last;
697 }
698
699 return newSamples;
700}
701
702////////////////////////////////////////////////////////////////////////////////
703/// clear the cache obtained from the pdf used for speeding the toy and global observables generation
704/// needs to be called every time the model pdf (fPdf) changes
705
707
708 if (_gs1) delete _gs1;
709 _gs1 = 0;
710 if (_gs2) delete _gs2;
711 _gs2 = 0;
712 if (_gs3) delete _gs3;
713 _gs3 = 0;
714 if (_gs4) delete _gs4;
715 _gs4 = 0;
716
717 // no need to delete the _pdfList since it is managed by the RooSimultaneous object
718 if (_pdfList.size() > 0) {
719 std::list<RooArgSet*>::iterator oiter = _obsList.begin();
720 for (std::list<RooAbsPdf::GenSpec*>::iterator giter = _gsList.begin(); giter != _gsList.end(); ++giter, ++oiter) {
721 delete *oiter;
722 delete *giter;
723 }
724 _pdfList.clear();
725 _obsList.clear();
726 _gsList.clear();
727 }
728
729 //LM: is this set really needed ??
730 if (_allVars) delete _allVars;
731 _allVars = 0;
732
733}
734
735} // end namespace RooStats
ROOT::R::TRInterface & r
Definition: Object.C:4
#define oocoutW(o, a)
Definition: RooMsgService.h:46
#define oocoutE(o, a)
Definition: RooMsgService.h:47
#define oocoutI(o, a)
Definition: RooMsgService.h:44
#define ooccoutP(o, a)
Definition: RooMsgService.h:52
#define oocoutP(o, a)
Definition: RooMsgService.h:45
#define ooccoutE(o, a)
Definition: RooMsgService.h:54
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
char name[80]
Definition: TGX11.cxx:109
double ceil(double)
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Return the observables of this pdf given a set of observables.
Definition: RooAbsArg.h:240
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
Definition: RooAbsArg.cxx:2034
Int_t numTypes(const char *=0) const
Int_t getSize() const
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
RooAbsArg * first() const
TIterator * createIterator(Bool_t dir=kIterForward) const R__SUGGEST_ALTERNATIVE("begin()
TIterator-style iteration over contained elements.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
virtual const RooArgSet * get() const
Definition: RooAbsData.h:80
virtual Double_t weight() const =0
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:306
GenSpec * prepareMultiGen(const RooArgSet &whatVars, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none())
Prepare GenSpec configuration object for efficient generation of multiple datasets from identical spe...
Definition: RooAbsPdf.cxx:1871
Bool_t canBeExtended() const
Definition: RooAbsPdf.h:230
RooDataSet * generate(const RooArgSet &whatVars, Int_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none())
See RooAbsPdf::generate(const RooArgSet&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,...
Definition: RooAbsPdf.h:56
virtual Double_t expectedEvents(const RooArgSet *nset) const
Return expected number of events from this p.d.f for use in extended likelihood calculations.
Definition: RooAbsPdf.cxx:2920
virtual RooDataSet * generateSimGlobal(const RooArgSet &whatVars, Int_t nEvents)
Special generator interface for generation of 'global observables' – for RooStats tools.
Definition: RooAbsPdf.cxx:2368
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:134
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:24
virtual const char * getLabel() const
Return label string of current state.
Definition: RooCategory.h:39
virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE)
Set value by specifying the index code of the desired state.
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:31
virtual const RooArgSet * get(Int_t index) const
Return RooArgSet with coordinates of event 'index'.
static RooMsgService & instance()
Return reference to singleton instance.
StreamConfig & getStream(Int_t id)
static Double_t infinity()
Return internal infinity representation.
Definition: RooNumber.cxx:49
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
Definition: RooRandom.cxx:54
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
void setBins(Int_t nBins, const char *name=0)
Definition: RooRealVar.h:78
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.
This class is designed to aid in the construction of RooDataSets and RooArgSets, particularly those n...
void AppendArgSet(const RooAbsCollection *aset, TString prefix="")
For each variable in aset, prepend prefix to its name and add to the internal store.
RooDataSet * GetAsDataSet(TString name, TString title)
Returns all detailed output as a dataset.
void CommitSet(double weight=1.0)
Commit to the result RooDataSet.
Helper class for ToyMCSampler.
Definition: ToyMCSampler.h:40
void Refresh()
Creates the initial set of nuisance parameter points.
void NextPoint(RooArgSet &nuisPoint, Double_t &weight)
Assigns new nuisance parameter point to members of nuisPoint.
RooWorkspace & GetWorkspace(void) const
Definition: ProofConfig.h:95
Int_t GetNExperiments(void) const
Definition: ProofConfig.h:99
const char * GetHost(void) const
Definition: ProofConfig.h:97
Bool_t GetShowGui(void) const
Definition: ProofConfig.h:101
This class simply holds a sampling distribution of some test statistic.
void Add(const SamplingDistribution *other)
merge two sampling distributions
TestStatistic is an interface class to provide a facility for construction test statistics distributi...
Definition: TestStatistic.h:31
ToyMCSampler is an implementation of the TestStatSampler interface.
Definition: ToyMCSampler.h:72
const RooArgSet * fGlobalObservables
Definition: ToyMCSampler.h:257
RooAbsPdf::GenSpec * _gs3
GenSpec #2.
Definition: ToyMCSampler.h:290
std::list< RooAbsPdf::GenSpec * > _gsList
Definition: ToyMCSampler.h:287
std::string fSamplingDistName
Definition: ToyMCSampler.h:253
virtual void GenerateGlobalObservables(RooAbsPdf &pdf) const
virtual RooDataSet * GetSamplingDistributionsSingleWorker(RooArgSet &paramPoint)
This is the main function for serial runs.
RooAbsData * Generate(RooAbsPdf &pdf, RooArgSet &observables, const RooDataSet *protoData=NULL, int forceEvents=0) const
This is the generate function to use in the context of the ToyMCSampler instead of the standard RooAb...
std::unique_ptr< const RooArgSet > fParametersForTestStat
Definition: ToyMCSampler.h:250
RooAbsPdf::GenSpec * _gs2
GenSpec #1.
Definition: ToyMCSampler.h:289
virtual SamplingDistribution * AppendSamplingDistribution(RooArgSet &allParameters, SamplingDistribution *last, Int_t additionalMC)
Extended interface to append to sampling distribution more samples.
NuisanceParametersSampler * fNuisanceParametersSampler
Definition: ToyMCSampler.h:281
const RooArgSet * fObservables
Definition: ToyMCSampler.h:256
virtual RooArgList * EvaluateAllTestStatistics(RooAbsData &data, const RooArgSet &poi)
Evaluate all test statistics, returning result and any detailed output.
virtual RooDataSet * GetSamplingDistributions(RooArgSet &paramPoint)
Use for serial and parallel runs.
Bool_t CheckConfig(void)
only checks, no guessing/determination (do this in calculators, e.g.
static Bool_t fgAlwaysUseMultiGen
GenSpec #4.
Definition: ToyMCSampler.h:293
virtual RooAbsData * GenerateToyData(RooArgSet &paramPoint, RooAbsPdf &pdf) const
Definition: ToyMCSampler.h:111
virtual void AddTestStatistic(TestStatistic *t=NULL)
Definition: ToyMCSampler.h:98
const RooArgSet * fNuisancePars
Definition: ToyMCSampler.h:255
std::list< RooArgSet * > _obsList
Definition: ToyMCSampler.h:286
static void SetAlwaysUseMultiGen(Bool_t flag)
std::vector< TestStatistic * > fTestStatistics
Definition: ToyMCSampler.h:251
ToyMCSampler()
Proof constructor. Do not use.
virtual void ClearCache()
clear the cache obtained from the pdf used for speeding the toy and global observables generation nee...
RooAbsPdf::GenSpec * _gs4
GenSpec #3.
Definition: ToyMCSampler.h:291
ProofConfig * fProofConfig
Definition: ToyMCSampler.h:279
const RooDataSet * fProtoData
Definition: ToyMCSampler.h:277
virtual SamplingDistribution * GetSamplingDistribution(RooArgSet &paramPoint)
std::list< RooAbsPdf * > _pdfList
Definition: ToyMCSampler.h:285
RooAbsPdf::GenSpec * _gs1
Definition: ToyMCSampler.h:288
RooAbsPdf * fPriorNuisance
Definition: ToyMCSampler.h:254
ToyMCStudy is an implementation of RooAbsStudy for toy Monte Carlo sampling.
Definition: ToyMCStudy.h:32
void SetToyMCSampler(ToyMCSampler &t)
Definition: ToyMCStudy.h:57
void SetParamPoint(const RooArgSet &paramPoint)
Definition: ToyMCStudy.h:58
void SetRandomSeed(unsigned int seed)
Definition: ToyMCStudy.h:60
RooDataSet * merge()
Definition: ToyMCStudy.cxx:101
RooStudyManager is a utility class to manage studies that consist of repeated applications of generat...
void runProof(Int_t nExperiments, const char *proofHost="", Bool_t showGui=kTRUE)
Open PROOF-Lite session.
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
TObject * Next()
Definition: TCollection.h:249
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:401
virtual UInt_t Integer(UInt_t imax)
Returns a random integer uniformly distributed on the interval [ 0, imax-1 ].
Definition: TRandom.cxx:349
Basic string class.
Definition: TString.h:131
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2311
Template specialisation used in RooAbsArg:
RooCmdArg ProtoData(const RooDataSet &protoData, Bool_t randomizeOrder=kFALSE, Bool_t resample=kFALSE)
RooCmdArg AllBinned()
RooCmdArg Extended(Bool_t flag=kTRUE)
RooCmdArg AutoBinned(Bool_t flag=kTRUE)
RooCmdArg NumEvents(Int_t numEvents)
@ Generation
Definition: RooGlobalFunc.h:57
@ NumIntegration
Definition: RooGlobalFunc.h:59
@ InputArguments
Definition: RooGlobalFunc.h:58
RooCmdArg GenBinned(const char *tag)
RooCmdArg ExpectedData(Bool_t flag=kTRUE)
Namespace for the RooStats classes.
Definition: Asimov.h:20
void removeTopic(RooFit::MsgTopic oldTopic)
static void output(int code)
Definition: gifencode.c:226