Re: looping over files

From: Valeri Fine (Faine) (fine@bnl.gov)
Date: Fri Mar 03 2000 - 17:19:42 MET


> Hi,
> 
> i would use *perl* to do the selection ... then use popen,
> TSystem::OpenPipe that is, to get the names in.
> eg.:
> #!/usr/bin/perl <<END_PERL
> @files = sort @ARGV;
> # some higher magick might be usefull ...
> print join("\n", @files);
> print "\n";
> END_PERL
> 
> and then use
> FILE* in = gSystem->OpenPipe("perlscript *.root", "r");
> while(!feof(in)) {
>  // read name ... open the file ... do magick
> }
> 
> or do the preselection in perl script itself ... which is even better.
> Then you can also pass other stuff to analyzing routine (like labels
> for Canvasen).
> 
> Not sure how this works on windooze ...
> 

 Hello, I guess I missed the original message.

 To loop over files one can use TSystem class with no "perl involve"

http://root.cern.ch/root/html/TSystem.html#TSystem:OpenDirectory
http://root.cern.ch/root/html/TSystem.html#TSystem:GetDirEntry
http://root.cern.ch/root/html/src/TSystem.cxx.html#TSystem:FreeDirectory

This works for any platform ROOT support. To make a selection ROOT class
TRegexp can be handy too.

http://root.cern.ch/root/html/TRegexp.html

One can see an example of how this can be employ:

http://www.star.bnl.gov/STAR/html/comp_l/root/html/St_FileSet.html

The class mentioned above is renamed into TFileSet and is included into
ROOT.CMZ 2.23/12. ROOT  team doesn't provide any  pre-compiled share
library yet. It is under development and it should be documented first.
If people want it just now I can provide further explanation and instruction.

               Valery





> ... there is more than one way to do it ...
> 
> Cheers,
> matevz
> 
> ---------------------------------------------------
>  Matevz Tadel,         E-mail: Matevz.Tadel@ijs.si 
>  Department of Experimental High Energy Physics F9 
>  Jozef Stefan Institute,  Jamova 39,  P.o.Box 3000 
>  SI-1001 Ljubljana, Slovenia                       
>  Tel.: +386-61-177-3674      Fax: +386-61-125-7074 
> ---------------------------------------------------
> 
> 
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:20 MET