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