Logo ROOT   6.08/07
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 USEMEMPOOL
25 
26 class RooArgSet : public RooAbsCollection {
27 public:
28 
29 #ifdef USEMEMPOOL
30  void* operator new (size_t bytes);
31  void* operator new (size_t bytes, void* ptr) noexcept;
32  void operator delete (void *ptr);
33 #endif
34 
35  // Constructors, assignment etc.
36  RooArgSet();
37  RooArgSet(const RooArgList& list) ;
38  RooArgSet(const RooArgList& list, const RooAbsArg* var1) ;
39  explicit RooArgSet(const TCollection& tcoll, const char* name="") ;
40  explicit RooArgSet(const char *name);
41  RooArgSet(const RooArgSet& set1, const RooArgSet& set2,
42  const char *name="");
43  RooArgSet(const RooAbsArg& var1,
44  const char *name="");
45  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
46  const char *name="");
47  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
48  const RooAbsArg& var3,
49  const char *name="");
50  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
51  const RooAbsArg& var3, const RooAbsArg& var4,
52  const char *name="");
53  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
54  const RooAbsArg& var3, const RooAbsArg& var4,
55  const RooAbsArg& var5,
56  const char *name="");
57  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
58  const RooAbsArg& var3, const RooAbsArg& var4,
59  const RooAbsArg& var5, const RooAbsArg& var6,
60  const char *name="");
61  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
62  const RooAbsArg& var3, const RooAbsArg& var4,
63  const RooAbsArg& var5, const RooAbsArg& var6,
64  const RooAbsArg& var7,
65  const char *name="");
66  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
67  const RooAbsArg& var3, const RooAbsArg& var4,
68  const RooAbsArg& var5, const RooAbsArg& var6,
69  const RooAbsArg& var7, const RooAbsArg& var8,
70  const char *name="");
71  RooArgSet(const RooAbsArg& var1, const RooAbsArg& var2,
72  const RooAbsArg& var3, const RooAbsArg& var4,
73  const RooAbsArg& var5, const RooAbsArg& var6,
74  const RooAbsArg& var7, const RooAbsArg& var8,
75  const RooAbsArg& var9, const char *name="");
76 
77  virtual ~RooArgSet();
78  // Create a copy of an existing list. New variables cannot be added
79  // to a copied list. The variables in the copied list are independent
80  // of the original variables.
81  RooArgSet(const RooArgSet& other, const char *name="");
82  virtual TObject* clone(const char* newname) const { return new RooArgSet(*this,newname); }
83  virtual TObject* create(const char* newname) const { return new RooArgSet(newname); }
84  RooArgSet& operator=(const RooArgSet& other) { RooAbsCollection::operator=(other) ; return *this ;}
85 
86  virtual Bool_t add(const RooAbsCollection& col, Bool_t silent=kFALSE) {
87  // Add all elements in list to collection
88  return RooAbsCollection::add(col, silent);
89  }
90  virtual Bool_t addOwned(const RooAbsCollection& col, Bool_t silent=kFALSE) {
91  // Add all elements in list as owned components to collection
92  return RooAbsCollection::addOwned(col, silent);
93  }
94  virtual void addClone(const RooAbsCollection& col, Bool_t silent=kFALSE) {
95  // Add owned clone of all elements of list to collection
96  RooAbsCollection::addClone(col, silent);
97  }
98 
99  virtual Bool_t add(const RooAbsArg& var, Bool_t silent=kFALSE) ;
100  virtual Bool_t addOwned(RooAbsArg& var, Bool_t silent=kFALSE);
101  virtual RooAbsArg *addClone(const RooAbsArg& var, Bool_t silent=kFALSE) ;
102 
103  RooAbsArg& operator[](const char* name) const ;
104 
105  virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) {
106  // I/O streaming interface (machine readable)
107  return readFromStream(is, compact, 0, 0, verbose) ;
108  }
109  Bool_t readFromStream(std::istream& is, Bool_t compact, const char* flagReadAtt, const char* section, Bool_t verbose=kFALSE) ;
110  virtual void writeToStream(std::ostream& os, Bool_t compact, const char* section=0) const;
111  void writeToFile(const char* fileName) const ;
112  Bool_t readFromFile(const char* fileName, const char* flagReadAtt=0, const char* section=0, Bool_t verbose=kFALSE) ;
113 
114  // Utilities functions when used as configuration object
115  Double_t getRealValue(const char* name, Double_t defVal=0, Bool_t verbose=kFALSE) const ;
116  const char* getCatLabel(const char* name, const char* defVal="", Bool_t verbose=kFALSE) const ;
117  Int_t getCatIndex(const char* name, Int_t defVal=0, Bool_t verbose=kFALSE) const ;
118  const char* getStringValue(const char* name, const char* defVal="", Bool_t verbose=kFALSE) const ;
119  Bool_t setRealValue(const char* name, Double_t newVal=0, Bool_t verbose=kFALSE) ;
120  Bool_t setCatLabel(const char* name, const char* newVal="", Bool_t verbose=kFALSE) ;
121  Bool_t setCatIndex(const char* name, Int_t newVal=0, Bool_t verbose=kFALSE) ;
122  Bool_t setStringValue(const char* name, const char* newVal="", Bool_t verbose=kFALSE) ;
123 
124  static void cleanup() ;
125 
126  Bool_t isInRange(const char* rangeSpec) ;
127 
128 protected:
129 
130  Bool_t checkForDup(const RooAbsArg& arg, Bool_t silent) const ;
131 
132  static char* _poolBegin ; //! Start of memory pool
133  static char* _poolCur ; //! Next free slot in memory pool
134  static char* _poolEnd ; //! End of memory pool
135 
136  ClassDef(RooArgSet,1) // Set of RooAbsArg objects
137 };
138 
139 #endif
RooArgSet & operator=(const RooArgSet &other)
Definition: RooArgSet.h:84
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:613
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
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:86
const char * getStringValue(const char *name, const char *defVal="", Bool_t verbose=kFALSE) const
Get string value of a RooAbsString stored in set with given name.
Definition: RooArgSet.cxx:656
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:548
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add a clone of the specified argument to list.
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
RooAbsArg & operator[](const char *name) const
Array operator.
Definition: RooArgSet.cxx:489
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Bool_t checkForDup(const RooAbsArg &arg, Bool_t silent) const
Check if element with var's name is already in set.
Definition: RooArgSet.cxx:504
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:737
Bool_t isInRange(const char *rangeSpec)
Definition: RooArgSet.cxx:1005
#define ClassDef(name, id)
Definition: Rtypes.h:254
static char * _poolEnd
Next free slot in memory pool.
Definition: RooArgSet.h:134
virtual TObject * clone(const char *newname) const
Definition: RooArgSet.h:82
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:94
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Definition: RooArgSet.h:105
void writeToFile(const char *fileName) const
Write contents of the argset to specified file.
Definition: RooArgSet.cxx:699
Collection abstract base class.
Definition: TCollection.h:48
bool verbose
virtual TObject * create(const char *newname) const
Definition: RooArgSet.h:83
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:90
static char * _poolCur
Start of memory pool.
Definition: RooArgSet.h:133
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:715
double Double_t
Definition: RtypesCore.h:55
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:677
static void cleanup()
Clear memoery pool on exit to avoid reported memory leaks.
Definition: RooArgSet.cxx:83
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:634
Mother of all ROOT objects.
Definition: TObject.h:37
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects...
static char * _poolBegin
Definition: RooArgSet.h:132
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:570
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:591
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:527
RooArgSet()
Default constructor.
Definition: RooArgSet.cxx:199
RooAbsCollection & operator=(const RooAbsCollection &other)
The assignment operator sets the value of any argument in our set that also appears in the other set...
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
virtual ~RooArgSet()
Destructor.
Definition: RooArgSet.cxx:435
char name[80]
Definition: TGX11.cxx:109