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