hi,
i'm quite new to the philosophy of C++ (and thus root), so the solution
should be obvious for my problem, but i can't find it. poor me... :p
i have some files in the following structure on my disk
/corsika/light/file1.nt
file2.nt
/noise/file3.nt
/wimp/light/file4.nt
...
i want to get all these *.nt files (each of these have 4 columns of
floats) in one structure in root with the same hierarchy as on disk. is an
ntuple the best way to do it? i do not plan to add histograms or
non-float stuff to the root files.
the problem is that i don't know how to list directories and put them in
some sort of loop. gSystem->Exec("ls ") gives the dirs, but how do i put
them in a loop?
in this loop, i would again need to list all files in the directory and
fill them in ntuples. the filling of ntuples would go in the following way
(found on root site)
in.open("files/corsika/light/light.muon.L2.ama.mmc.corama.pcors.700XX.simu2001.AMAII.gz.nt");
Float_t om,adc,le,tot;
Int_t nlines = 0;
// put ntuple in this dir in rootfile
corsika->cd();
TNtuple *ntuple = new TNtuple("file1","light from L2.pcors","om:adc:le:tot");
while (1) {
in >> om >> adc >> le >> tot;
if (!in.good()) break;
ntuple->Fill(om,adc,le,tot);
nlines++;
}
every time i have a new file, i would change this in the
in.open("newfile"), change to the appropriate dir, and redo the ntuples
filling
how can i do this in practice? help is very welcome for this c++/root
beginner.
daan
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET