Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 std::endl, std::vector;
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++ ) { fImpNLLs[i].reset(); }
48 for( unsigned int i=0; i < fNullNLLs.size(); i++ ) { fNullNLLs[i].reset(); }
49}
50
51////////////////////////////////////////////////////////////////////////////////
52
54 if( fNToys == 0 ) return nullptr;
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 from 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 = nullptr;
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(nullptr,Generation) << endl << endl << " GENERATING FROM nullptr DENSITY " << endl << endl;
73 SetDensityToGenerateFromByIndex( 0, true ); // true = generate from null
74 }else{
75 oocoutP(nullptr,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(nullptr,InputArguments) << "Generating " << fNToys << " toys for this density." << endl;
94 ooccoutI(nullptr,InputArguments) << "Reweight is " << reweight.getVal() << endl;
95
96
98
99 if (result->get()->size() > fTestStatistics.size()) {
100 // add label
101 densityLabel.setIndex( i );
102 result->addColumn( densityLabel );
103 result->addColumn( reweight );
104 }
105
106 if( !fullResult ) {
107 fullResult = new RooDataSet( result->GetName(), result->GetTitle(), *result->get(), RooFit::WeightVar());
108 }
109
110 for( int j=0; j < result->numEntries(); j++ ) {
111// cout << "entry: " << j << endl;
112// result->get(j)->Print();
113// cout << "weight: " << result->weight() << endl;
114// cout << "reweight: " << reweight.getVal() << endl;
115 const RooArgSet* row = result->get(j);
116 fullResult->add( *row, result->weight()*reweight.getVal() );
117 }
118 delete result;
119 }
120
121 // restore #toys
122 fNToys = allToys;
123
124 return fullResult;
125}
126
127////////////////////////////////////////////////////////////////////////////////
128
130 RooArgSet& paramPoint,
131 double& weight
132) const {
133 if( fNullDensities.size() > 1 ) {
134 ooccoutI(nullptr,InputArguments) << "Null Densities:" << endl;
135 for( unsigned int i=0; i < fNullDensities.size(); i++) {
136 ooccoutI(nullptr,InputArguments) << " null density["<<i<<"]: " << fNullDensities[i] << " \t null snapshot["<<i<<"]: " << fNullSnapshots[i] << endl;
137 }
138 ooccoutE(nullptr,InputArguments) << "Cannot use multiple null densities and only ask for one weight." << endl;
139 return nullptr;
140 }
141
142 if( fNullDensities.empty() && fPdf ) {
143 ooccoutI(nullptr,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;
144 //AddNullDensity( fPdf, &paramPoint );
145 }
146
147 // do not do anything if the given parameter point if fNullSnapshots[0]
148 // ... which is the most common case
149 if( fNullSnapshots[0] != &paramPoint ) {
150 ooccoutD(nullptr,InputArguments) << "Using given parameter point. Replaces snapshot for the only null currently defined." << endl;
151 if(fNullSnapshots[0]) delete fNullSnapshots[0];
152 fNullSnapshots.clear();
153 fNullSnapshots.push_back( (RooArgSet*)paramPoint.snapshot() );
154 }
155
156 vector<double> weights;
157 weights.push_back( weight );
158
159 vector<double> impNLLs;
160 for( unsigned int i=0; i < fImportanceDensities.size(); i++ ) impNLLs.push_back( 0.0 );
161 vector<double> nullNLLs;
162 for( unsigned int i=0; i < fNullDensities.size(); i++ ) nullNLLs.push_back( 0.0 );
163
164 RooAbsData *d = GenerateToyData( weights, impNLLs, nullNLLs );
165 weight = weights[0];
166 return d;
167}
168
169////////////////////////////////////////////////////////////////////////////////
170
172 RooArgSet& paramPoint,
173 double& weight,
174 vector<double>& impNLLs,
175 double& nullNLL
176) const {
177 if( fNullDensities.size() > 1 ) {
178 ooccoutI(nullptr,InputArguments) << "Null Densities:" << endl;
179 for( unsigned int i=0; i < fNullDensities.size(); i++) {
180 ooccoutI(nullptr,InputArguments) << " null density["<<i<<"]: " << fNullDensities[i] << " \t null snapshot["<<i<<"]: " << fNullSnapshots[i] << endl;
181 }
182 ooccoutE(nullptr,InputArguments) << "Cannot use multiple null densities and only ask for one weight and NLL." << endl;
183 return nullptr;
184 }
185
186 if( fNullDensities.empty() && fPdf ) {
187 ooccoutI(nullptr,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;
188 //AddNullDensity( fPdf, &paramPoint );
189 }
190
191 ooccoutI(nullptr,InputArguments) << "Using given parameter point. Overwrites snapshot for the only null currently defined." << endl;
192 if(fNullSnapshots[0]) delete fNullSnapshots[0];
193 fNullSnapshots.clear();
194 fNullSnapshots.push_back( (const RooArgSet*)paramPoint.snapshot() );
195
196 vector<double> weights;
197 weights.push_back( weight );
198
199 vector<double> nullNLLs;
200 nullNLLs.push_back( nullNLL );
201
202 RooAbsData *d = GenerateToyData( weights, impNLLs, nullNLLs );
203 weight = weights[0];
204 nullNLL = nullNLLs[0];
205 return d;
206}
207
208////////////////////////////////////////////////////////////////////////////////
209
211 vector<double>& weights
212) const {
213 if( fNullDensities.size() != weights.size() ) {
214 ooccoutI(nullptr,InputArguments) << "weights.size() != nullDesnities.size(). You need to provide a vector with the correct size." << endl;
215 //AddNullDensity( fPdf, &paramPoint );
216 }
217
218 vector<double> impNLLs;
219 for( unsigned int i=0; i < fImportanceDensities.size(); i++ ) impNLLs.push_back( 0.0 );
220 vector<double> nullNLLs;
221 for( unsigned int i=0; i < fNullDensities.size(); i++ ) nullNLLs.push_back( 0.0 );
222
223 RooAbsData *d = GenerateToyData( weights, impNLLs, nullNLLs );
224 return d;
225}
226
227////////////////////////////////////////////////////////////////////////////////
228/// This method generates a toy data set for importance sampling for the given parameter point taking
229/// global observables into account.
230/// The values of the generated global observables remain in the pdf's variables.
231/// They have to have those values for the subsequent evaluation of the
232/// test statistics.
233
235 vector<double>& weights,
236 vector<double>& impNLLVals,
237 vector<double>& nullNLLVals
238) const {
239
240
241 ooccoutD(nullptr,InputArguments) << endl;
242 ooccoutD(nullptr,InputArguments) << "GenerateToyDataImportanceSampling" << endl;
243
244 if(!fObservables) {
245 ooccoutE(nullptr,InputArguments) << "Observables not set." << endl;
246 return nullptr;
247 }
248
249 if( fNullDensities.empty() ) {
250 oocoutE(nullptr,InputArguments) << "ToyMCImportanceSampler: Need to specify the null density explicitly." << endl;
251 return nullptr;
252 }
253
254 // catch the case when NLLs are not created (e.g. when ToyMCSampler was streamed for Proof)
255 if( fNullNLLs.empty() && !fNullDensities.empty() ) {
256 for( unsigned int i = 0; i < fNullDensities.size(); i++ ) fNullNLLs.push_back( nullptr );
257 }
258 if( fImpNLLs.empty() && !fImportanceDensities.empty() ) {
259 for( unsigned int i = 0; i < fImportanceDensities.size(); i++ ) fImpNLLs.push_back( nullptr );
260 }
261
262 if( fNullDensities.size() != fNullNLLs.size() ) {
263 oocoutE(nullptr,InputArguments) << "ToyMCImportanceSampler: Something wrong. NullNLLs must be of same size as null densities." << endl;
264 return nullptr;
265 }
266
269 ) {
270 oocoutE(nullptr,InputArguments) << "ToyMCImportanceSampler: no importance density given or index out of range." << endl;
271 return nullptr;
272 }
273
274
275 // paramPoint used to be given as parameter
276 // situation is clear when there is only one null.
277 // WHAT TO DO FOR MANY nullptr DENSITIES?
278 RooArgSet paramPoint( *fNullSnapshots[0] );
279 //cout << "paramPoint: " << endl;
280 //paramPoint.Print("v");
281
282
283 // assign input paramPoint
284 std::unique_ptr<RooArgSet> allVars{fPdf->getVariables()};
285 allVars->assign(paramPoint);
286
287
288 // create nuisance parameter points
291
292 // generate global observables
293 RooArgSet observables(*fObservables);
295 observables.remove(*fGlobalObservables);
296 // WHAT TODO FOR MANY nullptr DENSITIES?
298 }
299
300 // save values to restore later.
301 // but this must remain after(!) generating global observables
302 if( !fGenerateFromNull ) {
303 std::unique_ptr<RooArgSet> allVarsImpDens{fImportanceDensities[fIndexGenDensity]->getVariables()};
304 allVars->add(*allVarsImpDens);
305 }
306 const RooArgSet* saveVars = (const RooArgSet*)allVars->snapshot();
307
308 double globalWeight = 1.0;
309 if(fNuisanceParametersSampler) { // use nuisance parameters?
310 // Construct a set of nuisance parameters that has the parameters
311 // in the input paramPoint removed. Therefore, no parameter in
312 // paramPoint is randomized.
313 // Therefore when a parameter is given (should be held fixed),
314 // but is also in the list of nuisance parameters, the parameter
315 // will be held fixed. This is useful for debugging to hold single
316 // parameters fixed although under "normal" circumstances it is
317 // randomized.
318 RooArgSet allVarsMinusParamPoint(*allVars);
319 allVarsMinusParamPoint.remove(paramPoint, false, true); // match by name
320
321 // get nuisance parameter point and weight
322 fNuisanceParametersSampler->NextPoint(allVarsMinusParamPoint, globalWeight);
323 }
324 // populate input weights vector with this globalWeight
325 for( unsigned int i=0; i < weights.size(); i++ ) weights[i] = globalWeight;
326
327 RooAbsData* data = nullptr;
328 if( fGenerateFromNull ) {
329 //cout << "gen from null" << endl;
330 allVars->assign(*fNullSnapshots[fIndexGenDensity]);
331 data = Generate(*fNullDensities[fIndexGenDensity], observables).release();
332 }else{
333 // need to be careful here not to overwrite the current state of the
334 // nuisance parameters, ie they must not be part of the snapshot
335 //cout << "gen from imp" << endl;
337 allVars->assign(*fImportanceSnapshots[fIndexGenDensity]);
338 }
339 data = Generate(*fImportanceDensities[fIndexGenDensity], observables).release();
340 }
341 //cout << "data generated: " << data << endl;
342
343 if (!data) {
344 oocoutE(nullptr,InputArguments) << "ToyMCImportanceSampler: error generating data" << endl;
345 return nullptr;
346 }
347
348
349
350 // Importance Sampling: adjust weight
351 // Sources: Alex Read, presentation by Michael Woodroofe
352
353 ooccoutD(nullptr,InputArguments) << "About to create/calculate all nullNLLs." << endl;
354 for( unsigned int i=0; i < fNullDensities.size(); i++ ) {
355 //oocoutI(nullptr,InputArguments) << "Setting variables to nullSnapshot["<<i<<"]"<<endl;
356 //fNullSnapshots[i]->Print("v");
357
358 allVars->assign(*fNullSnapshots[i]);
359 if( !fNullNLLs[i] ) {
360 std::unique_ptr<RooArgSet> allParams{fNullDensities[i]->getParameters(*data)};
361 fNullNLLs[i] = std::unique_ptr<RooAbsReal>{fNullDensities[i]->createNLL(*data, RooFit::CloneData(false), RooFit::Constrain(*allParams),
363 }else{
364 fNullNLLs[i]->setData( *data, false );
365 }
366 nullNLLVals[i] = fNullNLLs[i]->getVal();
367 // FOR DEBuGGING!!!!!!!!!!!!!!!!!
368 if( !fReuseNLL ) { fNullNLLs[i].reset(); }
369 }
370
371
372 // for each null: find minNLLVal of null and all imp densities
373 ooccoutD(nullptr,InputArguments) << "About to find the minimum NLLs." << endl;
374 vector<double> minNLLVals;
375 for( unsigned int i=0; i < nullNLLVals.size(); i++ ) minNLLVals.push_back( nullNLLVals[i] );
376
377 for( unsigned int i=0; i < fImportanceDensities.size(); i++ ) {
378 //oocoutI(nullptr,InputArguments) << "Setting variables to impSnapshot["<<i<<"]"<<endl;
379 //fImportanceSnapshots[i]->Print("v");
380
381 if( fImportanceSnapshots[i] ) {
382 allVars->assign(*fImportanceSnapshots[i]);
383 }
384 if( !fImpNLLs[i] ) {
385 std::unique_ptr<RooArgSet> allParams{fImportanceDensities[i]->getParameters(*data)};
386 fImpNLLs[i] = std::unique_ptr<RooAbsReal>{fImportanceDensities[i]->createNLL(*data, RooFit::CloneData(false), RooFit::Constrain(*allParams),
388 }else{
389 fImpNLLs[i]->setData( *data, false );
390 }
391 impNLLVals[i] = fImpNLLs[i]->getVal();
392 // FOR DEBuGGING!!!!!!!!!!!!!!!!!
393 if( !fReuseNLL ) { fImpNLLs[i].reset(); }
394
395 for( unsigned int j=0; j < nullNLLVals.size(); j++ ) {
396 if( impNLLVals[i] < minNLLVals[j] ) minNLLVals[j] = impNLLVals[i];
397 ooccoutD(nullptr,InputArguments) << "minNLLVals["<<j<<"]: " << minNLLVals[j] << " nullNLLVals["<<j<<"]: " << nullNLLVals[j] << " impNLLVals["<<i<<"]: " << impNLLVals[i] << endl;
398 }
399 }
400
401 // veto toys: this is a sort of "overlap removal" of the various distributions
402 // if not vetoed: apply weight
403 ooccoutD(nullptr,InputArguments) << "About to apply vetos and calculate weights." << endl;
404 for( unsigned int j=0; j < nullNLLVals.size(); j++ ) {
405 if ( fApplyVeto && fGenerateFromNull && minNLLVals[j] != nullNLLVals[j] ) weights[j] = 0.0;
406 else if( fApplyVeto && !fGenerateFromNull && minNLLVals[j] != impNLLVals[fIndexGenDensity] ) weights[j] = 0.0;
407 else if( !fGenerateFromNull ) {
408 // apply (for fImportanceGenNorm, the weight is one, so nothing needs to be done here)
409
410 // L(pdf) / L(imp) = exp( NLL(imp) - NLL(pdf) )
411 weights[j] *= exp(minNLLVals[j] - nullNLLVals[j]);
412 }
413
414 ooccoutD(nullptr,InputArguments) << "weights["<<j<<"]: " << weights[j] << endl;
415 }
416
417
418
419 allVars->assign(*saveVars);
420 delete saveVars;
421
422 return data;
423}
424
425////////////////////////////////////////////////////////////////////////////////
426/// poi has to be fitted beforehand. This function expects this to be the muhat value.
427
428int ToyMCImportanceSampler::CreateImpDensitiesForOnePOIAdaptively( RooAbsPdf& pdf, const RooArgSet& allPOI, RooRealVar& poi, double nStdDevOverlap, double poiValueForBackground ) {
429 // these might not necessarily be the same thing.
430 double impMaxMu = poi.getVal();
431
432 // this includes the null
433 int n = 1;
434
435 // check whether error is trustworthy
436 if( poi.getError() > 0.01 && poi.getError() < 5.0 ) {
437 n = TMath::CeilNint( poi.getVal() / (2.*nStdDevOverlap*poi.getError()) ); // round up
438 oocoutI(nullptr,InputArguments) << "Using fitFavoredMu and error to set the number of imp points" << endl;
439 oocoutI(nullptr,InputArguments) << "muhat: " << poi.getVal() << " optimize for distance: " << 2.*nStdDevOverlap*poi.getError() << endl;
440 oocoutI(nullptr,InputArguments) << "n = " << n << endl;
441 oocoutI(nullptr,InputArguments) << "This results in a distance of: " << impMaxMu / n << endl;
442 }
443
444 // exclude the null, just return the number of importance snapshots
445 return CreateNImpDensitiesForOnePOI( pdf, allPOI, poi, n-1, poiValueForBackground);
446}
447
448////////////////////////////////////////////////////////////////////////////////
449/// n is the number of importance densities
450
451int ToyMCImportanceSampler::CreateNImpDensitiesForOnePOI( RooAbsPdf& pdf, const RooArgSet& allPOI, RooRealVar& poi, int n, double poiValueForBackground ) {
452
453 // these might not necessarily be the same thing.
454 double impMaxMu = poi.getVal();
455
456 // create imp snapshots
457 if( impMaxMu > poiValueForBackground && n > 0 ) {
458 for( int i=1; i <= n; i++ ) {
459 poi.setVal( poiValueForBackground + (double)i/(n)*(impMaxMu - poiValueForBackground) );
460 oocoutI(nullptr,InputArguments) << endl << "create point with poi: " << endl;
461 poi.Print();
462
463 // impSnaps without first snapshot because that is null hypothesis
464
465 AddImportanceDensity( &pdf, &allPOI );
466 }
467 }
468
469 return n;
470}
471
472} // end namespace RooStats
#define d(i)
Definition RSha256.hxx:102
#define oocoutE(o, a)
#define oocoutI(o, a)
#define ooccoutI(o, a)
#define ooccoutD(o, a)
#define oocoutP(o, a)
#define ooccoutE(o, a)
#define ClassImp(name)
Definition Rtypes.h:382
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 Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
void Print(Option_t *options=nullptr) const override
Print the object to the defaultPrintStream().
Definition RooAbsArg.h:263
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
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:103
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:154
Object to represent discrete states.
Definition RooCategory.h:28
bool setIndex(Int_t index, bool printError=true) override
Set value by specifying the index code of the desired state.
bool defineType(const std::string &label)
Define a state with given name.
Container class to hold unbinned data.
Definition RooDataSet.h:34
void add(const RooArgSet &row, double weight, double weightError)
Add one ore more rows of data.
Variable that can be changed from the outside.
Definition RooRealVar.h:37
void setVal(double value) override
Set value of variable to 'value'.
double getError() const
Definition RooRealVar.h:58
Helper class for ToyMCSampler.
void NextPoint(RooArgSet &nuisPoint, double &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)
For importance sampling with multiple densities/snapshots: This is used to check the current Likeliho...
std::vector< const RooArgSet * > fImportanceSnapshots
RooDataSet * GetSamplingDistributionsSingleWorker(RooArgSet &paramPoint) override
overwrite GetSamplingDistributionsSingleWorker(paramPoint) with a version that loops over nulls and i...
RooAbsData * GenerateToyData(RooArgSet &paramPoint, double &weight) const override
std::vector< const RooArgSet * > fNullSnapshots
void SetDensityToGenerateFromByIndex(unsigned int i, bool fromNull=false)
specifies the pdf to sample from
std::vector< RooAbsPdf * > fImportanceDensities
std::vector< std::unique_ptr< RooAbsReal > > fImpNLLs
!
std::vector< std::unique_ptr< RooAbsReal > > fNullNLLs
!
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.
void ClearCache() override
helper method for clearing the cache
RooArgSet fConditionalObs
set of conditional observables
std::vector< RooAbsPdf * > fNullDensities
support multiple null densities
int CreateNImpDensitiesForOnePOI(RooAbsPdf &pdf, const RooArgSet &allPOI, RooRealVar &poi, int n, double poiValueForBackground=0.0)
n is the number of importance densities
const RooArgSet * fGlobalObservables
virtual void GenerateGlobalObservables(RooAbsPdf &pdf) const
generate global observables
virtual RooDataSet * GetSamplingDistributionsSingleWorker(RooArgSet &paramPoint)
This is the main function for serial runs.
NuisanceParametersSampler * fNuisanceParametersSampler
!
const RooArgSet * fObservables
RooAbsPdf * fPdf
densities, snapshots, and test statistics to reweight to
bool fExpectedNuisancePar
whether to use expectation values for nuisance parameters (ie Asimov data set)
const RooArgSet * fNuisancePars
std::vector< TestStatistic * > fTestStatistics
std::unique_ptr< RooAbsData > Generate(RooAbsPdf &pdf, RooArgSet &observables, const RooDataSet *protoData=nullptr, int forceEvents=0) const
helper for GenerateToyData
Int_t fNToys
number of toys to generate
virtual void ClearCache()
helper method for clearing the cache
RooAbsPdf * fPriorNuisance
prior pdf for nuisance parameters
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 WeightVar(const char *name="weight", bool reinterpretAsWeight=false)
RooCmdArg Constrain(const RooArgSet &params)
RooCmdArg CloneData(bool flag)
RooCmdArg ConditionalObservables(Args_t &&... argsOrArgSet)
Create a RooCmdArg to declare conditional observables.
const Int_t n
Definition legend1.C:16
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition CodegenImpl.h:64
@ InputArguments
Namespace for the RooStats classes.
Definition CodegenImpl.h:58
Int_t CeilNint(Double_t x)
Returns the nearest integer of TMath::Ceil(x).
Definition TMath.h:678