How to fit individual peaks in a multi-peaked histogram

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;“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);

TF1 func(“func”, “gaus”,128.5,8191.5);

printf(“found %dpoints\n”,nlines);

ROOT Version: 6.16
Platform: Ubuntu
Compiler: Not Provided

Thanks for responding. But i’m a newbie to root and i could not be able to understand it properly. please help me in modifying my own program which i have posted above.

Check the guide:
7.3.2 and 7.3.3 may be what you need; in short, you split the histogram in x-axis ranges to fit each peak with a separate function and then combine all.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.