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