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
23Named 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 _o[0] = nullptr ;
63 _o[1] = nullptr ;
64 _i[0] = 0 ;
65 _i[1] = 0 ;
66 _d[0] = 0 ;
67 _d[1] = 0 ;
68}
69
70
71////////////////////////////////////////////////////////////////////////////////
72/// Constructor with full specification of payload: two integers, two doubles,
73/// three string poiners, two object pointers and one RooCmdArg pointer
74
75RooCmdArg::RooCmdArg(const char* name, Int_t i1, Int_t i2, double d1, double d2,
76 const char* s1, const char* s2, const TObject* o1, const TObject* o2,
77 const RooCmdArg* ca, const char* s3, const RooArgSet* c1, const RooArgSet* c2) :
79{
80 _i[0] = i1 ;
81 _i[1] = i2 ;
82 _d[0] = d1 ;
83 _d[1] = d2 ;
84 if (s1) _s[0] = s1 ;
85 if (s2) _s[1] = s2 ;
86 if (s3) _s[2] = s3 ;
87 _o[0] = const_cast<TObject*>(o1);
88 _o[1] = const_cast<TObject*>(o2);
89 _c = nullptr ;
90
91 if (c1||c2) _c = new RooArgSet[2] ;
92 if (c1) _c[0].add(*c1) ;
93 if (c2) _c[1].add(*c2) ;
94
95 _procSubArgs = true ;
96 _prefixSubArgs = true ;
97 if (ca) {
98 _argList.Add(new RooCmdArg(*ca)) ;
99 }
100}
101
102
103
104////////////////////////////////////////////////////////////////////////////////
105/// Copy constructor
106
108 TNamed(other)
109{
110 _i[0] = other._i[0] ;
111 _i[1] = other._i[1] ;
112 _d[0] = other._d[0] ;
113 _d[1] = other._d[1] ;
114 _s[0] = other._s[0] ;
115 _s[1] = other._s[1] ;
116 _s[2] = other._s[2] ;
117 _o[0] = other._o[0] ;
118 _o[1] = other._o[1] ;
119 if (other._c) {
120 _c = new RooArgSet[2] ;
121 _c[0].add(other._c[0]) ;
122 _c[1].add(other._c[1]) ;
123 } else {
124 _c = nullptr ;
125 }
126
127 _procSubArgs = other._procSubArgs ;
129 for (Int_t i=0 ; i<other._argList.GetSize() ; i++) {
130 _argList.Add(new RooCmdArg(static_cast<RooCmdArg&>(*other._argList.At(i)))) ;
131 }
132}
133
134
135////////////////////////////////////////////////////////////////////////////////
136/// Assignment operator
137
139{
140 if (&other==this) return *this ;
141
142 SetName(other.GetName()) ;
143 SetTitle(other.GetTitle()) ;
144
145 _i[0] = other._i[0] ;
146 _i[1] = other._i[1] ;
147 _d[0] = other._d[0] ;
148 _d[1] = other._d[1] ;
149 _s[0] = other._s[0] ;
150 _s[1] = other._s[1] ;
151 _s[2] = other._s[2] ;
152 _o[0] = other._o[0] ;
153 _o[1] = other._o[1] ;
154 if (!_c) _c = new RooArgSet[2] ;
155 if (other._c) {
156 _c[0].removeAll() ; _c[0].add(other._c[0]) ;
157 _c[1].removeAll() ; _c[1].add(other._c[1]) ;
158 }
159
160 _procSubArgs = other._procSubArgs ;
162
163 for (Int_t i=0 ; i<other._argList.GetSize() ; i++) {
164 _argList.Add(new RooCmdArg(static_cast<RooCmdArg&>(*other._argList.At(i)))) ;
165 }
166
167 return *this ;
168}
169
170
171
172////////////////////////////////////////////////////////////////////////////////
173/// Destructor
174
176{
177 _argList.Delete() ;
178 if (_c) delete[] _c ;
179}
180
181
182
183////////////////////////////////////////////////////////////////////////////////
184/// Utility function to add nested RooCmdArg to payload of this RooCmdArg
185
187{
188 _argList.Add(new RooCmdArg(arg)) ;
189}
190
191
192
193////////////////////////////////////////////////////////////////////////////////
194/// Return RooArgSet stored in slot idx
195
197 return _c ? &_c[idx] : nullptr ;
198 }
199
200
201
202////////////////////////////////////////////////////////////////////////////////
203
205{
206 if (!_c) {
207 _c = new RooArgSet[2] ;
208 }
209 _c[idx].removeAll() ;
210 _c[idx].add(set) ;
211}
212
213
214////////////////////////////////////////////////////////////////////////////////
215/// Print contents
216void RooCmdArg::Print(const char*) const {
217 std::cout << GetName()
218 << ":\ndoubles\t" << _d[0] << " " << _d[1]
219 << "\nints\t" << _i[0] << " " << _i[1]
220 << "\nstrings\t" << _s[0] << " " << _s[1] << " " << _s[2]
221 << "\nobjects\t" << _o[0] << " " << _o[1] << std::endl;
222}
#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
Named container for two doubles, two integers two object points and three string pointers that can be...
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