Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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(...).
18*/
19
20/** \class RooStats::ToyMCSampler
21 \ingroup Roostats
22
23ToyMCSampler is an implementation of the TestStatSampler interface.
24It generates Toy Monte Carlo for a given parameter point and evaluates a
25TestStatistic.
26*/
27
29
30#include "RooMsgService.h"
31
32#include "RooDataHist.h"
33
34#include "RooRealVar.h"
35
36#include "TCanvas.h"
37#include "RooPlot.h"
38#include "RooRandom.h"
39
40#include "RooStudyManager.h"
43#include "RooSimultaneous.h"
44#include "RooCategory.h"
45
46#include "TMath.h"
47
48
49using namespace RooFit;
50using std::endl;
51
52
53
54namespace RooStats {
55
56////////////////////////////////////////////////////////////////////////////////
57/// Assigns new nuisance parameter point to members of nuisPoint.
58/// nuisPoint can be more objects than just the nuisance
59/// parameters.
60
62
63 // check whether to get new set of nuisanceParPoints
64 if (fIndex >= fNToys) {
65 Refresh();
66 fIndex = 0;
67 }
68
69 // get value
70 nuisPoint.assign(*fPoints->get(fIndex++));
71 weight = fPoints->weight();
72
73 // check whether result will have any influence
74 if(fPoints->weight() == 0.0) {
75 oocoutI(nullptr,Generation) << "Weight 0 encountered. Skipping." << std::endl;
76 NextPoint(nuisPoint, weight);
77 }
78}
79
80////////////////////////////////////////////////////////////////////////////////
81/// Creates the initial set of nuisance parameter points. It also refills the
82/// set with new parameter points if called repeatedly. This helps with
83/// adaptive sampling as the required number of nuisance parameter points
84/// might increase during the run.
85
87
88 if (!fPrior || !fParams) return;
89
90 if (fExpected) {
91 // UNDER CONSTRUCTION
92 oocoutI(nullptr,InputArguments) << "Using expected nuisance parameters." << std::endl;
93
94 int nBins = fNToys;
95
96 // From FeldmanCousins.cxx:
97 // set nbins for the POI
99 myarg2->setBins(nBins);
100 }
101
102
103 fPoints = std::unique_ptr<RooDataSet>{fPrior->generate(
104 *fParams,
105 AllBinned(),
106 ExpectedData(),
107 NumEvents(1) // for Asimov set, this is only a scale factor
108 )};
109 if(fPoints->numEntries() != fNToys) {
110 fNToys = fPoints->numEntries();
111 oocoutI(nullptr,InputArguments) <<
112 "Adjusted number of toys to number of bins of nuisance parameters: " << fNToys << std::endl;
113 }
114
115/*
116 // check
117 TCanvas *c1 = new TCanvas;
118 RooPlot *p = dynamic_cast<RooRealVar*>(fParams->first())->frame();
119 fPoints->plotOn(p);
120 p->Draw();
121 for(int x=0; x < fPoints->numEntries(); x++) {
122 fPoints->get(x)->Print("v");
123 std::cout << fPoints->weight() << std::endl;
124 }
125*/
126
127 }else{
128 oocoutI(nullptr,InputArguments) << "Using randomized nuisance parameters." << std::endl;
129
130 fPoints = std::unique_ptr<RooDataSet>{fPrior->generate(*fParams, fNToys)};
131 }
132}
133
135
136////////////////////////////////////////////////////////////////////////////////
137
139
140////////////////////////////////////////////////////////////////////////////////
141
143 : fSamplingDistName(ts.GetVarName().Data()),
144 fNToys(ntoys),
145 fMaxToys(RooNumber::infinity()),
146 fAdaptiveLowLimit(-RooNumber::infinity()),
147 fAdaptiveHighLimit(RooNumber::infinity())
148{
149
150 //suppress messages for num integration of Roofit
151 RooMsgService::instance().getStream(1).removeTopic(RooFit::NumIntegration);
152
154}
155
156////////////////////////////////////////////////////////////////////////////////
157
163
164////////////////////////////////////////////////////////////////////////////////
165/// only checks, no guessing/determination (do this in calculators,
166/// e.g. using ModelConfig::GuessObsAndNuisance(...))
167
169 bool goodConfig = true;
170
171 if(fTestStatistics.empty() || fTestStatistics[0] == nullptr) { ooccoutE(nullptr,InputArguments) << "Test statistic not set." << std::endl; goodConfig = false; }
172 if(!fObservables) { ooccoutE(nullptr,InputArguments) << "Observables not set." << std::endl; goodConfig = false; }
173 if(!fParametersForTestStat) { ooccoutE(nullptr,InputArguments) << "Parameter values used to evaluate the test statistic are not set." << std::endl; goodConfig = false; }
174 if(!fPdf) { ooccoutE(nullptr,InputArguments) << "Pdf not set." << std::endl; goodConfig = false; }
175
176 return goodConfig;
177}
178
179////////////////////////////////////////////////////////////////////////////////
180/// Evaluate all test statistics, returning result and any detailed output.
181/// PDF parameter values are saved in case they are modified by
182/// TestStatistic::Evaluate (eg. SimpleLikelihoodRatioTestStat).
183
187 if (!allTS) return nullptr;
188 // no need to delete allTS, it is deleted in destructor of detOutAgg
189 return dynamic_cast<RooArgList*>(allTS->snapshot());
190}
191
192////////////////////////////////////////////////////////////////////////////////
193
195 std::unique_ptr<RooArgSet> allVars;
196 std::unique_ptr<RooArgSet> saveAll;
197 if(fPdf) {
198 allVars = std::unique_ptr<RooArgSet>{fPdf->getVariables()};
199 }
200 if(allVars) {
201 saveAll = std::make_unique<RooArgSet>();
202 allVars->snapshot(*saveAll);
203 }
204 for( unsigned int i = 0; i < fTestStatistics.size(); i++ ) {
205 if( fTestStatistics[i] == nullptr ) continue;
206 TString name( TString::Format("%s_TS%u", fSamplingDistName.c_str(), i) );
208 poi.snapshot(parForTS);
209 RooRealVar ts( name, fTestStatistics[i]->GetVarName(), fTestStatistics[i]->Evaluate( data, parForTS ) );
211 detOutAgg.AppendArgSet(&tset);
212 if (const RooArgSet* detOut = fTestStatistics[i]->GetDetailedOutput()) {
213 name.Append("_");
214 detOutAgg.AppendArgSet(detOut, name);
215 }
216 if (saveAll) {
217 // restore values, perhaps modified by fTestStatistics[i]->Evaluate()
218 allVars->assign(*saveAll);
219 }
220 }
221 return detOutAgg.GetAsArgList();
222}
223
224////////////////////////////////////////////////////////////////////////////////
225
227 if(fTestStatistics.size() > 1) {
228 oocoutW(nullptr, InputArguments) << "Multiple test statistics defined, but only one distribution will be returned." << std::endl;
229 for( unsigned int i=0; i < fTestStatistics.size(); i++ ) {
230 oocoutW(nullptr, InputArguments) << " \t test statistic: " << fTestStatistics[i] << std::endl;
231 }
232 }
233
234 std::unique_ptr<RooDataSet> r{GetSamplingDistributions(paramPointIn)};
235 if(r == nullptr || r->numEntries() == 0) {
236 oocoutW(nullptr, Generation) << "no sampling distribution generated" << std::endl;
237 return nullptr;
238 }
239
240 return new SamplingDistribution( r->GetName(), r->GetTitle(), *r );
241}
242
243////////////////////////////////////////////////////////////////////////////////
244/// Use for serial and parallel runs.
245
251
252////////////////////////////////////////////////////////////////////////////////
253/// This is the main function for serial runs.
254
256{
257 // Make sure the cache is clear. It is important to clear it here, because
258 // the cache might be invalid even when just the firstPOI was changed, for which
259 // no accessor has to be called. (Fixes a bug when ToyMCSampler is
260 // used with the Neyman Construction)
261 ClearCache();
262
263 if (!CheckConfig()){
264 oocoutE(nullptr, InputArguments)
265 << "Bad COnfiguration in ToyMCSampler "
266 << std::endl;
267 return nullptr;
268 }
269
270 // important to cache the paramPoint b/c test statistic might
271 // modify it from event to event
272 std::unique_ptr<RooArgSet> paramPoint{paramPointIn.snapshot()};
273 std::unique_ptr<RooArgSet> allVars{fPdf->getVariables()};
274 std::unique_ptr<RooArgSet> saveAll{allVars->snapshot()};
275
276
278
279 // counts the number of toys in the limits set for adaptive sampling
280 // (taking weights into account; always on first test statistic)
281 double toysInTails = 0.0;
282
283 for (Int_t i = 0; i < fMaxToys; ++i) {
284 // need to check at the beginning for case that zero toys are requested
285 if (toysInTails >= fToysInTails && i+1 > fNToys) break;
286
287 // status update
288 if ( i% 500 == 0 && i>0 ) {
289 oocoutP(nullptr,Generation) << "generated toys: " << i << " / " << fNToys;
290 if (fToysInTails) ooccoutP(nullptr,Generation) << " (tails: " << toysInTails << " / " << fToysInTails << ")" << std::endl;
291 else ooccoutP(nullptr,Generation) << std::endl;
292 }
293
294 // TODO: change this treatment to keep track of all values so that the threshold
295 // for adaptive sampling is counted for all distributions and not just the
296 // first one.
297 double valueFirst = -999.0;
298 double weight = 1.0;
299
300 // set variables to requested parameter point
301 allVars->assign(*saveAll); // important for example for SimpleLikelihoodRatioTestStat
302
303 std::unique_ptr<RooAbsData> toydata{GenerateToyData(*paramPoint, weight)};
304 if (i == 0 && !fPdf->canBeExtended() && dynamic_cast<RooSimultaneous*>(fPdf)) {
305 const RooArgSet* toySet = toydata->get();
306 if (std::none_of(toySet->begin(), toySet->end(),
307 [](const RooAbsArg *arg) { return dynamic_cast<const RooAbsCategory *>(arg) != nullptr; })) {
308 oocoutE(nullptr, Generation)
309 << "ToyMCSampler: Generated toy data didn't contain a category variable, although"
310 " a simultaneous PDF is in use. To generate events for a simultaneous PDF, all components need to be"
311 " extended. Otherwise, the number of events to generate per component cannot be determined."
312 << std::endl;
313 }
314 }
315
316 allVars->assign(*fParametersForTestStat);
317
319 if (allTS->size() > fTestStatistics.size())
320 detOutAgg.AppendArgSet( fGlobalObservables, "globObs_" );
321 if (RooRealVar* firstTS = dynamic_cast<RooRealVar*>(allTS->first()))
322 valueFirst = firstTS->getVal();
323
324 // check for nan
325 if(valueFirst != valueFirst) {
326 oocoutW(nullptr, Generation) << "skip: " << valueFirst << ", " << weight << std::endl;
327 continue;
328 }
329
330 detOutAgg.CommitSet(weight);
331
332 // adaptive sampling checks
334 if(weight >= 0.) toysInTails += weight;
335 else toysInTails += 1.;
336 }
337 }
338
339 // clean up
340 allVars->assign(*saveAll);
341
342 return detOutAgg.GetAsDataSet(fSamplingDistName, fSamplingDistName);
343}
344
345////////////////////////////////////////////////////////////////////////////////
346
348
349
350 if(!fGlobalObservables || fGlobalObservables->empty()) {
351 ooccoutE(nullptr,InputArguments) << "Global Observables not set." << std::endl;
352 return;
353 }
354
355
357
358 // generate one set of global observables and assign it
359 // has problem for sim pdfs
360 RooSimultaneous* simPdf = dynamic_cast<RooSimultaneous*>(&pdf );
361 if (!simPdf) {
362 std::unique_ptr<RooDataSet> one{pdf.generate(*fGlobalObservables, 1)};
363
364 const RooArgSet *values = one->get(0);
365 if (!_allVars) {
366 _allVars = std::unique_ptr<RooArgSet>{pdf.getVariables()};
367 }
368 _allVars->assign(*values);
369
370 } else {
371
372 if (_pdfList.empty()) {
373 auto& channelCat = const_cast<RooCategory&>(static_cast<RooCategory const&>(simPdf->indexCat()));
374 int nCat = channelCat.numTypes();
375 for (int i=0; i < nCat; ++i){
376 channelCat.setIndex(i);
377 RooAbsPdf* pdftmp = simPdf->getPdf(channelCat.getCurrentLabel());
378 assert(pdftmp);
379 std::unique_ptr<RooArgSet> globtmp{pdftmp->getObservables(*fGlobalObservables)};
380 RooAbsPdf::GenSpec* gs = pdftmp->prepareMultiGen(*globtmp, NumEvents(1));
381 _pdfList.push_back(pdftmp);
382 _obsList.emplace_back(std::move(globtmp));
383 _gsList.emplace_back(gs);
384 }
385 }
386
387 // Assign generated values to the observables in _obsList
388 for (unsigned int i = 0; i < _pdfList.size(); ++i) {
389 std::unique_ptr<RooDataSet> tmp( _pdfList[i]->generate(*_gsList[i]) );
390 _obsList[i]->assign(*tmp->get(0));
391 }
392 }
393
394
395 } else {
396
397 // not using multigen for global observables
398 std::unique_ptr<RooDataSet> one{pdf.generateSimGlobal( *fGlobalObservables, 1 )};
399 const RooArgSet *values = one->get(0);
400 std::unique_ptr<RooArgSet> allVars{pdf.getVariables()};
401 allVars->assign(*values);
402
403 }
404}
405
406////////////////////////////////////////////////////////////////////////////////
407/// This method generates a toy data set for the given parameter point taking
408/// global observables into account.
409/// The values of the generated global observables remain in the pdf's variables.
410/// They have to have those values for the subsequent evaluation of the
411/// test statistics.
412
414
415 if(!fObservables) {
416 ooccoutE(nullptr,InputArguments) << "Observables not set." << std::endl;
417 return nullptr;
418 }
419
420 // assign input paramPoint
421 std::unique_ptr<RooArgSet> allVars{fPdf->getVariables()};
422 allVars->assign(paramPoint);
423
424
425 // create nuisance parameter points
429 oocoutI(nullptr,InputArguments) << "Cannot use multigen when nuisance parameters vary for every toy" << std::endl;
430 }
431
432 // generate global observables
433 RooArgSet observables(*fObservables);
434 if(fGlobalObservables && !fGlobalObservables->empty()) {
435 observables.remove(*fGlobalObservables);
437 }
438
439 // save values to restore later.
440 // but this must remain after(!) generating global observables
441 std::unique_ptr<RooArgSet> saveVars{allVars->snapshot()};
442
443 if(fNuisanceParametersSampler) { // use nuisance parameters?
444 // Construct a set of nuisance parameters that has the parameters
445 // in the input paramPoint removed. Therefore, no parameter in
446 // paramPoint is randomized.
447 // Therefore when a parameter is given (should be held fixed),
448 // but is also in the list of nuisance parameters, the parameter
449 // will be held fixed. This is useful for debugging to hold single
450 // parameters fixed although under "normal" circumstances it is
451 // randomized.
453 allVarsMinusParamPoint.remove(paramPoint, false, true); // match by name
454
455 // get nuisance parameter point and weight
457
458
459 }else{
460 weight = 1.0;
461 }
462
463 RooAbsData *data = Generate(pdf, observables).release();
464
465 // We generated the data with the randomized nuisance parameter (if hybrid)
466 // but now we are setting the nuisance parameters back to where they were.
467 allVars->assign(*saveVars);
468
469 return data;
470}
471
472////////////////////////////////////////////////////////////////////////////////
473/// This is the generate function to use in the context of the ToyMCSampler
474/// instead of the standard RooAbsPdf::generate(...).
475/// It takes into account whether the number of events is given explicitly
476/// or whether it should use the expected number of events. It also takes
477/// into account the option to generate a binned data set (*i.e.* RooDataHist).
478
479std::unique_ptr<RooAbsData> ToyMCSampler::Generate(RooAbsPdf &pdf, RooArgSet &observables, const RooDataSet* protoData, int forceEvents) const {
480
481 if(fProtoData) {
483 forceEvents = protoData->numEntries();
484 }
485
486 std::unique_ptr<RooAbsData> data;
487 int events = forceEvents;
488 if(events == 0) events = fNEvents;
489
490 // cannot use multigen when the nuisance parameters change for every toy
492
493 if (events == 0) {
494 if (pdf.canBeExtended() && pdf.expectedEvents(observables) > 0) {
495 if(fGenerateBinned) {
496 if(protoData) data = std::unique_ptr<RooDataSet>{pdf.generate(observables, AllBinned(), Extended(), ProtoData(*protoData, true, true))};
497 else data = std::unique_ptr<RooDataSet>{pdf.generate(observables, AllBinned(), Extended())};
498 } else {
499 if (protoData) {
500 if (useMultiGen) {
501 if (!_gs2) _gs2.reset( pdf.prepareMultiGen(observables, Extended(), AutoBinned(fGenerateAutoBinned), GenBinned(fGenerateBinnedTag), ProtoData(*protoData, true, true)) );
502 data = std::unique_ptr<RooDataSet>{pdf.generate(*_gs2)};
503 } else {
504 data = std::unique_ptr<RooDataSet>{pdf.generate(observables, Extended(), AutoBinned(fGenerateAutoBinned), GenBinned(fGenerateBinnedTag), ProtoData(*protoData, true, true))};
505 }
506 } else {
507 if (useMultiGen) {
508 if (!_gs1) _gs1.reset( pdf.prepareMultiGen(observables, Extended(), AutoBinned(fGenerateAutoBinned), GenBinned(fGenerateBinnedTag)) );
509 data = std::unique_ptr<RooDataSet>{pdf.generate(*_gs1)};
510 } else {
511 data = std::unique_ptr<RooDataSet>{pdf.generate(observables, Extended(), AutoBinned(fGenerateAutoBinned), GenBinned(fGenerateBinnedTag) )};
512 }
513
514 }
515 }
516 } else {
517 oocoutE(nullptr,InputArguments)
518 << "ToyMCSampler: Error : pdf is not extended and number of events per toy is zero"
519 << std::endl;
520 }
521 } else {
522 if (fGenerateBinned) {
523 if(protoData) data = std::unique_ptr<RooDataSet>{pdf.generate(observables, events, AllBinned(), ProtoData(*protoData, true, true))};
524 else data = std::unique_ptr<RooDataSet>{pdf.generate(observables, events, AllBinned())};
525 } else {
526 if (protoData) {
527 if (useMultiGen) {
528 if (!_gs3) _gs3.reset( pdf.prepareMultiGen(observables, NumEvents(events), AutoBinned(fGenerateAutoBinned), GenBinned(fGenerateBinnedTag), ProtoData(*protoData, true, true)) );
529 data = std::unique_ptr<RooDataSet>{pdf.generate(*_gs3)};
530 } else {
531 data = std::unique_ptr<RooDataSet>{pdf.generate(observables, NumEvents(events), AutoBinned(fGenerateAutoBinned), GenBinned(fGenerateBinnedTag), ProtoData(*protoData, true, true))};
532 }
533 } else {
534 if (useMultiGen) {
536 data = std::unique_ptr<RooDataSet>{pdf.generate(*_gs4)};
537 } else {
538 data = std::unique_ptr<RooDataSet>{pdf.generate(observables, NumEvents(events), AutoBinned(fGenerateAutoBinned), GenBinned(fGenerateBinnedTag))};
539 }
540 }
541 }
542 }
543
544 return data;
545}
546
547////////////////////////////////////////////////////////////////////////////////
548/// Extended interface to append to sampling distribution more samples
549
568
569////////////////////////////////////////////////////////////////////////////////
570/// clear the cache obtained from the pdf used for speeding the toy and global observables generation
571/// needs to be called every time the model pdf (fPdf) changes
572
574 _gs1 = nullptr;
575 _gs2 = nullptr;
576 _gs3 = nullptr;
577 _gs4 = nullptr;
578 _allVars = nullptr;
579
580 // no need to delete the _pdfList since it is managed by the RooSimultaneous object
581 if (!_pdfList.empty()) {
582 _pdfList.clear();
583 _obsList.clear();
584 _gsList.clear();
585 }
586}
587
588} // end namespace RooStats
#define oocoutW(o, a)
#define oocoutE(o, a)
#define oocoutI(o, a)
#define ooccoutP(o, a)
#define oocoutP(o, a)
#define ooccoutE(o, a)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
char name[80]
Definition TGX11.cxx:110
const_iterator begin() const
const_iterator end() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
RooFit::OwningPtr< RooArgSet > getVariables(bool stripDisconnected=true) const
Return RooArgSet with all variables (tree leaf nodes of expression tree)
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:57
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
virtual double expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
Definition RooAbsPdf.h:218
GenSpec * prepareMultiGen(const RooArgSet &whatVars, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={})
Prepare GenSpec configuration object for efficient generation of multiple datasets from identical spe...
RooFit::OwningPtr< RooDataSet > generate(const RooArgSet &whatVars, Int_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={})
See RooAbsPdf::generate(const RooArgSet&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,...
Definition RooAbsPdf.h:57
virtual RooFit::OwningPtr< RooDataSet > generateSimGlobal(const RooArgSet &whatVars, Int_t nEvents)
Special generator interface for generation of 'global observables' – for RooStats tools.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition RooArgSet.h:159
Object to represent discrete states.
Definition RooCategory.h:28
Container class to hold unbinned data.
Definition RooDataSet.h:34
static RooMsgService & instance()
Return reference to singleton instance.
Provides numeric constants used in RooFit.
Definition RooNumber.h:22
Variable that can be changed from the outside.
Definition RooRealVar.h:37
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
This class is designed to aid in the construction of RooDataSets and RooArgSets, particularly those n...
Helper class for ToyMCSampler.
void Refresh()
Creates the initial set of nuisance parameter points.
void NextPoint(RooArgSet &nuisPoint, double &weight)
Assigns new nuisance parameter point to members of nuisPoint.
std::unique_ptr< RooAbsData > fPoints
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...
const RooArgSet * fGlobalObservables
std::string fSamplingDistName
name of the model
virtual void GenerateGlobalObservables(RooAbsPdf &pdf) const
generate global observables
virtual RooDataSet * GetSamplingDistributionsSingleWorker(RooArgSet &paramPoint)
This is the main function for serial runs.
std::unique_ptr< const RooArgSet > fParametersForTestStat
virtual SamplingDistribution * AppendSamplingDistribution(RooArgSet &allParameters, SamplingDistribution *last, Int_t additionalMC)
Extended interface to append to sampling distribution more samples.
NuisanceParametersSampler * fNuisanceParametersSampler
!
std::unique_ptr< RooAbsPdf::GenSpec > _gs4
! GenSpec #4
const RooArgSet * fObservables
double fToysInTails
minimum no of toys in tails for adaptive sampling (taking weights into account, therefore double) Def...
virtual RooArgList * EvaluateAllTestStatistics(RooAbsData &data, const RooArgSet &poi)
Evaluate all test statistics, returning result and any detailed output.
RooAbsPdf * fPdf
densities, snapshots, and test statistics to reweight to
SamplingDistribution * GetSamplingDistribution(RooArgSet &paramPoint) override
main interface
std::unique_ptr< RooAbsPdf::GenSpec > _gs1
! GenSpec #1
virtual RooDataSet * GetSamplingDistributions(RooArgSet &paramPoint)
Use for serial and parallel runs.
virtual void AddTestStatistic(TestStatistic *t=nullptr)
The pdf can be nullptr in which case the density from SetPdf() is used.
ToyMCSampler(TestStatistic &ts, Int_t ntoys)
virtual RooAbsData * GenerateToyData(RooArgSet &paramPoint, RooAbsPdf &pdf) const
generates toy data without weight
bool fExpectedNuisancePar
whether to use expectation values for nuisance parameters (ie Asimov data set)
bool fUseMultiGen
Use PrepareMultiGen?
std::unique_ptr< RooAbsPdf::GenSpec > _gs2
! GenSpec #2
const RooArgSet * fNuisancePars
std::unique_ptr< RooAbsPdf::GenSpec > _gs3
! GenSpec #3
std::vector< TestStatistic * > fTestStatistics
Int_t fNEvents
number of events per toy (may be ignored depending on settings)
std::unique_ptr< RooArgSet > _allVars
!
std::unique_ptr< RooAbsData > Generate(RooAbsPdf &pdf, RooArgSet &observables, const RooDataSet *protoData=nullptr, int forceEvents=0) const
helper for GenerateToyData
static void SetAlwaysUseMultiGen(bool flag)
std::vector< RooAbsPdf * > _pdfList
! We don't own those objects
Int_t fNToys
number of toys to generate
virtual void ClearCache()
helper method for clearing the cache
bool CheckConfig(void)
Checks for sufficient information to do a GetSamplingDistribution(...).
std::vector< std::unique_ptr< RooArgSet > > _obsList
!
static bool fgAlwaysUseMultiGen
Use PrepareMultiGen always.
double fMaxToys
maximum no of toys (taking weights into account, therefore double)
const RooDataSet * fProtoData
in dev
std::vector< std::unique_ptr< RooAbsPdf::GenSpec > > _gsList
!
RooAbsPdf * fPriorNuisance
prior pdf for nuisance parameters
Basic string class.
Definition TString.h:139
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:2378
RooCmdArg Extended(bool flag=true)
RooCmdArg ProtoData(const RooDataSet &protoData, bool randomizeOrder=false, bool resample=false)
RooCmdArg AllBinned()
RooCmdArg AutoBinned(bool flag=true)
RooCmdArg NumEvents(Int_t numEvents)
RooCmdArg GenBinned(const char *tag)
RooCmdArg ExpectedData(bool flag=true)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition CodegenImpl.h:64
@ NumIntegration
@ InputArguments
Namespace for the RooStats classes.
Definition CodegenImpl.h:58