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