93 HybridCalculatorOriginal::HybridCalculatorOriginal(
const char *
name) :
98 fNuisanceParameters(0),
101 fGenerateBinned(false),
102 fUsePriorPdf(false), fTmpDoExtended(true)
197 fNuisanceParameters((sbModel.GetNuisanceParameters()) ? sbModel.GetNuisanceParameters() : bModel.GetNuisanceParameters()),
198 fPriorPdf((sbModel.GetPriorPdf()) ? sbModel.GetPriorPdf() : bModel.GetPriorPdf()),
259 TString dataHistName =
GetName(); dataHistName +=
"_roodatahist";
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);
336 TString
name =
"HybridResult_" + TString(
GetName() );
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();
380 if (fTestStatisticsIdx == 3) {
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; }
464 if ( fTestStatisticsIdx==2 ) {
466 if ( !dataIsEmpty ) nEvents = dataToTest->
numEntries();
467 if ( hypoTested==0 ) sbVals.push_back(nEvents);
468 else bVals.push_back(nEvents);
469 }
else if ( fTestStatisticsIdx==3 ) {
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);
491 }
else if ( fTestStatisticsIdx==1 ) {
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);
513 if (fTestStatisticsIdx == 3) {
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 Double_t sumEntries() const =0
virtual const char * GetName() const
Returns name of object.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
virtual const RooArgSet * get() const
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())
Generate a new dataset containing the specified variables with events sampled from our distribution...
RooCmdArg CloneData(Bool_t flag)
RooCmdArg PrintLevel(Int_t code)
Double_t getVal(const RooArgSet *set=0) const
RooCmdArg Strategy(Int_t code)
const RooArgSet * fNuisanceParameters
unsigned int fTestStatisticsIdx
HybridCalculatorOriginal class.
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 ...
RooCmdArg Extended(Bool_t flag=kTRUE)
void SetDataTestStatistics(double testStat_data_val)
set the value of the test statistics on data
void SetNumberOfToys(unsigned int ntoys)
RooDataSet is a container class to hold N-dimensional binned data.
The TNamed class is the base class for all named ROOT classes.
virtual HybridResult * GetHypoTest() const
inherited methods from HypoTestCalculator interface
virtual void SetAlternateModel(const ModelConfig &)
Set the model describing the alternate hypothesis.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
virtual void SetNullModel(const ModelConfig &)
Set the model describing the null hypothesis.
void RunToys(std::vector< double > &bVals, std::vector< double > &sbVals, unsigned int nToys, bool usePriors) const
do the actual run-MC processing
bool DoCheckInputs() const
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
HybridCalculatorOriginal(const char *name=0)
Dummy Constructor with only name.
RooRealVar represents a fundamental (non-derived) real valued object.
virtual void addClone(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
RooAbsPdf * GetPriorPdf() const
get parameters prior pdf (return NULL if not existing)
virtual void setVal(Double_t value)
Set value of variable to 'value'.
Class RooNLLVar implements a a -log(likelihood) calculation from a dataset and a PDF.
RooAbsArg * at(Int_t idx) const
void UseNuisance(bool on=true)
RooArgList * fObservables
RooAbsData is the common abstract base class for binned and unbinned datasets.
RooDataSet is a container class to hold unbinned data.
virtual const RooArgSet * get(Int_t index) const
Return RooArgSet with coordinates of event 'index'.
Namespace for the RooStats classes.
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
RooCmdArg Hesse(Bool_t flag=kTRUE)
RooArgSet * getParameters(const RooAbsData *data, Bool_t stripDisconnected=kTRUE) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
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.
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())
Generate a new dataset containing the specified variables with events sampled from our distribution...
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.
Class encapsulating the result of the HybridCalculatorOriginal.
void PrintMore(const char *options) const
Print out some information about the input models.
virtual Int_t numEntries() const
void SetTestStatistic(int index)
set the desired test statistics: index=1 : 2 * log( L_sb / L_b ) (DEFAULT) index=2 : number of genera...
virtual ~HybridCalculatorOriginal()
Destructor of HybridCalculator.