37dbb69e |
1 | TChain* CreateESDChainFromDir(const char* aDataDir, Int_t aRuns = 20, Bool_t aAddHeader = kTRUE) |
539b6cb4 |
2 | { |
3 | if (!aDataDir) |
4 | return 0; |
5 | |
6 | TChain* chain = new TChain("esdTree"); |
7 | TChain* chaingAlice = 0; |
8 | |
9 | if (aAddHeader != kFALSE) |
10 | chaingAlice = new TChain("TE"); |
11 | |
12 | TString execDir(gSystem->pwd()); |
13 | TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir); |
14 | TList* dirList = baseDir->GetListOfFiles(); |
15 | Int_t nDirs = dirList->GetEntries(); |
16 | gSystem->cd(execDir); |
17 | |
49dc84d9 |
18 | Int_t count = 0; |
19 | |
539b6cb4 |
20 | for (Int_t iDir=0; iDir<nDirs; ++iDir) |
21 | { |
22 | TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir); |
23 | if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0) |
24 | continue; |
25 | |
49dc84d9 |
26 | if (count++ == aRuns) |
27 | break; |
28 | |
539b6cb4 |
29 | TString presentDirName(aDataDir); |
30 | presentDirName += "/"; |
31 | presentDirName += presentDir->GetName(); |
32 | |
33 | chain->Add(presentDirName + "/AliESDs.root/esdTree"); |
34 | |
35 | if (aAddHeader != kFALSE) |
36 | chaingAlice->Add(presentDirName + "/galice.root/TE"); |
37 | } |
38 | |
39 | if (aAddHeader != kFALSE) |
40 | chain->AddFriend(chaingAlice); |
41 | |
42 | return chain; |
43 | } |
37dbb69e |
44 | |
45 | TChain* CreateESDChainFromList(const char* listFile, Int_t aRuns = 20, Bool_t aAddHeader = kTRUE) |
46 | { |
47 | if (!listFile) |
48 | return 0; |
49 | |
50 | TChain* chain = new TChain("esdTree"); |
51 | TChain* chaingAlice = 0; |
52 | |
53 | if (aAddHeader != kFALSE) |
54 | chaingAlice = new TChain("TE"); |
55 | |
56 | // Open the input stream |
57 | ifstream in; |
58 | in.open(listFile); |
59 | |
60 | Int_t count = 0; |
61 | |
62 | // Read the input list of files and add them to the chain |
63 | TString esdfile; |
64 | while(in.good()) { |
65 | in >> esdfile; |
66 | if (!esdfile.Contains("root")) continue; // protection |
67 | |
68 | if (count++ == aRuns) |
69 | break; |
70 | |
71 | // add esd file |
72 | chain->Add(esdfile); |
73 | |
74 | // add header |
75 | if (aAddHeader != kFALSE) |
76 | { |
77 | esdfile.ReplaceAll("AliESDs", "galice"); |
78 | chaingAlice->Add(esdfile + "/TE"); |
79 | } |
80 | } |
81 | |
82 | in.close(); |
83 | |
84 | chain->Lookup(); |
85 | |
86 | if (aAddHeader != kFALSE) |
87 | { |
88 | chaingAlice->Lookup(); |
89 | chain->AddFriend(chaingAlice); |
90 | } |
91 | |
92 | return chain; |
93 | } |