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