14#if !defined(R__ALPHA) && !defined(R__SOLARIS) && !defined(R__ACC) && !defined(R__FBSD)
35 template<
class listT,
class stringT>
void getParameterNames(
const listT*
l,std::vector<stringT>& names){
40 while((obj = itr.next())){
41 names.push_back(obj->
GetName());
45 for(
const auto& p:names){
65 double sb2 = sigma_b*sigma_b;
70 double bpsb2 =
b + sb2;
73 double za2 = 2.*( (spb)* std::log( ( spb)*(bpsb2)/(b2+ spb*sb2) ) -
74 (b2/sb2) * std::log(1. + ( sb2 * s)/(
b * bpsb2) ) );
79 double za2 = 2.*( (s+
b) * std::log(1. + s/
b) -s );
80 return std::sqrt(za2);
96 if (
auto prod =
dynamic_cast<RooProdPdf *
>(&pdf)) {
98 for (
int i = 0,
n = list.
getSize(); i <
n; ++i) {
100 FactorizePdf(observables, *pdfi, obsTerms, constraints);
111 for (
int ic = 0, nc = cat->
numBins((
const char *)0); ic < nc; ++ic) {
115 if (catPdf != 0)
FactorizePdf(observables, *catPdf, obsTerms, constraints);
121 if (!constraints.
contains(pdf)) constraints.
add(pdf);
130 oocoutE((
TObject*)0,InputArguments) <<
"RooStatsUtils::FactorizePdf - invalid input model: missing observables" << endl;
141 if(constraints.
getSize() == 0) {
142 oocoutW((
TObject *)0, Eval) <<
"RooStatsUtils::MakeNuisancePdf - no constraints found on nuisance parameters in the input model" << endl;
151 oocoutE((
TObject*)0, InputArguments) <<
"RooStatsUtils::MakeNuisancePdf - invalid input model: missing pdf and/or observables" << endl;
159 if (
auto prod =
dynamic_cast<RooProdPdf *
>(&pdf)) {
163 for (
int i = 0,
n = list.
getSize(); i <
n; ++i) {
166 if(newPdfi != NULL) newList.
add(*newPdfi);
169 if(newList.
getSize() == 0)
return NULL;
180 auto uPdf =
dynamic_cast<RooAbsPdf *
>(*(iter++));
181 auto extended_term =
dynamic_cast<RooAbsReal *
>(*(iter++));
182 assert(uPdf !=
nullptr);
183 assert(extended_term !=
nullptr);
187 if(newUPdf == NULL)
return NULL;
193 assert(sim !=
nullptr);
197 for (
int ic = 0, nc = cat->
numBins((
const char *)NULL); ic < nc; ++ic) {
203 if (newPdf == NULL) {
delete cat;
return NULL; }
204 pdfList.
add(*newPdf);
220 if(!unconstrainedPdf) {
221 oocoutE((
TObject *)NULL, InputArguments) <<
"RooStats::MakeUnconstrainedPdf - invalid observable list passed (observables not found in original pdf) or invalid pdf passed (without observables)" << endl;
225 return unconstrainedPdf;
231 oocoutE((
TObject *)NULL, InputArguments) <<
"RooStatsUtils::MakeUnconstrainedPdf - invalid input model: missing pdf and/or observables" << endl;
244 BranchStore(
const vector <TString> ¶ms = vector <TString>(),
double _inval = -999.) :
fTree(0) {
246 for(
unsigned int i = 0;i<params.size();i++)
252 for(std::map<TString, Double_t>::iterator it =
fVarVals.begin();it!=
fVarVals.end();++it) {
261 for(std::map<TString, Double_t>::iterator it =
fVarVals.begin();it!=
fVarVals.end();++it) {
267 for(std::map<TString, Double_t>::iterator it =
fVarVals.begin();it!=
fVarVals.end();++it) {
303 for(
int entry = 0;entry<data.
numEntries();entry++) {
338 for (
int i = 0; i<
l.getSize(); ++i) {
354 bool copySnapshots,
const char *mcname,
355 const char *newmcname) {
360 for (
auto it : objects) {
366 throw std::runtime_error(
"unable to retrieve ModelConfig");
371 std::vector<TString> poilist;
372 std::vector<TString> nplist;
373 std::vector<TString> obslist;
374 std::vector<TString> globobslist;
398 for (
auto* snap : static_range_cast<RooArgSet const*>(oldWS->
getSnapshots())) {
407 for (
auto d : data) {
412 ::getArgs(newWS, poilist, poiset);
414 ::getArgs(newWS, nplist, npset);
416 ::getArgs(newWS, obslist, obsset);
418 ::getArgs(newWS, globobslist, globobsset);
#define NamespaceImp(name)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Bool_t dependsOn(const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
Test whether we depend on (ie, are served by) any object in the specified collection.
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
const RefCountList_t & servers() const
List of all servers of this object.
virtual TObject * clone(const char *newname=0) const =0
void SetName(const char *name)
Set the name of the TNamed.
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
virtual void setBin(Int_t ibin, const char *rangeName=0)
Set category to i-th fit bin, which is the i-th registered state.
virtual Int_t numBins(const char *rangeName=nullptr) const
Return the number of fit bins ( = number of types )
virtual const char * getCurrentLabel() const
Return label string of current state.
Bool_t contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
RooLinkedListIter iterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
TIterator * createIterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
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.
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'.
RooExtendPdf is a wrapper around an existing PDF that adds a parameteric extended likelihood term to ...
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
A wrapper around TIterator derivatives.
TObject * Next() override
RooProdPdf is an efficient implementation of a product of PDFs of the form.
RooRealVar represents a variable that can be changed from the outside.
Double_t getAsymErrorLo() const
Bool_t hasAsymError(Bool_t allowZero=kTRUE) const
Double_t getAsymErrorHi() const
virtual Double_t getValV(const RooArgSet *nset=0) const
Return value of variable.
Bool_t hasError(Bool_t allowZero=kTRUE) const
Double_t getError() const
Container_t::const_iterator begin() const
Iterator over contained objects.
Container_t::const_iterator end() const
End of contained objects.
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
void AssignToTTree(TTree &myTree)
BranchStore(const vector< TString > ¶ms=vector< TString >(), double _inval=-999.)
std::map< TString, Double_t > fVarVals
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
virtual void SetObservables(const RooArgSet &set)
Specify the observables.
const RooArgSet * GetGlobalObservables() const
get RooArgSet for global observables (return NULL if not existing)
virtual void SetParametersOfInterest(const RooArgSet &set)
Specify parameters of interest.
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return NULL if not existing)
virtual void SetGlobalObservables(const RooArgSet &set)
Specify the global observables.
const RooArgSet * GetObservables() const
get RooArgSet for observables (return NULL if not existing)
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
virtual void SetNuisanceParameters(const RooArgSet &set)
Specify the nuisance parameters (parameters that are not POI).
virtual void SetPdf(const RooAbsPdf &pdf)
Set the Pdf, add to the the workspace if not already there.
The RooWorkspace is a persistable container for RooFit projects.
std::list< RooAbsData * > allData() const
Return list of all dataset in the workspace.
Bool_t import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
std::list< TObject * > allGenericObjects() const
Return list of all generic objects in the workspace.
RooLinkedList const & getSnapshots() const
static void autoImportClassCode(Bool_t flag)
If flag is true, source code of classes not the the ROOT distribution is automatically imported if on...
Bool_t saveSnapshot(const char *name, const char *paramNames)
Save snapshot of values and attributes (including "Constant") of given parameters.
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name)
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
A TTree is a list of TBranches.
virtual void ResetAddress()
Reset the address of the branch.
Iterator abstract base class.
virtual TObject * Next()=0
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
A TTree represents a columnar dataset.
virtual Int_t Fill()
Fill all branches.
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
RooCmdArg RecycleConflictNodes(Bool_t flag=kTRUE)
Namespace for the RooStats classes.
Double_t AsimovSignificance(Double_t s, Double_t b, Double_t sigma_b=0.0)
Compute the Asimov Median significance for a Poisson process with s = expected number of signal event...
TTree * GetAsTTree(TString name, TString desc, const RooDataSet &data)
RooAbsPdf * MakeUnconstrainedPdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name=NULL)
void FillTree(TTree &myTree, const RooDataSet &data)
BranchStore * CreateBranchStore(const RooDataSet &data)
RooAbsPdf * StripConstraints(RooAbsPdf &pdf, const RooArgSet &observables)
RooAbsPdf * MakeNuisancePdf(RooAbsPdf &pdf, const RooArgSet &observables, const char *name)
void FactorizePdf(const RooArgSet &observables, RooAbsPdf &pdf, RooArgList &obsTerms, RooArgList &constraints)
RooStatsConfig & GetGlobalRooStatsConfig()
Retrieve the config object which can be used to set flags for things like offsetting the likelihood o...
void UseNLLOffset(bool on)
Use an offset in NLL calculations.
bool IsNLLOffset()
Test of RooStats should by default offset NLL calculations.
RooWorkspace * MakeCleanWorkspace(RooWorkspace *oldWS, const char *newName, bool copySnapshots, const char *mcname, const char *newmcname)
void PrintListContent(const RooArgList &l, std::ostream &os=std::cout)