Updated list of files
[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 ============================================
19TString train_name = "default"; // enters file names, so no blancs or special characters
20//==============================================================================
21
22// ### Settings that make sense in PROOF only
23//==============================================================================
24TString proof_cluster = "alicecaf.cern.ch";
25Bool_t useAFPAR = kFALSE; // use AF special par file
26TString AFversion = "AF-v4-16";
7581b1bc 27// Change CAF dataset here
a42c0df6 28TString proof_dataset = "/COMMON/COMMON/LHC09a4_run8100X#/esdTree";
b160b576 29TString proof_outdir = "";
c6e7c68c 30
a42c0df6 31// ### Settings that make sense when using the Alien plugin
32//==============================================================================
33Bool_t usePLUGIN = kTRUE; // do not change
34// Usage of par files ONLY in grid mode and ONLY if the code is not available
7581b1bc 35// in the deployed AliRoot versions. Par file search path: local dir, if not there $ALICE_ROOT.
36// To refresh par files, remove the ones in the workdir, then do "make <target.par>" in
37// AliRoot.
a42c0df6 38Bool_t usePAR = kFALSE; // use par files for extra libs
39Bool_t useCPAR = kFALSE; // use par files for common libs
b160b576 40TString root_version = "v5-23-04";
e4d0b516 41TString aliroot_version = "v4-17-02";
a42c0df6 42// Change production base directory here
43TString alien_datadir = "/alice/sim/PDC_09/LHC09a4/";
44// Use up to 10 non-zero run numbers
3b1610cf 45//Int_t run_numbers[10] = {81272, 81273 , 81274, 0, 0,
46// 0, 0, 0, 0, 0};
47Int_t run_range[2] = {81270, 81275};
a42c0df6 48// ### Settings that make sense only for local analysis
49//==============================================================================
50// Change local xml dataset for local interactive analysis
51TString local_xmldataset = "";
c6e7c68c 52
a42c0df6 53// ### Other flags to steer the analysis
54//==============================================================================
55Bool_t useDBG = kTRUE; // activate debugging
56Bool_t useMC = kTRUE; // use MC info
57Bool_t useTAGS = kFALSE; // use ESD tags for selection
58Bool_t useKFILTER = kTRUE; // use Kinematics filter
59Bool_t useTR = kFALSE; // use track references
60Bool_t useCORRFW = kFALSE; // do not change
b160b576 61Bool_t useAODTAGS = kTRUE; // use AOD tags
a42c0df6 62Bool_t saveTrain = kTRUE; // save train configuration as:
b160b576 63Bool_t saveProofToAlien = kFALSE; // save proof outputs in AliEn
a42c0df6 64 // train_[trainName]_ddMonthyyyy_time.C
65// ### Analysis modules to be included. Some may not be yet fully implemented.
66//==============================================================================
67Int_t iAODanalysis = 0; // Analysis on input AOD's
68Int_t iAODhandler = 1; // Analysis produces an AOD or dAOD's
69Int_t iESDfilter = 1; // ESD to AOD filter (barrel + muon tracks)
70Int_t iMUONcopyAOD = 0; // Task that copies only muon events in a separate AOD (PWG3)
e4d0b516 71Int_t iJETAN = 1; // Jet analysis (PWG4) - needs ESD filter
a42c0df6 72Int_t iPWG4partcorr = 1; // Gamma-hadron correlations task (PWG4)
e4d0b516 73Int_t iPWG3vertexing = 1; // Vertexing HF task (PWG2)
74Int_t iPWG2femto = 1; // Femtoscopy task (PWG2)
75Int_t iPWG2spectra = 1; // Spectra PWG2 tasks (protons, cascades, V0 check, strange)
76Int_t iPWG2flow = 1; // Flow analysis task (PWG2)
7cbd7add 77Int_t iPWG2res = 0; // Resonances task (PWG2)
e4d0b516 78Int_t iPWG2kink = 1; // Kink analysis task (PWG2)
a42c0df6 79
80// Temporaries.
c6e7c68c 81TString anaPars = "";
82TString anaLibs = "";
83// Function signatures
84class AliAnalysisGrid;
85
86//______________________________________________________________________________
a42c0df6 87void AnalysisTrainNew(const char *analysis_mode="grid",
88 const char *plugin_mode="full",
89 const char *config_file="")
c6e7c68c 90{
a42c0df6 91// Main analysis train macro. If a configuration file is provided, all parameters
92// are taken from there but may be altered by CheckModuleFlags.
93 if (strlen(config_file) && !LoadConfig(config_file)) return;
c6e7c68c 94 TString smode(analysis_mode);
a42c0df6 95 smode.ToUpper();
96 if (saveTrain) WriteConfig();
c6e7c68c 97 // Check compatibility of selected modules
98 CheckModuleFlags(smode);
99
100 printf("==================================================================\n");
a42c0df6 101 printf("=========== RUNNING ANALYSIS TRAIN %s IN %s MODE ==========\n", train_name.Data(),smode.Data());
c6e7c68c 102 printf("==================================================================\n");
103 printf("= Configuring analysis train for: =\n");
104 if (iAODanalysis) printf("= AOD analysis =\n");
105 else printf("= ESD analysis =\n");
106 if (iESDfilter) printf("= ESD filter =\n");
c6e7c68c 107 if (iMUONcopyAOD) printf("= MUON copy AOD =\n");
108 if (iJETAN) printf("= Jet analysis =\n");
f0e8e44e 109 if (iPWG2spectra) printf("= PWG2 proton, checkCascade, checkV0, strange =\n");
c6e7c68c 110 if (iPWG2femto) printf("= PWG2 femtoscopy =\n");
111 if (iPWG2flow) printf("= PWG2 flow =\n");
112 if (iPWG2res) printf("= PWG2 resonances =\n");
081194a7 113 if (iPWG2kink) printf("= PWG2 kink analysis =\n");
c6e7c68c 114 if (iPWG3vertexing) printf("= PWG3 vertexing =\n");
274ff025 115 if (iPWG4partcorr) printf("= PWG4 gamma-hadron, pi0 and gamma-jet correlations =\n");
c6e7c68c 116 printf("==================================================================\n");
117 printf(":: use MC truth %d\n", (UInt_t)useMC);
099d8f33 118 printf(":: use KINE filter %d\n", (UInt_t)useKFILTER);
c6e7c68c 119 printf(":: use track refs %d\n", (UInt_t)useTR);
099d8f33 120 printf(":: use tags %d\n", (UInt_t)useTAGS);
121 printf(":: use AOD tags %d\n", (UInt_t)useAODTAGS);
c6e7c68c 122 printf(":: use debugging %d\n", (UInt_t)useDBG);
123 printf(":: use PAR files %d\n", (UInt_t)usePAR);
124 printf(":: use AliEn plugin %d\n", (UInt_t)usePLUGIN);
125
b160b576 126 //==========================================================================
c6e7c68c 127 // Connect to back-end system
128 if (!Connect(smode)) {
129 ::Error("AnalysisTrain", "Could not connect to %s back-end", analysis_mode);
130 return;
131 }
132
133 // Load common libraries and set include path
134 if (!LoadCommonLibraries(smode)) {
135 ::Error("AnalysisTrain", "Could not load common libraries");
136 return;
b160b576 137 }
c6e7c68c 138
b160b576 139 // Make the analysis manager and connect event handlers
140 AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train", "Production train");
141 if (saveProofToAlien) mgr->SetSpecialOutputLocation(proof_outdir);
142
c6e7c68c 143 // Load analysis specific libraries
144 if (!LoadAnalysisLibraries(smode)) {
145 ::Error("AnalysisTrain", "Could not load analysis libraries");
146 return;
147 }
148
c6e7c68c 149 // Create input handler (input container created automatically)
150 if (iAODanalysis) {
151 // AOD input handler
152 AliAODInputHandler *aodH = new AliAODInputHandler();
153 mgr->SetInputEventHandler(aodH);
154 } else {
155 // ESD input handler
156 AliESDInputHandler *esdHandler = new AliESDInputHandler();
099d8f33 157 if (useTAGS) esdHandler->SetReadTags();
c6e7c68c 158 mgr->SetInputEventHandler(esdHandler);
159 }
160 // Monte Carlo handler
161 if (useMC && !iAODanalysis) {
162 AliMCEventHandler* mcHandler = new AliMCEventHandler();
163 mgr->SetMCtruthEventHandler(mcHandler);
164 mcHandler->SetReadTR(useTR);
165 }
166 // AOD output container, created automatically when setting an AOD handler
167 if (iAODhandler) {
168 // AOD output handler
169 AliAODHandler* aodHandler = new AliAODHandler();
b160b576 170 aodHandler->SetOutputFileName("AliAOD.root");
c6e7c68c 171 mgr->SetOutputEventHandler(aodHandler);
b160b576 172 if (iAODanalysis) {
173 aodHandler->SetCreateNonStandardAOD();
174 if (iPWG3vertexing) aodHandler->SetOutputFileName("AliAOD.VertexingHF.root");
175 }
c6e7c68c 176 }
177 // Debugging if needed
178 if (useDBG) mgr->SetDebugLevel(3);
179
180 //==========================================================================
181 // Create the chain. In this example it is created only from ALIEN files but
182 // can be done to work in batch or grid mode as well.
183 TChain *chain = CreateChain(smode, plugin_mode);
184
185 //==========================================================================
186 // Load the tasks configuration macros for all wagons. These files are supposed now to be
187 // in the current workdir, but in AliEn they will be in the file catalog,
188 // mapped from AliRoot and pecified in the jdl input list.
189
190 // For now connection to top input container and common AOD output container
191 // is done in this macro, but in future these containers will be connected
192 // from each task configuration macro.
193
194 if (iESDfilter && !iAODanalysis) {
195 // ESD filter task configuration.
196 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C");
099d8f33 197 AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER);
c6e7c68c 198 }
199
099d8f33 200 // AOD tags
201 if (useAODTAGS) {
202 AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator");
203 mgr->AddTask(tagTask);
204 AliAnalysisDataContainer *coutTags = mgr->CreateContainer("cTag", TTree::Class(),
205 AliAnalysisManager::kOutputContainer, "AOD.tag.root");
206 mgr->ConnectInput (tagTask, 0, mgr->GetCommonInputContainer());
207 mgr->ConnectOutput(tagTask, 1, coutTags);
c6e7c68c 208 }
209
210 // Jet analysis
211 if (iJETAN) {
212 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJets.C");
274ff025 213 AliAnalysisTaskJets *taskjets = AddTaskJets("AOD", "UA1");
081194a7 214 if (!taskjets) ::Warning("AnalysisTrainNew", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED");
c6e7c68c 215 }
216
217 // Proton analysis
218 if (iPWG2spectra) {
f0e8e44e 219 // protons
c85963a0 220 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskProtons.C");
c6e7c68c 221 AliAnalysisTaskProtons *taskprotons = AddTaskProtons();
081194a7 222 if (!taskprotons) ::Warning("AnalysisTrainNew", "AliAnalysisTaskProtons cannot run for this train conditions - EXCLUDED");
f0e8e44e 223 // cascades
274ff025 224 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskCheckCascade.C");
f0e8e44e 225 AliAnalysisTaskCheckCascade *taskcheckcascade = AddTaskCheckCascade();
081194a7 226 if (!taskcheckcascade) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCheckCascade cannot run for this train conditions - EXCLUDED");
6e7f8264 227 // v0's
274ff025 228 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskCheckV0.C");
6e7f8264 229 AliAnalysisTaskCheckV0 *taskcheckV0 = AddTaskCheckV0();
081194a7 230 if (!taskcheckV0) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCheckV0 cannot run for this train conditions - EXCLUDED");
6e7f8264 231 // strangeness
274ff025 232 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskStrange.C");
6e7f8264 233 AliAnalysisTaskStrange *taskstrange = AddTaskStrange();
081194a7 234 if (!taskstrange) ::Warning("AnalysisTrainNew", "AliAnalysisTaskStrange cannot run for this train conditions - EXCLUDED");
c6e7c68c 235 }
236
081194a7 237 // Femtoscopy analysis modules
238 if (iPWG2femto) {
239 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FEMTOSCOPY/macros/AddTaskFemto.C");
240 AliAnalysisTaskFemto *taskfemto = AddTaskFemto();
241 if (!taskfemto) ::Warning("AnalysisTrainNew", "AliAnalysisTaskFemto cannot run for this train conditions - EXCLUDED");
242 }
243
244 // Kink analysis
245 if (iPWG2kink) {
246 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKink.C");
247 AliAnalysisKinkESDMC *taskkink = AddTaskKink();
248 if (!taskkink) ::Warning("AnalysisTrainNew", "AliAnalysisKinkESDMC cannot run for this train conditions - EXCLUDED");
249 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonance.C");
250 AliResonanceKinkPID *taskkinkres = AddTaskKinkResonance();
251 if (!taskkinkres) ::Warning("AnalysisTrainNew", "AliResonanceKinkPID cannot run for this train conditions - EXCLUDED");
252 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceLikeSign.C");
253 AliResonanceKinkLikeSign *taskkinklikesign = AddTaskKinkResonanceLikeSign();
254 if (!taskkinklikesign) ::Warning("AnalysisTrainNew", "AliResonanceKinkLikeSign cannot run for this train conditions - EXCLUDED");
255 }
e4d0b516 256
257 // Flow analysis
258 if (iPWG2flow) {
259 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FLOW/macros/AddTaskFlow.C");
260 Bool_t SP = kTRUE;
261 Bool_t LYZ1 = kTRUE;
262 Bool_t LYZ2 = kFALSE;
263 Bool_t LYZEP = kFALSE;
264 Bool_t GFC = kTRUE;
265 Bool_t QC = kTRUE;
266 Bool_t FQD = kTRUE;
267 Bool_t MCEP = kFALSE; //not for pp
268 Bool_t kineFromESD = kTRUE;
269 Bool_t METHODS[] = {SP,LYZ1,LYZ2,LYZEP,GFC,QC,FQD,MCEP};
270 // Analysis type can be ESD, AOD, MC, ESDMC0, ESDMC1
271 TString type = "AOD";
272 if (!iAODanalysis) type = "ESD";
273 if (useMC) {
274 type += "MC";
275 if (!kineFromESD) type += "1";
276 else type += "0";
277 }
278 // Boolean to fill/not fill the QA histograms
279 Bool_t QA = kTRUE;
280 // Boolean to use/not use weights for the Q vector
281 Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
282 AliAnalysisTaskFlowEvent* taskFE = AddTaskFlow(type,METHODS,QA,WEIGHTS);
283 if (!taskFE) ::Warning("AnalysisTrainNew", "AliAnalysisTaskFlowEvent cannot run for this train conditions - EXCLUDED");
284 }
3b1610cf 285
286 // PWG2 resonances
287 if (iPWG2res) {
288 gROOT->LoadMacro("$ALICE_ROOT/PWG2/RESONANCES/macros/AddAnalysisTaskRsn.C");
289 AddAnalysisTaskRsn("rsn.root", useMC);
290 }
e4d0b516 291
292 // PWG3 vertexing
15dac83a 293 if (iPWG3vertexing) {
294 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/AddTaskVertexingHF.C");
295 AliAnalysisTaskSEVertexingHF *taskvertexingHF = AddTaskVertexingHF();
081194a7 296 if (!taskvertexingHF) ::Warning("AnalysisTrainNew", "AliAnalysisTaskSEVertexingHF cannot run for this train conditions - EXCLUDED");
15dac83a 297 }
298
c6e7c68c 299 // PWG4 hadron correlations
300 if (iPWG4partcorr) {
099d8f33 301 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPartCorr.C");
081194a7 302 AliAnalysisTaskParticleCorrelation *taskpartcorrPHOS = AddTaskPartCorr("AOD", "PHOS");
303 if (!taskpartcorrPHOS) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation PHOS cannot run for this train conditions - EXCLUDED");
274ff025 304 AliAnalysisTaskParticleCorrelation *taskpartcorrEMCAL = AddTaskPartCorr("AOD", "EMCAL");
081194a7 305 if (!taskpartcorrEMCAL) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation EMCAL cannot run for this train conditions - EXCLUDED");
15dac83a 306 }
c6e7c68c 307 //==========================================================================
308 // FOR THE REST OF THE TASKS THE MACRO AddTaskXXX() is not yet implemented/
309 // Run the analysis
310 //
311 if (mgr->InitAnalysis()) {
312 mgr->PrintStatus();
a42c0df6 313 if (saveTrain) gSystem->ChangeDirectory(train_name);
c6e7c68c 314 StartAnalysis(smode, chain);
315 }
316}
317
318//______________________________________________________________________________
319void StartAnalysis(const char *mode, TChain *chain) {
320// Start analysis.
321 Int_t imode = -1;
322 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
323 if (!strcmp(mode, "LOCAL")) imode = 0;
324 if (!strcmp(mode, "PROOF")) imode = 1;
325 if (!strcmp(mode, "GRID")) imode = 2;
326 switch (imode) {
327 case 0:
328 if (!chain) {
a42c0df6 329 ::Error("AnalysisTrainNew.C::StartAnalysis", "Cannot create the chain");
c6e7c68c 330 return;
331 }
081194a7 332 mgr->StartAnalysis(mode, chain);
c6e7c68c 333 return;
334 case 1:
a42c0df6 335 if (!proof_dataset.Length()) {
336 ::Error("AnalysisTrainNew.C::StartAnalysis", "proof_dataset is empty");
c6e7c68c 337 return;
338 }
b160b576 339 mgr->StartAnalysis(mode, proof_dataset, 1000);
c6e7c68c 340 return;
341 case 2:
342 if (usePLUGIN) {
343 if (!mgr->GetGridHandler()) {
a42c0df6 344 ::Error("AnalysisTrainNew.C::StartAnalysis", "Grid plugin not initialized");
c6e7c68c 345 return;
346 }
347 mgr->StartAnalysis("grid");
348 } else {
349 if (!chain) {
a42c0df6 350 ::Error("AnalysisTrainNew.C::StartAnalysis", "Cannot create the chain");
c6e7c68c 351 return;
352 }
353 mgr->StartAnalysis(mode, chain);
354 }
355 return;
356 }
357}
358
359//______________________________________________________________________________
360void CheckModuleFlags(const char *mode) {
361// Checks selected modules and insure compatibility
362 Int_t imode = -1;
363 if (!strcmp(mode, "LOCAL")) imode = 0;
364 if (!strcmp(mode, "PROOF")) imode = 1;
365 if (!strcmp(mode, "GRID")) imode = 2;
366 if (imode==1) {
081194a7 367 if (!usePAR) {
a42c0df6 368 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis");
081194a7 369 usePAR = kTRUE;
370 }
274ff025 371 }
081194a7 372 if (imode != 2) {
a42c0df6 373 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode");
081194a7 374 usePLUGIN = kFALSE;
375 }
c6e7c68c 376 if (iAODanalysis) {
377 // AOD analysis
081194a7 378 if (useMC)
a42c0df6 379 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's");
c6e7c68c 380 useMC = kFALSE;
381 useTR = kFALSE;
081194a7 382 if (iESDfilter)
a42c0df6 383 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's");
c6e7c68c 384 iESDfilter = 0;
081194a7 385 if (!iAODhandler) {
386 if (iJETAN)
a42c0df6 387 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler");
081194a7 388 iJETAN = 0;
389 }
c6e7c68c 390 // Disable tasks that do not work yet on AOD data
081194a7 391 if (iPWG2kink)
a42c0df6 392 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2kink disabled in analysis on AOD's");
7cbd7add 393 iPWG2kink = 0;
c6e7c68c 394 } else {
395 // ESD analysis
396 iMUONcopyAOD = 0;
c6e7c68c 397 }
099d8f33 398 if (iJETAN) iESDfilter=1;
c6e7c68c 399 if (iESDfilter) iAODhandler=1;
15dac83a 400 if (iPWG2spectra || iPWG2flow || iPWG3vertexing) useCORRFW = kTRUE;
099d8f33 401 if (useKFILTER && !useMC) useKFILTER = kFALSE;
402 if (useAODTAGS && !iAODhandler) useAODTAGS = kFALSE;
c6e7c68c 403}
404
405//______________________________________________________________________________
406Bool_t Connect(const char *mode) {
407// Connect <username> to the back-end system.
408 Int_t imode = -1;
409 if (!strcmp(mode, "LOCAL")) imode = 0;
410 if (!strcmp(mode, "PROOF")) imode = 1;
411 if (!strcmp(mode, "GRID")) imode = 2;
412 TString username = gSystem->Getenv("alien_API_USER");
413 switch (imode) {
414 case 0:
415 break;
416 case 1:
417 if (!username.Length()) {
a42c0df6 418 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), "Make sure you:\n \
c6e7c68c 419 1. Have called: alien-token-init <username>\n \
420 2. Have called: >source /tmp/gclient_env_$UID");
421 return kFALSE;
422 }
a42c0df6 423 ::Info("AnalysisTrainNew.C::Connect", "Connecting user <%s> to PROOF cluster <%s>",
424 username.Data(), proof_cluster.Data());
b160b576 425 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
7cbd7add 426// TProof::Open(Form("%s@%s:31093", username.Data(), proof_cluster.Data()));
427 TProof::Open(Form("%s@%s", username.Data(), proof_cluster.Data()));
c6e7c68c 428 if (!gProof) {
429 if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch"))
a42c0df6 430 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch");
c6e7c68c 431 return kFALSE;
432 }
b160b576 433 TGrid::Connect("alien://");
434 if (gGrid) {
435 TString homedir = gGrid->GetHomeDirectory();
436 TString workdir = homedir + train_name;
437 if (!gGrid->Cd(workdir)) {
438 gGrid->Cd(homedir);
439 if (gGrid->Mkdir(workdir)) {
440 gGrid->Cd(train_name);
441 ::Info("AnalysisTrainNew::Connect()", "Directory %s created", gGrid->Pwd());
442 }
443 }
444 gGrid->Mkdir("proof_output");
445 gGrid->Cd("proof_output");
446 proof_outdir = Form("alien://%s", gGrid->Pwd());
447 }
c6e7c68c 448 break;
449 case 2:
450 if (!username.Length()) {
a42c0df6 451 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), "Make sure you:\n \
c6e7c68c 452 1. Have called: alien-token-init <username>\n \
453 2. Have called: >source /tmp/gclient_env_$UID");
454 return kFALSE;
455 }
456 if (usePLUGIN && !gSystem->Getenv("alien_CLOSE_SE")) {
a42c0df6 457 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode),
c6e7c68c 458 "When using the AliEn plugin it is preferable to define the \
459 variable alien_CLOSE_SE in your environment.");
460 return kFALSE;
461 }
a42c0df6 462 ::Info("AnalysisTrainNew.C::Connect", "Connecting user <%s> to AliEn ...",
c6e7c68c 463 username.Data());
464 TGrid::Connect("alien://");
465 if (!gGrid || !gGrid->IsConnected()) return kFALSE;
466 break;
467 default:
a42c0df6 468 ::Error("AnalysisTrainNew.C::Connect", "Unknown run mode: %s", mode);
c6e7c68c 469 return kFALSE;
470 }
a42c0df6 471 ::Info("AnalysisTrainNew.C::Connect","Connected in %s mode", mode);
c6e7c68c 472 return kTRUE;
473}
474
475//______________________________________________________________________________
476Bool_t LoadCommonLibraries(const char *mode)
477{
478// Load common analysis libraries.
479 Int_t imode = -1;
480 if (!strcmp(mode, "LOCAL")) imode = 0;
481 if (!strcmp(mode, "PROOF")) imode = 1;
482 if (!strcmp(mode, "GRID")) imode = 2;
483 if (!gSystem->Getenv("ALICE_ROOT")) {
a42c0df6 484 ::Error("AnalysisTrainNew.C::LoadCommonLibraries", "Analysis train requires that analysis libraries are compiled with a local AliRoot");
c6e7c68c 485 return kFALSE;
486 }
487 Bool_t success = kTRUE;
488 // ROOT libraries
489 gSystem->Load("libTree.so");
490 gSystem->Load("libGeom.so");
491 gSystem->Load("libVMC.so");
492 gSystem->Load("libPhysics.so");
493
494 // Load framework classes. Par option ignored here.
495 switch (imode) {
496 case 0:
497 case 2:
7581b1bc 498 if (useCPAR) {
499 success &= LoadLibrary("STEERBase", mode, kTRUE);
500 success &= LoadLibrary("ESD", mode, kTRUE);
501 success &= LoadLibrary("AOD", mode, kTRUE);
502 success &= LoadLibrary("ANALYSIS", mode, kTRUE);
503 success &= LoadLibrary("ANALYSISalice", mode, kTRUE);
504 if (useCORRFW) success &= LoadLibrary("CORRFW", mode, kTRUE);
505 } else {
506 success &= LoadLibrary("libSTEERBase.so", mode);
507 success &= LoadLibrary("libESD.so", mode);
508 success &= LoadLibrary("libAOD.so", mode);
509 success &= LoadLibrary("libANALYSIS.so", mode);
510 success &= LoadLibrary("libANALYSISalice.so", mode);
511 if (useCORRFW) success &= LoadLibrary("libCORRFW.so", mode);
512 gROOT->ProcessLine(".include $ALICE_ROOT/include");
513 }
c6e7c68c 514 break;
515 case 1:
516 Int_t ires = -1;
a42c0df6 517 if (useAFPAR && !gSystem->AccessPathName(AFversion)) ires = gProof->UploadPackage(AFversion);
c6e7c68c 518 if (ires < 0) {
519 success &= LoadLibrary("STEERBase", mode);
520 success &= LoadLibrary("ESD", mode);
521 success &= LoadLibrary("AOD", mode);
522 success &= LoadLibrary("ANALYSIS", mode);
523 success &= LoadLibrary("ANALYSISalice", mode);
524 if (useCORRFW) success &= LoadLibrary("CORRFW", mode);
525 } else {
526 ires = gProof->EnablePackage(AFversion);
2b142d4b 527 if (ires<0) success = kFALSE;
c6e7c68c 528 if (useCORRFW) success &= LoadLibrary("CORRFW", mode);
529 }
c6e7c68c 530 break;
531 default:
a42c0df6 532 ::Error("AnalysisTrainNew.C::LoadCommonLibraries", "Unknown run mode: %s", mode);
c6e7c68c 533 return kFALSE;
534 }
535 if (success) {
a42c0df6 536 ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Load common libraries: SUCCESS");
537 ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s",
c6e7c68c 538 gSystem->GetIncludePath());
539 } else {
a42c0df6 540 ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Load common libraries: FAILED");
c6e7c68c 541 }
542
543 return success;
544}
545
546//______________________________________________________________________________
547Bool_t LoadAnalysisLibraries(const char *mode)
548{
549// Load common analysis libraries.
550 Bool_t success = kTRUE;
099d8f33 551 if (iESDfilter) {
c6e7c68c 552 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
553 !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE;
554 }
555 // JETAN
556 if (iJETAN) {
557 if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE;
558 }
559
560 // PWG4 particle correlations
274ff025 561 if (iPWG4partcorr) {
c6e7c68c 562 if (!LoadLibrary("PWG4PartCorrBase", mode, kTRUE) ||
563 !LoadLibrary("PWG4PartCorrDep", mode, kTRUE)) return kFALSE;
c6e7c68c 564 }
565 // PWG2 task protons
566 if (iPWG2spectra) {
567 if (!LoadLibrary("PWG2spectra", mode, kTRUE)) return kFALSE;
568 }
569 // PWG2 flow
570 if (iPWG2flow) {
e4d0b516 571 if (!LoadLibrary("PWG2flowCommon", mode, kTRUE) ||
572 !LoadLibrary("PWG2flowTasks", mode, kTRUE)) return kFALSE;
c6e7c68c 573 }
574 // PWG2 resonances
575 if (iPWG2res) {
576 if (!LoadLibrary("PWG2resonances", mode, kTRUE)) return kFALSE;
577 }
081194a7 578 // PWG2 kink
579 if (iPWG2kink) {
580 if (!LoadLibrary("PWG2kink", mode, kTRUE)) return kFALSE;
581 }
c6e7c68c 582 // PWG2 femtoscopy
583 if (iPWG2femto) {
584 if (!LoadLibrary("PWG2AOD", mode, kTRUE) ||
585 !LoadLibrary("PWG2femtoscopy", mode, kTRUE) ||
586 !LoadLibrary("PWG2femtoscopyUser", mode, kTRUE)) return kFALSE;
a42c0df6 587 TFile::Cp(gSystem->ExpandPathName("$(ALICE_ROOT)/PWG2/FEMTOSCOPY/macros/ConfigFemtoAnalysis.C"), Form("%s/ConfigFemtoAnalysis.C", train_name.Data()));
588 anaLibs += "ConfigFemtoAnalysis.C ";
c6e7c68c 589 }
590 // Vertexing HF
591 if (iPWG3vertexing) {
15dac83a 592 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
593 !LoadLibrary("PWG3vertexingHF", mode, kTRUE)) return kFALSE;
c6e7c68c 594 }
a42c0df6 595 ::Info("AnalysisTrainNew.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS");
c6e7c68c 596 return kTRUE;
597}
598
599//______________________________________________________________________________
600Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE)
601{
602// Load a module library in a given mode. Reports success.
603 Int_t imode = -1;
604 Int_t result;
605 TString smodule(module);
606 if (!strcmp(mode, "LOCAL")) imode = 0;
607 if (!strcmp(mode, "PROOF")) imode = 1;
608 if (!strcmp(mode, "GRID")) imode = 2;
609 TString mod(module);
610 if (!mod.Length()) {
a42c0df6 611 ::Error("AnalysisTrainNew.C::LoadLibrary", "Empty module name");
c6e7c68c 612 return kFALSE;
613 }
614 // If a library is specified, just load it
615 if (smodule.EndsWith(".so")) {
616 mod.Remove(mod.Index(".so"));
617 result = gSystem->Load(mod);
618 if (result < 0) {
a42c0df6 619 ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not load library %s", module);
c6e7c68c 620 return kFALSE;
621 }
622 if (rec) anaLibs += Form("%s.so ",mod.Data());
623 return kTRUE;
624 }
625 // Check if the library is already loaded
626 if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0)
627 return kTRUE;
628 switch (imode) {
629 case 0:
630 case 2:
631 if (usePAR) {
632 result = SetupPar(module);
633 if (rec) anaPars += Form("%s.par ", module);
634 } else {
635 result = gSystem->Load(Form("lib%s.so", module));
636 if (rec) anaLibs += Form("lib%s.so ", module);
637 }
638 break;
639 case 1:
640 result = gProof->UploadPackage(module);
641 if (result<0) {
642 result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module)));
643 if (result<0) {
a42c0df6 644 ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module);
c6e7c68c 645 return kFALSE;
646 }
647 }
648 result = gProof->EnablePackage(module);
649 break;
650 default:
651 return kFALSE;
652 }
653 if (result < 0) {
a42c0df6 654 ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not load module %s", module);
c6e7c68c 655 return kFALSE;
656 }
657 return kTRUE;
658}
659
660
661//______________________________________________________________________________
662TChain *CreateChain(const char *mode, const char *plugin_mode)
663{
664// Create the input chain
665 Int_t imode = -1;
666 if (!strcmp(mode, "LOCAL")) imode = 0;
667 if (!strcmp(mode, "PROOF")) imode = 1;
668 if (!strcmp(mode, "GRID")) imode = 2;
669 TChain *chain = NULL;
670 // Local chain
671 switch (imode) {
672 case 0:
673 if (iAODanalysis) {
a42c0df6 674 if (!local_xmldataset.Length()) {
c6e7c68c 675 // Local AOD
676 chain = new TChain("aodTree");
274ff025 677 if (gSystem->AccessPathName("data/AliAOD.root"))
a42c0df6 678 ::Error("AnalysisTrainNew.C::CreateChain", "File: AliAOD.root not in ./data dir");
b160b576 679 else {
680 if (!saveTrain) chain->Add("data/AliAOD.root");
681 else chain->Add("../data/AliAOD.root");
682 }
c6e7c68c 683 } else {
684 // Interactive AOD
a42c0df6 685 chain = CreateChainSingle(local_xmldataset, "aodTree");
c6e7c68c 686 }
687 } else {
a42c0df6 688 if (!local_xmldataset.Length()) {
c6e7c68c 689 // Local ESD
690 chain = new TChain("esdTree");
099d8f33 691 if (gSystem->AccessPathName("data/AliESDs.root"))
a42c0df6 692 ::Error("AnalysisTrainNew.C::CreateChain", "File: AliESDs.root not in ./data dir");
b160b576 693 else {
694 if (!saveTrain) chain->Add("data/AliESDs.root");
695 else chain->Add("../data/AliESDs.root");
696 }
c6e7c68c 697 } else {
698 // Interactive ESD
a42c0df6 699 chain = CreateChainSingle(local_xmldataset, "esdTree");
c6e7c68c 700 }
701 }
702 break;
703 case 1:
704 break;
705 case 2:
706 if (usePLUGIN) {
707 AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
708 AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
709 } else {
710 TString treeName = "esdTree";
711 if (iAODanalysis) treeName = "aodTree";
712 chain = CreateChainSingle("wn.xml", treeName);
713 }
714 break;
715 default:
716 }
717 if (chain && chain->GetNtrees()) return chain;
718 return NULL;
719}
720
721//______________________________________________________________________________
722TChain* CreateChainSingle(const char* xmlfile, const char *treeName)
723{
724 printf("*******************************\n");
725 printf("*** Getting the ESD Chain ***\n");
726 printf("*******************************\n");
727 TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
728
729 if (!myCollection) {
a42c0df6 730 ::Error("AnalysisTrainNew.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
c6e7c68c 731 return NULL ;
732 }
733
734 TChain* chain = new TChain(treeName);
735 myCollection->Reset() ;
736 while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
737 chain->ls();
738 return chain;
739}
740
741//______________________________________________________________________________
742Int_t SetupPar(char* pararchivename)
743{
744 if (!pararchivename || !strlen(pararchivename)) return -1;
745 char processline[1024];
746 if (gSystem->AccessPathName(Form("%s.par", pararchivename))) {
747 if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) {
a42c0df6 748 ::Info("AnalysisTrainNew.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename);
c6e7c68c 749 TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)),
750 Form("%s.par",pararchivename));
751 } else {
a42c0df6 752 ::Error("AnalysisTrainNew.C::SetupPar", "Cannot find %s.par", pararchivename);
c6e7c68c 753 return -1;
754 }
755 }
a42c0df6 756 if (usePLUGIN && saveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, train_name.Data()));
c6e7c68c 757 gSystem->Exec(Form("tar xvzf %s.par", pararchivename));
758
759 TString ocwd = gSystem->WorkingDirectory();
760 if (!gSystem->ChangeDirectory(pararchivename)) return -1;
761
762 // check for BUILD.sh and execute
763 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
764 printf("*******************************\n");
765 printf("*** Building PAR archive ***\n");
766 printf("*******************************\n");
767 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
768 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
769 return -1;
770 }
771 }
772
773 // check for SETUP.C and execute
774 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
775 printf("*******************************\n");
776 printf("*** Setup PAR archive ***\n");
777 printf("*******************************\n");
778 gROOT->Macro("PROOF-INF/SETUP.C");
779 }
780 if (!gSystem->ChangeDirectory(ocwd.Data())) return -1;
781 return 0;
782}
783
784//______________________________________________________________________________
785AliAnalysisGrid* CreateAlienHandler(const char *plugin_mode)
786{
787// Check if user has a valid token, otherwise make one. This has limitations.
788// One can always follow the standard procedure of calling alien-token-init then
789// source /tmp/gclient_env_$UID in the current shell.
790 if (!AliAnalysisGrid::CreateToken()) return NULL;
791 AliAnalysisAlien *plugin = new AliAnalysisAlien();
792// Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
793 plugin->SetRunMode(plugin_mode);
794 plugin->SetNtestFiles(1);
a42c0df6 795 plugin->SetPreferedSE("ALICE::NIHAM::FILE");
c6e7c68c 796// Set versions of used packages
797 plugin->SetAPIVersion("V2.4");
798 plugin->SetROOTVersion(root_version);
799 plugin->SetAliROOTVersion(aliroot_version);
800// Declare input data to be processed.
801// Method 1: Create automatically XML collections using alien 'find' command.
802// Define production directory LFN
803 plugin->SetGridDataDir(alien_datadir);
804// Set data search pattern
274ff025 805 if (iAODanalysis) plugin->SetDataPattern("*AliAOD.root");
806 else plugin->SetDataPattern("*AliESDs.root");
c6e7c68c 807// ...then add run numbers to be considered
3b1610cf 808 plugin->SetRunRange(run_range[0], run_range[1]);
809// for (Int_t i=0; i<10; i++) {
810// if (run_numbers[i]==0) break;
811// plugin->AddRunNumber(run_numbers[i]);
812// }
c6e7c68c 813// Method 2: Declare existing data files (raw collections, xml collections, root file)
814// If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
815// XML collections added via this method can be combined with the first method if
816// the content is compatible (using or not tags)
817// plugin->AddDataFile("tag.xml");
818// plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
819// Define alien work directory where all files will be copied. Relative to alien $HOME.
274ff025 820 if (iAODanalysis) plugin->SetGridWorkingDir("analysisAOD");
821 else plugin->SetGridWorkingDir("analysisESD");
c6e7c68c 822// Declare alien output directory. Relative to working directory.
a42c0df6 823 plugin->SetGridOutputDir(Form("output_%s",train_name.Data())); // In this case will be $HOME/work/output
c6e7c68c 824
825 TString ana_sources = "";
826 TString ana_add = "";
827 if (usePAR && anaPars.Length()) {
7581b1bc 828 printf("%s\n", anaPars.Data());
c6e7c68c 829 TObjArray *arr;
830 TObjString *objstr;
831 arr = anaPars.Tokenize(" ");
832 TIter next(arr);
833 while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString());
834 delete arr;
835 }
836
837// Declare the analysis source files names separated by blancs. To be compiled runtime
838// using ACLiC on the worker nodes.
839 ana_sources = ana_sources.Strip();
840// Declare all libraries (other than the default ones for the framework. These will be
841// loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
842 anaLibs = anaLibs.Strip();
843 if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources);
844 if (anaLibs.Length()) plugin->SetAdditionalLibs(anaLibs);
845
846// Declare the output file names separated by blancs.
847// (can be like: file.root or file.root@ALICE::Niham::File)
848 plugin->SetDefaultOutputs();
849 plugin->SetMergeExcludes("AliAOD.root");
c6e7c68c 850// Optionally define the files to be archived.
851// plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:*.root@ALICE::NIHAM::File");
852 plugin->SetOutputArchive("log_archive.zip:stdout,stderr");
853// Optionally set a name for the generated analysis macro (default MyAnalysis.C)
a42c0df6 854 plugin->SetAnalysisMacro(Form("%s.C", train_name.Data()));
c6e7c68c 855// Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
a42c0df6 856 plugin->SetSplitMaxInputFileNumber(100);
c6e7c68c 857// Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
858// plugin->SetMaxInitFailed(5);
859// Optionally resubmit threshold.
860// plugin->SetMasterResubmitThreshold(90);
861// Optionally set time to live (default 30000 sec)
862 plugin->SetTTL(30000);
863// Optionally set input format (default xml-single)
864 plugin->SetInputFormat("xml-single");
865// Optionally modify the name of the generated JDL (default analysis.jdl)
a42c0df6 866 plugin->SetJDLName(Form("%s.jdl", train_name.Data()));
7ceeacc7 867// Optionally modify the executable name (default analysis.sh)
a42c0df6 868 plugin->SetExecutable(Form("%s.sh", train_name.Data()));
c6e7c68c 869// Optionally modify job price (default 1)
870 plugin->SetPrice(1);
871// Optionally modify split mode (default 'se')
872 plugin->SetSplitMode("se");
873 return plugin;
874}
a42c0df6 875
876//______________________________________________________________________________
877void WriteConfig()
878{
879// Write train configuration in a file. The file name has the format:
880// train_[trainName]_ddMonthyyyy_time.C
881 gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp");
882 ifstream fdate("date.tmp");
883 if (!fdate.is_open()) {
884 ::Error("AnalysisTrainNew.C::Export","Could not generate file name");
885 return;
886 }
887 const char date[64];
888 fdate.getline(date,64);
889 fdate.close();
890 gSystem->Exec("rm date.tmp");
891 train_name = Form("train_%s_%s", train_name.Data(), date);
892 TString cdir = gSystem->WorkingDirectory();
893 gSystem->MakeDirectory(train_name);
894 gSystem->ChangeDirectory(train_name);
895 ofstream out;
896 out.open("ConfigTrain.C", ios::out);
897 if (out.bad()) {
898 ::Error("AnalysisTrainNew.C::Export", "Cannot open ConfigTrain.C for writing");
899 return;
900 }
901 out << "{" << endl;
902 out << " train_name = " << "\"" << train_name.Data() << "\";" << endl;
903 out << " proof_cluster = " << "\"" << proof_cluster.Data() << "\";" << endl;
904 out << " useAFPAR = " << useAFPAR << ";" << endl;
905 if (useAFPAR)
906 out << " AFversion = " << AFversion.Data() << ";" << endl;
907 out << " proof_dataset = " << "\"" << proof_dataset.Data() << "\";" << endl;
908 out << " usePLUGIN = " << usePLUGIN << ";" << endl;
909 out << " usePAR = " << usePAR << ";" << endl;
910 out << " useCPAR = " << useCPAR << ";" << endl;
911 out << " root_version = " << "\"" << root_version.Data() << "\";" << endl;
912 out << " aliroot_version = " << "\"" << aliroot_version.Data() << "\";" << endl;
913 out << " alien_datadir = " << "\"" << alien_datadir.Data() << "\";" << endl;
3b1610cf 914// for (Int_t i=0; i<10; i++) {
915// if (run_numbers[i])
916// out << " run_numbers[" << i << "] = " << run_numbers[i] << ";" << endl;
917// }
918 out << " run_range[0] = " << run_range[0] << ";" << endl;
919 out << " run_range[1] = " << run_range[1] << ";" << endl;
a42c0df6 920 out << " useDBG = " << useDBG << ";" << endl;
921 out << " useMC = " << useMC << ";" << endl;
922 out << " useTAGS = " << useTAGS << ";" << endl;
923 out << " useKFILTER = " << useKFILTER << ";" << endl;
924 out << " useTR = " << useTR << ";" << endl;
925 out << " useCORRFW = " << useCORRFW << ";" << endl;
926 out << " useAODTAGS = " << useAODTAGS << ";" << endl;
927 out << " saveTrain = " << "kFALSE;" << endl << endl;
928 out << " // Analysis modules" << endl;
929 out << " iAODanalysis = " << iAODanalysis << ";" << endl;
930 out << " iAODhandler = " << iAODhandler << ";" << endl;
931 out << " iESDfilter = " << iESDfilter << ";" << endl;
932 out << " iMUONcopyAOD = " << iMUONcopyAOD << ";" << endl;
933 out << " iJETAN = " << iJETAN << ";" << endl;
934 out << " iPWG4partcorr = " << iPWG4partcorr << ";" << endl;
935 out << " iPWG2femto = " << iPWG2femto << ";" << endl;
936 out << " iPWG2spectra = " << iPWG2spectra << ";" << endl;
937 out << " iPWG2flow = " << iPWG2flow << ";" << endl;
938 out << " iPWG2res = " << iPWG2res << ";" << endl;
939 out << " iPWG2kink = " << iPWG2kink << ";" << endl;
940 out << "}" << endl;
941 ::Info("AnalysisTrainNew.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", train_name.Data()));
942 gSystem->ChangeDirectory(cdir);
943}
944
945//______________________________________________________________________________
946Bool_t LoadConfig(const char *filename)
947{
948// Read train configuration from file
949 if (gSystem->AccessPathName(filename)) {
950 ::Error("AnalysisTrainNew.C::LoadConfig", "Config file name not found");
951 return kFALSE;
952 }
953 gROOT->ProcessLine(Form(".x %s", filename));
954 ::Info("AnalysisTrainNew.C::LoadConfig", "Train configuration loaded from file %s", filename);
955 return kTRUE;
956}