]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/scripts/MakeESDChain.C
removing the setting of AOD track references for TPC only tracks
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / scripts / MakeESDChain.C
1 void
2 ScanDirectory(TSystemDirectory* dir, TChain* chain, bool recursive)
3 {
4   // gROOT->IndentLevel();
5   // Printf("Scanning %s ...", dir->GetName());
6   // gROOT->IncreaseDirLevel();
7   
8   
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);
13
14   // Sort list of files and check if we should add it 
15   files->Sort();
16   TIter next(files);
17   TSystemFile* file = 0;
18   while ((file = static_cast<TSystemFile*>(next()))) {
19     TString name(file->GetName());
20     
21     // Ignore special links 
22     if (name == "." || name == "..") continue;
23
24     // Check if this is a directory 
25     if (file->IsDirectory()) { 
26       if (recursive) 
27         ScanDirectory(static_cast<TSystemDirectory*>(file),chain,recursive);
28       continue;
29     }
30     
31     // If this is not a root file, ignore 
32     if (!name.EndsWith(".root")) continue;
33
34     // If this file does not contain AliESDs, ignore 
35     if (!name.Contains("AliESDs")) continue;
36     
37     // Get the path 
38     TString esd(Form("%s/%s", file->GetTitle(), name.Data()));
39
40     // Print and add 
41     // gROOT->IndentLevel();
42     // Printf("adding %s", esd.Data());
43     chain->Add(esd);
44
45   }
46   // gROOT->DecreaseDirLevel();
47 }
48
49 TChain*
50 MakeESDChain(const char* esddir, bool recursive=false)
51 {
52   // --- Our data chain ----------------------------------------------
53   TChain* chain = new TChain("esdTree");
54
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);
60
61   // chain->GetListOfFiles()->ls();
62
63   return chain;
64 }