54 if(
fNToys == 0 )
return nullptr;
60 RooCategory densityLabel(
"densityLabel",
"densityLabel" );
72 oocoutP(
nullptr,
Generation) << endl << endl <<
" GENERATING FROM nullptr DENSITY " << endl << endl;
79 RooRealVar reweight(
"reweight",
"reweight", 1.0 );
102 result->addColumn( densityLabel );
103 result->addColumn( reweight );
110 for(
int j=0; j <
result->numEntries(); j++ ) {
138 ooccoutE(
nullptr,
InputArguments) <<
"Cannot use multiple null densities and only ask for one weight." << endl;
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;
150 ooccoutD(
nullptr,
InputArguments) <<
"Using given parameter point. Replaces snapshot for the only null currently defined." << endl;
156 vector<double> weights;
157 weights.push_back( weight );
159 vector<double> impNLLs;
161 vector<double> nullNLLs;
162 for(
unsigned int i=0; i <
fNullDensities.size(); i++ ) nullNLLs.push_back( 0.0 );
174 vector<double>& impNLLs,
182 ooccoutE(
nullptr,
InputArguments) <<
"Cannot use multiple null densities and only ask for one weight and NLL." << endl;
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;
191 ooccoutI(
nullptr,
InputArguments) <<
"Using given parameter point. Overwrites snapshot for the only null currently defined." << endl;
196 vector<double> weights;
197 weights.push_back( weight );
199 vector<double> nullNLLs;
200 nullNLLs.push_back( nullNLL );
204 nullNLL = nullNLLs[0];
211 vector<double>& weights
214 ooccoutI(
nullptr,
InputArguments) <<
"weights.size() != nullDesnities.size(). You need to provide a vector with the correct size." << endl;
218 vector<double> impNLLs;
220 vector<double> nullNLLs;
221 for(
unsigned int i=0; i <
fNullDensities.size(); i++ ) nullNLLs.push_back( 0.0 );
235 vector<double>& weights,
236 vector<double>& impNLLVals,
237 vector<double>& nullNLLVals
250 oocoutE(
nullptr,
InputArguments) <<
"ToyMCImportanceSampler: Need to specify the null density explicitly." << endl;
263 oocoutE(
nullptr,
InputArguments) <<
"ToyMCImportanceSampler: Something wrong. NullNLLs must be of same size as null densities." << endl;
270 oocoutE(
nullptr,
InputArguments) <<
"ToyMCImportanceSampler: no importance density given or index out of range." << endl;
285 allVars->assign(paramPoint);
304 allVars->add(*allVarsImpDens);
308 double globalWeight = 1.0;
318 RooArgSet allVarsMinusParamPoint(*allVars);
319 allVarsMinusParamPoint.
remove(paramPoint,
false,
true);
325 for(
unsigned int i=0; i < weights.size(); i++ ) weights[i] = globalWeight;
374 vector<double> minNLLVals;
375 for(
unsigned int i=0; i < nullNLLVals.size(); i++ ) minNLLVals.push_back( nullNLLVals[i] );
391 impNLLVals[i] =
fImpNLLs[i]->getVal();
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;
404 for(
unsigned int j=0; j < nullNLLVals.size(); j++ ) {
411 weights[j] *= exp(minNLLVals[j] - nullNLLVals[j]);
419 allVars->assign(*saveVars);
430 double impMaxMu = poi.
getVal();
438 oocoutI(
nullptr,
InputArguments) <<
"Using fitFavoredMu and error to set the number of imp points" << endl;
454 double impMaxMu = poi.
getVal();
457 if( impMaxMu > poiValueForBackground &&
n > 0 ) {
458 for(
int i=1; i <=
n; i++ ) {
459 poi.
setVal( poiValueForBackground + (
double)i/(
n)*(impMaxMu - poiValueForBackground) );
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().
RooFit::OwningPtr< RooArgSet > getVariables(bool stripDisconnected=true) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
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.
RooAbsData is the common abstract base class for binned and unbinned datasets.
double 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 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.
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.
void setVal(double value) override
Set value of variable to 'value'.
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
~ToyMCImportanceSampler() override
RooDataSet * GetSamplingDistributionsSingleWorker(RooArgSet ¶mPoint) override
overwrite GetSamplingDistributionsSingleWorker(paramPoint) with a version that loops over nulls and i...
RooAbsData * GenerateToyData(RooArgSet ¶mPoint, 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
toysStrategies fToysStrategy
std::vector< std::unique_ptr< RooAbsReal > > fImpNLLs
!
std::vector< std::unique_ptr< RooAbsReal > > fNullNLLs
!
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.
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 ¶mPoint)
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.
RooCmdArg WeightVar(const char *name="weight", bool reinterpretAsWeight=false)
RooCmdArg Constrain(const RooArgSet ¶ms)
RooCmdArg CloneData(bool 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)
Returns the nearest integer of TMath::Ceil(x).