Logo ROOT   6.10/09
Reference Guide
RooTFnBinding.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * *
4  * This code was autogenerated by RooClassFactory *
5  *****************************************************************************/
6 
7 /** \class RooTFnBinding
8  \ingroup Roofit
9 
10 **/
11 
12 #include "Riostream.h"
13 
14 #include "RooTFnBinding.h"
15 #include "RooAbsReal.h"
16 #include "RooAbsCategory.h"
17 #include "TF3.h"
18 
19 using namespace std;
20 
22 
23 ////////////////////////////////////////////////////////////////////////////////
24 
25 RooTFnBinding::RooTFnBinding(const char *name, const char *title, TF1* func, const RooArgList& list) :
26  RooAbsReal(name,title),
27  _olist("obs","obs",this),
28  _func(func)
29 {
30  _olist.add(list) ;
31 }
32 
33 ////////////////////////////////////////////////////////////////////////////////
34 
35 RooTFnBinding::RooTFnBinding(const char *name, const char *title, TF1* func, const RooArgList& obsList, const RooArgList& paramList) :
36  RooAbsReal(name,title),
37  _olist("obs","obs",this),
38  _plist("params","params",this),
39  _func(func)
40 {
41  _olist.add(obsList) ;
42  _plist.add(paramList) ;
43 }
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 
47 RooTFnBinding::RooTFnBinding(const RooTFnBinding& other, const char* name) :
48  RooAbsReal(other,name),
49  _olist("obs",this,other._olist),
50  _plist("params",this,other._plist),
51  _func(other._func)
52 {
53 }
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 
58 {
59  Double_t x = _olist.at(0) ? ((RooAbsReal*)_olist.at(0))->getVal() : 0 ;
60  Double_t y = _olist.at(1) ? ((RooAbsReal*)_olist.at(1))->getVal() : 0 ;
61  Double_t z = _olist.at(2) ? ((RooAbsReal*)_olist.at(2))->getVal() : 0 ;
62  for (Int_t i=0 ; i<_func->GetNpar() ; i++) {
63  _func->SetParameter(i,_plist.at(i)?((RooAbsReal*)_plist.at(i))->getVal() : 0) ;
64  }
65  return _func->Eval(x,y,z) ;
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 
70 void RooTFnBinding::printArgs(ostream& os) const
71 {
72  // Print object arguments and name/address of function pointer
73  os << "[ TFn={" << _func->GetName() << "=" << _func->GetTitle() << "} " ;
74  for (Int_t i=0 ; i<numProxies() ; i++) {
75  RooAbsProxy* p = getProxy(i) ;
76  if (!TString(p->name()).BeginsWith("!")) {
77  p->print(os) ;
78  os << " " ;
79  }
80  }
81  os << "]" ;
82 }
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 
86 namespace RooFit {
87 
89  return new RooTFnBinding(func->GetName(),func->GetTitle(),func,x) ;
90  }
91 
93  return new RooTFnBinding(func->GetName(),func->GetTitle(),func,RooArgList(x,y)) ;
94  }
95 
97  return new RooTFnBinding(func->GetName(),func->GetTitle(),func,RooArgList(x,y,z)) ;
98  }
99 
101  return new RooTFnBinding(func->GetName(),func->GetTitle(),func,x,params) ;
102  }
103 
105  return new RooTFnBinding(func->GetName(),func->GetTitle(),func,RooArgList(x,y),params) ;
106  }
107 
109  return new RooTFnBinding(func->GetName(),func->GetTitle(),func,RooArgList(x,y,z),params) ;
110  }
111 
112 }
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
void printArgs(std::ostream &os) const
Print object arguments, ie its proxies.
virtual const char * name() const
Definition: RooAbsProxy.h:41
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
int Int_t
Definition: RtypesCore.h:41
STL namespace.
RooAbsReal * bindFunction(const char *name, CFUNCD1D func, RooAbsReal &x)
Double_t x[n]
Definition: legend1.C:17
Double_t evaluate() const
RooListProxy _olist
Definition: RooTFnBinding.h:30
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
RooAbsArg * at(Int_t idx) const
Definition: RooArgList.h:84
A 3-Dim function with parameters.
Definition: TF3.h:28
RooAbsProxy is the abstact interface for proxy classes.
Definition: RooAbsProxy.h:31
A 2-Dim function with parameters.
Definition: TF2.h:29
RooListProxy _plist
Definition: RooTFnBinding.h:31
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
Definition: TF1.cxx:1197
#define ClassImp(name)
Definition: Rtypes.h:336
double Double_t
Definition: RtypesCore.h:55
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition: RooAbsReal.h:53
Double_t y[n]
Definition: legend1.C:17
double func(double *x, double *p)
Definition: stressTF1.cxx:213
RooAbsProxy * getProxy(Int_t index) const
Return the nth proxy from the proxy list.
Definition: RooAbsArg.cxx:1254
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
Int_t numProxies() const
Return the number of registered proxies.
Definition: RooAbsArg.cxx:1267
virtual Int_t GetNpar() const
Definition: TF1.h:435
1-Dim function class
Definition: TF1.h:150
virtual void SetParameter(Int_t param, Double_t value)
Definition: TF1.h:578
virtual void print(std::ostream &os, Bool_t addContents=kFALSE) const
Print proxy name.
Definition: RooAbsProxy.cxx:75
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48