Re: [ROOT] Fit over several subranges...

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Mar 08 2002 - 10:11:41 MET


Hi Matt,

Here is an example. Note that the function is still drawn in the excluded
range with the value set in the function (zero in this case).
You could compute the function and call TF1::RejectPoint
at the end of the function evaluation.

Rene Brun

Double_t fitf(Double_t *x, Double_t *par)
{
   if (TMath::Abs(x[0]) < 1 || TMath::Abs(x[0]) > 2) {
      TF1::RejectPoint();
      return 0;
   }

   Double_t arg = 0;
   if (par[2]) arg = (x[0] - par[1])/par[2];

   Double_t fitval = par[0]*TMath::Exp(-0.5*arg*arg);
   return fitval;
}
void rejectpoint()
{

   TH1F *hpx = new TH1F("hpx","px distribution",100,-4,4);
   hpx->FillRandom("gaus",25000);
   
   TF1 *func = new TF1("fitf",fitf,-4,4,3);
   func->SetParameters(100,0,1);
   func->SetParNames("Constant","Mean_value","Sigma");
   hpx->Fit("fitf");
}


Matt Palmer wrote:
> 
> Hi, could you give an example of this?  I can't quite see how its supposed to
> work with static functions
> 
> Thanks
> 
> Matt
> 
> On Thursday 28 February 2002  7:17 am, Rene Brun wrote:
> >Hi Yuriy,
> >
> >In version 3.02, I introduced a new function (static) in TF1:
> >see: http://root.cern.ch/root/htmldoc/TF1.html#TF1:RejectPoint
> >
> >This function is intended to be used in fits to reject some
> >disjoint ranges of a function.
> >
> >Rene Brun
> >
> >On Thu, 28 Feb 2002, Shitov Yuriy wrote:
> >> Hi, ROOTers
> >>
> >> I need to fit simultaneously several  non intersected parts (subranges)
> >> of histogram with single function. In my case it is linear
> >> backround, which is approximated by "pol1" function through all the
> >> spectrum. And ONE fit must be done SIMULTANEOUSLY over SEVERAL
> >> subranges of this spectrum,  where we have pure background. I can't fit
> >> ALL the spectrum due to a lot of lines with unknown structure.
> >> How can I do this?  Is there possibility to skeep some histogram bins
> >> during fitting?
> >>
> >> Best wishes,
> >> Yuriy.



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:45 MET