Fix in PID application for LambdaC (Rossella)
[u/mrichter/AliRoot.git] / PWG2 / EBYE / macros / runBalanceFunction.C
CommitLineData
3feee083 1// run.C\r
2//\r
3// Template run macro for AliBasicTask.cxx/.h with example layout of\r
4// physics selections and options, in macro and task.\r
5//\r
6// Author: Arvinder Palaha\r
7//\r
8class AliAnalysisGrid;\r
9class AliAnalysisTaskBF;\r
10class AliBalance;\r
11\r
12//Centrality stuff\r
13Int_t binfirst = 0; //where do we start numbering bins\r
14Int_t binlast = 8; //where do we stop numbering bins\r
15const Int_t numberOfCentralityBins = 9;\r
16Float_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile\r
17\r
18//______________________________________________________________________________\r
19void runBalanceFunction(\r
20 const char* runtype = "local", // local, proof or grid\r
21 const char *gridmode = "test", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof\r
22 const Int_t bunchN = 0,\r
23 const bool bAOD = 1, // 1 = AOD ANALYSIS, 0 = ESD ANALYSIS\r
24 const bool bMCtruth = 0, // 1 = MCEvent handler is on (MC truth), 0 = MCEvent handler is off (MC reconstructed/real data)\r
25 const bool bMCphyssel = 0, // 1 = looking at MC truth or reconstructed, 0 = looking at real data\r
26 const Long64_t nentries = 5000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events.\r
27 const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode\r
28 const char *proofdataset = "/alice/data/LHC10c_000120821_p1", // path to dataset on proof cluster, for proof analysis\r
29 const char *proofcluster = "alice-caf.cern.ch", // which proof cluster to use in proof mode\r
30 const char *taskname = "BF_AOD_49_bunch" // sets name of grid generated macros\r
31 )\r
32{\r
33 // check run type\r
34 if(runtype != "local" && runtype != "proof" && runtype != "grid"){\r
35 Printf("\n\tIncorrect run option, check first argument of run macro");\r
36 Printf("\tint runtype = local, proof or grid\n");\r
37 return;\r
38 }\r
39 Printf("%s analysis chosen",runtype);\r
40 \r
41 // load libraries\r
42 gSystem->Load("libCore.so"); \r
43 gSystem->Load("libGeom.so");\r
44 gSystem->Load("libVMC.so");\r
45 gSystem->Load("libPhysics.so");\r
46 gSystem->Load("libTree.so");\r
47 gSystem->Load("libSTEERBase.so");\r
48 gSystem->Load("libESD.so");\r
49 gSystem->Load("libAOD.so");\r
50 gSystem->Load("libANALYSIS.so");\r
51 gSystem->Load("libANALYSISalice.so");\r
52 gSystem->Load("libPWG2ebye.so");\r
53\r
54 // additional\r
55\r
56 // add aliroot indlude path\r
57 gROOT->ProcessLine(".include $PWD/.");\r
58 gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ALICE_ROOT")));\r
59 gROOT->SetStyle("Plain");\r
60\r
61 // analysis manager\r
62 AliAnalysisManager* mgr = new AliAnalysisManager(Form("%s%i",taskname,bunchN));\r
63 \r
64 // create the alien handler and attach it to the manager\r
65 AliAnalysisGrid *plugin = CreateAlienHandler(bAOD,bunchN,Form("%s%i",taskname,bunchN), gridmode, proofcluster, proofdataset); \r
66 mgr->SetGridHandler(plugin);\r
67 \r
68\r
69 // input handler (ESD or AOD)\r
70 AliVEventHandler* inputH = NULL;\r
71 if(!bAOD){\r
72 inputH = new AliESDInputHandler();\r
73 }\r
74 else{\r
75 inputH = new AliAODInputHandler();\r
76 }\r
77 mgr->SetInputEventHandler(inputH);\r
78 \r
79 // mc event handler\r
80 if(bMCtruth) {\r
81 AliMCEventHandler* mchandler = new AliMCEventHandler();\r
82 // Not reading track references\r
83 mchandler->SetReadTR(kFALSE);\r
84 mgr->SetMCtruthEventHandler(mchandler);\r
85 } \r
86\r
87 // AOD output handler\r
88 //AliAODHandler* aodoutHandler = new AliAODHandler();\r
89 //aodoutHandler->SetOutputFileName("aod.root");\r
90 //mgr->SetOutputEventHandler(aodoutHandler); \r
91 \r
92 // === Physics Selection Task ===\r
93 //\r
94 // In SelectCollisionCandidate(), default is kMB, so the task UserExec() \r
95 // function is only called for these events.\r
96 // Options are:\r
97 // kMB Minimum Bias trigger\r
98 // kMBNoTRD Minimum bias trigger where the TRD is not read out\r
99 // kMUON Muon trigger\r
100 // kHighMult High-Multiplicity Trigger\r
101 // kUserDefined For manually defined trigger selection\r
102 //\r
103 // Multiple options possible with the standard AND/OR operators && and ||\r
104 // These all have the usual offline SPD or V0 selections performed.\r
105 //\r
106 // With a pointer to the physics selection object using physSelTask->GetPhysicsSelection(),\r
107 // one can manually set the selected and background classes using:\r
108 // AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL")\r
109 // AddBGTriggerClass("+CINT1A-ABCE-NOPF-ALL");\r
110 //\r
111 // One can also specify multiple classes at once, or require a class to NOT\r
112 // trigger, for e.g.\r
113 // AddBGTriggerClass("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL");\r
114 //\r
115 // NOTE that manually setting the physics selection overrides the standard\r
116 // selection, so it must be done in completeness.\r
117 //\r
118 // ALTERNATIVELY, one can make the physics selection inside the task\r
119 // UserExec().\r
120 // For this case, comment out the task->SelectCol.... line, \r
121 // and see AliBasicTask.cxx UserExec() function for details on this.\r
122\r
123 //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");\r
124 //AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel);\r
125 //if(!physSelTask) { Printf("no physSelTask"); return; }\r
126 //AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection();\r
127 //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769");\r
128 \r
129 // create task\r
130 // copile standalone stuff\r
131 //gROOT->LoadMacro("AliBalance.cxx++g");\r
132 //gROOT->LoadMacro("AliAnalysisTaskB.cxx++g");\r
133\r
134 //Add the centrality determination task (only on ESD level)\r
135 if(!bAOD){\r
136 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");\r
137 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();\r
138 }\r
139\r
140 // Add the trigger selection task\r
141 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");\r
142 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();\r
143\r
144 //Add the BF task (all centralities)\r
145 gROOT->LoadMacro("AddTaskBalanceCentralityTrain.C"); \r
146 AliAnalysisTaskBF *task = AddTaskBalanceCentralityTrain(0,100);\r
147 \r
148 //Add the BFG task (different centralities)\r
149 for (Int_t i=binfirst; i<binlast+1; i++) {\r
150 Float_t lowCentralityBinEdge = centralityArray[i];\r
151 Float_t highCentralityBinEdge = centralityArray[i+1];\r
152 Printf("\nWagon for centrality bin %i: %.0f-%.0f",i,lowCentralityBinEdge,highCentralityBinEdge);\r
153 AddTaskBalanceCentralityTrain(lowCentralityBinEdge,highCentralityBinEdge);\r
154 } \r
155 \r
156 \r
157 // enable debug printouts\r
158 //mgr->SetDebugLevel(2);\r
159 //mgr->SetUseProgressBar(1,100);\r
160 if (!mgr->InitAnalysis()) return;\r
161 mgr->PrintStatus();\r
162 \r
163 // start analysis\r
164 Printf("Starting Analysis....");\r
165 mgr->StartAnalysis(runtype,nentries,firstentry);\r
166}\r
167\r
168//______________________________________________________________________________\r
169AliAnalysisGrid* CreateAlienHandler(Bool_t bAOD, Int_t bunchN, const char *taskname, const char *gridmode, const char *proofcluster, const char *proofdataset)\r
170{\r
171 AliAnalysisAlien *plugin = new AliAnalysisAlien();\r
172 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")\r
173 plugin->SetRunMode(gridmode);\r
174\r
175 // Set versions of used packages\r
176 plugin->SetAPIVersion("V1.1x");\r
177 plugin->SetROOTVersion("v5-28-00d");\r
178 plugin->SetAliROOTVersion("v4-21-27-AN");\r
179\r
180 // Declare input data to be processed.\r
181\r
182 // Method 1: Create automatically XML collections using alien 'find' command.\r
183 // Define production directory LFN\r
184 plugin->SetGridDataDir("/alice/data/2010/LHC10h/");\r
185 // On real reconstructed data:\r
186 // plugin->SetGridDataDir("/alice/data/2009/LHC09d");\r
187\r
188 // Set data search pattern\r
189 //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES\r
190 // Data pattern for reconstructed data\r
191 if(!bAOD){\r
192 plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH\r
193 } \r
194 else{\r
195 plugin->SetDataPattern("*ESDs/pass2/AOD049/*/AliAOD.root");\r
196 }\r
197\r
198 plugin->SetRunPrefix("000"); // real data\r
199 // ...then add run numbers to be considered\r
200 //plugin->SetRunRange(114917,115322);\r
201\r
202 if(bunchN==0){\r
203 plugin->AddRunNumber(137366);\r
204 }\r
205 \r
206 //bunch1\r
207 else if(bunchN == 1){\r
208 plugin->AddRunNumber(139510);\r
209 plugin->AddRunNumber(139507);\r
210 plugin->AddRunNumber(139505);\r
211 plugin->AddRunNumber(139503); \r
212 plugin->AddRunNumber(139465); \r
213 plugin->AddRunNumber(139438);\r
214 plugin->AddRunNumber(139437);\r
215 plugin->AddRunNumber(139360); \r
216 plugin->AddRunNumber(139329);\r
217 plugin->AddRunNumber(139328); \r
218 }\r
219\r
220 //bunch2\r
221 else if(bunchN == 2){\r
222 plugin->AddRunNumber(139314); \r
223 plugin->AddRunNumber(139310);\r
224 plugin->AddRunNumber(139309); \r
225 plugin->AddRunNumber(139173); \r
226 plugin->AddRunNumber(139107); \r
227 plugin->AddRunNumber(139105); \r
228 plugin->AddRunNumber(139038); \r
229 plugin->AddRunNumber(139037); \r
230 plugin->AddRunNumber(139036); \r
231 plugin->AddRunNumber(139029); \r
232 plugin->AddRunNumber(139028); \r
233 plugin->AddRunNumber(138872); \r
234 plugin->AddRunNumber(138871); \r
235 plugin->AddRunNumber(138870); \r
236 plugin->AddRunNumber(138837); \r
237 plugin->AddRunNumber(138732); \r
238 plugin->AddRunNumber(138730);\r
239 plugin->AddRunNumber(138666);\r
240 plugin->AddRunNumber(138662); \r
241 plugin->AddRunNumber(138653); \r
242 }\r
243\r
244 else if(bunchN == 3){\r
245 plugin->AddRunNumber(138652);\r
246 plugin->AddRunNumber(138638);\r
247 plugin->AddRunNumber(138624); \r
248 plugin->AddRunNumber(138621); \r
249 plugin->AddRunNumber(138583); \r
250 plugin->AddRunNumber(138582); \r
251 plugin->AddRunNumber(138579); \r
252 plugin->AddRunNumber(138578);\r
253 plugin->AddRunNumber(138534);\r
254 plugin->AddRunNumber(138469); \r
255 }\r
256\r
257 else if(bunchN == 4){\r
258 \r
259 plugin->AddRunNumber(138442);\r
260 plugin->AddRunNumber(138439);\r
261 plugin->AddRunNumber(138438);\r
262 plugin->AddRunNumber(138396); \r
263 plugin->AddRunNumber(138364); \r
264 plugin->AddRunNumber(138275); \r
265 plugin->AddRunNumber(138225); \r
266 plugin->AddRunNumber(138201);\r
267 plugin->AddRunNumber(138197); \r
268 plugin->AddRunNumber(138192); \r
269 }\r
270\r
271 else if(bunchN == 5){\r
272\r
273 plugin->AddRunNumber(138190);\r
274 plugin->AddRunNumber(137848); \r
275 plugin->AddRunNumber(137844); \r
276 plugin->AddRunNumber(137752); \r
277 plugin->AddRunNumber(137751); \r
278 plugin->AddRunNumber(137724); \r
279 plugin->AddRunNumber(137722); \r
280 plugin->AddRunNumber(137718); \r
281 plugin->AddRunNumber(137704); \r
282 plugin->AddRunNumber(137693);\r
283 }\r
284\r
285 else if(bunchN == 6){\r
286\r
287 plugin->AddRunNumber(137692); \r
288 plugin->AddRunNumber(137691); \r
289 plugin->AddRunNumber(137686); \r
290 plugin->AddRunNumber(137685); \r
291 plugin->AddRunNumber(137639); \r
292 plugin->AddRunNumber(137638);\r
293 plugin->AddRunNumber(137608); \r
294 plugin->AddRunNumber(137595);\r
295 plugin->AddRunNumber(137549);\r
296 plugin->AddRunNumber(137546); \r
297\r
298 }\r
299\r
300 else if(bunchN == 7){\r
301\r
302 plugin->AddRunNumber(137544); \r
303 plugin->AddRunNumber(137541); \r
304 plugin->AddRunNumber(137539); \r
305 plugin->AddRunNumber(137531); \r
306 plugin->AddRunNumber(137530); \r
307 plugin->AddRunNumber(137443); \r
308 plugin->AddRunNumber(137441); \r
309 plugin->AddRunNumber(137440); \r
310 plugin->AddRunNumber(137439); \r
311 plugin->AddRunNumber(137434); \r
312\r
313 }\r
314\r
315 else if(bunchN == 8){\r
316\r
317 plugin->AddRunNumber(137432); \r
318 plugin->AddRunNumber(137431); \r
319 plugin->AddRunNumber(137430); \r
320 plugin->AddRunNumber(137366); \r
321 plugin->AddRunNumber(137243); \r
322 plugin->AddRunNumber(137236);\r
323 plugin->AddRunNumber(137235);\r
324 plugin->AddRunNumber(137232); \r
325 plugin->AddRunNumber(137231); \r
326 plugin->AddRunNumber(137162); \r
327 plugin->AddRunNumber(137161);\r
328 }\r
329\r
330 else{\r
331\r
332 stderr<<"BUNCH NOT THERE"<<endl;\r
333 return NULL;\r
334\r
335 }\r
336\r
337\r
338 //plugin->AddRunList("139510, 139507, 139505, 139503, 139465, 139438, 139437, 139360, 139329, 139328, 139314, 139310, 139309, 139173, 139107, 139105, 139038, 139037, 139036, 139029, 139028, 138872, 138871, 138870, 138837, 138732, 138730, 138666, 138662, 138653, 138652, 138638, 138624, 138621, 138583, 138582, 138579, 138578, 138534, 138469, 138442, 138439, 138438, 138396, 138364, 138275, 138225, 138201, 138197, 138192, 138190, 137848, 137844, 137752, 137751, 137724, 137722, 137718, 137704, 137693, 137692, 137691, 137686, 137685, 137639, 137638, 137608, 137595, 137549, 137546, 137544, 137541, 137539, 137531, 137530, 137443, 137441, 137440, 137439, 137434, 137432, 137431, 137430, 137366, 137243, 137236, 137235, 137232, 137231, 137162, 137161");\r
339\r
340\r
341\r
342\r
343\r
344 plugin->SetNrunsPerMaster(1);\r
345 plugin->SetOutputToRunNo();\r
346 // comment out the next line when using the "terminate" option, unless\r
347 // you want separate merged files for each run\r
348 plugin->SetMergeViaJDL();\r
349\r
350 // Method 2: Declare existing data files (raw collections, xml collections, root file)\r
351 // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())\r
352 // XML collections added via this method can be combined with the first method if\r
353 // the content is compatible (using or not tags)\r
354 // plugin->AddDataFile("tag.xml");\r
355 // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");\r
356\r
357 // Define alien work directory where all files will be copied. Relative to alien $HOME.\r
358 plugin->SetGridWorkingDir(taskname);\r
359\r
360 // Declare alien output directory. Relative to working directory.\r
361 plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out\r
362\r
363 // Declare the analysis source files names separated by blancs. To be compiled runtime\r
364 // using ACLiC on the worker nodes.\r
365 // plugin->SetAnalysisSource("AliBalance.cxx AliAnalysisTaskBF.cxx");\r
366\r
367 // Declare all libraries (other than the default ones for the framework. These will be\r
368 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.\r
369 //plugin->AddIncludePath("-I.");\r
370 //plugin->SetAdditionalLibs("AliBalance.cxx AliBalance.h AliAnalysisTaskBF.cxx AliAnalysisTaskBF.h");\r
371\r
372 // Declare the output file names separated by blancs.\r
373 // (can be like: file.root or file.root@ALICE::Niham::File)\r
374 // To only save certain files, use SetDefaultOutputs(kFALSE), and then\r
375 // SetOutputFiles("list.root other.filename") to choose which files to save\r
376 plugin->SetDefaultOutputs();\r
377 //plugin->SetOutputFiles("list.root");\r
378\r
379 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)\r
380 plugin->SetAnalysisMacro(Form("%s.C",taskname));\r
381\r
382 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)\r
383 plugin->SetSplitMaxInputFileNumber(100);\r
384\r
385 // Optionally modify the executable name (default analysis.sh)\r
386 plugin->SetExecutable(Form("%s.sh",taskname));\r
387\r
388 // set number of test files to use in "test" mode\r
389 plugin->SetNtestFiles(1);\r
390\r
391 // Optionally resubmit threshold.\r
392 plugin->SetMasterResubmitThreshold(90);\r
393\r
394 // Optionally set time to live (default 30000 sec)\r
395 plugin->SetTTL(90000);\r
396\r
397 // Optionally set input format (default xml-single)\r
398 plugin->SetInputFormat("xml-single");\r
399\r
400 // Optionally modify the name of the generated JDL (default analysis.jdl)\r
401 plugin->SetJDLName(Form("%s.jdl",taskname));\r
402\r
403 // Optionally modify job price (default 1)\r
404 plugin->SetPrice(1); \r
405\r
406 // Optionally modify split mode (default 'se') \r
407 plugin->SetSplitMode("se");\r
408\r
409 //plugin->SetUseSubmitPolicy();\r
410 //plugin->SetKeepLogs();\r
411 \r
412 //----------------------------------------------------------\r
413 //--- PROOF MODE SPECIFIC SETTINGS ------------\r
414 //---------------------------------------------------------- \r
415 // Proof cluster\r
416 plugin->SetProofCluster(proofcluster);\r
417 // Dataset to be used \r
418 plugin->SetProofDataSet(proofdataset);\r
419 // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard\r
420 plugin->SetProofReset(0);\r
421 // May limit number of workers\r
422 plugin->SetNproofWorkers(0);\r
423 // May limit the number of workers per slave\r
424 plugin->SetNproofWorkersPerSlave(1); \r
425 // May use a specific version of root installed in proof\r
426 plugin->SetRootVersionForProof("current");\r
427 // May set the aliroot mode. Check http://aaf.cern.ch/node/83 \r
428 plugin->SetAliRootMode("default"); // Loads AF libs by default\r
429 // May request ClearPackages (individual ClearPackage not supported)\r
430 plugin->SetClearPackages(kFALSE);\r
431 // Plugin test mode works only providing a file containing test file locations, used in "local" mode also\r
432 plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc\r
433 // Request connection to alien upon connection to grid\r
434 plugin->SetProofConnectGrid(kFALSE);\r
435\r
436 plugin->Print();\r
437\r
438 return plugin;\r
439}\r
440\r