Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooMultiReal.cxx
Go to the documentation of this file.
1#include "RooMultiReal.h"
2#include "RooConstVar.h"
3
4// Constructor
5RooMultiReal::RooMultiReal(const char *name, const char *title, RooCategory &indexCat, const RooArgList &models)
6 : RooAbsReal(name, title),
7 _models("_models", "List of RooAbsReal models", this), // name, title, owner
8 _index("_index", "Index category", this, indexCat) // name, title, owner, reference to RooCategory
9
10{
12
13 RooCategory &cat = dynamic_cast<RooCategory &>(const_cast<RooAbsCategory &>(_index.arg()));
14
15 for (int i = 0; i < _models.getSize(); ++i) {
16 cat.defineType(("model" + std::to_string(i)).c_str(), i);
17 }
18}
19
20// Copy constructor
23 _models("_models", this, other._models), // name, owner, other list proxy
24 _index("_index", this, other._index) // name, owner, other category proxy
25
26{
27}
28
29// Evaluate: returns the value of the currently selected RooAbsReal model
31{
32 int currentIndex = static_cast<int>(_index);
34 // Defensive fallback: invalid index
35 return 0.0;
36 }
37
38 Double_t val = static_cast<RooAbsReal *>(_models.at(currentIndex))->getVal(_models.nset());
39
40 return val;
41}
42
43// Propagate parameter fetching to the current model
45{
47 return;
48
49 list->removeAll();
50
51 RooAbsReal *absReal = static_cast<RooAbsReal *>(_models.at(static_cast<int>(_index)));
52
53 if (absReal->isFundamental()) {
54 if (!nset || !absReal->dependsOn(*nset)) {
55 list->add(*absReal);
56 }
57 return;
58 }
59
60 absReal->getParameters(nset, *list, stripDisconnected);
61 list->add(*_index);
62}
char name[80]
Definition TGX11.cxx:110
A space to attach TBranches.
Int_t getSize() const
Return the number of elements in the collection.
const RooArgSet * nset() const
Definition RooAbsProxy.h:52
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:63
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:107
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
Definition RooArgList.h:110
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Object to represent discrete states.
Definition RooCategory.h:28
bool defineType(const std::string &label)
Define a state with given name.
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
RooCategoryProxy _index
RooMultiReal()=default
void getParametersHook(const RooArgSet *nset, RooArgSet *list, bool stripDisconnected) const override
RooListProxy _models
Double_t evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
const T & arg() const
Return reference to object held in proxy.