Problem fitting histos

From: <perfetto_at_na.infn.it>
Date: Wed, 25 Jan 2012 18:48:08 +0100


Hi All,

I don't be able to fitting and save some variables of a tree that I put in a histo.
The following the part of my code that should do this... But when I run it:

.L Fit.C
fit_peak()

I got the following result:
<TCanvas::MakeDefCanvas>: created default TCanvas with name c1 Warning in <Fit>: Fit data is empty
0
Warning in <Fit>: Fit data is empty
0
Warning in <Fit>: Fit data is empty
0
Warning in <Fit>: Fit data is empty
0

and ROOT open an empty canvas.
Is there anyone can help me ?

I use ROOT 5.26/00 on Scientific Linux 5

Thanks in advance
Francesco.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <TH1>

void fit_peak() {

  ofstream out;
...
  TFile *_file0 = TFile::Open("/data/singlepe/Run000470.root");

  TTree *tv__tree = (TTree *) gROOT->FindObject("Events");

  Double_t res_fit;
  TF1 *f = new TF1("f","gaus");

  for (Int_t i = 0; i < 4; i++) {
    TH1D *histo = new TH1D(); // <------ I don't put bin and range because  I do not know in

                                                                   what
range
the
histo
lives.

    tv__tree->Draw( Form("-channels[%d].regions[0].integral >> histo", i) );

    histo->Fit(f);

    res_fit = f->GetParameter(i);

    out.open("result_fit_from_to.txt", ios::out | ios::app);

    out << setw(8) << setprecision(5) << f->GetParameter(1);
    out << setw(8) << setprecision(5) << f->GetParameter(2);
    out << setw(8) << setprecision(5) << f->GetParameter(3);
    out << endl;

    out.close();
    histo->Delete();
  }
....
....
} Received on Wed Jan 25 2012 - 18:48:13 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 25 2012 - 23:50:01 CET