]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/macros/AnalysisTrainNewFilterAOD.C
warning when trigger is loaded appears only once
[u/mrichter/AliRoot.git] / ANALYSIS / macros / AnalysisTrainNewFilterAOD.C
CommitLineData
09765e37 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.
12//
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")
17
18//================== TRAIN NAME ============================================
f145e990 19TString train_name = "FILTERpass1"; // local folder name
20TString train_tag = "pass1"; // Train special tag appended to
09765e37 21 // visible name. ("data", "sim", "pp", "highmult", ...)
22 // Name in train page (DON'T CHANGE)
23TString visible_name = Form("FILTER%s$2_$3", train_tag.Data()); //# FIXED #
24 // Add train composition and other comments
f145e990 25TString job_comment = "Tender+PhysSel -> AODs: std(+jets)/(di)muon/vertexing/dielectrons";
09765e37 26TString job_tag = Form("%s: %s", visible_name.Data(), job_comment.Data());
27//==============================================================================
28
29// ### Settings that make sense in PROOF only
30//==============================================================================
31TString proof_cluster = "alice-caf.cern.ch";
32Bool_t useAFPAR = kFALSE; // use AF special par file
33TString AFversion = "AF-v4-17";
34// Change CAF dataset here
35TString proof_dataset = "/COMMON/COMMON/LHC09a4_run8100X#/esdTree";
36TString proof_outdir = "";
37
38// ### Settings that make sense when using the Alien plugin
39//==============================================================================
40Int_t runOnData = 1; // Set to 1 if processing real data
41Int_t iCollision = 0; // 0=pp, 1=Pb-Pb
42Bool_t usePLUGIN = kTRUE; // do not change
43Bool_t useProductionMode = kTRUE; // use the plugin in production mode
44// Usage of par files ONLY in grid mode and ONLY if the code is not available
45// in the deployed AliRoot versions. Par file search path: local dir, if not there $ALICE_ROOT.
46// To refresh par files, remove the ones in the workdir, then do "make <target.par>" in
47// AliRoot.
48Bool_t usePAR = kFALSE; // use par files for extra libs
49Bool_t useCPAR = kFALSE; // use par files for common libs
f145e990 50TString root_version = "v5-27-06-1"; // *CHANGE ME IF MORE RECENT IN GRID*
51TString aliroot_version = "v4-20-12-AN"; // *CHANGE ME IF MORE RECENT IN GRID*
09765e37 52// Change production base directory here (test mode)
f145e990 53TString alien_datadir = "/alice/data/2010/LHC10e";
09765e37 54 // Work directory in GRID (DON'T CHANGE)
55TString grid_workdir = "/alice/cern.ch/user/a/alidaq/AOD/AOD$2";
56 // Data pattern - change as needed for test mode
f145e990 57TString data_pattern = "*ESDs/pass1/*ESDs.root";
09765e37 58// Set the run range
f145e990 59Int_t run_numbers[10] = {128913}; // **********************!!!!!!!
09765e37 60//Int_t run_range[2] = {114786, 114949}; // LHC09a7 *CHANGE ME*
61// AliEn output directory. If blank will become output_<train_name>
62 // Output directory (DON'T CHANGE)
63TString alien_outdir = "$1/AOD$2";
64 // Input collection (production mode)
65TString data_collection = "$1/qa1.xml";
66// Output folder to write delta AOD's. Considered if not null.
67TString outputSingleFolder = "";
68//TString outputSingleFolder = "deltas";
69// Number of files merged in a chunk
70Int_t maxMergeFiles = 20;
71// Files that should not be merged
72TString mergeExclude = "AliAOD.root AliAOD.VertexingHF.root AliAOD.Jets.root deltaAODPartCorr.root AliAOD.Muons.root AliAOD.Dimuons.root AliAOD.Dielectron.root";
73// Make replicas on the storages below
74TString outputStorages = "disk=4";
75// Number of runs per master job
76Int_t nRunsPerMaster = 10;
77// Maximum number of files per job (gives size of AOD)
78Int_t nFilesPerJob = 20;
79// Int_t nFilesPerJob = 1; (AOD->delta AOD production case)
80// ### Settings that make sense only for local analysis
81//==============================================================================
82// Change local xml dataset for local interactive analysis
83TString local_xmldataset = "";
84
85// ### Other flags to steer the analysis
86//==============================================================================
87Bool_t usePhysicsSelection = kTRUE; // use physics selection
88Bool_t useTender = kTRUE; // use tender wagon
f145e990 89Bool_t useV0tender = kTRUE; // use V0 correction in tender
09765e37 90Bool_t useMergeViaJDL = kTRUE; // merge via JDL
91Bool_t useFastReadOption = kTRUE; // use xrootd tweaks
92Bool_t useOverwriteMode = kTRUE; // overwrite existing collections
93Bool_t useDATE = kFALSE; // use date in train name
94Bool_t useDBG = kFALSE; // activate debugging
95Bool_t useMC = kFALSE; // use MC info
96Bool_t useTAGS = kFALSE; // use ESD tags for selection
97Bool_t useKFILTER = kFALSE; // use Kinematics filter
98Bool_t useTR = kFALSE; // use track references
99Bool_t useCORRFW = kFALSE; // do not change
100Bool_t useAODTAGS = kFALSE; // use AOD tags
101Bool_t saveTrain = kTRUE; // save train configuration as:
102Bool_t saveCanvases = kFALSE; // save canvases created in Terminate
103Bool_t saveProofToAlien = kFALSE; // save proof outputs in AliEn
104
105// ### Analysis modules to be included. Some may not be yet fully implemented.
106//==============================================================================
107Int_t iAODanalysis = 0; // Analysis on input AOD's
108Int_t iAODhandler = 1; // Analysis produces an AOD or dAOD's
109Int_t iESDfilter = 1; // ESD to AOD filter (barrel + muon tracks)
110Int_t iMUONcopyAOD = 1; // Task that copies only muon events in a separate AOD (PWG3)
111Int_t iJETAN = 1; // Jet analysis (PWG4)
112Int_t iJETANdelta = 0; // Jet delta AODs
113Int_t iPWG4partcorr = 0; // Gamma-hadron correlations task (PWG4)
f145e990 114Int_t iPWG4gammaconv = 0; // Gamma conversion analysis (PWG4)
09765e37 115Int_t iPWG4omega3pi = 0; // Omega to 3 pi analysis (PWG4)
116Int_t iPWG3vertexing = 1; // Vertexing HF task (PWG3)
f145e990 117Int_t iPWG3hfe = 0; // Electrons analysis (PWG3)
09765e37 118Int_t iPWG3JPSIfilter = 1; // JPSI filtering (PWG3)
f145e990 119Int_t iPWG3JPSI = 0; // JPSI analysis (PWG3)
09765e37 120Int_t iPWG3d2h = 0; // D0->2 hadrons (PWG3)
121Int_t iPWG3d0mass = 1; // D0 mass (PWG3D2H)
122Int_t iPWG3d0massLS = 1; // D0 mass LS (PWG3D2H)
123Int_t iPWG3dplus = 1; // D+ analysis (PWG3D2H)
124Int_t iPWG3LSd0 = 1; // LS D0 analysis (PWG3D2H)
125Int_t iPWG3LSjpsi = 1; // LS J/Psi analysis (PWG3D2H)
126Int_t iPWG3CFd0 = 1; // CF D0 analysis (PWG3D2H)
127Int_t iPWG3promptd0 = 1; // prompt D0 analysis (PWG3D2H)
128Int_t iPWG3MuonTrain = 0; // Muon analysis train
129Int_t iPWG2femto = 0; // Femtoscopy task (PWG2)
130Int_t iPWG2spectra = 0; // Spectra tasks (PWG2
131Int_t iPWG2protons = 1; // Proton-antiproton analysis
132Int_t iPWG2checkcascade = 1; // Check cascades task
133Int_t iPWG2perfcascade = 1; // Check performance cascade
134Int_t iPWG2checkv0 = 1; // Check V0 task
135Int_t iPWG2strange = 1; // Strangeness task
136Int_t iPWG2central = 1; // Anisothropy in central collisions
137Int_t iPWG2flow = 0; // Flow analysis tasks (PWG2)
138Int_t iPWG2res = 0; // Resonances task (PWG2)
139Int_t iPWG2rsneff = 0; // Resonances efficiency
140Int_t iPWG2kink = 0; // Kink analysis tasks (PWG2)
141Int_t iPWG2kinkESDMC = 1; // Kink ESD-MC comparison (PWG2)
142Int_t iPWG2kinkLSKstar = 1; // Kink like-sign K* (PWG2)
143Int_t iPWG2kinkLSL1520 = 1; // Kink like-sign L1520 (PWG2)
144Int_t iPWG2kinkLSPhi = 1; // Kink like-sign Phi (PWG2)
145Int_t iPWG2kinkKstarESD = 1; // Kink Kstar ESD (PWG2)
146Int_t iPWG2kinkKstarMC = 1; // Kink Kstar MC (PWG2)
147Int_t iPWG2kinkL1520ESD = 1; // Kink L1520 ESD (PWG2)
148Int_t iPWG2kinkL1520MC = 1; // Kink L1520 MC (PWG2)
149Int_t iPWG2kinkPhiESD = 1; // Kink resonances Phi ESD (PWG2)
150Int_t iPWG2kinkPhiMC = 1; // Kink resonances Phi MC (PWG2)
151Int_t iPWG2evchar = 0; // Event characteristics (PWG2)
152Int_t iPWG2unicor = 0; // Unicor analysis (PWG2)
153Int_t iPWG2forward = 0; // FMD analysis (PWG2)
154
155// ### Configuration macros used for each module
156//==============================================================================
157TString configPWG2femto = "$ALICE_ROOT/PWG2/FEMTOSCOPY/macros/Train/Train3/ConfigFemtoAnalysis.C";
158//TString configPWG3d2h = "$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF_highmult.C";
159TString configPWG3d2h = "$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C";
160// Temporaries.
161TString anaPars = "";
162TString anaLibs = "";
163// Function signatures
164class AliAnalysisAlien;
165
166//______________________________________________________________________________
167void AnalysisTrainNew(const char *analysis_mode="grid",
168 const char *plugin_mode="full",
169 const char *config_file="")
170{
171// Main analysis train macro. If a configuration file is provided, all parameters
172// are taken from there but may be altered by CheckModuleFlags.
173 if (strlen(config_file) && !LoadConfig(config_file)) return;
174 TString smode(analysis_mode);
175 smode.ToUpper();
176 TString spmode(plugin_mode);
177 spmode.ToLower();
178 if (spmode == "test") useProductionMode = kFALSE;
179 // Check compatibility of selected modules
180 CheckModuleFlags(smode);
181 if (saveTrain) WriteConfig();
182
183 printf("==================================================================\n");
184 printf("=========== RUNNING ANALYSIS TRAIN %s IN %s MODE ==========\n", train_name.Data(),smode.Data());
185 printf("==================================================================\n");
186 printf("= Configuring analysis train for: =\n");
187 if (iAODanalysis) printf("= AOD analysis =\n");
188 else printf("= ESD analysis =\n");
189 if (usePhysicsSelection) printf("= Physics selection =\n");
190 if (useTender) printf("= TENDER =\n");
191 if (iESDfilter) printf("= ESD filter =\n");
192 if (iMUONcopyAOD) printf("= MUON copy AOD =\n");
193 if (iJETAN) printf("= Jet analysis =\n");
194 if (iJETANdelta) printf("= Jet delta AODs =\n");
195 if (iPWG2spectra) {
196 printf("= PWG2 SPECTRA tasks : =\n");
197 if (iPWG2protons) printf("= PWG2 proton-antiproton =\n");
198 if (iPWG2checkcascade) printf("= PWG2 check cascades =\n");
199 if (iPWG2perfcascade) printf("= PWG2 performance cascades =\n");
200 if (iPWG2checkv0) printf("= PWG2 check V0 =\n");
201 if (iPWG2strange) printf("= PWG2 strangeness =\n");
202 if (iPWG2central) printf("= PWG2 central =\n");
203 }
204 if (iPWG2femto) {
205 printf("= PWG2 femtoscopy =\n");
206 printf(" +++ configured by: %s\n", configPWG2femto.Data());
207 }
208 if (iPWG2flow) printf("= PWG2 flow =\n");
209 if (iPWG2res) printf("= PWG2 resonances =\n");
210 if (iPWG2rsneff) printf("= PWG2 resonances efficiency =\n");
211 if (iPWG2kink) {
212 printf("= PWG2 kink analysis tasks: =\n");
213 if (iPWG2kinkESDMC) printf("= PWG2 ESD-MC kinks =\n");
214 if (iPWG2kinkLSKstar) printf("= PWG2 kink like-sign analysis K* =\n");
215 if (iPWG2kinkLSL1520) printf("= PWG2 kink like-sign analysis L1520 =\n");
216 if (iPWG2kinkLSPhi) printf("= PWG2 kink like-sign analysis Phi =\n");
217 if (iPWG2kinkKstarESD) printf("= PWG2 kink Kstar ESD analysis =\n");
218 if (iPWG2kinkKstarMC) printf("= PWG2 kink Kstar MC analysis =\n");
219 if (iPWG2kinkL1520ESD) printf("= PWG2 kink L1520 ESD analysis =\n");
220 if (iPWG2kinkL1520MC) printf("= PWG2 kink L1520 MC analysis =\n");
221 if (iPWG2kinkPhiESD) printf("= PWG2 kink Phi ESD analysis =\n");
222 if (iPWG2kinkPhiMC) printf("= PWG2 kink Phi MC analysis =\n");
223 }
224 if (iPWG2evchar) printf("= PWG2 event characteristics =\n");
225 if (iPWG2unicor) printf("= PWG2 Unicor analysis =\n");
226 if (iPWG2forward) printf("= PWG2 forward: sharing, density, bkg. correction, dNdEta =\n");
227 if (iPWG3vertexing) printf("= PWG3 vertexing =\n");
228 if (iPWG3hfe) printf("= PWG3 electrons =\n");
229 if (iPWG3JPSIfilter) printf("= PWG3 j/psi filter =\n");
230 if (iPWG3JPSI) printf("= PWG3 j/psi =\n");
231 if (iPWG3d2h) {
232 printf("= PWG3 D0->2 hadrons tasks =\n");
233 printf(" +++ configured by: %s\n", configPWG3d2h.Data());
234 if (iPWG3d0mass) printf("= PWG3 D0 mass =\n");
235 if (iPWG3d0massLS) printf("= PWG3 D0 mass LS =\n");
236 if (iPWG3dplus) printf("= PWG3 D+ analysis =\n");
237 if (iPWG3LSd0) printf("= PWG3 LS D0 =\n");
238 if (iPWG3LSjpsi) printf("= PWG3 LS J/Psi =\n");
239 if (iPWG3CFd0) printf("= PWG3 CF D0 =\n");
240 if (iPWG3promptd0) printf("= PWG3 prompt D0 =\n");
241 }
242 if (iPWG3MuonTrain) printf("= PWG3 muon train =\n");
243 if (iPWG4partcorr) printf("= PWG4 gamma-hadron, pi0 and gamma-jet correlations =\n");
244 if (iPWG4gammaconv) printf("= PWG4 gamma conversion =\n");
245 if (iPWG4omega3pi) printf("= PWG4 omega to 3 pions =\n");
246 printf("==================================================================\n");
247 printf(":: use physics selection: %d\n", (UInt_t)usePhysicsSelection);
248 printf(":: use xrootd tweaks: %d\n", (UInt_t)useFastReadOption);
249 printf(":: use overwrite xml : %d\n", (UInt_t)useOverwriteMode);
250 printf(":: use merge via JDL: %d\n", (UInt_t)useMergeViaJDL);
251 printf(":: use MC truth: %d\n", (UInt_t)useMC);
252 printf(":: use KINE filter: %d\n", (UInt_t)useKFILTER);
253 printf(":: use track references: %d\n", (UInt_t)useTR);
254 printf(":: use tags: %d\n", (UInt_t)useTAGS);
255 printf(":: use AOD tags: %d\n", (UInt_t)useAODTAGS);
256 printf(":: use debugging: %d\n", (UInt_t)useDBG);
257 printf(":: use PAR files: %d\n", (UInt_t)usePAR);
258 printf(":: use AliEn plugin: %d\n", (UInt_t)usePLUGIN);
259
260 //==========================================================================
261 // Connect to back-end system
262// if (!Connect(smode)) {
263// ::Error("AnalysisTrain", "Could not connect to %s back-end", analysis_mode);
264// return;
265// }
266
267 // Load common libraries and set include path
268 if (!LoadCommonLibraries(smode)) {
269 ::Error("AnalysisTrain", "Could not load common libraries");
270 return;
271 }
272
273 // Make the analysis manager and connect event handlers
274 AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train", "Production train");
275 if (saveProofToAlien) mgr->SetSpecialOutputLocation(proof_outdir);
276 if (!strcmp(plugin_mode, "test")) mgr->SetNSysInfo(1);
277 // Load analysis specific libraries
278 if (!LoadAnalysisLibraries(smode)) {
279 ::Error("AnalysisTrain", "Could not load analysis libraries");
280 return;
281 }
282
283 // Create input handler (input container created automatically)
284 if (iAODanalysis) {
285 // AOD input handler
286 AliAODInputHandler *aodH = new AliAODInputHandler();
287 if (iPWG3d2h) aodH->AddFriend("AliAOD.VertexingHF.root");
288 mgr->SetInputEventHandler(aodH);
289 } else {
290 // ESD input handler
291 AliESDInputHandler *esdHandler = new AliESDInputHandler();
292 if (useTAGS) esdHandler->SetReadTags();
293 mgr->SetInputEventHandler(esdHandler);
294 }
295 // Monte Carlo handler
296 if (useMC && !iAODanalysis) {
297 AliMCEventHandler* mcHandler = new AliMCEventHandler();
298 mgr->SetMCtruthEventHandler(mcHandler);
299 mcHandler->SetReadTR(useTR);
300 }
301 // AOD output container, created automatically when setting an AOD handler
302 if (iAODhandler) {
303 // AOD output handler
304 AliAODHandler* aodHandler = new AliAODHandler();
305 aodHandler->SetOutputFileName("AliAOD.root");
306 mgr->SetOutputEventHandler(aodHandler);
307 if (iAODanalysis) {
308 aodHandler->SetFillAOD(kFALSE);
309 aodHandler->SetCreateNonStandardAOD();
310 if (iJETAN) aodHandler->SetOutputFileName("AliAOD.Jets.root");
311// if (iPWG3vertexing) aodHandler->SetOutputFileName("AliAOD.VertexingHF.root");
312 }
313 }
314 // Debugging if needed
315 if (useDBG) mgr->SetDebugLevel(3);
316 if (saveCanvases) mgr->SetSaveCanvases(kTRUE);
317
318 //==========================================================================
319 // Create the chain. In this example it is created only from ALIEN files but
320 // can be done to work in batch or grid mode as well.
321 TChain *chain = CreateChain(smode, plugin_mode);
322
323 //==========================================================================
324 // Load the tasks configuration macros for all wagons. These files are supposed now to be
325 // in the current workdir, but in AliEn they will be in the file catalog,
326 // mapped from AliRoot and pecified in the jdl input list.
327
328 // For now connection to top input container and common AOD output container
329 // is done in this macro, but in future these containers will be connected
330 // from each task configuration macro.
331
332 AddAnalysisTasks();
333
334 // Run the analysis
335 //
336 if (usePLUGIN) {
337 AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
338 AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
339 }
340
341 if (mgr->InitAnalysis()) {
342 mgr->PrintStatus();
343 if (saveTrain || strlen(config_file)) gSystem->ChangeDirectory(train_name);
344 StartAnalysis(smode, chain);
345 }
346}
347
348//______________________________________________________________________________
349void AddAnalysisTasks()
350{
351// Add all analysis task wagons to the train
352 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
353
354 //
355 // Tender and supplies. Needs to be called for every event.
356 //
357 if (useTender) {
358 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/TenderSupplies/AddTaskTender.C");
f145e990 359 // IF V0 tender needed, put kTRUE below
360 AliAnalysisTaskSE *tender = AddTaskTender(useV0tender);
361// tender->SetDebugLevel(2);
09765e37 362 }
363
364 if (usePhysicsSelection) {
365 // Physics selection task
366 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
367 mgr->RegisterExtraFile("event_stat.root");
368 AliPhysicsSelectionTask *physSel = AddTaskPhysicsSelection(useMC);
369 }
370
371 if (iESDfilter && !iAODanalysis) {
372 // ESD filter task configuration.
373 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C");
374 if (iMUONcopyAOD) {
375 printf("Registering delta AOD file\n");
376 mgr->RegisterExtraFile("AliAOD.Muons.root");
377 mgr->RegisterExtraFile("AliAOD.Dimuons.root");
378 AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER, kTRUE, kTRUE, usePhysicsSelection);
379 } else {
380 AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER, kFALSE, kFALSE, usePhysicsSelection);
381 }
382 }
383
384 // AOD tags
385 if (useAODTAGS) {
386 AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator");
387 mgr->AddTask(tagTask);
388 AliAnalysisDataContainer *coutTags = mgr->CreateContainer("cTag", TTree::Class(),
389 AliAnalysisManager::kOutputContainer, "AOD.tag.root");
390 mgr->ConnectInput (tagTask, 0, mgr->GetCommonInputContainer());
391 mgr->ConnectOutput(tagTask, 1, coutTags);
392 }
393
394// ********** PWG2 wagons ******************************************************
395 AliAnalysisManager::SetCommonFileName("PWG2histograms.root");
396
397 // Proton analysis
398 if (iPWG2spectra) {
399 // protons
400 if (iPWG2protons) {
401 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskProtons.C");
402 AliAnalysisTaskProtons *taskprotons = AddTaskProtons();
403 if (!taskprotons) ::Warning("AnalysisTrainNew", "AliAnalysisTaskProtons cannot run for this train conditions - EXCLUDED");
404 }
405 // cascades
406 if (iPWG2checkcascade) {
407 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskCheckCascade.C");
408 AliAnalysisTaskCheckCascade *taskcheckcascade = AddTaskCheckCascade(iCollision,runOnData);
409 if (!taskcheckcascade) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCheckCascade cannot run for this train conditions - EXCLUDED");
410 }
411 // v0's
412 if (iPWG2checkv0) {
413 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskCheckV0.C");
414 AliAnalysisTaskCheckV0 *taskcheckV0 = AddTaskCheckV0();
415 if (!taskcheckV0) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCheckV0 cannot run for this train conditions - EXCLUDED");
416 }
417 // strangeness
418 if (iPWG2strange) {
419 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskStrange.C");
420 AliAnalysisTaskStrange *taskstrange = AddTaskStrange();
421 if (!taskstrange) ::Warning("AnalysisTrainNew", "AliAnalysisTaskStrange cannot run for this train conditions - EXCLUDED");
422 }
423 // performance cascades
424 if (iPWG2perfcascade) {
425 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskCheckPerformanceCascade.C");
426 AliAnalysisTaskCheckPerformanceCascade *taskperfcascade = AddTaskCheckPerformanceCascade();
427 if (!taskperfcascade) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCheckPerformanceCascade cannot run for this train conditions - EXCLUDED");
428 }
429 // central
430 if (iPWG2central) {
431 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskCentral.C");
432 AliAnalysisTaskCentral *taskcentral = AddTaskCentral();
433 if (!taskcentral) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCentral cannot run for this train conditions - EXCLUDED");
434 }
435 }
436
437 // Femtoscopy analysis modules
438 if (iPWG2femto) {
439 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FEMTOSCOPY/macros/AddTaskFemto.C");
440 AliAnalysisTaskFemto *taskfemto = AddTaskFemto(configPWG2femto);
441 if (!taskfemto) ::Warning("AnalysisTrainNew", "AliAnalysisTaskFemto cannot run for this train conditions - EXCLUDED");
442 }
443
444 // Kink analysis
445 if (iPWG2kink) {
446 if (iPWG2kinkESDMC) {
447 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKink.C");
448 AliAnalysisKinkESDMC *taskkink1 = AddTaskKink();
449 if (!taskkink1) ::Warning("AnalysisTrainNew", "AliAnalysisKinkESDMC cannot run for this train conditions - EXCLUDED");
450 }
451 if (iPWG2kinkLSKstar) {
452 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResLikeSignKstar.C");
453 AliResonanceKinkLikeSign *taskkink2 = AddTaskKinkResLikeSignKstar();
454 if (!taskkink2) ::Warning("AnalysisTrainNew", "AliResonanceKinkLikeSign cannot run for this train conditions - EXCLUDED");
455 }
456 if (iPWG2kinkLSL1520) {
457 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResLikeSignL1520.C");
458 AliResonanceKinkLikeSign *taskkink3 = AddTaskKinkResLikeSignL1520();
459 if (!taskkink3) ::Warning("AnalysisTrainNew", "AliResonanceKinkLikeSign cannot run for this train conditions - EXCLUDED");
460 }
461 if (iPWG2kinkLSPhi) {
462 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResLikeSignPhi.C");
463 AliResonanceKinkLikeSign *taskkink4 = AddTaskKinkResLikeSignPhi();
464 if (!taskkink4) ::Warning("AnalysisTrainNew", "AliResonanceKinkLikeSign cannot run for this train conditions - EXCLUDED");
465 }
466 if (iPWG2kinkKstarESD) {
467 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceKstarESD.C");
468 AliAnalysisTaskKinkResonance *taskkink5 = AddTaskKinkResonanceKstarESD();
469 if (!taskkink5) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonanceKstarESD cannot run for this train conditions - EXCLUDED");
470 }
471 if (iPWG2kinkKstarMC) {
472 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceKstarMC.C");
473 AliAnalysisTaskKinkResonance *taskkink6 = AddTaskKinkResonanceKstarMC();
474 if (!taskkink6) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonanceKstarMC cannot run for this train conditions - EXCLUDED");
475 }
476 if (iPWG2kinkL1520ESD) {
477 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceL1520ESD.C");
478 AliAnalysisTaskKinkResonance *taskkink7 = AddTaskKinkResonanceL1520ESD();
479 if (!taskkink7) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonanceL1520ESD cannot run for this train conditions - EXCLUDED");
480 }
481 if (iPWG2kinkL1520MC) {
482 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceL1520MC.C");
483 AliAnalysisTaskKinkResonance *taskkink8 = AddTaskKinkResonanceL1520MC();
484 if (!taskkink8) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonanceL1520MC cannot run for this train conditions - EXCLUDED");
485 }
486 if (iPWG2kinkPhiESD) {
487 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonancePhiESD.C");
488 AliAnalysisTaskKinkResonance *taskkink9 = AddTaskKinkResonancePhiESD();
489 if (!taskkink9) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonancePhiESD cannot run for this train conditions - EXCLUDED");
490 }
491 if (iPWG2kinkPhiMC) {
492 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonancePhiMC.C");
493 AliAnalysisTaskKinkResonance *taskkink10 = AddTaskKinkResonancePhiMC();
494 if (!taskkink10) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonancePhiMC cannot run for this train conditions - EXCLUDED");
495 }
496 }
497
498 // Event characterization
499 if (iPWG2evchar) {
500 gROOT->LoadMacro("$ALICE_ROOT/PWG2/EVCHAR/macros/AddTaskSPDdNdEta.C");
501 AliAnalysisTaskSPDdNdEta *taskspddndeta = AddTaskSPDdNdEta();
502 if (!taskspddndeta) ::Warning("AnalysisTrainNew", "AliAnalysisTaskSPDdNdEta cannot run for this train conditions - EXCLUDED");
503 taskspddndeta->SetReadMC(useMC);
504 }
505
506 // Unicor
507 if (iPWG2unicor) {
508 gROOT->LoadMacro("$ALICE_ROOT/PWG2/UNICOR/AddTaskUnicor.C");
509 AliAnalysisTaskUnicor *taskunicor = AddTaskUnicor();
510 if (!taskunicor) ::Warning("AnalysisTrainNew", "AliAnalysisTaskUnicor cannot run for this train conditions - EXCLUDED");
511 }
512
513 // FMD
514 AliAnalysisManager::SetCommonFileName("forward.root");
515 if (iPWG2forward) {
516 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis/AddTaskFMD.C");
517 AliFMDAnalysisTaskSE *taskfmd = AddTaskFMD();
518 if (!taskfmd) ::Warning("AnalysisTrainNew", "AliFMDAnalysisTaskSE cannot run for this train conditions - EXCLUDED");
519 }
520 AliAnalysisManager::SetCommonFileName("PWG2histograms.root");
521
522 // Flow analysis
523 if (iPWG2flow) {
524 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FLOW/macros/AddTaskFlow.C");
525 Bool_t SP = kTRUE;
526 Bool_t LYZ1SUM = kTRUE;
527 Bool_t LYZ1PROD = kTRUE;
528 Bool_t LYZ2SUM = kFALSE;
529 Bool_t LYZ2PROD = kFALSE;
530 Bool_t LYZEP = kFALSE;
531 Bool_t GFC = kTRUE;
532 Bool_t QC = kTRUE;
533 Bool_t FQD = kFALSE;
534 Bool_t MCEP = kFALSE; //does not work yet 24/12/08
535 Bool_t kineFromESD = kTRUE;
536 Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP};
537 // Analysis type can be ESD, AOD, MC, ESDMC0, ESDMC1
538 TString type = "AOD";
539 if (!iAODanalysis) type = "ESD";
540 // Boolean to fill/not fill the QA histograms
541 Bool_t QA = kTRUE;
542 // Boolean to use/not use weights for the Q vector
543 Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
544 AliAnalysisTaskFlowEvent* taskFE = AddTaskFlow(type,METHODS,QA,WEIGHTS);
545 if (!taskFE) ::Warning("AnalysisTrainNew", "AliAnalysisTaskFlowEvent cannot run for this train conditions - EXCLUDED");
546 }
547
548 // PWG2 resonances
549 AliAnalysisManager::SetCommonFileName("resonances.root");
550 if (iPWG2res) {
551 gROOT->LoadMacro("$ALICE_ROOT/PWG2/RESONANCES/macros/train/AddAnalysisTaskRsnNew.C");
552 gROOT->LoadMacro("$ALICE_ROOT/PWG2/RESONANCES/macros/train/AddAnalysisTaskRsnEffNew.C");
553 TString path = gROOT->GetMacroPath();
554 path += ":$ALICE_ROOT/PWG2/RESONANCES/macros/train";
555 gROOT->SetMacroPath(path);
556 AddAnalysisTaskRsn(kTRUE);
557 if (iPWG2rsneff) AddAnalysisTaskRsnEff();
558 }
559 AliAnalysisManager::SetCommonFileName("PWG2histograms.root");
560
561// ********** PWG3 wagons ******************************************************
562 AliAnalysisManager::SetCommonFileName("PWG3histograms.root");
563
564 // PWG3 vertexing
565 if (iPWG3vertexing) {
566 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/macros/AddTaskVertexingHF.C");
567 if (!iPWG3d2h) TFile::Cp(gSystem->ExpandPathName(configPWG3d2h.Data()), Form("%s/ConfigVertexingHF.C", train_name.Data()));
568 AliAnalysisTaskSEVertexingHF *taskvertexingHF = AddTaskVertexingHF();
569 if (!taskvertexingHF) ::Warning("AnalysisTrainNew", "AliAnalysisTaskSEVertexingHF cannot run for this train conditions - EXCLUDED");
570 else mgr->RegisterExtraFile("AliAOD.VertexingHF.root");
571 }
572
573 // PWG3 electrons
574 if (iPWG3hfe) {
575 gROOT->LoadMacro("$ALICE_ROOT/PWG3/hfe/AddTaskHFE.C");
576 AliAnalysisTaskHFE *taskHFE = AddTaskHFE();
577 if (!taskHFE) ::Warning("AnalysisTrainNew", "AliAnalysisTaskHFE cannot run for this train conditions - EXCLUDED");
578 }
579
580 // PWG3 JPSI filtering
581 if (iPWG3JPSIfilter) {
582 gROOT->LoadMacro("$ALICE_ROOT/PWG3/dielectron/macros/AddTaskJPSIFilter.C");
583 AliAnalysisTask *taskJPSIfilter = AddTaskJPSIFilter();
584 if (!taskJPSIfilter) ::Warning("AnalysisTrainNew", "AliAnalysisTaskDielectronFilter cannot run for this train conditions - EXCLUDED");
585 else mgr->RegisterExtraFile("AliAOD.Dielectron.root");
586 }
587
588 // PWG3 JPSI
589 if (iPWG3JPSI) {
590 gROOT->LoadMacro("$ALICE_ROOT/PWG3/dielectron/macros/AddTaskJPSI.C");
591 AliAnalysisTask *taskJPSI = AddTaskJPSI();
592 if (!taskJPSI) ::Warning("AnalysisTrainNew", "AliAnalysisTaskMultiDielectron cannot run for this train conditions - EXCLUDED");
593 }
594
595 // PWG3 D2h
596 if (iPWG3d2h) {
597 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/AddD2HTrain.C");
598 TFile::Cp(gSystem->ExpandPathName(configPWG3d2h.Data()), Form("%s/ConfigVertexingHF.C", train_name.Data()));
599 AddD2HTrain(iPWG3d0mass,iPWG3d0massLS,iPWG3dplus, iPWG3LSd0, iPWG3LSjpsi, iPWG3CFd0, iPWG3promptd0);
600 }
601
602 // PWG3 muon
603 if (iPWG3MuonTrain) {
604 gROOT->LoadMacro("$ALICE_ROOT/PWG3/muon/AddPWG3MuonTrain.C");
605 // iESDAnalysis, iAODAnalysis -> flags to select if the train is AOD or ESD based
606 // iMuonDistributions, iSingleMuonANAlysis -> flags to switch on/off analysis wagons
607 Int_t isESDAnalysis = (iAODanalysis)?0:1;
608 Int_t isAODAnalysis = (iAODanalysis)?1:0;
609 Int_t addMuonDistributions = 1;
610 Int_t addSingleMuonAnalysis = 1;
611 Int_t addMuonHFAnalysis = 1;
612 Int_t ntaskmuon = AddPWG3MuonTrain(isESDAnalysis,isAODAnalysis,addMuonDistributions,addSingleMuonAnalysis,addMuonHFAnalysis);
613 printf("Added %d muon tasks\n", ntaskmuon);
614 }
615
616// ********** PWG4 wagons ******************************************************
617 AliAnalysisManager::SetCommonFileName("PWG4histograms.root");
618
619 // Jet analysis
620 if (iJETAN) {
621 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJets.C");
622 if (!iAODanalysis) {
623 // Default jet reconstructor running on ESD's
624 AliAnalysisTaskJets * taskjets = AddTaskJets();
625 if (!taskjets) ::Warning("AnalysisTrainNew", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED");
626 if (iJETANdelta) {
627 AddTaskJetsDelta("AliAOD.Jets.root");
628 mgr->RegisterExtraFile("AliAOD.Jets.root");
629 }
630 } else {
631 // AOD-based analysis. Add all reconstructors to write into delta AOD's
632 if (iJETANdelta) {
633 Int_t ntasksjets = AddTaskJetsDelta("AliAOD.Jets.root",0,kFALSE);
634 if (ntasksjets) printf("Added %d jet reconstructors\n", ntasksjets);
635 }
636 }
637 }
638 // PWG4 hadron correlations
639 if (iPWG4partcorr) {
640 Bool_t isSimulation = (runOnData)?kFALSE:kTRUE;
641 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPartCorr.C");
642 AliAnalysisTaskParticleCorrelation *taskpartcorrPHOS = AddTaskPartCorr("AOD", "PHOS", kFALSE, isSimulation);
643 if (!taskpartcorrPHOS) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation PHOS cannot run for this train conditions - EXCLUDED");
644 AliAnalysisTaskParticleCorrelation *taskpartcorrEMCAL = AddTaskPartCorr("AOD", "EMCAL", kFALSE, isSimulation);
645 if (!taskpartcorrEMCAL) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation EMCAL cannot run for this train conditions - EXCLUDED");
646 mgr->RegisterExtraFile("deltaAODPartCorr.root");
647 }
648
649 // PWG4 gamma conversion analysis
650 if (iPWG4gammaconv) {
651 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskGammaConversion.C");
652 TString cdir = gSystem->WorkingDirectory();
653 gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/"));
654 TString gcArguments = "-run-on-train -use-own-xyz -run-jet -run-neutralmeson -no-aod -apply-chi2-cut -low-memory -use-v0-multiplicity -move-bg-vertex ";
655 TString kGCAnalysisCutSelectionId="900110204010001";
656// gcArguments.Append(Form(" -set-cut-selection %s",kGCAnalysisCutSelectionId.Data()));
657 if(!useMC)gcArguments += " -mc-off";
658 AliAnalysisTaskGammaConversion * taskGammaConversion = AddTaskGammaConversion(gcArguments,mgr->GetCommonInputContainer());
659 gSystem->ChangeDirectory(cdir);
660 taskGammaConversion->SelectCollisionCandidates();
661 if (!taskGammaConversion) ::Warning("AnalysisTrainNew", "AliAnalysisTaskGammaConversion cannot run for these train conditions - EXCLUDED");
662 }
663
664 // PWG4 omega to 3 pions analysis
665 if (iPWG4omega3pi) {
666 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskomega3pi.C");
667 AliAnalysisTaskOmegaPi0PiPi *taskomega3pi = AddTaskomega3pi();
668 if (!taskomega3pi) ::Warning("AnalysisTrainNew", "AliAnalysisTaskomega3pi cannot run for these train conditions - EXCLUDED");
669 }
670}
671
672//______________________________________________________________________________
673void StartAnalysis(const char *mode, TChain *chain) {
674// Start analysis.
675 Int_t imode = -1;
676 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
677 if (!strcmp(mode, "LOCAL")) imode = 0;
678 if (!strcmp(mode, "PROOF")) imode = 1;
679 if (!strcmp(mode, "GRID")) imode = 2;
680 switch (imode) {
681 case 0:
682 if (!chain) {
683 ::Error("AnalysisTrainNew.C::StartAnalysis", "Cannot create the chain");
684 return;
685 }
686 mgr->StartAnalysis(mode, chain);
687 return;
688 case 1:
689 if (!proof_dataset.Length()) {
690 ::Error("AnalysisTrainNew.C::StartAnalysis", "proof_dataset is empty");
691 return;
692 }
693 mgr->StartAnalysis(mode, proof_dataset, 1000);
694 return;
695 case 2:
696 if (usePLUGIN) {
697 if (!mgr->GetGridHandler()) {
698 ::Error("AnalysisTrainNew.C::StartAnalysis", "Grid plugin not initialized");
699 return;
700 }
701 mgr->StartAnalysis("grid");
702 } else {
703 if (!chain) {
704 ::Error("AnalysisTrainNew.C::StartAnalysis", "Cannot create the chain");
705 return;
706 }
707 mgr->StartAnalysis(mode, chain);
708 }
709 return;
710 }
711}
712
713//______________________________________________________________________________
714void CheckModuleFlags(const char *mode) {
715// Checks selected modules and insure compatibility
716 Int_t imode = -1;
717 if (!strcmp(mode, "LOCAL")) imode = 0;
718 if (!strcmp(mode, "PROOF")) imode = 1;
719 if (!strcmp(mode, "GRID")) imode = 2;
720 if (!iJETAN) iJETANdelta = 0;
721 if (imode==1) {
722 if (!usePAR) {
723 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis");
724 usePAR = kTRUE;
725 }
726 }
727 if (imode != 2) {
728 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode");
729 usePLUGIN = kFALSE;
730 }
731 if (iAODanalysis) {
732 // AOD analysis
733 if (useMC)
734 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's");
735 if (useAODTAGS)
736 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "AOD tags usage disabled in analysis on AOD's");
737 useMC = kFALSE;
738 useTR = kFALSE;
739 useAODTAGS = kFALSE;
740 if (iESDfilter)
741 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's");
742 iESDfilter = 0;
743 if (!iAODhandler) {
744 if (iJETAN)
745 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler");
746 iJETAN = 0;
747 iJETANdelta = 0;
748 }
749 // Disable tasks that do not work yet on AOD data
750 if (iPWG4gammaconv)
751 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4gammaconv disabled on AOD's without AOD handler");
752 iPWG4gammaconv = 0;
753 if (iPWG2central)
754 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2central disabled on AOD's");
755 iPWG2central = 0;
756 if (iPWG2flow)
757 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2flow disabled on AOD's");
758 iPWG2flow = 0;
759 if (iPWG2femto)
760 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2femto disabled on AOD's");
761 iPWG2femto = 0;
762 if (iPWG2res)
763 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2res disabled on AOD's");
764 iPWG2res = 0;
765 if (iPWG2rsneff)
766 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2rsneff disabled on AOD's");
767 iPWG2rsneff = 0;
768 if (iPWG2kink)
769 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2kink disabled in analysis on AOD's");
770 iPWG2kink = 0;
771 if (iPWG2unicor)
772 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2unicor disabled in analysis on AOD's");
773 iPWG2unicor = 0;
774 if (iPWG2evchar)
775 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4evchar disabled on AOD's");
776 iPWG2evchar = 0;
777 if (iPWG2forward)
778 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2forward disabled in analysis on AOD's");
779 iPWG2forward = 0;
780 if (iPWG3hfe)
781 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG3hfe disabled on AOD's");
782 iPWG3hfe = 0;
783 if (iPWG4omega3pi)
784 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4omega3pi disabled on AOD's");
785 iPWG4omega3pi = 0;
786 } else {
787 // ESD analysis
788 if (!useMC) useTR = kFALSE;
789 if (!useTR) {
790 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "iPWG2evchar disabled if not reading track references");
791 iPWG2evchar = 0;
792 }
793 }
794 if (!useMC) {
795 if (iPWG2perfcascade)
796 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2perfcascade disabled without MC info");
797 iPWG2perfcascade = 0;
798 if (iPWG2central)
799 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2central disabled without MC info");
800 iPWG2central = 0;
801 }
802 if (iJETAN && !iAODanalysis) iESDfilter=1;
803 if (iESDfilter) {iAODhandler=1; useCORRFW = kTRUE;}
804 if (iPWG2spectra || iPWG2flow || iPWG3vertexing || iPWG3hfe || iPWG2res || iPWG2rsneff) useCORRFW = kTRUE;
805 if (useKFILTER && !useMC) useKFILTER = kFALSE;
806 if (useAODTAGS && !iAODhandler) useAODTAGS = kFALSE;
807}
808
809//______________________________________________________________________________
810Bool_t Connect(const char *mode) {
811// Connect <username> to the back-end system.
812 Int_t imode = -1;
813 if (!strcmp(mode, "LOCAL")) imode = 0;
814 if (!strcmp(mode, "PROOF")) imode = 1;
815 if (!strcmp(mode, "GRID")) imode = 2;
816 TString username = gSystem->Getenv("alien_API_USER");
817 switch (imode) {
818 case 0:
819 break;
820 case 1:
821 if (!username.Length()) {
822 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), "Make sure you:\n \
823 1. Have called: alien-token-init <username>\n \
824 2. Have called: >source /tmp/gclient_env_$UID");
825 return kFALSE;
826 }
827 ::Info("AnalysisTrainNew.C::Connect", "Connecting user <%s> to PROOF cluster <%s>",
828 username.Data(), proof_cluster.Data());
829 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
830// TProof::Open(Form("%s@%s:31093", username.Data(), proof_cluster.Data()));
831 TProof::Open(Form("%s@%s", username.Data(), proof_cluster.Data()));
832 if (!gProof) {
833 if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch"))
834 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch");
835 return kFALSE;
836 }
837 TGrid::Connect("alien://");
838 if (gGrid) {
839 TString homedir = gGrid->GetHomeDirectory();
840 TString workdir = homedir + train_name;
841 if (!gGrid->Cd(workdir)) {
842 gGrid->Cd(homedir);
843 if (gGrid->Mkdir(workdir)) {
844 gGrid->Cd(train_name);
845 ::Info("AnalysisTrainNew::Connect()", "Directory %s created", gGrid->Pwd());
846 }
847 }
848 gGrid->Mkdir("proof_output");
849 gGrid->Cd("proof_output");
850 proof_outdir = Form("alien://%s", gGrid->Pwd());
851 }
852 break;
853 case 2:
854 if (usePLUGIN && !gSystem->Getenv("alien_CLOSE_SE")) {
855 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode),
856 "When using the AliEn plugin it is preferable to define the \
857 variable alien_CLOSE_SE in your environment.");
858 return kFALSE;
859 }
860 ::Info("AnalysisTrainNew.C::Connect", "Connecting user <%s> to AliEn ...",
861 username.Data());
862 TGrid::Connect("alien://");
863 if (!gGrid || !gGrid->IsConnected()) return kFALSE;
864 break;
865 default:
866 ::Error("AnalysisTrainNew.C::Connect", "Unknown run mode: %s", mode);
867 return kFALSE;
868 }
869 ::Info("AnalysisTrainNew.C::Connect","Connected in %s mode", mode);
870 return kTRUE;
871}
872
873//______________________________________________________________________________
874Bool_t LoadCommonLibraries(const char *mode)
875{
876// Load common analysis libraries.
877 Int_t imode = -1;
878 if (!strcmp(mode, "LOCAL")) imode = 0;
879 if (!strcmp(mode, "PROOF")) imode = 1;
880 if (!strcmp(mode, "GRID")) imode = 2;
881 if (!gSystem->Getenv("ALICE_ROOT")) {
882 ::Error("AnalysisTrainNew.C::LoadCommonLibraries", "Analysis train requires that analysis libraries are compiled with a local AliRoot");
883 return kFALSE;
884 }
885 Bool_t success = kTRUE;
886 // ROOT libraries
887 gSystem->Load("libTree.so");
888 gSystem->Load("libGeom.so");
889 gSystem->Load("libVMC.so");
890 gSystem->Load("libPhysics.so");
891 gSystem->Load("libMinuit.so");
892
893 // Load framework classes. Par option ignored here.
894 switch (imode) {
895 case 0:
896 case 2:
897 if (useCPAR) {
898 success &= LoadLibrary("STEERBase", mode, kTRUE);
899 success &= LoadLibrary("ESD", mode, kTRUE);
900 success &= LoadLibrary("AOD", mode, kTRUE);
901 success &= LoadLibrary("ANALYSIS", mode, kTRUE);
902 success &= LoadLibrary("ANALYSISalice", mode, kTRUE);
903 if (useCORRFW) success &= LoadLibrary("CORRFW", mode, kTRUE);
904 } else {
905 success &= LoadLibrary("libSTEERBase.so", mode);
906 success &= LoadLibrary("libESD.so", mode);
907 success &= LoadLibrary("libAOD.so", mode);
908 success &= LoadLibrary("libANALYSIS.so", mode);
909 success &= LoadLibrary("libANALYSISalice.so", mode);
910 if (useCORRFW) success &= LoadLibrary("libCORRFW.so", mode);
911 gROOT->ProcessLine(".include $ALICE_ROOT/include");
912 }
913 break;
914 case 1:
915 Int_t ires = -1;
916 if (useAFPAR && !gSystem->AccessPathName(AFversion)) ires = gProof->UploadPackage(AFversion);
917 if (ires < 0) {
918 success &= LoadLibrary("STEERBase", mode);
919 success &= LoadLibrary("ESD", mode);
920 success &= LoadLibrary("AOD", mode);
921 success &= LoadLibrary("ANALYSIS", mode);
922 success &= LoadLibrary("ANALYSISalice", mode);
923 if (useCORRFW) success &= LoadLibrary("CORRFW", mode);
924 } else {
925 ires = gProof->EnablePackage(AFversion);
926 if (ires<0) success = kFALSE;
927 if (useCORRFW) success &= LoadLibrary("CORRFW", mode);
928 }
929 break;
930 default:
931 ::Error("AnalysisTrainNew.C::LoadCommonLibraries", "Unknown run mode: %s", mode);
932 return kFALSE;
933 }
934 if (success) {
935 ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Load common libraries: SUCCESS");
936 ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s",
937 gSystem->GetIncludePath());
938 } else {
939 ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Load common libraries: FAILED");
940 }
941
942 return success;
943}
944
945//______________________________________________________________________________
946Bool_t LoadAnalysisLibraries(const char *mode)
947{
948// Load common analysis libraries.
949 Bool_t success = kTRUE;
950 if (useTender) {
951 if (!LoadLibrary("TENDER", mode, kTRUE) ||
952 !LoadLibrary("TENDERSupplies", mode, kTRUE)) return kFALSE;
953 }
954 if (iESDfilter || iPWG3MuonTrain) {
955 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
956 !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE;
957 }
958 // JETAN
959 if (iJETAN) {
960 if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE;
961 }
962 if (iJETANdelta) {
963 if (!LoadLibrary("JETAN", mode, kTRUE) ||
964 !LoadLibrary("CGAL", mode, kTRUE) ||
965 !LoadLibrary("fastjet", mode, kTRUE) ||
966 !LoadLibrary("siscone", mode, kTRUE) ||
967 !LoadLibrary("SISConePlugin", mode, kTRUE) ||
968 !LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE;
969 }
970 // PWG4 particle correlations
971 if (iPWG4partcorr) {
972 if (!LoadLibrary("EMCALUtils", mode, kTRUE) ||
973 !LoadLibrary("PHOSUtils", mode, kTRUE) ||
974 !LoadLibrary("PWG4PartCorrBase", mode, kTRUE) ||
975 !LoadLibrary("PWG4PartCorrDep", mode, kTRUE)) return kFALSE;
976 }
977 // PWG4 gamma conversion
978 if (iPWG4gammaconv) {
979 if (!LoadLibrary("PWG4GammaConv", mode, kTRUE)) return kFALSE;
980 }
981 // PWG4 omega to 3 pions
982 if (iPWG4omega3pi) {
983 if (!LoadLibrary("PWG4omega3pi", mode, kTRUE)) return kFALSE;
984 }
985 // PWG2 task protons
986 if (iPWG2spectra) {
987 if (!LoadLibrary("PWG2spectra", mode, kTRUE)) return kFALSE;
988 }
989 // PWG2 flow
990 if (iPWG2flow) {
991 if (!LoadLibrary("PWG2flowCommon", mode, kTRUE) ||
992 !LoadLibrary("PWG2flowTasks", mode, kTRUE)) return kFALSE;
993 }
994 // PWG2 resonances
995 if (iPWG2res || iPWG2rsneff) {
996 if (!LoadLibrary("PWG2resonances", mode, kTRUE)) return kFALSE;
997 }
998 // PWG2 kink
999 if (iPWG2kink) {
1000 if (!LoadLibrary("PWG2kink", mode, kTRUE)) return kFALSE;
1001 }
1002 // PWG2 unicor
1003 if (iPWG2unicor) {
1004 if (!LoadLibrary("PWG2unicor", mode, kTRUE)) return kFALSE;
1005 }
1006 // PWG2 evchar
1007 if (iPWG2evchar) {
1008 if (!LoadLibrary("PWG2evchar", mode, kTRUE)) return kFALSE;
1009 }
1010 // PWG2 femtoscopy
1011 if (iPWG2femto) {
1012 if (!LoadLibrary("PWG2AOD", mode, kTRUE) ||
1013 !LoadLibrary("PWG2femtoscopy", mode, kTRUE) ||
1014 !LoadLibrary("PWG2femtoscopyUser", mode, kTRUE)) return kFALSE;
1015// TFile::Cp(gSystem->ExpandPathName("$(ALICE_ROOT)/PWG2/FEMTOSCOPY/macros/ConfigFemtoAnalysis.C"), Form("%s/ConfigFemtoAnalysis.C", train_name.Data()));
1016// anaLibs += "ConfigFemtoAnalysis.C ";
1017 }
1018 // PWG2 FORWARD
1019 if (iPWG2forward) {
1020 if (!LoadLibrary("PWG2forward", mode, kTRUE)) return kFALSE;
1021 }
1022 // PWG3 Vertexing HF
1023 if (iPWG3vertexing || iPWG3d2h) {
1024 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
1025 !LoadLibrary("PWG3vertexingHF", mode, kTRUE)) return kFALSE;
1026 }
1027 // PWG3 hfe
1028 if (iPWG3hfe) {
1029 if (!LoadLibrary("PWG3hfe", mode, kTRUE)) return kFALSE;
1030 }
1031 // PWG3 dielectron
1032 if (iPWG3JPSIfilter || iPWG3JPSI) {
1033 if (!LoadLibrary("PWG3dielectron", mode, kTRUE)) return kFALSE;
1034 }
1035
1036 ::Info("AnalysisTrainNew.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS");
1037 return kTRUE;
1038}
1039
1040//______________________________________________________________________________
1041Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE)
1042{
1043// Load a module library in a given mode. Reports success.
1044 Int_t imode = -1;
1045 Int_t result;
1046 TString smodule(module);
1047 if (!strcmp(mode, "LOCAL")) imode = 0;
1048 if (!strcmp(mode, "PROOF")) imode = 1;
1049 if (!strcmp(mode, "GRID")) imode = 2;
1050 TString mod(module);
1051 if (!mod.Length()) {
1052 ::Error("AnalysisTrainNew.C::LoadLibrary", "Empty module name");
1053 return kFALSE;
1054 }
1055 // If a library is specified, just load it
1056 if (smodule.EndsWith(".so")) {
1057 mod.Remove(mod.Index(".so"));
1058 result = gSystem->Load(mod);
1059 if (result < 0) {
1060 ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not load library %s", module);
1061 return kFALSE;
1062 }
1063 if (rec) anaLibs += Form("%s.so ",mod.Data());
1064 return kTRUE;
1065 }
1066 // Check if the library is already loaded
1067 if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0)
1068 return kTRUE;
1069 switch (imode) {
1070 case 0:
1071 case 2:
1072 if (usePAR) {
1073 result = SetupPar(module);
1074 if (rec) anaPars += Form("%s.par ", module);
1075 } else {
1076 result = gSystem->Load(Form("lib%s.so", module));
1077 if (rec) anaLibs += Form("lib%s.so ", module);
1078 }
1079 break;
1080 case 1:
1081 result = gProof->UploadPackage(module);
1082 if (result<0) {
1083 result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module)));
1084 if (result<0) {
1085 ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module);
1086 return kFALSE;
1087 }
1088 }
1089 result = gProof->EnablePackage(module);
1090 break;
1091 default:
1092 return kFALSE;
1093 }
1094 if (result < 0) {
1095 ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not load module %s", module);
1096 return kFALSE;
1097 }
1098 return kTRUE;
1099}
1100
1101
1102//______________________________________________________________________________
1103TChain *CreateChain(const char *mode, const char *plugin_mode)
1104{
1105// Create the input chain
1106 Int_t imode = -1;
1107 if (!strcmp(mode, "LOCAL")) imode = 0;
1108 if (!strcmp(mode, "PROOF")) imode = 1;
1109 if (!strcmp(mode, "GRID")) imode = 2;
1110 TChain *chain = NULL;
1111 // Local chain
1112 switch (imode) {
1113 case 0:
1114 if (iAODanalysis) {
1115 if (!local_xmldataset.Length()) {
1116 // Local AOD
1117 chain = new TChain("aodTree");
1118 if (gSystem->AccessPathName("data/AliAOD.root"))
1119 ::Error("AnalysisTrainNew.C::CreateChain", "File: AliAOD.root not in ./data dir");
1120 else {
1121 if (!saveTrain) chain->Add("data/AliAOD.root");
1122 else chain->Add("../data/AliAOD.root");
1123 }
1124 } else {
1125 // Interactive AOD
1126 chain = CreateChainSingle(local_xmldataset, "aodTree");
1127 }
1128 } else {
1129 if (!local_xmldataset.Length()) {
1130 // Local ESD
1131 chain = new TChain("esdTree");
1132 if (gSystem->AccessPathName("data/AliESDs.root"))
1133 ::Error("AnalysisTrainNew.C::CreateChain", "File: AliESDs.root not in ./data dir");
1134 else {
1135 if (!saveTrain) chain->Add("data/AliESDs.root");
1136 else chain->Add("../data/AliESDs.root");
1137 }
1138 } else {
1139 // Interactive ESD
1140 chain = CreateChainSingle(local_xmldataset, "esdTree");
1141 }
1142 }
1143 break;
1144 case 1:
1145 break;
1146 case 2:
1147 if (usePLUGIN) {
1148// AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
1149// AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
1150 } else {
1151 TString treeName = "esdTree";
1152 if (iAODanalysis) treeName = "aodTree";
1153 chain = CreateChainSingle("wn.xml", treeName);
1154 }
1155 break;
1156 default:
1157 }
1158 if (chain && chain->GetNtrees()) return chain;
1159 return NULL;
1160}
1161
1162//______________________________________________________________________________
1163TChain* CreateChainSingle(const char* xmlfile, const char *treeName)
1164{
1165 printf("*******************************\n");
1166 printf("*** Getting the ESD Chain ***\n");
1167 printf("*******************************\n");
1168 TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
1169
1170 if (!myCollection) {
1171 ::Error("AnalysisTrainNew.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
1172 return NULL ;
1173 }
1174
1175 TChain* chain = new TChain(treeName);
1176 myCollection->Reset() ;
1177 while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
1178 chain->ls();
1179 return chain;
1180}
1181
1182//______________________________________________________________________________
1183Int_t SetupPar(char* pararchivename)
1184{
1185 if (!pararchivename || !strlen(pararchivename)) return -1;
1186 char processline[1024];
1187 if (gSystem->AccessPathName(Form("%s.par", pararchivename))) {
1188 if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) {
1189 ::Info("AnalysisTrainNew.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename);
1190 TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)),
1191 Form("%s.par",pararchivename));
1192 } else {
1193 ::Error("AnalysisTrainNew.C::SetupPar", "Cannot find %s.par", pararchivename);
1194 return -1;
1195 }
1196 }
1197 if (usePLUGIN && saveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, train_name.Data()));
1198 gSystem->Exec(Form("tar xvzf %s.par", pararchivename));
1199
1200 TString ocwd = gSystem->WorkingDirectory();
1201 if (!gSystem->ChangeDirectory(pararchivename)) return -1;
1202
1203 // check for BUILD.sh and execute
1204 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
1205 printf("*******************************\n");
1206 printf("*** Building PAR archive ***\n");
1207 printf("*******************************\n");
1208 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
1209 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
1210 return -1;
1211 }
1212 }
1213
1214 // check for SETUP.C and execute
1215 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
1216 printf("*******************************\n");
1217 printf("*** Setup PAR archive ***\n");
1218 printf("*******************************\n");
1219 gROOT->Macro("PROOF-INF/SETUP.C");
1220 }
1221 if (!gSystem->ChangeDirectory(ocwd.Data())) return -1;
1222 return 0;
1223}
1224
1225//______________________________________________________________________________
1226AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
1227{
1228// Check if user has a valid token, otherwise make one. This has limitations.
1229// One can always follow the standard procedure of calling alien-token-init then
1230 AliAnalysisAlien *plugin = new AliAnalysisAlien();
1231// Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
1232 plugin->SetRunMode(plugin_mode);
1233 if (useProductionMode) {
1234 plugin->SetProductionMode();
1235 plugin->AddDataFile(data_collection);
1236 }
1237
1238 if (!outputSingleFolder.IsNull()) {
1239 plugin->SetOutputSingleFolder(outputSingleFolder);
1240 plugin->SetOutputToRunNo();
1241 }
1242 plugin->SetJobTag(job_tag);
1243 plugin->SetNtestFiles(1);
1244 plugin->SetCheckCopy(kFALSE);
1245 plugin->SetOneStageMerging(kTRUE);
1246// Set versions of used packages
1247 plugin->SetAPIVersion("V1.1x");
1248 plugin->SetROOTVersion(root_version);
1249 plugin->SetAliROOTVersion(aliroot_version);
1250// Declare input data to be processed.
1251// Method 1: Create automatically XML collections using alien 'find' command.
1252// Define production directory LFN
1253 plugin->SetGridDataDir(alien_datadir);
1254// Set data search pattern
1255 plugin->SetDataPattern(data_pattern);
1256 if (!useProductionMode) {
1257 if (runOnData) {
1258 plugin->SetRunPrefix("000");
1259 }
1260// if (!iAODanalysis) plugin->SetRunRange(run_range[0], run_range[1]);
1261 for (Int_t i=0; i<10; i++) {
1262 if (run_numbers[i]==0) break;
1263 plugin->AddRunNumber(run_numbers[i]);
1264 }
1265 }
1266// Define alien work directory where all files will be copied. Relative to alien $HOME.
1267 plugin->SetGridWorkingDir(grid_workdir);
1268// Declare alien output directory. Relative to working directory.
1269 if (alien_outdir.IsNull()) alien_outdir = Form("output_%s",train_name.Data());
1270 plugin->SetGridOutputDir(alien_outdir);
1271
1272 TString ana_sources = "";
1273 TString ana_add = "";
1274 if (usePAR && anaPars.Length()) {
1275 printf("%s\n", anaPars.Data());
1276 TObjArray *arr;
1277 TObjString *objstr;
1278 arr = anaPars.Tokenize(" ");
1279 TIter next(arr);
1280 while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString());
1281 delete arr;
1282 }
1283// Add external packages
1284 if (iJETANdelta) {
1285 plugin->AddExternalPackage("boost::v1_38_0");
1286 plugin->AddExternalPackage("cgal::v3.3.1");
1287 plugin->AddExternalPackage("fastjet::v2.4.0");
1288 }
1289
1290// Declare the analysis source files names separated by blancs. To be compiled runtime
1291// using ACLiC on the worker nodes.
1292 ana_sources = ana_sources.Strip();
1293// Declare all libraries (other than the default ones for the framework. These will be
1294// loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
1295 anaLibs = anaLibs.Strip();
1296 if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources);
1297 if (anaLibs.Length()) plugin->SetAdditionalLibs(anaLibs);
1298
1299// Declare the output file names separated by blancs.
1300// (can be like: file.root or file.root@ALICE::Niham::File)
1301 plugin->SetDefaultOutputs();
1302 plugin->SetMergeExcludes(mergeExclude);
1303 plugin->SetMaxMergeFiles(maxMergeFiles);
1304 plugin->SetNrunsPerMaster(nRunsPerMaster);
1305// Optionally define the files to be archived.
1306// plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File");
1307
1308
1309 // Put default output files to archive
1310 TString listhists = "";
1311 TString listaods = "";
1312 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1313 TIter next(mgr->GetOutputs());
1314 AliAnalysisDataContainer *output;
1315 while ((output=(AliAnalysisDataContainer*)next())) {
1316 const char *filename = output->GetFileName();
1317 if (!(strcmp(filename, "default"))) {
1318 if (!mgr->GetOutputEventHandler()) continue;
1319 filename = mgr->GetOutputEventHandler()->GetOutputFileName();
1320 if (listaods.Length()) listaods += ",";
1321 listaods += filename;
1322 listaods += ",";
1323 listaods += "pyxsec_hists.root";
1324 } else {
1325 if (!strcmp(filename, "pyxsec_hists.root")) continue;
1326 if (listhists.Contains(filename)) continue;
1327 if (listhists.Length()) listhists += ",";
1328 listhists += filename;
1329 }
1330 }
1331 if (mgr->GetExtraFiles().Length()) {
1332 if (listaods.Length()) listaods += ",";
1333 listaods += mgr->GetExtraFiles();
1334 listaods.ReplaceAll(" ", ",");
1335 }
1336 if (listhists.Length()) listhists = Form("hist_archive.zip:%s@%s", listhists.Data(), outputStorages.Data());
1337 if (listaods.Length()) listaods = Form("aod_archive.zip:%s@%s", listaods.Data(), outputStorages.Data());
1338 if (!listhists.Length() && !listaods.Length()) {
1339 ::Fatal("AnalysisTrainNew", "No task output !");
1340 }
1341 TString outputArchive = Form("log_archive.zip:stderr@%s", outputStorages.Data());
1342 if (listaods.Length()) {
1343 outputArchive += " ";
1344 outputArchive += listaods;
1345 }
1346 if (listhists.Length()) {
1347 outputArchive += " ";
1348 outputArchive += listhists;
1349 }
1350// Set friends
1351// if (iAODanalysis && iPWG3d2h)
1352// plugin->SetFriendChainName("AliAOD.VertexingHF.root");
1353// plugin->SetOutputArchive(outputArchive);
1354// Optionally set a name for the generated analysis macro (default MyAnalysis.C)
1355 plugin->SetAnalysisMacro(Form("%s.C", train_name.Data()));
1356// Optionally set a name for the generated validation script
1357 plugin->SetValidationScript("FILTERvalidation.sh");
1358// Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
1359 plugin->SetSplitMaxInputFileNumber(nFilesPerJob);
1360// Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
1361// plugin->SetMaxInitFailed(5);
1362// Optionally modify the number of replicas
1363 plugin->SetNumberOfReplicas(4);
1364// Optionally resubmit threshold.
1365// plugin->SetMasterResubmitThreshold(90);
1366// Optionally set time to live (default 30000 sec)
1367 plugin->SetTTL(70000);
1368// Optionally set input format (default xml-single)
1369 plugin->SetInputFormat("xml-single");
1370// Optionally modify the name of the generated JDL (default analysis.jdl)
1371 plugin->SetJDLName(Form("%s.jdl", train_name.Data()));
1372// Optionally modify the executable name (default analysis.sh)
1373 plugin->SetExecutable(Form("%s.sh", train_name.Data()));
1374// Optionally modify job price (default 1)
1375 plugin->SetPrice(1);
1376// Merge via JDL
1377 plugin->SetMergeViaJDL(useMergeViaJDL);
1378// Use fastread option
1379 plugin->SetFastReadOption(useFastReadOption);
1380// UseOverwrite mode
1381 plugin->SetOverwriteMode(useOverwriteMode);
1382 plugin->SetExecutableCommand("aliroot -b -q");
1383// Optionally modify split mode (default 'se')
1384 plugin->SetSplitMode("se");
1385 return plugin;
1386}
1387
1388//______________________________________________________________________________
1389void WriteConfig()
1390{
1391// Write train configuration in a file. The file name has the format:
1392// train_[trainName]_ddMonthyyyy_time.C
1393 if (useDATE) {
1394 gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp");
1395 ifstream fdate("date.tmp");
1396 if (!fdate.is_open()) {
1397 ::Error("AnalysisTrainNew.C::Export","Could not generate file name");
1398 return;
1399 }
1400 const char date[64];
1401 fdate.getline(date,64);
1402 fdate.close();
1403 gSystem->Exec("rm date.tmp");
1404 train_name = Form("%s_%s", train_name.Data(), date);
1405 }
1406 TString cdir = gSystem->WorkingDirectory();
1407 gSystem->MakeDirectory(train_name);
1408 gSystem->ChangeDirectory(train_name);
1409 ofstream out;
1410 out.open(Form("%sConfig.C",train_name.Data()), ios::out);
1411 if (out.bad()) {
1412 ::Error("AnalysisTrainNew.C::Export", "Cannot open ConfigTrain.C for writing");
1413 return;
1414 }
1415 out << "{" << endl;
1416 out << " train_name = " << "\"" << train_name.Data() << "\";" << endl;
1417 out << " proof_cluster = " << "\"" << proof_cluster.Data() << "\";" << endl;
1418 out << " useAFPAR = " << useAFPAR << ";" << endl;
1419 if (useAFPAR)
1420 out << " AFversion = " << AFversion.Data() << ";" << endl;
1421 out << " proof_dataset = " << "\"" << proof_dataset.Data() << "\";" << endl;
1422 out << " usePLUGIN = " << usePLUGIN << ";" << endl;
1423 out << " usePAR = " << usePAR << ";" << endl;
1424 out << " useCPAR = " << useCPAR << ";" << endl;
1425 out << " root_version = " << "\"" << root_version.Data() << "\";" << endl;
1426 out << " aliroot_version = " << "\"" << aliroot_version.Data() << "\";" << endl;
1427 out << " alien_datadir = " << "\"" << alien_datadir.Data() << "\";" << endl;
1428 if (!alien_outdir.Length()) alien_outdir = Form("output_%s",train_name.Data());
1429 out << " alien_outdir = " << "\"" << alien_outdir.Data() << "\";" << endl;
1430 out << " maxMergeFiles = " << maxMergeFiles << ";" << endl;
1431 out << " mergeExclude = " << "\"" << mergeExclude.Data() << "\";" << endl;
1432 out << " nRunsPerMaster = " << nRunsPerMaster << ";" << endl;
1433 out << " nFilesPerJob = " << nFilesPerJob << ";" << endl;
1434// for (Int_t i=0; i<10; i++) {
1435// if (run_numbers[i])
1436// out << " run_numbers[" << i << "] = " << run_numbers[i] << ";" << endl;
1437// }
1438// out << " run_range[0] = " << run_range[0] << ";" << endl;
1439// out << " run_range[1] = " << run_range[1] << ";" << endl;
1440 out << " usePhysicsSelection = " << usePhysicsSelection << ";" << endl;
1441 out << " useTender = " << useTender << ";" << endl;
1442 out << " useMergeViaJDL = " << useMergeViaJDL << ";" << endl;
1443 out << " useOverwriteMode = " << useOverwriteMode << ";" << endl;
1444 out << " useFastReadOption = " << useFastReadOption << ";" << endl;
1445 out << " useDBG = " << useDBG << ";" << endl;
1446 out << " useMC = " << useMC << ";" << endl;
1447 out << " useTAGS = " << useTAGS << ";" << endl;
1448 out << " useKFILTER = " << useKFILTER << ";" << endl;
1449 out << " useTR = " << useTR << ";" << endl;
1450 out << " useCORRFW = " << useCORRFW << ";" << endl;
1451 out << " useAODTAGS = " << useAODTAGS << ";" << endl;
1452 out << " saveTrain = " << "kFALSE;" << endl << endl;
1453 out << " // Analysis modules" << endl;
1454 out << " iAODanalysis = " << iAODanalysis << ";" << endl;
1455 out << " iAODhandler = " << iAODhandler << ";" << endl;
1456 out << " iESDfilter = " << iESDfilter << ";" << endl;
1457 out << " iMUONcopyAOD = " << iMUONcopyAOD << ";" << endl;
1458 out << " iJETAN = " << iJETAN << ";" << endl;
1459 out << " iJETANdelta = " << iJETANdelta << ";" << endl;
1460 out << " iPWG4partcorr = " << iPWG4partcorr << ";" << endl;
1461 out << " iPWG4gammaconv = " << iPWG4gammaconv << ";" << endl;
1462 out << " iPWG4omega3pi = " << iPWG4omega3pi << ";" << endl;
1463 out << " iPWG3vertexing = " << iPWG3vertexing << ";" << endl;
1464 out << " iPWG3hfe = " << iPWG3hfe << ";" << endl;
1465 out << " iPWG3JPSIfilter = " << iPWG3JPSIfilter << ";" << endl;
1466 out << " iPWG3JPSI = " << iPWG3JPSI << ";" << endl;
1467 out << " iPWG3d2h = " << iPWG3d2h << ";" << endl;
1468 out << " iPWG3d0mass = " << iPWG3d0mass << ";" << endl;
1469 out << " iPWG3d0massLS = " << iPWG3d0massLS << ";" << endl;
1470 out << " iPWG3dplus = " << iPWG3dplus << ";" << endl;
1471 out << " iPWG3LSd0 = " << iPWG3LSd0 << ";" << endl;
1472 out << " iPWG3LSjpsi = " << iPWG3LSjpsi << ";" << endl;
1473 out << " iPWG3CFd0 = " << iPWG3CFd0 << ";" << endl;
1474 out << " iPWG3promptd0 = " << iPWG3promptd0 << ";" << endl;
1475 out << " iPWG3MuonTrain = " << iPWG3MuonTrain << ";" << endl;
1476 out << " iPWG2femto = " << iPWG2femto << ";" << endl;
1477 out << " iPWG2spectra = " << iPWG2spectra << ";" << endl;
1478 out << " iPWG2protons = " << iPWG2protons << ";" << endl;
1479 out << " iPWG2checkcascade = " << iPWG2checkcascade << ";" << endl;
1480 out << " iPWG2perfcascade = " << iPWG2perfcascade << ";" << endl;
1481 out << " iPWG2checkv0 = " << iPWG2checkv0 << ";" << endl;
1482 out << " iPWG2strange = " << iPWG2strange << ";" << endl;
1483 out << " iPWG2central = " << iPWG2central << ";" << endl;
1484 out << " iPWG2flow = " << iPWG2flow << ";" << endl;
1485 out << " iPWG2res = " << iPWG2res << ";" << endl;
1486 out << " iPWG2rsneff = " << iPWG2rsneff << ";" << endl;
1487 out << " iPWG2kink = " << iPWG2kink << ";" << endl;
1488 out << " iPWG2kinkESDMC = " << iPWG2kinkESDMC << ";" << endl;
1489 out << " iPWG2kinkLSKstar = " << iPWG2kinkLSKstar << ";" << endl;
1490 out << " iPWG2kinkLSL1520 = " << iPWG2kinkLSL1520 << ";" << endl;
1491 out << " iPWG2kinkLSPhi = " << iPWG2kinkLSPhi << ";" << endl;
1492 out << " iPWG2kinkKstarESD = " << iPWG2kinkKstarESD << ";" << endl;
1493 out << " iPWG2kinkKstarMC = " << iPWG2kinkKstarMC << ";" << endl;
1494 out << " iPWG2kinkL1520ESD = " << iPWG2kinkL1520ESD << ";" << endl;
1495 out << " iPWG2kinkL1520MC = " << iPWG2kinkL1520MC << ";" << endl;
1496 out << " iPWG2kinkPhiESD = " << iPWG2kinkPhiESD << ";" << endl;
1497 out << " iPWG2kinkPhiMC = " << iPWG2kinkPhiMC << ";" << endl;
1498 out << " iPWG2unicor = " << iPWG2unicor << ";" << endl;
1499 out << " iPWG2evchar = " << iPWG2evchar << ";" << endl;
1500 out << " iPWG2forward = " << iPWG2forward << ";" << endl << endl;
1501 out << "// Configuration fot the wagons" << endl;
1502 out << " configPWG2femto = \"" << configPWG2femto << "\";" << endl;
1503 out << " configPWG3d2h = \"" << configPWG3d2h << "\";" << endl;
1504 out << "}" << endl;
1505 ::Info("AnalysisTrainNew.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", train_name.Data()));
1506 gSystem->ChangeDirectory(cdir);
1507}
1508
1509//______________________________________________________________________________
1510Bool_t LoadConfig(const char *filename)
1511{
1512// Read train configuration from file
1513 if (gSystem->AccessPathName(filename)) {
1514 ::Error("AnalysisTrainNew.C::LoadConfig", "Config file name not found");
1515 return kFALSE;
1516 }
1517 gROOT->ProcessLine(Form(".x %s", filename));
1518 ::Info("AnalysisTrainNew.C::LoadConfig", "Train configuration loaded from file %s", filename);
1519 return kTRUE;
1520}