104 for (
auto *myarg2 : static_range_cast<RooRealVar *>(*
fParams)) {
105 myarg2->setBins(nBins);
118 "Adjusted number of toys to number of bins of nuisance parameters: " <<
fNToys << endl;
229 bool goodConfig =
true;
247 if (!allTS)
return 0;
255 std::unique_ptr<RooArgSet> allVars;
256 std::unique_ptr<RooArgSet> saveAll;
261 saveAll = std::make_unique<RooArgSet>();
262 allVars->snapshot(*saveAll);
267 std::unique_ptr<RooArgSet> parForTS(poi.
snapshot());
277 allVars->assign(*saveAll);
287 oocoutW(
nullptr,
InputArguments) <<
"Multiple test statistics defined, but only one distribution will be returned." << endl;
294 if(
r ==
nullptr ||
r->numEntries() == 0) {
315 <<
"Bad COnfiguration in ToyMCSampler "
324 <<
"Adaptive sampling in ToyMCSampler is not supported for parallel runs."
370 <<
"Bad COnfiguration in ToyMCSampler "
386 double toysInTails = 0.0;
393 if ( i% 500 == 0 && i>0 ) {
402 double valueFirst = -999.0, weight = 1.0;
405 allVars->assign(*saveAll);
411 return dynamic_cast<const RooAbsCategory*>(arg) != nullptr;
413 oocoutE(
nullptr,
Generation) <<
"ToyMCSampler: Generated toy data didn't contain a category variable, although"
414 " a simultaneous PDF is in use. To generate events for a simultaneous PDF, all components need to be"
415 " extended. Otherwise, the number of events to generate per component cannot be determined." << std::endl;
424 valueFirst = firstTS->getVal();
429 if(valueFirst != valueFirst) {
430 oocoutW(
nullptr,
Generation) <<
"skip: " << valueFirst <<
", " << weight << endl;
438 if(weight >= 0.) toysInTails += weight;
439 else toysInTails += 1.;
444 allVars->assign(*saveAll);
481 for (
int i=0; i < nCat; ++i){
488 _obsList.emplace_back(std::move(globtmp));
494 for (
unsigned int i = 0; i <
_pdfList.size(); ++i) {
507 allVars->assign(*values);
528 allVars->assign(paramPoint);
535 oocoutI(
nullptr,
InputArguments) <<
"Cannot use multigen when nuisance parameters vary for every toy" << endl;
558 RooArgSet allVarsMinusParamPoint(*allVars);
559 allVarsMinusParamPoint.
remove(paramPoint,
false,
true);
573 allVars->assign(*saveVars);
593 std::unique_ptr<RooAbsData>
data;
594 int events = forceEvents;
625 <<
"ToyMCSampler: Error : pdf is not extended and number of events per toy is zero"
668 last->
Add(newSamples);
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 r
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooFit::OwningPtr< RooArgSet > getObservables(const RooArgSet &set, bool valueOnly=true) const
Given a set of possible observables, return the observables that this PDF depends on.
RooFit::OwningPtr< RooArgSet > getVariables(bool stripDisconnected=true) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
virtual const char * getCurrentLabel() const
Return label string of current state.
Int_t numTypes(const char *=nullptr) const
Return number of types defined (in range named rangeName if rangeName!=nullptr)
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
Storage_t const & get() const
Const access to the underlying stl container.
RooAbsCollection * snapshot(bool deepCopy=true) const
Take a snap shot of current collection contents.
Int_t getSize() const
Return the number of elements in the collection.
const_iterator end() const
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...
RooAbsArg * first() const
const_iterator begin() const
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
GenSpec * prepareMultiGen(const RooArgSet &whatVars, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none())
Prepare GenSpec configuration object for efficient generation of multiple datasets from identical spe...
virtual double expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
RooFit::OwningPtr< RooDataSet > generate(const RooArgSet &whatVars, Int_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none())
See RooAbsPdf::generate(const RooArgSet&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,...
bool canBeExtended() const
If true, PDF can provide extended likelihood term.
virtual RooFit::OwningPtr< RooDataSet > generateSimGlobal(const RooArgSet &whatVars, Int_t nEvents)
Special generator interface for generation of 'global observables' – for RooStats tools.
RooArgList is a container object that can hold multiple RooAbsArg objects.
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.
RooDataSet is a container class to hold unbinned data.
static RooMsgService & instance()
Return reference to singleton instance.
StreamConfig & getStream(Int_t id)
static constexpr double infinity()
Return internal infinity representation.
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
RooRealVar represents a variable that can be changed from the outside.
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
RooAbsPdf * getPdf(RooStringView catName) const
Return the p.d.f associated with the given index category name.
const RooAbsCategoryLValue & indexCat() const
This class is designed to aid in the construction of RooDataSets and RooArgSets, particularly those n...
void AppendArgSet(const RooAbsCollection *aset, TString prefix="")
For each variable in aset, prepend prefix to its name and add to the internal store.
RooDataSet * GetAsDataSet(TString name, TString title)
Returns all detailed output as a dataset.
const RooArgList * GetAsArgList() const
void CommitSet(double weight=1.0)
Commit to the result RooDataSet.
RooWorkspace & GetWorkspace(void) const
returns fWorkspace
Int_t GetNExperiments(void) const
return fNExperiments
const char * GetHost(void) const
returns fHost
bool GetShowGui(void) const
return fShowGui
This class simply holds a sampling distribution of some test statistic.
void Add(const SamplingDistribution *other)
merge two sampling distributions
TestStatistic is an interface class to provide a facility for construction test statistics distributi...
ToyMCSampler is an implementation of the TestStatSampler interface.
const RooArgSet * fGlobalObservables
std::string fSamplingDistName
name of the model
virtual void GenerateGlobalObservables(RooAbsPdf &pdf) const
generate global observables
virtual RooDataSet * GetSamplingDistributionsSingleWorker(RooArgSet ¶mPoint)
This is the main function for serial runs.
std::unique_ptr< const RooArgSet > fParametersForTestStat
virtual SamplingDistribution * AppendSamplingDistribution(RooArgSet &allParameters, SamplingDistribution *last, Int_t additionalMC)
Extended interface to append to sampling distribution more samples.
NuisanceParametersSampler * fNuisanceParametersSampler
!
std::unique_ptr< RooAbsPdf::GenSpec > _gs4
! GenSpec #4
const RooArgSet * fObservables
double fAdaptiveHighLimit
double fToysInTails
minimum no of toys in tails for adaptive sampling (taking weights into account, therefore double) Def...
virtual RooArgList * EvaluateAllTestStatistics(RooAbsData &data, const RooArgSet &poi)
Evaluate all test statistics, returning result and any detailed output.
RooAbsPdf * fPdf
densities, snapshots, and test statistics to reweight to
SamplingDistribution * GetSamplingDistribution(RooArgSet ¶mPoint) override
main interface
std::unique_ptr< RooAbsPdf::GenSpec > _gs1
! GenSpec #1
virtual RooDataSet * GetSamplingDistributions(RooArgSet ¶mPoint)
Use for serial and parallel runs.
virtual void AddTestStatistic(TestStatistic *t=nullptr)
The pdf can be nullptr in which case the density from SetPdf() is used.
virtual RooAbsData * GenerateToyData(RooArgSet ¶mPoint, RooAbsPdf &pdf) const
generates toy data without weight
bool fExpectedNuisancePar
whether to use expectation values for nuisance parameters (ie Asimov data set)
bool fUseMultiGen
Use PrepareMultiGen?
std::unique_ptr< RooAbsPdf::GenSpec > _gs2
! GenSpec #2
const RooArgSet * fNuisancePars
std::unique_ptr< RooAbsPdf::GenSpec > _gs3
! GenSpec #3
std::vector< TestStatistic * > fTestStatistics
Int_t fNEvents
number of events per toy (may be ignored depending on settings)
ToyMCSampler()
Proof constructor. Do not use.
double fAdaptiveLowLimit
tails
std::unique_ptr< RooArgSet > _allVars
!
std::unique_ptr< RooAbsData > Generate(RooAbsPdf &pdf, RooArgSet &observables, const RooDataSet *protoData=nullptr, int forceEvents=0) const
helper for GenerateToyData
static void SetAlwaysUseMultiGen(bool flag)
std::vector< RooAbsPdf * > _pdfList
! We don't own those objects
Int_t fNToys
number of toys to generate
virtual void ClearCache()
helper method for clearing the cache
bool CheckConfig(void)
Checks for sufficient information to do a GetSamplingDistribution(...).
ProofConfig * fProofConfig
!
std::vector< std::unique_ptr< RooArgSet > > _obsList
!
static bool fgAlwaysUseMultiGen
Use PrepareMultiGen always.
double fMaxToys
maximum no of toys (taking weights into account, therefore double)
const RooDataSet * fProtoData
in dev
TString fGenerateBinnedTag
std::vector< std::unique_ptr< RooAbsPdf::GenSpec > > _gsList
!
RooAbsPdf * fPriorNuisance
prior pdf for nuisance parameters
ToyMCStudy is an implementation of RooAbsStudy for toy Monte Carlo sampling.
void SetToyMCSampler(ToyMCSampler &t)
void SetParamPoint(const RooArgSet ¶mPoint)
void SetRandomSeed(unsigned int seed)
RooStudyManager is a utility class to manage studies that consist of repeated applications of generat...
void runProof(Int_t nExperiments, const char *proofHost="", bool showGui=true)
Open PROOF-Lite session.
The RooWorkspace is a persistable container for RooFit projects.
virtual UInt_t Integer(UInt_t imax)
Returns a random integer uniformly distributed on the interval [ 0, imax-1 ].
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
RooCmdArg Extended(bool flag=true)
RooCmdArg ProtoData(const RooDataSet &protoData, bool randomizeOrder=false, bool resample=false)
RooCmdArg AutoBinned(bool flag=true)
RooCmdArg NumEvents(Int_t numEvents)
RooCmdArg GenBinned(const char *tag)
RooCmdArg ExpectedData(bool flag=true)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Namespace for the RooStats classes.
void removeTopic(RooFit::MsgTopic oldTopic)