I have drawn a histogram from .dat file by converting ascii(.dat) to root file format. Now my histogram is showing a number of peaks and i want to fit each peak individually(gaussian) but i don’t know how to do that?
help me!!!
#include “Riostream.h”
#include “TFile.h”
#include “TH1.h”
#include “TNtuple.h”
void hist()
{
ifstream in;
in.open(Form(“eu_gu_1.dat”));
Float_t x,y;
Int_t nlines= 0;
TFile*f= new TFile(“basic.root”,“RECREATE”);
TH1F *h1 = new TH1F(“h1”,“x distribution”,8063,128.5,8191.5);
TNtuple*ntuple= new TNtuple(“ntuple”,“data from asciifile”,“x:y”);
while (1)
{
in >> x>> y;
if (!in.good()) break;
if (nlines< 5)
printf(“x=%8f, y=%8f”,x,y);
h1->Fill(x,y);
ntuple->Fill(x,y);
nlines++;
}
TF1 func(“func”, “gaus”,128.5,8191.5);
h1->Fit(“func”,128.5,8191.5);
printf(“found %dpoints\n”,nlines);
in.close();
f->Write();
}
__
ROOT Version: 6.16
Platform: Ubuntu
Compiler: Not Provided