98 fNuisanceParameters(0),
101 fGenerateBinned(false),
102 fUsePriorPdf(false), fTmpDoExtended(true)
125 fNuisanceParameters(nuisance_parameters),
128 fGenerateBinned(GenerateBinned),
167 fNuisanceParameters(nuisance_parameters),
170 fGenerateBinned(GenerateBinned),
194 fSbModel(sbModel.GetPdf()),
195 fBModel(bModel.GetPdf()),
197 fNuisanceParameters((sbModel.GetNuisanceParameters()) ? sbModel.GetNuisanceParameters() : bModel.GetNuisanceParameters()),
198 fPriorPdf((sbModel.GetPriorPdf()) ? sbModel.GetPriorPdf() : bModel.GetPriorPdf()),
200 fGenerateBinned(GenerateBinned),
273 double testStatData = 0;
277 testStatData = nEvents;
283 double sb_nll_val = sb_nll.
getVal();
286 double b_nll_val = b_nll.
getVal();
287 double m2lnQ = 2*(sb_nll_val-b_nll_val);
288 testStatData = m2lnQ;
292 double sb_nll_val = sb_nll.
getVal();
295 double b_nll_val = b_nll.
getVal();
296 double m2lnQ = 2*(sb_nll_val-b_nll_val);
297 testStatData = m2lnQ;
305 testStatData = m2lnQ;
310 testStatData = m2lnQ;
314 std::cout <<
"Test statistics has been evaluated for data\n";
326 std::vector<double> bVals;
327 bVals.reserve(nToys);
329 std::vector<double> sbVals;
330 sbVals.reserve(nToys);
332 RunToys(bVals,sbVals,nToys,usePriors);
351 std::cout <<
"HybridCalculatorOriginal: run " << nToys <<
" toy-MC experiments\n";
353 if (usePriors) std::cout <<
"marginalize nuisance parameters \n";
363 std::vector<double> parameterValues;
367 if (usePriors && nParameters>0) {
369 parameterValues.resize(nParameters);
370 for (
int iParameter=0; iParameter<nParameters; iParameter++) {
372 parameterValues[iParameter] = oneParam->
getVal();
383 if (sbparams) originalSbParams.
addClone(*sbparams);
384 if (bparams) originalBParams.
addClone(*bparams);
392 for (
unsigned int iToy=0; iToy<nToys; iToy++) {
397 std::cout <<
"....... toy number " << iToy <<
" / " << nToys << std::endl;
401 if (usePriors && nParameters>0) {
404 for (
int iParameter=0; iParameter<nParameters; iParameter++) {
422 bool bIsEmpty =
false;
441 bool sbIsEmpty =
false;
451 if (usePriors && nParameters>0) {
452 for (
int iParameter=0; iParameter<nParameters; iParameter++) {
454 oneParam->
setVal(parameterValues[iParameter]);
459 for (
int hypoTested=0; hypoTested<=1; hypoTested++) {
461 bool dataIsEmpty = sbIsEmpty;
462 if ( hypoTested==1 ) { dataToTest = bData; dataIsEmpty = bIsEmpty; }
466 if ( !dataIsEmpty ) nEvents = dataToTest->
numEntries();
467 if ( hypoTested==0 ) sbVals.push_back(nEvents);
468 else bVals.push_back(nEvents);
473 double sb_nll_val = sb_nll.
getVal();
476 double b_nll_val = b_nll.
getVal();
477 double m2lnQ = -2*(b_nll_val-sb_nll_val);
478 if ( hypoTested==0 ) sbVals.push_back(m2lnQ);
479 else bVals.push_back(m2lnQ);
483 double sb_nll_val = sb_nll.
getVal();
486 double b_nll_val = b_nll.
getVal();
487 double m2lnQ = -2*(b_nll_val-sb_nll_val);
488 if ( hypoTested==0 ) sbVals.push_back(m2lnQ);
489 else bVals.push_back(m2lnQ);
496 if ( hypoTested==0 ) sbVals.push_back(m2lnQ);
497 else bVals.push_back(m2lnQ);
502 if ( hypoTested==0 ) sbVals.push_back(m2lnQ);
503 else bVals.push_back(m2lnQ);
517 *sbparams = originalSbParams;
523 *bparams = originalBParams;
534 if (usePriors && nParameters>0) {
535 for (
int iParameter=0; iParameter<nParameters; iParameter++) {
537 oneParam->
setVal(parameterValues[iParameter]);
551 std::cout <<
"Signal plus background model:\n";
556 std::cout <<
"\nBackground model:\n";
561 std::cout <<
"\nObservables:\n";
566 std::cout <<
"\nParameters being integrated:\n";
571 std::cout <<
"\nPrior PDF model for integration:\n";
588 std::cerr <<
"Error in HybridCalculatorOriginal::GetHypoTest - invalid data type - return NULL" << std::endl;
598 std::cerr <<
"Error in HybridCalculatorOriginal - data have not been set" << std::endl;
605 std::cerr <<
"Error in HybridCalculatorOriginal - no observables" << std::endl;
610 std::cerr <<
"Error in HybridCalculatorOriginal - S+B pdf has not been set " << std::endl;
615 std::cerr <<
"Error in HybridCalculatorOriginal - B pdf has not been set" << std::endl;
619 std::cerr <<
"Error in HybridCalculatorOriginal - nuisance parameters have not been set " << std::endl;
623 std::cerr <<
"Error in HybridCalculatorOriginal - prior pdf has not been set " << std::endl;
virtual void Print(Option_t *options=0) const
Print the object to the defaultPrintStream().
RooArgSet * getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Double_t getRealValue(const char *name, Double_t defVal=0, Bool_t verbose=kFALSE) const
Get value of a RooAbsReal stored in set with given name.
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
virtual Double_t sumEntries() const =0
Return effective number of entries in dataset, i.e., sum all weights.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
virtual RooDataHist * generateBinned(const RooArgSet &whatVars, Double_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()) const
As RooAbsPdf::generateBinned(const RooArgSet&, const RooCmdArg&,const RooCmdArg&, const RooCmdArg&,...
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&,...
virtual RooFitResult * fitTo(RooAbsData &data, 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(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
Fit PDF to given dataset.
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE) override
Add clone of specified element to an owning set.
The RooDataHist is a container class to hold N-dimensional binned data.
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'.
Class RooNLLVar implements a -log(likelihood) calculation from a dataset and a PDF.
RooRealVar represents a variable that can be changed from the outside.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
HybridCalculatorOriginal class.
void PrintMore(const char *options) const
Print out some information about the input models.
virtual void SetAlternateModel(const ModelConfig &)
Set the model describing the alternate hypothesis.
virtual ~HybridCalculatorOriginal()
Destructor of HybridCalculator.
virtual HybridResult * GetHypoTest() const
inherited methods from HypoTestCalculator interface
void RunToys(std::vector< double > &bVals, std::vector< double > &sbVals, unsigned int nToys, bool usePriors) const
do the actual run-MC processing
virtual void SetNullModel(const ModelConfig &)
Set the model describing the null hypothesis.
unsigned int fTestStatisticsIdx
HybridCalculatorOriginal(const char *name=0)
Dummy Constructor with only name.
void UseNuisance(bool on=true)
void SetTestStatistic(int index)
set the desired test statistics: index=1 : 2 * log( L_sb / L_b ) (DEFAULT) index=2 : number of genera...
const RooArgSet * fNuisanceParameters
HybridResult * Calculate(TH1 &data, unsigned int nToys, bool usePriors) const
first compute the test statistics for data and then prepare and run the toy-MC experiments
bool DoCheckInputs() const
RooArgList * fObservables
void SetNumberOfToys(unsigned int ntoys)
Class encapsulating the result of the HybridCalculatorOriginal.
void SetDataTestStatistics(double testStat_data_val)
set the value of the test statistics on data
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
RooAbsPdf * GetPriorPdf() const
get parameters prior pdf (return NULL if not existing)
TH1 is the base class of all histogram classes in ROOT.
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetName() const
Returns name of object.
RooCmdArg Strategy(Int_t code)
RooCmdArg Extended(Bool_t flag=kTRUE)
RooCmdArg Hesse(Bool_t flag=kTRUE)
RooCmdArg CloneData(Bool_t flag)
RooCmdArg PrintLevel(Int_t code)
Namespace for the RooStats classes.