Make the macros run for PROOF and PROOFLite
[u/mrichter/AliRoot.git] / PWG2 / FEMTOSCOPY / macros / Proof / runProof.C
1 void runProof(const char *chainlistfile, int nEvents=0, int offset=0, int domc=0, int prooflite=0) {
2   TStopwatch timer;
3   timer.Start();
4   
5   printf("*** Open PROOF ***");
6   if (prooflite) 
7     TProof::Open("");
8   else
9     TProof::Open("alicecaf");
10
11   gSystem->Load("libProofPlayer.so");
12   gSystem->Load("libVMC.so");
13   gSystem->Load("libXMLIO.so");
14
15   gProof->UploadPackage("STEERBase.par");
16   gProof->EnablePackage("STEERBase");
17   gProof->UploadPackage("ESD.par");
18   gProof->EnablePackage("ESD");
19   gProof->UploadPackage("AOD.par");
20   gProof->EnablePackage("AOD");
21   gProof->UploadPackage("ANALYSIS.par");
22   gProof->EnablePackage("ANALYSIS");
23   gProof->UploadPackage("ANALYSISalice.par");
24   gProof->EnablePackage("ANALYSISalice");
25   gProof->UploadPackage("PWG2AOD.par");
26   gProof->EnablePackage("PWG2AOD");
27   gProof->UploadPackage("PWG2femtoscopy.par");
28   gProof->EnablePackage("PWG2femtoscopy");
29   gProof->UploadPackage("PWG2femtoscopyUser.par");
30   gProof->EnablePackage("PWG2femtoscopyUser");
31     
32   gSystem->SetIncludePath("-I$ROOTSYS/include -I./STEERBase/ -I./ESD/ -I./AOD/ -I./ANALYSIS/ -I./ANALYSISalice/ -I./PWG2AOD/AOD -I./PWG2femtoscopy/FEMTOSCOPY/AliFemto -I./PWG2femtoscopyUser/FEMTOSCOPY/AliFemtoUser");
33   gProof->Exec(".L AddTaskFemto.C",kTRUE);
34   gROOT->LoadMacro("AddTaskFemto.C");
35   cout << "Loaded AddTaskFemto macro "<< endl;
36
37   gProof->ShowEnabledPackages();
38
39   //ANALYSIS PART
40   TChain *chain = 0x0;
41   if (prooflite) {
42     gROOT->LoadMacro("CreateESDChain.C");
43     chain = CreateESDChain(chainlistfile,10000);
44   }
45
46   //____________________________________________//
47   // Make the analysis manager
48   AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
49   AliESDInputHandler* esdH = new AliESDInputHandler;
50
51   esdH->SetInactiveBranches("FMD CaloCluster");
52   mgr->SetInputEventHandler(esdH);  
53
54   if (domc) {
55     AliMCEventHandler *mcH = new AliMCEventHandler;
56     mgr->SetMCtruthEventHandler(mcH);
57   }
58   //____________________________________________//
59   // 1st Pt task
60
61   AliAnalysisTaskFemto *taskfemto = AddTaskFemto();
62
63   if (!mgr->InitAnalysis()) return;
64   mgr->PrintStatus();
65   if (prooflite) 
66     mgr->StartAnalysis("proof",chain,2000000,0);
67   else 
68     mgr->StartAnalysis("proof",chainlistfile,nEvents,offset);
69
70   timer.Stop();
71   timer.Print();
72 }
73
74 Int_t setupPar(const char* pararchivename) {
75   ///////////////////
76   // Setup PAR File//
77   ///////////////////
78   if (pararchivename) {
79     char processline[1024];
80     sprintf(processline,".! tar xvzf %s.par",pararchivename);
81     gROOT->ProcessLine(processline);
82     const char* ocwd = gSystem->WorkingDirectory();
83     gSystem->ChangeDirectory(pararchivename);
84
85     // check for BUILD.sh and execute
86     if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
87       printf("*******************************\n");
88       printf("*** Building PAR archive    ***\n");
89       printf("*******************************\n");
90
91       if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
92         Error("runProcess","Cannot Build the PAR Archive! - Abort!");
93         return -1;
94       }
95     }
96     // check for SETUP.C and execute
97     if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
98       printf("*******************************\n");
99       printf("*** Setup PAR archive       ***\n");
100       printf("*******************************\n");
101       gROOT->Macro("PROOF-INF/SETUP.C");
102     }
103     
104     gSystem->ChangeDirectory("../");
105   }
106
107   return 1;
108 }