Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
32
33#include "RooCmdArg.h"
34#include "Riostream.h"
35#include "RooArgSet.h"
36#include "RooFit.h"
37
38#include <string>
39#include <iostream>
40
41using namespace std;
42
44 ;
45
47
48
49////////////////////////////////////////////////////////////////////////////////
50/// Return reference to null argument
51
53{
54 return _none ;
55}
56
57
58////////////////////////////////////////////////////////////////////////////////
59/// Default constructor
60
62{
65 _c = 0 ;
66 _o[0] = 0 ;
67 _o[1] = 0 ;
68 _i[0] = 0 ;
69 _i[1] = 0 ;
70 _d[0] = 0 ;
71 _d[1] = 0 ;
72}
73
74
75////////////////////////////////////////////////////////////////////////////////
76/// Constructor with full specification of payload: two integers, two doubles,
77/// three string poiners, two object pointers and one RooCmdArg pointer
78
80 const char* s1, const char* s2, const TObject* o1, const TObject* o2,
81 const RooCmdArg* ca, const char* s3, const RooArgSet* c1, const RooArgSet* c2) :
83{
84 _i[0] = i1 ;
85 _i[1] = i2 ;
86 _d[0] = d1 ;
87 _d[1] = d2 ;
88 if (s1) _s[0] = s1 ;
89 if (s2) _s[1] = s2 ;
90 if (s3) _s[2] = s3 ;
91 _o[0] = (TObject*) o1 ;
92 _o[1] = (TObject*) o2 ;
93 _c = 0 ;
94
95 if (c1||c2) _c = new RooArgSet[2] ;
96 if (c1) _c[0].add(*c1) ;
97 if (c2) _c[1].add(*c2) ;
98
101 if (ca) {
102 _argList.Add(new RooCmdArg(*ca)) ;
103 }
104
105 _sharedData.reset(new DataCollection);
107}
108
109
110
111////////////////////////////////////////////////////////////////////////////////
112/// Copy constructor
113
115 TNamed(other),
116 _sharedData{other._sharedData}
117{
118 _i[0] = other._i[0] ;
119 _i[1] = other._i[1] ;
120 _d[0] = other._d[0] ;
121 _d[1] = other._d[1] ;
122 _s[0] = other._s[0] ;
123 _s[1] = other._s[1] ;
124 _s[2] = other._s[2] ;
125 _o[0] = other._o[0] ;
126 _o[1] = other._o[1] ;
127 if (other._c) {
128 _c = new RooArgSet[2] ;
129 _c[0].add(other._c[0]) ;
130 _c[1].add(other._c[1]) ;
131 } else {
132 _c = 0 ;
133 }
134
135 _procSubArgs = other._procSubArgs ;
137 for (Int_t i=0 ; i<other._argList.GetSize() ; i++) {
138 _argList.Add(new RooCmdArg((RooCmdArg&)*other._argList.At(i))) ;
139 }
140}
141
142
143////////////////////////////////////////////////////////////////////////////////
144/// Assignment operator
145
147{
148 if (&other==this) return *this ;
149
150 _sharedData = other._sharedData;
151
152 SetName(other.GetName()) ;
153 SetTitle(other.GetTitle()) ;
154
155 _i[0] = other._i[0] ;
156 _i[1] = other._i[1] ;
157 _d[0] = other._d[0] ;
158 _d[1] = other._d[1] ;
159 _s[0] = other._s[0] ;
160 _s[1] = other._s[1] ;
161 _s[2] = other._s[2] ;
162 _o[0] = other._o[0] ;
163 _o[1] = other._o[1] ;
164 if (!_c) _c = new RooArgSet[2] ;
165 if (other._c) {
166 _c[0].removeAll() ; _c[0].add(other._c[0]) ;
167 _c[1].removeAll() ; _c[1].add(other._c[1]) ;
168 }
169
170 _procSubArgs = other._procSubArgs ;
172
173 for (Int_t i=0 ; i<other._argList.GetSize() ; i++) {
174 _argList.Add(new RooCmdArg((RooCmdArg&)*other._argList.At(i))) ;
175 }
176
177 return *this ;
178}
179
180
181
182////////////////////////////////////////////////////////////////////////////////
183/// Destructor
184
186{
187 _argList.Delete() ;
188 if (_c) delete[] _c ;
189}
190
191
192
193////////////////////////////////////////////////////////////////////////////////
194/// Utility function to add nested RooCmdArg to payload of this RooCmdArg
195
197{
198 _argList.Add(new RooCmdArg(arg)) ;
199}
200
201
202
203////////////////////////////////////////////////////////////////////////////////
204/// Return RooArgSet stored in slot idx
205
207 return _c ? &_c[idx] : 0 ;
208 }
209
210
211
212////////////////////////////////////////////////////////////////////////////////
213
214void RooCmdArg::setSet(Int_t idx,const RooArgSet& set)
215{
216 if (!_c) {
217 _c = new RooArgSet[2] ;
218 }
219 _c[idx].removeAll() ;
220 _c[idx].add(set) ;
221}
222
223
224////////////////////////////////////////////////////////////////////////////////
225/// Print contents
226void RooCmdArg::Print(const char*) const {
227 std::cout << GetName()
228 << ":\ndoubles\t" << _d[0] << " " << _d[1]
229 << "\nints\t" << _i[0] << " " << _i[1]
230 << "\nstrings\t" << _s[0] << " " << _s[1] << " " << _s[2]
231 << "\nobjects\t" << _o[0] << " " << _o[1] << std::endl;
232}
233
235
#define s1(x)
Definition RSha256.hxx:91
const Bool_t kFALSE
Definition RtypesCore.h:101
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:364
char name[80]
Definition TGX11.cxx:110
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:35
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.
RooArgSet * _c
Definition RooCmdArg.h:122
RooLinkedList _argList
Definition RooCmdArg.h:123
void addArg(const RooCmdArg &arg)
Utility function to add nested RooCmdArg to payload of this RooCmdArg.
std::shared_ptr< DataCollection > _sharedData
Definition RooCmdArg.h:127
Int_t _i[2]
Definition RooCmdArg.h:118
RooCmdArg & operator=(const RooCmdArg &other)
Assignment operator.
static const RooCmdArg & none()
Return reference to null argument.
Definition RooCmdArg.cxx:52
static DataCollection _nextSharedData
Definition RooCmdArg.h:130
Bool_t _procSubArgs
Definition RooCmdArg.h:121
Bool_t _prefixSubArgs
Definition RooCmdArg.h:124
virtual ~RooCmdArg()
Destructor.
void setSet(Int_t idx, const RooArgSet &set)
std::string _s[3]
Definition RooCmdArg.h:119
Double_t _d[2]
Definition RooCmdArg.h:117
RooCmdArg()
Default constructor.
Definition RooCmdArg.cxx:61
TObject * _o[2]
Definition RooCmdArg.h:120
void Print(const char *="") const
Print contents.
static const RooCmdArg _none
Definition RooCmdArg.h:109
std::vector< std::unique_ptr< TObject > > DataCollection
Definition RooCmdArg.h:126
static DataCollection & getNextSharedData()
Int_t GetSize() const
TObject * At(int 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)
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:41
return c1
Definition legend1.C:41
return c2
Definition legend2.C:14