1 #include "AliReadESD.h"
3 //======================================================================================
4 TChain * AliReadESDfromdisk(const UInt_t eventsToRead,
6 const TString esdTreeName,
9 // Reads ESDs from Disk
12 AliInfo( Form("\nReading files in %s \nESD tree name is %s \nReading %d events",
13 dirName.Data(), esdTreeName.Data(), eventsToRead) ) ;
15 // create a TChain of all the files
16 TChain * cESDTree = new TChain(esdTreeName) ;
18 // read from the directory file until the require number of events are collected
19 void * from = gSystem->OpenDirectory(dirName) ;
21 AliError( Form("Directory %s does not exist") ) ;
24 else{ // reading file names from directory
26 // search all subdirectories witch matching pattern
27 while( (subdir = gSystem->GetDirEntry(from)) &&
28 (cESDTree->GetEntries() < eventsToRead)) {
29 if ( strstr(subdir, pattern) != 0 ) {
31 sprintf(file, "%s%s/AliESDs.root", dirName.Data(), subdir);
32 AliInfo( Form("Adding %s\n", file) );
37 AliInfo( Form(" %d events read", cESDTree->GetEntriesFast()) ) ;
40 } // reading file names from directory
44 //======================================================================================
45 TChain * AliReadESD(const UInt_t eventsToRead,
46 const TString dirName,
47 const TString esdTreeName,
50 // Read AliESDs files and return a Chain of events
52 if ( dirName == "" ) {
53 AliError("Give the name of the DIR where to find files") ;
56 if ( esdTreeName == "" )
57 return AliReadESDfromdisk(eventsToRead, dirName) ;
58 else if ( strcmp(pattern, "") == 0 )
59 return AliReadESDfromdisk(eventsToRead, dirName, esdTreeName) ;
61 return AliReadESDfromdisk(eventsToRead, dirName, esdTreeName, pattern) ;