ROOT  6.06/09
Reference Guide
RooRealProxy.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 // BEGIN_HTML
20 // RooRealProxy is the concrete proxy for RooAbsReal objects
21 // A RooRealProxy is the general mechanism to store references
22 // to RooAbsReals inside a RooAbsArg
23 //
24 // RooRealProxy provides a cast operator to Double_t, allowing
25 // the proxy to functions a Double_t on the right hand side of expressions.
26 // END_HTML
27 //
28 
29 #include "RooFit.h"
30 #include "Riostream.h"
31 
32 #include "TClass.h"
33 #include "RooRealProxy.h"
34 #include "RooRealVar.h"
35 
36 using namespace std;
37 
39 ;
40 
41 
42 ////////////////////////////////////////////////////////////////////////////////
43 /// Constructor with owner.
44 
45 RooRealProxy::RooRealProxy(const char* inName, const char* desc, RooAbsArg* owner,
46  Bool_t valueServer, Bool_t shapeServer, Bool_t ownArg) :
47  RooArgProxy(inName, desc, owner, valueServer, shapeServer, ownArg)
48 {
49 }
50 
51 
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// Constructor with owner and proxied real-valued object. The propagation
55 /// of value and shape dirty flags of the contained arg to the owner is
56 /// controlled by the valueServer and shapeServer flags. If ownArg is true
57 /// the proxy will take ownership of the contained arg
58 
59 RooRealProxy::RooRealProxy(const char* inName, const char* desc, RooAbsArg* owner, RooAbsReal& ref,
60  Bool_t valueServer, Bool_t shapeServer, Bool_t ownArg) :
61  RooArgProxy(inName, desc, owner,ref, valueServer, shapeServer, ownArg)
62 {
63 }
64 
65 
66 
67 ////////////////////////////////////////////////////////////////////////////////
68 /// Copy constructor
69 
70 RooRealProxy::RooRealProxy(const char* inName, RooAbsArg* owner, const RooRealProxy& other) :
71  RooArgProxy(inName, owner, other)
72 {
73 }
74 
75 
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 /// Destructor
79 
81 {
82 }
83 
84 
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 /// Return l-value pointer to contents, if contents is in fact an l-value
88 
90 {
91  // WVE remove check here -- need to put it back in setArg and ctor
92  return (RooAbsRealLValue*) _arg ;
93 
94  // Assert that the held arg is an LValue
95  RooAbsRealLValue* Lvptr = (RooAbsRealLValue*)dynamic_cast<const RooAbsRealLValue*>(_arg) ;
96  if (!Lvptr) {
97  cout << "RooRealProxy(" << name() << ")::INTERNAL error, expected " << _arg->GetName() << " to be an lvalue" << endl ;
98  assert(0) ;
99  }
100  return Lvptr ;
101 }
102 
103 
104 ////////////////////////////////////////////////////////////////////////////////
105 /// Change object held in proxy into newRef
106 
108 {
109  if (absArg()) {
110  if (TString(arg().GetName()!=newRef.GetName())) {
111  newRef.setAttribute(Form("ORIGNAME:%s",arg().GetName())) ;
112  }
113  return changePointer(RooArgSet(newRef),kTRUE) ;
114  } else {
115  return changePointer(RooArgSet(newRef),kFALSE,kTRUE);
116  }
117 }
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:265
virtual Bool_t changePointer(const RooAbsCollection &newServerSet, Bool_t nameChange=kFALSE, Bool_t factoryInitMode=kFALSE)
Change proxied object to object of same name in given list.
virtual ~RooRealProxy()
Destructor.
#define assert(cond)
Definition: unittest.h:542
virtual const char * name() const
Definition: RooArgProxy.h:42
Basic string class.
Definition: TString.h:137
RooAbsArg * _arg
Definition: RooArgProxy.h:52
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
STL namespace.
const RooAbsReal & arg() const
Definition: RooRealProxy.h:43
RooAbsRealLValue * lvptr() const
Return l-value pointer to contents, if contents is in fact an l-value.
ClassImp(RooRealProxy)
char * Form(const char *fmt,...)
RooAbsArg * absArg() const
Definition: RooArgProxy.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
virtual Bool_t setArg(RooAbsReal &newRef)
Change object held in proxy into newRef.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
Definition: RooAbsArg.h:66
const Bool_t kTRUE
Definition: Rtypes.h:91