RooFormulaVar

From: Arthur E. Snyder <snyder_at_slac.stanford.edu>
Date: Mon, 8 Sep 2008 17:29:08 -0700

This a question about RooFormulaVar constructors which are:

   inline RooFormulaVar() { }
   RooFormulaVar(const char *name, const char *title, const char* formula, const RooArgList& dependents);

   RooFormulaVar(const char *name, const char *title, const RooArgList& dependents);

   RooFormulaVar(const RooFormulaVar& other, const char* name=0);

  1. I would like to use a RooFormulaVar as data memember and add the formula in the constructor later in code. This means using defaults constructor but I see no way to add formula after construction.

Is this right?

2) This is just a curiousity, but the third constructor is weird. It takes only name and title. However, the title is used both as title and as expersion for formula, so

RooFormulaVar::RooFormulaVar(const char *name, const char *title, const RooArgList& dependents) :

   RooAbsReal(name,title),
_actualVars("actualVars","Variables used by formula expression",this),
_formula(0), _formExpr(title)

{

   // Constructor with formula expression, title and list of input variables
// RooFormula tmpFormula(name,title,dependents) ;

_actualVars.add(dependents) ; //tmpFormula.actualDependents()) ;

   if (_actualVars.getSize()==0) _value = traceEval(0) ; }

--that seems odd and confusing and not something you could figure out by just looking at the interface in the header file, but you have to look at .cc to see this weired usage. Is this intended?

-Art S.

PS. More genrally there doesn't seem to be anyway to introduce plain doubles, etc. in to formula. This would be handy in my current application, but I'm forced to make everything a RealRooVar.

A.E. Snyder, Group EC                        \!c*p?/
SLAC Mail Stop #95                          ((.   .))
Box 4349                                        |
Stanford, Ca, USA, 94309                      '\|/`
e-mail:snyder_at_slac.stanford.edu                 o
phone:650-926-2701                              _
http://www.slac.stanford.edu/~snyder          BaBar
FAX:650-926-2657                          Collaboration



On Mon, 8 Sep 2008, Arthur E. Snyder wrote:

>
> I have a problem that |plotMin| and |plotMax| to not return me min and max of 
> a |RooRealVar|:
>
> Code is:
>
> #include "rootLib/RooMapMaker.hh"
> TH2D* convolTest() {
>
>
>  RooRealVar x("x","x",0.0,-25.0,25.0);
>  RooRealVar xmean("xmean","xmean",0.0,-100.0,100.0);
>
>  Int_t nx=x.getPlotBins();
>  Double_t xmin=x.getPlotMin();
>  Double_t xmax=x.getPlotMax();
>
>  cout << "nx:" << nx
>       << " xmin:" << xmin
>       << " xmax:" << xmax
>       << endl;
>
>
>  RooRealVar s0("s0","s0",1.0,0.0,10.0);
>  RooRealVar s1("s1","s1",1.0.0,-10.0,10.0);
>  RooFormulaVar err
>    ("sigma","sigma","@0+@1*sqrt(@2)",RooArgList(s0,s1,xmean));
>
>  cout << "err(1):" << err.getVal() << endl;
>
>
>  RooGaussian G("G","G",x,xmean,err);
>
>  RooPlot* plot=x.frame();
>  G.plotOn(plot,RooFit::LineColor(2));
>  plot->Draw();
>
>  xmean.setVal(10);
>  cout << "err(2):" << err.getVal() << endl;
>
>  G.plotOn(plot,RooFit::LineColor(3));
>  plot->Draw();
>
>  RooMapMaker* maker=new RooMapMaker("GMap","GMap",G,xmean,x);
>
>  return maker->map();
>
> }
>
> Running this macro I get:
>
> root [0] .L convolTest.C
> root [1] convolTest()
> nx:100 xmin:0 xmax:0
>
> and yet the plot has the range specified (-25->+25):
>
> see http:/www.slac.stanford.edu/~snyder/convolTest.gif
>
> --so why don't |plotMin()| and |plotMax()| work?
>
> --and how do I get the plot range I specified in constructor for the 
> |RooRealVar|?
>
>
>
> A.E. Snyder, Group EC                        \!c*p?/
> SLAC Mail Stop #95                          ((.   .))
> Box 4349                                        |
> Stanford, Ca, USA, 94309                      '\|/`
> e-mail:snyder_at_slac.stanford.edu                 o
> phone:650-926-2701                              _
> http://www.slac.stanford.edu/~snyder          BaBar
> FAX:650-926-2657                          Collaboration
>
>
>
>
Received on Tue Sep 09 2008 - 02:29:18 CEST

This archive was generated by hypermail 2.2.0 : Tue Sep 09 2008 - 23:50:01 CEST