TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGUD / DIFFRACTIVE / xsAndTwoProng / runMesonGrid.C
1 // runMeson.C
2 //
3 // run macro for central diffractive meson analysis
4 //
5 // Author: Felix Reidt <felix.reidt@cern.ch>
6 //
7 // based on:
8 // ---
9 // Template run macro for AliBasicTask.cxx/.h with example layout of
10 // physics selections and options, in macro and task.
11 //
12 // Author: Arvinder Palaha
13 //
14 class AliAnalysisGrid;
15
16 //______________________________________________________________________________
17 void runMeson(
18              const char* runtype = "grid", // local, proof or grid
19              const char *gridmode = "full", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof
20              const bool bMCphyssel = 0, // 1 = looking at MC truth or reconstructed, 0 = looking at real data
21              const Long64_t nentries = 2000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events.
22              const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode
23              const char *proofdataset = "/alice/data/LHC10c_000120821_p1", // path to dataset on proof cluster, for proof analysis
24              const char *proofcluster = "alice-caf.cern.ch", // which proof cluster to use in proof mode
25              const char *taskname = "CDMeson" // sets name of grid generated macros
26              )
27 {
28         // check run type
29         if(runtype != "local" && runtype != "proof" && runtype != "grid"){
30                 Printf("\n\tIncorrect run option, check first argument of run macro");
31                 Printf("\tint runtype = local, proof or grid\n");
32                 return;
33         }
34         Printf("%s analysis chosen",runtype);
35
36         // load libraries (to be optimized)
37         gSystem->Load("libCore.so");
38         gSystem->Load("libTree.so");
39         gSystem->Load("libPhysics");
40         gSystem->Load("libMinuit");
41         gSystem->Load("libProof");
42         gSystem->Load("libmicrocern");
43         gSystem->Load("liblhapdf");
44         gSystem->Load("libpythia6");
45         gSystem->Load("libEG");
46         gSystem->Load("libGeom");
47         gSystem->Load("libVMC");
48         gSystem->Load("libEGPythia6");
49         gSystem->Load("libSTEERBase");
50         gSystem->Load("libESD");
51         gSystem->Load("libCDB");
52         gSystem->Load("libRAWDatabase");
53         gSystem->Load("libRAWDatarec");
54         gSystem->Load("libAOD");
55         gSystem->Load("libANALYSIS");
56         gSystem->Load("libANALYSISalice");
57         gSystem->Load("libSTEER");
58         gSystem->Load("libTender");
59         gSystem->Load("libRAWDatasim");
60         gSystem->Load("libFASTSIM");
61         gSystem->Load("libEVGEN");
62         gSystem->Load("libAliPythia6");
63         gSystem->Load("libSTAT");
64         gSystem->Load("libhijing");
65         gSystem->Load("libTHijing");
66         gSystem->Load("libSTRUCT");
67         gSystem->Load("libPHOSUtils");
68         gSystem->Load("libPHOSbase");
69         gSystem->Load("libPHOSsim");
70         gSystem->Load("libPHOSrec");
71         gSystem->Load("libMUONcore");
72         gSystem->Load("libMUONmapping");
73         gSystem->Load("libMUONgeometry");
74         gSystem->Load("libMUONcalib");
75         gSystem->Load("libMUONraw");
76         gSystem->Load("libMUONtrigger");
77         gSystem->Load("libMUONbase");
78         gSystem->Load("libMUONsim");
79         gSystem->Load("libMUONrec");
80         gSystem->Load("libMUONevaluation");
81         gSystem->Load("libFMDbase");
82         gSystem->Load("libFMDsim");
83         gSystem->Load("libFMDrec");
84         gSystem->Load("libPMDbase");
85         gSystem->Load("libPMDsim");
86         gSystem->Load("libPMDrec");
87         gSystem->Load("libHMPIDbase");
88         gSystem->Load("libHMPIDsim");
89         gSystem->Load("libHMPIDrec");
90         gSystem->Load("libT0base");
91         gSystem->Load("libT0sim");
92         gSystem->Load("libT0rec");
93         gSystem->Load("libZDCbase");
94         gSystem->Load("libZDCsim");
95         gSystem->Load("libZDCrec");
96         gSystem->Load("libACORDEbase");
97         gSystem->Load("libACORDErec");
98         gSystem->Load("libACORDEsim");
99         gSystem->Load("libVZERObase");
100         gSystem->Load("libVZEROrec");
101         gSystem->Load("libVZEROsim");
102         gSystem->Load("libEMCALraw");
103         gSystem->Load("libEMCALUtils");
104         gSystem->Load("libEMCALbase");
105         gSystem->Load("libEMCALsim");
106         gSystem->Load("libEMCALrec");
107         gSystem->Load("libTPCbase");
108         gSystem->Load("libTPCrec");
109         gSystem->Load("libTPCsim");
110         gSystem->Load("libTPCfast");
111         gSystem->Load("libITSbase");
112         gSystem->Load("libITSsim");
113         gSystem->Load("libITSrec");
114         gSystem->Load("libTRDbase");
115         gSystem->Load("libTRDsim");
116         gSystem->Load("libTRDrec");
117         gSystem->Load("libTOFbase");
118         gSystem->Load("libTOFrec");
119         gSystem->Load("libTOFsim");
120         gSystem->Load("libHLTbase");
121         gSystem->Load("libHLTinterface");
122         gSystem->Load("libHLTsim");
123         gSystem->Load("libHLTrec");
124         gSystem->Load("libPWGPP");
125
126         // add aliroot include path
127         gROOT->ProcessLine(Form(".include %s/include",
128                                 gSystem->ExpandPathName("$ALICE_ROOT")));
129         gROOT->ProcessLine(Form(".include $ALICE_ROOT/include",
130                                 gSystem->ExpandPathName("$ALICE_ROOT")));
131         gROOT->ProcessLine(Form(".include $ALICE_ROOT/ITS",
132                                 gSystem->ExpandPathName("$ALICE_ROOT")));
133         gROOT->ProcessLine(Form(".include $ALICE_ROOT/PWGPP/ITS",
134                                 gSystem->ExpandPathName("$ALICE_ROOT")));
135         gROOT->ProcessLine(Form(".include $ALICE_ROOT/VZERO",
136                                 gSystem->ExpandPathName("$ALICE_ROOT")));
137
138         gROOT->SetStyle("Plain");
139
140         // create the alien handler and attach it to the manager
141         AliAnalysisGrid *plugin =
142                 CreateAlienHandler(taskname, gridmode, proofcluster, proofdataset);
143
144         // analysis manager
145         AliAnalysisManager* mgr = new AliAnalysisManager("CDMeson-Manager");
146         mgr->SetGridHandler(plugin);
147
148         AliESDInputHandler* esdH = new AliESDInputHandler();
149         mgr->SetInputEventHandler(esdH);
150
151         // === Physics Selection Task ===
152         gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
153         AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel);
154         if(!physSelTask) { Printf("no physSelTask"); return; }
155
156         // === Add PID Response Task ===
157         gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
158         AliAnalysisTaskPIDResponse *pidResponseTask = AddTaskPIDResponse(bMCphyssel);
159         if(!pidResponseTask) { Printf("no pidResponseTask"); return; }
160
161
162         // === create user task ===
163         gROOT->LoadMacro("AliCDMesonBase.cxx+g");
164         gROOT->LoadMacro("AliCDMesonTracks.cxx+g");
165         gROOT->LoadMacro("AliCDMesonUtils.cxx+g");
166         gROOT->LoadMacro("AliAnalysisTaskCDMeson.cxx+g");
167
168         Long_t taskConfig = AliCDMesonBase::kBitConfigurationSet; // has to be set
169         taskConfig |= AliCDMesonBase::kBitEtaPhiMaps;
170         taskConfig |= AliCDMesonBase::kBitEtaPhiMapsWithCuts;
171         taskConfig |= AliCDMesonBase::kBitStatsFlow;
172         taskConfig |= AliCDMesonBase::kBitMultPerGapHists;
173         taskConfig |= AliCDMesonBase::kBitRmMultPerGapHists;
174         taskConfig |= AliCDMesonBase::kBitTHnMother;
175         taskConfig |= AliCDMesonBase::kBitFastORStudy;
176         taskConfig |= AliCDMesonBase::kBitHitMapSPD;
177         taskConfig |= AliCDMesonBase::kBitHitMapFMD;
178         taskConfig |= AliCDMesonBase::kBitVtxStudies;
179         taskConfig |= AliCDMesonBase::kBitPIDStudy;
180         taskConfig |= AliCDMesonBase::kBitFMDsum;
181         taskConfig |= AliCDMesonBase::kBitSoftTracks;
182         taskConfig |= AliCDMesonBase::kBitPWAtree;
183         taskConfig |= AliCDMesonBase::kBitMultStudy;
184         //taskConfig |= AliCDMesonBase::kBitReadPreprocessedGap;
185         taskConfig |= AliCDMesonBase::kBitVZEROStudy;
186         taskConfig |= AliCDMesonBase::kBitTPCGapStudy;
187         if(bMCphyssel) taskConfig |= AliCDMesonBase::kBitMCProcess; // only for MC data
188         if(bMCphyssel) taskConfig |= AliCDMesonBase::kBitTHnMC;
189         if(bMCphyssel) taskConfig |= AliCDMesonBase::kBitMultResponseMC;
190         //taskConfig |= AliCDMesonBase::kBitReduceGapEvents;
191         taskConfig |= AliCDMesonBase::kBitConfigurationVersion;
192
193         printf("taskConfig=0x%x\n", taskConfig);
194
195         AliAnalysisTaskSE* task = new AliAnalysisTaskCDMeson(taskname, taskConfig);
196         task->SelectCollisionCandidates(AliVEvent::kMB);
197         mgr->AddTask(task);
198
199         // INPUT ---------------------------------------------------------------------
200         AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
201         mgr->ConnectInput(task, 0, cinput );
202
203         // OUTPUT --------------------------------------------------------------------
204         // output filename
205         Char_t foutname[100];
206         Char_t foutnamePWA[100];
207         sprintf(foutname,"cd_%s.root",taskname);
208         sprintf(foutnamePWA,"cd_%sPWA.root",taskname);
209
210         // output containers
211         // in AnalysisTaskSE, slot 0 reserved, must start from 1
212         // since the number of output containers is flexible, the slot is assigned
213         // dynamically
214         AliAnalysisDataContainer* outlist[6] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
215         Int_t nOutputs = 0;
216
217         outlist[nOutputs] =
218                 mgr->CreateContainer("cd_Hist", TList::Class(),
219                                      AliAnalysisManager::kOutputContainer,foutname);
220         nOutputs++;
221         mgr->ConnectOutput(task, nOutputs, outlist[nOutputs-1]);
222
223         if (!taskConfig
224             || ((taskConfig & AliCDMesonBase::kBitSoftTracks)
225                 && (taskConfig & AliCDMesonBase::kBitTHnMother))) {
226                 outlist[nOutputs] =
227                         mgr->CreateContainer("cd_ThnMother", THnSparse::Class(),
228                                              AliAnalysisManager::kOutputContainer,foutname);
229                 nOutputs++;
230                 mgr->ConnectOutput(task, nOutputs, outlist[nOutputs-1]);
231         }
232
233         if (!taskConfig || (taskConfig & AliCDMesonBase::kBitSoftTracks)) {
234                 outlist[nOutputs] =
235                         mgr->CreateContainer("cd_ThnMotherSoft", THnSparse::Class(),
236                                              AliAnalysisManager::kOutputContainer,foutname);
237                 nOutputs++;
238                 mgr->ConnectOutput(task, nOutputs, outlist[nOutputs-1]);
239         }
240
241         if (!taskConfig || (taskConfig & AliCDMesonBase::kBitMultStudy)) {
242                 outlist[nOutputs] =
243                         mgr->CreateContainer("cd_ThnMultiplicity", THnSparse::Class(),
244                                              AliAnalysisManager::kOutputContainer,foutname);
245                 nOutputs++;
246                 mgr->ConnectOutput(task, nOutputs, outlist[nOutputs-1]);
247         }
248
249         if (!taskConfig || (taskConfig & AliCDMesonBase::kBitTHnMC)) {
250                 outlist[nOutputs] =
251                         mgr->CreateContainer("cd_ThnMotherMC", THnSparse::Class(),
252                                              AliAnalysisManager::kOutputContainer,foutname);
253                 nOutputs++;
254                 mgr->ConnectOutput(task, nOutputs, outlist[nOutputs-1]);
255         }
256         if (!taskConfig || (taskConfig & AliCDMesonBase::kBitPWAtree)) {
257                 outlist[nOutputs] =
258                         mgr->CreateContainer("cd_PWA", TTree::Class(),
259                                              AliAnalysisManager::kOutputContainer,foutnamePWA);
260                 nOutputs++;
261                 mgr->ConnectOutput(task, nOutputs, outlist[nOutputs-1]);
262         }
263
264         // enable debug printouts
265         mgr->SetDebugLevel(2);
266         //mgr->SetNSysInfo(100);
267         if (!mgr->InitAnalysis()) return;
268         mgr->PrintStatus();
269
270         // start analysis
271         Printf("Starting Analysis....");
272         mgr->StartAnalysis(runtype); //,nentries,firstentry);
273 }
274
275 //______________________________________________________________________________
276 AliAnalysisGrid* CreateAlienHandler(const char *taskname,
277                                     const char *gridmode,
278                                     const char *proofcluster,
279                                     const char *proofdataset)
280 {
281         AliAnalysisAlien *plugin = new AliAnalysisAlien();
282         // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
283         plugin->SetOverwriteMode();
284         plugin->SetRunMode(gridmode);
285
286         plugin->SetMergeViaJDL(kTRUE);
287
288         // Set versions of used packages
289         plugin->SetAPIVersion("V1.1x");
290         plugin->SetROOTVersion("v5-34-01-1");
291         plugin->SetAliROOTVersion("v5-03-50-AN");
292
293         // Declare input data to be processed.
294         //plugin->SetCheckCopy(kFALSE);
295
296         // Method 1: Create automatically XML collections using alien 'find' command.
297         // Define production directory LFN
298         plugin->SetGridDataDir("/alice/sim/2012/LHC12d4a");
299         // On real reconstructed data:
300         // plugin->SetGridDataDir("/alice/data/2009/LHC09d");
301         // Set data search pattern
302         plugin->SetDataPattern("*AliESDs.root"); // THIS CHOOSES ALL PASSES
303         // Data pattern for reconstructed data
304         //plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
305         //    plugin->SetDataPattern("ESDs/pass2/AOD038/*AliAOD.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH
306         plugin->SetRunPrefix(""); //000");   // real data
307         // ...then add run numbers to be considered
308
309         //Int_t runlist[15]={117039, 146859, 146858, 146856, 146824, 146817, 146806, 146805, 146804, 146803, 146802, 146801, 146748, 146747, 146746};  
310         //for (Int_t ind=0; ind<1; ind++) {
311         //      plugin->AddRunNumber(runlist[ind]);
312         //}
313         //plugin->SetRunRange(114917,115322);
314         //plugin->AddRunNumber(117050);
315         plugin->SetRunRange(115393,126408);
316
317         plugin->SetNrunsPerMaster(1);
318
319         // Define alien work directory where all files will be copied. Relative to alien $HOME.
320         plugin->SetGridWorkingDir(taskname);
321
322         // Declare alien output directory. Relative to working directory.
323         plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out
324
325         // Declare the analysis source files names separated by blancs. To be compiled runtime
326         // using ACLiC on the worker nodes.
327         plugin->SetAnalysisSource("AliCDMesonBase.cxx AliCDMesonTracks.cxx AliCDMesonUtils.cxx AliAnalysisTaskCDMeson.cxx");
328
329         // Declare all libraries (other than the default ones for the framework. These will be
330         // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
331         plugin->SetAdditionalLibs("libGui.so libCore.so libTree.so libPhysics.so libMinuit.so libProof.so libmicrocern.so liblhapdf.so libpythia6.so libEG.so libGeom.so libVMC.so libEGPythia6.so libSTEERBase.so libESD.so libRAWDatabase.so libRAWDatarec.so libAOD.so libANALYSIS.so libANALYSISalice.so libCDB.so libSTEER.so libRAWDatasim.so libFASTSIM.so libEVGEN.so libAliPythia6.so libSTAT.so libhijing.so libTHijing.so libSTRUCT.so libPHOSUtils.so libPHOSbase.so libPHOSsim.so libPHOSrec.so libMUONcore.so libMUONmapping.so libMUONgeometry.so libMUONcalib.so libMUONraw.so libMUONtrigger.so libMUONbase.so libMUONsim.so libMUONrec.so libMUONevaluation.so libFMDbase.so libFMDsim.so libFMDrec.so libPMDbase.so libPMDsim.so libPMDrec.so libHMPIDbase.so libHMPIDsim.so libHMPIDrec.so libT0base.so libT0sim.so libT0rec.so libZDCbase.so libZDCsim.so libZDCrec.so libACORDEbase.so libACORDErec.so libACORDEsim.so libVZERObase.so libVZEROrec.so libVZEROsim.so libEMCALraw.so libEMCALUtils.so libEMCALbase.so libEMCALsim.so libEMCALrec.so libTPCbase.so libTPCrec.so libTPCsim.so libTPCfast.so libITSbase.so libITSsim.so libITSrec.so libTRDbase.so libTRDsim.so libTRDrec.so libTOFbase.so libTOFrec.so libTOFsim.so libHLTbase.so libHLTinterface.so libHLTsim.so libHLTrec.so libTender.so libTenderSupplies.so libPWGPP.so AliCDMesonBase.h AliCDMesonBase.cxx AliCDMesonTracks.h AliCDMesonTracks.cxx AliCDMesonUtils.h AliCDMesonUtils.cxx AliAnalysisTaskCDMeson.h AliAnalysisTaskCDMeson.cxx");
332
333         plugin->AddIncludePath("-I$ALICE_ROOT/ITS -I$ALICE_ROOT/PWGPP/ITS");
334
335         // Declare the output file names separated by blancs.
336         // (can be like: file.root or file.root@ALICE::Niham::File)
337         // To only save certain files, use SetDefaultOutputs(kFALSE), and then
338         // SetOutputFiles("list.root other.filename") to choose which files to save
339         plugin->SetDefaultOutputs();
340
341         // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
342         plugin->SetAnalysisMacro("CDMeson.C");
343
344         // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
345         plugin->SetSplitMaxInputFileNumber(100);
346
347         // Optionally modify the executable name (default analysis.sh)
348         plugin->SetExecutable("CDMeson.sh");
349
350         // set number of test files to use in "test" mode
351         plugin->SetNtestFiles(1);
352
353         // Optionally resubmit threshold.
354         //plugin->SetMasterResubmitThreshold(90);
355
356         // Optionally set time to live (default 30000 sec)
357         //plugin->SetTTL(30000);
358
359         // Optionally set input format (default xml-single)
360         //plugin->SetInputFormat("xml-single");
361
362         // Optionally modify the name of the generated JDL (default analysis.jdl)
363         plugin->SetJDLName("CDMeson.jdl");
364
365         // Optionally modify job price (default 1)
366         plugin->SetPrice(1);
367
368         // Optionally modify split mode (default 'se')
369         plugin->SetSplitMode("se");
370
371         //----------------------------------------------------------
372         //---      PROOF MODE SPECIFIC SETTINGS         ------------
373         //----------------------------------------------------------
374         // Proof cluster
375         plugin->SetProofCluster(proofcluster);
376         // Dataset to be used
377         plugin->SetProofDataSet(proofdataset);
378         // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard
379         plugin->SetProofReset(0);
380         // May limit number of workers
381         plugin->SetNproofWorkers(0);
382         // May limit the number of workers per slave
383         plugin->SetNproofWorkersPerSlave(1);
384         // May use a specific version of root installed in proof
385         plugin->SetRootVersionForProof("current");
386         // May set the aliroot mode. Check http://aaf.cern.ch/node/83
387         plugin->SetAliRootMode("default"); // Loads AF libs by default
388         // May request ClearPackages (individual ClearPackage not supported)
389         plugin->SetClearPackages(kFALSE);
390         // Plugin test mode works only providing a file containing test file locations, used in "local" mode also
391         plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc
392         // Request connection to alien upon connection to grid
393         plugin->SetProofConnectGrid(kFALSE);
394         // Other PROOF specific parameters
395         plugin->SetProofParameter("PROOF_UseMergers","-1");
396         printf("Using: PROOF_UseMergers   : %s\n", plugin->GetProofParameter("PROOF_UseMergers"));
397
398         return plugin;
399 }