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 = 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;
380 vector<double> minNLLVals;
381 for(
unsigned int i=0; i < nullNLLVals.size(); i++ ) minNLLVals.push_back( nullNLLVals[i] );
396 impNLLVals[i] =
fImpNLLs[i]->getVal();
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;
409 for(
unsigned int j=0; j < nullNLLVals.size(); j++ ) {
416 weights[j] *=
exp(minNLLVals[j] - nullNLLVals[j]);
424 *allVars = *saveVars;
436 double impMaxMu = poi.
getVal();
460 double impMaxMu = poi.
getVal();
463 if( impMaxMu > poiValueForBackground &&
n > 0 ) {
464 for(
int i=1; i <=
n; i++ ) {
465 poi.
setVal( poiValueForBackground + (
double)i/(
n)*(impMaxMu - poiValueForBackground) );
double pow(double, double)
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
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
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.
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...
RooCategory represents a fundamental (non-derived) discrete value object.
Bool_t defineType(const char *label)
Define a state with given name, the lowest available positive integer is assigned as index.
virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE)
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
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 Double_t weight() const
Return event weight of current event.
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0)
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
RooRealVar represents a fundamental (non-derived) real valued object.
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.
Template specialisation used in RooAbsArg:
RooCmdArg Constrain(const RooArgSet ¶ms)
RooCmdArg CloneData(Bool_t flag)
RooCmdArg ConditionalObservables(const RooArgSet &set)
Namespace for the RooStats classes.
@ EXPONENTIALTOYDISTRIBUTION
Int_t CeilNint(Double_t x)