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
37#include <string>
38#include <iostream>
39
40using namespace std;
41
43 ;
44
46
47
48////////////////////////////////////////////////////////////////////////////////
49/// Return reference to null argument
50
52{
53 return _none ;
54}
55
56
57////////////////////////////////////////////////////////////////////////////////
58/// Default constructor
59
61{
62 _procSubArgs = false ;
63 _prefixSubArgs = true ;
64 _c = 0 ;
65 _o[0] = 0 ;
66 _o[1] = 0 ;
67 _i[0] = 0 ;
68 _i[1] = 0 ;
69 _d[0] = 0 ;
70 _d[1] = 0 ;
71}
72
73
74////////////////////////////////////////////////////////////////////////////////
75/// Constructor with full specification of payload: two integers, two doubles,
76/// three string poiners, two object pointers and one RooCmdArg pointer
77
78RooCmdArg::RooCmdArg(const char* name, Int_t i1, Int_t i2, double d1, double d2,
79 const char* s1, const char* s2, const TObject* o1, const TObject* o2,
80 const RooCmdArg* ca, const char* s3, const RooArgSet* c1, const RooArgSet* c2) :
82{
83 _i[0] = i1 ;
84 _i[1] = i2 ;
85 _d[0] = d1 ;
86 _d[1] = d2 ;
87 if (s1) _s[0] = s1 ;
88 if (s2) _s[1] = s2 ;
89 if (s3) _s[2] = s3 ;
90 _o[0] = (TObject*) o1 ;
91 _o[1] = (TObject*) o2 ;
92 _c = 0 ;
93
94 if (c1||c2) _c = new RooArgSet[2] ;
95 if (c1) _c[0].add(*c1) ;
96 if (c2) _c[1].add(*c2) ;
97
98 _procSubArgs = true ;
99 _prefixSubArgs = true ;
100 if (ca) {
101 _argList.Add(new RooCmdArg(*ca)) ;
102 }
103}
104
105
106
107////////////////////////////////////////////////////////////////////////////////
108/// Copy constructor
109
111 TNamed(other)
112{
113 _i[0] = other._i[0] ;
114 _i[1] = other._i[1] ;
115 _d[0] = other._d[0] ;
116 _d[1] = other._d[1] ;
117 _s[0] = other._s[0] ;
118 _s[1] = other._s[1] ;
119 _s[2] = other._s[2] ;
120 _o[0] = other._o[0] ;
121 _o[1] = other._o[1] ;
122 if (other._c) {
123 _c = new RooArgSet[2] ;
124 _c[0].add(other._c[0]) ;
125 _c[1].add(other._c[1]) ;
126 } else {
127 _c = 0 ;
128 }
129
130 _procSubArgs = other._procSubArgs ;
132 for (Int_t i=0 ; i<other._argList.GetSize() ; i++) {
133 _argList.Add(new RooCmdArg((RooCmdArg&)*other._argList.At(i))) ;
134 }
135}
136
137
138////////////////////////////////////////////////////////////////////////////////
139/// Assignment operator
140
142{
143 if (&other==this) return *this ;
144
145 SetName(other.GetName()) ;
146 SetTitle(other.GetTitle()) ;
147
148 _i[0] = other._i[0] ;
149 _i[1] = other._i[1] ;
150 _d[0] = other._d[0] ;
151 _d[1] = other._d[1] ;
152 _s[0] = other._s[0] ;
153 _s[1] = other._s[1] ;
154 _s[2] = other._s[2] ;
155 _o[0] = other._o[0] ;
156 _o[1] = other._o[1] ;
157 if (!_c) _c = new RooArgSet[2] ;
158 if (other._c) {
159 _c[0].removeAll() ; _c[0].add(other._c[0]) ;
160 _c[1].removeAll() ; _c[1].add(other._c[1]) ;
161 }
162
163 _procSubArgs = other._procSubArgs ;
165
166 for (Int_t i=0 ; i<other._argList.GetSize() ; i++) {
167 _argList.Add(new RooCmdArg((RooCmdArg&)*other._argList.At(i))) ;
168 }
169
170 return *this ;
171}
172
173
174
175////////////////////////////////////////////////////////////////////////////////
176/// Destructor
177
179{
180 _argList.Delete() ;
181 if (_c) delete[] _c ;
182}
183
184
185
186////////////////////////////////////////////////////////////////////////////////
187/// Utility function to add nested RooCmdArg to payload of this RooCmdArg
188
190{
191 _argList.Add(new RooCmdArg(arg)) ;
192}
193
194
195
196////////////////////////////////////////////////////////////////////////////////
197/// Return RooArgSet stored in slot idx
198
200 return _c ? &_c[idx] : 0 ;
201 }
202
203
204
205////////////////////////////////////////////////////////////////////////////////
206
208{
209 if (!_c) {
210 _c = new RooArgSet[2] ;
211 }
212 _c[idx].removeAll() ;
213 _c[idx].add(set) ;
214}
215
216
217////////////////////////////////////////////////////////////////////////////////
218/// Print contents
219void RooCmdArg::Print(const char*) const {
220 std::cout << GetName()
221 << ":\ndoubles\t" << _d[0] << " " << _d[1]
222 << "\nints\t" << _i[0] << " " << _i[1]
223 << "\nstrings\t" << _s[0] << " " << _s[1] << " " << _s[2]
224 << "\nobjects\t" << _o[0] << " " << _o[1] << std::endl;
225}
#define s1(x)
Definition RSha256.hxx:91
#define ClassImp(name)
Definition Rtypes.h:377
char name[80]
Definition TGX11.cxx:110
virtual void removeAll()
Remove all arguments from our set, deleting them if we own them.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition RooCmdArg.h:26
const RooArgSet * getSet(Int_t idx) const
Return RooArgSet stored in slot idx.
RooArgSet * _c
Payload RooArgSets.
Definition RooCmdArg.h:120
void Print(const char *="") const override
Print contents.
RooLinkedList _argList
Payload sub-arguments.
Definition RooCmdArg.h:121
void addArg(const RooCmdArg &arg)
Utility function to add nested RooCmdArg to payload of this RooCmdArg.
Int_t _i[2]
Payload integers.
Definition RooCmdArg.h:116
RooCmdArg & operator=(const RooCmdArg &other)
Assignment operator.
static const RooCmdArg & none()
Return reference to null argument.
Definition RooCmdArg.cxx:51
void setSet(Int_t idx, const RooArgSet &set)
std::string _s[3]
Payload strings.
Definition RooCmdArg.h:117
bool _procSubArgs
If true argument requires recursive processing.
Definition RooCmdArg.h:119
RooCmdArg()
Default constructor.
Definition RooCmdArg.cxx:60
TObject * _o[2]
Payload objects.
Definition RooCmdArg.h:118
static const RooCmdArg _none
Static instance of null object.
Definition RooCmdArg.h:112
double _d[2]
Payload doubles.
Definition RooCmdArg.h:115
bool _prefixSubArgs
Prefix sub-arguments with container name?
Definition RooCmdArg.h:122
~RooCmdArg() override
Destructor.
Int_t GetSize() const
TObject * At(int index) const
Return object stored in sequential position given by index.
void Delete(Option_t *o=nullptr) override
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
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
Mother of all ROOT objects.
Definition TObject.h:41
return c1
Definition legend1.C:41
return c2
Definition legend2.C:14