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