]>
Commit | Line | Data |
---|---|---|
a000cab6 | 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 = "PWG2"; // local folder name | |
20 | TString train_tag = "_Pb-Pb_"; // 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("PWG2%s$2_$3", train_tag.Data()); //# FIXED # | |
24 | // Add train composition and other comments | |
25 | TString job_comment = "PWG2 tasks on ESDs"; | |
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 = 1; // Set to 1 if processing real data | |
41 | Int_t iCollision = 1; // 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-06c"; // *CHANGE ME IF MORE RECENT IN GRID* | |
51 | TString aliroot_version = "v4-21-15-AN"; // *CHANGE ME IF MORE RECENT IN GRID* | |
52 | // Change production base directory here (test mode) | |
53 | TString alien_datadir = "/alice/data/2010/LHC10h"; | |
54 | // Work directory in GRID (DON'T CHANGE) | |
55 | TString grid_workdir = "/alice/cern.ch/user/a/alidaq/PWG2/PWG2_$2"; | |
56 | // Data pattern - change as needed for test mode | |
57 | // TString data_pattern = "*ESDs/pass1/AOD033/*AOD.root"; | |
58 | TString data_pattern = "*ESDs/pass1/*ESDs.root"; | |
59 | // Set the run range | |
60 | Int_t run_numbers[10] = {137844}; // **********************!!!!!!! | |
61 | // AliEn output directory. If blank will become output_<train_name> | |
62 | // Output directory (DON'T CHANGE) | |
63 | TString alien_outdir = "$1/PWG2OUT$2"; | |
64 | // Input collection (production mode) | |
65 | TString data_collection = "$1/input.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 AliAODCentrality.root"; | |
73 | TString mergeDirName = "PWG2OUT$2"; | |
74 | // Make replicas on the storages below | |
75 | TString outputStorages = "disk=4"; | |
76 | // Number of runs per master job | |
77 | Int_t nRunsPerMaster = 10; | |
78 | // Maximum number of files per job (gives size of AOD) | |
79 | Int_t nFilesPerJob = 5; | |
80 | // Int_t nFilesPerJob = 1; (AOD->delta AOD production case) | |
81 | // ### Settings that make sense only for local analysis | |
82 | //============================================================================== | |
83 | // Change local xml dataset for local interactive analysis | |
84 | TString local_xmldataset = ""; | |
85 | ||
86 | // ### Other flags to steer the analysis | |
87 | //============================================================================== | |
88 | Bool_t usePhysicsSelection = kFALSE; // use physics selection | |
89 | Bool_t useBKrejection = kFALSE; // use BK rejection | |
62e790f1 | 90 | Bool_t useCentrality = kTRUE; // centrality delta AOD |
a000cab6 | 91 | Bool_t useTender = kFALSE; // use tender wagon |
92 | Bool_t useV0tender = kFALSE; // use V0 correction in tender | |
93 | Bool_t useMergeViaJDL = kTRUE; // merge via JDL | |
94 | Bool_t useFastReadOption = kFALSE; // use xrootd tweaks | |
95 | Bool_t useOverwriteMode = kTRUE; // overwrite existing collections | |
96 | Bool_t useDATE = kFALSE; // use date in train name | |
97 | Bool_t useDBG = kTRUE; // activate debugging | |
98 | Bool_t useMC = kFALSE; // use MC info | |
99 | Bool_t useTAGS = kFALSE; // use ESD tags for selection | |
100 | Bool_t useKFILTER = kFALSE; // use Kinematics filter | |
101 | Bool_t useTR = kFALSE; // use track references | |
102 | Bool_t useCORRFW = kTRUE; // do not change | |
103 | Bool_t useAODTAGS = kFALSE; // use AOD tags | |
104 | Bool_t saveTrain = kTRUE; // save train configuration as: | |
105 | Bool_t saveCanvases = kFALSE; // save canvases created in Terminate | |
106 | Bool_t saveProofToAlien = kFALSE; // save proof outputs in AliEn | |
107 | ||
108 | // ### Analysis modules to be included. Some may not be yet fully implemented. | |
109 | //============================================================================== | |
110 | Int_t iAODanalysis = 0; // Analysis on input AOD's | |
111 | Int_t iAODhandler = 1; // Analysis produces an AOD or dAOD's | |
112 | ||
113 | Int_t iPWG2fmd = 0; // FMD forward analysis (PWG2) | |
114 | Int_t iPWG2femto = 1; // Femtoscopy two-track analysis (PWG2) | |
62e790f1 | 115 | Int_t iPWG2spectra = 1; // Charge hadron spectra (PWG2) |
a000cab6 | 116 | |
117 | // Temporaries. | |
118 | TString anaPars = ""; | |
119 | TString anaLibs = ""; | |
120 | // Function signatures | |
121 | class AliAnalysisAlien; | |
122 | ||
123 | //______________________________________________________________________________ | |
124 | void AnalysisTrainPWG2(const char *analysis_mode="local", | |
125 | const char *plugin_mode="full", | |
126 | const char *config_file="") | |
127 | { | |
128 | // Main analysis train macro. If a configuration file is provided, all parameters | |
129 | // are taken from there but may be altered by CheckModuleFlags. | |
130 | if (strlen(config_file) && !LoadConfig(config_file)) return; | |
131 | TString smode(analysis_mode); | |
132 | smode.ToUpper(); | |
133 | TString spmode(plugin_mode); | |
134 | spmode.ToLower(); | |
135 | if (spmode == "test") useProductionMode = kFALSE; | |
136 | // Check compatibility of selected modules | |
137 | CheckModuleFlags(smode); | |
138 | if (saveTrain) WriteConfig(); | |
139 | ||
140 | printf("==================================================================\n"); | |
141 | printf("=========== RUNNING ANALYSIS TRAIN %s IN %s MODE ==========\n", train_name.Data(),smode.Data()); | |
142 | printf("==================================================================\n"); | |
143 | printf("= Configuring analysis train for: =\n"); | |
144 | if (iAODanalysis) printf("= AOD analysis =\n"); | |
145 | else printf("= ESD analysis =\n"); | |
146 | if (usePhysicsSelection) printf("= Physics selection =\n"); | |
147 | if (useTender) printf("= TENDER =\n"); | |
148 | if (iPWG2fmd) printf("= PWG2 FMD =\n"); | |
149 | if (iPWG2femto) printf("= PWG2 Femtoscopy =\n"); | |
62e790f1 | 150 | if (iPWG2spectra) printf("= PWG2 Charged Spectra =\n"); |
a000cab6 | 151 | printf("==================================================================\n"); |
152 | printf(":: use physics selection: %d\n", (UInt_t)usePhysicsSelection); | |
153 | printf(":: use xrootd tweaks: %d\n", (UInt_t)useFastReadOption); | |
154 | printf(":: use overwrite xml : %d\n", (UInt_t)useOverwriteMode); | |
155 | printf(":: use merge via JDL: %d\n", (UInt_t)useMergeViaJDL); | |
156 | printf(":: use MC truth: %d\n", (UInt_t)useMC); | |
157 | printf(":: use KINE filter: %d\n", (UInt_t)useKFILTER); | |
158 | printf(":: use track references: %d\n", (UInt_t)useTR); | |
159 | printf(":: use tags: %d\n", (UInt_t)useTAGS); | |
160 | printf(":: use AOD tags: %d\n", (UInt_t)useAODTAGS); | |
161 | printf(":: use debugging: %d\n", (UInt_t)useDBG); | |
162 | printf(":: use PAR files: %d\n", (UInt_t)usePAR); | |
163 | printf(":: use AliEn plugin: %d\n", (UInt_t)usePLUGIN); | |
164 | ||
165 | //========================================================================== | |
166 | // Connect to back-end system | |
167 | // if (!Connect(smode)) { | |
168 | // ::Error("AnalysisTrain", "Could not connect to %s back-end", analysis_mode); | |
169 | // return; | |
170 | // } | |
171 | ||
172 | // Load common libraries and set include path | |
173 | if (!LoadCommonLibraries(smode)) { | |
174 | ::Error("AnalysisTrain", "Could not load common libraries"); | |
175 | return; | |
176 | } | |
177 | ||
178 | // Make the analysis manager and connect event handlers | |
179 | AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train", "Production train"); | |
180 | if (saveProofToAlien) mgr->SetSpecialOutputLocation(proof_outdir); | |
181 | if (!strcmp(plugin_mode, "test")) mgr->SetNSysInfo(1); | |
182 | // Load analysis specific libraries | |
183 | if (!LoadAnalysisLibraries(smode)) { | |
184 | ::Error("AnalysisTrain", "Could not load analysis libraries"); | |
185 | return; | |
186 | } | |
187 | ||
188 | // Create input handler (input container created automatically) | |
189 | if (iAODanalysis) { | |
190 | // AOD input handler | |
191 | AliAODInputHandler *aodH = new AliAODInputHandler(); | |
192 | mgr->SetInputEventHandler(aodH); | |
193 | } else { | |
194 | // ESD input handler | |
195 | AliESDInputHandler *esdHandler = new AliESDInputHandler(); | |
196 | if (useTAGS) esdHandler->SetReadTags(); | |
197 | mgr->SetInputEventHandler(esdHandler); | |
198 | } | |
199 | // Monte Carlo handler | |
200 | if (useMC && !iAODanalysis) { | |
201 | AliMCEventHandler* mcHandler = new AliMCEventHandler(); | |
202 | mgr->SetMCtruthEventHandler(mcHandler); | |
203 | mcHandler->SetReadTR(useTR); | |
204 | } | |
205 | // AOD output container, created automatically when setting an AOD handler | |
206 | if (iAODhandler) { | |
207 | // AOD output handler | |
208 | AliAODHandler* aodHandler = new AliAODHandler(); | |
209 | aodHandler->SetOutputFileName("AliAOD.root"); | |
210 | mgr->SetOutputEventHandler(aodHandler); | |
211 | if (iAODanalysis) { | |
212 | aodHandler->SetFillAOD(kFALSE); | |
213 | aodHandler->SetCreateNonStandardAOD(); | |
214 | // if (iPWG3vertexing) aodHandler->SetOutputFileName("AliAOD.VertexingHF.root"); | |
215 | } | |
216 | } | |
217 | // Debugging if needed | |
218 | if (useDBG) mgr->SetDebugLevel(3); | |
219 | if (saveCanvases) mgr->SetSaveCanvases(kTRUE); | |
220 | ||
221 | //========================================================================== | |
222 | // Create the chain. In this example it is created only from ALIEN files but | |
223 | // can be done to work in batch or grid mode as well. | |
224 | TChain *chain = CreateChain(smode, plugin_mode); | |
225 | ||
226 | //========================================================================== | |
227 | // Load the tasks configuration macros for all wagons. These files are supposed now to be | |
228 | // in the current workdir, but in AliEn they will be in the file catalog, | |
229 | // mapped from AliRoot and pecified in the jdl input list. | |
230 | ||
231 | // For now connection to top input container and common AOD output container | |
232 | // is done in this macro, but in future these containers will be connected | |
233 | // from each task configuration macro. | |
234 | ||
235 | AddAnalysisTasks(); | |
236 | ||
237 | // Run the analysis | |
238 | // | |
239 | if (usePLUGIN) { | |
240 | AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode); | |
241 | AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler); | |
242 | } | |
243 | ||
244 | if (mgr->InitAnalysis()) { | |
245 | mgr->PrintStatus(); | |
246 | if (saveTrain || strlen(config_file)) gSystem->ChangeDirectory(train_name); | |
247 | StartAnalysis(smode, chain); | |
248 | } | |
249 | } | |
250 | ||
251 | //______________________________________________________________________________ | |
252 | void AddAnalysisTasks() | |
253 | { | |
254 | // Add all analysis task wagons to the train | |
255 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
256 | ||
257 | // | |
258 | // Tender and supplies. Needs to be called for every event. | |
259 | // | |
260 | if (useTender) { | |
261 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/TenderSupplies/AddTaskTender.C"); | |
262 | // IF V0 tender needed, put kTRUE below | |
263 | AliAnalysisTaskSE *tender = AddTaskTender(useV0tender); | |
264 | // tender->SetDebugLevel(2); | |
265 | } | |
266 | ||
267 | if (usePhysicsSelection) { | |
268 | // Physics selection task | |
269 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); | |
270 | mgr->RegisterExtraFile("event_stat.root"); | |
271 | AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(useMC,useBKrejection); | |
272 | mgr->AddStatisticsTask(AliVEvent::kMB); | |
273 | } | |
274 | ||
62e790f1 | 275 | if (useCentrality) { |
276 | // Common Centrality task | |
277 | AliCentralitySelectionTask *centralityTask = new AliCentralitySelectionTask("CentralitySelection"); | |
278 | mgr->AddTask(centralityTask); | |
279 | mgr->ConnectInput(centralityTask, 0, mgr->GetCommonInputContainer()); | |
280 | // gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); | |
281 | // mgr->RegisterExtraFile("event_stat.root"); | |
282 | // AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(useMC,useBKrejection); | |
283 | // mgr->AddStatisticsTask(AliVEvent::kMB); | |
284 | } | |
285 | ||
a000cab6 | 286 | // AOD tags |
287 | if (useAODTAGS) { | |
288 | AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator"); | |
289 | mgr->AddTask(tagTask); | |
290 | AliAnalysisDataContainer *coutTags = mgr->CreateContainer("cTag", TTree::Class(), | |
291 | AliAnalysisManager::kOutputContainer, "AOD.tag.root"); | |
292 | mgr->ConnectInput (tagTask, 0, mgr->GetCommonInputContainer()); | |
293 | mgr->ConnectOutput(tagTask, 1, coutTags); | |
294 | } | |
295 | ||
296 | ||
297 | // ********** PWG2 wagons ****************************************************** | |
298 | AliAnalysisManager::SetCommonFileName("PWG2histograms.root"); | |
299 | ||
300 | // PWG2 FMD | |
301 | if (iPWG2fmd) { | |
302 | gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/AddTaskFMD.C"); | |
303 | AliAnalysisTask *taskFMD = AddTaskFMD(useMC, iCollision+1, iCollision?7000:2750, 0.5); | |
304 | if (!taskFMD) ::Warning("AnalysisTrainNew", "AliAnalysisTaskFMD cannot run for this train conditions - EXCLUDED"); | |
305 | } | |
306 | ||
307 | // PWG2 Femtoscopy | |
308 | if (iPWG2femto) { | |
309 | gROOT->LoadMacro("$ALICE_ROOT/PWG2/FEMTOSCOPY/macros/AddTaskFemto.C"); | |
62e790f1 | 310 | AliAnalysisTask *taskFemto = AddTaskFemto("$ALICE_ROOT/PWG2/FEMTOSCOPY/macros/Train/TwoTrackQA/ConfigFemtoAnalysisCentral.C",Form("%i, %i, %i", iAODanalysis?0:1, iCollision, 0)); |
a000cab6 | 311 | if (!taskFemto) ::Warning("AnalysisTrainNew", "AliAnalysisTaskFemto cannot run for this train conditions - EXCLUDED"); |
312 | } | |
cd2a6200 | 313 | |
314 | // PWG2 Spectra | |
cf1669a9 | 315 | if (iPWG2spectra) { |
316 | gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskITSsaSpectra.C"); | |
317 | AliAnalysisTask *taskSpectraITSsa = AddTaskITSsaSpectra(0,useMC,-1,-1,iCollision); | |
318 | if (!taskSpectraITSsa) ::Warning("AnalysisTrainNew", "AliAnalysisTaskSpectraITSsa cannot run for this train conditions - EXCLUDED"); | |
319 | } | |
cd2a6200 | 320 | if (iPWG2spectra) { |
321 | gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/AddTaskChargedHadronSpectraITSTruncatedMean.C"); | |
322 | AliAnalysisTask *taskSpectraITSTPC = AddTaskChargedHadronSpectraITSTruncatedMean(-1,-1,useMC,iCollision,"$ALICE_ROOT/PWG2/SPECTRA/macros/configChargedHadronSpectraITSTruncatedMeanTask.C"); | |
323 | if (!taskSpectraITSTPC) ::Warning("AnalysisTrainNew", "AliAnalysisTaskSpectraITSTPC cannot run for this train conditions - EXCLUDED"); | |
cf1669a9 | 324 | } |
a000cab6 | 325 | } |
326 | ||
327 | //______________________________________________________________________________ | |
328 | void StartAnalysis(const char *mode, TChain *chain) { | |
329 | // Start analysis. | |
330 | Int_t imode = -1; | |
331 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
332 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
333 | if (!strcmp(mode, "PROOF")) imode = 1; | |
334 | if (!strcmp(mode, "GRID")) imode = 2; | |
335 | switch (imode) { | |
336 | case 0: | |
337 | if (!chain) { | |
338 | ::Error("AnalysisTrainNew.C::StartAnalysis", "Cannot create the chain"); | |
339 | return; | |
340 | } | |
341 | mgr->StartAnalysis(mode, chain); | |
342 | return; | |
343 | case 1: | |
344 | if (!proof_dataset.Length()) { | |
345 | ::Error("AnalysisTrainNew.C::StartAnalysis", "proof_dataset is empty"); | |
346 | return; | |
347 | } | |
348 | mgr->StartAnalysis(mode, proof_dataset, 1000); | |
349 | return; | |
350 | case 2: | |
351 | if (usePLUGIN) { | |
352 | if (!mgr->GetGridHandler()) { | |
353 | ::Error("AnalysisTrainNew.C::StartAnalysis", "Grid plugin not initialized"); | |
354 | return; | |
355 | } | |
356 | mgr->StartAnalysis("grid"); | |
357 | } else { | |
358 | if (!chain) { | |
359 | ::Error("AnalysisTrainNew.C::StartAnalysis", "Cannot create the chain"); | |
360 | return; | |
361 | } | |
362 | mgr->StartAnalysis(mode, chain); | |
363 | } | |
364 | return; | |
365 | } | |
366 | } | |
367 | ||
368 | //______________________________________________________________________________ | |
369 | void CheckModuleFlags(const char *mode) { | |
370 | // Checks selected modules and insure compatibility | |
371 | Int_t imode = -1; | |
372 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
373 | if (!strcmp(mode, "PROOF")) imode = 1; | |
374 | if (!strcmp(mode, "GRID")) imode = 2; | |
375 | if (imode==1) { | |
376 | if (!usePAR) { | |
377 | ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis"); | |
378 | usePAR = kTRUE; | |
379 | } | |
380 | } | |
381 | if (imode != 2) { | |
382 | ::Info("AnalysisTrainNew.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode"); | |
383 | usePLUGIN = kFALSE; | |
384 | } | |
385 | if (iAODanalysis) { | |
386 | // AOD analysis | |
387 | if (useMC) | |
388 | ::Info("AnalysisTrainNew.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's"); | |
389 | if (useAODTAGS) | |
390 | ::Info("AnalysisTrainNew.C::CheckModuleFlags", "AOD tags usage disabled in analysis on AOD's"); | |
391 | useMC = kFALSE; | |
392 | useTR = kFALSE; | |
393 | useAODTAGS = kFALSE; | |
394 | } else { | |
395 | // ESD analysis | |
396 | if (!useMC) useTR = kFALSE; | |
397 | if (!useTR) { | |
398 | ::Info("AnalysisTrainNew.C::CheckModuleFlags", "iPWG2evchar disabled if not reading track references"); | |
399 | iPWG2evchar = 0; | |
400 | } | |
401 | } | |
402 | if (useKFILTER && !useMC) useKFILTER = kFALSE; | |
403 | if (useAODTAGS && !iAODhandler) useAODTAGS = kFALSE; | |
404 | } | |
405 | ||
406 | //______________________________________________________________________________ | |
407 | Bool_t Connect(const char *mode) { | |
408 | // Connect <username> to the back-end system. | |
409 | Int_t imode = -1; | |
410 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
411 | if (!strcmp(mode, "PROOF")) imode = 1; | |
412 | if (!strcmp(mode, "GRID")) imode = 2; | |
413 | TString username = gSystem->Getenv("alien_API_USER"); | |
414 | switch (imode) { | |
415 | case 0: | |
416 | break; | |
417 | case 1: | |
418 | if (!username.Length()) { | |
419 | ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), "Make sure you:\n \ | |
420 | 1. Have called: alien-token-init <username>\n \ | |
421 | 2. Have called: >source /tmp/gclient_env_$UID"); | |
422 | return kFALSE; | |
423 | } | |
424 | ::Info("AnalysisTrainNew.C::Connect", "Connecting user <%s> to PROOF cluster <%s>", | |
425 | username.Data(), proof_cluster.Data()); | |
426 | gEnv->SetValue("XSec.GSI.DelegProxy", "2"); | |
427 | // TProof::Open(Form("%s@%s:31093", username.Data(), proof_cluster.Data())); | |
428 | TProof::Open(Form("%s@%s", username.Data(), proof_cluster.Data())); | |
429 | if (!gProof) { | |
430 | if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch")) | |
431 | ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch"); | |
432 | return kFALSE; | |
433 | } | |
434 | TGrid::Connect("alien://"); | |
435 | if (gGrid) { | |
436 | TString homedir = gGrid->GetHomeDirectory(); | |
437 | TString workdir = homedir + train_name; | |
438 | if (!gGrid->Cd(workdir)) { | |
439 | gGrid->Cd(homedir); | |
440 | if (gGrid->Mkdir(workdir)) { | |
441 | gGrid->Cd(train_name); | |
442 | ::Info("AnalysisTrainNew::Connect()", "Directory %s created", gGrid->Pwd()); | |
443 | } | |
444 | } | |
445 | gGrid->Mkdir("proof_output"); | |
446 | gGrid->Cd("proof_output"); | |
447 | proof_outdir = Form("alien://%s", gGrid->Pwd()); | |
448 | } | |
449 | break; | |
450 | case 2: | |
451 | if (usePLUGIN && !gSystem->Getenv("alien_CLOSE_SE")) { | |
452 | ::Error(Form("AnalysisTrainNew.C::Connect <%s>", mode), | |
453 | "When using the AliEn plugin it is preferable to define the \ | |
454 | variable alien_CLOSE_SE in your environment."); | |
455 | return kFALSE; | |
456 | } | |
457 | ::Info("AnalysisTrainNew.C::Connect", "Connecting user <%s> to AliEn ...", | |
458 | username.Data()); | |
459 | TGrid::Connect("alien://"); | |
460 | if (!gGrid || !gGrid->IsConnected()) return kFALSE; | |
461 | break; | |
462 | default: | |
463 | ::Error("AnalysisTrainNew.C::Connect", "Unknown run mode: %s", mode); | |
464 | return kFALSE; | |
465 | } | |
466 | ::Info("AnalysisTrainNew.C::Connect","Connected in %s mode", mode); | |
467 | return kTRUE; | |
468 | } | |
469 | ||
470 | //______________________________________________________________________________ | |
471 | Bool_t LoadCommonLibraries(const char *mode) | |
472 | { | |
473 | // Load common analysis libraries. | |
474 | Int_t imode = -1; | |
475 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
476 | if (!strcmp(mode, "PROOF")) imode = 1; | |
477 | if (!strcmp(mode, "GRID")) imode = 2; | |
478 | if (!gSystem->Getenv("ALICE_ROOT")) { | |
479 | ::Error("AnalysisTrainNew.C::LoadCommonLibraries", "Analysis train requires that analysis libraries are compiled with a local AliRoot"); | |
480 | return kFALSE; | |
481 | } | |
482 | Bool_t success = kTRUE; | |
483 | // ROOT libraries | |
484 | gSystem->Load("libTree.so"); | |
485 | gSystem->Load("libGeom.so"); | |
486 | gSystem->Load("libVMC.so"); | |
487 | gSystem->Load("libPhysics.so"); | |
488 | gSystem->Load("libMinuit.so"); | |
489 | ||
490 | // Load framework classes. Par option ignored here. | |
491 | switch (imode) { | |
492 | case 0: | |
493 | case 2: | |
494 | if (useCPAR) { | |
495 | success &= LoadLibrary("STEERBase", mode, kTRUE); | |
496 | success &= LoadLibrary("ESD", mode, kTRUE); | |
497 | success &= LoadLibrary("AOD", mode, kTRUE); | |
498 | success &= LoadLibrary("ANALYSIS", mode, kTRUE); | |
499 | success &= LoadLibrary("ANALYSISalice", mode, kTRUE); | |
500 | if (useCORRFW) success &= LoadLibrary("CORRFW", mode, kTRUE); | |
501 | } else { | |
502 | success &= LoadLibrary("libSTEERBase.so", mode); | |
503 | success &= LoadLibrary("libESD.so", mode); | |
504 | success &= LoadLibrary("libAOD.so", mode); | |
505 | success &= LoadLibrary("libANALYSIS.so", mode); | |
506 | success &= LoadLibrary("libANALYSISalice.so", mode); | |
507 | if (useCORRFW) success &= LoadLibrary("libCORRFW.so", mode); | |
508 | gROOT->ProcessLine(".include $ALICE_ROOT/include"); | |
509 | } | |
510 | break; | |
511 | case 1: | |
512 | Int_t ires = -1; | |
513 | if (useAFPAR && !gSystem->AccessPathName(AFversion)) ires = gProof->UploadPackage(AFversion); | |
514 | if (ires < 0) { | |
515 | success &= LoadLibrary("STEERBase", mode); | |
516 | success &= LoadLibrary("ESD", mode); | |
517 | success &= LoadLibrary("AOD", mode); | |
518 | success &= LoadLibrary("ANALYSIS", mode); | |
519 | success &= LoadLibrary("ANALYSISalice", mode); | |
520 | if (useCORRFW) success &= LoadLibrary("CORRFW", mode); | |
521 | } else { | |
522 | ires = gProof->EnablePackage(AFversion); | |
523 | if (ires<0) success = kFALSE; | |
524 | if (useCORRFW) success &= LoadLibrary("CORRFW", mode); | |
525 | } | |
526 | break; | |
527 | default: | |
528 | ::Error("AnalysisTrainNew.C::LoadCommonLibraries", "Unknown run mode: %s", mode); | |
529 | return kFALSE; | |
530 | } | |
531 | if (success) { | |
532 | ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Load common libraries: SUCCESS"); | |
533 | ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s", | |
534 | gSystem->GetIncludePath()); | |
535 | } else { | |
536 | ::Info("AnalysisTrainNew.C::LoadCommodLibraries", "Load common libraries: FAILED"); | |
537 | } | |
538 | ||
539 | return success; | |
540 | } | |
541 | ||
542 | //______________________________________________________________________________ | |
543 | Bool_t LoadAnalysisLibraries(const char *mode) | |
544 | { | |
545 | // Load common analysis libraries. | |
546 | Bool_t success = kTRUE; | |
547 | if (useTender) { | |
548 | if (!LoadLibrary("TENDER", mode, kTRUE) || | |
549 | !LoadLibrary("TENDERSupplies", mode, kTRUE)) return kFALSE; | |
550 | } | |
551 | // PWG2 fmd | |
552 | if (iPWG2fmd) { | |
553 | if (!LoadLibrary("PWG2forward", mode, kTRUE)) return kFALSE; | |
554 | } | |
555 | // PWG2 femtoscopy | |
556 | if (iPWG2femto) { | |
557 | if (!LoadLibrary("PWG2AOD", mode, kTRUE) || | |
558 | !LoadLibrary("PWG2femtoscopy", mode, kTRUE) || | |
559 | !LoadLibrary("PWG2femtoscopyUser", mode, kTRUE)) return kFALSE; | |
560 | } | |
62e790f1 | 561 | // PWG2 spectra |
562 | if (iPWG2spectra) { | |
563 | if (!LoadLibrary("PWG2spectra", mode, kTRUE)) return kFALSE; | |
564 | } | |
a000cab6 | 565 | ::Info("AnalysisTrainNew.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS"); |
566 | return kTRUE; | |
567 | } | |
568 | ||
569 | //______________________________________________________________________________ | |
570 | Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE) | |
571 | { | |
572 | // Load a module library in a given mode. Reports success. | |
573 | Int_t imode = -1; | |
574 | Int_t result; | |
575 | TString smodule(module); | |
576 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
577 | if (!strcmp(mode, "PROOF")) imode = 1; | |
578 | if (!strcmp(mode, "GRID")) imode = 2; | |
579 | TString mod(module); | |
580 | if (!mod.Length()) { | |
581 | ::Error("AnalysisTrainNew.C::LoadLibrary", "Empty module name"); | |
582 | return kFALSE; | |
583 | } | |
584 | // If a library is specified, just load it | |
585 | if (smodule.EndsWith(".so")) { | |
586 | mod.Remove(mod.Index(".so")); | |
587 | result = gSystem->Load(mod); | |
588 | if (result < 0) { | |
589 | ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not load library %s", module); | |
590 | return kFALSE; | |
591 | } | |
592 | if (rec) anaLibs += Form("%s.so ",mod.Data()); | |
593 | return kTRUE; | |
594 | } | |
595 | // Check if the library is already loaded | |
596 | if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0) | |
597 | return kTRUE; | |
598 | switch (imode) { | |
599 | case 0: | |
600 | case 2: | |
601 | if (usePAR) { | |
602 | result = SetupPar(module); | |
603 | if (rec) anaPars += Form("%s.par ", module); | |
604 | } else { | |
605 | result = gSystem->Load(Form("lib%s.so", module)); | |
606 | if (rec) anaLibs += Form("lib%s.so ", module); | |
607 | } | |
608 | break; | |
609 | case 1: | |
610 | result = gProof->UploadPackage(module); | |
611 | if (result<0) { | |
612 | result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module))); | |
613 | if (result<0) { | |
614 | ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module); | |
615 | return kFALSE; | |
616 | } | |
617 | } | |
618 | result = gProof->EnablePackage(module); | |
619 | break; | |
620 | default: | |
621 | return kFALSE; | |
622 | } | |
623 | if (result < 0) { | |
624 | ::Error("AnalysisTrainNew.C::LoadLibrary", "Could not load module %s", module); | |
625 | return kFALSE; | |
626 | } | |
627 | return kTRUE; | |
628 | } | |
629 | ||
630 | ||
631 | //______________________________________________________________________________ | |
632 | TChain *CreateChain(const char *mode, const char *plugin_mode) | |
633 | { | |
634 | // Create the input chain | |
635 | Int_t imode = -1; | |
636 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
637 | if (!strcmp(mode, "PROOF")) imode = 1; | |
638 | if (!strcmp(mode, "GRID")) imode = 2; | |
639 | TChain *chain = NULL; | |
640 | // Local chain | |
641 | switch (imode) { | |
642 | case 0: | |
643 | if (iAODanalysis) { | |
644 | if (!local_xmldataset.Length()) { | |
645 | // Local AOD | |
646 | chain = new TChain("aodTree"); | |
647 | if (gSystem->AccessPathName("data/AliAOD.root")) | |
648 | ::Error("AnalysisTrainNew.C::CreateChain", "File: AliAOD.root not in ./data dir"); | |
649 | else { | |
650 | if (!saveTrain) chain->Add("data/AliAOD.root"); | |
651 | else chain->Add("../data/AliAOD.root"); | |
652 | } | |
653 | } else { | |
654 | // Interactive AOD | |
655 | chain = CreateChainSingle(local_xmldataset, "aodTree"); | |
656 | } | |
657 | } else { | |
658 | if (!local_xmldataset.Length()) { | |
659 | // Local ESD | |
660 | chain = new TChain("esdTree"); | |
661 | if (gSystem->AccessPathName("data/AliESDs.root")) | |
662 | ::Error("AnalysisTrainNew.C::CreateChain", "File: AliESDs.root not in ./data dir"); | |
663 | else { | |
664 | if (!saveTrain) chain->Add("data/AliESDs.root"); | |
665 | else chain->Add("../data/AliESDs.root"); | |
666 | } | |
667 | } else { | |
668 | // Interactive ESD | |
669 | chain = CreateChainSingle(local_xmldataset, "esdTree"); | |
670 | } | |
671 | } | |
672 | break; | |
673 | case 1: | |
674 | break; | |
675 | case 2: | |
676 | if (usePLUGIN) { | |
677 | // AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode); | |
678 | // AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler); | |
679 | } else { | |
680 | TString treeName = "esdTree"; | |
681 | if (iAODanalysis) treeName = "aodTree"; | |
682 | chain = CreateChainSingle("wn.xml", treeName); | |
683 | } | |
684 | break; | |
685 | default: | |
686 | } | |
687 | if (chain && chain->GetNtrees()) return chain; | |
688 | return NULL; | |
689 | } | |
690 | ||
691 | //______________________________________________________________________________ | |
692 | TChain* CreateChainSingle(const char* xmlfile, const char *treeName) | |
693 | { | |
694 | printf("*******************************\n"); | |
695 | printf("*** Getting the ESD Chain ***\n"); | |
696 | printf("*******************************\n"); | |
697 | TAlienCollection * myCollection = TAlienCollection::Open(xmlfile); | |
698 | ||
699 | if (!myCollection) { | |
700 | ::Error("AnalysisTrainNew.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ; | |
701 | return NULL ; | |
702 | } | |
703 | ||
704 | TChain* chain = new TChain(treeName); | |
705 | myCollection->Reset() ; | |
706 | while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ; | |
707 | chain->ls(); | |
708 | return chain; | |
709 | } | |
710 | ||
711 | //______________________________________________________________________________ | |
712 | Int_t SetupPar(char* pararchivename) | |
713 | { | |
714 | if (!pararchivename || !strlen(pararchivename)) return -1; | |
715 | char processline[1024]; | |
716 | if (gSystem->AccessPathName(Form("%s.par", pararchivename))) { | |
717 | if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) { | |
718 | ::Info("AnalysisTrainNew.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename); | |
719 | TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)), | |
720 | Form("%s.par",pararchivename)); | |
721 | } else { | |
722 | ::Error("AnalysisTrainNew.C::SetupPar", "Cannot find %s.par", pararchivename); | |
723 | return -1; | |
724 | } | |
725 | } | |
726 | if (usePLUGIN && saveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, train_name.Data())); | |
727 | gSystem->Exec(Form("tar xvzf %s.par", pararchivename)); | |
728 | ||
729 | TString ocwd = gSystem->WorkingDirectory(); | |
730 | if (!gSystem->ChangeDirectory(pararchivename)) return -1; | |
731 | ||
732 | // check for BUILD.sh and execute | |
733 | if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) { | |
734 | printf("*******************************\n"); | |
735 | printf("*** Building PAR archive ***\n"); | |
736 | printf("*******************************\n"); | |
737 | if (gSystem->Exec("PROOF-INF/BUILD.sh")) { | |
738 | Error("runProcess","Cannot Build the PAR Archive! - Abort!"); | |
739 | return -1; | |
740 | } | |
741 | } | |
742 | ||
743 | // check for SETUP.C and execute | |
744 | if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) { | |
745 | printf("*******************************\n"); | |
746 | printf("*** Setup PAR archive ***\n"); | |
747 | printf("*******************************\n"); | |
748 | gROOT->Macro("PROOF-INF/SETUP.C"); | |
749 | } | |
750 | if (!gSystem->ChangeDirectory(ocwd.Data())) return -1; | |
751 | return 0; | |
752 | } | |
753 | ||
754 | //______________________________________________________________________________ | |
755 | AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode) | |
756 | { | |
757 | // Check if user has a valid token, otherwise make one. This has limitations. | |
758 | // One can always follow the standard procedure of calling alien-token-init then | |
759 | AliAnalysisAlien *plugin = new AliAnalysisAlien(); | |
760 | // Set the run mode (can be "full", "test", "offline", "submit" or "terminate") | |
761 | plugin->SetRunMode(plugin_mode); | |
762 | if (useProductionMode) { | |
763 | plugin->SetProductionMode(); | |
764 | plugin->AddDataFile(data_collection); | |
765 | } | |
766 | ||
767 | if (!outputSingleFolder.IsNull()) { | |
768 | plugin->SetOutputSingleFolder(outputSingleFolder); | |
769 | plugin->SetOutputToRunNo(); | |
770 | } | |
771 | plugin->SetJobTag(job_tag); | |
772 | plugin->SetNtestFiles(5); | |
773 | plugin->SetCheckCopy(kFALSE); | |
774 | plugin->SetMergeDirName(mergeDirName); | |
775 | // Set versions of used packages | |
776 | plugin->SetAPIVersion("V1.1x"); | |
777 | plugin->SetROOTVersion(root_version); | |
778 | plugin->SetAliROOTVersion(aliroot_version); | |
779 | // Declare input data to be processed. | |
780 | // Method 1: Create automatically XML collections using alien 'find' command. | |
781 | // Define production directory LFN | |
782 | plugin->SetGridDataDir(alien_datadir); | |
783 | // Set data search pattern | |
784 | plugin->SetDataPattern(data_pattern); | |
785 | if (!useProductionMode) { | |
786 | if (runOnData) { | |
787 | plugin->SetRunPrefix("%09d"); | |
788 | } | |
789 | // if (!iAODanalysis) plugin->SetRunRange(run_range[0], run_range[1]); | |
790 | for (Int_t i=0; i<10; i++) { | |
791 | if (run_numbers[i]==0) break; | |
792 | plugin->AddRunNumber(run_numbers[i]); | |
793 | } | |
794 | } | |
795 | // Define alien work directory where all files will be copied. Relative to alien $HOME. | |
796 | plugin->SetGridWorkingDir(grid_workdir); | |
797 | // Declare alien output directory. Relative to working directory. | |
798 | if (alien_outdir.IsNull()) alien_outdir = Form("output_%s",train_name.Data()); | |
799 | plugin->SetGridOutputDir(alien_outdir); | |
800 | ||
801 | TString ana_sources = ""; | |
802 | TString ana_add = ""; | |
803 | if (usePAR && anaPars.Length()) { | |
804 | printf("%s\n", anaPars.Data()); | |
805 | TObjArray *arr; | |
806 | TObjString *objstr; | |
807 | arr = anaPars.Tokenize(" "); | |
808 | TIter next(arr); | |
809 | while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString()); | |
810 | delete arr; | |
811 | } | |
812 | ||
813 | // Declare the analysis source files names separated by blancs. To be compiled runtime | |
814 | // using ACLiC on the worker nodes. | |
815 | ana_sources = ana_sources.Strip(); | |
816 | // Declare all libraries (other than the default ones for the framework. These will be | |
817 | // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here. | |
818 | anaLibs = anaLibs.Strip(); | |
819 | if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources); | |
820 | if (anaLibs.Length()) plugin->SetAdditionalLibs(anaLibs); | |
821 | ||
822 | // Declare the output file names separated by blancs. | |
823 | // (can be like: file.root or file.root@ALICE::Niham::File) | |
824 | plugin->SetDefaultOutputs(); | |
825 | plugin->SetMergeExcludes(mergeExclude); | |
826 | plugin->SetMaxMergeFiles(maxMergeFiles); | |
827 | plugin->SetNrunsPerMaster(nRunsPerMaster); | |
828 | // Optionally define the files to be archived. | |
829 | // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File"); | |
830 | ||
831 | ||
832 | // Put default output files to archive | |
833 | TString listhists = ""; | |
834 | TString listaods = ""; | |
835 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
836 | TIter next(mgr->GetOutputs()); | |
837 | AliAnalysisDataContainer *output; | |
838 | while ((output=(AliAnalysisDataContainer*)next())) { | |
839 | const char *filename = output->GetFileName(); | |
840 | if (!(strcmp(filename, "default"))) { | |
841 | if (!mgr->GetOutputEventHandler()) continue; | |
842 | filename = mgr->GetOutputEventHandler()->GetOutputFileName(); | |
843 | if (listaods.Length()) listaods += ","; | |
844 | listaods += filename; | |
845 | listaods += ","; | |
846 | listaods += "pyxsec_hists.root"; | |
847 | } else { | |
848 | if (!strcmp(filename, "pyxsec_hists.root")) continue; | |
849 | if (listhists.Contains(filename)) continue; | |
850 | if (listhists.Length()) listhists += ","; | |
851 | listhists += filename; | |
852 | } | |
853 | } | |
854 | if (mgr->GetExtraFiles().Length()) { | |
855 | if (listaods.Length()) listaods += ","; | |
856 | listaods += mgr->GetExtraFiles(); | |
857 | listaods.ReplaceAll(" ", ","); | |
858 | } | |
859 | if (listhists.Length()) listhists = Form("hist_archive.zip:%s@%s", listhists.Data(), outputStorages.Data()); | |
860 | if (listaods.Length()) listaods = Form("aod_archive.zip:%s@%s", listaods.Data(), outputStorages.Data()); | |
861 | if (!listhists.Length() && !listaods.Length()) { | |
862 | ::Fatal("AnalysisTrainNew", "No task output !"); | |
863 | } | |
864 | TString outputArchive = Form("log_archive.zip:stderr@%s", outputStorages.Data()); | |
865 | if (listaods.Length()) { | |
866 | outputArchive += " "; | |
867 | outputArchive += listaods; | |
868 | } | |
869 | if (listhists.Length()) { | |
870 | outputArchive += " "; | |
871 | outputArchive += listhists; | |
872 | } | |
873 | // Set friends | |
874 | // if (iAODanalysis && iPWG3d2h) | |
875 | // plugin->SetFriendChainName("AliAOD.VertexingHF.root"); | |
876 | // plugin->SetOutputArchive(outputArchive); | |
877 | // Optionally set a name for the generated analysis macro (default MyAnalysis.C) | |
878 | plugin->SetAnalysisMacro(Form("%s.C", train_name.Data())); | |
879 | // Optionally set a name for the generated validation script | |
880 | plugin->SetValidationScript("PWG2validation.sh"); | |
881 | // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore) | |
882 | plugin->SetSplitMaxInputFileNumber(nFilesPerJob); | |
883 | // Optionally set number of failed jobs that will trigger killing waiting sub-jobs. | |
884 | // plugin->SetMaxInitFailed(5); | |
885 | // Optionally modify the number of replicas | |
886 | plugin->SetNumberOfReplicas(4); | |
887 | // Optionally resubmit threshold. | |
888 | // plugin->SetMasterResubmitThreshold(90); | |
889 | // Optionally set time to live (default 30000 sec) | |
890 | plugin->SetTTL(70000); | |
891 | // Optionally set input format (default xml-single) | |
892 | plugin->SetInputFormat("xml-single"); | |
893 | // Optionally modify the name of the generated JDL (default analysis.jdl) | |
894 | plugin->SetJDLName(Form("%s.jdl", train_name.Data())); | |
895 | // Optionally modify the executable name (default analysis.sh) | |
896 | plugin->SetExecutable(Form("%s.sh", train_name.Data())); | |
897 | // Optionally modify job price (default 1) | |
898 | plugin->SetPrice(1); | |
899 | // Merge via JDL | |
900 | plugin->SetMergeViaJDL(useMergeViaJDL); | |
901 | // Use fastread option | |
902 | plugin->SetFastReadOption(useFastReadOption); | |
903 | // UseOverwrite mode | |
904 | plugin->SetOverwriteMode(useOverwriteMode); | |
905 | plugin->SetExecutableCommand("aliroot -b -q"); | |
906 | // Optionally modify split mode (default 'se') | |
907 | plugin->SetSplitMode("se"); | |
908 | return plugin; | |
909 | } | |
910 | ||
911 | //______________________________________________________________________________ | |
912 | void WriteConfig() | |
913 | { | |
914 | // Write train configuration in a file. The file name has the format: | |
915 | // train_[trainName]_ddMonthyyyy_time.C | |
916 | if (useDATE) { | |
917 | gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp"); | |
918 | ifstream fdate("date.tmp"); | |
919 | if (!fdate.is_open()) { | |
920 | ::Error("AnalysisTrainNew.C::Export","Could not generate file name"); | |
921 | return; | |
922 | } | |
923 | const char date[64]; | |
924 | fdate.getline(date,64); | |
925 | fdate.close(); | |
926 | gSystem->Exec("rm date.tmp"); | |
927 | train_name = Form("%s_%s", train_name.Data(), date); | |
928 | } | |
929 | TString cdir = gSystem->WorkingDirectory(); | |
930 | gSystem->MakeDirectory(train_name); | |
931 | gSystem->ChangeDirectory(train_name); | |
932 | ofstream out; | |
933 | out.open(Form("%sConfig.C",train_name.Data()), ios::out); | |
934 | if (out.bad()) { | |
935 | ::Error("AnalysisTrainNew.C::Export", "Cannot open ConfigTrain.C for writing"); | |
936 | return; | |
937 | } | |
938 | out << "{" << endl; | |
939 | out << " train_name = " << "\"" << train_name.Data() << "\";" << endl; | |
940 | out << " proof_cluster = " << "\"" << proof_cluster.Data() << "\";" << endl; | |
941 | out << " useAFPAR = " << useAFPAR << ";" << endl; | |
942 | if (useAFPAR) | |
943 | out << " AFversion = " << AFversion.Data() << ";" << endl; | |
944 | out << " proof_dataset = " << "\"" << proof_dataset.Data() << "\";" << endl; | |
945 | out << " usePLUGIN = " << usePLUGIN << ";" << endl; | |
946 | out << " usePAR = " << usePAR << ";" << endl; | |
947 | out << " useCPAR = " << useCPAR << ";" << endl; | |
948 | out << " root_version = " << "\"" << root_version.Data() << "\";" << endl; | |
949 | out << " aliroot_version = " << "\"" << aliroot_version.Data() << "\";" << endl; | |
950 | out << " alien_datadir = " << "\"" << alien_datadir.Data() << "\";" << endl; | |
951 | if (!alien_outdir.Length()) alien_outdir = Form("output_%s",train_name.Data()); | |
952 | out << " alien_outdir = " << "\"" << alien_outdir.Data() << "\";" << endl; | |
953 | out << " maxMergeFiles = " << maxMergeFiles << ";" << endl; | |
954 | out << " mergeExclude = " << "\"" << mergeExclude.Data() << "\";" << endl; | |
955 | out << " nRunsPerMaster = " << nRunsPerMaster << ";" << endl; | |
956 | out << " nFilesPerJob = " << nFilesPerJob << ";" << endl; | |
957 | // for (Int_t i=0; i<10; i++) { | |
958 | // if (run_numbers[i]) | |
959 | // out << " run_numbers[" << i << "] = " << run_numbers[i] << ";" << endl; | |
960 | // } | |
961 | // out << " run_range[0] = " << run_range[0] << ";" << endl; | |
962 | // out << " run_range[1] = " << run_range[1] << ";" << endl; | |
963 | out << " usePhysicsSelection = " << usePhysicsSelection << ";" << endl; | |
964 | out << " useTender = " << useTender << ";" << endl; | |
965 | out << " useMergeViaJDL = " << useMergeViaJDL << ";" << endl; | |
966 | out << " useOverwriteMode = " << useOverwriteMode << ";" << endl; | |
967 | out << " useFastReadOption = " << useFastReadOption << ";" << endl; | |
968 | out << " useDBG = " << useDBG << ";" << endl; | |
969 | out << " useMC = " << useMC << ";" << endl; | |
970 | out << " useTAGS = " << useTAGS << ";" << endl; | |
971 | out << " useKFILTER = " << useKFILTER << ";" << endl; | |
972 | out << " useTR = " << useTR << ";" << endl; | |
973 | out << " useCORRFW = " << useCORRFW << ";" << endl; | |
974 | out << " useAODTAGS = " << useAODTAGS << ";" << endl; | |
975 | out << " saveTrain = " << "kFALSE;" << endl << endl; | |
976 | out << " // Analysis modules" << endl; | |
977 | out << " iAODanalysis = " << iAODanalysis << ";" << endl; | |
978 | out << " iAODhandler = " << iAODhandler << ";" << endl; | |
979 | out << " iPWG2fmd = " << iPWG2fmd << ";" << endl; | |
980 | out << " iPWG2femto = " << iPWG2femto << ";" << endl; | |
62e790f1 | 981 | out << " iPWG2spectra = " << iPWG2spectra << ";" << endl; |
a000cab6 | 982 | out << "}" << endl; |
983 | ::Info("AnalysisTrainNew.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", train_name.Data())); | |
984 | gSystem->ChangeDirectory(cdir); | |
985 | } | |
986 | ||
987 | //______________________________________________________________________________ | |
988 | Bool_t LoadConfig(const char *filename) | |
989 | { | |
990 | // Read train configuration from file | |
991 | if (gSystem->AccessPathName(filename)) { | |
992 | ::Error("AnalysisTrainNew.C::LoadConfig", "Config file name not found"); | |
993 | return kFALSE; | |
994 | } | |
995 | gROOT->ProcessLine(Form(".x %s", filename)); | |
996 | ::Info("AnalysisTrainNew.C::LoadConfig", "Train configuration loaded from file %s", filename); | |
997 | return kTRUE; | |
998 | } |