#include #include #include "STDIO.H" #include "TH1.h" #include "TF1.h" #include "TFitter.h" #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) { //Histogram cration: int NBins= 200, keVMin= 0, keVMax= 200; TH1F *histResolEner= new TH1F("hErec", "hErec", NBins, keVMin, keVMax); //Read the data file: ifstream file("Data.txt"); const int nData= 60740; float Erec; for(int i=0; i< nData; i++){ file >> Erec; histResolEner->Fill(Erec); //Fill the histogram } // Fit the histogram without showing the canvas TF1*f1= new TF1("f1", "gaus", 115,155); histResolEner->Fit(f1, "0", "0", 115,155); cout << "Fit results:" << f1->GetParameter(0) << " " << f1->GetParameter(1) << " " << f1->GetParameter(2)<< " % \n" ; return 0; }