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