--- /dev/null
+#include "AliReadESD.h"
+
+//======================================================================================
+TChain * AliReadESDfromdisk(const UInt_t eventsToRead,
+ const TString dirName,
+ const TString esdTreeName,
+ const char * pattern)
+{
+ // Reads ESDs from Disk
+ TChain * rv = 0;
+
+ AliInfo( Form("\nReading files in %s \nESD tree name is %s \nReading %d events",
+ dirName.Data(), esdTreeName.Data(), eventsToRead) ) ;
+
+ // create a TChain of all the files
+ TChain * cESDTree = new TChain(esdTreeName) ;
+
+ // read from the directory file until the require number of events are collected
+ void * from = gSystem->OpenDirectory(dirName) ;
+ if (!from) {
+ AliError( Form("Directory %s does not exist") ) ;
+ rv = 0 ;
+ }
+ else{ // reading file names from directory
+ const char * file ;
+ // search all subdirectories witch matching pattern
+ while( (file = gSystem->GetDirEntry(from)) &&
+ (cESDTree->GetEntries() < eventsToRead)) {
+ if ( strstr(file, pattern) != 0 ) {
+ AliInfo( Form("Adding %s\n", file) );
+ cESDTree->Add(file) ;
+ }
+ } // while file
+
+ AliInfo( Form(" %d events read", cESDTree->GetEntriesFast()) ) ;
+ rv = cESDTree ;
+
+ } // reading file names from directory
+ return rv ;
+}
+
+//======================================================================================
+TChain * AliReadESD(const UInt_t eventsToRead,
+ const TString dirName,
+ const TString esdTreeName,
+ const char * pattern)
+{
+ // Read AliESDs files and return a Chain of events
+
+ if ( dirName == "" ) {
+ AliError("Give the name of the DIR where to find files") ;
+ return 0 ;
+ }
+ if ( esdTreeName == "" )
+ return AliReadESDfromdisk(eventsToRead, dirName) ;
+ else if ( strcmp(pattern, "") == 0 )
+ return AliReadESDfromdisk(eventsToRead, dirName, esdTreeName) ;
+ else
+ return AliReadESDfromdisk(eventsToRead, dirName, esdTreeName, pattern) ;
+}
--- /dev/null
+#if !defined(__CINT__) || defined(__MAKECINT__)
+
+// Root include files
+#include <Riostream.h>
+#include <TString.h>
+#include <TChain.h>
+#include <TSystem.h>
+
+// AliROOT include files
+#include <AliLog.h>
+
+#else
+#endif
+
+// Define global parameters
+const TString kgESDTreeName = "esdTree" ;
+const UInt_t kgeventsToRead = 1 ;
+const char * kgPattern = "Evt" ;
+
+TChain * AliReadESDfromdisk(const UInt_t eventsToRead,
+ const TString dirName,
+ const TString esdTreeName = kgESDTreeName,
+ const char * pattern = kgPattern) ;
+TChain * AliReadESD(const UInt_t eventsToRead = kgeventsToRead,
+ TString fileName = "",
+ const TString esdTreeName = kgESDTreeName,
+ const char * pattern = kgPattern ) ;
+
+// Needed for AliLog (return the macro name)
+char * ClassName() { return "macro" ; }
+