]> git.uio.no Git - u/mrichter/AliRoot.git/blob - UNICOR/makechain.C
New class for AOD<->MC association
[u/mrichter/AliRoot.git] / UNICOR / makechain.C
1 // Author: Dariusz Miskowiec <mailto:d.miskowiec@gsi.de> 2008
2
3 //=============================================================================
4 TChain *makechainexp(char *exp, char *path, int nfil=1000000, int nskip=0) {
5   char treename[1000];
6   if (strcmp(exp,"ceres3c2")==0) sprintf(treename,"T");
7   if (strcmp(exp,"aliceesd")==0) sprintf(treename,"esdTree");
8   if (strcmp(exp,"cbm")==0) sprintf(treename,"cbmsim");
9   return makechain(treename, path, nfil, nskip);
10 }
11 //=============================================================================
12 TChain *makechain(char *name, char *path, int nfil=1000000, int nskip=0) {
13
14   // make chain of root files
15   // if path ends with "root" then add all these files; 
16   // otherwise interprete path as the list of files and add nfil files 
17   // after skipping nskip
18
19   printf("path=%s\n",path);
20
21   TChain *chain = new TChain(name);
22   TString str(path);
23   if (str.EndsWith("root")) chain->Add(path);
24   else {
25     fstream ascii_in;
26     ascii_in.open(path, ios::in);
27     char filnam[1000];
28     for (int i=0; i<nfil+nskip; i++) {
29       ascii_in >> filnam;
30       if (ascii_in.eof()) break;
31       if (i>=nskip) chain->Add(filnam);
32     }
33   }
34   chain->Lookup();
35   chain->GetListOfFiles()->Print();
36   return chain;
37 }
38 //=============================================================================