TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGPP / PilotTrain / PilotAnalysis_sim.C
CommitLineData
a05adbe9 1#include "Riostream.h"
2void LoadLibraries();
3void AddAnalysisTasks();
4class AliAnalysisAlien;
5AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode);
6
ad4c45fb 7Int_t runNumbers[5] = {126437};
a05adbe9 8
a05adbe9 9Bool_t doQAsym = 1; // output ok
10Bool_t doVZERO = 1; // output ok but there is a 2nd file
11Bool_t doVertex = 1; // output ok
12Bool_t doSPD = 1; // output ok, needs RP
a05adbe9 13Bool_t doTPC = 1; // output ok
14Bool_t doEventStat = 0; // output ok
15Bool_t doSDD = 1; // outout ok needs RP
16Bool_t doSSDdEdx = 1; // testing
17// new
18Bool_t doTRD = 1; // TRD
19Bool_t doITS = 1; // ITS
20Bool_t doCALO = 1; // Calorimeter
21Bool_t doMUONTrig = 1; // MUON trigger
22Bool_t doImpParRes = 1; // Impact parameter resolution
23Bool_t doMUON = 1; // MUON QA
24
25Bool_t doMUONEff = 0; // MUON efficiency NEEDS geometry
26Bool_t doV0 = 0; // V0 recosntruction performance NEEDS MCtruth
27
ad4c45fb 28TString train_name = "QA"; // QA local folder name
29TString train_tag = ""; // Train special tag appended to
30 // visible name. ("sim", "pp", ...)
31 // Name in train page (DON'T CHANGE)
32TString visible_name = Form("QA$2_$3%s", train_tag.Data()); //# FIXED #
2bfe5463 33TString job_comment = "PWGPP QA train"; // Can add observations here
ad4c45fb 34 // Job tag (DON'T CHANGE)
35TString job_tag = Form("%s: %s", visible_name.Data(), job_comment.Data());
36 // Package versions - Modify as needed
37TString root_version = "v5-27-06-1";
38TString aliroot_version = "v4-20-12-AN";
39 // Production directory - change as needed for test mode
40TString grid_datadir = "/alice/sim/LHC10f7";
41 // Work directory in GRID (DON'T CHANGE)
42TString grid_workdir = "/alice/cern.ch/user/a/alidaq/QA/QA$2";
43 // Job splitting
44Int_t grid_split = 20; // Splitting
45 // Debug level
46Int_t debug_level = 1; // Debugging
47 // Data pattern - change as needed for test mode
a05adbe9 48TString data_pattern = "*ESDs.root";
ad4c45fb 49 // Output directory (DON'T CHANGE)
50TString alien_outdir = "$1/QA$2";
51 // Input collection (production mode)
52TString data_collection = "$1/qa1.xml";
53TString mergeExcludes = ""; // Files to be excluded for merging
a9b5fbe0 54TString terminateFiles = "trending.root"; // Files produced during Terminate
a05adbe9 55
56Bool_t useProductionMode = kTRUE;
57Bool_t useMergeViaJDL = kTRUE;
58Bool_t useFastReadOption = kTRUE;
ad4c45fb 59Bool_t useOverwriteMode = kFALSE;
a05adbe9 60Bool_t useDevelopmentVersion = kFALSE;
61
62void PilotAnalysis(const char *plugin_mode = "full")
63{
ad4c45fb 64 TString smode(plugin_mode);
65 smode.ToLower();
66 if (smode == "test") useProductionMode = kFALSE;
67 if (!useProductionMode) {
68 TGrid::Connect("alien://");
69 if (!gGrid || !gGrid->IsConnected()) {
70 ::Error("PilotAnalysis", "No grid connection");
71 return;
72 }
73 }
a05adbe9 74 // Write configuration
75 TString cdir = gSystem->WorkingDirectory();
76 gSystem->MakeDirectory(train_name);
77 gSystem->ChangeDirectory(train_name);
78 ofstream out;
79 out.open(Form("%sConfig.C",train_name.Data()), ios::out);
80 out << "{" << endl;
81 out << " train_name = " << "\"" << train_name.Data() << "\";" << endl;
82 out << " root_version = " << "\"" << root_version.Data() << "\";" << endl;
83 out << " aliroot_version = " << "\"" << aliroot_version.Data() << "\";" << endl;
84 out << " grid_datadir = " << "\"" << grid_datadir.Data() << "\";" << endl;
85 if (!alien_outdir.Length()) alien_outdir = Form("output_%s",train_name.Data());
86 out << " alien_outdir = " << "\"" << alien_outdir.Data() << "\";" << endl;
a05adbe9 87 out << " doQAsim = " << doQAsym << ";" << endl;
88 out << " doVZERO = " << doVZERO << ";" << endl;
89 out << " doVertex = " << doVertex << ";" << endl;
90 out << " doSPD = " << doSPD << ";" << endl;
91 out << " doSDD = " << doSDD << ";" << endl;
92 out << " doSSDdEdx = " << doSSDdEdx << ";" << endl;
a05adbe9 93 out << " doTPC = " << doTPC << ";" << endl;
94 out << " doTRD = " << doTRD << ";" << endl;
95 out << " doImpParRes = " << doImpParRes << ";" << endl;
96 out << " doMUON = " << doMUON << ";" << endl;
97 out << " doEventStat = " << doEventStat << ";" << endl;
98 out << "}" << endl;
99 out.close();
100
101 // Load libraries
102 gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TRD");
103 LoadLibraries();
104 // Create manager
105 AliAnalysisManager *mgr = new AliAnalysisManager("PilotAnalysis", "Production train");
106 mgr->SetNSysInfo(100);
107 // Input handler
108 AliESDInputHandlerRP *esdHandler = new AliESDInputHandlerRP();
109 esdHandler->SetReadFriends(kTRUE);
110 esdHandler->SetActiveBranches("ESDfriend");
111 mgr->SetInputEventHandler(esdHandler);
ad4c45fb 112 mgr->SetDebugLevel(debug_level);
113 mgr->SetSaveCanvases(kFALSE);
a05adbe9 114
a05adbe9 115 // AnalysisTasks
116 AddAnalysisTasks();
117 // Grid handler
118 AliAnalysisAlien *alienHandler = CreateAlienHandler(plugin_mode);
119 mgr->SetGridHandler(alienHandler);
120 if (mgr->InitAnalysis()) {
121 mgr->PrintStatus();
122 mgr->StartAnalysis("grid");
a05adbe9 123 }
124}
125
126void LoadLibraries()
127{
128 gSystem->Load("libANALYSIS");
129 gSystem->Load("libANALYSISalice");
130 gSystem->Load("libCORRFW");
af472fff 131 gSystem->Load("libTender");
a05adbe9 132 gSystem->Load("libPWG0base.so");
133 gSystem->Load("libPWG0dep.so");
134 gSystem->Load("libPWG0selectors.so");
2bfe5463 135 gSystem->Load("libPWGPP.so");
a05adbe9 136 gSystem->Load("libPWG2.so");
137 gSystem->Load("libPWG2forward.so");
138
139 if (doCALO) {
140 gSystem->Load("libEMCALUtils");
141 gSystem->Load("libPWG4PartCorrBase");
142 gSystem->Load("libPWG4PartCorrDep");
143 }
144 if(doMUONTrig || doAOD) {
40a0a69c 145 gSystem->Load("libPWGHFbase");
146 gSystem->Load("libPWGmuon");
147 gSystem->Load("libPWGmuondep");
a05adbe9 148 }
149}
150
151void AddAnalysisTasks()
152{
153 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
154 mgr->SetCommonFileName("QAresults.root");
a05adbe9 155 //
156 // Event Statistics (Jan Fiete)
157 //
158
159 if (doEventStat) {
160 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
161 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection();
ad4c45fb 162 if (!terminateFiles.IsNull()) terminateFiles += ",";
163 terminateFiles += "event_stat.root";
a05adbe9 164 }
165 // Vertexing (A. Dainese)
166 //
167 if (doVertex) {
2bfe5463 168 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTaskVertexESD.C");
a05adbe9 169 AliAnalysisTaskVertexESD* taskvertexesd = AddTaskVertexESD();
170 taskvertexesd->SelectCollisionCandidates();
171 }
172
173 // TPC QA (E. Sicking)
174 //
175 if (doQAsym) {
2bfe5463 176 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/PilotTrain/AddTaskQAsym.C");
a05adbe9 177 AliAnalysisTaskSE * taskqasim = AddTaskQAsym(0);
178 taskqasim->SelectCollisionCandidates();
179 }
180 //
181 // VZERO QA (C. Cheshkov)
182 //
183 if (doVZERO) {
2bfe5463 184 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/PilotTrain/AddTaskVZEROQA.C");
a05adbe9 185 AliAnalysisTaskSE * taskv0qa = AddTaskVZEROQA(0);
186// taskv0qa->SelectCollisionCandidates();
187 }
188 //
a28555e1 189 // TPC (Jacek Otwinowski & Michael Knichel)
a05adbe9 190 //
191 if (doTPC) {
2bfe5463 192 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/TPC/macros/AddTaskPerformanceTPCdEdxQA.C");
ad4c45fb 193 AliPerformanceTask *tpcQA = AddTaskPerformanceTPCdEdxQA(kFALSE, kTRUE);
a28555e1 194 tpcQA->SelectCollisionCandidates();
a05adbe9 195 }
196 //
197 // SPD (A. Mastroserio)
198 //
199 if (doSPD) {
2bfe5463 200 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/PilotTrain/AddTaskSPDQA.C");
a05adbe9 201 AliAnalysisTaskSE* taskspdqa = AddTaskSPDQA();
202 taskspdqa->SelectCollisionCandidates();
203 }
204 //
205 // SDD (F. Prino)
206 //
207 if (doSDD) {
2bfe5463 208 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/PilotTrain/AddSDDPoints.C");
a05adbe9 209 AliAnalysisTaskSE* tasksdd = AddSDDPoints();
210 tasksdd->SelectCollisionCandidates();
211 }
212 //
213 // SSD dEdx (Marek Chojnacki)
214 //
215 if (doSSDdEdx) {
2bfe5463 216 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/PilotTrain/AddTaskdEdxSSDQA.C");
a05adbe9 217 AliAnalysisTaskSE* taskssddedx = AddTaskdEdxSSDQA();
218 taskssddedx->SelectCollisionCandidates();
219 }
220
221 //
222 // ITS
223 //
224 if (doITS) {
2bfe5463 225 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTaskPerformanceITS.C");
a05adbe9 226 AliAnalysisTaskITSTrackingCheck *itsQA = AddTaskPerformanceITS(kFALSE);
227 }
228 //
229 // TRD (Alex Bercuci, M. Fasel)
230 //
231 if(doTRD) {
2bfe5463 232 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTrainPerformanceTRD.C");
92238d29 233 // steer individual TRD tasks
234 Bool_t
235 doCheckESD(kTRUE), // AliTRDcheckESD
236 doCheckDET(kTRUE), // AliTRDcheckDET
237 doEffic(kTRUE), // AliTRDefficiency
238 doResolution(kTRUE),// AliTRDresolution
239 doCheckPID(kTRUE), // AliTRDcheckPID
240 doV0Monitor(kFALSE);// AliTRDv0Monitor
241 AddTrainPerformanceTRD(Translate(doCheckESD, doCheckDET, doEffic, doResolution, doCheckPID, doV0Monitor));
a05adbe9 242 }
243
244 //
245 // Calorimetry (Gustavo Conesa)
246 //
247
248 if(doCALO) {
249 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/QA/AddTaskCalorimeterQA.C");
250 AliAnalysisTaskParticleCorrelation *taskCaloQA = AddTaskCalorimeterQA("ESD", kTRUE, kFALSE);
251 taskCaloQA->SetDebugLevel(0);
252 }
253
254 //
255 // Muon Trigger
256 //
257
258 if(doMUONTrig) {
2bfe5463 259 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTaskMTRchamberEfficiency.C");
a05adbe9 260 AliAnalysisTaskTrigChEff *taskMuonTrig = AddTaskMTRchamberEfficiency();
261 }
262
263 //
264 // Muon Efficiency
265 //
266
267 if(doMUONEff) {
268 gROOT->LoadMacro("$ALICE_ROOT/PWG3/muondep/AddTaskMUONTrackingEfficiency.C");
269 AliAnalysisTaskMuonTrackingEff *taskMuonTrackEff = AddTaskMUONTrackingEfficiency();
270 }
271
272 //
273 // V0-Decay Reconstruction (Ana Marin)
274 //
275
276 if (doV0) {
2bfe5463 277 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTaskV0QA.C");
a05adbe9 278 AliAnalysisTaskV0QA *taskv0QA = AddTaskV0QA(kFALSE);
279 }
a05adbe9 280 // Impact parameter resolution (xianbao.yuan@pd.infn.it, andrea.dainese@pd.infn.it)
281 //
282 if (doImpParRes) {
2bfe5463 283 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTaskImpParRes.C");
a05adbe9 284 AliAnalysisTaskSE* taskimpparres= AddTaskImpParRes();
285 taskimpparres->SelectCollisionCandidates();
286 }
287 // MUON QA (Philippe Pillot)
288 //
289 if (doMUON) {
290 gROOT->LoadMacro("$ALICE_ROOT/PWG3/muon/AddTaskMuonQA.C");
291 AliAnalysisTaskSE* taskmuonqa= AddTaskMuonQA(kFALSE, kFALSE);
292 }
293}
294
295//______________________________________________________________________________
296AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
297{
298// Check if user has a valid token, otherwise make one. This has limitations.
299// One can always follow the standard procedure of calling alien-token-init then
300// source /tmp/gclient_env_$UID in the current shell.
301 if (!AliAnalysisGrid::CreateToken()) return NULL;
302 AliAnalysisAlien *plugin = new AliAnalysisAlien();
303// Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
304 plugin->SetRunMode(plugin_mode);
ad4c45fb 305 if (useProductionMode) {
306 plugin->SetProductionMode();
307 plugin->AddDataFile(data_collection);
308 }
a05adbe9 309 plugin->SetJobTag(job_tag);
310 plugin->SetNtestFiles(1);
ad4c45fb 311 plugin->SetCheckCopy(kFALSE);
312 plugin->SetOneStageMerging(kTRUE);
a05adbe9 313// Set versions of used packages
314 plugin->SetAPIVersion("V1.1x");
315 plugin->SetROOTVersion(root_version);
316 plugin->SetAliROOTVersion(aliroot_version);
317// Declare input data to be processed.
318// Method 1: Create automatically XML collections using alien 'find' command.
319// Define production directory LFN
320 plugin->SetGridDataDir(grid_datadir);
321// Set data search pattern
322 plugin->SetDataPattern(data_pattern);
323// ...then add run numbers to be considered
324// if (!iAODanalysis) plugin->SetRunRange(run_range[0], run_range[1]);
325 //plugin->SetRunPrefix("000");
326// plugin->SetOutputSingleFolder("output");
ad4c45fb 327 if (!useProductionMode) {
328 plugin->SetOutputToRunNo();
329 for (Int_t i=0; i<2; i++) {
330 if (!runNumbers[i]) break;
331 plugin->AddRunNumber(runNumbers[i]);
332 }
333 }
a05adbe9 334// Define alien work directory where all files will be copied. Relative to alien $HOME.
ad4c45fb 335 plugin->SetGridWorkingDir(grid_workdir);
a05adbe9 336// Declare alien output directory. Relative to working directory.
337 if (alien_outdir.IsNull()) alien_outdir = Form("output_%s",train_name.Data());
338 plugin->SetGridOutputDir(alien_outdir);
339
340 if (useDevelopmentVersion) {
341 plugin->EnablePackage("STEERBase");
342 plugin->EnablePackage("ESD");
343 plugin->EnablePackage("AOD");
344 plugin->EnablePackage("ANALYSIS");
345 plugin->EnablePackage("ANALYSISalice");
346 }
347
348// Declare the analysis source files names separated by blancs. To be compiled runtime
349// using ACLiC on the worker nodes.
350// Declare all libraries (other than the default ones for the framework. These will be
351// loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
352 plugin->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TRD");
353
af472fff 354 plugin->SetAdditionalLibs("libTender.so libPWG0base.so libPWG0dep.so libPWG0selectors.so libPWGPP.so libPWG2.so \
a05adbe9 355 libPWG2forward.so libEMCALUtils.so libPWG4PartCorrBase.so libPWG4PartCorrDep.so \
40a0a69c 356 libPWGHFbase.so libPWGmuon.so libPWGmuondep.so");
a05adbe9 357
358// Declare the output file names separated by blancs.
359// (can be like: file.root or file.root@ALICE::Niham::File)
360 plugin->SetDefaultOutputs();
a05adbe9 361 plugin->SetMaxMergeFiles(20);
362 plugin->SetNrunsPerMaster(1);
a05adbe9 363
364 // Put default output files to archive
365 TString listhists = "";
366 TString listaods = "";
367 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
a05adbe9 368 if (!mergeExcludes.IsNull()) plugin->SetMergeExcludes(mergeExcludes);
ad4c45fb 369 if (!terminateFiles.IsNull()) plugin->SetTerminateFiles(terminateFiles);
a05adbe9 370// Set friends
a05adbe9 371// Optionally set a name for the generated analysis macro (default MyAnalysis.C)
372 plugin->SetAnalysisMacro(Form("%s.C", train_name.Data()));
373// Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
ad4c45fb 374 plugin->SetSplitMaxInputFileNumber(grid_split);
a05adbe9 375// Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
376// plugin->SetMaxInitFailed(5);
ad4c45fb 377// Optionally modify the number of replicas
378 plugin->SetNumberOfReplicas(4);
a05adbe9 379// Optionally resubmit threshold.
380// plugin->SetMasterResubmitThreshold(90);
381// Optionally set time to live (default 30000 sec)
382 plugin->SetTTL(70000);
383// Optionally set input format (default xml-single)
384 plugin->SetInputFormat("xml-single");
385// Optionally modify the name of the generated JDL (default analysis.jdl)
386 plugin->SetJDLName(Form("%s.jdl", train_name.Data()));
387// Optionally modify the executable name (default analysis.sh)
388 plugin->SetExecutable(Form("%s.sh", train_name.Data()));
389// Optionally modify job price (default 1)
390 plugin->SetPrice(1);
391// Optionally modify split mode (default 'se')
392 plugin->SetSplitMode("se");
393 plugin->SetExecutableCommand("aliroot -b -q");
394// Merge via JDL
395 plugin->SetMergeViaJDL(useMergeViaJDL);
396// Use fastread option
397 plugin->SetFastReadOption(useFastReadOption);
398// UseOverwrite mode
399 plugin->SetOverwriteMode(useOverwriteMode);
ad4c45fb 400/*********************************************************
401 *** PROOF MODE SPECIFIC SETTINGS ************
402 *********************************************************/
403// Proof cluster
404// plugin->SetProofCluster("alice-caf");
405 plugin->SetProofCluster("skaf.saske.sk");
406// Dataset to be used
407 plugin->SetProofDataSet("/alice/data/LHC10e_000128175_p1#esdTree");
408// May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard
409 plugin->SetProofReset(0);
410// May limit number of workers
411 plugin->SetNproofWorkers(20);
412// May use a specific version of root installed in proof
413 plugin->SetRootVersionForProof("current_dbg");
414// May set the aliroot mode. Check http://aaf.cern.ch/node/83
415 plugin->SetAliRootMode("ALIROOT"); // Loads AF libs by default
416// May request ClearPackages (individual ClearPackage not supported)
417 plugin->SetClearPackages(kFALSE);
418// Plugin test mode works only providing a file containing test file locations
2bfe5463 419 plugin->SetFileForTestMode(gSystem->ExpandPathName("$ALICE_ROOT/PWGPP/PilotTrain/files.txt"));
a05adbe9 420 return plugin;
421}