{ gROOT->Reset(); FILE *fp = fopen("./hits.txt","r"); Float_t pt,cu,d0,p0,z0,ct,goodtrack,sign,cell,offset,rplen,sina,sinatrad,cosa,aspc,tx,hitTV,hitD; Float_t weight,trackY,driftVx,driftVy,wireX,wireY,deriv0,deriv1,deriv2,deriv3,deriv4; Float_t deltaD,deltaY,layer,width,x,y,z,chi2; Int_t ncols,n1,n2,n3,n4; Int_t nlines = 0; TFile *f = new TFile("hits.root","RECREATE"); TNtuple *ntuple = new TNtuple("ntuple","data from ascii file","cu:d0:p0:z0:ct:cell:layer:sina:aspc:hitD:width:deltaY:x:y:z"); while (1) { n1 = fscanf(fp,"%f %f %f %f %f %f %f %f %f %f",&cu, &d0, &p0, &z0, &ct, &goodtrack, &sign, &cell, &offset, &rplen); n2 = fscanf(fp,"%f %f %f %f %f %f %f %f %f %f",&sina, &sinatrad, &cosa, &aspc, &tx, &hitTV, &hitD, &weight,&trackY,&driftVx); n3 = fscanf(fp,"%f %f %f %f %f %f %f %f %f %f",&driftVy,&wireX,&wireY, &deriv0, &deriv1, &deriv2, &deriv3, &deriv4, &deltaD,&deltaY); n4 = fscanf(fp,"%f %f %f %f %f %f", &layer,&width, &x, &y, &z,&chi2); ncols=n1+n2+n3+n4; if (ncols < 0) break; ntuple->Fill(cu,d0,p0,z0,ct,cell,layer,sina,aspc,hitD,width,deltaY,x,y,z); nlines++; } printf(" found %d points\n",nlines); fclose(fp); f->Write(); }