{ // 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/work4/336MeV1.txt","r"); Float_t Decay1,N1,NA1,Z_f1,N_f1,Zc1,N_c1; if (Decay1=1,4) A=0,Z=0 if (Decay1=2) A=1,Z=1 if (Decay1=3) A=4,Z=2 Int_t ncols; Int_t nlines = 0; TFile *f = new TFile("336MeV1.root","RECREATE"); TH1F *h1 = new TH1F("h1","x distribution",100,-400,400); TNtuple *bahl = new TNtuple("bahl","data from ascii file","Decay1:N1:NA1:Z_f1:N_f1:Zc1:N_c1"); bahl.ReadFile("336MeV1.txt"); while (1) { ncols = fscanf(fp,"%f %f %f %f %f %f %f",&Decay1,&N1,&NA1,&Z_f1,&N_f1,&Zc1,&N_c1); if (ncols < 0) break; if (nlines < 5) printf("Decay1=%8f, N1=%8f, NA1=%8f, Z_f1=%8f, N_f1=%8f, Zc1=%8f, N_c1=%8f ",Decay1,N1,NA1,Z_f1,N_f1,Zc1,N_c1); h1->Fill(Decay1); bahl->Fill(Decay1,N1,NA1,Z_f1,N_f1,Zc1,N_c1); nlines++; } printf(" found %d points\n",nlines); fclose(fp); f->Write(); }