Art,
see example below and also TFormula class description at:
http://root.cern.ch/root/htmldoc/TFormula.html
Rene Brun
void gg() {
//generating/fitting a histogram with the sum of 2 gaussians
TF1 *f1 = new TF1("f1","gaus(0) + gaus(3)",0,10);
f1->SetParameters(1,5,1,0.5,8,0.3);
TH1F *h1 = new TH1F("gg","hist from g+g",100,0,10);
h1->FillRandom("f1",10000);
f1->SetParameters(300,5,1,150,8,0.3);
h1->Fit("f1");
}
On
Fri, 1 Oct 2004, Arthur
E. Snyder wrote:
> Thanks again.
>
> Another question: Is it possible to do the equivalant of 'g+g' or 'g+p3'
> in paw? I see the "+" option but this seems to be just a set of
> independent fits to the same histogram (also a useful feature, but not the
> same thing).
>
> -Art
>
> A.E. Snyder, Group EC \!c*p?/
> SLAC Mail Stop #95 ((. .))
> Box 4349 |
> Stanford, Ca, USA, 94309 '\|/`
> e-mail:snyder@slac.stanford.edu o
> phone:650-926-2701 _
> http://www.slac.stanford.edu/~snyder BaBar
> FAX:650-926-2657 Collaboration
>
>
>
> On Fri, 1 Oct 2004, Rene Brun wrote:
>
> > Art,
> >
> > The "B" option is now documented. see my previous mail to roottalk
> >
> > and http://root.cern.ch/root/htmldoc/TH1.html#TH1:Fit
> >
> > Rene Brun
> >
> > On Fri,
> > 1 Oct 2004, Arthur E. Snyder wrote:
> >
> > > Thanks, Rene.
> > >
> > > Maybe "B" could be added to the list of available options in the
> > > description. I did find it down where initialization is described once I
> > > knew to look.
> > >
> > > -Thanks, Art
> > >
> > >
> > > A.E. Snyder, Group EC \!c*p?/
> > > SLAC Mail Stop #95 ((. .))
> > > Box 4349 |
> > > Stanford, Ca, USA, 94309 '\|/`
> > > e-mail:snyder@slac.stanford.edu o
> > > phone:650-926-2701 _
> > > http://www.slac.stanford.edu/~snyder BaBar
> > > FAX:650-926-2657 Collaboration
> > >
> > >
> > >
> > > On Fri, 1 Oct 2004, Rene Brun wrote:
> > >
> > > > Hi Art,
> > > >
> > > > Do not use SetNumber, but fit option "b".
> > > > Instead of
> > > > h->Fit(f);
> > > > do
> > > > h->Fit(f,"b");
> > > >
> > > > Rene Brun
> > > >
> > > > On Wed, 29 Sep 2004, Arthur E. Snyder wrote:
> > > >
> > > > > It looks like it might be possible to avoid the problem by using
> > > > > TF1::SetNumber to change the identification number. Sounds a little
> > > > > dangerous though .. but it works!
> > > > >
> > > > > root [14] f->SetNumber(13313)
> > > > > root [12] f->FixParameter(1,0.15)
> > > > > root [13] h->Fit(f)
> > > > > FCN=70133.3 FROM MIGRAD STATUS=CONVERGED 165 CALLS 166
> > > > > TOTAL
> > > > > EDM=1.52786e-07 STRATEGY= 1 ERROR MATRIX
> > > > > ACCURATE
> > > > > EXT PARAMETER STEP FIRST
> > > > > NO. NAME VALUE ERROR SIZE DERIVATIVE
> > > > > 1 Constant 3.55542e+01 1.29881e+00 1.02231e-01 6.94347e-04
> > > > > 2 Mean 1.50000e-01 fixed
> > > > > 3 Sigma 3.41244e-03 1.00248e-04 1.30824e-03 3.91318e-02
> > > > > (Int_t)0
> > > > > root [14]
> > > > >
> > > > >
> > > > > --The only place I find fNumber used is in TH1F where it indicates
> > > > > "specials". It's set to -1 to indicate use of an 'intrepreted function',
> > > > > so it seems reasonable safe to mess with it.
> > > > >
> > > > > --However, it would be more natural if attempt to set initial values was
> > > > > not used for 'fixed' parameters ..
> > > > >
> > > > > A.E. Snyder, Group EC \!c*p?/
> > > > > SLAC Mail Stop #95 ((. .))
> > > > > Box 4349 |
> > > > > Stanford, Ca, USA, 94309 '\|/`
> > > > > e-mail:snyder@slac.stanford.edu o
> > > > > phone:650-926-2701 _
> > > > > http://www.slac.stanford.edu/~snyder BaBar
> > > > > FAX:650-926-2657 Collaboration
> > > > >
> > > > >
> > > > >
> > > > > On Wed, 29 Sep 2004, federico wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I think you are using FixParameter with a missing argument, the value at
> > > > > > which you want the parameter to be fixed....
> > > > > >
> > > > > > virtual void <ListOfTypes.html#void> FixParameter
> > > > > > <#TF1:FixParameter>(Int_t <ListOfTypes.html#Int_t> ipar, Double_t
> > > > > > <ListOfTypes.html#Double_t> value)
> > > > > >
> > > > > > I can tell you I used it many times and it works....
> > > > > >
> > > > > > Cheers,
> > > > > > Federico
> > > > > >
> > > > > > Arthur E. Snyder wrote:
> > > > > >
> > > > > > >The command TF1::FixParameter does not seem to work. E.g.,:aroot [3] TH1F*
> > > > > > >h=gDirectory->FindObject("deltamgood")
> > > > > > >root [4] h
> > > > > > >(class TH1F*)0x975a090
> > > > > > >root [5] TF1* f=gROOT->GetFunction("gaus")
> > > > > > >root [6] f->SetParameter(1
> > > > > > >tab completion not implemented for this context
> > > > > > >root [6] f->SetParameter(1,0.15)
> > > > > > >root [7] f->SetParameter(2,0.001)
> > > > > > >root [8] f->FixParameter(2)
> > > > > > >root [10] f->Print()
> > > > > > > gaus : gaus Ndim= 1, Npar= 3, Noper= 1
> > > > > > > fExpr[0] = gaus fOper = 2001
> > > > > > > Par 0 Constant = 1
> > > > > > > Par 1 Mean = 0.15
> > > > > > > Par 2 Sigma = 0.001
> > > > > > >
> > > > > > >root [11] h->Fit(f)
> > > > > > > FCN=15572.3 FROM MIGRAD STATUS=CONVERGED 65 CALLS 66
> > > > > > >TOTAL
> > > > > > > EDM=1.89405e-08 STRATEGY= 1 ERROR MATRIX
> > > > > > >ACCURATE
> > > > > > > EXT PARAMETER STEP FIRST
> > > > > > > NO. NAME VALUE ERROR SIZE DERIVATIVE
> > > > > > > 1 Constant 4.53561e+03 3.22550e+01 1.16184e+00 -9.02437e-06
> > > > > > > 2 Mean 1.45671e-01 fixed
> > > > > > > 3 Sigma 7.46547e-04 4.27946e-06 4.88547e-05 -2.40157e-01
> > > > > > >(Int_t)0
> > > > > > >root [12] f->Print()
> > > > > > > gaus : gaus Ndim= 1, Npar= 3, Noper= 1
> > > > > > > fExpr[0] = gaus fOper = 2001
> > > > > > > Par 0 Constant = 4535.61
> > > > > > > Par 1 Mean = 0.145671
> > > > > > > Par 2 Sigma = 0.000746547
> > > > > > >root [13]
> > > > > > >
> > > > > > >--so you can see it has gone ahead and fit for the nominally fixed
> > > > > > >parameters.
> > > > > > >
> > > > > > >--the limits have in fact been set by FixParameters (see blow), but the
> > > > > > >fit doesn't seems to ignore it .. Minuit even thinks the parameter is
> > > > > > >"fixed" (see Minuit output above), but doesn't treat it has fixed.
> > > > > > >
> > > > > > >root [13] Double_t l,u
> > > > > > >root [14] f->GetParLimits(1,l,u)
> > > > > > >root [15] u
> > > > > > >(Double_t)1.49999999999999994e-01
> > > > > > >root [16] l
> > > > > > >(Double_t)1.49999999999999994e-01
> > > > > > >
> > > > > > >The error assigned to parameter 1 is 0, but it moved it!
> > > > > > >
> > > > > > >--Is this a known problem? Looks like a bug to me.
> > > > > > >
> > > > > > >-Art
> > > > > > >
> > > > > > >A.E. Snyder, Group EC \!c*p?/
> > > > > > >SLAC Mail Stop #95 ((. .))
> > > > > > >Box 4349 |
> > > > > > >Stanford, Ca, USA, 94309 '\|/`
> > > > > > >e-mail:snyder@slac.stanford.edu o
> > > > > > >phone:650-926-2701 _
> > > > > > >http://www.slac.stanford.edu/~snyder BaBar
> > > > > > >FAX:650-926-2657 Collaboration
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >On Wed, 22 Sep 2004, Chris Crawford wrote:
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >>Hi Victor,
> > > > > > >> Thanks! I replaced gPad with TVirtualPad::Pad(), and it works just
> > > > > > >>fine in CINT.
> > > > > > >>--Chris
> > > > > > >>
> > > > > > >>Victor Perevoztchikov wrote:
> > > > > > >>
> > > > > > >>
> > > > > > >>
> > > > > > >>>>>Could anyone please tell me what is wrong with the following little
> > > > > > >>>>>piece of code? I am using v4.00/08, linux redhat 8.0. I'm not sure it
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>gPad is not a variable. It is macro.
> > > > > > >>>#define gPad (TVirtualPad::Pad())
> > > > > > >>>CINT does not work with macros. For C++ your code is valid.
> > > > > > >>>Victor
> > > > > > >>>
> > > > > > >>>
> > > > > > >>>
> > > > > > >>>Victor M. Perevoztchikov perev@bnl.gov
> > > > > > >>>Brookhaven National Laboratory MS 510A PO Box 5000 Upton NY 11973-5000
> > > > > > >>>tel office : 631-344-7894; fax 631-344-4206;
> > > > > > >>>
> > > > > > >>>----- Original Message -----
> > > > > > >>>From: "Axel Naumann" <axel-naumann@gmx.de>
> > > > > > >>>To: "Chris Crawford" <chris2@lns.mit.edu>
> > > > > > >>>Cc: <roottalk@pcroot.cern.ch>
> > > > > > >>>Sent: Wednesday, September 22, 2004 5:51 PM
> > > > > > >>>Subject: Re: [ROOT] for + if + gPad problem?
> > > > > > >>>
> > > > > > >>>
> > > > > > >>>
> > > > > > >>>
> > > > > > >>>
> > > > > > >>>
> > > > > > >>>>Hi Chris,
> > > > > > >>>>this is due to cint's loop optimization. .O 0 prevents it.
> > > > > > >>>>Axel.
> > > > > > >>>>
> > > > > > >>>>Chris Crawford wrote:
> > > > > > >>>>
> > > > > > >>>>
> > > > > > >>>>
> > > > > > >>>>
> > > > > > >>>>>Hello,
> > > > > > >>>>>Could anyone please tell me what is wrong with the following little
> > > > > > >>>>>piece of code? I am using v4.00/08, linux redhat 8.0. I'm not sure it
> > > > > > >>>>>really has to do with gPad, that's just what I ran across.
> > > > > > >>>>>--thanks,
> > > > > > >>>>>Chris Crawford
> > > > > > >>>>>
> > > > > > >>>>>{
> > > > > > >>>>>new TCanvas("cv1","cv1");
> > > > > > >>>>>for (int x=0;x<2;x++) { //x=1;x<2;x++
> > > > > > >>>>> cout<<"gPad1="<<gPad<<endl;
> > > > > > >>>>> if (!x) cout<<"gPad2="<<gPad<<endl;
> > > > > > >>>>> if (x) cout<<"gPad3="<<gPad<<endl;
> > > > > > >>>>>}
> > > > > > >>>>>}
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>>>>
> > > > > > >>
> > > > > > >>
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:09 MET