Removing + operator which was a synonym for the | operator to remove confusion experi...
[u/mrichter/AliRoot.git] / PWG2 / runProtonAnalysisQA.C
CommitLineData
9e2392b0 1void runProtonAnalysisQA(const char *analysisType = "TPC") {
2 //Macro to run the proton QA analysis tested for local, proof & GRID.
3 //Proof: Takes three arguments, the number of events, the dataset name
4 // and the analysis type
5 //Interactive: Takes two arguments, the name of the collection file with
6 // the event list for each file and the analysis type
1b309669 7 //Batch: Takes two arguments, the name of the collection file with
8 // the ESDs and the analysis type
9e2392b0 9 //Analysis type can be one of the three: "TPC", "Hybrid", "Global"
7b59a00b 10 TStopwatch timer;
11 timer.Start();
12
1b309669 13 //runProof(200000,"/COMMON/COMMON/LHC08c11_10TeV_0.5T",analysisType);
9e2392b0 14 //runInteractive("wn.xml",analysisType);
1b309669 15 runBatch("wn.xml",analysisType);
7b59a00b 16
17 timer.Stop();
18 timer.Print();
19}
20
21//_________________________________________________//
1b309669 22void runBatch(const char *collectionfile,
23 const char *analysisType) {
24 TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
25 outputFilename1 += ".root"; //main QA file
26 TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
27 outputFilename2 += ".root"; //MC process QA
28 TString outputFilename3 = "Protons.QA.Histograms.";
29 outputFilename3 += analysisType;
30 outputFilename3 += ".root"; //Accepted cut distributions
31 TString outputFilename4 = "Protons.Efficiency.";
32 outputFilename4 += analysisType;
33 outputFilename4 += ".root"; //Reco and PID efficiency
34
35 TGrid::Connect("alien://");
36 gSystem->Load("libProofPlayer.so");
37
38 //Setup the par files
39 setupPar("STEERBase");
40 gSystem->Load("libSTEERBase.so");
41 setupPar("ESD");
42 gSystem->Load("libESD.so");
43 setupPar("AOD");
44 gSystem->Load("libAOD.so");
45 setupPar("ANALYSIS");
46 gSystem->Load("libANALYSIS.so");
47 setupPar("ANALYSISalice");
48 gSystem->Load("libANALYSISalice.so");
49 setupPar("CORRFW");
50 gSystem->Load("libCORRFW.so");
51 setupPar("PWG2spectra");
52 gSystem->Load("libPWG2spectra.so");
53
54 gROOT->LoadMacro("AliAnalysisTaskProtonsQA.cxx+");
55 //____________________________________________//
56 //Create the chain from the xml collection of esd files
57 TAlienCollection* coll = TAlienCollection::Open(collectionfile);
58 TGridResult* gridResult = coll->GetGridResult("",0,0);
59 Int_t nEntries = gridResult->GetEntries();
60 TChain *chain = new TChain("esdTree");
61 TString alienUrl = 0;
62 for(Int_t i = 0; i < nEntries; i++) {
63 alienUrl = gridResult->GetKey(i,"turl");
64 chain->Add(alienUrl);
65 }
66
67 //____________________________________________//
68 // Make the analysis manager
69 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
70 AliVEventHandler* esdH = new AliESDInputHandler;
71 mgr->SetInputEventHandler(esdH);
72 AliMCEventHandler *mc = new AliMCEventHandler();
73 mgr->SetMCtruthEventHandler(mc);
74
75 //____________________________________________//
76 // 1st Proton task
77 AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
78 taskProtonsQA->SetTriggerMode(AliAnalysisTaskProtonsQA::kMB2);
79 switch(analysisType) {
80 case "TPC":
81 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kTPC);
82 break;
83 case "Hybrid":
84 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kHybrid);
85 break;
86 case "Global":
87 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kGlobal);
88 break;
89 default:
90 break;
91 }
92 taskProtonsQA->SetAcceptedVertexDiamond(5.,5.,15.);
93 mgr->AddTask(taskProtonsQA);
94
95 // Create containers for input/output
96 AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("dataChain",
97 TChain::Class(),
98 AliAnalysisManager::kInputContainer);
99 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("globalQAList",
100 TList::Class(),
101 AliAnalysisManager::kOutputContainer,
102 outputFilename1.Data());
103 AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("pdgCodeList",
104 TList::Class(),
105 AliAnalysisManager::kOutputContainer,
106 outputFilename2.Data());
107 AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("mcProcessList",
108 TList::Class(),
109 AliAnalysisManager::kOutputContainer,
110 outputFilename2.Data());
111 AliAnalysisDataContainer *coutput4 = mgr->CreateContainer("acceptedCutList",
112 TList::Class(),
113 AliAnalysisManager::kOutputContainer,
114 outputFilename3.Data());
115 AliAnalysisDataContainer *coutput5 = mgr->CreateContainer("acceptedDCAList",
116 TList::Class(),
117 AliAnalysisManager::kOutputContainer,
118 outputFilename3.Data());
119 AliAnalysisDataContainer *coutput6 = mgr->CreateContainer("efficiencyList",
120 TList::Class(),
121 AliAnalysisManager::kOutputContainer,
122 outputFilename4.Data());
123
124 //____________________________________________//
125 mgr->ConnectInput(taskProtonsQA,0,cinput1);
126 mgr->ConnectOutput(taskProtonsQA,0,coutput1);
127 mgr->ConnectOutput(taskProtonsQA,1,coutput2);
128 mgr->ConnectOutput(taskProtonsQA,2,coutput3);
129 mgr->ConnectOutput(taskProtonsQA,3,coutput4);
130 mgr->ConnectOutput(taskProtonsQA,4,coutput5);
131 mgr->ConnectOutput(taskProtonsQA,5,coutput6);
132 if (!mgr->InitAnalysis()) return;
133 mgr->PrintStatus();
134 mgr->StartAnalysis("local",chain);
135}
136
137//_________________________________________________//
9e2392b0 138void runInteractive(const char *collectionfile,
139 const char *analysisType) {
140 TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
141 outputFilename1 += ".root"; //main QA file
142 TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
143 outputFilename2 += ".root"; //MC process QA
144 TString outputFilename3 = "Protons.QA.Histograms.";
145 outputFilename3 += analysisType;
146 outputFilename3 += ".root"; //Accepted cut distributions
147 TString outputFilename4 = "Protons.Efficiency.";
148 outputFilename4 += analysisType;
149 outputFilename4 += ".root"; //Reco and PID efficiency
e2f97a75 150
151 TGrid::Connect("alien://");
152
153 //Setup the par files
154 setupPar("STEERBase");
155 gSystem->Load("libSTEERBase.so");
156 setupPar("ESD");
157 gSystem->Load("libESD.so");
158 setupPar("AOD");
159 gSystem->Load("libAOD.so");
160 setupPar("ANALYSIS");
161 gSystem->Load("libANALYSIS.so");
162 setupPar("ANALYSISalice");
163 gSystem->Load("libANALYSISalice.so");
164 setupPar("CORRFW");
165 gSystem->Load("libCORRFW.so");
166 setupPar("PWG2spectra");
167 gSystem->Load("libPWG2spectra.so");
168
169 gROOT->LoadMacro("AliAnalysisTaskProtonsQA.cxx+");
170 //____________________________________________//
171 //Usage of event tags
172 AliTagAnalysis *analysis = new AliTagAnalysis();
173 TChain *chain = 0x0;
174 chain = analysis->GetChainFromCollection(collectionfile,"esdTree");
175
176 //____________________________________________//
177 // Make the analysis manager
178 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
179 AliVEventHandler* esdH = new AliESDInputHandler;
180 mgr->SetInputEventHandler(esdH);
181 AliMCEventHandler *mc = new AliMCEventHandler();
182 mgr->SetMCtruthEventHandler(mc);
7b59a00b 183
e2f97a75 184 //____________________________________________//
185 // 1st Proton task
186 AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
5429dd65 187 taskProtonsQA->SetTriggerMode(AliAnalysisTaskProtonsQA::kMB2);
9e2392b0 188 switch(analysisType) {
189 case "TPC":
190 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kTPC);
191 break;
192 case "Hybrid":
193 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kHybrid);
194 break;
195 case "Global":
196 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kGlobal);
197 break;
198 default:
199 break;
200 }
5429dd65 201 taskProtonsQA->SetAcceptedVertexDiamond(5.,5.,15.);
e2f97a75 202 mgr->AddTask(taskProtonsQA);
203
204 // Create containers for input/output
8a546c82 205 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
e2f97a75 206 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("globalQAList",
207 TList::Class(),
208 AliAnalysisManager::kOutputContainer,
209 outputFilename1.Data());
210 AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("pdgCodeList",
211 TList::Class(),
212 AliAnalysisManager::kOutputContainer,
213 outputFilename2.Data());
214 AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("mcProcessList",
215 TList::Class(),
216 AliAnalysisManager::kOutputContainer,
217 outputFilename2.Data());
218 AliAnalysisDataContainer *coutput4 = mgr->CreateContainer("acceptedCutList",
219 TList::Class(),
220 AliAnalysisManager::kOutputContainer,
221 outputFilename3.Data());
222 AliAnalysisDataContainer *coutput5 = mgr->CreateContainer("acceptedDCAList",
223 TList::Class(),
224 AliAnalysisManager::kOutputContainer,
225 outputFilename3.Data());
226 AliAnalysisDataContainer *coutput6 = mgr->CreateContainer("efficiencyList",
227 TList::Class(),
228 AliAnalysisManager::kOutputContainer,
229 outputFilename4.Data());
230
231 //____________________________________________//
232 mgr->ConnectInput(taskProtonsQA,0,cinput1);
233 mgr->ConnectOutput(taskProtonsQA,0,coutput1);
234 mgr->ConnectOutput(taskProtonsQA,1,coutput2);
235 mgr->ConnectOutput(taskProtonsQA,2,coutput3);
236 mgr->ConnectOutput(taskProtonsQA,3,coutput4);
237 mgr->ConnectOutput(taskProtonsQA,4,coutput5);
238 mgr->ConnectOutput(taskProtonsQA,5,coutput6);
239 if (!mgr->InitAnalysis()) return;
240 mgr->PrintStatus();
241 mgr->StartAnalysis("local",chain);
242}
243
244//_________________________________________________//
9e2392b0 245void runProof(Int_t stats = 0,
246 const char* dataset = 0x0,
247 const char *analysisType) {
248 TString outputFilename1 = "Protons.QA."; outputFilename1 += analysisType;
249 outputFilename1 += ".root"; //main QA file
250 TString outputFilename2 = "Protons.MC.QA."; outputFilename2 += analysisType;
251 outputFilename2 += ".root"; //MC process QA
252 TString outputFilename3 = "Protons.QA.Histograms.";
253 outputFilename3 += analysisType;
254 outputFilename3 += ".root"; //Accepted cut distributions
255 TString outputFilename4 = "Protons.Efficiency.";
256 outputFilename4 += analysisType;
257 outputFilename4 += ".root"; //Reco and PID efficiency
7b59a00b 258
259 printf("****** Connect to PROOF *******\n");
96f84c25 260 TProof::Open("alicecaf.cern.ch");
7b59a00b 261 gProof->SetParallel();
262
263 // Enable the Analysis Package
264 gProof->UploadPackage("STEERBase.par");
265 gProof->EnablePackage("STEERBase");
266 gProof->UploadPackage("ESD.par");
267 gProof->EnablePackage("ESD");
268 gProof->UploadPackage("AOD.par");
269 gProof->EnablePackage("AOD");
270 gProof->UploadPackage("ANALYSIS.par");
271 gProof->EnablePackage("ANALYSIS");
272 gProof->UploadPackage("ANALYSISalice.par");
273 gProof->EnablePackage("ANALYSISalice");
f99662ca 274 gProof->UploadPackage("CORRFW.par");
275 gProof->EnablePackage("CORRFW");
7b59a00b 276 gProof->UploadPackage("PWG2spectra.par");
277 gProof->EnablePackage("PWG2spectra");
278
279 gProof->Load("AliAnalysisTaskProtonsQA.cxx++");
280
281 //____________________________________________//
282 // Make the analysis manager
283 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
284 AliVEventHandler* esdH = new AliESDInputHandler;
285 mgr->SetInputEventHandler(esdH);
286 AliMCEventHandler *mc = new AliMCEventHandler();
287 mgr->SetMCtruthEventHandler(mc);
288
289 //____________________________________________//
290 // 1st Proton task
291 AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA");
5429dd65 292 taskProtonsQA->SetTriggerMode(AliAnalysisTaskProtonsQA::kMB2);
9e2392b0 293 switch(analysisType) {
294 case "TPC":
295 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kTPC);
296 break;
297 case "Hybrid":
298 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kHybrid);
299 break;
300 case "Global":
301 taskProtonsQA->SetAnalysisMode(AliAnalysisTaskProtonsQA::kGlobal);
302 break;
303 default:
304 break;
305 }
5429dd65 306 taskProtonsQA->SetAcceptedVertexDiamond(5.,5.,15.);
7b59a00b 307 mgr->AddTask(taskProtonsQA);
308
309 // Create containers for input/output
8a546c82 310 AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
5b8133c7 311 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("globalQAList",
f99662ca 312 TList::Class(),
313 AliAnalysisManager::kOutputContainer,
d4733690 314 outputFilename1.Data());
5b8133c7 315 AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("pdgCodeList",
d4733690 316 TList::Class(),
317 AliAnalysisManager::kOutputContainer,
318 outputFilename2.Data());
5b8133c7 319 AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("mcProcessList",
d4733690 320 TList::Class(),
321 AliAnalysisManager::kOutputContainer,
0008a5a6 322 outputFilename2.Data());
5b8133c7 323 AliAnalysisDataContainer *coutput4 = mgr->CreateContainer("acceptedCutList",
324 TList::Class(),
325 AliAnalysisManager::kOutputContainer,
326 outputFilename3.Data());
327 AliAnalysisDataContainer *coutput5 = mgr->CreateContainer("acceptedDCAList",
328 TList::Class(),
329 AliAnalysisManager::kOutputContainer,
330 outputFilename3.Data());
e2f97a75 331 AliAnalysisDataContainer *coutput6 = mgr->CreateContainer("efficiencyList",
332 TList::Class(),
333 AliAnalysisManager::kOutputContainer,
334 outputFilename4.Data());
7b59a00b 335
336 //____________________________________________//
337 mgr->ConnectInput(taskProtonsQA,0,cinput1);
338 mgr->ConnectOutput(taskProtonsQA,0,coutput1);
d4733690 339 mgr->ConnectOutput(taskProtonsQA,1,coutput2);
340 mgr->ConnectOutput(taskProtonsQA,2,coutput3);
5b8133c7 341 mgr->ConnectOutput(taskProtonsQA,3,coutput4);
342 mgr->ConnectOutput(taskProtonsQA,4,coutput5);
e2f97a75 343 mgr->ConnectOutput(taskProtonsQA,5,coutput6);
7b59a00b 344 if (!mgr->InitAnalysis()) return;
345 mgr->PrintStatus();
346
347 if(dataset)
348 mgr->StartAnalysis("proof",dataset,stats);
349 else {
350 // You should get this macro and the txt file from:
351 // http://aliceinfo.cern.ch/Offline/Analysis/CAF/
352 gROOT->LoadMacro("CreateESDChain.C");
353 TChain* chain = 0x0;
354 chain = CreateESDChain("ESD82XX_30K.txt",stats);
355 chain->SetBranchStatus("*Calo*",0);
356
357 mgr->StartAnalysis("proof",chain);
f99662ca 358 //mgr->StartAnalysis("local",chain);
7b59a00b 359 }
7b59a00b 360}
361
362//_________________________________________________//
363Int_t setupPar(const char* pararchivename) {
364 ///////////////////
365 // Setup PAR File//
366 ///////////////////
367 if (pararchivename) {
368 char processline[1024];
369 sprintf(processline,".! tar xvzf %s.par",pararchivename);
1b309669 370 gROOT->ProcessLine(processline);
7b59a00b 371 const char* ocwd = gSystem->WorkingDirectory();
372 gSystem->ChangeDirectory(pararchivename);
373
374 // check for BUILD.sh and execute
375 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
376 printf("*******************************\n");
377 printf("*** Building PAR archive ***\n");
378 printf("*******************************\n");
379
380 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
381 Error("runAnalysis","Cannot Build the PAR Archive! - Abort!");
382 return -1;
383 }
384 }
385 // check for SETUP.C and execute
386 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
387 printf("*******************************\n");
388 printf("*** Setup PAR archive ***\n");
389 printf("*******************************\n");
390 gROOT->Macro("PROOF-INF/SETUP.C");
391 }
392
393 gSystem->ChangeDirectory("../");
394 }
395 return 1;
396}