[ROOT] Reading Multiple Files Bug?

From: Jeffrey Reid (jgreid@u.washington.edu)
Date: Thu Nov 02 2000 - 00:08:12 MET


Hi all

  I have been using a little code bit I adapted from some roottalk posts
and I have found a weird bug.  I want to specify a directory, and have
ROOT find all of the relevant files (.ebe.root in my case) in that
directory and add them to my analysis chain.  

  The problem I am encountering is that in directories with many files
(around 700) the code below is finding some files multiple times (it ends
up double counting most of the files).  The bizzare thing is that if I
comment out the myChain->Add() command and just find the files without
adding them to the chain it only finds each file once and behaves as
expected.  I fixed this by adding an intermediate step that puts the files
in an array once found and then adds the files from the array to the chain
and it works without problems, but I thought I should point this out since
it look to be a bug to me.

Jeff

code fragment below...

ROOT_LEVEL : 2.25.01  running on RedHat Linux 6.1
------------------------------------------------------------------

  TChain *myChain = new TChain("myTree");

  Int_t nfiles = 0;
  Char_t *file;
  Char_t path_file[100];
  Char_t dirname[]="~/mydir/";

  void *dirhandle = gSystem->OpenDirectory(gSystem->ExpandPathName(dirname));
  while (file = gSystem->GetDirEntry(dirhandle)) {
    if (strstr(file,".ebe.root") != 0) {
      strcpy(path_file,dirname);
      strcat(path_file,file);
      myChain->Add(path_file);  // comment this line out and it works!!
      printf("file %d: %s\n",nfiles,path_file);
      nfiles++;
    }
  }

  if (nfiles == 0) {
    printf("No *.ebe.root files found in specified directory\n");
    break;
  }



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