ROOT  6.06/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 // Your description goes here...
8 
9 #include "Riostream.h"
10 
11 #include "RooTFnBinding.h"
12 #include "RooAbsReal.h"
13 #include "RooAbsCategory.h"
14 #include "TF3.h"
15 
16 using namespace std;
17 
19 
20 RooTFnBinding::RooTFnBinding(const char *name, const char *title, TF1* func, const RooArgList& list) :
21  RooAbsReal(name,title),
22  _olist("obs","obs",this),
23  _func(func)
24 {
25  _olist.add(list) ;
26 }
27 
28 
29 RooTFnBinding::RooTFnBinding(const char *name, const char *title, TF1* func, const RooArgList& obsList, const RooArgList& paramList) :
30  RooAbsReal(name,title),
31  _olist("obs","obs",this),
32  _plist("params","params",this),
33  _func(func)
34 {
35  _olist.add(obsList) ;
36  _plist.add(paramList) ;
37 }
38 
39 
40 RooTFnBinding::RooTFnBinding(const RooTFnBinding& other, const char* name) :
41  RooAbsReal(other,name),
42  _olist("obs",this,other._olist),
43  _plist("params",this,other._plist),
44  _func(other._func)
45 {
46 }
47 
48 
49 
51 {
52  Double_t x = _olist.at(0) ? ((RooAbsReal*)_olist.at(0))->getVal() : 0 ;
53  Double_t y = _olist.at(1) ? ((RooAbsReal*)_olist.at(1))->getVal() : 0 ;
54  Double_t z = _olist.at(2) ? ((RooAbsReal*)_olist.at(2))->getVal() : 0 ;
55  for (Int_t i=0 ; i<_func->GetNpar() ; i++) {
56  _func->SetParameter(i,_plist.at(i)?((RooAbsReal*)_plist.at(i))->getVal() : 0) ;
57  }
58  return _func->Eval(x,y,z) ;
59 }
60 
61 
62 
63 void RooTFnBinding::printArgs(ostream& os) const
64 {
65  // Print object arguments and name/address of function pointer
66  os << "[ TFn={" << _func->GetName() << "=" << _func->GetTitle() << "} " ;
67  for (Int_t i=0 ; i<numProxies() ; i++) {
68  RooAbsProxy* p = getProxy(i) ;
69  if (!TString(p->name()).BeginsWith("!")) {
70  p->print(os) ;
71  os << " " ;
72  }
73  }
74  os << "]" ;
75 }
76 
77 
78 namespace RooFit {
79 
81  return new RooTFnBinding(func->GetName(),func->GetTitle(),func,x) ;
82  }
83 
85  return new RooTFnBinding(func->GetName(),func->GetTitle(),func,RooArgList(x,y)) ;
86  }
87 
89  return new RooTFnBinding(func->GetName(),func->GetTitle(),func,RooArgList(x,y,z)) ;
90  }
91 
93  return new RooTFnBinding(func->GetName(),func->GetTitle(),func,x,params) ;
94  }
95 
97  return new RooTFnBinding(func->GetName(),func->GetTitle(),func,RooArgList(x,y),params) ;
98  }
99 
101  return new RooTFnBinding(func->GetName(),func->GetTitle(),func,RooArgList(x,y,z),params) ;
102  }
103 
104 }
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:52
virtual void print(std::ostream &os, Bool_t addContents=kFALSE) const
Print proxy name.
Definition: RooAbsProxy.cxx:74
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
STL namespace.
RooAbsProxy * getProxy(Int_t index) const
Return the nth proxy from the proxy list.
Definition: RooAbsArg.cxx:1253
RooAbsReal * bindFunction(const char *name, CFUNCD1D func, RooAbsReal &x)
Double_t x[n]
Definition: legend1.C:17
RooListProxy _olist
Definition: RooTFnBinding.h:30
bool BeginsWith(const std::string &theString, const std::string &theSubstring)
Double_t getVal(const RooArgSet *set=0) const
Definition: RooAbsReal.h:64
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
Int_t numProxies() const
Return the number of registered proxies.
Definition: RooAbsArg.cxx:1266
A 3-Dim function with parameters.
Definition: TF3.h:30
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
A 2-Dim function with parameters.
Definition: TF2.h:33
virtual const char * name() const
Definition: RooAbsProxy.h:42
RooListProxy _plist
Definition: RooTFnBinding.h:31
RooAbsArg * at(Int_t idx) const
Definition: RooArgList.h:84
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
void printArgs(std::ostream &os) const
Print object arguments, ie its proxies.
#define name(a, b)
Definition: linkTestLib0.cpp:5
ClassImp(RooTFnBinding) RooTFnBinding
1-Dim function class
Definition: TF1.h:149
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:1185
Double_t evaluate() const
virtual void SetParameter(Int_t param, Double_t value)
Definition: TF1.h:431
virtual Int_t GetNpar() const
Definition: TF1.h:349