ROOT is an open source library created in 1994.
#977on PLDB | 30Years Old |
ROOT is an object-oriented program and library developed by CERN. It was originally designed for particle physics data analysis and contains several features specific to this field, but it is also used in other applications such as astronomy and data mining. Release 6.14.04 as of 2018-08-23. Read more on Wikipedia...
#include "Riostream.h"
void basic() {
// read file $ROOTSYS/tutorials/tree/basic.dat
// this file has 3 columns of float data
TString dir = gROOT->GetTutorialDir();
dir.Append("/tree/");
dir.ReplaceAll("/./","/");
ifstream in;
in.open(Form("%sbasic.dat",dir.Data()));
Float_t x,y,z;
Int_t nlines = 0;
auto f = TFile::Open("basic.root","RECREATE");
TH1F h1("h1","x distribution",100,-4,4);
TNtuple ntuple("ntuple","data from ascii file","x:y:z");
while (1) {
in >> x >> y >> z;
if (!in.good()) break;
if (nlines < 5) printf("x=%8f, y=%8f, z=%8f\n",x,y,z);
h1.Fill(x);
ntuple.Fill(x,y,z);
nlines++;
}
printf(" found %d points\n",nlines);
in.close();
f->Write();
}