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