Logo ROOT  
Reference Guide
ToyMCImportanceSampler.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Author: Sven Kreiss January 2012
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::ToyMCImportanceSampler
13 \ingroup Roostats
14
15ToyMCImportanceSampler is an extension of the ToyMCSampler for Importance Sampling.
16
17Implementation based on a work by Cranmer, Kreiss, Read (in Preparation)
18*/
19
21
22#include "RooMsgService.h"
23
24#include "RooCategory.h"
25#include "TMath.h"
26
27using namespace RooFit;
28using namespace std;
29
30
32
33namespace RooStats {
34
35////////////////////////////////////////////////////////////////////////////////
36
38 for( unsigned int i=0; i < fImportanceSnapshots.size(); i++ ) if(fImportanceSnapshots[i]) delete fImportanceSnapshots[i];
39 for( unsigned int i=0; i < fNullSnapshots.size(); i++ ) if(fNullSnapshots[i]) delete fNullSnapshots[i];
40}
41
42////////////////////////////////////////////////////////////////////////////////
43
46
47 for( unsigned int i=0; i < fImpNLLs.size(); i++ ) if(fImpNLLs[i]) { delete fImpNLLs[i]; fImpNLLs[i] = NULL; }
48 for( unsigned int i=0; i < fNullNLLs.size(); i++ ) if(fNullNLLs[i]) { delete fNullNLLs[i]; fNullNLLs[i] = NULL; }
49}
50
51////////////////////////////////////////////////////////////////////////////////
52
54 if( fNToys == 0 ) return NULL;
55
56 // remember original #toys, but overwrite it temporarily with the #toys per distribution
57 Int_t allToys = fNToys;
58
59 // to keep track of which dataset entry comes form which density, define a roocategory as a label
60 RooCategory densityLabel( "densityLabel", "densityLabel" );
61 densityLabel.defineType( "null", -1 );
62 for( unsigned int i=0; i < fImportanceDensities.size(); i++ )
63 densityLabel.defineType( TString::Format( "impDens_%d", i ), i );
64
65
66 RooDataSet* fullResult = NULL;
67
68 // generate null (negative i) and imp densities (0 and positive i)
69 for( int i = -1; i < (int)fImportanceDensities.size(); i++ ) {
70 if( i < 0 ) {
71 // generate null toys
72 oocoutP((TObject*)0,Generation) << endl << endl << " GENERATING FROM NULL DENSITY " << endl << endl;
73 SetDensityToGenerateFromByIndex( 0, true ); // true = generate from null
74 }else{
75 oocoutP((TObject*)0,Generation) << endl << endl << " GENERATING IMP DENS/SNAP "<<i+1<<" OUT OF "<<fImportanceDensities.size()<<endl<<endl;
76 SetDensityToGenerateFromByIndex( i, false ); // false = generate not from null
77 }
78
79 RooRealVar reweight( "reweight", "reweight", 1.0 );
80 // apply strategy for how to distribute the #toys between the distributions
82 // assuming alltoys = one null + N imp densities. And round up.
83 fNToys = TMath::CeilNint( double(allToys)/(fImportanceDensities.size()+1) );
85 // for N densities, split the toys into (2^(N+1))-1 parts, and assign 2^0 parts to the first
86 // density (which is the null), 2^1 to the second (first imp dens), etc, up to 2^N
87 fNToys = TMath::CeilNint( double(allToys) * pow( double(2) , i+1 ) / (pow( double(2), int(fImportanceDensities.size()+1) )-1) );
88
89 int largestNToys = TMath::CeilNint( allToys * pow( double(2), int(fImportanceDensities.size()) ) / (pow( double(2), int(fImportanceDensities.size()+1) )-1) );
90 reweight.setVal( ((double)largestNToys) / fNToys );
91 }
92
93 ooccoutI((TObject*)NULL,InputArguments) << "Generating " << fNToys << " toys for this density." << endl;
94 ooccoutI((TObject*)NULL,InputArguments) << "Reweight is " << reweight.getVal() << endl;
95
96
98
99 if (result->get()->getSize() > Int_t(fTestStatistics.size())) {
100 // add label
101 densityLabel.setIndex( i );
102 result->addColumn( densityLabel );
103 result->addColumn( reweight );
104 }
105
106 if( !fullResult ) {
107 RooArgSet columns( *result->get() );
108 RooRealVar weightVar ( "weight", "weight", 1.0 );
109 columns.add( weightVar );
110// cout << endl << endl << "Reweighted data columns: " << endl;
111// columns.Print("v");
112// cout << endl;
113 fullResult = new RooDataSet( result->GetName(), result->GetTitle(), columns, "weight" );
114 }
115
116 for( int j=0; j < result->numEntries(); j++ ) {
117// cout << "entry: " << j << endl;
118// result->get(j)->Print();
119// cout << "weight: " << result->weight() << endl;
120// cout << "reweight: " << reweight.getVal() << endl;
121 const RooArgSet* row = result->get(j);
122 fullResult->add( *row, result->weight()*reweight.getVal() );
123 }
124 delete result;
125 }
126
127 // restore #toys
128 fNToys = allToys;
129
130 return fullResult;
131}
132
133////////////////////////////////////////////////////////////////////////////////
134
136 RooArgSet& paramPoint,
137 double& weight
138) const {
139 if( fNullDensities.size() > 1 ) {
140 ooccoutI((TObject*)NULL,InputArguments) << "Null Densities:" << endl;
141 for( unsigned int i=0; i < fNullDensities.size(); i++) {
142 ooccoutI((TObject*)NULL,InputArguments) << " null density["<<i<<"]: " << fNullDensities[i] << " \t null snapshot["<<i<<"]: " << fNullSnapshots[i] << endl;
143 }
144 ooccoutE((TObject*)NULL,InputArguments) << "Cannot use multiple null densities and only ask for one weight." << endl;
145 return NULL;
146 }
147
148 if( fNullDensities.size() == 0 && fPdf ) {
149 ooccoutI((TObject*)NULL,InputArguments) << "No explicit null densities specified. Going to add one based on the given paramPoint and the global fPdf. ... but cannot do that inside const function." << endl;
150 //AddNullDensity( fPdf, &paramPoint );
151 }
152
153 // do not do anything if the given parameter point if fNullSnapshots[0]
154 // ... which is the most common case
155 if( fNullSnapshots[0] != &paramPoint ) {
156 ooccoutD((TObject*)NULL,InputArguments) << "Using given parameter point. Replaces snapshot for the only null currently defined." << endl;
157 if(fNullSnapshots[0]) delete fNullSnapshots[0];
158 fNullSnapshots.clear();
159 fNullSnapshots.push_back( (RooArgSet*)paramPoint.snapshot() );
160 }
161
162 vector<double> weights;
163 weights.push_back( weight );
164
165 vector<double> impNLLs;
166 for( unsigned int i=0; i < fImportanceDensities.size(); i++ ) impNLLs.push_back( 0.0 );
167 vector<double> nullNLLs;
168 for( unsigned int i=0; i < fNullDensities.size(); i++ ) nullNLLs.push_back( 0.0 );
169
170 RooAbsData *d = GenerateToyData( weights, impNLLs, nullNLLs );
171 weight = weights[0];
172 return d;
173}
174
175////////////////////////////////////////////////////////////////////////////////
176
178 RooArgSet& paramPoint,
179 double& weight,
180 vector<double>& impNLLs,
181 double& nullNLL
182) const {
183 if( fNullDensities.size() > 1 ) {
184 ooccoutI((TObject*)NULL,InputArguments) << "Null Densities:" << endl;
185 for( unsigned int i=0; i < fNullDensities.size(); i++) {
186 ooccoutI((TObject*)NULL,InputArguments) << " null density["<<i<<"]: " << fNullDensities[i] << " \t null snapshot["<<i<<"]: " << fNullSnapshots[i] << endl;
187 }
188 ooccoutE((TObject*)NULL,InputArguments) << "Cannot use multiple null densities and only ask for one weight and NLL." << endl;
189 return NULL;
190 }
191
192 if( fNullDensities.size() == 0 && fPdf ) {
193 ooccoutI((TObject*)NULL,InputArguments) << "No explicit null densities specified. Going to add one based on the given paramPoint and the global fPdf. ... but cannot do that inside const function." << endl;
194 //AddNullDensity( fPdf, &paramPoint );
195 }
196
197 ooccoutI((TObject*)NULL,InputArguments) << "Using given parameter point. Overwrites snapshot for the only null currently defined." << endl;
198 if(fNullSnapshots[0]) delete fNullSnapshots[0];
199 fNullSnapshots.clear();
200 fNullSnapshots.push_back( (const RooArgSet*)paramPoint.snapshot() );
201
202 vector<double> weights;
203 weights.push_back( weight );
204
205 vector<double> nullNLLs;
206 nullNLLs.push_back( nullNLL );
207
208 RooAbsData *d = GenerateToyData( weights, impNLLs, nullNLLs );
209 weight = weights[0];
210 nullNLL = nullNLLs[0];
211 return d;
212}
213
214////////////////////////////////////////////////////////////////////////////////
215
217 vector<double>& weights
218) const {
219 if( fNullDensities.size() != weights.size() ) {
220 ooccoutI((TObject*)NULL,InputArguments) << "weights.size() != nullDesnities.size(). You need to provide a vector with the correct size." << endl;
221 //AddNullDensity( fPdf, &paramPoint );
222 }
223
224 vector<double> impNLLs;
225 for( unsigned int i=0; i < fImportanceDensities.size(); i++ ) impNLLs.push_back( 0.0 );
226 vector<double> nullNLLs;
227 for( unsigned int i=0; i < fNullDensities.size(); i++ ) nullNLLs.push_back( 0.0 );
228
229 RooAbsData *d = GenerateToyData( weights, impNLLs, nullNLLs );
230 return d;
231}
232
233////////////////////////////////////////////////////////////////////////////////
234/// This method generates a toy data set for importance sampling for the given parameter point taking
235/// global observables into account.
236/// The values of the generated global observables remain in the pdf's variables.
237/// They have to have those values for the subsequent evaluation of the
238/// test statistics.
239
241 vector<double>& weights,
242 vector<double>& impNLLVals,
243 vector<double>& nullNLLVals
244) const {
245
246
247 ooccoutD((TObject*)0,InputArguments) << endl;
248 ooccoutD((TObject*)0,InputArguments) << "GenerateToyDataImportanceSampling" << endl;
249
250 if(!fObservables) {
251 ooccoutE((TObject*)NULL,InputArguments) << "Observables not set." << endl;
252 return NULL;
253 }
254
255 if( fNullDensities.size() == 0 ) {
256 oocoutE((TObject*)NULL,InputArguments) << "ToyMCImportanceSampler: Need to specify the null density explicitly." << endl;
257 return NULL;
258 }
259
260 // catch the case when NLLs are not created (e.g. when ToyMCSampler was streamed for Proof)
261 if( fNullNLLs.size() == 0 && fNullDensities.size() > 0 ) {
262 for( unsigned int i = 0; i < fNullDensities.size(); i++ ) fNullNLLs.push_back( NULL );
263 }
264 if( fImpNLLs.size() == 0 && fImportanceDensities.size() > 0 ) {
265 for( unsigned int i = 0; i < fImportanceDensities.size(); i++ ) fImpNLLs.push_back( NULL );
266 }
267
268 if( fNullDensities.size() != fNullNLLs.size() ) {
269 oocoutE((TObject*)NULL,InputArguments) << "ToyMCImportanceSampler: Something wrong. NullNLLs must be of same size as null densities." << endl;
270 return NULL;
271 }
272
275 ) {
276 oocoutE((TObject*)NULL,InputArguments) << "ToyMCImportanceSampler: no importance density given or index out of range." << endl;
277 return NULL;
278 }
279
280
281 // paramPoint used to be given as parameter
282 // situation is clear when there is only one null.
283 // WHAT TO DO FOR MANY NULL DENSITIES?
284 RooArgSet paramPoint( *fNullSnapshots[0] );
285 //cout << "paramPoint: " << endl;
286 //paramPoint.Print("v");
287
288
289 // assign input paramPoint
290 RooArgSet* allVars = fPdf->getVariables();
291 *allVars = paramPoint;
292
293
294 // create nuisance parameter points
297
298 // generate global observables
299 RooArgSet observables(*fObservables);
301 observables.remove(*fGlobalObservables);
302 // WHAT TODO FOR MANY NULL DENSITIES?
304 }
305
306 // save values to restore later.
307 // but this must remain after(!) generating global observables
308 if( !fGenerateFromNull ) {
309 RooArgSet* allVarsImpDens = fImportanceDensities[fIndexGenDensity]->getVariables();
310 allVars->add(*allVarsImpDens);
311 delete allVarsImpDens;
312 }
313 const RooArgSet* saveVars = (const RooArgSet*)allVars->snapshot();
314
315 double globalWeight = 1.0;
316 if(fNuisanceParametersSampler) { // use nuisance parameters?
317 // Construct a set of nuisance parameters that has the parameters
318 // in the input paramPoint removed. Therefore, no parameter in
319 // paramPoint is randomized.
320 // Therefore when a parameter is given (should be held fixed),
321 // but is also in the list of nuisance parameters, the parameter
322 // will be held fixed. This is useful for debugging to hold single
323 // parameters fixed although under "normal" circumstances it is
324 // randomized.
325 RooArgSet allVarsMinusParamPoint(*allVars);
326 allVarsMinusParamPoint.remove(paramPoint, kFALSE, kTRUE); // match by name
327
328 // get nuisance parameter point and weight
329 fNuisanceParametersSampler->NextPoint(allVarsMinusParamPoint, globalWeight);
330 }
331 // populate input weights vector with this globalWeight
332 for( unsigned int i=0; i < weights.size(); i++ ) weights[i] = globalWeight;
333
334 RooAbsData* data = NULL;
335 if( fGenerateFromNull ) {
336 //cout << "gen from null" << endl;
337 *allVars = *fNullSnapshots[fIndexGenDensity];
338 data = Generate(*fNullDensities[fIndexGenDensity], observables);
339 }else{
340 // need to be careful here not to overwrite the current state of the
341 // nuisance parameters, ie they must not be part of the snapshot
342 //cout << "gen from imp" << endl;
344 data = Generate(*fImportanceDensities[fIndexGenDensity], observables);
345 }
346 //cout << "data generated: " << data << endl;
347
348 if (!data) {
349 oocoutE((TObject*)0,InputArguments) << "ToyMCImportanceSampler: error generating data" << endl;
350 return NULL;
351 }
352
353
354
355 // Importance Sampling: adjust weight
356 // Sources: Alex Read, presentation by Michael Woodroofe
357
358 ooccoutD((TObject*)0,InputArguments) << "About to create/calculate all nullNLLs." << endl;
359 for( unsigned int i=0; i < fNullDensities.size(); i++ ) {
360 //oocoutI((TObject*)0,InputArguments) << "Setting variables to nullSnapshot["<<i<<"]"<<endl;
361 //fNullSnapshots[i]->Print("v");
362
363 *allVars = *fNullSnapshots[i];
364 if( !fNullNLLs[i] ) {
365 RooArgSet* allParams = fNullDensities[i]->getParameters(*data);
366 fNullNLLs[i] = fNullDensities[i]->createNLL(*data, RooFit::CloneData(kFALSE), RooFit::Constrain(*allParams),
368 delete allParams;
369 }else{
370 fNullNLLs[i]->setData( *data, kFALSE );
371 }
372 nullNLLVals[i] = fNullNLLs[i]->getVal();
373 // FOR DEBuGGING!!!!!!!!!!!!!!!!!
374 if( !fReuseNLL ) { delete fNullNLLs[i]; fNullNLLs[i] = NULL; }
375 }
376
377
378 // for each null: find minNLLVal of null and all imp densities
379 ooccoutD((TObject*)0,InputArguments) << "About to find the minimum NLLs." << endl;
380 vector<double> minNLLVals;
381 for( unsigned int i=0; i < nullNLLVals.size(); i++ ) minNLLVals.push_back( nullNLLVals[i] );
382
383 for( unsigned int i=0; i < fImportanceDensities.size(); i++ ) {
384 //oocoutI((TObject*)0,InputArguments) << "Setting variables to impSnapshot["<<i<<"]"<<endl;
385 //fImportanceSnapshots[i]->Print("v");
386
387 if( fImportanceSnapshots[i] ) *allVars = *fImportanceSnapshots[i];
388 if( !fImpNLLs[i] ) {
389 RooArgSet* allParams = fImportanceDensities[i]->getParameters(*data);
390 fImpNLLs[i] = fImportanceDensities[i]->createNLL(*data, RooFit::CloneData(kFALSE), RooFit::Constrain(*allParams),
392 delete allParams;
393 }else{
394 fImpNLLs[i]->setData( *data, kFALSE );
395 }
396 impNLLVals[i] = fImpNLLs[i]->getVal();
397 // FOR DEBuGGING!!!!!!!!!!!!!!!!!
398 if( !fReuseNLL ) { delete fImpNLLs[i]; fImpNLLs[i] = NULL; }
399
400 for( unsigned int j=0; j < nullNLLVals.size(); j++ ) {
401 if( impNLLVals[i] < minNLLVals[j] ) minNLLVals[j] = impNLLVals[i];
402 ooccoutD((TObject*)0,InputArguments) << "minNLLVals["<<j<<"]: " << minNLLVals[j] << " nullNLLVals["<<j<<"]: " << nullNLLVals[j] << " impNLLVals["<<i<<"]: " << impNLLVals[i] << endl;
403 }
404 }
405
406 // veto toys: this is a sort of "overlap removal" of the various distributions
407 // if not vetoed: apply weight
408 ooccoutD((TObject*)0,InputArguments) << "About to apply vetos and calculate weights." << endl;
409 for( unsigned int j=0; j < nullNLLVals.size(); j++ ) {
410 if ( fApplyVeto && fGenerateFromNull && minNLLVals[j] != nullNLLVals[j] ) weights[j] = 0.0;
411 else if( fApplyVeto && !fGenerateFromNull && minNLLVals[j] != impNLLVals[fIndexGenDensity] ) weights[j] = 0.0;
412 else if( !fGenerateFromNull ) {
413 // apply (for fImportanceGenNorm, the weight is one, so nothing needs to be done here)
414
415 // L(pdf) / L(imp) = exp( NLL(imp) - NLL(pdf) )
416 weights[j] *= exp(minNLLVals[j] - nullNLLVals[j]);
417 }
418
419 ooccoutD((TObject*)0,InputArguments) << "weights["<<j<<"]: " << weights[j] << endl;
420 }
421
422
423
424 *allVars = *saveVars;
425 delete allVars;
426 delete saveVars;
427
428 return data;
429}
430
431////////////////////////////////////////////////////////////////////////////////
432/// poi has to be fitted beforehand. This function expects this to be the muhat value.
433
434int ToyMCImportanceSampler::CreateImpDensitiesForOnePOIAdaptively( RooAbsPdf& pdf, const RooArgSet& allPOI, RooRealVar& poi, double nStdDevOverlap, double poiValueForBackground ) {
435 // these might not necessarily be the same thing.
436 double impMaxMu = poi.getVal();
437
438 // this includes the null
439 int n = 1;
440
441 // check whether error is trustworthy
442 if( poi.getError() > 0.01 && poi.getError() < 5.0 ) {
443 n = TMath::CeilNint( poi.getVal() / (2.*nStdDevOverlap*poi.getError()) ); // round up
444 oocoutI((TObject*)0,InputArguments) << "Using fitFavoredMu and error to set the number of imp points" << endl;
445 oocoutI((TObject*)0,InputArguments) << "muhat: " << poi.getVal() << " optimize for distance: " << 2.*nStdDevOverlap*poi.getError() << endl;
446 oocoutI((TObject*)0,InputArguments) << "n = " << n << endl;
447 oocoutI((TObject*)0,InputArguments) << "This results in a distance of: " << impMaxMu / n << endl;
448 }
449
450 // exclude the null, just return the number of importance snapshots
451 return CreateNImpDensitiesForOnePOI( pdf, allPOI, poi, n-1, poiValueForBackground);
452}
453
454////////////////////////////////////////////////////////////////////////////////
455/// n is the number of importance densities
456
457int ToyMCImportanceSampler::CreateNImpDensitiesForOnePOI( RooAbsPdf& pdf, const RooArgSet& allPOI, RooRealVar& poi, int n, double poiValueForBackground ) {
458
459 // these might not necessarily be the same thing.
460 double impMaxMu = poi.getVal();
461
462 // create imp snapshots
463 if( impMaxMu > poiValueForBackground && n > 0 ) {
464 for( int i=1; i <= n; i++ ) {
465 poi.setVal( poiValueForBackground + (double)i/(n)*(impMaxMu - poiValueForBackground) );
466 oocoutI((TObject*)0,InputArguments) << endl << "create point with poi: " << endl;
467 poi.Print();
468
469 // impSnaps without first snapshot because that is null hypothesis
470
471 AddImportanceDensity( &pdf, &allPOI );
472 }
473 }
474
475 return n;
476}
477
478} // end namespace RooStats
#define d(i)
Definition: RSha256.hxx:102
#define oocoutE(o, a)
Definition: RooMsgService.h:48
#define oocoutI(o, a)
Definition: RooMsgService.h:45
#define ooccoutI(o, a)
Definition: RooMsgService.h:53
#define ooccoutD(o, a)
Definition: RooMsgService.h:52
#define oocoutP(o, a)
Definition: RooMsgService.h:46
#define ooccoutE(o, a)
Definition: RooMsgService.h:56
const Bool_t kFALSE
Definition: RtypesCore.h:90
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
double pow(double, double)
double exp(double)
virtual void Print(Option_t *options=0) const
Print the object to the defaultPrintStream().
Definition: RooAbsArg.h:302
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
Definition: RooAbsArg.cxx:1909
Int_t getSize() const
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:44
virtual Int_t numEntries() const
Definition: RooAbsData.cxx:306
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:90
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:126
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
Definition: RooArgSet.h:88
RooCategory is an object to represent discrete states.
Definition: RooCategory.h:23
bool defineType(const std::string &label)
Define a state with given name.
virtual Bool_t setIndex(Int_t index, bool printError=true) override
Set value by specifying the index code of the desired state.
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:33
virtual const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
virtual RooAbsArg * addColumn(RooAbsArg &var, Bool_t adjustRange=kTRUE)
Add a column with the values of the given (function) argument to this dataset.
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0) override
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
virtual Double_t weight() const override
Return event weight of current event.
Definition: RooDataSet.cxx:973
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:35
Double_t getError() const
Definition: RooRealVar.h:62
virtual void setVal(Double_t value)
Set value of variable to 'value'.
Definition: RooRealVar.cxx:261
Helper class for ToyMCSampler.
Definition: ToyMCSampler.h:40
void NextPoint(RooArgSet &nuisPoint, Double_t &weight)
Assigns new nuisance parameter point to members of nuisPoint.
ToyMCImportanceSampler is an extension of the ToyMCSampler for Importance Sampling.
void AddImportanceDensity(RooAbsPdf *p, const RooArgSet *s)
std::vector< const RooArgSet * > fImportanceSnapshots
std::vector< const RooArgSet * > fNullSnapshots
void SetDensityToGenerateFromByIndex(unsigned int i, bool fromNull=false)
specifies the pdf to sample from
virtual RooAbsData * GenerateToyData(RooArgSet &paramPoint, double &weight) const
std::vector< RooAbsPdf * > fImportanceDensities
virtual RooDataSet * GetSamplingDistributionsSingleWorker(RooArgSet &paramPoint)
This is the main function for serial runs.
virtual void ClearCache()
clear the cache obtained from the pdf used for speeding the toy and global observables generation nee...
int CreateImpDensitiesForOnePOIAdaptively(RooAbsPdf &pdf, const RooArgSet &allPOI, RooRealVar &poi, double nStdDevOverlap=0.5, double poiValueForBackground=0.0)
poi has to be fitted beforehand. This function expects this to be the muhat value.
std::vector< RooAbsPdf * > fNullDensities
std::vector< RooAbsReal * > fImpNLLs
int CreateNImpDensitiesForOnePOI(RooAbsPdf &pdf, const RooArgSet &allPOI, RooRealVar &poi, int n, double poiValueForBackground=0.0)
n is the number of importance densities
std::vector< RooAbsReal * > fNullNLLs
const RooArgSet * fGlobalObservables
Definition: ToyMCSampler.h:257
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...
NuisanceParametersSampler * fNuisanceParametersSampler
Definition: ToyMCSampler.h:281
const RooArgSet * fObservables
Definition: ToyMCSampler.h:256
const RooArgSet * fNuisancePars
Definition: ToyMCSampler.h:255
std::vector< TestStatistic * > fTestStatistics
Definition: ToyMCSampler.h:251
virtual void ClearCache()
clear the cache obtained from the pdf used for speeding the toy and global observables generation nee...
RooAbsPdf * fPriorNuisance
Definition: ToyMCSampler.h:254
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
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
RooCmdArg Constrain(const RooArgSet &params)
RooCmdArg CloneData(Bool_t flag)
RooCmdArg ConditionalObservables(const RooArgSet &set)
const Int_t n
Definition: legend1.C:16
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
@ Generation
Definition: RooGlobalFunc.h:67
@ InputArguments
Definition: RooGlobalFunc.h:68
Namespace for the RooStats classes.
Definition: Asimov.h:19
Int_t CeilNint(Double_t x)
Definition: TMath.h:689