-TChain* CreateESDChainFromDir(const char* aDataDir, Int_t aRuns = 20, Bool_t aAddHeader = kTRUE)
+/* $Id$ */
+
+// Helper macros for creating chains
+
+TChain* CreateESDChainFromDir(const char* aDataDir, Int_t aRuns = 20, Int_t offset = 0)
{
+ // creates chain of files in a given directory. The structure is expected as:
+ // <aDataDir>/<dir0>/AliESDs.root
+ // <aDataDir>/<dir1>/AliESDs.root
+ // ...
+
if (!aDataDir)
return 0;
TChain* chain = new TChain("esdTree");
TChain* chaingAlice = 0;
- if (aAddHeader != kFALSE)
- chaingAlice = new TChain("TE");
-
TString execDir(gSystem->pwd());
TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
TList* dirList = baseDir->GetListOfFiles();
if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
continue;
+ if (offset > 0)
+ {
+ --offset;
+ continue;
+ }
+
if (count++ == aRuns)
break;
presentDirName += presentDir->GetName();
chain->Add(presentDirName + "/AliESDs.root/esdTree");
-
- if (aAddHeader != kFALSE)
- chaingAlice->Add(presentDirName + "/galice.root/TE");
}
- if (aAddHeader != kFALSE)
- chain->AddFriend(chaingAlice);
-
return chain;
}
-TChain* CreateESDChainFromList(const char* listFile, Int_t aRuns = 20, Bool_t aAddHeader = kTRUE)
+TChain* CreateESDChainFromList(const char* listFile, Int_t aRuns = 20, Int_t offset = 0)
{
+ // Creates a chain from a file which contains a list of ESD files
+
if (!listFile)
return 0;
TChain* chain = new TChain("esdTree");
TChain* chaingAlice = 0;
- if (aAddHeader != kFALSE)
- chaingAlice = new TChain("TE");
-
// Open the input stream
ifstream in;
in.open(listFile);
in >> esdfile;
if (!esdfile.Contains("root")) continue; // protection
+ if (offset > 0)
+ {
+ --offset;
+ continue;
+ }
+
if (count++ == aRuns)
break;
// add esd file
chain->Add(esdfile);
-
- // add header
- if (aAddHeader != kFALSE)
- {
- esdfile.ReplaceAll("AliESDs", "galice");
- chaingAlice->Add(esdfile + "/TE");
- }
}
in.close();
chain->Lookup();
- if (aAddHeader != kFALSE)
- {
- chaingAlice->Lookup();
- chain->AddFriend(chaingAlice);
- }
-
return chain;
}