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