ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
89  virtual Bool_t add(const RooAbsArg& var, Bool_t silent=kFALSE) ;
90  virtual Bool_t addOwned(RooAbsArg& var, Bool_t silent=kFALSE);
91  virtual RooAbsArg *addClone(const RooAbsArg& var, Bool_t silent=kFALSE) ;
92 
93  RooAbsArg& operator[](const char* name) const ;
94 
95  virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) {
96  // I/O streaming interface (machine readable)
97  return readFromStream(is, compact, 0, 0, verbose) ;
98  }
99  Bool_t readFromStream(std::istream& is, Bool_t compact, const char* flagReadAtt, const char* section, Bool_t verbose=kFALSE) ;
100  virtual void writeToStream(std::ostream& os, Bool_t compact, const char* section=0) const;
101  void writeToFile(const char* fileName) const ;
102  Bool_t readFromFile(const char* fileName, const char* flagReadAtt=0, const char* section=0, Bool_t verbose=kFALSE) ;
103 
104  // Utilities functions when used as configuration object
105  Double_t getRealValue(const char* name, Double_t defVal=0, Bool_t verbose=kFALSE) const ;
106  const char* getCatLabel(const char* name, const char* defVal="", Bool_t verbose=kFALSE) const ;
107  Int_t getCatIndex(const char* name, Int_t defVal=0, Bool_t verbose=kFALSE) const ;
108  const char* getStringValue(const char* name, const char* defVal="", Bool_t verbose=kFALSE) const ;
109  Bool_t setRealValue(const char* name, Double_t newVal=0, Bool_t verbose=kFALSE) ;
110  Bool_t setCatLabel(const char* name, const char* newVal="", Bool_t verbose=kFALSE) ;
111  Bool_t setCatIndex(const char* name, Int_t newVal=0, Bool_t verbose=kFALSE) ;
112  Bool_t setStringValue(const char* name, const char* newVal="", Bool_t verbose=kFALSE) ;
113 
114  static void cleanup() ;
115 
116  Bool_t isInRange(const char* rangeSpec) ;
117 
118 protected:
119 
120  Bool_t checkForDup(const RooAbsArg& arg, Bool_t silent) const ;
121 
122  static char* _poolBegin ; //! Start of memory pool
123  static char* _poolCur ; //! Next free slot in memory pool
124  static char* _poolEnd ; //! End of memory pool
125 
126  ClassDef(RooArgSet,1) // Set of RooAbsArg objects
127 };
128 
129 #endif
RooArgSet & operator=(const RooArgSet &other)
Definition: RooArgSet.h:84
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
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 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.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
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 isInRange(const char *rangeSpec)
Definition: RooArgSet.cxx:1005
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add element to an owning set.
Definition: RooArgSet.cxx:461
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
static char * _poolEnd
Next free slot in memory pool.
Definition: RooArgSet.h:124
void writeToFile(const char *fileName) const
Write contents of the argset to specified file.
Definition: RooArgSet.cxx:699
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Definition: RooArgSet.h:95
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
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
Collection abstract base class.
Definition: TCollection.h:48
RooAbsArg & operator[](const char *name) const
Array operator.
Definition: RooArgSet.cxx:489
bool verbose
static char * _poolCur
Start of memory pool.
Definition: RooArgSet.h:123
virtual TObject * create(const char *newname) const
Definition: RooArgSet.h:83
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
virtual TObject * clone(const char *newname) const
Definition: RooArgSet.h:82
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
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects...
static char * _poolBegin
Definition: RooArgSet.h:122
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
virtual RooAbsArg * addClone(const RooAbsArg &var, Bool_t silent=kFALSE)
Add clone of specified element to an owning set.
Definition: RooArgSet.cxx:475
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
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add element to non-owning set.
Definition: RooArgSet.cxx:448
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