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
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
120
121 static void cleanup() ;
122
123 Bool_t isInRange(const char* rangeSpec) ;
124
125 /// Use RooAbsCollection::snapshot(), but return as RooArgSet.
126 RooArgSet * snapshot(bool deepCopy = true) const {
127 return static_cast<RooArgSet*>(RooAbsCollection::snapshot(deepCopy));
128 }
129
130 /// \copydoc RooAbsCollection::snapshot()
132 return RooAbsCollection::snapshot(output, deepCopy);
133 }
134
135protected:
136
137 Bool_t checkForDup(const RooAbsArg& arg, Bool_t silent) const ;
138
139#ifdef USEMEMPOOLFORARGSET
140private:
141 typedef MemPoolForRooSets<RooArgSet, 10*600> MemPool; //600 = about 100 kb
142 //Initialise a static mem pool. It has to happen inside a function to solve the
143 //static initialisation order fiasco. At the end of the program, this might have
144 //to leak depending if RooArgSets are still alive. This depends on the order of destructions.
145 static MemPool* memPool();
146#endif
147
148 ClassDef(RooArgSet,1) // Set of RooAbsArg objects
149};
150
151#endif
const Bool_t kFALSE
Definition: RtypesCore.h:90
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassDef(name, id)
Definition: Rtypes.h:322
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:73
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.
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
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition: RooArgSet.h:126
RooArgSet()
Default constructor.
Definition: RooArgSet.cxx:144
Bool_t snapshot(RooAbsCollection &output, Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents.
Definition: RooArgSet.h:131
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
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:492
Bool_t isInRange(const char *rangeSpec)
Definition: RooArgSet.cxx:790
void writeToFile(const char *fileName) const
Write contents of the argset to specified file.
Definition: RooArgSet.cxx:476
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:518
MemPoolForRooSets< RooArgSet, 10 *600 > MemPool
Definition: RooArgSet.h:141
virtual TObject * clone(const char *newname) const
Definition: RooArgSet.h:84
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
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