{ // example of macro to read data from an ascii file and // create a root file with an histogram and an ntuple. gROOT->Reset(); FILE *fp = fopen("/home/user/Amani/n-p-alpha-gamma __(1).txt","r"); Float_t Decay,N,NA,Z_f,N_f,Zc,N_c; Int_t ncols; Int_t nlines = 0; TFile *f = new TFile("file1.root","RECREATE"); TH1F *h1 = new TH1F("h1","x distribution",100,-400,400); TNtuple *data = new TNtuple("data","data from ascii file","Decay:N:NA:Z_f:N_f:Zc:N_c"); data.ReadFile("n-p-alpha-gamma __(1).txt"); while (1) { ncols = fscanf(fp,"%f %f %f %f %f %f %f",&Decay,&N,&NA,&Z_f,&N_f,&Zc,&N_c); if (ncols < 0) break; if (nlines < 5) printf("Decay=%8f, N=%8f, NA=%8f, Z_f=%8f, N_f=%8f, Zc=%8f, N_c=%8f ",Decay,N,NA,Z_f,N_f,Zc,N_c); h1->Fill(Decay); data->Fill(Decay,N,NA,Z_f,N_f,Zc,N_c); nlines++; } printf(" found %d points\n",nlines); fclose(fp); f->Write(); }