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