1 //===================== ANALYSIS TRAIN =========================================
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")
9 // Local mode requires AliESds.root or AliAOD.root in ./data directory
10 // root[3] AnalysisTrainNew("local")
11 // In proof and grid modes, a token is needed and sourcing the produced environment file.
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")
18 //================== TRAIN NAME ============================================
19 TString train_name = "testTR018_LHC10a6ESD"; // *CHANGE ME* (no blancs or special characters)
20 TString job_tag = "testTR018: ESD -> histograms"; // *CHANGE ME*
21 //==============================================================================
23 // ### Settings that make sense in PROOF only
24 //==============================================================================
25 TString proof_cluster = "alicecaf.cern.ch";
26 Bool_t useAFPAR = kFALSE; // use AF special par file
27 TString AFversion = "AF-v4-17";
28 // Change CAF dataset here
29 TString proof_dataset = "/COMMON/COMMON/LHC09a4_run8100X#/esdTree";
30 TString proof_outdir = "";
32 // ### Settings that make sense when using the Alien plugin
33 //==============================================================================
34 Int_t runOnData = 0; // Set to 1 if processing real data
35 Int_t iCollision = 0; // 0=pp, 1=Pb-Pb
36 Bool_t usePLUGIN = kTRUE; // do not change
37 Bool_t useProductionMode = kFALSE; // use the plugin in production mode
38 // Usage of par files ONLY in grid mode and ONLY if the code is not available
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
42 Bool_t usePAR = kFALSE; // use par files for extra libs
43 Bool_t useCPAR = kFALSE; // use par files for common libs
44 TString root_version = "v5-26-00b"; // *CHANGE ME IF MORE RECENT IN GRID*
45 TString aliroot_version = "v4-19-06-AN"; // *CHANGE ME IF MORE RECENT IN GRID*
46 // Change production base directory here
47 TString alien_datadir = "/alice/sim/LHC10a13";
48 // AliEn output directory. If blank will become output_<train_name>
49 //TString alien_outdir = "/alice/sim/LHC10a6/analysis/ESD/TR016";
50 TString alien_outdir = "";
51 // Output folder to write delta AOD's. Considered if not null.
52 TString outputSingleFolder = "";
53 //TString outputSingleFolder = "deltas";
54 // Number of files merged in a chunk
55 Int_t maxMergeFiles = 20;
56 // Files that should not be merged
57 TString mergeExclude = "AliAOD.root AliAOD.VertexingHF.root AliAOD.Jets.root deltaAODPartCorr.root AliAOD.Muons.root resonances.root forward.root";
58 // Make replicas on the storages below
59 TString outputStorages = "disk=4";
60 // Number of runs per master job
61 Int_t nRunsPerMaster = 10;
62 // Maximum number of files per job (gives size of AOD)
63 Int_t nFilesPerJob = 10;
64 // Int_t nFilesPerJob = 1; (AOD->delta AOD production case)
66 Int_t run_range[2] = {104824, 104825}; // *CHANGE ME*
67 // ### Settings that make sense only for local analysis
68 //==============================================================================
69 // Change local xml dataset for local interactive analysis
70 TString local_xmldataset = "";
72 // ### Other flags to steer the analysis
73 //==============================================================================
74 Bool_t useDATE = kFALSE; // use date in train name
75 Bool_t useDBG = kTRUE; // activate debugging
76 Bool_t useMC = kTRUE; // use MC info
77 Bool_t useTAGS = kTRUE; // use ESD tags for selection
78 Bool_t useKFILTER = kTRUE; // use Kinematics filter
79 Bool_t useTR = kTRUE; // use track references
80 Bool_t useCORRFW = kFALSE; // do not change
81 Bool_t useAODTAGS = kFALSE; // use AOD tags
82 Bool_t saveTrain = kTRUE; // save train configuration as:
83 Bool_t saveCanvases = kTRUE; // save canvases created in Terminate
84 Bool_t saveProofToAlien = kFALSE; // save proof outputs in AliEn
85 // train_[trainName]_ddMonthyyyy_time.C
86 // ### Analysis modules to be included. Some may not be yet fully implemented.
87 //==============================================================================
88 Int_t iAODanalysis = 0; // Analysis on input AOD's
89 Int_t iAODhandler = 1; // Analysis produces an AOD or dAOD's
90 Int_t iESDfilter = 1; // ESD to AOD filter (barrel + muon tracks)
91 Int_t iMUONcopyAOD = 1; // Task that copies only muon events in a separate AOD (PWG3)
92 Int_t iJETAN = 1; // Jet analysis (PWG4)
93 Int_t iJETANdelta = 1; // Jet delta AODs
94 Int_t iPWG4partcorr = 1; // Gamma-hadron correlations task (PWG4)
95 Int_t iPWG4gammaconv = 1; // Gamma conversion analysis (PWG4)
96 Int_t iPWG4omega3pi = 1; // Omega to 3 pi analysis (PWG4)
97 Int_t iPWG3vertexing = 1; // Vertexing HF task (PWG3)
98 Int_t iPWG3hfe = 1; // Electrons analysis (PWG3)
99 Int_t iPWG3d2h = 1; // D0->2 hadrons (PWG3)
100 Int_t iPWG3d0mass = 1; // D0 mass (PWG3D2H)
101 Int_t iPWG3d0massLS = 1; // D0 mass LS (PWG3D2H)
102 Int_t iPWG3dplus = 1; // D+ analysis (PWG3D2H)
103 Int_t iPWG3LSd0 = 1; // LS D0 analysis (PWG3D2H)
104 Int_t iPWG3LSjpsi = 1; // LS J/Psi analysis (PWG3D2H)
105 Int_t iPWG3CFd0 = 1; // CF D0 analysis (PWG3D2H)
106 Int_t iPWG3promptd0 = 1; // prompt D0 analysis (PWG3D2H)
107 Int_t iPWG3MuonTrain = 1; // Muon analysis train
108 Int_t iPWG2femto = 1; // Femtoscopy task (PWG2)
109 Int_t iPWG2spectra = 1; // Spectra tasks (PWG2
110 Int_t iPWG2protons = 1; // Proton-antiproton analysis
111 Int_t iPWG2checkcascade = 1; // Check cascades task
112 Int_t iPWG2perfcascade = 1; // Check performance cascade
113 Int_t iPWG2checkv0 = 1; // Check V0 task
114 Int_t iPWG2strange = 1; // Strangeness task
115 Int_t iPWG2central = 1; // Anisothropy in central collisions
116 Int_t iPWG2flow = 1; // Flow analysis tasks (PWG2)
117 Int_t iPWG2res = 1; // Resonances task (PWG2)
118 Int_t iPWG2rsneff = 1; // Resonances efficiency
119 Int_t iPWG2kink = 1; // Kink analysis tasks (PWG2)
120 Int_t iPWG2kinkESDMC = 1; // Kink ESD-MC comparison (PWG2)
121 Int_t iPWG2kinkLSKstar = 1; // Kink like-sign K* (PWG2)
122 Int_t iPWG2kinkLSL1520 = 1; // Kink like-sign L1520 (PWG2)
123 Int_t iPWG2kinkLSPhi = 1; // Kink like-sign Phi (PWG2)
124 Int_t iPWG2kinkKstarESD = 1; // Kink Kstar ESD (PWG2)
125 Int_t iPWG2kinkKstarMC = 1; // Kink Kstar MC (PWG2)
126 Int_t iPWG2kinkL1520ESD = 1; // Kink L1520 ESD (PWG2)
127 Int_t iPWG2kinkL1520MC = 1; // Kink L1520 MC (PWG2)
128 Int_t iPWG2kinkPhiESD = 1; // Kink resonances Phi ESD (PWG2)
129 Int_t iPWG2kinkPhiMC = 1; // Kink resonances Phi MC (PWG2)
130 Int_t iPWG2evchar = 1; // Event characteristics (PWG2)
131 Int_t iPWG2unicor = 1; // Unicor analysis (PWG2)
132 Int_t iPWG2forward = 1; // FMD analysis (PWG2)
134 // ### Configuration macros used for each module
135 //==============================================================================
136 //TString configPWG2femto = "$ALICE_ROOT/PWG2/FEMTOSCOPY/macros/Train/Train3/ConfigFemtoAnalysis.C";
137 TString configPWG2femto = "$ALICE_ROOT/PWG2/FEMTOSCOPY/macros/Train/PWG2TrainLHC10a6/ConfigFemtoAnalysis.C";
138 //TString configPWG3d2h = "$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF_highmult.C";
139 TString configPWG3d2h = "$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C";
141 TString anaPars = "";
142 TString anaLibs = "";
143 // Function signatures
144 class AliAnalysisAlien;
146 //______________________________________________________________________________
147 void AnalysisTrainNew(const char *analysis_mode="grid",
148 const char *plugin_mode="full",
149 const char *config_file="")
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;
154 TString smode(analysis_mode);
156 // Check compatibility of selected modules
157 CheckModuleFlags(smode);
158 if (saveTrain) WriteConfig();
160 printf("==================================================================\n");
161 printf("=========== RUNNING ANALYSIS TRAIN %s IN %s MODE ==========\n", train_name.Data(),smode.Data());
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");
167 if (iMUONcopyAOD) printf("= MUON copy AOD =\n");
168 if (iJETAN) printf("= Jet analysis =\n");
169 if (iJETANdelta) printf("= Jet delta AODs =\n");
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");
177 if (iPWG2central) printf("= PWG2 central =\n");
180 printf("= PWG2 femtoscopy =\n");
181 printf(" +++ configured by: %s\n", configPWG2femto.Data());
183 if (iPWG2flow) printf("= PWG2 flow =\n");
184 if (iPWG2res) printf("= PWG2 resonances =\n");
185 if (iPWG2rsneff) printf("= PWG2 resonances efficiency =\n");
187 printf("= PWG2 kink analysis tasks: =\n");
188 if (iPWG2kinkESDMC) printf("= PWG2 ESD-MC kinks =\n");
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");
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");
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");
205 printf("= PWG3 D0->2 hadrons tasks =\n");
206 printf(" +++ configured by: %s\n", configPWG3d2h.Data());
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");
215 if (iPWG3MuonTrain) printf("= PWG3 muon train =\n");
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");
219 printf("==================================================================\n");
220 printf(":: use MC truth %d\n", (UInt_t)useMC);
221 printf(":: use KINE filter %d\n", (UInt_t)useKFILTER);
222 printf(":: use track refs %d\n", (UInt_t)useTR);
223 printf(":: use tags %d\n", (UInt_t)useTAGS);
224 printf(":: use AOD tags %d\n", (UInt_t)useAODTAGS);
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);
229 //==========================================================================
230 // Connect to back-end system
231 if (!Connect(smode)) {
232 ::Error("AnalysisTrain", "Could not connect to %s back-end", analysis_mode);
236 // Load common libraries and set include path
237 if (!LoadCommonLibraries(smode)) {
238 ::Error("AnalysisTrain", "Could not load common libraries");
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);
245 if (!strcmp(plugin_mode, "test")) mgr->SetNSysInfo(1);
246 // Load analysis specific libraries
247 if (!LoadAnalysisLibraries(smode)) {
248 ::Error("AnalysisTrain", "Could not load analysis libraries");
252 // Create input handler (input container created automatically)
255 AliAODInputHandler *aodH = new AliAODInputHandler();
256 if (iPWG3d2h) aodH->AddFriend("AliAOD.VertexingHF.root");
257 mgr->SetInputEventHandler(aodH);
260 AliESDInputHandler *esdHandler = new AliESDInputHandler();
261 if (useTAGS) esdHandler->SetReadTags();
262 mgr->SetInputEventHandler(esdHandler);
264 // Monte Carlo handler
265 if (useMC && !iAODanalysis) {
266 AliMCEventHandler* mcHandler = new AliMCEventHandler();
267 mgr->SetMCtruthEventHandler(mcHandler);
268 mcHandler->SetReadTR(useTR);
270 // AOD output container, created automatically when setting an AOD handler
272 // AOD output handler
273 AliAODHandler* aodHandler = new AliAODHandler();
274 aodHandler->SetOutputFileName("AliAOD.root");
275 mgr->SetOutputEventHandler(aodHandler);
277 aodHandler->SetFillAOD(kFALSE);
278 aodHandler->SetCreateNonStandardAOD();
279 aodHandler->SetOutputFileName("");
280 if (iJETAN) aodHandler->SetOutputFileName("AliAOD.Jets.root");
281 // if (iPWG3vertexing) aodHandler->SetOutputFileName("AliAOD.VertexingHF.root");
284 // Debugging if needed
285 if (useDBG) mgr->SetDebugLevel(2);
286 if (saveCanvases) mgr->SetSaveCanvases(kTRUE);
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);
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.
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.
307 AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
308 AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
311 if (mgr->InitAnalysis()) {
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()));
331 //______________________________________________________________________________
332 void AddAnalysisTasks()
334 // Add all analysis task wagons to the train
335 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
337 if (iESDfilter && !iAODanalysis) {
338 // ESD filter task configuration.
339 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C");
341 printf("Registering delta AOD file\n");
342 mgr->RegisterExtraFile("AliAOD.Muons.root");
343 AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER, kTRUE);
345 AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(useKFILTER, kFALSE);
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);
359 // ********** PWG2 wagons ******************************************************
360 AliAnalysisManager::SetCommonFileName("PWG2histograms.root");
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");
371 if (iPWG2checkcascade) {
372 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskCheckCascade.C");
373 AliAnalysisTaskCheckCascade *taskcheckcascade = AddTaskCheckCascade(iCollision);
374 if (!taskcheckcascade) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCheckCascade cannot run for this train conditions - EXCLUDED");
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");
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");
388 // performance cascades
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");
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");
402 // Femtoscopy analysis modules
404 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FEMTOSCOPY/macros/AddTaskFemto.C");
405 AliAnalysisTaskFemto *taskfemto = AddTaskFemto(configPWG2femto);
406 if (!taskfemto) ::Warning("AnalysisTrainNew", "AliAnalysisTaskFemto cannot run for this train conditions - EXCLUDED");
411 if (iPWG2kinkESDMC) {
412 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKink.C");
413 AliAnalysisKinkESDMC *taskkink1 = AddTaskKink();
414 if (!taskkink1) ::Warning("AnalysisTrainNew", "AliAnalysisKinkESDMC cannot run for this train conditions - EXCLUDED");
416 if (iPWG2kinkLSKstar) {
417 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResLikeSignKstar.C");
418 AliResonanceKinkLikeSign *taskkink2 = AddTaskKinkResLikeSignKstar();
419 if (!taskkink2) ::Warning("AnalysisTrainNew", "AliResonanceKinkLikeSign cannot run for this train conditions - EXCLUDED");
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");
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");
431 if (iPWG2kinkKstarESD) {
432 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceKstarESD.C");
433 AliAnalysisTaskKinkResonance *taskkink5 = AddTaskKinkResonanceKstarESD();
434 if (!taskkink5) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonanceKstarESD cannot run for this train conditions - EXCLUDED");
436 if (iPWG2kinkKstarMC) {
437 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceKstarMC.C");
438 AliAnalysisTaskKinkResonance *taskkink6 = AddTaskKinkResonanceKstarMC();
439 if (!taskkink6) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonanceKstarMC cannot run for this train conditions - EXCLUDED");
441 if (iPWG2kinkL1520ESD) {
442 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceL1520ESD.C");
443 AliAnalysisTaskKinkResonance *taskkink7 = AddTaskKinkResonanceL1520ESD();
444 if (!taskkink7) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonanceL1520ESD cannot run for this train conditions - EXCLUDED");
446 if (iPWG2kinkL1520MC) {
447 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonanceL1520MC.C");
448 AliAnalysisTaskKinkResonance *taskkink8 = AddTaskKinkResonanceL1520MC();
449 if (!taskkink8) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonanceL1520MC cannot run for this train conditions - EXCLUDED");
451 if (iPWG2kinkPhiESD) {
452 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonancePhiESD.C");
453 AliAnalysisTaskKinkResonance *taskkink9 = AddTaskKinkResonancePhiESD();
454 if (!taskkink9) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonancePhiESD cannot run for this train conditions - EXCLUDED");
456 if (iPWG2kinkPhiMC) {
457 gROOT->LoadMacro("$ALICE_ROOT/PWG2/KINK/macros/AddTaskKinkResonancePhiMC.C");
458 AliAnalysisTaskKinkResonance *taskkink10 = AddTaskKinkResonancePhiMC();
459 if (!taskkink10) ::Warning("AnalysisTrainNew", "AliAnalysisKinkResonancePhiMC cannot run for this train conditions - EXCLUDED");
463 // Event characterization
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);
473 gROOT->LoadMacro("$ALICE_ROOT/PWG2/UNICOR/AddTaskUnicor.C");
474 AliAnalysisTaskUnicor *taskunicor = AddTaskUnicor();
475 if (!taskunicor) ::Warning("AnalysisTrainNew", "AliAnalysisTaskUnicor cannot run for this train conditions - EXCLUDED");
479 AliAnalysisManager::SetCommonFileName("forward.root");
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");
485 AliAnalysisManager::SetCommonFileName("PWG2histograms.root");
489 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FLOW/macros/AddTaskFlow.C");
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;
499 Bool_t MCEP = kFALSE; //does not work yet 24/12/08
500 Bool_t kineFromESD = kTRUE;
501 Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP};
502 // Analysis type can be ESD, AOD, MC, ESDMC0, ESDMC1
503 TString type = "AOD";
504 if (!iAODanalysis) type = "ESD";
505 // Boolean to fill/not fill the QA histograms
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");
514 AliAnalysisManager::SetCommonFileName("resonances.root");
516 gROOT->LoadMacro("$ALICE_ROOT/PWG2/RESONANCES/macros/train/AddAnalysisTaskRsnNew.C");
517 gROOT->LoadMacro("$ALICE_ROOT/PWG2/RESONANCES/macros/train/AddAnalysisTaskRsnEffNew.C");
518 TString path = gROOT->GetMacroPath();
519 path += ":$ALICE_ROOT/PWG2/RESONANCES/macros/train";
520 gROOT->SetMacroPath(path);
521 AddAnalysisTaskRsnNew();
522 if (iPWG2rsneff) AddAnalysisTaskRsnEffNew();
524 AliAnalysisManager::SetCommonFileName("PWG2histograms.root");
526 // ********** PWG3 wagons ******************************************************
527 AliAnalysisManager::SetCommonFileName("PWG3histograms.root");
530 if (iPWG3vertexing) {
531 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/AddTaskVertexingHF.C");
532 if (!iPWG3d2h) TFile::Cp(gSystem->ExpandPathName(configPWG3d2h.Data()), Form("%s/ConfigVertexingHF.C", train_name.Data()));
533 AliAnalysisTaskSEVertexingHF *taskvertexingHF = AddTaskVertexingHF();
534 if (!taskvertexingHF) ::Warning("AnalysisTrainNew", "AliAnalysisTaskSEVertexingHF cannot run for this train conditions - EXCLUDED");
535 else mgr->RegisterExtraFile("AliAOD.VertexingHF.root");
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");
547 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/AddD2HTrain.C");
548 TFile::Cp(gSystem->ExpandPathName(configPWG3d2h.Data()), Form("%s/ConfigVertexingHF.C", train_name.Data()));
549 AddD2HTrain(kTRUE, iPWG3d0mass,iPWG3d0massLS,iPWG3dplus, iPWG3LSd0, iPWG3LSjpsi, iPWG3CFd0, iPWG3promptd0);
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
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;
562 Int_t ntaskmuon = AddPWG3MuonTrain(isESDAnalysis,isAODAnalysis,addMuonDistributions,addSingleMuonAnalysis,addMuonHFAnalysis);
563 printf("Added %d muon tasks\n", ntaskmuon);
566 // ********** PWG4 wagons ******************************************************
567 AliAnalysisManager::SetCommonFileName("PWG4histograms.root");
571 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJets.C");
573 // Default jet reconstructor running on ESD's
574 AliAnalysisTaskJets * taskjets = AddTaskJets();
575 if (!taskjets) ::Warning("AnalysisTrainNew", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED");
577 AddTaskJetsDelta("AliAOD.Jets.root");
578 mgr->RegisterExtraFile("AliAOD.Jets.root");
581 // AOD-based analysis. Add all reconstructors to write into delta AOD's
583 Int_t ntasksjets = AddTaskJetsDelta("AliAOD.Jets.root");
584 if (ntasksjets) printf("Added %d jet reconstructors\n", ntasksjets);
588 // PWG4 hadron correlations
590 Bool_t isSimulation = (runOnData)?kFALSE:kTRUE;
591 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPartCorr.C");
592 AliAnalysisTaskParticleCorrelation *taskpartcorrPHOS = AddTaskPartCorr("AOD", "PHOS", kFALSE, isSimulation);
593 if (!taskpartcorrPHOS) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation PHOS cannot run for this train conditions - EXCLUDED");
594 AliAnalysisTaskParticleCorrelation *taskpartcorrEMCAL = AddTaskPartCorr("AOD", "EMCAL", kFALSE, isSimulation);
595 if (!taskpartcorrEMCAL) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation EMCAL cannot run for this train conditions - EXCLUDED");
596 mgr->RegisterExtraFile("deltaAODPartCorr.root");
599 // PWG4 gamma conversion analysis
600 if (iPWG4gammaconv) {
601 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskGammaConversion.C");
602 TString cdir = gSystem->WorkingDirectory();
603 gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/"));
604 TString gcArguments = "-run-on-train -run-jet -run-chic -run-neutralmeson -run-cf";
605 AliAnalysisTaskGammaConversion * taskGammaConversion = AddTaskGammaConversion(gcArguments,mgr->GetCommonInputContainer());
606 gSystem->ChangeDirectory(cdir);
607 if (!taskGammaConversion) ::Warning("AnalysisTrainNew", "AliAnalysisTaskGammaConversion cannot run for these train conditions - EXCLUDED");
610 // PWG4 omega to 3 pions analysis
612 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskomega3pi.C");
613 AliAnalysisTaskOmegaPi0PiPi *taskomega3pi = AddTaskomega3pi();
614 if (!taskomega3pi) ::Warning("AnalysisTrainNew", "AliAnalysisTaskomega3pi cannot run for these train conditions - EXCLUDED");
618 //______________________________________________________________________________
619 void StartAnalysis(const char *mode, TChain *chain) {
622 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
623 if (!strcmp(mode, "LOCAL")) imode = 0;
624 if (!strcmp(mode, "PROOF")) imode = 1;
625 if (!strcmp(mode, "GRID")) imode = 2;
629 ::Error("AnalysisTrainNew.C::StartAnalysis", "Cannot create the chain");
632 mgr->StartAnalysis(mode, chain);
635 if (!proof_dataset.Length()) {
636 ::Error("AnalysisTrainNew.C::StartAnalysis", "proof_dataset is empty");
639 mgr->StartAnalysis(mode, proof_dataset, 1000);
643 if (!mgr->GetGridHandler()) {
644 ::Error("AnalysisTrainNew.C::StartAnalysis", "Grid plugin not initialized");
647 mgr->StartAnalysis("grid");
650 ::Error("AnalysisTrainNew.C::StartAnalysis", "Cannot create the chain");
653 mgr->StartAnalysis(mode, chain);
659 //______________________________________________________________________________
660 void CheckModuleFlags(const char *mode) {
661 // Checks selected modules and insure compatibility
663 if (!strcmp(mode, "LOCAL")) imode = 0;
664 if (!strcmp(mode, "PROOF")) imode = 1;
665 if (!strcmp(mode, "GRID")) imode = 2;
666 if (!iJETAN) iJETANdelta = 0;
669 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis");
674 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode");
680 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's");
682 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "AOD tags usage disabled in analysis on AOD's");
687 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's");
691 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler");
695 // Disable tasks that do not work yet on AOD data
697 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4gammaconv disabled on AOD's without AOD handler");
700 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2central disabled on AOD's");
703 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2flow disabled on AOD's");
706 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2femto disabled on AOD's");
709 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2res disabled on AOD's");
712 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2rsneff disabled on AOD's");
715 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2kink disabled in analysis on AOD's");
718 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2unicor disabled in analysis on AOD's");
721 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4evchar disabled on AOD's");
724 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2forward disabled in analysis on AOD's");
727 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG3hfe disabled on AOD's");
730 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4omega3pi disabled on AOD's");
734 if (!useMC) useTR = kFALSE;
736 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "iPWG2evchar disabled if not reading track references");
740 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "iPWG3d2h disabled on ESD analysis without AOD handler");
745 if (iPWG2perfcascade)
746 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2perfcascade disabled without MC info");
747 iPWG2perfcascade = 0;
749 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2central disabled without MC info");
752 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG2rsneff disabled without MC info");
755 if (iJETAN && !iAODanalysis) iESDfilter=1;
756 if (iESDfilter) {iAODhandler=1; useCORRFW = kTRUE;}
757 if (iPWG2spectra || iPWG2flow || iPWG3vertexing || iPWG3hfe || iPWG2res || iPWG2rsneff) useCORRFW = kTRUE;
758 if (useKFILTER && !useMC) useKFILTER = kFALSE;
759 if (useAODTAGS && !iAODhandler) useAODTAGS = kFALSE;
762 //______________________________________________________________________________
763 Bool_t Connect(const char *mode) {
764 // Connect <username> to the back-end system.
766 if (!strcmp(mode, "LOCAL")) imode = 0;
767 if (!strcmp(mode, "PROOF")) imode = 1;
768 if (!strcmp(mode, "GRID")) imode = 2;
769 TString username = gSystem->Getenv("alien_API_USER");
774 if (!username.Length()) {
775 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), "Make sure you:\n \
776 1. Have called: alien-token-init <username>\n \
777 2. Have called: >source /tmp/gclient_env_$UID");
780 ::Info("AnalysisTrainNew.C::Connect", "Connecting user <%s> to PROOF cluster <%s>",
781 username.Data(), proof_cluster.Data());
782 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
783 // TProof::Open(Form("%s@%s:31093", username.Data(), proof_cluster.Data()));
784 TProof::Open(Form("%s@%s", username.Data(), proof_cluster.Data()));
786 if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch"))
787 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch");
790 TGrid::Connect("alien://");
792 TString homedir = gGrid->GetHomeDirectory();
793 TString workdir = homedir + train_name;
794 if (!gGrid->Cd(workdir)) {
796 if (gGrid->Mkdir(workdir)) {
797 gGrid->Cd(train_name);
798 ::Info("AnalysisTrainNew::Connect()", "Directory %s created", gGrid->Pwd());
801 gGrid->Mkdir("proof_output");
802 gGrid->Cd("proof_output");
803 proof_outdir = Form("alien://%s", gGrid->Pwd());
807 if (!username.Length()) {
808 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), "Make sure you:\n \
809 1. Have called: alien-token-init <username>\n \
810 2. Have called: >source /tmp/gclient_env_$UID");
813 if (usePLUGIN && !gSystem->Getenv("alien_CLOSE_SE")) {
814 ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode),
815 "When using the AliEn plugin it is preferable to define the \
816 variable alien_CLOSE_SE in your environment.");
819 ::Info("AnalysisTrainNew.C::Connect", "Connecting user <%s> to AliEn ...",
821 TGrid::Connect("alien://");
822 if (!gGrid || !gGrid->IsConnected()) return kFALSE;
825 ::Error("AnalysisTrainNew.C::Connect", "Unknown run mode: %s", mode);
828 ::Info("AnalysisTrainNew.C::Connect","Connected in %s mode", mode);
832 //______________________________________________________________________________
833 Bool_t LoadCommonLibraries(const char *mode)
835 // Load common analysis libraries.
837 if (!strcmp(mode, "LOCAL")) imode = 0;
838 if (!strcmp(mode, "PROOF")) imode = 1;
839 if (!strcmp(mode, "GRID")) imode = 2;
840 if (!gSystem->Getenv("ALICE_ROOT")) {
841 ::Error("AnalysisTrainNew.C::LoadCommonLibraries", "Analysis train requires that analysis libraries are compiled with a local AliRoot");
844 Bool_t success = kTRUE;
846 gSystem->Load("libTree.so");
847 gSystem->Load("libGeom.so");
848 gSystem->Load("libVMC.so");
849 gSystem->Load("libPhysics.so");
850 gSystem->Load("libMinuit.so");
852 // Load framework classes. Par option ignored here.
857 success &= LoadLibrary("STEERBase", mode, kTRUE);
858 success &= LoadLibrary("ESD", mode, kTRUE);
859 success &= LoadLibrary("AOD", mode, kTRUE);
860 success &= LoadLibrary("ANALYSIS", mode, kTRUE);
861 success &= LoadLibrary("ANALYSISalice", mode, kTRUE);
862 if (useCORRFW) success &= LoadLibrary("CORRFW", mode, kTRUE);
864 success &= LoadLibrary("libSTEERBase.so", mode);
865 success &= LoadLibrary("libESD.so", mode);
866 success &= LoadLibrary("libAOD.so", mode);
867 success &= LoadLibrary("libANALYSIS.so", mode);
868 success &= LoadLibrary("libANALYSISalice.so", mode);
869 if (useCORRFW) success &= LoadLibrary("libCORRFW.so", mode);
870 gROOT->ProcessLine(".include $ALICE_ROOT/include");
875 if (useAFPAR && !gSystem->AccessPathName(AFversion)) ires = gProof->UploadPackage(AFversion);
877 success &= LoadLibrary("STEERBase", mode);
878 success &= LoadLibrary("ESD", mode);
879 success &= LoadLibrary("AOD", mode);
880 success &= LoadLibrary("ANALYSIS", mode);
881 success &= LoadLibrary("ANALYSISalice", mode);
882 if (useCORRFW) success &= LoadLibrary("CORRFW", mode);
884 ires = gProof->EnablePackage(AFversion);
885 if (ires<0) success = kFALSE;
886 if (useCORRFW) success &= LoadLibrary("CORRFW", mode);
890 ::Error("AnalysisTrainNew.C::LoadCommonLibraries", "Unknown run mode: %s", mode);
894 ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Load common libraries: SUCCESS");
895 ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s",
896 gSystem->GetIncludePath());
898 ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Load common libraries: FAILED");
904 //______________________________________________________________________________
905 Bool_t LoadAnalysisLibraries(const char *mode)
907 // Load common analysis libraries.
908 Bool_t success = kTRUE;
909 if (iESDfilter || iPWG3MuonTrain) {
910 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
911 !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE;
915 if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE;
918 if (!LoadLibrary("JETAN", mode, kTRUE) ||
919 !LoadLibrary("CGAL", mode, kTRUE) ||
920 !LoadLibrary("fastjet", mode, kTRUE) ||
921 !LoadLibrary("siscone", mode, kTRUE) ||
922 !LoadLibrary("SISConePlugin", mode, kTRUE) ||
923 !LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE;
925 // PWG4 particle correlations
927 if (!LoadLibrary("EMCALUtils", mode, kTRUE) ||
928 !LoadLibrary("PHOSUtils", mode, kTRUE) ||
929 !LoadLibrary("PWG4PartCorrBase", mode, kTRUE) ||
930 !LoadLibrary("PWG4PartCorrDep", mode, kTRUE)) return kFALSE;
932 // PWG4 gamma conversion
933 if (iPWG4gammaconv) {
934 if (!LoadLibrary("PWG4GammaConv", mode, kTRUE)) return kFALSE;
936 // PWG4 omega to 3 pions
938 if (!LoadLibrary("PWG4omega3pi", mode, kTRUE)) return kFALSE;
942 if (!LoadLibrary("PWG2spectra", mode, kTRUE)) return kFALSE;
946 if (!LoadLibrary("PWG2flowCommon", mode, kTRUE) ||
947 !LoadLibrary("PWG2flowTasks", mode, kTRUE)) return kFALSE;
950 if (iPWG2res || iPWG2rsneff) {
951 if (!LoadLibrary("PWG2resonances", mode, kTRUE)) return kFALSE;
955 if (!LoadLibrary("PWG2kink", mode, kTRUE)) return kFALSE;
959 if (!LoadLibrary("PWG2unicor", mode, kTRUE)) return kFALSE;
963 if (!LoadLibrary("PWG2evchar", mode, kTRUE)) return kFALSE;
967 if (!LoadLibrary("PWG2AOD", mode, kTRUE) ||
968 !LoadLibrary("PWG2femtoscopy", mode, kTRUE) ||
969 !LoadLibrary("PWG2femtoscopyUser", mode, kTRUE)) return kFALSE;
970 // TFile::Cp(gSystem->ExpandPathName("$(ALICE_ROOT)/PWG2/FEMTOSCOPY/macros/ConfigFemtoAnalysis.C"), Form("%s/ConfigFemtoAnalysis.C", train_name.Data()));
971 // anaLibs += "ConfigFemtoAnalysis.C ";
975 if (!LoadLibrary("PWG2forward", mode, kTRUE)) return kFALSE;
978 if (iPWG3vertexing || iPWG3d2h) {
979 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
980 !LoadLibrary("PWG3vertexingHF", mode, kTRUE)) return kFALSE;
984 if (!LoadLibrary("PWG3hfe", mode, kTRUE)) return kFALSE;
987 ::Info("AnalysisTrainNew.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS");
991 //______________________________________________________________________________
992 Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE)
994 // Load a module library in a given mode. Reports success.
997 TString smodule(module);
998 if (!strcmp(mode, "LOCAL")) imode = 0;
999 if (!strcmp(mode, "PROOF")) imode = 1;
1000 if (!strcmp(mode, "GRID")) imode = 2;
1001 TString mod(module);
1002 if (!mod.Length()) {
1003 ::Error("AnalysisTrainNew.C::LoadLibrary", "Empty module name");
1006 // If a library is specified, just load it
1007 if (smodule.EndsWith(".so")) {
1008 mod.Remove(mod.Index(".so"));
1009 result = gSystem->Load(mod);
1011 ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not load library %s", module);
1014 if (rec) anaLibs += Form("%s.so ",mod.Data());
1017 // Check if the library is already loaded
1018 if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0)
1024 result = SetupPar(module);
1025 if (rec) anaPars += Form("%s.par ", module);
1027 result = gSystem->Load(Form("lib%s.so", module));
1028 if (rec) anaLibs += Form("lib%s.so ", module);
1032 result = gProof->UploadPackage(module);
1034 result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module)));
1036 ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module);
1040 result = gProof->EnablePackage(module);
1046 ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not load module %s", module);
1053 //______________________________________________________________________________
1054 TChain *CreateChain(const char *mode, const char *plugin_mode)
1056 // Create the input chain
1058 if (!strcmp(mode, "LOCAL")) imode = 0;
1059 if (!strcmp(mode, "PROOF")) imode = 1;
1060 if (!strcmp(mode, "GRID")) imode = 2;
1061 TChain *chain = NULL;
1066 if (!local_xmldataset.Length()) {
1068 chain = new TChain("aodTree");
1069 if (gSystem->AccessPathName("data/AliAOD.root"))
1070 ::Error("AnalysisTrainNew.C::CreateChain", "File: AliAOD.root not in ./data dir");
1072 if (!saveTrain) chain->Add("data/AliAOD.root");
1073 else chain->Add("../data/AliAOD.root");
1077 chain = CreateChainSingle(local_xmldataset, "aodTree");
1080 if (!local_xmldataset.Length()) {
1082 chain = new TChain("esdTree");
1083 if (gSystem->AccessPathName("data/AliESDs.root"))
1084 ::Error("AnalysisTrainNew.C::CreateChain", "File: AliESDs.root not in ./data dir");
1086 if (!saveTrain) chain->Add("data/AliESDs.root");
1087 else chain->Add("../data/AliESDs.root");
1091 chain = CreateChainSingle(local_xmldataset, "esdTree");
1099 // AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
1100 // AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
1102 TString treeName = "esdTree";
1103 if (iAODanalysis) treeName = "aodTree";
1104 chain = CreateChainSingle("wn.xml", treeName);
1109 if (chain && chain->GetNtrees()) return chain;
1113 //______________________________________________________________________________
1114 TChain* CreateChainSingle(const char* xmlfile, const char *treeName)
1116 printf("*******************************\n");
1117 printf("*** Getting the ESD Chain ***\n");
1118 printf("*******************************\n");
1119 TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
1121 if (!myCollection) {
1122 ::Error("AnalysisTrainNew.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
1126 TChain* chain = new TChain(treeName);
1127 myCollection->Reset() ;
1128 while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
1133 //______________________________________________________________________________
1134 Int_t SetupPar(char* pararchivename)
1136 if (!pararchivename || !strlen(pararchivename)) return -1;
1137 char processline[1024];
1138 if (gSystem->AccessPathName(Form("%s.par", pararchivename))) {
1139 if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) {
1140 ::Info("AnalysisTrainNew.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename);
1141 TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)),
1142 Form("%s.par",pararchivename));
1144 ::Error("AnalysisTrainNew.C::SetupPar", "Cannot find %s.par", pararchivename);
1148 if (usePLUGIN && saveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, train_name.Data()));
1149 gSystem->Exec(Form("tar xvzf %s.par", pararchivename));
1151 TString ocwd = gSystem->WorkingDirectory();
1152 if (!gSystem->ChangeDirectory(pararchivename)) return -1;
1154 // check for BUILD.sh and execute
1155 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
1156 printf("*******************************\n");
1157 printf("*** Building PAR archive ***\n");
1158 printf("*******************************\n");
1159 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
1160 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
1165 // check for SETUP.C and execute
1166 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
1167 printf("*******************************\n");
1168 printf("*** Setup PAR archive ***\n");
1169 printf("*******************************\n");
1170 gROOT->Macro("PROOF-INF/SETUP.C");
1172 if (!gSystem->ChangeDirectory(ocwd.Data())) return -1;
1176 //______________________________________________________________________________
1177 AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
1179 // Check if user has a valid token, otherwise make one. This has limitations.
1180 // One can always follow the standard procedure of calling alien-token-init then
1181 // source /tmp/gclient_env_$UID in the current shell.
1182 if (!AliAnalysisGrid::CreateToken()) return NULL;
1183 AliAnalysisAlien *plugin = new AliAnalysisAlien();
1184 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
1185 plugin->SetRunMode(plugin_mode);
1186 if (useProductionMode) plugin->SetProductionMode();
1187 if (!outputSingleFolder.IsNull()) plugin->SetOutputSingleFolder(outputSingleFolder);
1188 plugin->SetJobTag(job_tag);
1189 plugin->SetNtestFiles(1);
1190 // plugin->SetPreferedSE("ALICE::NIHAM::File");
1191 // Set versions of used packages
1192 // plugin->SetAPIVersion("V2.4");
1193 plugin->SetAPIVersion("V1.1x");
1194 plugin->SetROOTVersion(root_version);
1195 plugin->SetAliROOTVersion(aliroot_version);
1196 // Declare input data to be processed.
1197 // Method 1: Create automatically XML collections using alien 'find' command.
1198 // Define production directory LFN
1199 plugin->SetGridDataDir(alien_datadir);
1200 // Set data search pattern
1201 if (iAODanalysis) plugin->SetDataPattern("*AliAOD.root");
1202 else plugin->SetDataPattern("*AliESDs.root");
1203 // ...then add run numbers to be considered
1204 if (!iAODanalysis) plugin->SetRunRange(run_range[0], run_range[1]);
1205 // for (Int_t i=0; i<10; i++) {
1206 // if (run_numbers[i]==0) break;
1207 // plugin->AddRunNumber(run_numbers[i]);
1209 // Method 2: Declare existing data files (raw collections, xml collections, root file)
1210 // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
1211 // XML collections added via this method can be combined with the first method if
1212 // the content is compatible (using or not tags)
1213 // plugin->AddDataFile("tag.xml");
1214 // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
1215 // Define alien work directory where all files will be copied. Relative to alien $HOME.
1216 if (iAODanalysis) plugin->SetGridWorkingDir("analysisAOD");
1217 else plugin->SetGridWorkingDir("analysisESD");
1218 // Declare alien output directory. Relative to working directory.
1219 if (!alien_outdir.Length()) alien_outdir = Form("output_%s",train_name.Data());
1220 plugin->SetGridOutputDir(alien_outdir);
1222 TString ana_sources = "";
1223 TString ana_add = "";
1224 if (usePAR && anaPars.Length()) {
1225 printf("%s\n", anaPars.Data());
1228 arr = anaPars.Tokenize(" ");
1230 while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString());
1233 // Add external packages
1235 plugin->AddExternalPackage("boost::v1_38_0");
1236 plugin->AddExternalPackage("cgal::v3.3.1");
1237 plugin->AddExternalPackage("fastjet::v2.4.0");
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);
1249 // Declare the output file names separated by blancs.
1250 // (can be like: file.root or file.root@ALICE::Niham::File)
1251 plugin->SetDefaultOutputs();
1252 plugin->SetMergeExcludes(mergeExclude);
1253 plugin->SetMaxMergeFiles(maxMergeFiles);
1254 plugin->SetNrunsPerMaster(nRunsPerMaster);
1255 // Optionally define the files to be archived.
1256 // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File");
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;
1273 listaods += "pyxsec_hists.root";
1275 if (!strcmp(filename, "pyxsec_hists.root")) continue;
1276 if (listhists.Contains(filename)) continue;
1277 if (listhists.Length()) listhists += ",";
1278 listhists += filename;
1281 if (mgr->GetExtraFiles().Length()) {
1282 if (listaods.Length()) listaods += ",";
1283 listaods += mgr->GetExtraFiles();
1284 listaods.ReplaceAll(" ", ",");
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());
1288 if (!listhists.Length() && !listaods.Length()) {
1289 ::Fatal("AnalysisTrainNew", "No task output !");
1291 TString outputArchive = Form("log_archive.zip:stderr,stdout@%s", outputStorages.Data());
1292 if (listaods.Length()) {
1293 outputArchive += " ";
1294 outputArchive += listaods;
1296 if (listhists.Length()) {
1297 outputArchive += " ";
1298 outputArchive += listhists;
1301 // if (iAODanalysis && iPWG3d2h)
1302 // plugin->SetFriendChainName("AliAOD.VertexingHF.root");
1303 plugin->SetOutputArchive(outputArchive);
1304 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
1305 plugin->SetAnalysisMacro(Form("%s.C", train_name.Data()));
1306 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
1307 plugin->SetSplitMaxInputFileNumber(nFilesPerJob);
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)
1313 plugin->SetTTL(70000);
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)
1317 plugin->SetJDLName(Form("%s.jdl", train_name.Data()));
1318 // Optionally modify the executable name (default analysis.sh)
1319 plugin->SetExecutable(Form("%s.sh", train_name.Data()));
1320 // Optionally modify job price (default 1)
1321 plugin->SetPrice(1);
1322 // Optionally modify split mode (default 'se')
1323 // plugin->SetSplitMode("se");
1327 //______________________________________________________________________________
1330 // Write train configuration in a file. The file name has the format:
1331 // train_[trainName]_ddMonthyyyy_time.C
1333 gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp");
1334 ifstream fdate("date.tmp");
1335 if (!fdate.is_open()) {
1336 ::Error("AnalysisTrainNew.C::Export","Could not generate file name");
1339 const char date[64];
1340 fdate.getline(date,64);
1342 gSystem->Exec("rm date.tmp");
1343 train_name = Form("train_%s_%s", train_name.Data(), date);
1345 train_name = Form("train_%s", train_name.Data());
1347 TString cdir = gSystem->WorkingDirectory();
1348 gSystem->MakeDirectory(train_name);
1349 gSystem->ChangeDirectory(train_name);
1351 out.open(Form("%sConfig.C",train_name.Data()), ios::out);
1353 ::Error("AnalysisTrainNew.C::Export", "Cannot open ConfigTrain.C for writing");
1357 out << " train_name = " << "\"" << train_name.Data() << "\";" << endl;
1358 out << " proof_cluster = " << "\"" << proof_cluster.Data() << "\";" << endl;
1359 out << " useAFPAR = " << useAFPAR << ";" << endl;
1361 out << " AFversion = " << AFversion.Data() << ";" << endl;
1362 out << " proof_dataset = " << "\"" << proof_dataset.Data() << "\";" << endl;
1363 out << " usePLUGIN = " << usePLUGIN << ";" << endl;
1364 out << " usePAR = " << usePAR << ";" << endl;
1365 out << " useCPAR = " << useCPAR << ";" << endl;
1366 out << " root_version = " << "\"" << root_version.Data() << "\";" << endl;
1367 out << " aliroot_version = " << "\"" << aliroot_version.Data() << "\";" << endl;
1368 out << " alien_datadir = " << "\"" << alien_datadir.Data() << "\";" << endl;
1369 if (!alien_outdir.Length()) alien_outdir = Form("output_%s",train_name.Data());
1370 out << " alien_outdir = " << "\"" << alien_outdir.Data() << "\";" << endl;
1371 out << " maxMergeFiles = " << maxMergeFiles << ";" << endl;
1372 out << " mergeExclude = " << "\"" << mergeExclude.Data() << "\";" << endl;
1373 out << " nRunsPerMaster = " << nRunsPerMaster << ";" << endl;
1374 out << " nFilesPerJob = " << nFilesPerJob << ";" << endl;
1375 // for (Int_t i=0; i<10; i++) {
1376 // if (run_numbers[i])
1377 // out << " run_numbers[" << i << "] = " << run_numbers[i] << ";" << endl;
1379 out << " run_range[0] = " << run_range[0] << ";" << endl;
1380 out << " run_range[1] = " << run_range[1] << ";" << endl;
1381 out << " useDBG = " << useDBG << ";" << endl;
1382 out << " useMC = " << useMC << ";" << endl;
1383 out << " useTAGS = " << useTAGS << ";" << endl;
1384 out << " useKFILTER = " << useKFILTER << ";" << endl;
1385 out << " useTR = " << useTR << ";" << endl;
1386 out << " useCORRFW = " << useCORRFW << ";" << endl;
1387 out << " useAODTAGS = " << useAODTAGS << ";" << endl;
1388 out << " saveTrain = " << "kFALSE;" << endl << endl;
1389 out << " // Analysis modules" << endl;
1390 out << " iAODanalysis = " << iAODanalysis << ";" << endl;
1391 out << " iAODhandler = " << iAODhandler << ";" << endl;
1392 out << " iESDfilter = " << iESDfilter << ";" << endl;
1393 out << " iMUONcopyAOD = " << iMUONcopyAOD << ";" << endl;
1394 out << " iJETAN = " << iJETAN << ";" << endl;
1395 out << " iJETANdelta = " << iJETANdelta << ";" << endl;
1396 out << " iPWG4partcorr = " << iPWG4partcorr << ";" << endl;
1397 out << " iPWG4gammaconv = " << iPWG4gammaconv << ";" << endl;
1398 out << " iPWG4omega3pi = " << iPWG4omega3pi << ";" << endl;
1399 out << " iPWG3vertexing = " << iPWG3vertexing << ";" << endl;
1400 out << " iPWG3hfe = " << iPWG3hfe << ";" << endl;
1401 out << " iPWG3d2h = " << iPWG3d2h << ";" << endl;
1402 out << " iPWG3d0mass = " << iPWG3d0mass << ";" << endl;
1403 out << " iPWG3d0massLS = " << iPWG3d0massLS << ";" << endl;
1404 out << " iPWG3dplus = " << iPWG3dplus << ";" << endl;
1405 out << " iPWG3LSd0 = " << iPWG3LSd0 << ";" << endl;
1406 out << " iPWG3LSjpsi = " << iPWG3LSjpsi << ";" << endl;
1407 out << " iPWG3CFd0 = " << iPWG3CFd0 << ";" << endl;
1408 out << " iPWG3promptd0 = " << iPWG3promptd0 << ";" << endl;
1409 out << " iPWG3MuonTrain = " << iPWG3MuonTrain << ";" << endl;
1410 out << " iPWG2femto = " << iPWG2femto << ";" << endl;
1411 out << " iPWG2spectra = " << iPWG2spectra << ";" << endl;
1412 out << " iPWG2protons = " << iPWG2protons << ";" << endl;
1413 out << " iPWG2checkcascade = " << iPWG2checkcascade << ";" << endl;
1414 out << " iPWG2perfcascade = " << iPWG2perfcascade << ";" << endl;
1415 out << " iPWG2checkv0 = " << iPWG2checkv0 << ";" << endl;
1416 out << " iPWG2strange = " << iPWG2strange << ";" << endl;
1417 out << " iPWG2central = " << iPWG2central << ";" << endl;
1418 out << " iPWG2flow = " << iPWG2flow << ";" << endl;
1419 out << " iPWG2res = " << iPWG2res << ";" << endl;
1420 out << " iPWG2rsneff = " << iPWG2rsneff << ";" << endl;
1421 out << " iPWG2kink = " << iPWG2kink << ";" << endl;
1422 out << " iPWG2kinkESDMC = " << iPWG2kinkESDMC << ";" << endl;
1423 out << " iPWG2kinkLSKstar = " << iPWG2kinkLSKstar << ";" << endl;
1424 out << " iPWG2kinkLSL1520 = " << iPWG2kinkLSL1520 << ";" << endl;
1425 out << " iPWG2kinkLSPhi = " << iPWG2kinkLSPhi << ";" << endl;
1426 out << " iPWG2kinkKstarESD = " << iPWG2kinkKstarESD << ";" << endl;
1427 out << " iPWG2kinkKstarMC = " << iPWG2kinkKstarMC << ";" << endl;
1428 out << " iPWG2kinkL1520ESD = " << iPWG2kinkL1520ESD << ";" << endl;
1429 out << " iPWG2kinkL1520MC = " << iPWG2kinkL1520MC << ";" << endl;
1430 out << " iPWG2kinkPhiESD = " << iPWG2kinkPhiESD << ";" << endl;
1431 out << " iPWG2kinkPhiMC = " << iPWG2kinkPhiMC << ";" << endl;
1432 out << " iPWG2unicor = " << iPWG2unicor << ";" << endl;
1433 out << " iPWG2evchar = " << iPWG2evchar << ";" << endl;
1434 out << " iPWG2forward = " << iPWG2forward << ";" << endl << endl;
1435 out << "// Configuration fot the wagons" << endl;
1436 out << " configPWG2femto = \"" << configPWG2femto << "\";" << endl;
1437 out << " configPWG3d2h = \"" << configPWG3d2h << "\";" << endl;
1439 ::Info("AnalysisTrainNew.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", train_name.Data()));
1440 gSystem->ChangeDirectory(cdir);
1443 //______________________________________________________________________________
1444 Bool_t LoadConfig(const char *filename)
1446 // Read train configuration from file
1447 if (gSystem->AccessPathName(filename)) {
1448 ::Error("AnalysisTrainNew.C::LoadConfig", "Config file name not found");
1451 gROOT->ProcessLine(Form(".x %s", filename));
1452 ::Info("AnalysisTrainNew.C::LoadConfig", "Train configuration loaded from file %s", filename);