RooCmdArg.cxx

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  * @(#)root/roofitcore:$Id: RooCmdArg.cxx 37128 2010-11-30 22:24:50Z wouter $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 
00017 
00018 //////////////////////////////////////////////////////////////////////////////
00019 // 
00020 // BEGIN_HTML
00021 // RooCmdArg is a named container for two doubles, two integers
00022 // two object points and three string pointers that can be passed
00023 // as generic named arguments to a variety of RooFit end user
00024 // methods. To achieved the named syntax, RooCmdArg objects are
00025 // created using global helper functions defined in RooGlobalFunc.h
00026 // that create and fill these generic containers
00027 // END_HTML
00028 //
00029 
00030 #include "RooFit.h"
00031 
00032 #include "RooCmdArg.h"
00033 #include "RooCmdArg.h"
00034 #include "Riostream.h"
00035 #include "RooArgSet.h"
00036 #include <string>
00037 
00038 ClassImp(RooCmdArg)
00039   ;
00040 
00041 const RooCmdArg RooCmdArg::_none ;
00042 
00043 
00044 //_____________________________________________________________________________
00045 const RooCmdArg& RooCmdArg::none() 
00046 {
00047   // Return reference to null argument
00048   return _none ;
00049 }
00050 
00051 
00052 //_____________________________________________________________________________
00053 RooCmdArg::RooCmdArg() : TNamed("","")
00054 {
00055   // Default constructor
00056   _procSubArgs = kFALSE ;
00057   _prefixSubArgs = kTRUE ;
00058   _c = 0 ;
00059   _o[0] = 0 ;
00060   _o[1] = 0 ; 
00061   _i[0] = 0 ;
00062   _i[1] = 0 ;
00063   _d[0] = 0 ;
00064   _d[1] = 0 ;
00065 }
00066 
00067 
00068 //_____________________________________________________________________________
00069 RooCmdArg::RooCmdArg(const char* name, Int_t i1, Int_t i2, Double_t d1, Double_t d2, 
00070                      const char* s1, const char* s2, const TObject* o1, const TObject* o2, 
00071                      const RooCmdArg* ca, const char* s3, const RooArgSet* c1, const RooArgSet* c2) :
00072   TNamed(name,name)
00073 {
00074   // Constructor with full specification of payload: two integers, two doubles,
00075   // three string poiners, two object pointers and one RooCmdArg pointer
00076 
00077   _i[0] = i1 ;
00078   _i[1] = i2 ;
00079   _d[0] = d1 ;
00080   _d[1] = d2 ;
00081   if (s1) _s[0] = s1 ;
00082   if (s2) _s[1] = s2 ;
00083   if (s3) _s[2] = s3 ;
00084   _o[0] = (TObject*) o1 ;
00085   _o[1] = (TObject*) o2 ;
00086   _c = 0 ;
00087 
00088   if (c1||c2) _c = new RooArgSet[2] ;
00089   if (c1) _c[0].add(*c1) ;
00090   if (c2) _c[1].add(*c2) ;
00091 
00092   _procSubArgs = kTRUE ;
00093   _prefixSubArgs = kTRUE ;
00094   if (ca) {
00095     _argList.Add(new RooCmdArg(*ca)) ;
00096   }
00097 }
00098 
00099 
00100 
00101 //_____________________________________________________________________________
00102 RooCmdArg::RooCmdArg(const RooCmdArg& other) :
00103   TNamed(other)
00104 {
00105   // Copy constructor
00106 
00107   _i[0] = other._i[0] ;
00108   _i[1] = other._i[1] ;
00109   _d[0] = other._d[0] ;
00110   _d[1] = other._d[1] ;
00111   _s[0] = other._s[0] ;
00112   _s[1] = other._s[1] ;
00113   _s[2] = other._s[2] ;
00114   _o[0] = other._o[0] ;
00115   _o[1] = other._o[1] ;
00116   if (other._c) {
00117     _c = new RooArgSet[2] ;
00118     _c[0].add(other._c[0]) ;
00119     _c[1].add(other._c[1]) ;
00120   } else {
00121     _c = 0 ;
00122   }
00123   
00124   _procSubArgs = other._procSubArgs ;
00125   _prefixSubArgs = other._prefixSubArgs ;
00126   for (Int_t i=0 ; i<other._argList.GetSize() ; i++) {
00127     _argList.Add(new RooCmdArg((RooCmdArg&)*other._argList.At(i))) ;
00128   }
00129 }
00130 
00131 
00132 //_____________________________________________________________________________
00133 RooCmdArg& RooCmdArg::operator=(const RooCmdArg& other) 
00134 {
00135   // Assignment operator
00136 
00137   if (&other==this) return *this ;
00138 
00139   SetName(other.GetName()) ;
00140   SetTitle(other.GetTitle()) ;
00141 
00142   _i[0] = other._i[0] ;
00143   _i[1] = other._i[1] ;
00144   _d[0] = other._d[0] ;
00145   _d[1] = other._d[1] ;
00146   _s[0] = other._s[0] ;
00147   _s[1] = other._s[1] ;
00148   _s[2] = other._s[2] ;
00149   _o[0] = other._o[0] ;
00150   _o[1] = other._o[1] ;
00151   if (!_c) _c = new RooArgSet[2] ;
00152   if (other._c) {
00153     _c[0].removeAll() ; _c[0].add(other._c[0]) ;
00154     _c[1].removeAll() ; _c[1].add(other._c[1]) ;
00155   }
00156   
00157   _procSubArgs = other._procSubArgs ;
00158   _prefixSubArgs = other._prefixSubArgs ;
00159 
00160   for (Int_t i=0 ; i<other._argList.GetSize() ; i++) {
00161     _argList.Add(new RooCmdArg((RooCmdArg&)*other._argList.At(i))) ;
00162   }
00163 
00164   return *this ;
00165 }
00166 
00167 
00168 
00169 //_____________________________________________________________________________
00170 RooCmdArg::~RooCmdArg()
00171 {
00172   // Destructor
00173   _argList.Delete() ;
00174   if (_c) delete[] _c ;
00175 }
00176 
00177 
00178 
00179 //_____________________________________________________________________________
00180 void RooCmdArg::addArg(const RooCmdArg& arg) 
00181 {
00182   // Utility function to add nested RooCmdArg to payload of this RooCmdArg
00183 
00184   _argList.Add(new RooCmdArg(arg)) ;
00185 }
00186 
00187 
00188 
00189 //_____________________________________________________________________________
00190 const RooArgSet* RooCmdArg::getSet(Int_t idx) const {
00191   // Return RooArgSet stored in slot idx
00192     return _c ? &_c[idx] : 0 ;
00193   }
00194 
00195 
00196 
00197 //_____________________________________________________________________________
00198 void RooCmdArg::setSet(Int_t idx,const RooArgSet& set) 
00199 {
00200   if (!_c) {
00201     _c = new RooArgSet[2] ;
00202   }
00203     _c[idx].removeAll() ;
00204     _c[idx].add(set) ;
00205 }

Generated on Tue Jul 5 15:06:20 2011 for ROOT_528-00b_version by  doxygen 1.5.1