1 //===================== ANALYSIS TRAIN =========================================
2 // To use: copy this macro to your work directory, modify the global part to match
3 // your needs, then run root.
4 // root[0] .L AnalysisTrain.C
5 // Grid full mode as below (other modes: test, offline, submit, terminate)
6 // root[1] AnalysisTrainNew("grid", "full")
7 // CAF mode (requires root v5-23-02 + aliroot v4-16-Rev08)
8 // root[2] AnalysisTrainNew("proof")
9 // Local mode requires AliESds.root or AliAOD.root in ./data directory
10 // root[3] AnalysisTrainNew("local")
11 // In proof and grid modes, a token is needed and sourcing the produced environment file.
13 // If 'saveTrain' flag is set, the train will generate a directory name and run
14 // in this directory. A configuration file 'ConfigTrain.C' will be generated.
15 // One can replay at any time the train via:
16 // root[1] AnalysisTrainNew(ana_mode, plugin_mode, "train_default_<date>/ConfigTrain.C")
18 //================== TRAIN NAME ============================================
19 TString train_name = "TR020_LHC10b1ESD"; // *CHANGE ME* (no blancs or special characters)
20 TString job_tag = "TR020: ESD+MC -> AODMC + delta AOD"; // *CHANGE ME*
21 //==============================================================================
23 // ### Settings that make sense in PROOF only
24 //==============================================================================
25 TString proof_cluster = "alicecaf.cern.ch";
26 Bool_t useAFPAR = kFALSE; // use AF special par file
27 TString AFversion = "AF-v4-17";
28 // Change CAF dataset here
29 TString proof_dataset = "/COMMON/COMMON/LHC09a4_run8100X#/esdTree";
30 TString proof_outdir = "";
32 // ### Settings that make sense when using the Alien plugin
33 //==============================================================================
34 Int_t runOnData = 0; // Set to 1 if processing real data
35 Int_t iCollision = 0; // 0=pp, 1=Pb-Pb
36 Bool_t usePLUGIN = kTRUE; // do not change
37 Bool_t useProductionMode = kTRUE; // use the plugin in production mode
38 // Usage of par files ONLY in grid mode and ONLY if the code is not available
39 // in the deployed AliRoot versions. Par file search path: local dir, if not there $ALICE_ROOT.
40 // To refresh par files, remove the ones in the workdir, then do "make <target.par>" in
42 Bool_t usePAR = kFALSE; // use par files for extra libs
43 Bool_t useCPAR = kFALSE; // use par files for common libs
44 TString root_version = "v5-26-00b-2"; // *CHANGE ME IF MORE RECENT IN GRID*
45 TString aliroot_version = "v4-19-09-AN"; // *CHANGE ME IF MORE RECENT IN GRID*
46 // Change production base directory here
47 TString alien_datadir = " /alice/sim/LHC10b1";
48 // AliEn output directory. If blank will become output_<train_name>
49 TString alien_outdir = "/alice/sim/LHC10b1/AOD1";
50 // TString alien_outdir = "";
51 // Output folder to write delta AOD's. Considered if not null.
52 TString outputSingleFolder = "";
53 //TString outputSingleFolder = "deltas";
54 // Number of files merged in a chunk
55 Int_t maxMergeFiles = 20;
56 // Files that should not be merged
57 TString mergeExclude = "AliAOD.root AliAOD.VertexingHF.root AliAOD.Jets.root deltaAODPartCorr.root AliAOD.Muons.root resonances.root forward.root";
58 // Make replicas on the storages below
59 TString outputStorages = "disk=4";
60 // Number of runs per master job
61 Int_t nRunsPerMaster = 10;
62 // Maximum number of files per job (gives size of AOD)
63 Int_t nFilesPerJob = 100;
64 // Int_t nFilesPerJob = 1; (AOD->delta AOD production case)
66 Int_t run_range[2] = {114786, 114949}; // LHC09a7 *CHANGE ME*
67 // ### Settings that make sense only for local analysis
68 //==============================================================================
69 // Change local xml dataset for local interactive analysis
70 TString local_xmldataset = "";
72 // ### Other flags to steer the analysis
73 //==============================================================================
74 Bool_t usePhysicsSelection = kTRUE; // use physics selection
75 Bool_t useMergeViaJDL = kTRUE; // merge via JDL
76 Bool_t useFastReadOption = kFALSE; // use xrootd tweaks
77 Bool_t useOverwriteMode = kTRUE; // overwrite existing collections
78 Bool_t useDATE = kFALSE; // use date in train name
79 Bool_t useDBG = kTRUE; // activate debugging
80 Bool_t useMC = kTRUE; // use MC info
81 Bool_t useTAGS = kTRUE; // use ESD tags for selection
82 Bool_t useKFILTER = kTRUE; // use Kinematics filter
83 Bool_t useTR = kTRUE; // use track references
84 Bool_t useCORRFW = kFALSE; // do not change
85 Bool_t useAODTAGS = kFALSE; // use AOD tags
86 Bool_t saveTrain = kTRUE; // save train configuration as:
87 Bool_t saveCanvases = kTRUE; // save canvases created in Terminate
88 Bool_t saveProofToAlien = kFALSE; // save proof outputs in AliEn
90 // ### Analysis modules to be included. Some may not be yet fully implemented.
91 //==============================================================================
92 Int_t iAODanalysis = 0; // Analysis on input AOD's
93 Int_t iAODhandler = 1; // Analysis produces an AOD or dAOD's
94 Int_t iESDfilter = 1; // ESD to AOD filter (barrel + muon tracks)
95 Int_t iMUONcopyAOD = 1; // Task that copies only muon events in a separate AOD (PWG3)
96 Int_t iJETAN = 1; // Jet analysis (PWG4)
97 Int_t iJETANdelta = 1; // Jet delta AODs
98 Int_t iPWG4partcorr = 1; // Gamma-hadron correlations task (PWG4)
99 Int_t iPWG4gammaconv = 0; // Gamma conversion analysis (PWG4)
100 Int_t iPWG4omega3pi = 0; // Omega to 3 pi analysis (PWG4)
101 Int_t iPWG3vertexing = 1; // Vertexing HF task (PWG3)
102 Int_t iPWG3hfe = 0; // Electrons analysis (PWG3)
103 Int_t iPWG3d2h = 0; // D0->2 hadrons (PWG3)
104 Int_t iPWG3d0mass = 1; // D0 mass (PWG3D2H)
105 Int_t iPWG3d0massLS = 1; // D0 mass LS (PWG3D2H)
106 Int_t iPWG3dplus = 1; // D+ analysis (PWG3D2H)
107 Int_t iPWG3LSd0 = 1; // LS D0 analysis (PWG3D2H)
108 Int_t iPWG3LSjpsi = 1; // LS J/Psi analysis (PWG3D2H)
109 Int_t iPWG3CFd0 = 1; // CF D0 analysis (PWG3D2H)
110 Int_t iPWG3promptd0 = 1; // prompt D0 analysis (PWG3D2H)
111 Int_t iPWG3MuonTrain = 1; // Muon analysis train
112 Int_t iPWG2femto = 0; // Femtoscopy task (PWG2)
113 Int_t iPWG2spectra = 0; // Spectra tasks (PWG2
114 Int_t iPWG2protons = 1; // Proton-antiproton analysis
115 Int_t iPWG2checkcascade = 1; // Check cascades task
116 Int_t iPWG2perfcascade = 1; // Check performance cascade
117 Int_t iPWG2checkv0 = 1; // Check V0 task
118 Int_t iPWG2strange = 1; // Strangeness task
119 Int_t iPWG2central = 1; // Anisothropy in central collisions
120 Int_t iPWG2flow = 0; // Flow analysis tasks (PWG2)
121 Int_t iPWG2res = 0; // Resonances task (PWG2)
122 Int_t iPWG2rsneff = 0; // Resonances efficiency
123 Int_t iPWG2kink = 0; // Kink analysis tasks (PWG2)
124 Int_t iPWG2kinkESDMC = 1; // Kink ESD-MC comparison (PWG2)
125 Int_t iPWG2kinkLSKstar = 1; // Kink like-sign K* (PWG2)
126 Int_t iPWG2kinkLSL1520 = 1; // Kink like-sign L1520 (PWG2)
127 Int_t iPWG2kinkLSPhi = 1; // Kink like-sign Phi (PWG2)
128 Int_t iPWG2kinkKstarESD = 1; // Kink Kstar ESD (PWG2)
129 Int_t iPWG2kinkKstarMC = 1; // Kink Kstar MC (PWG2)
130 Int_t iPWG2kinkL1520ESD = 1; // Kink L1520 ESD (PWG2)
131 Int_t iPWG2kinkL1520MC = 1; // Kink L1520 MC (PWG2)
132 Int_t iPWG2kinkPhiESD = 1; // Kink resonances Phi ESD (PWG2)
133 Int_t iPWG2kinkPhiMC = 1; // Kink resonances Phi MC (PWG2)
134 Int_t iPWG2evchar = 0; // Event characteristics (PWG2)
135 Int_t iPWG2unicor = 0; // Unicor analysis (PWG2)
136 Int_t iPWG2forward = 0; // FMD analysis (PWG2)
138 // ### Configuration macros used for each module
139 //==============================================================================
140 TString configPWG2femto = "$ALICE_ROOT/PWG2/FEMTOSCOPY/macros/Train/Train3/ConfigFemtoAnalysis.C";
141 //TString configPWG3d2h = "$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF_highmult.C";
142 //TString configPWG3d2h = "$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C";
143 TString configPWG3d2h = "$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF_pp2009.C";
145 TString anaPars = "";
146 TString anaLibs = "";
147 // Function signatures
148 class AliAnalysisAlien;
150 //______________________________________________________________________________
151 void AnalysisTrainNew(const char *analysis_mode="grid",
152 const char *plugin_mode="full",
153 const char *config_file="")
155 // Main analysis train macro. If a configuration file is provided, all parameters
156 // are taken from there but may be altered by CheckModuleFlags.
157 if (strlen(config_file) && !LoadConfig(config_file)) return;
158 TString smode(analysis_mode);
160 // Check compatibility of selected modules
161 CheckModuleFlags(smode);
162 if (saveTrain) WriteConfig();
164 printf("==================================================================\n");
165 printf("=========== RUNNING ANALYSIS TRAIN %s IN %s MODE ==========\n", train_name.Data(),smode.Data());
166 printf("==================================================================\n");
167 printf("= Configuring analysis train for: =\n");
168 if (iAODanalysis) printf("= AOD analysis =\n");
169 else printf("= ESD analysis =\n");
170 if (iESDfilter) printf("= ESD filter =\n");
171 if (iMUONcopyAOD) printf("= MUON copy AOD =\n");
172 if (iJETAN) printf("= Jet analysis =\n");
173 if (iJETANdelta) printf("= Jet delta AODs =\n");
175 printf("= PWG2 SPECTRA tasks : =\n");
176 if (iPWG2protons) printf("= PWG2 proton-antiproton =\n");
177 if (iPWG2checkcascade) printf("= PWG2 check cascades =\n");
178 if (iPWG2perfcascade) printf("= PWG2 performance cascades =\n");
179 if (iPWG2checkv0) printf("= PWG2 check V0 =\n");
180 if (iPWG2strange) printf("= PWG2 strangeness =\n");
181 if (iPWG2central) printf("= PWG2 central =\n");
184 printf("= PWG2 femtoscopy =\n");
185 printf(" +++ configured by: %s\n", configPWG2femto.Data());
187 if (iPWG2flow) printf("= PWG2 flow =\n");
188 if (iPWG2res) printf("= PWG2 resonances =\n");
189 if (iPWG2rsneff) printf("= PWG2 resonances efficiency =\n");
191 printf("= PWG2 kink analysis tasks: =\n");
192 if (iPWG2kinkESDMC) printf("= PWG2 ESD-MC kinks =\n");
193 if (iPWG2kinkLSKstar) printf("= PWG2 kink like-sign analysis K* =\n");
194 if (iPWG2kinkLSL1520) printf("= PWG2 kink like-sign analysis L1520 =\n");
195 if (iPWG2kinkLSPhi) printf("= PWG2 kink like-sign analysis Phi =\n");
196 if (iPWG2kinkKstarESD) printf("= PWG2 kink Kstar ESD analysis =\n");
197 if (iPWG2kinkKstarMC) printf("= PWG2 kink Kstar MC analysis =\n");
198 if (iPWG2kinkL1520ESD) printf("= PWG2 kink L1520 ESD analysis =\n");
199 if (iPWG2kinkL1520MC) printf("= PWG2 kink L1520 MC analysis =\n");
200 if (iPWG2kinkPhiESD) printf("= PWG2 kink Phi ESD analysis =\n");
201 if (iPWG2kinkPhiMC) printf("= PWG2 kink Phi MC analysis =\n");
203 if (iPWG2evchar) printf("= PWG2 event characteristics =\n");
204 if (iPWG2unicor) printf("= PWG2 Unicor analysis =\n");
205 if (iPWG2forward) printf("= PWG2 forward: sharing, density, bkg. correction, dNdEta =\n");
206 if (iPWG3vertexing) printf("= PWG3 vertexing =\n");
207 if (iPWG3hfe) printf("= PWG3 electrons =\n");
209 printf("= PWG3 D0->2 hadrons tasks =\n");
210 printf(" +++ configured by: %s\n", configPWG3d2h.Data());
211 if (iPWG3d0mass) printf("= PWG3 D0 mass =\n");
212 if (iPWG3d0massLS) printf("= PWG3 D0 mass LS =\n");
213 if (iPWG3dplus) printf("= PWG3 D+ analysis =\n");
214 if (iPWG3LSd0) printf("= PWG3 LS D0 =\n");
215 if (iPWG3LSjpsi) printf("= PWG3 LS J/Psi =\n");
216 if (iPWG3CFd0) printf("= PWG3 CF D0 =\n");
217 if (iPWG3promptd0) printf("= PWG3 prompt D0 =\n");
219 if (iPWG3MuonTrain) printf("= PWG3 muon train =\n");
220 if (iPWG4partcorr) printf("= PWG4 gamma-hadron, pi0 and gamma-jet correlations =\n");
221 if (iPWG4gammaconv) printf("= PWG4 gamma conversion =\n");
222 if (iPWG4omega3pi) printf("= PWG4 omega to 3 pions =\n");
223 printf("==================================================================\n");
224 printf(":: use physics selection: %d\n", (UInt_t)usePhysicsSelection);
225 printf(":: use xrootd tweaks: %d\n", (UInt_t)useFastReadOption);
226 printf(":: use overwrite xml : %d\n", (UInt_t)useOverwriteMode);
227 printf(":: use merge via JDL: %d\n", (UInt_t)useMergeViaJDL);
228 printf(":: use MC truth: %d\n", (UInt_t)useMC);
229 printf(":: use KINE filter: %d\n", (UInt_t)useKFILTER);
230 printf(":: use track references: %d\n", (UInt_t)useTR);
231 printf(":: use tags: %d\n", (UInt_t)useTAGS);
232 printf(":: use AOD tags: %d\n", (UInt_t)useAODTAGS);
233 printf(":: use debugging: %d\n", (UInt_t)useDBG);
234 printf(":: use PAR files: %d\n", (UInt_t)usePAR);
235 printf(":: use AliEn plugin: %d\n", (UInt_t)usePLUGIN);
237 //==========================================================================
238 // Connect to back-end system
239 if (!Connect(smode)) {
240 ::Error("AnalysisTrain", "Could not connect to %s back-end", analysis_mode);
244 // Load common libraries and set include path
245 if (!LoadCommonLibraries(smode)) {
246 ::Error("AnalysisTrain", "Could not load common libraries");
250 // Make the analysis manager and connect event handlers
251 AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train", "Production train");
252 if (saveProofToAlien) mgr->SetSpecialOutputLocation(proof_outdir);
253 if (!strcmp(plugin_mode, "test")) mgr->SetNSysInfo(1);
254 // Load analysis specific libraries
255 if (!LoadAnalysisLibraries(smode)) {
256 ::Error("AnalysisTrain", "Could not load analysis libraries");
260 // Create input handler (input container created automatically)
263 AliAODInputHandler *aodH = new AliAODInputHandler();
264 if (iPWG3d2h) aodH->AddFriend("AliAOD.VertexingHF.root");
265 mgr->SetInputEventHandler(aodH);
268 AliESDInputHandler *esdHandler = new AliESDInputHandler();
269 if (useTAGS) esdHandler->SetReadTags();
270 mgr->SetInputEventHandler(esdHandler);
272 // Monte Carlo handler
273 if (useMC && !iAODanalysis) {
274 AliMCEventHandler* mcHandler = new AliMCEventHandler();
275 mgr->SetMCtruthEventHandler(mcHandler);
276 mcHandler->SetReadTR(useTR);
278 // AOD output container, created automatically when setting an AOD handler
280 // AOD output handler
281 AliAODHandler* aodHandler = new AliAODHandler();
282 aodHandler->SetOutputFileName("AliAOD.root");
283 mgr->SetOutputEventHandler(aodHandler);
285 aodHandler->SetFillAOD(kFALSE);
286 aodHandler->SetCreateNonStandardAOD();
287 if (iJETAN) aodHandler->SetOutputFileName("AliAOD.Jets.root");
288 // if (iPWG3vertexing) aodHandler->SetOutputFileName("AliAOD.VertexingHF.root");
291 // Debugging if needed
292 if (useDBG) mgr->SetDebugLevel(1);
293 if (saveCanvases) mgr->SetSaveCanvases(kTRUE);
295 //==========================================================================
296 // Create the chain. In this example it is created only from ALIEN files but
297 // can be done to work in batch or grid mode as well.
298 TChain *chain = CreateChain(smode, plugin_mode);
300 //==========================================================================
301 // Load the tasks configuration macros for all wagons. These files are supposed now to be
302 // in the current workdir, but in AliEn they will be in the file catalog,
303 // mapped from AliRoot and pecified in the jdl input list.
305 // For now connection to top input container and common AOD output container
306 // is done in this macro, but in future these containers will be connected
307 // from each task configuration macro.
314 AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
315 AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
318 if (mgr->InitAnalysis()) {
320 if (saveTrain || strlen(config_file)) gSystem->ChangeDirectory(train_name);
321 StartAnalysis(smode, chain);
322 if (saveTrain && smode=="GRID") {
323 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
324 TString alien_workdir = gGrid->GetHomeDirectory();
325 alien_workdir += train_name;
326 alien_outdir = gridhandler->GetGridOutputDir();
327 printf("=== Registering ConfigTrain.C in the work directory <%s> ===\n",
328 alien_workdir.Data());
329 if (AliAnalysisAlien::FileExists(Form("%s/%sConfig.C", alien_workdir.Data(), train_name.Data())))
330 gGrid->Rm(Form("%s/%sConfig.C", alien_workdir.Data(), train_name.Data()));
331 if (strcmp(plugin_mode, "test"))
332 TFile::Cp(Form("file:%sConfig.C",train_name.Data()), Form("alien://%s/%sConfig.C", alien_workdir.Data(), train_name.Data()));
337 //______________________________________________________________________________
338 void AddAnalysisTasks()
340 // Add all analysis task wagons to the train
341 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
343 if (usePhysicsSelection) {
344 // Physics selection task
345 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
346 mgr->RegisterExtraFile("event_stat.root");
347 AddTaskPhysicsSelection(useMC);
350 if (iESDfilter && !iAODanalysis) {
351 // ESD filter task configuration.
352 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C");
354 printf("Registering delta AOD file\n");
355 mgr->RegisterExtraFile("AliAOD.Muons.root");
356 mgr->RegisterExtraFile("AliAOD.Dimuons.root");
357 AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER, kTRUE, kTRUE, usePhysicsSelection);
359 AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER, kFALSE, kFALSE, usePhysicsSelection);
365 AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator");
366 mgr->AddTask(tagTask);
367 AliAnalysisDataContainer *coutTags = mgr->CreateContainer("cTag", TTree::Class(),
368 AliAnalysisManager::kOutputContainer, "AOD.tag.root");
369 mgr->ConnectInput (tagTask, 0, mgr->GetCommonInputContainer());
370 mgr->ConnectOutput(tagTask, 1, coutTags);
373 // ********** PWG2 wagons ******************************************************
374 AliAnalysisManager::SetCommonFileName("PWG2histograms.root");
380 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskProtons.C");
381 AliAnalysisTaskProtons *taskprotons = AddTaskProtons();
382 if (!taskprotons) ::Warning("AnalysisTrainNew", "AliAnalysisTaskProtons cannot run for this train conditions - EXCLUDED");
385 if (iPWG2checkcascade) {
386 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskCheckCascade.C");
387 AliAnalysisTaskCheckCascade *taskcheckcascade = AddTaskCheckCascade(iCollision);
388 if (!taskcheckcascade) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCheckCascade cannot run for this train conditions - EXCLUDED");
392 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskCheckV0.C");
393 AliAnalysisTaskCheckV0 *taskcheckV0 = AddTaskCheckV0();
394 if (!taskcheckV0) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCheckV0 cannot run for this train conditions - EXCLUDED");
398 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskStrange.C");
399 AliAnalysisTaskStrange *taskstrange = AddTaskStrange();
400 if (!taskstrange) ::Warning("AnalysisTrainNew", "AliAnalysisTaskStrange cannot run for this train conditions - EXCLUDED");
402 // performance cascades
403 if (iPWG2perfcascade) {
404 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskCheckPerformanceCascade.C");
405 AliAnalysisTaskCheckPerformanceCascade *taskperfcascade = AddTaskCheckPerformanceCascade();
406 if (!taskperfcascade) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCheckPerformanceCascade cannot run for this train conditions - EXCLUDED");
410 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskCentral.C");
411 AliAnalysisTaskCentral *taskcentral = AddTaskCentral();
412 if (!taskcentral) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCentral cannot run for this train conditions - EXCLUDED");
416 // Femtoscopy analysis modules
418 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FEMTOSCOPY/macros/AddTaskFemto.C");
419 AliAnalysisTaskFemto *taskfemto = AddTaskFemto(configPWG2femto);
420 if (!taskfemto) ::Warning("AnalysisTrainNew", "AliAnalysisTaskFemto cannot run for this train conditions - EXCLUDED");
425 if (iPWG2kinkESDMC) {
426 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKink.C");
427 AliAnalysisKinkESDMC *taskkink1 = AddTaskKink();
428 if (!taskkink1) ::Warning("AnalysisTrainNew", "AliAnalysisKinkESDMC cannot run for this train conditions - EXCLUDED");
430 if (iPWG2kinkLSKstar) {
431 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResLikeSignKstar.C");
432 AliResonanceKinkLikeSign *taskkink2 = AddTaskKinkResLikeSignKstar();
433 if (!taskkink2) ::Warning("AnalysisTrainNew", "AliResonanceKinkLikeSign cannot run for this train conditions - EXCLUDED");
435 if (iPWG2kinkLSL1520) {
436 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResLikeSignL1520.C");
437 AliResonanceKinkLikeSign *taskkink3 = AddTaskKinkResLikeSignL1520();
438 if (!taskkink3) ::Warning("AnalysisTrainNew", "AliResonanceKinkLikeSign cannot run for this train conditions - EXCLUDED");
440 if (iPWG2kinkLSPhi) {
441 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResLikeSignPhi.C");
442 AliResonanceKinkLikeSign *taskkink4 = AddTaskKinkResLikeSignPhi();
443 if (!taskkink4) ::Warning("AnalysisTrainNew", "AliResonanceKinkLikeSign cannot run for this train conditions - EXCLUDED");
445 if (iPWG2kinkKstarESD) {
446 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceKstarESD.C");
447 AliAnalysisTaskKinkResonance *taskkink5 = AddTaskKinkResonanceKstarESD();
448 if (!taskkink5) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonanceKstarESD cannot run for this train conditions - EXCLUDED");
450 if (iPWG2kinkKstarMC) {
451 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceKstarMC.C");
452 AliAnalysisTaskKinkResonance *taskkink6 = AddTaskKinkResonanceKstarMC();
453 if (!taskkink6) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonanceKstarMC cannot run for this train conditions - EXCLUDED");
455 if (iPWG2kinkL1520ESD) {
456 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceL1520ESD.C");
457 AliAnalysisTaskKinkResonance *taskkink7 = AddTaskKinkResonanceL1520ESD();
458 if (!taskkink7) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonanceL1520ESD cannot run for this train conditions - EXCLUDED");
460 if (iPWG2kinkL1520MC) {
461 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceL1520MC.C");
462 AliAnalysisTaskKinkResonance *taskkink8 = AddTaskKinkResonanceL1520MC();
463 if (!taskkink8) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonanceL1520MC cannot run for this train conditions - EXCLUDED");
465 if (iPWG2kinkPhiESD) {
466 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonancePhiESD.C");
467 AliAnalysisTaskKinkResonance *taskkink9 = AddTaskKinkResonancePhiESD();
468 if (!taskkink9) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonancePhiESD cannot run for this train conditions - EXCLUDED");
470 if (iPWG2kinkPhiMC) {
471 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonancePhiMC.C");
472 AliAnalysisTaskKinkResonance *taskkink10 = AddTaskKinkResonancePhiMC();
473 if (!taskkink10) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonancePhiMC cannot run for this train conditions - EXCLUDED");
477 // Event characterization
479 gROOT->LoadMacro("$ALICE_ROOT/PWG2/EVCHAR/macros/AddTaskSPDdNdEta.C");
480 AliAnalysisTaskSPDdNdEta *taskspddndeta = AddTaskSPDdNdEta();
481 if (!taskspddndeta) ::Warning("AnalysisTrainNew", "AliAnalysisTaskSPDdNdEta cannot run for this train conditions - EXCLUDED");
482 taskspddndeta->SetReadMC(useMC);
487 gROOT->LoadMacro("$ALICE_ROOT/PWG2/UNICOR/AddTaskUnicor.C");
488 AliAnalysisTaskUnicor *taskunicor = AddTaskUnicor();
489 if (!taskunicor) ::Warning("AnalysisTrainNew", "AliAnalysisTaskUnicor cannot run for this train conditions - EXCLUDED");
493 AliAnalysisManager::SetCommonFileName("forward.root");
495 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis/AddTaskFMD.C");
496 AliFMDAnalysisTaskSE *taskfmd = AddTaskFMD();
497 if (!taskfmd) ::Warning("AnalysisTrainNew", "AliFMDAnalysisTaskSE cannot run for this train conditions - EXCLUDED");
499 AliAnalysisManager::SetCommonFileName("PWG2histograms.root");
503 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FLOW/macros/AddTaskFlow.C");
505 Bool_t LYZ1SUM = kTRUE;
506 Bool_t LYZ1PROD = kTRUE;
507 Bool_t LYZ2SUM = kFALSE;
508 Bool_t LYZ2PROD = kFALSE;
509 Bool_t LYZEP = kFALSE;
513 Bool_t MCEP = kFALSE; //does not work yet 24/12/08
514 Bool_t kineFromESD = kTRUE;
515 Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP};
516 // Analysis type can be ESD, AOD, MC, ESDMC0, ESDMC1
517 TString type = "AOD";
518 if (!iAODanalysis) type = "ESD";
519 // Boolean to fill/not fill the QA histograms
521 // Boolean to use/not use weights for the Q vector
522 Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
523 AliAnalysisTaskFlowEvent* taskFE = AddTaskFlow(type,METHODS,QA,WEIGHTS);
524 if (!taskFE) ::Warning("AnalysisTrainNew", "AliAnalysisTaskFlowEvent cannot run for this train conditions - EXCLUDED");
528 AliAnalysisManager::SetCommonFileName("resonances.root");
530 gROOT->LoadMacro("$ALICE_ROOT/PWG2/RESONANCES/macros/train/AddAnalysisTaskRsnNew.C");
531 gROOT->LoadMacro("$ALICE_ROOT/PWG2/RESONANCES/macros/train/AddAnalysisTaskRsnEffNew.C");
532 TString path = gROOT->GetMacroPath();
533 path += ":$ALICE_ROOT/PWG2/RESONANCES/macros/train";
534 gROOT->SetMacroPath(path);
535 AddAnalysisTaskRsn(kTRUE);
536 if (iPWG2rsneff) AddAnalysisTaskRsnEff();
538 AliAnalysisManager::SetCommonFileName("PWG2histograms.root");
540 // ********** PWG3 wagons ******************************************************
541 AliAnalysisManager::SetCommonFileName("PWG3histograms.root");
544 if (iPWG3vertexing) {
545 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/AddTaskVertexingHF.C");
546 if (!iPWG3d2h) TFile::Cp(gSystem->ExpandPathName(configPWG3d2h.Data()), Form("%s/ConfigVertexingHF.C", train_name.Data()));
547 AliAnalysisTaskSEVertexingHF *taskvertexingHF = AddTaskVertexingHF();
548 if (!taskvertexingHF) ::Warning("AnalysisTrainNew", "AliAnalysisTaskSEVertexingHF cannot run for this train conditions - EXCLUDED");
549 else mgr->RegisterExtraFile("AliAOD.VertexingHF.root");
554 gROOT->LoadMacro("$ALICE_ROOT/PWG3/hfe/AddTaskHFE.C");
555 AliAnalysisTaskHFE *taskHFE = AddTaskHFE();
556 if (!taskHFE) ::Warning("AnalysisTrainNew", "AliAnalysisTaskHFE cannot run for this train conditions - EXCLUDED");
561 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/AddD2HTrain.C");
562 TFile::Cp(gSystem->ExpandPathName(configPWG3d2h.Data()), Form("%s/ConfigVertexingHF.C", train_name.Data()));
563 AddD2HTrain(iPWG3d0mass,iPWG3d0massLS,iPWG3dplus, iPWG3LSd0, iPWG3LSjpsi, iPWG3CFd0, iPWG3promptd0);
567 if (iPWG3MuonTrain) {
568 gROOT->LoadMacro("$ALICE_ROOT/PWG3/muon/AddPWG3MuonTrain.C");
569 // iESDAnalysis, iAODAnalysis -> flags to select if the train is AOD or ESD based
570 // iMuonDistributions, iSingleMuonANAlysis -> flags to switch on/off analysis wagons
571 Int_t isESDAnalysis = (iAODanalysis)?0:1;
572 Int_t isAODAnalysis = (iAODanalysis)?1:0;
573 Int_t addMuonDistributions = 1;
574 Int_t addSingleMuonAnalysis = 1;
575 Int_t addMuonHFAnalysis = 1;
576 Int_t ntaskmuon = AddPWG3MuonTrain(isESDAnalysis,isAODAnalysis,addMuonDistributions,addSingleMuonAnalysis,addMuonHFAnalysis);
577 printf("Added %d muon tasks\n", ntaskmuon);
580 // ********** PWG4 wagons ******************************************************
581 AliAnalysisManager::SetCommonFileName("PWG4histograms.root");
585 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJets.C");
587 // Default jet reconstructor running on ESD's
588 AliAnalysisTaskJets * taskjets = AddTaskJets();
589 if (!taskjets) ::Warning("AnalysisTrainNew", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED");
591 AddTaskJetsDelta("AliAOD.Jets.root");
592 mgr->RegisterExtraFile("AliAOD.Jets.root");
595 // AOD-based analysis. Add all reconstructors to write into delta AOD's
597 Int_t ntasksjets = AddTaskJetsDelta("AliAOD.Jets.root");
598 if (ntasksjets) printf("Added %d jet reconstructors\n", ntasksjets);
602 // PWG4 hadron correlations
604 Bool_t isSimulation = (runOnData)?kFALSE:kTRUE;
605 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPartCorr.C");
606 AliAnalysisTaskParticleCorrelation *taskpartcorrPHOS = AddTaskPartCorr("AOD", "PHOS", kFALSE, isSimulation);
607 if (!taskpartcorrPHOS) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation PHOS cannot run for this train conditions - EXCLUDED");
608 AliAnalysisTaskParticleCorrelation *taskpartcorrEMCAL = AddTaskPartCorr("AOD", "EMCAL", kFALSE, isSimulation);
609 if (!taskpartcorrEMCAL) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation EMCAL cannot run for this train conditions - EXCLUDED");
610 mgr->RegisterExtraFile("deltaAODPartCorr.root");
613 // PWG4 gamma conversion analysis
614 if (iPWG4gammaconv) {
615 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskGammaConversion.C");
616 TString cdir = gSystem->WorkingDirectory();
617 gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/"));
618 TString gcArguments = "-run-on-train -run-jet -run-chic -run-neutralmeson -run-cf";
619 AliAnalysisTaskGammaConversion * taskGammaConversion = AddTaskGammaConversion(gcArguments,mgr->GetCommonInputContainer());
620 gSystem->ChangeDirectory(cdir);
621 if (!taskGammaConversion) ::Warning("AnalysisTrainNew", "AliAnalysisTaskGammaConversion cannot run for these train conditions - EXCLUDED");
624 // PWG4 omega to 3 pions analysis
626 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskomega3pi.C");
627 AliAnalysisTaskOmegaPi0PiPi *taskomega3pi = AddTaskomega3pi();
628 if (!taskomega3pi) ::Warning("AnalysisTrainNew", "AliAnalysisTaskomega3pi cannot run for these train conditions - EXCLUDED");
632 //______________________________________________________________________________
633 void StartAnalysis(const char *mode, TChain *chain) {
636 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
637 if (!strcmp(mode, "LOCAL")) imode = 0;
638 if (!strcmp(mode, "PROOF")) imode = 1;
639 if (!strcmp(mode, "GRID")) imode = 2;
643 ::Error("AnalysisTrainNew.C::StartAnalysis", "Cannot create the chain");
646 mgr->StartAnalysis(mode, chain);
649 if (!proof_dataset.Length()) {
650 ::Error("AnalysisTrainNew.C::StartAnalysis", "proof_dataset is empty");
653 mgr->StartAnalysis(mode, proof_dataset, 1000);
657 if (!mgr->GetGridHandler()) {
658 ::Error("AnalysisTrainNew.C::StartAnalysis", "Grid plugin not initialized");
661 mgr->StartAnalysis("grid");
664 ::Error("AnalysisTrainNew.C::StartAnalysis", "Cannot create the chain");
667 mgr->StartAnalysis(mode, chain);
673 //______________________________________________________________________________
674 void CheckModuleFlags(const char *mode) {
675 // Checks selected modules and insure compatibility
677 if (!strcmp(mode, "LOCAL")) imode = 0;
678 if (!strcmp(mode, "PROOF")) imode = 1;
679 if (!strcmp(mode, "GRID")) imode = 2;
680 if (!iJETAN) iJETANdelta = 0;
683 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis");
688 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode");
694 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's");
696 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "AOD tags usage disabled in analysis on AOD's");
701 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's");
705 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler");
709 // Disable tasks that do not work yet on AOD data
711 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4gammaconv disabled on AOD's without AOD handler");
714 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2central disabled on AOD's");
717 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2flow disabled on AOD's");
720 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2femto disabled on AOD's");
723 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2res disabled on AOD's");
726 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2rsneff disabled on AOD's");
729 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2kink disabled in analysis on AOD's");
732 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2unicor disabled in analysis on AOD's");
735 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4evchar disabled on AOD's");
738 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2forward disabled in analysis on AOD's");
741 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG3hfe disabled on AOD's");
744 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4omega3pi disabled on AOD's");
748 if (!useMC) useTR = kFALSE;
750 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "iPWG2evchar disabled if not reading track references");
755 if (iPWG2perfcascade)
756 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2perfcascade disabled without MC info");
757 iPWG2perfcascade = 0;
759 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2central disabled without MC info");
762 if (iJETAN && !iAODanalysis) iESDfilter=1;
763 if (iESDfilter) {iAODhandler=1; useCORRFW = kTRUE;}
764 if (iPWG2spectra || iPWG2flow || iPWG3vertexing || iPWG3hfe || iPWG2res || iPWG2rsneff) useCORRFW = kTRUE;
765 if (useKFILTER && !useMC) useKFILTER = kFALSE;
766 if (useAODTAGS && !iAODhandler) useAODTAGS = kFALSE;
769 //______________________________________________________________________________
770 Bool_t Connect(const char *mode) {
771 // Connect <username> to the back-end system.
773 if (!strcmp(mode, "LOCAL")) imode = 0;
774 if (!strcmp(mode, "PROOF")) imode = 1;
775 if (!strcmp(mode, "GRID")) imode = 2;
776 TString username = gSystem->Getenv("alien_API_USER");
781 if (!username.Length()) {
782 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), "Make sure you:\n \
783 1. Have called: alien-token-init <username>\n \
784 2. Have called: >source /tmp/gclient_env_$UID");
787 ::Info("AnalysisTrainNew.C::Connect", "Connecting user <%s> to PROOF cluster <%s>",
788 username.Data(), proof_cluster.Data());
789 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
790 // TProof::Open(Form("%s@%s:31093", username.Data(), proof_cluster.Data()));
791 TProof::Open(Form("%s@%s", username.Data(), proof_cluster.Data()));
793 if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch"))
794 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch");
797 TGrid::Connect("alien://");
799 TString homedir = gGrid->GetHomeDirectory();
800 TString workdir = homedir + train_name;
801 if (!gGrid->Cd(workdir)) {
803 if (gGrid->Mkdir(workdir)) {
804 gGrid->Cd(train_name);
805 ::Info("AnalysisTrainNew::Connect()", "Directory %s created", gGrid->Pwd());
808 gGrid->Mkdir("proof_output");
809 gGrid->Cd("proof_output");
810 proof_outdir = Form("alien://%s", gGrid->Pwd());
814 if (usePLUGIN && !gSystem->Getenv("alien_CLOSE_SE")) {
815 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode),
816 "When using the AliEn plugin it is preferable to define the \
817 variable alien_CLOSE_SE in your environment.");
820 ::Info("AnalysisTrainNew.C::Connect", "Connecting user <%s> to AliEn ...",
822 TGrid::Connect("alien://");
823 if (!gGrid || !gGrid->IsConnected()) return kFALSE;
826 ::Error("AnalysisTrainNew.C::Connect", "Unknown run mode: %s", mode);
829 ::Info("AnalysisTrainNew.C::Connect","Connected in %s mode", mode);
833 //______________________________________________________________________________
834 Bool_t LoadCommonLibraries(const char *mode)
836 // Load common analysis libraries.
838 if (!strcmp(mode, "LOCAL")) imode = 0;
839 if (!strcmp(mode, "PROOF")) imode = 1;
840 if (!strcmp(mode, "GRID")) imode = 2;
841 if (!gSystem->Getenv("ALICE_ROOT")) {
842 ::Error("AnalysisTrainNew.C::LoadCommonLibraries", "Analysis train requires that analysis libraries are compiled with a local AliRoot");
845 Bool_t success = kTRUE;
847 gSystem->Load("libTree.so");
848 gSystem->Load("libGeom.so");
849 gSystem->Load("libVMC.so");
850 gSystem->Load("libPhysics.so");
851 gSystem->Load("libMinuit.so");
853 // Load framework classes. Par option ignored here.
858 success &= LoadLibrary("STEERBase", mode, kTRUE);
859 success &= LoadLibrary("ESD", mode, kTRUE);
860 success &= LoadLibrary("AOD", mode, kTRUE);
861 success &= LoadLibrary("ANALYSIS", mode, kTRUE);
862 success &= LoadLibrary("ANALYSISalice", mode, kTRUE);
863 if (useCORRFW) success &= LoadLibrary("CORRFW", mode, kTRUE);
865 success &= LoadLibrary("libSTEERBase.so", mode);
866 success &= LoadLibrary("libESD.so", mode);
867 success &= LoadLibrary("libAOD.so", mode);
868 success &= LoadLibrary("libANALYSIS.so", mode);
869 success &= LoadLibrary("libANALYSISalice.so", mode);
870 if (useCORRFW) success &= LoadLibrary("libCORRFW.so", mode);
871 gROOT->ProcessLine(".include $ALICE_ROOT/include");
876 if (useAFPAR && !gSystem->AccessPathName(AFversion)) ires = gProof->UploadPackage(AFversion);
878 success &= LoadLibrary("STEERBase", mode);
879 success &= LoadLibrary("ESD", mode);
880 success &= LoadLibrary("AOD", mode);
881 success &= LoadLibrary("ANALYSIS", mode);
882 success &= LoadLibrary("ANALYSISalice", mode);
883 if (useCORRFW) success &= LoadLibrary("CORRFW", mode);
885 ires = gProof->EnablePackage(AFversion);
886 if (ires<0) success = kFALSE;
887 if (useCORRFW) success &= LoadLibrary("CORRFW", mode);
891 ::Error("AnalysisTrainNew.C::LoadCommonLibraries", "Unknown run mode: %s", mode);
895 ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Load common libraries: SUCCESS");
896 ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s",
897 gSystem->GetIncludePath());
899 ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Load common libraries: FAILED");
905 //______________________________________________________________________________
906 Bool_t LoadAnalysisLibraries(const char *mode)
908 // Load common analysis libraries.
909 Bool_t success = kTRUE;
910 if (iESDfilter || iPWG3MuonTrain) {
911 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
912 !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE;
916 if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE;
919 if (!LoadLibrary("JETAN", mode, kTRUE) ||
920 !LoadLibrary("CGAL", mode, kTRUE) ||
921 !LoadLibrary("fastjet", mode, kTRUE) ||
922 !LoadLibrary("siscone", mode, kTRUE) ||
923 !LoadLibrary("SISConePlugin", mode, kTRUE) ||
924 !LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE;
926 // PWG4 particle correlations
928 if (!LoadLibrary("EMCALUtils", mode, kTRUE) ||
929 !LoadLibrary("PHOSUtils", mode, kTRUE) ||
930 !LoadLibrary("PWG4PartCorrBase", mode, kTRUE) ||
931 !LoadLibrary("PWG4PartCorrDep", mode, kTRUE)) return kFALSE;
933 // PWG4 gamma conversion
934 if (iPWG4gammaconv) {
935 if (!LoadLibrary("PWG4GammaConv", mode, kTRUE)) return kFALSE;
937 // PWG4 omega to 3 pions
939 if (!LoadLibrary("PWG4omega3pi", mode, kTRUE)) return kFALSE;
943 if (!LoadLibrary("PWG2spectra", mode, kTRUE)) return kFALSE;
947 if (!LoadLibrary("PWG2flowCommon", mode, kTRUE) ||
948 !LoadLibrary("PWG2flowTasks", mode, kTRUE)) return kFALSE;
951 if (iPWG2res || iPWG2rsneff) {
952 if (!LoadLibrary("PWG2resonances", mode, kTRUE)) return kFALSE;
956 if (!LoadLibrary("PWG2kink", mode, kTRUE)) return kFALSE;
960 if (!LoadLibrary("PWG2unicor", mode, kTRUE)) return kFALSE;
964 if (!LoadLibrary("PWG2evchar", mode, kTRUE)) return kFALSE;
968 if (!LoadLibrary("PWG2AOD", mode, kTRUE) ||
969 !LoadLibrary("PWG2femtoscopy", mode, kTRUE) ||
970 !LoadLibrary("PWG2femtoscopyUser", mode, kTRUE)) return kFALSE;
971 // TFile::Cp(gSystem->ExpandPathName("$(ALICE_ROOT)/PWG2/FEMTOSCOPY/macros/ConfigFemtoAnalysis.C"), Form("%s/ConfigFemtoAnalysis.C", train_name.Data()));
972 // anaLibs += "ConfigFemtoAnalysis.C ";
976 if (!LoadLibrary("PWG2forward", mode, kTRUE)) return kFALSE;
979 if (iPWG3vertexing || iPWG3d2h) {
980 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
981 !LoadLibrary("PWG3vertexingHF", mode, kTRUE)) return kFALSE;
985 if (!LoadLibrary("PWG3hfe", mode, kTRUE)) return kFALSE;
988 ::Info("AnalysisTrainNew.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS");
992 //______________________________________________________________________________
993 Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE)
995 // Load a module library in a given mode. Reports success.
998 TString smodule(module);
999 if (!strcmp(mode, "LOCAL")) imode = 0;
1000 if (!strcmp(mode, "PROOF")) imode = 1;
1001 if (!strcmp(mode, "GRID")) imode = 2;
1002 TString mod(module);
1003 if (!mod.Length()) {
1004 ::Error("AnalysisTrainNew.C::LoadLibrary", "Empty module name");
1007 // If a library is specified, just load it
1008 if (smodule.EndsWith(".so")) {
1009 mod.Remove(mod.Index(".so"));
1010 result = gSystem->Load(mod);
1012 ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not load library %s", module);
1015 if (rec) anaLibs += Form("%s.so ",mod.Data());
1018 // Check if the library is already loaded
1019 if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0)
1025 result = SetupPar(module);
1026 if (rec) anaPars += Form("%s.par ", module);
1028 result = gSystem->Load(Form("lib%s.so", module));
1029 if (rec) anaLibs += Form("lib%s.so ", module);
1033 result = gProof->UploadPackage(module);
1035 result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module)));
1037 ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module);
1041 result = gProof->EnablePackage(module);
1047 ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not load module %s", module);
1054 //______________________________________________________________________________
1055 TChain *CreateChain(const char *mode, const char *plugin_mode)
1057 // Create the input chain
1059 if (!strcmp(mode, "LOCAL")) imode = 0;
1060 if (!strcmp(mode, "PROOF")) imode = 1;
1061 if (!strcmp(mode, "GRID")) imode = 2;
1062 TChain *chain = NULL;
1067 if (!local_xmldataset.Length()) {
1069 chain = new TChain("aodTree");
1070 if (gSystem->AccessPathName("data/AliAOD.root"))
1071 ::Error("AnalysisTrainNew.C::CreateChain", "File: AliAOD.root not in ./data dir");
1073 if (!saveTrain) chain->Add("data/AliAOD.root");
1074 else chain->Add("../data/AliAOD.root");
1078 chain = CreateChainSingle(local_xmldataset, "aodTree");
1081 if (!local_xmldataset.Length()) {
1083 chain = new TChain("esdTree");
1084 if (gSystem->AccessPathName("data/AliESDs.root"))
1085 ::Error("AnalysisTrainNew.C::CreateChain", "File: AliESDs.root not in ./data dir");
1087 if (!saveTrain) chain->Add("data/AliESDs.root");
1088 else chain->Add("../data/AliESDs.root");
1092 chain = CreateChainSingle(local_xmldataset, "esdTree");
1100 // AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
1101 // AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
1103 TString treeName = "esdTree";
1104 if (iAODanalysis) treeName = "aodTree";
1105 chain = CreateChainSingle("wn.xml", treeName);
1110 if (chain && chain->GetNtrees()) return chain;
1114 //______________________________________________________________________________
1115 TChain* CreateChainSingle(const char* xmlfile, const char *treeName)
1117 printf("*******************************\n");
1118 printf("*** Getting the ESD Chain ***\n");
1119 printf("*******************************\n");
1120 TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
1122 if (!myCollection) {
1123 ::Error("AnalysisTrainNew.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
1127 TChain* chain = new TChain(treeName);
1128 myCollection->Reset() ;
1129 while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
1134 //______________________________________________________________________________
1135 Int_t SetupPar(char* pararchivename)
1137 if (!pararchivename || !strlen(pararchivename)) return -1;
1138 char processline[1024];
1139 if (gSystem->AccessPathName(Form("%s.par", pararchivename))) {
1140 if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) {
1141 ::Info("AnalysisTrainNew.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename);
1142 TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)),
1143 Form("%s.par",pararchivename));
1145 ::Error("AnalysisTrainNew.C::SetupPar", "Cannot find %s.par", pararchivename);
1149 if (usePLUGIN && saveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, train_name.Data()));
1150 gSystem->Exec(Form("tar xvzf %s.par", pararchivename));
1152 TString ocwd = gSystem->WorkingDirectory();
1153 if (!gSystem->ChangeDirectory(pararchivename)) return -1;
1155 // check for BUILD.sh and execute
1156 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
1157 printf("*******************************\n");
1158 printf("*** Building PAR archive ***\n");
1159 printf("*******************************\n");
1160 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
1161 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
1166 // check for SETUP.C and execute
1167 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
1168 printf("*******************************\n");
1169 printf("*** Setup PAR archive ***\n");
1170 printf("*******************************\n");
1171 gROOT->Macro("PROOF-INF/SETUP.C");
1173 if (!gSystem->ChangeDirectory(ocwd.Data())) return -1;
1177 //______________________________________________________________________________
1178 AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
1180 // Check if user has a valid token, otherwise make one. This has limitations.
1181 // One can always follow the standard procedure of calling alien-token-init then
1182 // source /tmp/gclient_env_$UID in the current shell.
1183 if (!AliAnalysisGrid::CreateToken()) return NULL;
1184 AliAnalysisAlien *plugin = new AliAnalysisAlien();
1185 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
1186 plugin->SetRunMode(plugin_mode);
1187 if (useProductionMode) plugin->SetProductionMode();
1188 if (!outputSingleFolder.IsNull()) plugin->SetOutputSingleFolder(outputSingleFolder);
1189 plugin->SetJobTag(job_tag);
1190 plugin->SetNtestFiles(1);
1191 // plugin->SetPreferedSE("ALICE::NIHAM::File");
1192 // Set versions of used packages
1193 // plugin->SetAPIVersion("V2.4");
1194 plugin->SetAPIVersion("V1.1x");
1195 plugin->SetROOTVersion(root_version);
1196 plugin->SetAliROOTVersion(aliroot_version);
1197 // Declare input data to be processed.
1198 // Method 1: Create automatically XML collections using alien 'find' command.
1199 // Define production directory LFN
1200 plugin->SetGridDataDir(alien_datadir);
1201 // Set data search pattern
1202 if (iAODanalysis) plugin->SetDataPattern("*AliAOD.root");
1203 else plugin->SetDataPattern("*AliESDs.root");
1204 // ...then add run numbers to be considered
1205 if (!iAODanalysis) plugin->SetRunRange(run_range[0], run_range[1]);
1206 // for (Int_t i=0; i<10; i++) {
1207 // if (run_numbers[i]==0) break;
1208 // plugin->AddRunNumber(run_numbers[i]);
1210 // Method 2: Declare existing data files (raw collections, xml collections, root file)
1211 // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
1212 // XML collections added via this method can be combined with the first method if
1213 // the content is compatible (using or not tags)
1214 // plugin->AddDataFile("tag.xml");
1215 // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
1216 // Define alien work directory where all files will be copied. Relative to alien $HOME.
1217 plugin->SetGridWorkingDir(train_name);
1218 // Declare alien output directory. Relative to working directory.
1219 if (!alien_outdir.Length()) alien_outdir = Form("output_%s",train_name.Data());
1220 plugin->SetGridOutputDir(alien_outdir);
1222 TString ana_sources = "";
1223 TString ana_add = "";
1224 if (usePAR && anaPars.Length()) {
1225 printf("%s\n", anaPars.Data());
1228 arr = anaPars.Tokenize(" ");
1230 while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString());
1233 // Add external packages
1235 plugin->AddExternalPackage("boost::v1_38_0");
1236 plugin->AddExternalPackage("cgal::v3.3.1");
1237 plugin->AddExternalPackage("fastjet::v2.4.0");
1240 // Declare the analysis source files names separated by blancs. To be compiled runtime
1241 // using ACLiC on the worker nodes.
1242 ana_sources = ana_sources.Strip();
1243 // Declare all libraries (other than the default ones for the framework. These will be
1244 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
1245 anaLibs = anaLibs.Strip();
1246 if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources);
1247 if (anaLibs.Length()) plugin->SetAdditionalLibs(anaLibs);
1249 // Declare the output file names separated by blancs.
1250 // (can be like: file.root or file.root@ALICE::Niham::File)
1251 plugin->SetDefaultOutputs();
1252 plugin->SetMergeExcludes(mergeExclude);
1253 plugin->SetMaxMergeFiles(maxMergeFiles);
1254 plugin->SetNrunsPerMaster(nRunsPerMaster);
1255 // Optionally define the files to be archived.
1256 // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File");
1259 // Put default output files to archive
1260 TString listhists = "";
1261 TString listaods = "";
1262 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1263 TIter next(mgr->GetOutputs());
1264 AliAnalysisDataContainer *output;
1265 while ((output=(AliAnalysisDataContainer*)next())) {
1266 const char *filename = output->GetFileName();
1267 if (!(strcmp(filename, "default"))) {
1268 if (!mgr->GetOutputEventHandler()) continue;
1269 filename = mgr->GetOutputEventHandler()->GetOutputFileName();
1270 if (listaods.Length()) listaods += ",";
1271 listaods += filename;
1273 listaods += "pyxsec_hists.root";
1275 if (!strcmp(filename, "pyxsec_hists.root")) continue;
1276 if (listhists.Contains(filename)) continue;
1277 if (listhists.Length()) listhists += ",";
1278 listhists += filename;
1281 if (mgr->GetExtraFiles().Length()) {
1282 if (listaods.Length()) listaods += ",";
1283 listaods += mgr->GetExtraFiles();
1284 listaods.ReplaceAll(" ", ",");
1286 if (listhists.Length()) listhists = Form("hist_archive.zip:%s@%s", listhists.Data(), outputStorages.Data());
1287 if (listaods.Length()) listaods = Form("aod_archive.zip:%s@%s", listaods.Data(), outputStorages.Data());
1288 if (!listhists.Length() && !listaods.Length()) {
1289 ::Fatal("AnalysisTrainNew", "No task output !");
1291 TString outputArchive = Form("log_archive.zip:stderr@%s", outputStorages.Data());
1292 if (listaods.Length()) {
1293 outputArchive += " ";
1294 outputArchive += listaods;
1296 if (listhists.Length()) {
1297 outputArchive += " ";
1298 outputArchive += listhists;
1301 // if (iAODanalysis && iPWG3d2h)
1302 // plugin->SetFriendChainName("AliAOD.VertexingHF.root");
1303 plugin->SetOutputArchive(outputArchive);
1304 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
1305 plugin->SetAnalysisMacro(Form("%s.C", train_name.Data()));
1306 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
1307 plugin->SetSplitMaxInputFileNumber(nFilesPerJob);
1308 // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
1309 // plugin->SetMaxInitFailed(5);
1310 // Optionally resubmit threshold.
1311 // plugin->SetMasterResubmitThreshold(90);
1312 // Optionally set time to live (default 30000 sec)
1313 plugin->SetTTL(70000);
1314 // Optionally set input format (default xml-single)
1315 plugin->SetInputFormat("xml-single");
1316 // Optionally modify the name of the generated JDL (default analysis.jdl)
1317 plugin->SetJDLName(Form("%s.jdl", train_name.Data()));
1318 // Optionally modify the executable name (default analysis.sh)
1319 plugin->SetExecutable(Form("%s.sh", train_name.Data()));
1320 // Optionally modify job price (default 1)
1321 plugin->SetPrice(1);
1323 plugin->SetMergeViaJDL(useMergeViaJDL);
1324 // Use fastread option
1325 plugin->SetFastReadOption(useFastReadOption);
1326 // UseOverwrite mode
1327 plugin->SetOverwriteMode(useOverwriteMode);
1328 // Optionally modify split mode (default 'se')
1329 // plugin->SetSplitMode("se");
1333 //______________________________________________________________________________
1336 // Write train configuration in a file. The file name has the format:
1337 // train_[trainName]_ddMonthyyyy_time.C
1339 gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp");
1340 ifstream fdate("date.tmp");
1341 if (!fdate.is_open()) {
1342 ::Error("AnalysisTrainNew.C::Export","Could not generate file name");
1345 const char date[64];
1346 fdate.getline(date,64);
1348 gSystem->Exec("rm date.tmp");
1349 train_name = Form("train_%s_%s", train_name.Data(), date);
1351 train_name = Form("train_%s", train_name.Data());
1353 TString cdir = gSystem->WorkingDirectory();
1354 gSystem->MakeDirectory(train_name);
1355 gSystem->ChangeDirectory(train_name);
1357 out.open(Form("%sConfig.C",train_name.Data()), ios::out);
1359 ::Error("AnalysisTrainNew.C::Export", "Cannot open ConfigTrain.C for writing");
1363 out << " train_name = " << "\"" << train_name.Data() << "\";" << endl;
1364 out << " proof_cluster = " << "\"" << proof_cluster.Data() << "\";" << endl;
1365 out << " useAFPAR = " << useAFPAR << ";" << endl;
1367 out << " AFversion = " << AFversion.Data() << ";" << endl;
1368 out << " proof_dataset = " << "\"" << proof_dataset.Data() << "\";" << endl;
1369 out << " usePLUGIN = " << usePLUGIN << ";" << endl;
1370 out << " usePAR = " << usePAR << ";" << endl;
1371 out << " useCPAR = " << useCPAR << ";" << endl;
1372 out << " root_version = " << "\"" << root_version.Data() << "\";" << endl;
1373 out << " aliroot_version = " << "\"" << aliroot_version.Data() << "\";" << endl;
1374 out << " alien_datadir = " << "\"" << alien_datadir.Data() << "\";" << endl;
1375 if (!alien_outdir.Length()) alien_outdir = Form("output_%s",train_name.Data());
1376 out << " alien_outdir = " << "\"" << alien_outdir.Data() << "\";" << endl;
1377 out << " maxMergeFiles = " << maxMergeFiles << ";" << endl;
1378 out << " mergeExclude = " << "\"" << mergeExclude.Data() << "\";" << endl;
1379 out << " nRunsPerMaster = " << nRunsPerMaster << ";" << endl;
1380 out << " nFilesPerJob = " << nFilesPerJob << ";" << endl;
1381 // for (Int_t i=0; i<10; i++) {
1382 // if (run_numbers[i])
1383 // out << " run_numbers[" << i << "] = " << run_numbers[i] << ";" << endl;
1385 out << " run_range[0] = " << run_range[0] << ";" << endl;
1386 out << " run_range[1] = " << run_range[1] << ";" << endl;
1387 out << " usePhysicsSelection = " << usePhysicsSelection << ";" << endl;
1388 out << " useMergeViaJDL = " << useMergeViaJDL << ";" << endl;
1389 out << " useOverwriteMode = " << useOverwriteMode << ";" << endl;
1390 out << " useFastReadOption = " << useFastReadOption << ";" << endl;
1391 out << " useDBG = " << useDBG << ";" << endl;
1392 out << " useMC = " << useMC << ";" << endl;
1393 out << " useTAGS = " << useTAGS << ";" << endl;
1394 out << " useKFILTER = " << useKFILTER << ";" << endl;
1395 out << " useTR = " << useTR << ";" << endl;
1396 out << " useCORRFW = " << useCORRFW << ";" << endl;
1397 out << " useAODTAGS = " << useAODTAGS << ";" << endl;
1398 out << " saveTrain = " << "kFALSE;" << endl << endl;
1399 out << " // Analysis modules" << endl;
1400 out << " iAODanalysis = " << iAODanalysis << ";" << endl;
1401 out << " iAODhandler = " << iAODhandler << ";" << endl;
1402 out << " iESDfilter = " << iESDfilter << ";" << endl;
1403 out << " iMUONcopyAOD = " << iMUONcopyAOD << ";" << endl;
1404 out << " iJETAN = " << iJETAN << ";" << endl;
1405 out << " iJETANdelta = " << iJETANdelta << ";" << endl;
1406 out << " iPWG4partcorr = " << iPWG4partcorr << ";" << endl;
1407 out << " iPWG4gammaconv = " << iPWG4gammaconv << ";" << endl;
1408 out << " iPWG4omega3pi = " << iPWG4omega3pi << ";" << endl;
1409 out << " iPWG3vertexing = " << iPWG3vertexing << ";" << endl;
1410 out << " iPWG3hfe = " << iPWG3hfe << ";" << endl;
1411 out << " iPWG3d2h = " << iPWG3d2h << ";" << endl;
1412 out << " iPWG3d0mass = " << iPWG3d0mass << ";" << endl;
1413 out << " iPWG3d0massLS = " << iPWG3d0massLS << ";" << endl;
1414 out << " iPWG3dplus = " << iPWG3dplus << ";" << endl;
1415 out << " iPWG3LSd0 = " << iPWG3LSd0 << ";" << endl;
1416 out << " iPWG3LSjpsi = " << iPWG3LSjpsi << ";" << endl;
1417 out << " iPWG3CFd0 = " << iPWG3CFd0 << ";" << endl;
1418 out << " iPWG3promptd0 = " << iPWG3promptd0 << ";" << endl;
1419 out << " iPWG3MuonTrain = " << iPWG3MuonTrain << ";" << endl;
1420 out << " iPWG2femto = " << iPWG2femto << ";" << endl;
1421 out << " iPWG2spectra = " << iPWG2spectra << ";" << endl;
1422 out << " iPWG2protons = " << iPWG2protons << ";" << endl;
1423 out << " iPWG2checkcascade = " << iPWG2checkcascade << ";" << endl;
1424 out << " iPWG2perfcascade = " << iPWG2perfcascade << ";" << endl;
1425 out << " iPWG2checkv0 = " << iPWG2checkv0 << ";" << endl;
1426 out << " iPWG2strange = " << iPWG2strange << ";" << endl;
1427 out << " iPWG2central = " << iPWG2central << ";" << endl;
1428 out << " iPWG2flow = " << iPWG2flow << ";" << endl;
1429 out << " iPWG2res = " << iPWG2res << ";" << endl;
1430 out << " iPWG2rsneff = " << iPWG2rsneff << ";" << endl;
1431 out << " iPWG2kink = " << iPWG2kink << ";" << endl;
1432 out << " iPWG2kinkESDMC = " << iPWG2kinkESDMC << ";" << endl;
1433 out << " iPWG2kinkLSKstar = " << iPWG2kinkLSKstar << ";" << endl;
1434 out << " iPWG2kinkLSL1520 = " << iPWG2kinkLSL1520 << ";" << endl;
1435 out << " iPWG2kinkLSPhi = " << iPWG2kinkLSPhi << ";" << endl;
1436 out << " iPWG2kinkKstarESD = " << iPWG2kinkKstarESD << ";" << endl;
1437 out << " iPWG2kinkKstarMC = " << iPWG2kinkKstarMC << ";" << endl;
1438 out << " iPWG2kinkL1520ESD = " << iPWG2kinkL1520ESD << ";" << endl;
1439 out << " iPWG2kinkL1520MC = " << iPWG2kinkL1520MC << ";" << endl;
1440 out << " iPWG2kinkPhiESD = " << iPWG2kinkPhiESD << ";" << endl;
1441 out << " iPWG2kinkPhiMC = " << iPWG2kinkPhiMC << ";" << endl;
1442 out << " iPWG2unicor = " << iPWG2unicor << ";" << endl;
1443 out << " iPWG2evchar = " << iPWG2evchar << ";" << endl;
1444 out << " iPWG2forward = " << iPWG2forward << ";" << endl << endl;
1445 out << "// Configuration fot the wagons" << endl;
1446 out << " configPWG2femto = \"" << configPWG2femto << "\";" << endl;
1447 out << " configPWG3d2h = \"" << configPWG3d2h << "\";" << endl;
1449 ::Info("AnalysisTrainNew.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", train_name.Data()));
1450 gSystem->ChangeDirectory(cdir);
1453 //______________________________________________________________________________
1454 Bool_t LoadConfig(const char *filename)
1456 // Read train configuration from file
1457 if (gSystem->AccessPathName(filename)) {
1458 ::Error("AnalysisTrainNew.C::LoadConfig", "Config file name not found");
1461 gROOT->ProcessLine(Form(".x %s", filename));
1462 ::Info("AnalysisTrainNew.C::LoadConfig", "Train configuration loaded from file %s", filename);