38using std::endl, std::string;
74 toymcs->SetProtoData(&data);
76 toymcs->SetGenerateBinned(dataIsBinned);
124 std::unique_ptr<const RooArgSet> nullSnapshot {
fNullModel->GetSnapshot()};
125 if(nullSnapshot ==
nullptr) {
126 oocoutE(
nullptr,Generation) <<
"Null model needs a snapshot. Set using modelconfig->SetSnapshot(poi)." << std::endl;
132 oocoutE(
nullptr,Generation) <<
"There was an error in CheckHook(). Stop." << std::endl;
137 oocoutE(
nullptr,InputArguments) <<
"Test Statistic Sampler or Test Statistics not defined. Stop." << std::endl;
142 std::unique_ptr<RooArgSet> altParams{
fAltModel->GetPdf()->getParameters(*
fData)};
144 std::unique_ptr<RooArgSet> bothParams{
fNullModel->GetPdf()->getParameters(*
fData)};
145 bothParams->add(*altParams,
false);
146 std::unique_ptr<RooArgSet> saveAll {(
RooArgSet*) bothParams->snapshot()};
155 std::unique_ptr<RooArgList> allTS;
158 if (!allTS)
return nullptr;
162 obsTestStat = firstTS->
getVal();
163 if (allTS->size()<=1) {
170 oocoutP(
nullptr,Generation) <<
"Test Statistic on data: " << obsTestStat << std::endl;
175 bothParams->assign(*saveAll);
182 auto *pdf = modelConfig->GetPdf();
183 if (nEventsPerToy == 0 && (!pdf->canBeExtended() || pdf->expectedEvents(modelConfig->GetObservables()) <= 0)) {
192 if(
PreNullHook(¶mPointNull, obsTestStat) != 0) {
193 oocoutE(
nullptr,Generation) <<
"PreNullHook did not return 0." << std::endl;
203 if (detOut_null->
get()->
size()<=1) {
205 detOut_null=
nullptr;
208 }
else samp_null =
fTestStatSampler->GetSamplingDistribution(paramPointNull);
211 bothParams->assign(*saveAll);
216 if(
PreAltHook(¶mPointAlt, obsTestStat) != 0) {
217 oocoutE(
nullptr,Generation) <<
"PreAltHook did not return 0." << std::endl;
225 unsigned int prevSeed = 0;
236 if (detOut_alt->
get()->
size()<=1) {
251 string resultname =
"HypoTestCalculator_result";
262 if (aset !=
nullptr) {
268 bothParams->assign(*saveAll);
Storage_t::size_type size() const
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.
Container class to hold N-dimensional binned data.
Container class to hold unbinned data.
const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
void add(const RooArgSet &row, double weight, double weightError)
Add one ore more rows of data.
static UInt_t integer(UInt_t max, TRandom *generator=randomGenerator())
Return an integer uniformly distributed from [0,n-1].
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
Variable that can be changed from the outside.
const ModelConfig * fAltModel
virtual void PreHook() const
HypoTestResult * GetHypoTest() const override
inherited methods from HypoTestCalculator interface
~HypoTestCalculatorGeneric() override
virtual int PreNullHook(RooArgSet *, double) const
void SetupSampler(const ModelConfig &model) const
common setup for both models
TestStatSampler * fTestStatSampler
unsigned int fAltToysSeed
virtual int PreAltHook(RooArgSet *, double) const
const ModelConfig * fNullModel
TestStatistic * fDefaultTestStat
virtual int CheckHook(void) const
virtual const RooArgSet * GetFitInfo() const
void UseSameAltToys()
Set this for re-using always the same toys for alternate hypothesis in case of calls at different nul...
TestStatSampler * fDefaultSampler
virtual void PostHook() const
HypoTestCalculatorGeneric(const RooAbsData &data, const ModelConfig &altModel, const ModelConfig &nullModel, TestStatSampler *sampler=nullptr)
Constructor.
HypoTestResult is a base class for results from hypothesis tests.
void SetAltDetailedOutput(RooDataSet *d)
void SetNullDetailedOutput(RooDataSet *d)
void SetAllTestStatisticsData(const RooArgList *tsd)
void SetNullDistribution(SamplingDistribution *null)
void SetTestStatisticData(const double tsd)
void SetFitInfo(RooDataSet *d)
void SetAltDistribution(SamplingDistribution *alt)
void SetPValueIsRightTail(bool pr)
< A class that holds configuration information for a model using a workspace as a store
const RooArgSet * GetSnapshot() const
get RooArgSet for parameters for a particular hypothesis (return nullptr if not existing)
RooAbsPdf * GetPdf() const
get model PDF (return nullptr if pdf has not been specified or does not exist)
TestStatistic that returns the ratio of profiled likelihoods.
This class simply holds a sampling distribution of some test statistic.
TestStatSampler is an interface class for a tools which produce RooStats SamplingDistributions.
ToyMCSampler is an implementation of the TestStatSampler interface.
int nEventsPerToy() const
virtual RooArgList * EvaluateAllTestStatistics(RooAbsData &data, const RooArgSet &poi)
Evaluate all test statistics, returning result and any detailed output.
virtual RooDataSet * GetSamplingDistributions(RooArgSet ¶mPoint)
Use for serial and parallel runs.
virtual void SetNEventsPerToy(const Int_t nevents)
Forces the generation of exactly n events even for extended PDFs.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
RooStats::ModelConfig ModelConfig
Namespace for the RooStats classes.