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