Logo ROOT   6.18/05
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 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
139 return RooAbsCollection::snapshot(output, deepCopy);
140 }
141
142protected:
143
144 Bool_t checkForDup(const RooAbsArg& arg, Bool_t silent) const ;
145
146#ifdef USEMEMPOOLFORARGSET
147private:
148 typedef MemPoolForRooSets<RooArgSet, 10*600> MemPool; //600 = about 100 kb
149 //Initialise a static mem pool. It has to happen inside a function to solve the
150 //static initialisation order fiasco. At the end of the program, this might have
151 //to leak depending if RooArgSets are still alive. This depends on the order of destructions.
152 static MemPool* memPool();
153#endif
154
155 ClassDef(RooArgSet,1) // Set of RooAbsArg objects
156};
157
158#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
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:326
char name[80]
Definition: TGX11.cxx:109
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:70
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
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 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.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgList.h:21
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 * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:134
RooArgSet()
Default constructor.
Definition: RooArgSet.cxx:144
Bool_t snapshot(RooAbsCollection &output, Bool_t deepCopy=kTRUE) const
Definition: RooArgSet.h:138
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
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:955
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:148
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
static void output(int code)
Definition: gifencode.c:226