Logo ROOT   6.16/01
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
21class RooArgList ;
22
23
24#define USEMEMPOOLFORARGSET
25template <class RooSet_t, size_t>
27
29public:
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 RooAbsArg& operator[](const char* name) const ;
106
107 /// Shortcut for readFromStream(std::istream&, Bool_t, const char*, const char*, Bool_t), setting
108 /// `flagReadAtt` and `section` to 0.
109 virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) {
110 // I/O streaming interface (machine readable)
111 return readFromStream(is, compact, 0, 0, verbose) ;
112 }
113 Bool_t readFromStream(std::istream& is, Bool_t compact, const char* flagReadAtt, const char* section, Bool_t verbose=kFALSE) ;
114 virtual void writeToStream(std::ostream& os, Bool_t compact, const char* section=0) const;
115 void writeToFile(const char* fileName) const ;
116 Bool_t readFromFile(const char* fileName, const char* flagReadAtt=0, const char* section=0, Bool_t verbose=kFALSE) ;
117
118 // Utilities functions when used as configuration object
119 Double_t getRealValue(const char* name, Double_t defVal=0, Bool_t verbose=kFALSE) const ;
120 const char* getCatLabel(const char* name, const char* defVal="", Bool_t verbose=kFALSE) const ;
121 Int_t getCatIndex(const char* name, Int_t defVal=0, Bool_t verbose=kFALSE) const ;
122 const char* getStringValue(const char* name, const char* defVal="", Bool_t verbose=kFALSE) const ;
123 Bool_t setRealValue(const char* name, Double_t newVal=0, Bool_t verbose=kFALSE) ;
124 Bool_t setCatLabel(const char* name, const char* newVal="", Bool_t verbose=kFALSE) ;
125 Bool_t setCatIndex(const char* name, Int_t newVal=0, Bool_t verbose=kFALSE) ;
126 Bool_t setStringValue(const char* name, const char* newVal="", Bool_t verbose=kFALSE) ;
127
128 static void cleanup() ;
129
130 Bool_t isInRange(const char* rangeSpec) ;
131
132protected:
133
134 Bool_t checkForDup(const RooAbsArg& arg, Bool_t silent) const ;
135
136#ifdef USEMEMPOOLFORARGSET
137private:
138 typedef MemPoolForRooSets<RooArgSet, 10*600> MemPool; //600 = about 100 kb
139 //Initialise a static mem pool. It has to happen inside a function to solve the
140 //static initialisation order fiasco. At the end of the program, this might have
141 //to leak depending if RooArgSets are still alive. This depends on the order of destructions.
142 static MemPool* memPool();
143#endif
144
145 ClassDef(RooArgSet,1) // Set of RooAbsArg objects
146};
147
148#endif
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
#define ClassDef(name, id)
Definition: Rtypes.h:324
Memory pool for RooArgSet and RooDataSet.
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.
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 Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
RooAbsCollection & operator=(const RooAbsCollection &other)
The assignment operator sets the value of any argument in our set that also appears in the other set.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
RooArgSet & operator=(const RooArgSet &other)
Definition: RooArgSet.h:86
RooAbsArg & operator[](const char *name) const
Array operator.
Definition: RooArgSet.cxx:434
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:558
RooArgSet()
Default constructor.
Definition: RooArgSet.cxx:144
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:109
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:515
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
virtual ~RooArgSet()
Destructor.
Definition: RooArgSet.cxx:380
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:660
Bool_t isInRange(const char *rangeSpec)
Definition: RooArgSet.cxx:959
void writeToFile(const char *fileName) const
Write contents of the argset to specified file.
Definition: RooArgSet.cxx:644
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:579
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:472
static MemPool * memPool()
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:686
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:601
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:536
MemPoolForRooSets< RooArgSet, 10 *600 > MemPool
Definition: RooArgSet.h:138
virtual TObject * clone(const char *newname) const
Definition: RooArgSet.h:84
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:493
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
static void cleanup()
Definition: RooArgSet.cxx:71
virtual TObject * create(const char *newname) const
Definition: RooArgSet.h:85
Bool_t checkForDup(const RooAbsArg &arg, Bool_t silent) const
Check if element with var's name is already in set.
Definition: RooArgSet.cxx:449
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:622
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
Collection abstract base class.
Definition: TCollection.h:63
Mother of all ROOT objects.
Definition: TObject.h:37