]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/CreateChain.C
Adding the files to create tags for the locally stored ESDs.
[u/mrichter/AliRoot.git] / PWG2 / CreateChain.C
CommitLineData
770b2d90 1//_________________________________________________________________________
2// Macro to create an esd chain and process it with a selector.
3// The macro takes as an argument the top directory where the
4// ESDs are stored. Then does the following:
5// o) Setup of the par file and load the library libESD.so.
6// o) Checks the directories that are one level down
7// o) If an AliESDs.root is found it adds it to the esd chain.
8// o) Then th chain is processed by the selector esdV0.C
9//_________________________________________________________________________
10void CreateChain(const char* fDataDir = "/home/pchrist/ALICE/PDC06/pp/data") {
11 TStopwatch timer;
12 timer.Start();
13
14 Char_t fWorkDir[256] = gSystem->pwd();
15 const char* pararchivename = "ESD";
16 //////////////////////////////////////////
17 // Libraries required to load
18 //////////////////////////////////////////
19
20 //////////////////////////////////////////////////////////////////
21 // Setup PAR File
22 if (pararchivename) {
23 char processline[1024];
24 sprintf(processline,".! tar xvzf %s.par",pararchivename);
25 gROOT->ProcessLine(processline);
26 gSystem->ChangeDirectory(pararchivename);
27
28 // check for BUILD.sh and execute
29 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
30 printf("*******************************\n");
31 printf("*** Building PAR archive ***\n");
32 printf("*******************************\n");
33
34 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
35 Error("batchSelector","Cannot Build the PAR Archive! - Abort!");
36 return -1;
37 }
38 }
39 // check for SETUP.C and execute
40 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
41 printf("*******************************\n");
42 printf("*** Setup PAR archive ***\n");
43 printf("*******************************\n");
44 gROOT->Macro("PROOF-INF/SETUP.C");
45 }
46
47 gSystem->ChangeDirectory("../");
48 }
49
50 // Create a Chain
51 TChain* fESDChain = new TChain("esdTree");
52 void *dirp = gSystem->OpenDirectory(fDataDir);
53
54 Char_t fPath[256];
55 const char * name = 0x0;
56 const char * dirname = 0x0;
57 const char * pattern = "AliESDs";
58
59 while(dirname = gSystem->GetDirEntry(dirp)) {
60 sprintf(fPath,"%s/%s",fDataDir,dirname);
61 TSystemDirectory* fSystemDir = new TSystemDirectory(".", fPath);
62 TList* dirList = fSystemDir->GetListOfFiles();
63 //loop over the dir entries - files
64 for(Int_t i = 0; i < dirList->GetEntries(); i++) {
65 TSystemFile* fFile = (TSystemFile*) dirList->At(i);
66 if(strstr(fFile->GetName(),pattern)) {
67 Char_t fESDFileName[256];
68 sprintf(fESDFileName,"%s/%s.root",fPath,pattern);
69 fESDChain->Add(fESDFileName);
70 }
71 }//loop over files
72 delete dirList;
73 delete fSystemDir;
74 }//loop over dirs
75
76 gSystem->ChangeDirectory(fWorkDir);
77 fESDChain->Process("esdV0.C");
78
79 timer.Stop();
80 timer.Print();
81}