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 //_________________________________________________________________________
10 void CreateChain(const char* fDataDir = "/home/pchrist/ALICE/PDC06/pp/data") {
14 Char_t fWorkDir[256] = gSystem->pwd();
15 const char* pararchivename = "ESD";
16 //////////////////////////////////////////
17 // Libraries required to load
18 //////////////////////////////////////////
20 //////////////////////////////////////////////////////////////////
23 char processline[1024];
24 sprintf(processline,".! tar xvzf %s.par",pararchivename);
25 gROOT->ProcessLine(processline);
26 gSystem->ChangeDirectory(pararchivename);
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");
34 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
35 Error("batchSelector","Cannot Build the PAR Archive! - Abort!");
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");
47 gSystem->ChangeDirectory("../");
51 TChain* fESDChain = new TChain("esdTree");
52 void *dirp = gSystem->OpenDirectory(fDataDir);
55 const char * name = 0x0;
56 const char * dirname = 0x0;
57 const char * pattern = "AliESDs";
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);
76 gSystem->ChangeDirectory(fWorkDir);
77 fESDChain->Process("esdV0.C");