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] = nullptr; }
48 for( unsigned int i=0; i < fNullNLLs.size(); i++ ) if(fNullNLLs[i]) { delete fNullNLLs[i]; fNullNLLs[i] = nullptr; }
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 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 = 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()->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(nullptr,InputArguments) << "Null Densities:" << endl;
141 for( unsigned int i=0; i < fNullDensities.size(); i++) {
142 ooccoutI(nullptr,InputArguments) << " null density["<<i<<"]: " << fNullDensities[i] << " \t null snapshot["<<i<<"]: " << fNullSnapshots[i] << endl;
143 }
144 ooccoutE(nullptr,InputArguments) << "Cannot use multiple null densities and only ask for one weight." << endl;
145 return nullptr;
146 }
147
148 if( fNullDensities.empty() && fPdf ) {
149 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;
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(nullptr,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(nullptr,InputArguments) << "Null Densities:" << endl;
185 for( unsigned int i=0; i < fNullDensities.size(); i++) {
186 ooccoutI(nullptr,InputArguments) << " null density["<<i<<"]: " << fNullDensities[i] << " \t null snapshot["<<i<<"]: " << fNullSnapshots[i] << endl;
187 }
188 ooccoutE(nullptr,InputArguments) << "Cannot use multiple null densities and only ask for one weight and NLL." << endl;
189 return nullptr;
190 }
191
192 if( fNullDensities.empty() && fPdf ) {
193 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;
194 //AddNullDensity( fPdf, &paramPoint );
195 }
196
197 ooccoutI(nullptr,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(nullptr,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(nullptr,InputArguments) << endl;
248 ooccoutD(nullptr,InputArguments) << "GenerateToyDataImportanceSampling" << endl;
249
250 if(!fObservables) {
251 ooccoutE(nullptr,InputArguments) << "Observables not set." << endl;
252 return nullptr;
253 }
254
255 if( fNullDensities.empty() ) {
256 oocoutE(nullptr,InputArguments) << "ToyMCImportanceSampler: Need to specify the null density explicitly." << endl;
257 return nullptr;
258 }
259
260 // catch the case when NLLs are not created (e.g. when ToyMCSampler was streamed for Proof)
261 if( fNullNLLs.empty() && fNullDensities.size() > 0 ) {
262 for( unsigned int i = 0; i < fNullDensities.size(); i++ ) fNullNLLs.push_back( nullptr );
263 }
264 if( fImpNLLs.empty() && fImportanceDensities.size() > 0 ) {
265 for( unsigned int i = 0; i < fImportanceDensities.size(); i++ ) fImpNLLs.push_back( nullptr );
266 }
267
268 if( fNullDensities.size() != fNullNLLs.size() ) {
269 oocoutE(nullptr,InputArguments) << "ToyMCImportanceSampler: Something wrong. NullNLLs must be of same size as null densities." << endl;
270 return nullptr;
271 }
272
275 ) {
276 oocoutE(nullptr,InputArguments) << "ToyMCImportanceSampler: no importance density given or index out of range." << endl;
277 return nullptr;
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 nullptr 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->assign(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 nullptr 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, false, true); // 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 = nullptr;
335 if( fGenerateFromNull ) {
336 //cout << "gen from null" << endl;
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;
345 }
347 }
348 //cout << "data generated: " << data << endl;
349
350 if (!data) {
351 oocoutE(nullptr,InputArguments) << "ToyMCImportanceSampler: error generating data" << endl;
352 return nullptr;
353 }
354
355
356
357 // Importance Sampling: adjust weight
358 // Sources: Alex Read, presentation by Michael Woodroofe
359
360 ooccoutD(nullptr,InputArguments) << "About to create/calculate all nullNLLs." << endl;
361 for( unsigned int i=0; i < fNullDensities.size(); i++ ) {
362 //oocoutI(nullptr,InputArguments) << "Setting variables to nullSnapshot["<<i<<"]"<<endl;
363 //fNullSnapshots[i]->Print("v");
364
365 allVars->assign(*fNullSnapshots[i]);
366 if( !fNullNLLs[i] ) {
367 RooArgSet* allParams = fNullDensities[i]->getParameters(*data);
368 fNullNLLs[i] = fNullDensities[i]->createNLL(*data, RooFit::CloneData(false), RooFit::Constrain(*allParams),
370 delete allParams;
371 }else{
372 fNullNLLs[i]->setData( *data, false );
373 }
374 nullNLLVals[i] = fNullNLLs[i]->getVal();
375 // FOR DEBuGGING!!!!!!!!!!!!!!!!!
376 if( !fReuseNLL ) { delete fNullNLLs[i]; fNullNLLs[i] = nullptr; }
377 }
378
379
380 // for each null: find minNLLVal of null and all imp densities
381 ooccoutD(nullptr,InputArguments) << "About to find the minimum NLLs." << endl;
382 vector<double> minNLLVals;
383 for( unsigned int i=0; i < nullNLLVals.size(); i++ ) minNLLVals.push_back( nullNLLVals[i] );
384
385 for( unsigned int i=0; i < fImportanceDensities.size(); i++ ) {
386 //oocoutI(nullptr,InputArguments) << "Setting variables to impSnapshot["<<i<<"]"<<endl;
387 //fImportanceSnapshots[i]->Print("v");
388
389 if( fImportanceSnapshots[i] ) {
390 allVars->assign(*fImportanceSnapshots[i]);
391 }
392 if( !fImpNLLs[i] ) {
393 RooArgSet* allParams = fImportanceDensities[i]->getParameters(*data);
394 fImpNLLs[i] = fImportanceDensities[i]->createNLL(*data, RooFit::CloneData(false), RooFit::Constrain(*allParams),
396 delete allParams;
397 }else{
398 fImpNLLs[i]->setData( *data, false );
399 }
400 impNLLVals[i] = fImpNLLs[i]->getVal();
401 // FOR DEBuGGING!!!!!!!!!!!!!!!!!
402 if( !fReuseNLL ) { delete fImpNLLs[i]; fImpNLLs[i] = nullptr; }
403
404 for( unsigned int j=0; j < nullNLLVals.size(); j++ ) {
405 if( impNLLVals[i] < minNLLVals[j] ) minNLLVals[j] = impNLLVals[i];
406 ooccoutD(nullptr,InputArguments) << "minNLLVals["<<j<<"]: " << minNLLVals[j] << " nullNLLVals["<<j<<"]: " << nullNLLVals[j] << " impNLLVals["<<i<<"]: " << impNLLVals[i] << endl;
407 }
408 }
409
410 // veto toys: this is a sort of "overlap removal" of the various distributions
411 // if not vetoed: apply weight
412 ooccoutD(nullptr,InputArguments) << "About to apply vetos and calculate weights." << endl;
413 for( unsigned int j=0; j < nullNLLVals.size(); j++ ) {
414 if ( fApplyVeto && fGenerateFromNull && minNLLVals[j] != nullNLLVals[j] ) weights[j] = 0.0;
415 else if( fApplyVeto && !fGenerateFromNull && minNLLVals[j] != impNLLVals[fIndexGenDensity] ) weights[j] = 0.0;
416 else if( !fGenerateFromNull ) {
417 // apply (for fImportanceGenNorm, the weight is one, so nothing needs to be done here)
418
419 // L(pdf) / L(imp) = exp( NLL(imp) - NLL(pdf) )
420 weights[j] *= exp(minNLLVals[j] - nullNLLVals[j]);
421 }
422
423 ooccoutD(nullptr,InputArguments) << "weights["<<j<<"]: " << weights[j] << endl;
424 }
425
426
427
428 allVars->assign(*saveVars);
429 delete allVars;
430 delete saveVars;
431
432 return data;
433}
434
435////////////////////////////////////////////////////////////////////////////////
436/// poi has to be fitted beforehand. This function expects this to be the muhat value.
437
438int ToyMCImportanceSampler::CreateImpDensitiesForOnePOIAdaptively( RooAbsPdf& pdf, const RooArgSet& allPOI, RooRealVar& poi, double nStdDevOverlap, double poiValueForBackground ) {
439 // these might not necessarily be the same thing.
440 double impMaxMu = poi.getVal();
441
442 // this includes the null
443 int n = 1;
444
445 // check whether error is trustworthy
446 if( poi.getError() > 0.01 && poi.getError() < 5.0 ) {
447 n = TMath::CeilNint( poi.getVal() / (2.*nStdDevOverlap*poi.getError()) ); // round up
448 oocoutI(nullptr,InputArguments) << "Using fitFavoredMu and error to set the number of imp points" << endl;
449 oocoutI(nullptr,InputArguments) << "muhat: " << poi.getVal() << " optimize for distance: " << 2.*nStdDevOverlap*poi.getError() << endl;
450 oocoutI(nullptr,InputArguments) << "n = " << n << endl;
451 oocoutI(nullptr,InputArguments) << "This results in a distance of: " << impMaxMu / n << endl;
452 }
453
454 // exclude the null, just return the number of importance snapshots
455 return CreateNImpDensitiesForOnePOI( pdf, allPOI, poi, n-1, poiValueForBackground);
456}
457
458////////////////////////////////////////////////////////////////////////////////
459/// n is the number of importance densities
460
461int ToyMCImportanceSampler::CreateNImpDensitiesForOnePOI( RooAbsPdf& pdf, const RooArgSet& allPOI, RooRealVar& poi, int n, double poiValueForBackground ) {
462
463 // these might not necessarily be the same thing.
464 double impMaxMu = poi.getVal();
465
466 // create imp snapshots
467 if( impMaxMu > poiValueForBackground && n > 0 ) {
468 for( int i=1; i <= n; i++ ) {
469 poi.setVal( poiValueForBackground + (double)i/(n)*(impMaxMu - poiValueForBackground) );
470 oocoutI(nullptr,InputArguments) << endl << "create point with poi: " << endl;
471 poi.Print();
472
473 // impSnaps without first snapshot because that is null hypothesis
474
475 AddImportanceDensity( &pdf, &allPOI );
476 }
477 }
478
479 return n;
480}
481
482} // end namespace RooStats
#define d(i)
Definition: RSha256.hxx:102
#define oocoutE(o, a)
Definition: RooMsgService.h:52
#define oocoutI(o, a)
Definition: RooMsgService.h:49
#define ooccoutI(o, a)
Definition: RooMsgService.h:57
#define ooccoutD(o, a)
Definition: RooMsgService.h:56
#define oocoutP(o, a)
Definition: RooMsgService.h:50
#define ooccoutE(o, a)
Definition: RooMsgService.h:60
#define ClassImp(name)
Definition: Rtypes.h:375
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:321
RooArgSet * getVariables(bool stripDisconnected=true) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
Definition: RooAbsArg.cxx:2057
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:62
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition: RooAbsReal.h:91
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:56
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:179
RooCategory is an 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.
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:55
void add(const RooArgSet &row, double weight=1.0, double weightError=0.0) override
Add one ore more rows of data.
RooRealVar represents a variable that can be changed from the outside.
Definition: RooRealVar.h:40
void setVal(double value) override
Set value of variable to 'value'.
Definition: RooRealVar.cxx:254
double getError() const
Definition: RooRealVar.h:62
Helper class for ToyMCSampler.
Definition: ToyMCSampler.h:38
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
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
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:251
virtual void GenerateGlobalObservables(RooAbsPdf &pdf) const
generate global observables
RooAbsData * Generate(RooAbsPdf &pdf, RooArgSet &observables, const RooDataSet *protoData=nullptr, int forceEvents=0) const
helper for GenerateToyData
virtual RooDataSet * GetSamplingDistributionsSingleWorker(RooArgSet &paramPoint)
This is the main function for serial runs.
NuisanceParametersSampler * fNuisanceParametersSampler
!
Definition: ToyMCSampler.h:275
const RooArgSet * fObservables
Definition: ToyMCSampler.h:250
RooAbsPdf * fPdf
densities, snapshots, and test statistics to reweight to
Definition: ToyMCSampler.h:243
bool fExpectedNuisancePar
whether to use expectation values for nuisance parameters (ie Asimov data set)
Definition: ToyMCSampler.h:255
const RooArgSet * fNuisancePars
Definition: ToyMCSampler.h:249
std::vector< TestStatistic * > fTestStatistics
Definition: ToyMCSampler.h:245
Int_t fNToys
number of toys to generate
Definition: ToyMCSampler.h:252
virtual void ClearCache()
helper method for clearing the cache
RooAbsPdf * fPriorNuisance
prior pdf for nuisance parameters
Definition: ToyMCSampler.h:248
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:2345
RooCmdArg Constrain(const RooArgSet &params)
RooCmdArg CloneData(bool flag)
RooCmdArg ConditionalObservables(Args_t &&... argsOrArgSet)
Create a RooCmdArg to declare conditional observables.
RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
Definition: RVec.hxx:1792
RVec< PromoteType< T > > exp(const RVec< T > &v)
Definition: RVec.hxx:1783
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: Common.h:18
@ Generation
Definition: RooGlobalFunc.h:61
@ InputArguments
Definition: RooGlobalFunc.h:62
Namespace for the RooStats classes.
Definition: Asimov.h:19
Int_t CeilNint(Double_t x)
Returns the nearest integer of TMath::Ceil(x).
Definition: TMath.h:672