This is what happens with the “fcntl.h” message. I have attached the code to see if you get the same error. Thank you,
Cristian
root [4] .x peakfit.C
Note: File “fcntl.h” already loaded
filename: fakedata
Warning in TH1::Build: Replacing existing histogram: h1 (Potential memory leak).
root [5]
The fakedata file is just a text file with integer data organize in either row or columns separated by spaces.
{
/* This Macro Creates a Histogram
of Type TH1I (integers) by reading
as input ascii text files containing
two columns: CHANNEL/COUNTS
--------------------------------------*/
gROOT->Reset();
//SYSTEM include files
//ROOT include files
#include <fcntl.h>
#include <TSpectrum.h>
#include <TPolyMarker.h>
#include <TMath.h>
#include <TAxis.h>
#include <TStyle.h>
#include <TAttLine.h>
#include <TH1.h>
//DEFINES for the program
#define MAX_COL 8;
#define MAX_MCA 16384;
/----------------------------------------------
VARIABLES FOR READING ASCII DATA
------------------------------------------------/
const char *filename = new char [50];
FILE *fp;
int ptmp;
int i=0, nbins;
int buffer[MAX_MCA]; //nbins <= MAX_MCA
/--------------------------------------
GET FILENAME
----------------------------------------/
printf("%s",“filename: “);
scanf(”%s”, filename);
if ((fp = fopen(filename,“r”)) == NULL)
printf("%s", “File not found!\n”);
/*-------------------------------------------------
READ FILE AND WRITE INTO buffer ARRAY
---------------------------------------------------/
nbins=0;
while ( fscanf(fp,"%d",&ptmp) != EOF )
buffer[nbins++] = ptmp;
//--------------------------------------//
//FILL HISTOGRAM *h1 WITH *buffer
//--------------------------------------//
TH1I *h1 = new TH1I(“h1”,"",nbins,0,nbins);
for(i=0;i<nbins;i++)h1->SetBinContent(i+1,buffer[i]);
xaxis = h1->GetXaxis();
xaxis->SetTitle(“Channel”);
xaxis->CenterTitle();
yaxis = h1->GetYaxis();
yaxis->SetTitle(“Relative Counts”);
yaxis->CenterTitle();
TCanvas *S = new TCanvas(“S”,“Spectra”,6);
S.SetLogy();
h1->Draw();
}