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