2 ScanDirectory(TSystemDirectory* dir, TChain* chain, bool recursive)
4 // gROOT->IndentLevel();
5 // Printf("Scanning %s ...", dir->GetName());
6 // gROOT->IncreaseDirLevel();
9 // Get list of files, and go back to old working directory
10 TString oldDir(gSystem->WorkingDirectory());
11 TList* files = dir->GetListOfFiles();
12 gSystem->ChangeDirectory(oldDir);
14 // Sort list of files and check if we should add it
17 TSystemFile* file = 0;
18 while ((file = static_cast<TSystemFile*>(next()))) {
19 TString name(file->GetName());
21 // Ignore special links
22 if (name == "." || name == "..") continue;
24 // Check if this is a directory
25 if (file->IsDirectory()) {
27 ScanDirectory(static_cast<TSystemDirectory*>(file),chain,recursive);
31 // If this is not a root file, ignore
32 if (!name.EndsWith(".root")) continue;
34 // If this file does not contain AliESDs, ignore
35 if (!name.Contains("AliESDs")) continue;
38 TString esd(Form("%s/%s", file->GetTitle(), name.Data()));
41 // gROOT->IndentLevel();
42 // Printf("adding %s", esd.Data());
46 // gROOT->DecreaseDirLevel();
50 MakeESDChain(const char* esddir, bool recursive=false)
52 // --- Our data chain ----------------------------------------------
53 TChain* chain = new TChain("esdTree");
55 // --- Get list of ESDs --------------------------------------------
56 // Open source directory, and make sure we go back to were we were
57 TString oldDir(gSystem->WorkingDirectory());
58 TSystemDirectory d(esddir, esddir);
59 ScanDirectory(&d, chain, recursive);
61 // chain->GetListOfFiles()->ls();