Re: Problem fitting histos

From: <perfetto_at_na.infn.it>
Date: Thu, 26 Jan 2012 09:53:27 +0100


Hi Eduard,

thanks for your help, but don't work.
I always got the same result:

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

Other ideas ?

Bye
Francesco

>
> Hi Francesco,
>
>
> On Wed, 25 Jan 2012, perfetto_at_na.infn.it wrote:
>
>> 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
>
> You don't need a bin and range, but you do need a name and title. Try
> this:
>
> TH1D *histo = new TH1D(Form("histo%1d",i),"Title",100,1,0); // the bin
> start is larger than bin end -> this will make binning automatic
> tv__tree->Draw( Form("-channels[%d].regions[0].integral >> histo%1d",
> i,i)
>
> Should work...
>
> Cheers
> Eduard
>
>
>
>> 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 Thu Jan 26 2012 - 09:53:35 CET

This archive was generated by hypermail 2.2.0 : Thu Jan 26 2012 - 11:50:01 CET