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