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