16#ifndef ROO_TEMPLATE_PROXY
17#define ROO_TEMPLATE_PROXY
165 :
RooArgProxy(theName, desc,
owner, valueServer, shapeServer, proxyOwnsArg) { }
179 RooArgProxy(theName, desc,
owner, const_cast<typename std::remove_const<T>::
type&>(ref), valueServer, shapeServer, proxyOwnsArg) { }
195 if (
_arg && !
dynamic_cast<const T*
>(
_arg)) {
196 if (allowWrongTypes) {
197 coutE(InputArguments) <<
"Error trying to copy an argument from a proxy with an incompatible payload." << std::endl;
199 throw std::invalid_argument(
"Tried to construct a RooTemplateProxy with incompatible payload.");
209 return static_cast<T&
>(*_arg);
214 return static_cast<T*
>(
_arg);
220 operator typename T::value_type()
const {
229 if (std::string(
arg().
GetName()) != newRef.GetName()) {
242 template<
class U,
class... ConstructorArgs>
246 throw std::runtime_error(
"Error in RooTemplateProxy: emplaceOwnedArg<>() called on a proxy already owning an arg.");
248 auto ownedArg =
new U{std::forward<ConstructorArgs>(constructorArgs)...};
262 throw std::runtime_error(
"Error in RooTemplateProxy: putOwnedArg<>() called on a proxy already owning an arg.");
264 auto argPtr = ownedArg.get();
265 setArg(*ownedArg.release());
281 return arg().getCurrentLabel();
286 return arg().hasRange(rangeName);
290 const T&
arg()
const {
return static_cast<const T&
>(*_arg); }
295 lvptr(
static_cast<T*
>(
nullptr))->operator=(value);
300 static_assert(std::is_base_of<RooAbsCategory, T>::value,
"Strings can only be assigned to category proxies.");
306 double min(
const char* rname=0)
const {
return lvptr(
static_cast<const T*
>(
nullptr))->getMin(rname) ; }
308 double max(
const char* rname=0)
const {
return lvptr(
static_cast<const T*
>(
nullptr))->getMax(rname) ; }
310 bool hasMin(
const char* rname=0)
const {
return lvptr(
static_cast<const T*
>(
nullptr))->hasMin(rname) ; }
312 bool hasMax(
const char* rname=0)
const {
return lvptr(
static_cast<const T*
>(
nullptr))->hasMax(rname) ; }
319 using LValue_t =
typename std::conditional<std::is_base_of<RooAbsReal, T>::value,
340 R__SUGGEST_ALTERNATIVE(
"The template argument of RooTemplateProxy needs to derive from RooAbsRealLValue or RooAbsCategoryLValue to safely call this function.") {
351 R__SUGGEST_ALTERNATIVE(
"The template argument of RooTemplateProxy needs to derive from RooAbsRealLValue or RooAbsCategoryLValue to safely call this function.") {
#define R__SUGGEST_ALTERNATIVE(ALTERNATIVE)
#define ClassDef(name, id)
char * Form(const char *fmt,...)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
virtual value_type getCurrentIndex() const
Return index number of current state.
RooArgSet * _nset
! Normalization set to be used for evaluation of RooAbsPdf contents
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgProxy is the abstract interface for RooAbsArg proxy classes.
virtual Bool_t changePointer(const RooAbsCollection &newServerSet, Bool_t nameChange=kFALSE, Bool_t factoryInitMode=kFALSE)
Change proxied object to object of same name in given list.
RooAbsArg * owner() const
Returns the owner of this proxy.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
LValue_t * lvptr(RooAbsArg *)
Return l-value pointer to contents.
bool hasMax(const char *rname=0) const
Check if the range has a upper bound. This requires the payload to be RooAbsRealLValue or derived.
bool hasRange(const char *rangeName) const
Check if the stored object has a range with the given name.
RooTemplateProxy(const char *theName, const char *desc, RooAbsArg *owner, T &ref, Bool_t valueServer=true, Bool_t shapeServer=false, Bool_t proxyOwnsArg=false)
Constructor with owner and proxied object.
T & operator*() const
Return reference to the proxied object.
T::value_type retrieveValue(const RooAbsCategory &cat) const
Retrieve index state from a category.
RooTemplateProxy(const char *theName, RooAbsArg *owner, const RooTemplateProxy< U > &other, bool allowWrongTypes=false)
Copy from an existing proxy.
RooTemplateProxy< T > & operator=(typename T::value_type value)
Assign a new value to the object pointed to by the proxy.
double min(const char *rname=0) const
Query lower limit of range. This requires the payload to be RooAbsRealLValue or derived.
double max(const char *rname=0) const
Query upper limit of range. This requires the payload to be RooAbsRealLValue or derived.
U & putOwnedArg(std::unique_ptr< U > ownedArg)
Move a new object held and owned by proxy.
RooTemplateProxy< T > & operator=(const std::string &newState)
Set a category state using its state name. This function can only work for category-type proxies.
const LValue_t * lvptr(const RooAbsArg *) const
Return l-value pointer to contents.
const LValue_t * lvptr(const LValue_t *) const
Return l-value pointer to contents.
bool hasMin(const char *rname=0) const
Check if the range has a lower bound. This requires the payload to be RooAbsRealLValue or derived.
virtual TObject * Clone(const char *newName=0) const
Make a clone of an object using the Streamer facility.
const char * label() const
Get the label of the current category state. This function only makes sense for category proxies.
RooTemplateProxy(const char *theName, const char *desc, RooAbsArg *owner, Bool_t valueServer=true, Bool_t shapeServer=false, Bool_t proxyOwnsArg=false)
Constructor with owner.
T * operator->() const
Member access operator to proxied object.
LValue_t * lvptr(LValue_t *)
Return l-value pointer to contents.
T::value_type retrieveValue(const RooAbsReal &real) const
Retrieve value from a real-valued object.
bool setArg(T &newRef)
Change object held in proxy into newRef.
U & emplaceOwnedArg(ConstructorArgs &&... constructorArgs)
Create a new object held and owned by proxy.
const T & arg() const
Return reference to object held in proxy.
typename std::conditional< std::is_base_of< RooAbsReal, T >::value, RooAbsRealLValue, RooAbsCategoryLValue >::type LValue_t
Are we a real-valued proxy or a category proxy?
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.