// Helper macros for creating chains
-TChain* CreateESDChainFromDir(const char* aDataDir, Int_t aRuns = 20, Int_t offset = 0, Bool_t aAddHeader = kTRUE)
+TChain* CreateESDChain(const char* aDataDir, Int_t aRuns = 20, Int_t offset = 0)
{
- // creates chain of files in a given directory. The structure is expected as:
+ // creates chain of files in a given directory or file containing a list.
+ // In case of directory the structure is expected as:
// <aDataDir>/<dir0>/AliESDs.root
- // <aDataDir>/<dir0>/galice.root (when <aAddHeader> flag is set)
// <aDataDir>/<dir1>/AliESDs.root
- // <aDataDir>/<dir1>/galice.root (when <aAddHeader> flag is set)
// ...
if (!aDataDir)
return 0;
+ Long_t id, size, flags, modtime;
+ if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
+ {
+ print("%s not found.\n", 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();
- Int_t nDirs = dirList->GetEntries();
- gSystem->cd(execDir);
-
- Int_t count = 0;
-
- for (Int_t iDir=0; iDir<nDirs; ++iDir)
+ if (flags & 2)
{
- TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
- if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
- continue;
+ TString execDir(gSystem->pwd());
+ TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
+ TList* dirList = baseDir->GetListOfFiles();
+ Int_t nDirs = dirList->GetEntries();
+ gSystem->cd(execDir);
- if (offset > 0)
+ Int_t count = 0;
+
+ for (Int_t iDir=0; iDir<nDirs; ++iDir)
{
- --offset;
- continue;
- }
+ TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
+ if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
+ continue;
- if (count++ == aRuns)
- break;
+ if (offset > 0)
+ {
+ --offset;
+ continue;
+ }
- TString presentDirName(aDataDir);
- presentDirName += "/";
- presentDirName += presentDir->GetName();
+ if (count++ == aRuns)
+ break;
- chain->Add(presentDirName + "/AliESDs.root/esdTree");
+ TString presentDirName(aDataDir);
+ presentDirName += "/";
+ presentDirName += presentDir->GetName();
- if (aAddHeader != kFALSE)
- chaingAlice->Add(presentDirName + "/galice.root/TE");
+ chain->Add(presentDirName + "/AliESDs.root/esdTree");
+ }
}
+ else
+ {
+ // Open the input stream
+ ifstream in;
+ in.open(aDataDir);
- if (aAddHeader != kFALSE)
- chain->AddFriend(chaingAlice);
-
- return chain;
-}
-
-TChain* CreateESDChainFromList(const char* listFile, Int_t aRuns = 20, Bool_t aAddHeader = kTRUE)
-{
- // Creates a chain from a file which contains a list of ESD files
- // if <aAddHeader> is set, the filename of the galice.root file is created by replacing
- // AliESDs to galice in the esd file name
-
- 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);
-
- Int_t count = 0;
+ Int_t count = 0;
- // Read the input list of files and add them to the chain
- TString esdfile;
- while(in.good()) {
- in >> esdfile;
- if (!esdfile.Contains("root")) continue; // protection
+ // Read the input list of files and add them to the chain
+ TString esdfile;
+ while(in.good()) {
+ in >> esdfile;
+ if (!esdfile.Contains("root")) continue; // protection
- if (count++ == aRuns)
- break;
+ if (offset > 0)
+ {
+ --offset;
+ continue;
+ }
- // add esd file
- chain->Add(esdfile);
+ if (count++ == aRuns)
+ break;
- // add header
- if (aAddHeader != kFALSE)
- {
- esdfile.ReplaceAll("AliESDs", "galice");
- chaingAlice->Add(esdfile + "/TE");
+ // add esd file
+ chain->Add(esdfile);
}
- }
-
- in.close();
- chain->Lookup();
+ in.close();
- if (aAddHeader != kFALSE)
- {
- chaingAlice->Lookup();
- chain->AddFriend(chaingAlice);
+ chain->Lookup();
}
return chain;