Logo ROOT   6.18/05
Reference Guide
RooCmdArg.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
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
17
18/**
19\file RooCmdArg.cxx
20\class RooCmdArg
21\ingroup Roofitcore
22
23RooCmdArg is a named container for two doubles, two integers
24two object points and three string pointers that can be passed
25as generic named arguments to a variety of RooFit end user
26methods. To achieved the named syntax, RooCmdArg objects are
27created using global helper functions defined in RooGlobalFunc.h
28that create and fill these generic containers
29**/
30
31#include "RooFit.h"
32
33#include "RooCmdArg.h"
34#include "RooCmdArg.h"
35#include "Riostream.h"
36#include "RooArgSet.h"
37#include <string>
38
39using namespace std;
40
42 ;
43
45
46
47////////////////////////////////////////////////////////////////////////////////
48/// Return reference to null argument
49
51{
52 return _none ;
53}
54
55
56////////////////////////////////////////////////////////////////////////////////
57/// Default constructor
58
60{
63 _c = 0 ;
64 _o[0] = 0 ;
65 _o[1] = 0 ;
66 _i[0] = 0 ;
67 _i[1] = 0 ;
68 _d[0] = 0 ;
69 _d[1] = 0 ;
70}
71
72
73////////////////////////////////////////////////////////////////////////////////
74/// Constructor with full specification of payload: two integers, two doubles,
75/// three string poiners, two object pointers and one RooCmdArg pointer
76
78 const char* s1, const char* s2, const TObject* o1, const TObject* o2,
79 const RooCmdArg* ca, const char* s3, const RooArgSet* c1, const RooArgSet* c2) :
81{
82 _i[0] = i1 ;
83 _i[1] = i2 ;
84 _d[0] = d1 ;
85 _d[1] = d2 ;
86 if (s1) _s[0] = s1 ;
87 if (s2) _s[1] = s2 ;
88 if (s3) _s[2] = s3 ;
89 _o[0] = (TObject*) o1 ;
90 _o[1] = (TObject*) o2 ;
91 _c = 0 ;
92
93 if (c1||c2) _c = new RooArgSet[2] ;
94 if (c1) _c[0].add(*c1) ;
95 if (c2) _c[1].add(*c2) ;
96
99 if (ca) {
100 _argList.Add(new RooCmdArg(*ca)) ;
101 }
102}
103
104
105
106////////////////////////////////////////////////////////////////////////////////
107/// Copy constructor
108
110 TNamed(other)
111{
112 _i[0] = other._i[0] ;
113 _i[1] = other._i[1] ;
114 _d[0] = other._d[0] ;
115 _d[1] = other._d[1] ;
116 _s[0] = other._s[0] ;
117 _s[1] = other._s[1] ;
118 _s[2] = other._s[2] ;
119 _o[0] = other._o[0] ;
120 _o[1] = other._o[1] ;
121 if (other._c) {
122 _c = new RooArgSet[2] ;
123 _c[0].add(other._c[0]) ;
124 _c[1].add(other._c[1]) ;
125 } else {
126 _c = 0 ;
127 }
128
129 _procSubArgs = other._procSubArgs ;
131 for (Int_t i=0 ; i<other._argList.GetSize() ; i++) {
132 _argList.Add(new RooCmdArg((RooCmdArg&)*other._argList.At(i))) ;
133 }
134}
135
136
137////////////////////////////////////////////////////////////////////////////////
138/// Assignment operator
139
141{
142 if (&other==this) return *this ;
143
144 SetName(other.GetName()) ;
145 SetTitle(other.GetTitle()) ;
146
147 _i[0] = other._i[0] ;
148 _i[1] = other._i[1] ;
149 _d[0] = other._d[0] ;
150 _d[1] = other._d[1] ;
151 _s[0] = other._s[0] ;
152 _s[1] = other._s[1] ;
153 _s[2] = other._s[2] ;
154 _o[0] = other._o[0] ;
155 _o[1] = other._o[1] ;
156 if (!_c) _c = new RooArgSet[2] ;
157 if (other._c) {
158 _c[0].removeAll() ; _c[0].add(other._c[0]) ;
159 _c[1].removeAll() ; _c[1].add(other._c[1]) ;
160 }
161
162 _procSubArgs = other._procSubArgs ;
164
165 for (Int_t i=0 ; i<other._argList.GetSize() ; i++) {
166 _argList.Add(new RooCmdArg((RooCmdArg&)*other._argList.At(i))) ;
167 }
168
169 return *this ;
170}
171
172
173
174////////////////////////////////////////////////////////////////////////////////
175/// Destructor
176
178{
179 _argList.Delete() ;
180 if (_c) delete[] _c ;
181}
182
183
184
185////////////////////////////////////////////////////////////////////////////////
186/// Utility function to add nested RooCmdArg to payload of this RooCmdArg
187
189{
190 _argList.Add(new RooCmdArg(arg)) ;
191}
192
193
194
195////////////////////////////////////////////////////////////////////////////////
196/// Return RooArgSet stored in slot idx
197
199 return _c ? &_c[idx] : 0 ;
200 }
201
202
203
204////////////////////////////////////////////////////////////////////////////////
205
206void RooCmdArg::setSet(Int_t idx,const RooArgSet& set)
207{
208 if (!_c) {
209 _c = new RooArgSet[2] ;
210 }
211 _c[idx].removeAll() ;
212 _c[idx].add(set) ;
213}
#define s1(x)
Definition: RSha256.hxx:91
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassImp(name)
Definition: Rtypes.h:365
char name[80]
Definition: TGX11.cxx:109
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition: RooArgSet.h:28
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
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27
const RooArgSet * getSet(Int_t idx) const
Return RooArgSet stored in slot idx.
Definition: RooCmdArg.cxx:198
RooArgSet * _c
Definition: RooCmdArg.h:114
RooLinkedList _argList
Definition: RooCmdArg.h:115
void addArg(const RooCmdArg &arg)
Utility function to add nested RooCmdArg to payload of this RooCmdArg.
Definition: RooCmdArg.cxx:188
Int_t _i[2]
Definition: RooCmdArg.h:110
RooCmdArg & operator=(const RooCmdArg &other)
Assignment operator.
Definition: RooCmdArg.cxx:140
static const RooCmdArg & none()
Return reference to null argument.
Definition: RooCmdArg.cxx:50
Bool_t _procSubArgs
Definition: RooCmdArg.h:113
Bool_t _prefixSubArgs
Definition: RooCmdArg.h:116
virtual ~RooCmdArg()
Destructor.
Definition: RooCmdArg.cxx:177
void setSet(Int_t idx, const RooArgSet &set)
Definition: RooCmdArg.cxx:206
std::string _s[3]
Definition: RooCmdArg.h:111
Double_t _d[2]
Definition: RooCmdArg.h:109
RooCmdArg()
Default constructor.
Definition: RooCmdArg.cxx:59
TObject * _o[2]
Definition: RooCmdArg.h:112
static const RooCmdArg _none
Definition: RooCmdArg.h:101
Int_t GetSize() const
Definition: RooLinkedList.h:61
TObject * At(Int_t index) const
Return object stored in sequential position given by index.
void Delete(Option_t *o=0)
Remove all elements in collection and delete all elements NB: Collection does not own elements,...
virtual void Add(TObject *arg)
Definition: RooLinkedList.h:63
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
Mother of all ROOT objects.
Definition: TObject.h:37
return c1
Definition: legend1.C:41
return c2
Definition: legend2.C:14