]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/macros/AliReadESD.C
Obsolete file removed
[u/mrichter/AliRoot.git] / PHOS / macros / AliReadESD.C
1 #include "macros/AliReadESD.h"
2
3 //======================================================================================
4 TChain * AliReadESDfromdisk(const UInt_t eventsToRead, 
5                                    const TString dirName, 
6                                    const TString esdTreeName, 
7                                    const char *  pattern) 
8 {
9   // Reads ESDs from Disk
10  TChain *  rv = 0; 
11
12   AliInfo( Form("\nReading files in %s \nESD tree name is %s \nReading %d events", 
13                 dirName.Data(), esdTreeName.Data(), eventsToRead) ) ;
14   
15   // create a TChain of all the files 
16   TChain * cESDTree = new TChain(esdTreeName) ; 
17
18   // read from the directory file until the require number of events are collected
19   void * from = gSystem->OpenDirectory(dirName) ;
20   if (!from) {
21     AliError( Form("Directory %s does not exist") ) ;
22     rv = 0 ;
23   }
24   else{ // reading file names from directory
25     const char * subdir ; 
26     // search all subdirectories witch matching pattern
27     while( (subdir = gSystem->GetDirEntry(from))  && 
28            (cESDTree->GetEntries() < eventsToRead)) {
29       if ( strstr(subdir, pattern) != 0 ) { 
30         char file[200] ; 
31         sprintf(file, "%s%s/AliESDs.root", dirName.Data(), subdir);     
32         AliInfo( Form("Adding %s\n", file) );
33         cESDTree->Add(file) ;
34       }
35     } // while file
36   
37     AliInfo( Form(" %d events read", cESDTree->GetEntriesFast()) ) ;
38     rv = cESDTree ; 
39     
40   } // reading file names from directory
41   return rv ; 
42 }
43
44 //======================================================================================
45 TChain * AliReadESD(const UInt_t eventsToRead,
46                   const TString dirName, 
47                   const TString esdTreeName, 
48                   const char *  pattern)  
49 {
50   // Read AliESDs files and return a Chain of events
51  
52   if ( dirName == "" ) {
53     AliError("Give the name of the DIR where to find files") ; 
54     return 0 ; 
55   }
56   if ( esdTreeName == "" ) 
57     return AliReadESDfromdisk(eventsToRead, dirName) ;
58   else if ( strcmp(pattern, "") == 0 )
59     return AliReadESDfromdisk(eventsToRead, dirName, esdTreeName) ;
60   else 
61     return AliReadESDfromdisk(eventsToRead, dirName, esdTreeName, pattern) ;        
62 }