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