Logo ROOT   6.16/01
Reference Guide
RooAbsCollection.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooAbsCollection.h,v 1.26 2007/08/09 19:55:47 wouter Exp $
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16#ifndef ROO_ABS_COLLECTION
17#define ROO_ABS_COLLECTION
18
19#include "TString.h"
20#include "RooAbsArg.h"
21#include "RooPrintable.h"
22#include "RooLinkedList.h"
23#include "RooCmdArg.h"
24#include "RooLinkedListIter.h"
25#include <string>
26
27class RooAbsCollection : public TObject, public RooPrintable {
28public:
29
30 // Constructors, assignment etc.
32 RooAbsCollection(const char *name);
33 virtual TObject* clone(const char* newname) const = 0 ;
34 virtual TObject* create(const char* newname) const = 0 ;
35 virtual TObject* Clone(const char* newname=0) const {
36 return clone(newname?newname:GetName()) ;
37 }
38 virtual ~RooAbsCollection();
39
40 // Create a copy of an existing list. New variables cannot be added
41 // to a copied list. The variables in the copied list are independent
42 // of the original variables.
43 RooAbsCollection(const RooAbsCollection& other, const char *name="");
46 void assignFast(const RooAbsCollection& other, Bool_t setValDirty=kTRUE) ;
47
48 // Copy list and contents (and optionally 'deep' servers)
49 RooAbsCollection *snapshot(Bool_t deepCopy=kTRUE) const ;
51
52 // Hash table control
54 // Set size of internal hash table to i (should be a prime number)
56 }
58 // Return size of internal hash table
59 return _list.getHashTableSize() ;
60 }
61
62 // List content management
63 virtual Bool_t add(const RooAbsArg& var, Bool_t silent=kFALSE) ;
64 virtual Bool_t addOwned(RooAbsArg& var, Bool_t silent=kFALSE);
65 virtual RooAbsArg *addClone(const RooAbsArg& var, Bool_t silent=kFALSE) ;
66 virtual Bool_t replace(const RooAbsArg& var1, const RooAbsArg& var2) ;
67 virtual Bool_t remove(const RooAbsArg& var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE) ;
68 virtual void removeAll() ;
69
70 virtual Bool_t add(const RooAbsCollection& list, Bool_t silent=kFALSE) ;
71 virtual Bool_t addOwned(const RooAbsCollection& list, Bool_t silent=kFALSE);
72 virtual void addClone(const RooAbsCollection& list, Bool_t silent=kFALSE);
73 Bool_t replace(const RooAbsCollection &other);
74 Bool_t remove(const RooAbsCollection& list, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE) ;
75
76 // Group operations on AbsArgs
77 void setAttribAll(const Text_t* name, Bool_t value=kTRUE) ;
78
79 // List search methods
80 RooAbsArg *find(const char *name) const ;
81 RooAbsArg *find(const RooAbsArg&) const ;
82
83 Bool_t contains(const RooAbsArg& var) const {
84 // Returns true if object with same name as var is contained in this collection
85 return (0 == find(var)) ? kFALSE:kTRUE;
86 }
87 Bool_t containsInstance(const RooAbsArg& var) const {
88 // Returns true if var is contained in this collection
89 return (0 == _list.FindObject(&var)) ? kFALSE:kTRUE;
90 }
91 RooAbsCollection* selectByAttrib(const char* name, Bool_t value) const ;
92 RooAbsCollection* selectCommon(const RooAbsCollection& refColl) const ;
93 RooAbsCollection* selectByName(const char* nameList, Bool_t verbose=kFALSE) const ;
94 Bool_t equals(const RooAbsCollection& otherColl) const ;
95 Bool_t overlaps(const RooAbsCollection& otherColl) const ;
96
97 // export subset of THashList interface
99 // Create and return an iterator over the elements in this collection
100 return _list.MakeIterator(dir);
101 }
102
104 RooFIter fwdIterator() const { return RooFIter(&_list); }
105
106 inline Int_t getSize() const {
107 // Return the number of elements in the collection
108 return _list.GetSize();
109 }
110 inline RooAbsArg *first() const {
111 // Return the first element in this collection
112 return (RooAbsArg*)_list.First();
113 }
114
115 inline virtual void Print(Option_t *options= 0) const {
116 // Printing interface (human readable)
118 }
119 std::string contentsString() const ;
120
121
122 virtual void printName(std::ostream& os) const ;
123 virtual void printTitle(std::ostream& os) const ;
124 virtual void printClassName(std::ostream& os) const ;
125 virtual void printValue(std::ostream& os) const ;
126 virtual void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const ;
127
128 virtual Int_t defaultPrintContents(Option_t* opt) const ;
129
130 // Latex printing methods
131 void printLatex(const RooCmdArg& arg1=RooCmdArg(), const RooCmdArg& arg2=RooCmdArg(),
132 const RooCmdArg& arg3=RooCmdArg(), const RooCmdArg& arg4=RooCmdArg(),
133 const RooCmdArg& arg5=RooCmdArg(), const RooCmdArg& arg6=RooCmdArg(),
134 const RooCmdArg& arg7=RooCmdArg(), const RooCmdArg& arg8=RooCmdArg()) const ;
135 void printLatex(std::ostream& ofs, Int_t ncol, const char* option="NEYU", Int_t sigDigit=1,
136 const RooLinkedList& siblingLists=RooLinkedList(), const RooCmdArg* formatCmd=0) const ;
137
138 void setName(const char *name) {
139 // Set name of collection
140 _name= name;
141 }
142 const char* GetName() const {
143 // Return namer of collection
144 return _name.Data() ;
145 }
146 Bool_t isOwning() const {
147 // Does collection own contents?
148 return _ownCont ;
149 }
150
151 Bool_t allInRange(const char* rangeSpec) const ;
152
153 void dump() const ;
154
157
158 void sort(Bool_t ascend=kTRUE) { _list.Sort(ascend) ; }
159
160 virtual void RecursiveRemove(TObject *obj);
161
162protected:
163
164 friend class RooMultiCatIter ;
165
166 RooLinkedList _list ; // Actual object store
167
168 Bool_t _ownCont; // Flag to identify a list that owns its contents.
169 TString _name; // Our name.
170 Bool_t _allRRV ; // All contents are RRV
171
172 void safeDeleteList() ;
173
174 // Support for snapshot method
176
179
180 mutable TNamed* _structureTag ; //! Structure tag
181 mutable TNamed* _typedStructureTag ; //! Typed structure tag
182
184
185 void makeStructureTag() ;
186 void makeTypedStructureTag() ;
187
188private:
189
190 ClassDef(RooAbsCollection,2) // Collection of RooAbsArg objects
191};
192
193#endif
int Int_t
Definition: RtypesCore.h:41
char Text_t
Definition: RtypesCore.h:58
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:324
const Bool_t kIterForward
Definition: TCollection.h:40
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
void clearStructureTags()
Typed structure tag.
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
Bool_t containsInstance(const RooAbsArg &var) const
TNamed * _typedStructureTag
Structure tag.
RooAbsCollection * selectCommon(const RooAbsCollection &refColl) const
Create a subset of the current collection, consisting only of those elements that are contained as we...
virtual TObject * create(const char *newname) const =0
TNamed * typedStructureTag()
RooAbsCollection()
Default constructor.
RooAbsCollection & assignValueOnly(const RooAbsCollection &other, Bool_t oneSafe=kFALSE)
The assignment operator sets the value of any argument in our set that also appears in the other set.
virtual Bool_t replace(const RooAbsArg &var1, const RooAbsArg &var2)
Replace var1 with var2 and return kTRUE for success.
Int_t getSize() const
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.
Bool_t contains(const RooAbsArg &var) const
Bool_t addServerClonesToList(const RooAbsArg &var)
Add clones of servers of given argument to list.
virtual void printName(std::ostream &os) const
Return collection name.
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
virtual TObject * Clone(const char *newname=0) const
Make a clone of an object using the Streamer facility.
RooFIter fwdIterator() const
TNamed * structureTag()
void sort(Bool_t ascend=kTRUE)
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual ~RooAbsCollection()
Destructor.
RooAbsArg * first() const
void assignFast(const RooAbsCollection &other, Bool_t setValDirty=kTRUE)
Functional equivalent of operator=() but assumes this and other collection have same layout.
RooAbsCollection * selectByName(const char *nameList, Bool_t verbose=kFALSE) const
Create a subset of the current collection, consisting only of those elements with names matching the ...
Bool_t overlaps(const RooAbsCollection &otherColl) const
Check if this and other collection have common entries.
Bool_t allInRange(const char *rangeSpec) const
Return true if all contained object report to have their value inside the specified range.
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Implement multiline printin of collection, one line for each ontained object showing the requested co...
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
void setAttribAll(const Text_t *name, Bool_t value=kTRUE)
Set given attribute in each element of the collection by calling each elements setAttribute() functio...
void dump() const
Base contents dumper for debugging purposes.
RooLinkedList _list
Bool_t isOwning() const
virtual void printTitle(std::ostream &os) const
Return collection title.
Bool_t equals(const RooAbsCollection &otherColl) const
Check if this and other collection have identically named contents.
RooAbsCollection * selectByAttrib(const char *name, Bool_t value) const
Create a subset of the current collection, consisting only of those elements with the specified attri...
const char * GetName() const
Returns name of object.
virtual void printClassName(std::ostream &os) const
Return collection class name.
std::string contentsString() const
Return comma separated list of contained object names as STL string.
void setName(const char *name)
RooAbsCollection & operator=(const RooAbsCollection &other)
The assignment operator sets the value of any argument in our set that also appears in the other set.
void safeDeleteList()
Examine client server dependencies in list and delete contents in safe order: any client is deleted b...
Int_t getHashTableSize() const
RooLinkedListIter iterator(Bool_t dir=kIterForward) const
virtual void RecursiveRemove(TObject *obj)
If one of the TObject we have a referenced to is deleted, remove the reference.
virtual Bool_t remove(const RooAbsArg &var, Bool_t silent=kFALSE, Bool_t matchByNameOnly=kFALSE)
Remove the specified argument from our list.
virtual TObject * clone(const char *newname) const =0
void setHashTableSize(Int_t i)
TIterator * createIterator(Bool_t dir=kIterForward) const
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual void printValue(std::ostream &os) const
Print value of collection, i.e.
virtual Int_t defaultPrintContents(Option_t *opt) const
Define default RooPrinable print options for given Print() flag string For inline printing only show ...
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27
RooLinkedListIter is the TIterator implementation for RooLinkedList.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Definition: RooLinkedList.h:35
Int_t GetSize() const
Definition: RooLinkedList.h:60
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
TIterator * MakeIterator(Bool_t dir=kTRUE) const
Return an iterator over this list.
void Sort(Bool_t ascend=kTRUE)
Int_t getHashTableSize() const
Definition: RooLinkedList.h:50
void setHashTableSize(Int_t size)
Change the threshold for hash-table use to given size.
TObject * First() const
Definition: RooLinkedList.h:78
RooMultiCatIter iterators over all state permutations of a list of categories.
RooPlotable is a 'mix-in' base class that define the standard RooFit plotting and printing methods.
Definition: RooPrintable.h:25
virtual StyleOption defaultPrintStyle(Option_t *opt) const
static std::ostream & defaultPrintStream(std::ostream *os=0)
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,...
Iterator abstract base class.
Definition: TIterator.h:30
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364