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