ROOT logo
void basic2() {
//   example of macro to create can ntuple reading data from an ascii file.
//   This macro is a variant of basic.C
//Author: Rene Brun   

   TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
   dir.ReplaceAll("basic2.C","");
   dir.ReplaceAll("/./","/");
   
   TFile *f = new TFile("basic2.root","RECREATE");
   TH1F *h1 = new TH1F("h1","x distribution",100,-4,4);
   TTree *T = new TTree("ntuple","data from ascii file");
   Long64_t nlines = T->ReadFile(Form("%sbasic.dat",dir.Data()),"x:y:z");
   printf(" found %lld points\n",nlines);
   T->Draw("x","z>2");
   T->Write();
}
 basic2.C:1
 basic2.C:2
 basic2.C:3
 basic2.C:4
 basic2.C:5
 basic2.C:6
 basic2.C:7
 basic2.C:8
 basic2.C:9
 basic2.C:10
 basic2.C:11
 basic2.C:12
 basic2.C:13
 basic2.C:14
 basic2.C:15
 basic2.C:16
 basic2.C:17
 basic2.C:18