54 if(
fNToys == 0 )
return NULL;
60 RooCategory densityLabel(
"densityLabel",
"densityLabel" );
79 RooRealVar reweight(
"reweight",
"reweight", 1.0 );
108 RooRealVar weightVar (
"weight",
"weight", 1.0 );
109 columns.
add( weightVar );
116 for(
int j=0; j < result->
numEntries(); j++ ) {
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;
162 vector<double> weights;
163 weights.push_back( weight );
165 vector<double> impNLLs;
167 vector<double> nullNLLs;
168 for(
unsigned int i=0; i <
fNullDensities.size(); i++ ) nullNLLs.push_back( 0.0 );
180 vector<double>& impNLLs,
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;
202 vector<double> weights;
203 weights.push_back( weight );
205 vector<double> nullNLLs;
206 nullNLLs.push_back( nullNLL );
210 nullNLL = nullNLLs[0];
217 vector<double>& weights
220 ooccoutI((
TObject*)NULL,
InputArguments) <<
"weights.size() != nullDesnities.size(). You need to provide a vector with the correct size." << endl;
224 vector<double> impNLLs;
226 vector<double> nullNLLs;
227 for(
unsigned int i=0; i <
fNullDensities.size(); i++ ) nullNLLs.push_back( 0.0 );
241 vector<double>& weights,
242 vector<double>& impNLLVals,
243 vector<double>& nullNLLVals
269 oocoutE((
TObject*)NULL,
InputArguments) <<
"ToyMCImportanceSampler: Something wrong. NullNLLs must be of same size as null densities." << endl;
291 allVars->
assign(paramPoint);
310 allVars->
add(*allVarsImpDens);
311 delete allVarsImpDens;
315 double globalWeight = 1.0;
325 RooArgSet allVarsMinusParamPoint(*allVars);
332 for(
unsigned int i=0; i < weights.size(); i++ ) weights[i] = globalWeight;
382 vector<double> minNLLVals;
383 for(
unsigned int i=0; i < nullNLLVals.size(); i++ ) minNLLVals.push_back( nullNLLVals[i] );
400 impNLLVals[i] =
fImpNLLs[i]->getVal();
404 for(
unsigned int j=0; j < nullNLLVals.size(); j++ ) {
405 if( impNLLVals[i] < minNLLVals[j] ) minNLLVals[j] = impNLLVals[i];
406 ooccoutD((
TObject*)0,
InputArguments) <<
"minNLLVals["<<j<<
"]: " << minNLLVals[j] <<
" nullNLLVals["<<j<<
"]: " << nullNLLVals[j] <<
" impNLLVals["<<i<<
"]: " << impNLLVals[i] << endl;
413 for(
unsigned int j=0; j < nullNLLVals.size(); j++ ) {
420 weights[j] *= exp(minNLLVals[j] - nullNLLVals[j]);
428 allVars->
assign(*saveVars);
440 double impMaxMu = poi.
getVal();
464 double impMaxMu = poi.
getVal();
467 if( impMaxMu > poiValueForBackground &&
n > 0 ) {
468 for(
int i=1; i <=
n; i++ ) {
469 poi.
setVal( poiValueForBackground + (
double)i/(
n)*(impMaxMu - poiValueForBackground) );
virtual void Print(Option_t *options=0) const
Print the object to the defaultPrintStream().
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
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...
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.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
RooCategory is an object to represent discrete states.
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.
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.
RooRealVar represents a variable that can be changed from the outside.
Double_t getError() const
virtual void setVal(Double_t value)
Set value of variable to 'value'.
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 ¶mPoint, double &weight) const
std::vector< RooAbsPdf * > fImportanceDensities
toysStrategies fToysStrategy
virtual RooDataSet * GetSamplingDistributionsSingleWorker(RooArgSet ¶mPoint)
This is the main function for serial runs.
virtual ~ToyMCImportanceSampler()
virtual void ClearCache()
clear the cache obtained from the pdf used for speeding the toy and global observables generation nee...
unsigned int fIndexGenDensity
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.
RooArgSet fConditionalObs
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
virtual void GenerateGlobalObservables(RooAbsPdf &pdf) const
virtual RooDataSet * GetSamplingDistributionsSingleWorker(RooArgSet ¶mPoint)
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
const RooArgSet * fObservables
const RooArgSet * fNuisancePars
Bool_t fExpectedNuisancePar
std::vector< TestStatistic * > fTestStatistics
virtual void ClearCache()
clear the cache obtained from the pdf used for speeding the toy and global observables generation nee...
RooAbsPdf * fPriorNuisance
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
RooCmdArg Constrain(const RooArgSet ¶ms)
RooCmdArg CloneData(Bool_t flag)
RooCmdArg ConditionalObservables(Args_t &&... argsOrArgSet)
Create a RooCmdArg to declare conditional observables.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Namespace for the RooStats classes.
@ EXPONENTIALTOYDISTRIBUTION
Int_t CeilNint(Double_t x)