Re: How to ignore low statistic bins with TH1::Fit(TF1*, ...) ?

From: Rene Brun <brun_at_pcroot.cern.ch>
Date: Mon, 20 Jun 2005 19:02:19 +0200 (MEST)


Hi Pierre-Luc,

See example in tutorial fitExclude.C or small example below

Rene Brun

TH1F *h;
Double_t myfunc(Double_t *x, Double_t *par) {

    Int_t bin = h->GetXaxis()->FindBin(x[0]);     if (h->GetBinContent(bin) < 10) {

       TF1::RejectPoint();
       return 0;

    }
    return par[0]*TMath::Gaus(x[0],par[1],par[2]); }
void ignore() {

    h = new TH1F("h","test",100,-3,3);
    h->FillRandom("gaus",1500);
    TF1 *f1 = new TF1("f1",myfunc,-3,3,3);     f1->SetParameters(10,0,1);
    h->Fit("f1");
}

On Mon, 20 Jun
2005, Pierre-Luc Drouin wrote:

> I want to fit a TF1 function to a histogram using TH1::Fit(TF1*, ...).
> I would like the fit to ignore the bins having less than 10 entries. How
> can I do it?
>
> Thanks!
>
> Pierre-Luc Drouin
>
Received on Mon Jun 20 2005 - 19:02:37 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:09 MET