Adding the QA plot for the pid efficiency/contamination vs the number of TPC points...
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / macros / runProtonAnalysisQA.C
1 void runProtonAnalysisQA(const char* esdAnalysisType = "Hybrid",
2                          const char* pidMode = "Bayesian") {
3   //Macro to run the proton QA analysis tested for local, proof & GRID.
4   //Local: Takes four arguments, the analysis mode, the type of the ESD 
5   //       analysis, the PID mode and the path where the tag and ESD or 
6   //       AOD files reside.
7   //Interactive: Takes four arguments, the analysis mode, the type of the ESD 
8   //             analysis, the PID mode and the name of the collection of tag 
9   //             files.
10   //Batch: Takes four arguments, the analysis mode, the type of the ESD 
11   //       analysis, the PID mode and the name of the collection file with 
12   //       the event list for each file.
13   //Proof: Takes five arguments, the analysis level, the analysis mode in 
14   //       case of ESD, the PID mode, the number of events and the dataset 
15   //       name and .  
16   //Analysis mode can be: "MC", "ESD", "AOD"
17   //ESD analysis type can be one of the three: "TPC", "Hybrid", "Global"
18   //PID mode can be one of the four: "Bayesian" (standard Bayesian approach) 
19   //   "Ratio" (ratio of measured over expected/theoretical dE/dx a la STAR) 
20   //   "Sigma1" (N-sigma area around the fitted dE/dx vs P band)
21   //   "Sigma2" (same as previous but taking into account the No of TPC points)
22   TStopwatch timer;
23   timer.Start();
24   
25   runLocal("ESD",
26            esdAnalysisType,
27            pidMode,
28            "/home/pchrist/ALICE/Baryons/QA/Local");
29   //runProof("ESD",esdAnalysisType,pidMode,200000,"/COMMON/COMMON/LHC08c11_10TeV_0.5T");
30   //runInteractive("ESD",esdAnalysisType,pidMode,"wn.xml");
31   //runBatch("ESD",esdAnalysisType,pidMode,"wn.xml");
32
33   timer.Stop();
34   timer.Print();
35 }
36
37 //_________________________________________________//
38 void runLocal(const char* mode = "ESD",
39               const char* analysisType = 0x0,
40               const char* pidMode = 0x0,
41               const char* path = 0x0) {
42   TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
43   outputFilename1 += ".root"; //main QA file
44   TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
45   outputFilename2 += ".root"; //MC process QA
46   TString outputFilename3 = "Protons.QA.Histograms."; 
47   outputFilename3 += analysisType;
48   outputFilename3 += ".root"; //Accepted cut distributions
49   TString outputFilename4 = "Protons.Efficiency."; 
50   outputFilename4 += analysisType;
51   outputFilename4 += ".root"; //Reco and PID efficiency
52   TString outputFilename5 = "Vertex.QA.root"; //vertex QA
53
54   gSystem->Load("libProofPlayer.so");
55
56   //Setup the par files
57   setupPar("STEERBase");
58   gSystem->Load("libSTEERBase.so");
59   setupPar("ESD");
60   gSystem->Load("libESD.so");
61   setupPar("AOD");
62   gSystem->Load("libAOD.so");
63   setupPar("ANALYSIS");
64   gSystem->Load("libANALYSIS.so");
65   setupPar("ANALYSISalice");
66   gSystem->Load("libANALYSISalice.so");
67   setupPar("CORRFW");
68   gSystem->Load("libCORRFW.so");
69   setupPar("PWG2spectra");
70   gSystem->Load("libPWG2spectra.so");
71
72    //____________________________________________//
73   AliTagAnalysis *tagAnalysis = new AliTagAnalysis("ESD"); 
74   tagAnalysis->ChainLocalTags(path);
75
76   AliRunTagCuts *runCuts = new AliRunTagCuts();
77   AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
78   AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
79   AliEventTagCuts *evCuts = new AliEventTagCuts();
80   
81   TChain* chain = 0x0;
82   chain = tagAnalysis->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
83   chain->SetBranchStatus("*Calo*",0);
84
85   //____________________________________________//
86   gROOT->LoadMacro("configProtonAnalysis.C");
87   AliProtonQAAnalysis *analysis = GetProtonQAAnalysisObject(mode,
88                                                             analysisType,
89                                                             pidMode);
90   //____________________________________________//
91   // Make the analysis manager
92   AliAnalysisManager *mgr = new AliAnalysisManager("protonAnalysisQAManager");
93   AliVEventHandler* esdH = new AliESDInputHandler;
94   mgr->SetInputEventHandler(esdH);
95   AliMCEventHandler *mc = new AliMCEventHandler();
96   mgr->SetMCtruthEventHandler(mc);
97   
98   //____________________________________________//
99   // 1st Proton task
100   AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
101   taskProtonsQA->SetAnalysisObject(analysis);
102   mgr->AddTask(taskProtonsQA);
103
104   // Create containers for input/output
105   AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("dataChain",
106                                                            TChain::Class(),
107                                                            AliAnalysisManager::kInputContainer);
108   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("globalQAList", 
109                                                             TList::Class(),
110                                                             AliAnalysisManager::kOutputContainer,
111                                                             outputFilename1.Data());
112   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("pdgCodeList", 
113                                                             TList::Class(),
114                                                             AliAnalysisManager::kOutputContainer,
115                                                             outputFilename2.Data());
116   AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("mcProcessList", 
117                                                             TList::Class(),
118                                                             AliAnalysisManager::kOutputContainer,
119                                                             outputFilename2.Data());
120   AliAnalysisDataContainer *coutput4 = mgr->CreateContainer("acceptedCutList", 
121                                                             TList::Class(),
122                                                             AliAnalysisManager::kOutputContainer,
123                                                             outputFilename3.Data());
124   AliAnalysisDataContainer *coutput5 = mgr->CreateContainer("rejectedCutList", 
125                                                             TList::Class(),
126                                                             AliAnalysisManager::kOutputContainer,
127                                                             outputFilename3.Data());
128   AliAnalysisDataContainer *coutput6 = mgr->CreateContainer("acceptedDCAList", 
129                                                             TList::Class(),
130                                                             AliAnalysisManager::kOutputContainer,
131                                                             outputFilename3.Data());
132   AliAnalysisDataContainer *coutput7 = mgr->CreateContainer("efficiencyList", 
133                                                             TList::Class(),
134                                                             AliAnalysisManager::kOutputContainer,
135                                                             outputFilename4.Data());
136   AliAnalysisDataContainer *coutput8 = mgr->CreateContainer("vertexList", 
137                                                             TList::Class(),
138                                                             AliAnalysisManager::kOutputContainer,
139                                                             outputFilename5.Data());
140   
141   //____________________________________________//
142   mgr->ConnectInput(taskProtonsQA,0,cinput1);
143   mgr->ConnectOutput(taskProtonsQA,0,coutput1);
144   mgr->ConnectOutput(taskProtonsQA,1,coutput2);
145   mgr->ConnectOutput(taskProtonsQA,2,coutput3);
146   mgr->ConnectOutput(taskProtonsQA,3,coutput4);
147   mgr->ConnectOutput(taskProtonsQA,4,coutput5);
148   mgr->ConnectOutput(taskProtonsQA,5,coutput6);
149   mgr->ConnectOutput(taskProtonsQA,6,coutput7);
150   mgr->ConnectOutput(taskProtonsQA,7,coutput8);
151   if (!mgr->InitAnalysis()) return;
152   mgr->PrintStatus();
153   mgr->StartAnalysis("local",chain);
154 }
155
156 //_________________________________________________//
157 void runInteractive(const char* mode = "ESD",
158                     const char* analysisType = 0x0,
159                     const char* pidMode = 0x0,
160                     const char* collectionName = "tag.xml") {
161   TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
162   outputFilename1 += ".root"; //main QA file
163   TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
164   outputFilename2 += ".root"; //MC process QA
165   TString outputFilename3 = "Protons.QA.Histograms."; 
166   outputFilename3 += analysisType;
167   outputFilename3 += ".root"; //Accepted cut distributions
168   TString outputFilename4 = "Protons.Efficiency."; 
169   outputFilename4 += analysisType;
170   outputFilename4 += ".root"; //Reco and PID efficiency
171   TString outputFilename5 = "Vertex.QA.root"; //vertex QA
172
173   TGrid::Connect("alien://");
174
175   //Setup the par files
176   setupPar("STEERBase");
177   gSystem->Load("libSTEERBase.so");
178   setupPar("ESD");
179   gSystem->Load("libESD.so");
180   setupPar("AOD");
181   gSystem->Load("libAOD.so");
182   setupPar("ANALYSIS");
183   gSystem->Load("libANALYSIS.so");
184   setupPar("ANALYSISalice");
185   gSystem->Load("libANALYSISalice.so");
186   setupPar("CORRFW");
187   gSystem->Load("libCORRFW.so");
188   setupPar("PWG2spectra");
189   gSystem->Load("libPWG2spectra.so");
190
191   //____________________________________________//
192   AliTagAnalysis *tagAnalysis = new AliTagAnalysis("ESD");
193  
194   AliRunTagCuts *runCuts = new AliRunTagCuts();
195   AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
196   AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
197   AliEventTagCuts *evCuts = new AliEventTagCuts();
198  
199   //grid tags
200   TAlienCollection* coll = TAlienCollection::Open(collectionName);
201   TGridResult* TagResult = coll->GetGridResult("",0,0);
202   tagAnalysis->ChainGridTags(TagResult);
203   TChain* chain = 0x0;
204   chain = tagAnalysis->QueryTags(runCuts,lhcCuts,detCuts,evCuts);
205   chain->SetBranchStatus("*Calo*",0);
206
207   //____________________________________________//
208   gROOT->LoadMacro("configProtonAnalysis.C");
209   AliProtonQAAnalysis *analysis = GetProtonQAAnalysisObject(mode,
210                                                             analysisType,
211                                                             pidMode);
212   //____________________________________________//
213   // Make the analysis manager
214   AliAnalysisManager *mgr = new AliAnalysisManager("protonAnalysisQAManager");
215   AliVEventHandler* esdH = new AliESDInputHandler;
216   mgr->SetInputEventHandler(esdH);
217   AliMCEventHandler *mc = new AliMCEventHandler();
218   mgr->SetMCtruthEventHandler(mc);
219   
220   //____________________________________________//
221   // 1st Proton task
222   AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
223   taskProtonsQA->SetAnalysisObject(analysis);
224   mgr->AddTask(taskProtonsQA);
225
226   // Create containers for input/output
227   AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
228   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("globalQAList", 
229                                                             TList::Class(),
230                                                             AliAnalysisManager::kOutputContainer,
231                                                             outputFilename1.Data());
232   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("pdgCodeList", 
233                                                             TList::Class(),
234                                                             AliAnalysisManager::kOutputContainer,
235                                                             outputFilename2.Data());
236   AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("mcProcessList", 
237                                                             TList::Class(),
238                                                             AliAnalysisManager::kOutputContainer,
239                                                             outputFilename2.Data());
240   AliAnalysisDataContainer *coutput4 = mgr->CreateContainer("acceptedCutList", 
241                                                             TList::Class(),
242                                                             AliAnalysisManager::kOutputContainer,
243                                                             outputFilename3.Data());
244   AliAnalysisDataContainer *coutput5 = mgr->CreateContainer("rejectedCutList", 
245                                                             TList::Class(),
246                                                             AliAnalysisManager::kOutputContainer,
247                                                             outputFilename3.Data());
248   AliAnalysisDataContainer *coutput6 = mgr->CreateContainer("acceptedDCAList", 
249                                                             TList::Class(),
250                                                             AliAnalysisManager::kOutputContainer,
251                                                             outputFilename3.Data());
252   AliAnalysisDataContainer *coutput7 = mgr->CreateContainer("efficiencyList", 
253                                                             TList::Class(),
254                                                             AliAnalysisManager::kOutputContainer,
255                                                             outputFilename4.Data());
256   AliAnalysisDataContainer *coutput8 = mgr->CreateContainer("vertexList", 
257                                                             TList::Class(),
258                                                             AliAnalysisManager::kOutputContainer,
259                                                             outputFilename5.Data());
260
261   //____________________________________________//
262   mgr->ConnectInput(taskProtonsQA,0,cinput1);
263   mgr->ConnectOutput(taskProtonsQA,0,coutput1);
264   mgr->ConnectOutput(taskProtonsQA,1,coutput2);
265   mgr->ConnectOutput(taskProtonsQA,2,coutput3);
266   mgr->ConnectOutput(taskProtonsQA,3,coutput4);
267   mgr->ConnectOutput(taskProtonsQA,4,coutput5);
268   mgr->ConnectOutput(taskProtonsQA,5,coutput6);
269   mgr->ConnectOutput(taskProtonsQA,6,coutput7);
270   mgr->ConnectOutput(taskProtonsQA,7,coutput8);
271   if (!mgr->InitAnalysis()) return;
272   mgr->PrintStatus();
273   mgr->StartAnalysis("local",chain);
274 }
275
276 //_________________________________________________//
277 void runBatch(const char* mode = "ESD",
278               const char* analysisType = 0x0,
279               const char* pidMode = 0x0,
280               const char *collectionfile = "wn.xml") {
281   TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
282   outputFilename1 += ".root"; //main QA file
283   TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
284   outputFilename2 += ".root"; //MC process QA
285   TString outputFilename3 = "Protons.QA.Histograms."; 
286   outputFilename3 += analysisType;
287   outputFilename3 += ".root"; //Accepted cut distributions
288   TString outputFilename4 = "Protons.Efficiency."; 
289   outputFilename4 += analysisType;
290   outputFilename4 += ".root"; //Reco and PID efficiency
291   TString outputFilename5 = "Vertex.QA.root"; //vertex QA
292
293   TGrid::Connect("alien://");
294   gSystem->Load("libProofPlayer.so");
295
296   //Setup the par files
297   setupPar("STEERBase");
298   gSystem->Load("libSTEERBase.so");
299   setupPar("ESD");
300   gSystem->Load("libESD.so");
301   setupPar("AOD");
302   gSystem->Load("libAOD.so");
303   setupPar("ANALYSIS");
304   gSystem->Load("libANALYSIS.so");
305   setupPar("ANALYSISalice");
306   gSystem->Load("libANALYSISalice.so");
307   setupPar("CORRFW");
308   gSystem->Load("libCORRFW.so");
309   setupPar("PWG2spectra");
310   gSystem->Load("libPWG2spectra.so");
311
312   //____________________________________________//
313   //Usage of event tags
314   AliTagAnalysis *tagAnalysis = new AliTagAnalysis();
315   TChain *chain = 0x0;
316   chain = tagAnalysis->GetChainFromCollection(collectionfile,"esdTree");
317   chain->SetBranchStatus("*Calo*",0);
318   
319   //____________________________________________//
320   gROOT->LoadMacro("configProtonAnalysis.C");
321   AliProtonQAAnalysis *analysis = GetProtonQAAnalysisObject(mode,
322                                                             analysisType,
323                                                             pidMode);
324   //____________________________________________//
325   // Make the analysis manager
326   AliAnalysisManager *mgr = new AliAnalysisManager("protonAnalysisQAManager");
327   AliVEventHandler* esdH = new AliESDInputHandler;
328   mgr->SetInputEventHandler(esdH);
329   AliMCEventHandler *mc = new AliMCEventHandler();
330   mgr->SetMCtruthEventHandler(mc);
331   
332   //____________________________________________//
333   // 1st Proton task
334   AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
335   taskProtonsQA->SetAnalysisObject(analysis);
336   mgr->AddTask(taskProtonsQA);
337
338   // Create containers for input/output
339   AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("dataChain",
340                                                            TChain::Class(),
341                                                            AliAnalysisManager::kInputContainer);
342   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("globalQAList", 
343                                                             TList::Class(),
344                                                             AliAnalysisManager::kOutputContainer,
345                                                             outputFilename1.Data());
346   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("pdgCodeList", 
347                                                             TList::Class(),
348                                                             AliAnalysisManager::kOutputContainer,
349                                                             outputFilename2.Data());
350   AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("mcProcessList", 
351                                                             TList::Class(),
352                                                             AliAnalysisManager::kOutputContainer,
353                                                             outputFilename2.Data());
354   AliAnalysisDataContainer *coutput4 = mgr->CreateContainer("acceptedCutList", 
355                                                             TList::Class(),
356                                                             AliAnalysisManager::kOutputContainer,
357                                                             outputFilename3.Data());
358   AliAnalysisDataContainer *coutput5 = mgr->CreateContainer("rejectedCutList", 
359                                                             TList::Class(),
360                                                             AliAnalysisManager::kOutputContainer,
361                                                             outputFilename3.Data());
362   AliAnalysisDataContainer *coutput6 = mgr->CreateContainer("acceptedDCAList", 
363                                                             TList::Class(),
364                                                             AliAnalysisManager::kOutputContainer,
365                                                             outputFilename3.Data());
366   AliAnalysisDataContainer *coutput7 = mgr->CreateContainer("efficiencyList", 
367                                                             TList::Class(),
368                                                             AliAnalysisManager::kOutputContainer,
369                                                             outputFilename4.Data());
370   AliAnalysisDataContainer *coutput8 = mgr->CreateContainer("vertexList", 
371                                                             TList::Class(),
372                                                             AliAnalysisManager::kOutputContainer,
373                                                             outputFilename5.Data());
374
375   //____________________________________________//
376   mgr->ConnectInput(taskProtonsQA,0,cinput1);
377   mgr->ConnectOutput(taskProtonsQA,0,coutput1);
378   mgr->ConnectOutput(taskProtonsQA,1,coutput2);
379   mgr->ConnectOutput(taskProtonsQA,2,coutput3);
380   mgr->ConnectOutput(taskProtonsQA,3,coutput4);
381   mgr->ConnectOutput(taskProtonsQA,4,coutput5);
382   mgr->ConnectOutput(taskProtonsQA,5,coutput6);
383   mgr->ConnectOutput(taskProtonsQA,6,coutput7);
384   mgr->ConnectOutput(taskProtonsQA,7,coutput8);
385   if (!mgr->InitAnalysis()) return;
386   mgr->PrintStatus();
387   mgr->StartAnalysis("local",chain);
388 }
389  
390 //_________________________________________________//
391 void runProof(const char* mode = "ESD",
392               const char* analysisType = 0x0,
393               const char* pidMode = 0x0,
394               Int_t stats = 0, 
395               const char* dataset = 0x0) {
396   TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
397   outputFilename1 += ".root"; //main QA file
398   TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
399   outputFilename2 += ".root"; //MC process QA
400   TString outputFilename3 = "Protons.QA.Histograms."; 
401   outputFilename3 += analysisType;
402   outputFilename3 += ".root"; //Accepted cut distributions
403   TString outputFilename4 = "Protons.Efficiency."; 
404   outputFilename4 += analysisType;
405   outputFilename4 += ".root"; //Reco and PID efficiency
406   TString outputFilename5 = "Vertex.QA.root"; //vertex QA
407
408   printf("****** Connect to PROOF *******\n");
409   TProof::Open("alicecaf.cern.ch"); 
410   gProof->SetParallel();
411
412   // Enable the Analysis Package
413   gProof->UploadPackage("STEERBase.par");
414   gProof->EnablePackage("STEERBase");
415   gProof->UploadPackage("ESD.par");
416   gProof->EnablePackage("ESD");
417   gProof->UploadPackage("AOD.par");
418   gProof->EnablePackage("AOD");
419   gProof->UploadPackage("ANALYSIS.par");
420   gProof->EnablePackage("ANALYSIS");
421   gProof->UploadPackage("ANALYSISalice.par");
422   gProof->EnablePackage("ANALYSISalice");
423   gProof->UploadPackage("CORRFW.par");
424   gProof->EnablePackage("CORRFW");
425   gProof->UploadPackage("PWG2spectra.par");
426   gProof->EnablePackage("PWG2spectra");
427   
428   //____________________________________________//
429   gROOT->LoadMacro("configProtonAnalysis.C");
430   AliProtonQAAnalysis *analysis = GetProtonQAAnalysisObject(mode,
431                                                             analysisType,
432                                                             pidMode);
433   //____________________________________________//
434   // Make the analysis manager
435   AliAnalysisManager *mgr = new AliAnalysisManager("protonAnalysisQAManager");
436   AliVEventHandler* esdH = new AliESDInputHandler;
437   mgr->SetInputEventHandler(esdH);
438   AliMCEventHandler *mc = new AliMCEventHandler();
439   mgr->SetMCtruthEventHandler(mc);
440   
441   //____________________________________________//
442   // 1st Proton task
443   AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
444   taskProtonsQA->SetAnalysisObject(analysis);
445   mgr->AddTask(taskProtonsQA);
446
447   // Create containers for input/output
448   AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
449   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("globalQAList", 
450                                                             TList::Class(),
451                                                             AliAnalysisManager::kOutputContainer,
452                                                             outputFilename1.Data());
453   AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("pdgCodeList", 
454                                                             TList::Class(),
455                                                             AliAnalysisManager::kOutputContainer,
456                                                             outputFilename2.Data());
457   AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("mcProcessList", 
458                                                             TList::Class(),
459                                                             AliAnalysisManager::kOutputContainer,
460                                                             outputFilename2.Data());
461   AliAnalysisDataContainer *coutput4 = mgr->CreateContainer("acceptedCutList", 
462                                                             TList::Class(),
463                                                             AliAnalysisManager::kOutputContainer,
464                                                             outputFilename3.Data());
465   AliAnalysisDataContainer *coutput5 = mgr->CreateContainer("rejectedCutList", 
466                                                             TList::Class(),
467                                                             AliAnalysisManager::kOutputContainer,
468                                                             outputFilename3.Data());
469   AliAnalysisDataContainer *coutput6 = mgr->CreateContainer("acceptedDCAList", 
470                                                             TList::Class(),
471                                                             AliAnalysisManager::kOutputContainer,
472                                                             outputFilename3.Data());
473   AliAnalysisDataContainer *coutput7 = mgr->CreateContainer("efficiencyList", 
474                                                             TList::Class(),
475                                                             AliAnalysisManager::kOutputContainer,
476                                                             outputFilename4.Data());
477   AliAnalysisDataContainer *coutput8 = mgr->CreateContainer("vertexList", 
478                                                             TList::Class(),
479                                                             AliAnalysisManager::kOutputContainer,
480                                                             outputFilename5.Data());
481
482   //____________________________________________//
483   mgr->ConnectInput(taskProtonsQA,0,cinput1);
484   mgr->ConnectOutput(taskProtonsQA,0,coutput1);
485   mgr->ConnectOutput(taskProtonsQA,1,coutput2);
486   mgr->ConnectOutput(taskProtonsQA,2,coutput3);
487   mgr->ConnectOutput(taskProtonsQA,3,coutput4);
488   mgr->ConnectOutput(taskProtonsQA,4,coutput5);
489   mgr->ConnectOutput(taskProtonsQA,5,coutput6);
490   mgr->ConnectOutput(taskProtonsQA,6,coutput7);
491   mgr->ConnectOutput(taskProtonsQA,7,coutput8);
492   if (!mgr->InitAnalysis()) return;
493   mgr->PrintStatus();
494
495   if(dataset)
496     mgr->StartAnalysis("proof",dataset,stats);
497   else {
498     // You should get this macro and the txt file from:
499     // http://aliceinfo.cern.ch/Offline/Analysis/CAF/
500     gROOT->LoadMacro("CreateESDChain.C");
501     TChain* chain = 0x0;
502     chain = CreateESDChain("ESD82XX_30K.txt",stats);
503     chain->SetBranchStatus("*Calo*",0);
504
505     mgr->StartAnalysis("proof",chain);
506     //mgr->StartAnalysis("local",chain);
507   }
508 }
509
510 //_________________________________________________//
511 Int_t setupPar(const char* pararchivename) {
512   ///////////////////
513   // Setup PAR File//
514   ///////////////////
515   if (pararchivename) {
516     char processline[1024];
517     sprintf(processline,".! tar xvzf %s.par",pararchivename);
518     gROOT->ProcessLine(processline);
519     const char* ocwd = gSystem->WorkingDirectory();
520     gSystem->ChangeDirectory(pararchivename);
521     
522     // check for BUILD.sh and execute
523     if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
524       printf("*******************************\n");
525       printf("*** Building PAR archive    ***\n");
526       printf("*******************************\n");
527       
528       if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
529         Error("runAnalysis","Cannot Build the PAR Archive! - Abort!");
530         return -1;
531       }
532     }
533     // check for SETUP.C and execute
534     if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
535       printf("*******************************\n");
536       printf("*** Setup PAR archive       ***\n");
537       printf("*******************************\n");
538       gROOT->Macro("PROOF-INF/SETUP.C");
539     }
540     
541     gSystem->ChangeDirectory("../");
542   } 
543   return 1;
544 }