3 // Helper macros for creating chains
5 TChain* CreateESDChainFromDir(const char* aDataDir, Int_t aRuns = 20, Int_t offset = 0, Bool_t aAddHeader = kTRUE)
7 // creates chain of files in a given directory. The structure is expected as:
8 // <aDataDir>/<dir0>/AliESDs.root
9 // <aDataDir>/<dir0>/galice.root (when <aAddHeader> flag is set)
10 // <aDataDir>/<dir1>/AliESDs.root
11 // <aDataDir>/<dir1>/galice.root (when <aAddHeader> flag is set)
17 TChain* chain = new TChain("esdTree");
18 TChain* chaingAlice = 0;
20 if (aAddHeader != kFALSE)
21 chaingAlice = new TChain("TE");
23 TString execDir(gSystem->pwd());
24 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
25 TList* dirList = baseDir->GetListOfFiles();
26 Int_t nDirs = dirList->GetEntries();
31 for (Int_t iDir=0; iDir<nDirs; ++iDir)
33 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
34 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
46 TString presentDirName(aDataDir);
47 presentDirName += "/";
48 presentDirName += presentDir->GetName();
50 chain->Add(presentDirName + "/AliESDs.root/esdTree");
52 if (aAddHeader != kFALSE)
53 chaingAlice->Add(presentDirName + "/galice.root/TE");
56 if (aAddHeader != kFALSE)
57 chain->AddFriend(chaingAlice);
62 TChain* CreateESDChainFromList(const char* listFile, Int_t aRuns = 20, Bool_t aAddHeader = kTRUE)
64 // Creates a chain from a file which contains a list of ESD files
65 // if <aAddHeader> is set, the filename of the galice.root file is created by replacing
66 // AliESDs to galice in the esd file name
71 TChain* chain = new TChain("esdTree");
72 TChain* chaingAlice = 0;
74 if (aAddHeader != kFALSE)
75 chaingAlice = new TChain("TE");
77 // Open the input stream
83 // Read the input list of files and add them to the chain
87 if (!esdfile.Contains("root")) continue; // protection
96 if (aAddHeader != kFALSE)
98 esdfile.ReplaceAll("AliESDs", "galice");
99 chaingAlice->Add(esdfile + "/TE");
107 if (aAddHeader != kFALSE)
109 chaingAlice->Lookup();
110 chain->AddFriend(chaingAlice);