16#ifndef ROO_ABS_COLLECTION
17#define ROO_ABS_COLLECTION
35#include <unordered_map>
42template <
typename T,
typename Range_t>
45 return ROOT::RangeStaticCast<T>(std::forward<Range_t>(coll));
50template <
typename T,
typename Range_t>
53 return ROOT::RangeDynCast<T>(std::forward<Range_t>(coll));
59struct HashAssistedFind;
117 virtual bool add(
const RooAbsArg& var,
bool silent=
false) ;
121#ifdef ROOFIT_MEMORY_SAFE_INTERFACES
125#ifdef ROOFIT_MEMORY_SAFE_INTERFACES
128 bool addOwned(std::unique_ptr<RooAbsArg> var,
bool silent=
false);
131 virtual bool remove(
const RooAbsArg& var,
bool silent=
false,
bool matchByNameOnly=
false) ;
134 template<
typename Iterator_t,
135 typename value_type =
typename std::remove_pointer<typename std::iterator_traits<Iterator_t>::value_type>,
136 typename = std::enable_if<std::is_convertible<const value_type*, const RooAbsArg*>::value> >
137 bool add(Iterator_t beginIt, Iterator_t endIt,
bool silent=
false) {
139 _list.reserve(
_list.size() + std::distance(beginIt, endIt));
140 for (
auto it = beginIt; it != endIt; ++it) {
156 template<
class forwardIt>
157 void remove(forwardIt rangeBegin, forwardIt rangeEnd,
bool silent =
false,
bool matchByNameOnly =
false) {
158 for (forwardIt it = rangeBegin; it != rangeEnd; ++it) {
159 static_assert(std::is_same<
160 typename std::iterator_traits<forwardIt>::value_type,
162 auto castedElm =
static_cast<RooAbsArg*
>(*it);
163 remove(*castedElm, silent, matchByNameOnly);
168 double getRealValue(
const char*
name,
double defVal=0.0,
bool verbose=
false)
const ;
169 const char*
getCatLabel(
const char*
name,
const char* defVal=
"",
bool verbose=
false)
const ;
171 const char*
getStringValue(
const char*
name,
const char* defVal=
"",
bool verbose=
false)
const ;
172 bool setRealValue(
const char*
name,
double newVal=0.0,
bool verbose=
false) ;
173 bool setCatLabel(
const char*
name,
const char* newVal=
"",
bool verbose=
false) ;
193 return find(var) !=
nullptr;
206 template<
typename Iterator_t,
207 typename value_type =
typename std::remove_pointer<typename std::iterator_traits<Iterator_t>::value_type>,
208 typename = std::enable_if<std::is_convertible<const value_type*, const RooAbsArg*>::value> >
209 bool overlaps(Iterator_t otherCollBegin, Iterator_t otherCollEnd)
const {
210 for (
auto it = otherCollBegin; it != otherCollEnd; ++it) {
248 return _list.begin();
255 Storage_t::const_reverse_iterator
rbegin()
const {
256 return _list.rbegin();
259 Storage_t::const_reverse_iterator
rend()
const {
263 Storage_t::size_type
size()
const {
268 return _list.empty();
272 _list.reserve(count);
288 return _list.empty() ? nullptr :
_list.front();
298 auto item = std::find(
_list.begin(),
_list.end(), arg);
299 return item !=
_list.end() ? item -
_list.begin() : -1;
316 void printName(std::ostream& os)
const override ;
317 void printTitle(std::ostream& os)
const override ;
319 void printValue(std::ostream& os)
const override ;
345 bool allInRange(
const char* rangeSpec)
const ;
352 void sort(
bool reverse =
false);
399 static_assert(!std::is_rvalue_reference<T&&>::value,
400 "A reference to a temporary RooAbsArg will be passed to a RooAbsCollection constructor! "
401 "This is not allowed, because the collection will not own the arguments. "
402 "Hence, the collection will contain dangling pointers when the temporary goes out of scope."
#define R__SUGGEST_ALTERNATIVE(ALTERNATIVE)
ROOT::RRangeCast< T, true, Range_t > dynamic_range_cast(Range_t &&coll)
ROOT::RRangeCast< T, false, Range_t > static_range_cast(Range_t &&coll)
#define ClassDefOverride(name, id)
static void indent(ostringstream &buf, int indent_level)
const Bool_t kIterForward
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Wraps any collection that can be used in range-based loops and applies static_cast<T> or dynamic_cast...
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
void remove(forwardIt rangeBegin, forwardIt rangeEnd, bool silent=false, bool matchByNameOnly=false)
RooAbsCollection * selectByAttrib(const char *name, bool value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
bool equals(const RooAbsCollection &otherColl) const
Check if this and other collection have identically-named contents.
void clearStructureTags()
RooFit::UniqueId< RooAbsCollection > const & uniqueId() const
Returns a unique ID that is different for every instantiated RooAbsCollection.
std::unique_ptr< HashAssistedFind > _hashAssistedFind
!
double getRealValue(const char *name, double defVal=0.0, bool verbose=false) const
Get value of a RooAbsReal stored in set with given name.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
void deleteList()
Delete contents of the list.
Int_t getCatIndex(const char *name, Int_t defVal=0, bool verbose=false) const
Get index value of a RooAbsCategory stored in set with given name.
std::vector< RooAbsArg * > Storage_t
TNamed * _typedStructureTag
! Typed structure tag
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
Storage_t const & get() const
Const access to the underlying stl container.
RooAbsCollection & assignValueOnly(const RooAbsCollection &other, bool forceIfSizeOne=false)
Sets the value of any argument in our set that also appears in the other set.
virtual TObject * create(const char *newname) const =0
Int_t defaultPrintContents(Option_t *opt) const override
Define default RooPrinable print options for given Print() flag string For inline printing only show ...
bool allInRange(const char *rangeSpec) const
Return true if all contained object report to have their value inside the specified range.
void assignFast(const RooAbsCollection &other, bool setValDirty=true) const
Functional equivalent of assign() but assumes this and other collection have same layout.
void sortTopologically()
Sort collection topologically: the servers of any RooAbsArg will be before that RooAbsArg in the coll...
const char * getStringValue(const char *name, const char *defVal="", bool verbose=false) const
Get string value of a RooStringVar stored in set with given name.
TNamed * typedStructureTag()
bool contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
virtual bool canBeAdded(const RooAbsArg &arg, bool silent) const =0
Determine whether it's possible to add a given RooAbsArg to the collection or not.
RooAbsCollection * snapshot(bool deepCopy=true) const
Take a snap shot of current collection contents.
RooAbsCollection()
Default constructor.
void printValue(std::ostream &os) const override
Print value of collection, i.e.
Int_t getSize() const
Return the number of elements in the collection.
Storage_t::const_reverse_iterator rend() const
~RooAbsCollection() override
Destructor.
bool setStringValue(const char *name, const char *newVal="", bool verbose=false)
Set string value of a RooStringVar stored in set with given name to newVal.
const char * GetName() const override
Returns name of object.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
void setAttribAll(const Text_t *name, bool value=true)
Set given attribute in each element of the collection by calling each elements setAttribute() functio...
bool overlaps(const RooAbsCollection &otherColl) const
Check if this and other collection have common entries.
void printLatex(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
Output content of collection as LaTex table.
Storage_t::const_reverse_iterator rbegin() const
TObject * FindObject(const TObject *obj) const override
Find object in the collection, Note: matching by object name, like the find() method.
void printTitle(std::ostream &os) const override
Return collection title.
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
RooFIter fwdIterator() const
One-time forward iterator.
bool overlaps(Iterator_t otherCollBegin, Iterator_t otherCollEnd) const
bool _allRRV
All contents are RRV.
bool addServerClonesToList(const RooAbsArg &var)
Add clones of servers of given argument to end of list.
RooLinkedListIter iterator(bool dir=kIterForward) const
TIterator-style iteration over contained elements.
const_iterator end() const
bool hasSameLayout(const RooAbsCollection &other) const
Check that all entries where the collections overlap have the same name.
void RecursiveRemove(TObject *obj) override
If one of the TObject we have a referenced to is deleted, remove the reference.
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...
Storage_t::size_type size() const
RooAbsArg * operator[](Storage_t::size_type i) const
RooAbsArg * first() const
static void assert_is_no_temporary(T &&)
virtual bool replace(const RooAbsArg &var1, const RooAbsArg &var2)
Replace var1 with var2 and return true for success.
bool add(const RooAbsCollection &list, bool silent=false)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
void reserve(Storage_t::size_type count)
bool setCatIndex(const char *name, Int_t newVal=0, bool verbose=false)
Set index value of a RooAbsCategoryLValue stored in set with given name to newVal.
void clear()
Clear contents. If the collection is owning, it will also delete the contents.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Implement multiline printing of collection, one line for each contained object showing the requested ...
bool setCatLabel(const char *name, const char *newVal="", bool verbose=false)
Set state name of a RooAbsCategoryLValue stored in set with given name to newVal.
virtual bool addOwned(RooAbsArg &var, bool silent=false)
Add an argument and transfer the ownership to the collection.
Storage_t _list
Actual object storage.
RooAbsCollection * selectByName(const char *nameList, bool verbose=false) const
Create a subset of the current collection, consisting only of those elements with names matching the ...
bool setRealValue(const char *name, double newVal=0.0, bool verbose=false)
Set value of a RooAbsRealLValye stored in set with given name to newVal No error messages are printed...
bool _ownCont
Flag to identify a list that owns its contents.
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
Int_t index(const RooAbsArg &arg) const
Returns index of given arg, or -1 if arg is not in the collection.
const_iterator begin() const
void printName(std::ostream &os) const override
Return collection name.
void sort(bool reverse=false)
Sort collection using std::sort and name comparison.
std::unique_ptr< LegacyIterator_t > makeLegacyIterator(bool forward=true) const
Factory for legacy iterators.
bool add(Iterator_t beginIt, Iterator_t endIt, bool silent=false)
std::size_t _sizeThresholdForMapSearch
!
void dump() const
Base contents dumper for debugging purposes.
const RooFit::UniqueId< RooAbsCollection > _uniqueId
bool selectCommon(const RooAbsCollection &refColl, RooAbsCollection &outColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
TObject * FindObject(const char *name) const override
Find object by name in the collection.
TNamed * _structureTag
! Structure tag
const char * getCatLabel(const char *name, const char *defVal="", bool verbose=false) const
Get state name of a RooAbsCategory stored in set with given name.
virtual bool containsInstance(const RooAbsArg &var) const
Check if this exact instance is in this collection.
void useHashMapForFind(bool flag) const
void setHashTableSize(Int_t number)
Set the size at which the collection will automatically start using an extra lookup table instead of ...
std::string contentsString() const
Return comma separated list of contained object names as STL string.
void printClassName(std::ostream &os) const override
Return collection class name.
void setName(const char *name)
RooAbsCollection & operator=(const RooAbsCollection &other)
Assign values from the elements in other to our elements.
Int_t getHashTableSize() const
Query the size at which the collection will automatically start using an extra lookup table instead o...
void makeTypedStructureTag()
virtual TObject * clone(const char *newname) const =0
void insert(RooAbsArg *)
Insert an element into the owned collections.
TIterator * createIterator(bool dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsArg * find(const char *name) const
Find object with given name in list.
Storage_t::const_iterator const_iterator
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
A wrapper around TIterator derivatives.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
RooPlotable is a 'mix-in' base class that define the standard RooFit plotting and printing methods.
virtual StyleOption defaultPrintStyle(Option_t *opt) const
static std::ostream & defaultPrintStream(std::ostream *os=nullptr)
Return a reference to the current default stream to use in Print().
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
TIterator and GenericRooFIter front end with STL back end.
Iterator abstract base class.
The TNamed class is the base class for all named ROOT classes.
Mother of all ROOT objects.
const char * Data() const
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
RooAbsArgPtrOrDouble(double x)
RooAbsArgPtrOrDouble(RooAbsArg &arg)
Helper for hash-map-assisted finding of elements by name.
A UniqueId can be added as a class member to enhance any class with a unique identifier for each inst...