Logo ROOT  
Reference Guide
RooArgSet.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooArgSet.h,v 1.45 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_ARG_SET
17 #define ROO_ARG_SET
18 
19 #include "RooAbsCollection.h"
20 
21 class RooArgList ;
22 
23 
24 #define USEMEMPOOLFORARGSET
25 template <class RooSet_t, size_t>
27 
28 class RooArgSet : public RooAbsCollection {
29 public:
30 
31 #ifdef USEMEMPOOLFORARGSET
32  void* operator new (size_t bytes);
33  void* operator new (size_t bytes, void* ptr) noexcept;
34  void operator delete (void *ptr);
35 #endif
36 
37  // Constructors, assignment etc.
38  RooArgSet();
39  RooArgSet(const RooArgList& list) ;
40  RooArgSet(const RooArgList& list, const RooAbsArg* var1) ;
41  explicit RooArgSet(const TCollection& tcoll, const char* name="") ;
42  explicit RooArgSet(const char *name);
43  RooArgSet(const RooArgSet& set1, const RooArgSet& set2,
44  const char *name="");
45  RooArgSet(const RooAbsArg& var1,
46  const char *name="");
47  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
48  const char *name="");
49  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
50  const RooAbsArg& var3,
51  const char *name="");
52  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
53  const RooAbsArg& var3, const RooAbsArg& var4,
54  const char *name="");
55  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
56  const RooAbsArg& var3, const RooAbsArg& var4,
57  const RooAbsArg& var5,
58  const char *name="");
59  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
60  const RooAbsArg& var3, const RooAbsArg& var4,
61  const RooAbsArg& var5, const RooAbsArg& var6,
62  const char *name="");
63  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
64  const RooAbsArg& var3, const RooAbsArg& var4,
65  const RooAbsArg& var5, const RooAbsArg& var6,
66  const RooAbsArg& var7,
67  const char *name="");
68  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
69  const RooAbsArg& var3, const RooAbsArg& var4,
70  const RooAbsArg& var5, const RooAbsArg& var6,
71  const RooAbsArg& var7, const RooAbsArg& var8,
72  const char *name="");
73  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
74  const RooAbsArg& var3, const RooAbsArg& var4,
75  const RooAbsArg& var5, const RooAbsArg& var6,
76  const RooAbsArg& var7, const RooAbsArg& var8,
77  const RooAbsArg& var9, const char *name="");
78 
79  virtual ~RooArgSet();
80  // Create a copy of an existing list. New variables cannot be added
81  // to a copied list. The variables in the copied list are independent
82  // of the original variables.
83  RooArgSet(const RooArgSet& other, const char *name="");
84  virtual TObject* clone(const char* newname) const { return new RooArgSet(*this,newname); }
85  virtual TObject* create(const char* newname) const { return new RooArgSet(newname); }
86  RooArgSet& operator=(const RooArgSet& other) { RooAbsCollection::operator=(other) ; return *this ;}
87 
88  virtual Bool_t add(const RooAbsCollection& col, Bool_t silent=kFALSE) {
89  // Add all elements in list to collection
90  return RooAbsCollection::add(col, silent);
91  }
92  virtual Bool_t addOwned(const RooAbsCollection& col, Bool_t silent=kFALSE) {
93  // Add all elements in list as owned components to collection
94  return RooAbsCollection::addOwned(col, silent);
95  }
96  virtual void addClone(const RooAbsCollection& col, Bool_t silent=kFALSE) {
97  // Add owned clone of all elements of list to collection
98  RooAbsCollection::addClone(col, silent);
99  }
100 
101  virtual Bool_t add(const RooAbsArg& var, Bool_t silent=kFALSE) ;
102  virtual Bool_t addOwned(RooAbsArg& var, Bool_t silent=kFALSE);
103  virtual RooAbsArg *addClone(const RooAbsArg& var, Bool_t silent=kFALSE) ;
104 
105  using RooAbsCollection::operator[];
106  RooAbsArg& operator[](const char* name) const;
107 
108  /// Shortcut for readFromStream(std::istream&, Bool_t, const char*, const char*, Bool_t), setting
109  /// `flagReadAtt` and `section` to 0.
110  virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) {
111  // I/O streaming interface (machine readable)
112  return readFromStream(is, compact, 0, 0, verbose) ;
113  }
114  Bool_t readFromStream(std::istream& is, Bool_t compact, const char* flagReadAtt, const char* section, Bool_t verbose=kFALSE) ;
115  virtual void writeToStream(std::ostream& os, Bool_t compact, const char* section=0) const;
116  void writeToFile(const char* fileName) const ;
117  Bool_t readFromFile(const char* fileName, const char* flagReadAtt=0, const char* section=0, Bool_t verbose=kFALSE) ;
118 
119  // Utilities functions when used as configuration object
120  Double_t getRealValue(const char* name, Double_t defVal=0, Bool_t verbose=kFALSE) const ;
121  const char* getCatLabel(const char* name, const char* defVal="", Bool_t verbose=kFALSE) const ;
122  Int_t getCatIndex(const char* name, Int_t defVal=0, Bool_t verbose=kFALSE) const ;
123  const char* getStringValue(const char* name, const char* defVal="", Bool_t verbose=kFALSE) const ;
124  Bool_t setRealValue(const char* name, Double_t newVal=0, Bool_t verbose=kFALSE) ;
125  Bool_t setCatLabel(const char* name, const char* newVal="", Bool_t verbose=kFALSE) ;
126  Bool_t setCatIndex(const char* name, Int_t newVal=0, Bool_t verbose=kFALSE) ;
127  Bool_t setStringValue(const char* name, const char* newVal="", Bool_t verbose=kFALSE) ;
128 
129  static void cleanup() ;
130 
131  Bool_t isInRange(const char* rangeSpec) ;
132 
133  /// Use RooAbsCollection::snapshot(), but return as RooArgSet.
134  RooArgSet * snapshot(bool deepCopy = true) const {
135  return static_cast<RooArgSet*>(RooAbsCollection::snapshot(deepCopy));
136  }
137 
138  /// \copydoc RooAbsCollection::snapshot()
140  return RooAbsCollection::snapshot(output, deepCopy);
141  }
142 
143 protected:
144 
145  Bool_t checkForDup(const RooAbsArg& arg, Bool_t silent) const ;
146 
147 #ifdef USEMEMPOOLFORARGSET
148 private:
149  typedef MemPoolForRooSets<RooArgSet, 10*600> MemPool; //600 = about 100 kb
150  //Initialise a static mem pool. It has to happen inside a function to solve the
151  //static initialisation order fiasco. At the end of the program, this might have
152  //to leak depending if RooArgSets are still alive. This depends on the order of destructions.
153  static MemPool* memPool();
154 #endif
155 
156  ClassDef(RooArgSet,1) // Set of RooAbsArg objects
157 };
158 
159 #endif
RooArgSet::MemPool
MemPoolForRooSets< RooArgSet, 10 *600 > MemPool
Definition: RooArgSet.h:149
RooArgSet::setRealValue
Bool_t setRealValue(const char *name, Double_t newVal=0, Bool_t verbose=kFALSE)
Set value of a RooAbsRealLValye stored in set with given name to newVal No error messages are printed...
Definition: RooArgSet.cxx:495
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooArgSet::writeToFile
void writeToFile(const char *fileName) const
Write contents of the argset to specified file.
Definition: RooArgSet.cxx:648
RooArgSet::getRealValue
Double_t getRealValue(const char *name, Double_t defVal=0, Bool_t verbose=kFALSE) const
Get value of a RooAbsReal stored in set with given name.
Definition: RooArgSet.cxx:474
RooArgSet::checkForDup
Bool_t checkForDup(const RooAbsArg &arg, Bool_t silent) const
Check if element with var's name is already in set.
Definition: RooArgSet.cxx:451
RooArgSet::isInRange
Bool_t isInRange(const char *rangeSpec)
Definition: RooArgSet.cxx:962
RooArgSet::RooArgSet
RooArgSet()
Default constructor.
Definition: RooArgSet.cxx:146
output
static void output(int code)
Definition: gifencode.c:226
RooArgList
Definition: RooArgList.h:21
RooArgSet::setStringValue
Bool_t setStringValue(const char *name, const char *newVal="", Bool_t verbose=kFALSE)
Set string value of a RooStringVar stored in set with given name to newVal.
Definition: RooArgSet.cxx:625
RooArgSet::operator=
RooArgSet & operator=(const RooArgSet &other)
Definition: RooArgSet.h:86
RooArgSet::setCatLabel
Bool_t setCatLabel(const char *name, const char *newVal="", Bool_t verbose=kFALSE)
Set state name of a RooAbsCategoryLValue stored in set with given name to newVal.
Definition: RooArgSet.cxx:538
RooArgSet::add
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
Definition: RooArgSet.h:88
RooArgSet::getCatLabel
const char * getCatLabel(const char *name, const char *defVal="", Bool_t verbose=kFALSE) const
Get state name of a RooAbsCategory stored in set with given name.
Definition: RooArgSet.cxx:517
RooAbsCollection::operator=
RooAbsCollection & operator=(const RooAbsCollection &other)
The assignment operator sets the value of any argument in our set that also appears in the other set.
Definition: RooAbsCollection.cxx:310
bool
RooArgSet::addOwned
virtual Bool_t addOwned(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
Definition: RooArgSet.h:92
RooArgSet::getCatIndex
Int_t getCatIndex(const char *name, Int_t defVal=0, Bool_t verbose=kFALSE) const
Get index value of a RooAbsCategory stored in set with given name.
Definition: RooArgSet.cxx:560
RooAbsCollection.h
RooArgSet::snapshot
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:134
RooArgSet::~RooArgSet
virtual ~RooArgSet()
Destructor.
Definition: RooArgSet.cxx:382
RooArgSet::operator[]
RooAbsArg & operator[](const char *name) const
Array operator.
Definition: RooArgSet.cxx:436
RooAbsCollection::addClone
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
Definition: RooAbsCollection.cxx:412
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooArgSet::memPool
static MemPool * memPool()
RooAbsCollection
Definition: RooAbsCollection.h:30
RooAbsCollection::add
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Definition: RooAbsCollection.cxx:437
RooArgSet::writeToStream
virtual void writeToStream(std::ostream &os, Bool_t compact, const char *section=0) const
Write the contents of the argset in ASCII form to given stream.
Definition: RooArgSet.cxx:690
RooAbsCollection::addOwned
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
Definition: RooAbsCollection.cxx:389
MemPoolForRooSets
Memory pool for RooArgSet and RooDataSet.
Definition: RooArgSet.h:26
RooArgSet::readFromStream
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Shortcut for readFromStream(std::istream&, Bool_t, const char*, const char*, Bool_t),...
Definition: RooArgSet.h:110
RooArgSet::clone
virtual TObject * clone(const char *newname) const
Definition: RooArgSet.h:84
RooArgSet::cleanup
static void cleanup()
Definition: RooArgSet.cxx:73
Double_t
double Double_t
Definition: RtypesCore.h:59
RooArgSet::snapshot
Bool_t snapshot(RooAbsCollection &output, Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents.
Definition: RooArgSet.h:139
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooArgSet::create
virtual TObject * create(const char *newname) const
Definition: RooArgSet.h:85
RooArgSet::readFromFile
Bool_t readFromFile(const char *fileName, const char *flagReadAtt=0, const char *section=0, Bool_t verbose=kFALSE)
Read contents of the argset from specified file.
Definition: RooArgSet.cxx:664
name
char name[80]
Definition: TGX11.cxx:110
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooAbsArg
Definition: RooAbsArg.h:73
TCollection
Definition: TCollection.h:63
RooArgSet::addClone
virtual void addClone(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling addOwned() for each element in the source...
Definition: RooArgSet.h:96
RooArgSet::getStringValue
const char * getStringValue(const char *name, const char *defVal="", Bool_t verbose=kFALSE) const
Get string value of a RooStringVar stored in set with given name.
Definition: RooArgSet.cxx:603
RooArgSet
Definition: RooArgSet.h:28
RooAbsCollection::snapshot
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents.
Definition: RooAbsCollection.cxx:201
int
RooArgSet::setCatIndex
Bool_t setCatIndex(const char *name, Int_t newVal=0, Bool_t verbose=kFALSE)
Set index value of a RooAbsCategoryLValue stored in set with given name to newVal.
Definition: RooArgSet.cxx:581