Updates
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / sim / AOD.C
CommitLineData
f8b7a926 1/**
2 * @file AOD.C
3 * @author Christian Holm Christensen <cholm@nbi.dk>
4 * @date Wed Sep 24 15:02:00 2014
5 *
6 * @brief Master script for AOD production.
7 *
8 * @note Do not modify this script.
9 *
421f877c 10 * This script reads in 4 other scripts
f8b7a926 11 *
12 * - GRP.C to load the global run parameters for the selected run,
13 * such as collision system, energy, etc.
14 *
15 * - AODConfig.C which defines a number of functions that return
16 * either true or false. The tasks added depends on these functions
421f877c 17 *
18 * - BaseConfig.C which defines some base classes
19 *
20 * - DetConfig.C which defines which detectors are active and on.
21 *
22 * Users can customize QAConfig.C and DetConfig.C according to their
23 * needs
f8b7a926 24 */
25/** Path to CDB */
26const char *cdbPath = "raw://";
ee275c29 27Bool_t cholm = false;
f8b7a926 28/**
29 * Interface (pure virtual) that all configuration classes must
30 * implement.
31 */
32struct VirtualAODCfg
33{
34 /**
35 * @{
36 * @name Plug-in settings
37 * Settings that make sense when using the Alien plugin
38 */
39 /** @return Connect to CDB */
40 virtual Bool_t UseCDBconnect() const = 0;
41 /** @return use physics selection */
42 virtual Bool_t UsePhysicsSelection() const = 0;
43 /** @return use tender wagon */
44 virtual Bool_t UseTender() const = 0;
45 /** @return centrality */
46 virtual Bool_t UseCentrality() const = 0;
47 /** @return use V0 correction in tender */
48 virtual Bool_t UseV0tender() const = 0;
49 /** @return activate debugging */
50 virtual Bool_t UseDBG() const = 0;
51 /** @return use MC info */
52 virtual Bool_t UseMC() const = 0;
53 /** @return use Kinematics filter */
54 virtual Bool_t UseKFILTER() const = 0;
55 /** @return use track references */
56 virtual Bool_t UseTR() const = 0;
57 /** @return do not change */
58 virtual Bool_t UseCORRFW() const = 0;
59 /** @return use AOD tags */
60 virtual Bool_t UseAODTAGS() const = 0;
61 /** @return use sys info */
62 virtual Bool_t UseSysInfo() const = 0;
63 /* @} */
64
65 /**
66 * @{
67 * @name Modules
68 * Analysis modules to be included. Some may not be yet fully implemented.
69 */
70 /** @return Analysis produces an AOD or dAOD's */
71 virtual Bool_t UseAODhandler() const = 0;
72 /** @return ESD to AOD filter (barrel + muon tracks) */
73 virtual Bool_t UseESDfilter() const = 0;
74 /** @return Use Muon train */
75 virtual Bool_t UsePWGMuonTrain() const = 0;
76 /** @return Task that copies only muon events */
77 virtual Bool_t UseMUONcopyAOD() const = 0;
78 /** @return Jet analysis (PWG4) */
79 virtual Bool_t UseJETAN() const = 0;
80 /** @return Jet delta AODs */
81 virtual Bool_t UseJETANdelta() const = 0;
82 /** @return Vertexing HF task (PWG3) */
83 virtual Bool_t UsePWGHFvertexing() const = 0;
84 /** @return JPSI filtering (PWG3) */
85 virtual Bool_t UsePWGDQJPSIfilter() const = 0;
86 /** @return D0->2 hadrons (PWG3) */
87 virtual Bool_t UsePWGHFd2h() const = 0;
88 /** @return PID response */
89 virtual Bool_t UsePIDResponse() const = 0;
90 /** @return Forward mult task (PWGLF) */
91 virtual Bool_t UsePWGLFForward() const = 0;
92 /* @} */
ee275c29 93 /**
94 * Print one flag
95 *
96 * @param title Title
97 * @param use Use or not
98 */
99 virtual void PrintOne(const char* title, Bool_t use) const
100 {
101 Printf("%-30s : %3s", title, use ? "yes" : "no");
102 }
103 /**
104 * Print settings
105 *
106 */
107 virtual void Print() const {
108 PrintOne("Connect to CDB", UseCDBconnect());
109 PrintOne("Use physics selection", UsePhysicsSelection());
110 PrintOne("Use tender wagon", UseTender());
111 PrintOne("Use centrality", UseCentrality());
112 PrintOne("Use V0 correction in tender", UseV0tender());
113 PrintOne("Activate debugging", UseDBG());
114 PrintOne("Use MC info", UseMC());
115 PrintOne("Use Kinematics filter", UseKFILTER());
116 PrintOne("Use track references", UseTR());
117 PrintOne("Use correction framework", UseCORRFW());
118 PrintOne("Use AOD tags", UseAODTAGS());
119 PrintOne("Use sys info", UseSysInfo());
120 PrintOne("Produces an AOD or dAOD's", UseAODhandler());
121 PrintOne("ESD to AOD filter", UseESDfilter());
122 PrintOne("Use Muon train ", UsePWGMuonTrain());
123 PrintOne("Copy muon events", UseMUONcopyAOD());
124 PrintOne("Jet analysis (PWG4)", UseJETAN());
125 PrintOne("Jet delta AODs", UseJETANdelta());
126 PrintOne("Vertexing HF task (PWG3)", UsePWGHFvertexing());
127 PrintOne("JPSI filtering (PWG3)", UsePWGDQJPSIfilter());
128 PrintOne("D0->2 hadrons (PWG3)", UsePWGHFd2h());
129 PrintOne("PID response", UsePIDResponse());
130 PrintOne("Forward mult task (PWGLF)", UsePWGLFForward());
131 }
f8b7a926 132};
133
134VirtualAODCfg* aodCfg = 0;
135
136//====================================================================
137/**
138 * Load a library/module
139 *
140 * @param module Library/module name
141 *
142 * @return true on success
143 */
144Bool_t LoadLibrary(const char *module)
145{
146 // Load a module library in a given mode. Reports success.
147 Int_t result = 0;
148 TString mod(module);
149 ::Info("LoadLibrary", "Loading %s", module);
150 gROOT->IncreaseDirLevel();
151
152 if (mod.IsNull()) {
153 ::Error("AnalysisTrainNew.C::LoadLibrary", "Empty module name");
154 gROOT->DecreaseDirLevel();
155 return kFALSE;
156 }
157
158 // If a library is specified, just load it
159 if (mod.EndsWith(".so")) {
160 mod.Remove(mod.Index(".so"));
161 ::Info("LoadLibrary", "Loading .so: %s", mod.Data());
162 result = gSystem->Load(mod);
163 if (result < 0) {
164 ::Error("AnalysisTrainNew.C::LoadLibrary",
165 "Could not load library %s", module);
166 }
167 gROOT->DecreaseDirLevel();
168 return (result >= 0);
169 }
170 // Check if the library is already loaded
171 if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0) {
172 ::Info("LoadLibrary", "Module %s.so already loaded", module);
173 gROOT->DecreaseDirLevel();
174 return kTRUE;
175 }
176
177 ::Info("LoadLibrary", "Trying to load lib%s.so", module);
178 result = gSystem->Load(Form("lib%s.so", module));
179 if (result < 0)
180 ::Error("AnalysisTrainNew.C::LoadLibrary",
181 "Could not load module %s", module);
182 ::Info("LoadLibrary", "Module %s, successfully loaded", module);
183 gROOT->DecreaseDirLevel();
184 return (result >= 0);
185}
186
187//====================================================================
188/**
189 * Load common libraries
190 *
191 * @return true on sucess
192 */
193Bool_t LoadCommonLibraries()
194{
195 // Load common analysis libraries.
196 if (!gSystem->Getenv("ALICE_ROOT")) {
197 ::Error("AnalysisTrainNew.C::LoadCommonLibraries",
198 "Analysis train requires that analysis libraries are "
199 "compiled with a local AliRoot");
200 return kFALSE;
201 }
202
203 Bool_t success = kTRUE;
204 // Load framework classes. Par option ignored here.
205 success &= LoadLibrary("libSTEERBase.so");
206 success &= LoadLibrary("libESD.so");
207 success &= LoadLibrary("libAOD.so");
208 success &= LoadLibrary("libANALYSIS.so");
209 success &= LoadLibrary("libOADB.so");
210 success &= LoadLibrary("libANALYSISalice.so");
211 success &= LoadLibrary("libESDfilter.so");
212 success &= LoadLibrary("libCORRFW.so");
213 gROOT->ProcessLine(".include $ALICE_ROOT/include");
214 if (success) {
215 ::Info("AnalysisTrainNew.C::LoadCommodLibraries",
216 "Load common libraries: SUCCESS");
217 ::Info("AnalysisTrainNew.C::LoadCommodLibraries",
218 "Include path for Aclic compilation:\n%s",
219 gSystem->GetIncludePath());
220 } else {
221 ::Info("AnalysisTrainNew.C::LoadCommodLibraries",
222 "Load common libraries: FAILED");
223 }
224 return success;
225}
226
227//====================================================================
228/**
229 * Load libraries needed by the train
230 *
231 * @param useTender
232 * @param doCDBconnect
233 * @param iESDfilter
234 * @param iPWGMuonTrain
235 * @param iJETAN
236 * @param iJETANdelta
237 * @param iPWGHFvertexing
238 * @param iPWGHFd2h
239 * @param iPWGDQJPSIfilter
240 *
241 * @return true on success
242 */
243Bool_t LoadAnalysisLibraries()
244{
245 // Load common analysis libraries.
246 if (aodCfg->UseTender() || aodCfg->UseCDBconnect()) {
247 if (!LoadLibrary("TENDER") ||!LoadLibrary("TENDERSupplies")) return kFALSE;
248 }
249 // CDBconnect
250 if ((aodCfg->UseCDBconnect() && !aodCfg->UseTender())
251 && !LoadLibrary("PWGPP")) return false;
ee275c29 252 if ((aodCfg->UseESDfilter() ||
253 (aodCfg->UsePWGMuonTrain() && detCfg->UseMUON())))
254 if (!LoadLibrary("PWGmuon")) return kFALSE;
f8b7a926 255 // JETAN
ee275c29 256 if ((aodCfg->UseJETAN() || aodCfg->UseJETANdelta()))
257 if (!LoadLibrary("JETAN")) return kFALSE;
f8b7a926 258 if (aodCfg->UseJETANdelta()) { // CINT doesn't like long '||' chains
259 if (!LoadLibrary("CGAL")) return false;
260 if (!LoadLibrary("fastjet")) return false;
261 if (!LoadLibrary("siscone")) return false;
262 if (!LoadLibrary("SISConePlugin")) return false;
263 if (!LoadLibrary("FASTJETAN")) return false;
264 }
265
266 // PWG3 Vertexing HF
ee275c29 267 if (aodCfg->UsePWGHFvertexing() || aodCfg->UsePWGHFd2h())) {
f8b7a926 268 // CINT doesn't like long '||' chains
269 if (!LoadLibrary("PWGflowBase")) return false;
270 if (!LoadLibrary("PWGflowTasks")) return false;
ee275c29 271 if (cholm) if (!LoadLibrary("PWGTRD")) return false;
f8b7a926 272 if (!LoadLibrary("PWGHFvertexingHF")) return false;
273 }
274
275 // PWG3 dielectron
276 if (aodCfg->UsePWGDQJPSIfilter() &&
277 !LoadLibrary("PWGDQdielectron")) return kFALSE;
278
279 ::Info("AnalysisTrainNew.C::LoadAnalysisLibraries",
280 "Load other libraries: SUCCESS");
281 return kTRUE;
282}
283
284//====================================================================
285/**
286 * Add tasks to the train
287 *
288 * @param cdb_location
289 */
290void AddAnalysisTasks(const char *cdb_location)
291{
292 // === Add all analysis task wagons to the train ===================
293 //
294 // --- Some constants ----------------------------------------------
295 TString ali = "$(ALICE_ROOT)";
296 TString ana = ali + "/ANALYSIS";
297 TString pwghf = ali + "/PWGHF";
298 TString pwglf = ali + "/PWGLF";
299 TString pwgje = ali + "/PWGJE";
300 TString pwgdq = ali + "/PWGDQ";
301 TString pwgpp = ali + "/PWGPP";
302
303 // --- Get the analysis manager ------------------------------------
304 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
305 AliAnalysisManager::SetCommonFileName("AODQA.root");
306
307 // --- PIDResponse(JENS) -------------------------------------------
308 if (aodCfg->UsePIDResponse()) {
309 gROOT->LoadMacro(ana+"/macros/AddTaskPIDResponse.C");
310 AliAnalysisTaskPIDResponse *PIDResponse = AddTaskPIDResponse(kTRUE);
311 }
312
313 // --- CDB connection ----------------------------------------------
314 if (aodCfg->UseCDBconnect() && !aodCfg->UseTender()) {
315 gROOT->LoadMacro(pwgpp+"/PilotTrain/AddTaskCDBconnect.C");
316 AliTaskCDBconnect *taskCDB = AddTaskCDBconnect(cdb_location, grp->run);
317 if (!taskCDB) return;
318
319 AliCDBManager *cdb = AliCDBManager::Instance();
320 // cdb->SetDefaultStorage(cdb_location);
321 cdb->SetDefaultStorageFromRun(grp->run);
322 }
323 if (aodCfg->UseTender()) {
324 gROOT->LoadMacro(ana+"/TenderSupplies/AddTaskTender.C");
325 AliAnalysisTaskSE *tender = AddTaskTender(aodCfg->UseV0tender());
326 }
327
328 // --- Physics selection -------------------------------------------
329 if (aodCfg->UsePhysicsSelection()) {
330 // Physics selection task
331 gROOT->LoadMacro(ana+"/macros/AddTaskPhysicsSelection.C");
332 mgr->RegisterExtraFile("event_stat.root");
333 AliPhysicsSelectionTask *physSelTask =
334 AddTaskPhysicsSelection(aodCfg->UseMC());
335 }
336
337 // --- Centrality (only Pb-Pb) -------------------------------------
338 if (aodCfg->UseCentrality()) {
339 gROOT->LoadMacro(ana+"/macros/AddTaskCentrality.C");
340 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
341 taskCentrality->SetMCInput();
342 }
343
344 // --- PWGLF - Forward (cholm@nbi.dk) -----------------------------
ee275c29 345 if (aodCfg->UsePWGLFForward() &&
346 aodCfg->UsePhysicsSelection() &&
347 detCfg->UseFMD()) {
f8b7a926 348 gROOT->LoadMacro(pwglf+"/FORWARD/analysis2/AddTaskForwardMult.C");
349 // Arguments are
350 // mc Assume MC input
351 // runNo Run number to do local initialization - not used
352 // sys Collision system (1:pp,2:PbPb,3:pPb/Pbp) - not used
353 // sNN Collision energy in GeV - not used
354 // field L3 magnetic field strength - not used
355 // config Configuration script
356 // corrdir Possible directory containing custom OADB corrections
357 // HACK load custom corrections
ee275c29 358 Info("", "Adding forward AOD task with mc=%d",
359 aodCfg->UseMC() && aodCfg->UseTR());
f8b7a926 360 AddTaskForwardMult(aodCfg->UseMC() && aodCfg->UseTR(),0,0,0,0,
361 "ForwardAODConfig.C",".");
362 gROOT->LoadMacro(pwglf+"/FORWARD/analysis2/AddTaskCentralMult.C");
363 AddTaskCentralMult(aodCfg->UseMC() && aodCfg->UseTR(),0,0,0,0,
364 "CentralAODConfig.C");
365 const char* hack2="AliForwardCorrectionManager::Instance().Print(\"R\")";
366 gROOT->ProcessLine(hack2);
367 }
368
369
370 // --- ESD filter --------------------------------------------------
371 if (aodCfg->UseESDfilter()) {
372 // ESD filter task configuration.
373 gROOT->LoadMacro(ana+"/ESDfilter/macros/AddTaskESDFilter.C");
ee275c29 374 if (aodCfg->UseMUONcopyAOD() && detCfg->UseMUON()) {
f8b7a926 375 printf("Registering delta AOD file\n");
376 mgr->RegisterExtraFile("AliAOD.Muons.root");
377 mgr->RegisterExtraFile("AliAOD.Dimuons.root");
378 }
379 UInt_t runFlag = (grp->Year()%100)*100;
380 AliAnalysisTaskESDfilter *taskesdfilter =
381 AddTaskESDFilter(aodCfg->UseKFILTER(),
382 aodCfg->UseMUONcopyAOD(), // write Muon AOD
383 kFALSE, // write dimuon AOD
384 kFALSE, // usePhysicsSelection
385 kFALSE, // centrality OBSOLETE
386 kTRUE, // enable TPS only tracks
387 kFALSE, // disable cascades
388 kFALSE, // disable kinks
389 runFlag); // run flag (YY00)
390 }
391
392 TString configPWGHFd2h =
393 (grp->IsPP() ?
394 pwghf+"/vertexingHF/ConfigVertexingHF.C" :
395 pwghf+"/vertexingHF/ConfigVertexingHF_Pb_AllCent.C");
396
397 // --- PWG3 vertexing ----------------------------------------------
398 if (aodCfg->UsePWGHFvertexing()) {
399 gROOT->LoadMacro(pwghf+"/vertexingHF/macros/AddTaskVertexingHF.C");
400
401 if (!aodCfg->UsePWGHFd2h())
402 TFile::Cp(gSystem->ExpandPathName(configPWG3d2h.Data()),
403 "file:ConfigVertexingHF.C");
404
405 AliAnalysisTaskSEVertexingHF *taskvertexingHF = AddTaskVertexingHF();
406 if (!taskvertexingHF)
407 ::Warning("AnalysisTrainNew",
408 "AliAnalysisTaskSEVertexingHF cannot run for this train "
409 "conditions - EXCLUDED");
410 else
411 mgr->RegisterExtraFile("AliAOD.VertexingHF.root");
412
413 taskvertexingHF->SelectCollisionCandidates(0);
414 }
415
416 // ---- PWG3 JPSI filtering (only pp) ------------------------------
a0bdf9a4 417 if (aodCfg->UsePWGDQJPSIfilter()) {
f8b7a926 418 gROOT->LoadMacro(pwgdq+"/dielectron/macros/AddTaskJPSIFilter.C");
419 AliAnalysisTaskSE *taskJPSIfilter = AddTaskJPSIFilter();
420
421 if (!taskJPSIfilter)
422 ::Warning("AnalysisTrainNew",
423 "AliAnalysisTaskDielectronFilter cannot run for this train "
424 "conditions - EXCLUDED");
425 else
426 mgr->RegisterExtraFile("AliAOD.Dielectron.root");
427
428 taskJPSIfilter->SelectCollisionCandidates(0);
429 }
430
431 // --- PWG3 D2h ----------------------------------------------------
ee275c29 432 if (aodCfg->UsePWGHFd2h() && aodCfg->UsePWGHFvertexing()) {
f8b7a926 433 gROOT->LoadMacro(pwghf+"/vertexingHF/AddD2HTrain.C");
434 TFile::Cp(gSystem->ExpandPathName(configPWGHFd2h.Data()),
435 "file:ConfigVertexingHF.C");
436 AddD2HTrain(kFALSE, 1,0,0,0,0,0,0,0,0,0,0);
437 }
438
439 // --- Jet analysis ------------------------------------------------
440
441 // Configurations flags, move up?
442 if (aodCfg->UseJETAN()) {
a0bdf9a4 443#if 0
f8b7a926 444 Warning("", "JET analysis disabled - major restructuring ofg JETAN");
445#else
446 TString jetAOD = "AliAOD.Jets.root";
447 UInt_t highPtMask = 768;// from esd filter
448 TString subtractBranches = "";
449 UInt_t psFlag = 0;
450
451 Info("", "Loading macro %s/macros/AddTaskJets.C", pwgje.Data());
452 gROOT->LoadMacro(pwgje+"/macros/AddTaskJets.C");
453 // Default jet reconstructor running on ESD's
454 // no background subtraction
455 AliAnalysisTask* task = AddTaskJets("AOD","UA1",0.4F,highPtMask,1.F,0);
456 if (!task)
457 ::Fatal("AnalysisTrainNew",
458 "AliAnalysisTaskJets cannot run for this train "
459 "conditions - EXCLUDED");
460
461 AliAnalysisTaskJets* taskjets = static_cast<AliAnalysisTaskJets*>(task);
462 if(!jetAOD.IsNull()) taskjets->SetNonStdOutputFile(jetAOD);
463
464 if (aodCfg->UseJETANdelta()) {
465 // need to modify this accordingly in the add task jets
466 // AddTaskJetsDelta("AliAOD.Jets.root");
467 mgr->RegisterExtraFile(jetAOD);
468 TString cTmp("");
469
470 if(grp->IsAA()){
471 // UA1 intrinsic background subtraction
472 // background subtraction
473 taskjets = AddTaskJets("AOD","UA1",0.4,highPtMask,1.,2);
474 if(!jetAOD.IsNull()) taskjets->SetNonStdOutputFile(jetAOD);
475 }
476 // SICONE
477 //no background subtration to be done later....
478 taskjets = AddTaskJets("AOD","SISCONE",0.4,highPtMask,0.15,0);
479 if(!jetAOD.IsNull()) taskjets->SetNonStdOutputFile(jetAOD.Data());
480 cTmp = taskjets->GetNonStdBranch();
481 if(!cTmp.IsNull()) subtractBranches += Form("%s ",cTmp.Data());
482
483 // Add the clusters..
484 gROOT->LoadMacro(pwgje+"/macros/AddTaskJetCluster.C");
485 AliAnalysisTaskJetCluster *taskCl = 0;
486 Float_t fCenUp = 0;
487 Float_t fCenLo = 0;
488 Float_t fTrackEtaWindow = 0.9;
489 // this one is for the background and random jets, random cones
490 // with no skip
491 taskCl = AddTaskJetCluster("AOD","",highPtMask,
492 psFlag,"KT",0.4,0,1,
493 jetAOD,0.15,
494 fTrackEtaWindow,0);
495 taskCl->SetBackgroundCalc(kTRUE);
496 taskCl->SetNRandomCones(10);
497 taskCl->SetCentralityCut(fCenLo,fCenUp);
498 taskCl->SetGhostEtamax(fTrackEtaWindow);
499 TString bkgBranch = Form("%s_%s",
500 AliAODJetEventBackground::StdBranchName(),
501 taskCl->GetJetOutputBranch());
502
503 taskCl = AddTaskJetCluster("AOD", "", highPtMask, psFlag, "ANTIKT",
504 0.4, 2, 1, jetAOD, 0.15);
505 taskCl->SetCentralityCut(fCenLo,fCenUp);
506 if(grp->IsAA()) taskCl->SetBackgroundBranch(bkgBranch.Data());
507
508 taskCl->SetNRandomCones(10);
509 subtractBranches += Form("%s ",taskCl->GetJetOutputBranch());
510
511 taskCl = AddTaskJetCluster("AOD", "", highPtMask, psFlag, "ANTIKT",
512 0.2, 0 , 1, jetAOD, 0.15);
513 taskCl->SetCentralityCut(fCenLo,fCenUp);
514 if(grp->IsAA())taskCl->SetBackgroundBranch(bkgBranch);
515
516 subtractBranches += Form("%s ",taskCl->GetJetOutputBranch());
517
518 // DO THE BACKGROUND SUBTRACTION
519 if(grp->IsAA() && !subtractBranches.IsNull()) {
520 gROOT->LoadMacro(pwgje+"/macros/AddTaskJetBackgroundSubtract.C");
521 AliAnalysisTaskJetBackgroundSubtract *taskSubtract = 0;
522 taskSubtract = AddTaskJetBackgroundSubtract(subtractBranches,1,
523 "B0","B%d");
524 taskSubtract->SetBackgroundBranch(bkgBranch);
525 if(!jetAOD.IsNull()) taskSubtract->SetNonStdOutputFile(jetAOD.Data());
526 }
527 }
528#endif
529 }
530}
531
532
533
534//====================================================================
535/**
536 * Create the input chain
537 *
538 *
539 * @return Pointer to newly allocated train
540 */
541TChain *CreateChain()
542{
543 // Create the input chain
544 chain = new TChain("esdTree");
545 if (gSystem->AccessPathName("AliESDs.root"))
546 ::Error("AnalysisTrainNew.C::CreateChain",
547 "File: AliESDs.root not in ./data dir");
548 else
549 chain->Add("AliESDs.root");
550 if (chain->GetNtrees()) return chain;
551 return NULL;
552}
553
554//====================================================================
555/**
556 * Merge AOD output
557 *
558 */
559void AODMerge()
560{
561 // Merging method. No staging and no terminate phase.
562 TStopwatch timer; timer.Start();
563 TString outputDir = "wn.xml";
a0bdf9a4 564 TObjArray outputFiles;
565 outputFiles.Add(new TObjString("EventStat_temp.root,"));
566 outputFiles.Add(new TObjString("AODQA.root,"));
567 outputFiles.Add(new TObjString("AliAOD.root,"));
568 if (aodCfg->UsePWGHFvertexing())
569 outputFiles.Add(new TObjString("AliAOD.VertexingHF.root,"));
ee275c29 570 if (aodCfg->UseESDfilter() &&
571 aodCfg->UseMUONcopyAOD() &&
572 detCfg->UseMUON())
a0bdf9a4 573 outputFiles.Add(new TObjString("AliAOD.Muons.root,"));
574 if (aodCfg->UseJETAN())
575 outputFiles.Add(new TObjString("AliAOD.Jets.root,"));
576 if (aodCfg->UsePWGDQJPSIfilter())
577 outputFiles.Add(new TObjString("AliAOD.Dielectron.root,"));
578 outputFiles.Add(new TObjString("pyxsec_hists.root"));
f8b7a926 579 TString mergeExcludes = "";
ee275c29 580 TIter iter(&outputFiles);
f8b7a926 581 TObjString* str = 0;
a0bdf9a4 582 Bool_t merged = kTRUE;
f8b7a926 583 while ((str = static_cast<TObjString*>(iter()))) {
a0bdf9a4 584 TString& outputFile = str->GetString();
f8b7a926 585 // Skip already merged outputs
586 if (!gSystem->AccessPathName(outputFile)) {
587 printf("Output file <%s> found. Not merging again.",outputFile.Data());
588 continue;
589 }
590 if (mergeExcludes.Contains(outputFile.Data())) continue;
591 merged = AliAnalysisAlien::MergeOutput(outputFile, outputDir, 10, 0);
592 if (!merged) {
593 printf("ERROR: Cannot merge %s\n", outputFile.Data());
594 continue;
595 }
596 }
597 // all outputs merged, validate
598 ofstream out;
599 out.open("outputs_valid", ios::out);
600 out.close();
601 timer.Print();
602}
603
604//====================================================================
605/**
606 * Set-up and run AOD train
607 *
608 * @param run Run number
609 * @param xmlfile Collection
610 * @param stage Stage
611 */
612void AOD(UInt_t run, const char* xmlfile=0, Int_t stage=0)
613{
ee275c29 614 TString host(gSystem->HostName());
615 cholm = host.BeginsWith("hehi");
616 if (cholm) TGrid::Connect("alien:");
617
f8b7a926 618 // -----------------------------------------------------------------
619 //
620 // Get GRP parameters. Defines global "grp" as a pointer to GRPData
621 //
622 gROOT->Macro(Form("GRP.C(%d)", run));
623 gROOT->Macro("AODConfig.C");
421f877c 624 gROOT->Macro("BaseConfig.C");
ee275c29 625 gROOT->Macro("DetConfig.C");
f8b7a926 626
627 // --- Some settings -----------------------------------------------
628 // Set temporary merging directory to current one
629 gSystem->Setenv("TMPDIR", gSystem->pwd());
630 // Set temporary compilation directory to current one
631 gSystem->SetBuildDir(gSystem->pwd(), kTRUE);
632
633 // --- Friendly message --------------------------------------------
634 printf("===================================================\n");
635 printf("=========== RUNNING FILTERING TRAIN ==========\n");
636 printf("===================================================\n");
637 printf("= Configuring analysis train for:\n");
ee275c29 638 aodCfg->Print();
f8b7a926 639
640 // Load common libraries and set include path
641 if (!LoadCommonLibraries()) {
642 ::Error("AnalysisTrain", "Could not load common libraries");
643 return;
644 }
645
646 // === Make the analysis manager and connect event handlers ========
647 //
648 // --- Analysis manager and load libraries -------------------------
649 AliAnalysisManager *mgr = new AliAnalysisManager("Filter","Production train");
650 if (aodCfg->UseSysInfo()) mgr->SetNSysInfo(100);
651 if (!LoadAnalysisLibraries()) {
652 ::Error("AnalysisTrain", "Could not load analysis libraries");
653 return;
654 }
655
656 // --- Create ESD input handler ------------------------------------
657 AliESDInputHandler *esdHandler = new AliESDInputHandler();
658 mgr->SetInputEventHandler(esdHandler);
659
660 // --- Monte Carlo handler -----------------------------------------
661 if (aodCfg->UseMC()) {
662 AliMCEventHandler* mcHandler = new AliMCEventHandler();
663 mgr->SetMCtruthEventHandler(mcHandler);
664 mcHandler->SetPreReadMode(1);
665 mcHandler->SetReadTR(aodCfg->UseTR());
666 }
667
668 // --- AOD output handler ------------------------------------------
669 if (aodCfg->UseAODhandler()) {
670 AliAODHandler* aodHandler = new AliAODHandler();
671 aodHandler->SetOutputFileName("AliAOD.root");
672 mgr->SetOutputEventHandler(aodHandler);
673 }
674
675 // --- Debugging if needed -----------------------------------------
676 if (aodCfg->UseDBG()) mgr->SetDebugLevel(3);
677
678 // === Set up tasks ================================================
679 //
680 // --- Create tasks ------------------------------------------------
681 AddAnalysisTasks(cdbPath);
682
683 // --- If merging, do so here and exit -----------------------------
684 if (stage > 0) {
685 AODMerge();
686 mgr->InitAnalysis();
687 mgr->SetGridHandler(new AliAnalysisAlien);
688 mgr->StartAnalysis("gridterminate",0);
689 return;
690 }
691 // === Run the analysis ============================================
692 //
693 // --- Make our chain ----------------------------------------------
694 TChain *chain = CreateChain();
695 if (!chain) return;
696
697 // --- Run the thing -----------------------------------------------
698 TStopwatch timer;
699 timer.Start();
700 mgr->SetSkipTerminate(kTRUE);
701 if (mgr->InitAnalysis()) {
702 mgr->PrintStatus();
703 mgr->StartAnalysis("local", chain);
704 }
705 timer.Print();
706}
707
708//
709// EOF
710//
711