93HybridCalculatorOriginal::HybridCalculatorOriginal(
const char *
name) :
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),
259 auto dataHistName = std::string(
GetName()) +
"_roodatahist";
273 double testStatData = 0;
276 double nEvents =
data.sumEntries();
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";
317 result->SetDataTestStatistics(testStatData);
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;
423 if (bData==
nullptr) {
441 bool sbIsEmpty =
false;
442 if (sbData==
nullptr) {
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->
assign(originalSbParams);
523 bparams->
assign(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 nullptr" << 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;
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
void Print(Option_t *options=0) const override
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...
void Print(Option_t *options=0) const override
This method must be overridden when a class wants to print itself.
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
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...
double getRealValue(const char *name, double defVal=0, bool verbose=false) const
Get value of a RooAbsReal stored in set with given name.
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.
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.
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 RooDataHist * generateBinned(const RooArgSet &whatVars, double 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&,...
double 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.
The RooDataHist is a container class to hold N-dimensional binned data.
RooDataSet is a container class to hold unbinned data.
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.
void setVal(double value) override
Set value of variable to 'value'.
HybridCalculatorOriginal class.
void PrintMore(const char *options) const
Print out some information about the input models.
RooAbsPdf * fSbModel
The pdf of the signal+background model.
RooAbsPdf * fBModel
The pdf of the background model.
void RunToys(std::vector< double > &bVals, std::vector< double > &sbVals, unsigned int nToys, bool usePriors) const
do the actual run-MC processing
unsigned int fNToys
number of Toys MC
void SetNullModel(const ModelConfig &) override
set the model for the null hypothesis (only B)
unsigned int fTestStatisticsIdx
Index of the test statistics to use.
RooAbsData * fData
pointer to the data sets
void SetAlternateModel(const ModelConfig &) override
set the model for the alternate hypothesis (S+B)
bool fGenerateBinned
Flag to control binned generation.
HybridCalculatorOriginal(const char *name=0)
Dummy Constructor with only name.
void UseNuisance(bool on=true)
control use of the pdf for the nuisance parameter and marginalize them
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
Collection of the nuisance parameters in the model.
HybridResult * GetHypoTest() const override
inherited methods from HypoTestCalculator interface
RooAbsPdf * fPriorPdf
Prior PDF of the nuisance parameters.
~HybridCalculatorOriginal() override
Destructor of HybridCalculator.
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
Collection of the observables of the model.
void SetNumberOfToys(unsigned int ntoys)
set number of toy MC (Default is 1000)
bool fUsePriorPdf
use a prior for nuisance parameters
Class encapsulating the result of the HybridCalculatorOriginal.
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 nullptr if not existing)
RooAbsPdf * GetPdf() const
get model PDF (return nullptr if pdf has not been specified or does not exist)
RooAbsPdf * GetPriorPdf() const
get parameters prior pdf (return nullptr 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.
const char * GetName() const override
Returns name of object.
RooCmdArg Hesse(bool flag=true)
RooCmdArg Strategy(Int_t code)
RooCmdArg PrintLevel(Int_t code)
RooCmdArg CloneData(bool flag)
RooCmdArg Extended(bool flag=true)
Namespace for the RooStats classes.