From: Philippe Canal <pcanal_at_fnal.gov>

Date: Thu, 12 Oct 2006 16:41:42 -0500

TGraph2D gra2(nv,x,y,z);

Date: Thu, 12 Oct 2006 16:41:42 -0500

Hi Robert,

*> I do NOT want to 'fit' to the population's distribution like the*

*> example does -- the function I'm trying to use (TF1 or whatever)*

*> should NOT return something proportional to the number of events*

*> in a bin/region. Instead, the evaluation is similar to TGraph,*

*> where the Chi2 function is built directly from the X and Y*

*> points.*

As far as I know/understand this is __exactly__ (except for actually creating the intermediary TGraph2D object) what TTree::UnbinnedFit does ....

Seriously, it sound that you want you exactly want is:

TF2 *myf = new TF2("myf","[0]*x+[1]*y",0.,3000.,0.,3000.);
myf->SetParameters(.1,.1);

tree->UnbinnedFit("myf","electronP:preshowerE:showerE",selection);

Cheers,

Philippe.

-----Original Message-----

From: Robert Feuerbach [mailto:feuerbac_at_jlab.org]
Sent: Thursday, October 12, 2006 2:01 PM
To: Rene Brun

Cc: pcanal_at_fnal.gov; roottalk_at_pcroot.cern.ch
Subject: Re: [ROOT] Using Parameters in TTreeFormula's?

Hi Rene,

Just to restate my original question about using parameters ('[0]', '[1]', etc.) like TFormula has in a TTreeFormula. Are there any plans to make them work in a TTreeFormula?

Thank you for the example but it is not applicable. I do NOT want to 'fit' to the population's distribution like the provided example does -- the function I'm trying to use (TF1 or whatever) does NOT return something proportional to the number of events in a bin/region but instead a value to be compared with one of the TTree variables.

This is a task that is performed more for calibration purposes, and not for extracting cross-sections and peaks. This application requires an evaluation similar to what is in TGraph, where the Chi2 function is built directly from the X and Y points.

For my current limited case with two 'independent' and one 'dependent' tree variable, the easiest solution I have found is to use a TGraph2D:

Int_t ne = T->Draw("electronP:preshowerE:showerE",selection);

Double_t *z = T->GetV1(); Double_t *y = T->GetV2(); Double_t *x = T->GetV3();

TGraph2D gra2(nv,x,y,z);

TF2 *myf = new TF2("myf","[0]*x+[1]*y",0.,3000.,0.,3000.);
myf->SetParameters(.1,.1);

gr2a.Fit("myf2");

Still, a general solution would be nice to find and use, especially once there are more than two 'independent' variables.

Thank you,

Rob Feuerbach

On Thu, 12 Oct 2006, Rene Brun wrote:

*> Date: Thu, 12 Oct 2006 06:00:34 +0200*

*> From: Rene Brun <Rene.Brun_at_cern.ch>*

*> To: Robert Feuerbach <feuerbac_at_jlab.org>*

*> Cc: Philippe Canal <pcanal_at_fnal.gov>, roottalk_at_pcroot.cern.ch*

*> Subject: Re: [ROOT] Using Parameters in TTreeFormula's?*

*>*

*> Robert,*

*>*

*> As already explained, you have everything you want in TTree::UnbinnedFit.*

*> In the doc of this function, we give an example with one variable*

*> // TF1* f1 = new TF1("f1", "gaus(0)/sqrt(2*3.14159)/[2]", 0, 5);*

*> // f1->SetParameters(1, 3.1, 0.01);*

*> // f1->SetParLimits(0, 1, 1); // fix the normalization parameter to 1*

*> // data->UnbinnedFit("f1", "jpsimass", "jpsipt>3.0");*

*>*

*> in case of 3 variables, give a TF3 as input using either an inline*

*> formula as above for the 1-d case*

*> or a Double_t myfunc(Double_t*x, Double_t*par).*

*> and call UnbinnedFit with something like*

*> data->UnbinnedFit(myfunc,"var1:var2:var3","some condition")*

*> where var1, var2, var3 are the 3 ntuple variables that you want to fit.*

*>*

*> Rene Brun*

*> Robert Feuerbach wrote:*

*> > Hi Philippe,*

*> >*

*> > Thank you for your indulgence, but from what I have seen in the*

*> > examples and my understanding of using TF1, what UnbinnedFit does*

*> > is fit a 'distribution' of events, not the relation between*

*> > different variables in the tree. If I am wrong, please point me*

*> > to an example of fitting the relation between two or more tree*

*> > variables.*

*> >*

*> > For now, for my specialized case, if TTreeFormula's Parameters*

*> > worked similarly to TFormula, I'm following the minexam.cxx*

*> > example and using my own fcnk0( ) which has to be modified by*

*> > hand for every case.*

*> >*

*> > As for an implementation of the 'Minimize' method/routine, it*

*> > would be something like what is below.*

*> >*

*> > Take care,*

*> > Rob Feuerbach*

/*************************************************** * Dr. Robert J. Feuerbach feuerbac_at_jlab.org * * 12000 Jefferson Avenue CEBAF Center A120 * * Suite 4 Office: (757) 269-7254 * * Newport News, VA 23606 Page: 584-7254 * * Fax: (757) 269-5703 Mailstop 12H3 * ***************************************************/Received on Thu Oct 12 2006 - 23:42:14 MEST

*
This archive was generated by hypermail 2.2.0
: Mon Jan 01 2007 - 16:32:01 MET
*