]>
Commit | Line | Data |
---|---|---|
c38e3b95 | 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) | |
121e4bd5 | 6 | // root[1] AnalysisTrainPWG-244Jets("grid", "full") |
c38e3b95 | 7 | // CAF mode (requires root v5-23-02 + aliroot v4-16-Rev08) |
8 | // root[2] AnalysisTrainPWG4Jets("proof") | |
9 | // Local mode requires AliESds.root or AliAOD.root in ./data directory | |
10 | // root[3] AnalysisTrainPWG4Jets("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] AnalysisTrainPWG4Jets(ana_mode, plugin_mode, "train_default_<date>/ConfigTrain.C") | |
17 | ||
18 | // For Usage with fastjet run in "offline" first and then "submit" | |
19 | // jdl and analysismacro are automatically patched after "offline" mode | |
20 | ||
21 | // ============================================================================= | |
22 | // ### General Steering variables | |
23 | // ============================================================================= | |
24 | //== general setup variables | |
25 | TString kTrainName = "testAnalysis"; // *CHANGE ME* (no blancs or special characters) | |
26 | TString kJobTag = "PWG4 Jet Tasks analysis train configured"; // *CHANGE ME* | |
27 | ||
28 | // Usage of par files ONLY in grid mode and ONLY if the code is not available | |
29 | // in the deployed AliRoot versions. Par file search path: local dir, if not there $ALICE_ROOT. | |
30 | // To refresh par files, remove the ones in the workdir, then do "make <target.par>" in | |
31 | // AliRoot. | |
32 | Bool_t kUsePAR = kFALSE; // use par files for extra libs | |
33 | Bool_t kUseCPAR = kFALSE; // use par files for common libs | |
34 | Bool_t kFillAOD = kFALSE; // switch of AOD filling for on the fly analysis | |
35 | ||
36 | //== general input and output variables | |
9a5c5b1e | 37 | |
c38e3b95 | 38 | Int_t iAODanalysis = 1; // Analysis on input AOD's |
39 | Int_t iAODhandler = 1; // Analysis produces an AOD or dAOD's | |
40 | Int_t iESDfilter = 0; // ESD to AOD filter (barrel + muon tracks) | |
e84da0a5 | 41 | Int_t iPhysicsSelection = 1; // ESD to AOD filter (barrel + muon tracks) |
c38e3b95 | 42 | Bool_t kUseKinefilter = kFALSE; // use Kinematics filter |
43 | Bool_t kUseMuonfilter = kFALSE; // use Kinematics filter | |
44 | TString kCommonOutputFileName = "PWG4_JetTasksOutput.root"; | |
45 | ||
46 | ||
47 | //== general process variables | |
48 | ||
49 | // ### Other flags to steer the analysis | |
50 | //============================================================================== | |
9a5c5b1e | 51 | Bool_t kSkipTerminate = kTRUE; // Do not call Teminate |
c38e3b95 | 52 | Bool_t kUseDate = kFALSE; // use date in train name |
53 | Bool_t kUseDebug = kTRUE; // activate debugging | |
c28abe00 | 54 | Int_t kUseSysInfo = 0; // activate debugging |
c38e3b95 | 55 | Bool_t kUseMC = kTRUE; // use MC info |
56 | Bool_t kIsMC = kTRUE; // is MC info, if false it overwrites Use(AOD)MC | |
57 | Bool_t kUseAODMC = kTRUE; // use MC infA | |
58 | Bool_t kUseESDTags = kFALSE; // use ESD tags for selection | |
59 | Bool_t kUseTR = kFALSE; // use track references | |
60 | Bool_t kUseAODTags = kFALSE; // use AOD tags | |
61 | Bool_t kSaveTrain = kFALSE; // save train configuration as: | |
62 | ||
9a5c5b1e | 63 | |
c38e3b95 | 64 | // ### Analysis modules to be included. Some may not be yet fully implemented. |
65 | //============================================================================== | |
66 | Int_t iJETAN = 1; // Jet analysis (PWG4) // 1 write standard 2 write non-standard jets, 3 wrtie both | |
67 | Int_t iDIJETAN = 1; | |
e6993a52 | 68 | Int_t iJETANLib = 1; |
c38e3b95 | 69 | Int_t iPWG1QASym = 0; // Eva's QA task compiled on the fly... |
70 | Int_t iPWG4JetTasks = 0; // all jet tasks flag for lib laoding | |
71 | Int_t iPWG4JetServices = 0; // jet spectrum analysis | |
72 | Int_t iPWG4JetSpectrum = 0; // jet spectrum analysis | |
73 | Int_t iPWG4UE = 0; // Underlying Event analysis | |
c166d299 | 74 | Int_t iPWG4TmpSourceSara = 0; // Underlying Event analysis not in svn |
75 | Int_t iPWG4TmpSourceFrag = 0; // Bastian's Fragmentation function not in svn | |
9f77f0ce | 76 | Int_t iPWG4JetChem = 0; // Jet chemistry |
c38e3b95 | 77 | Int_t iPWG4PtQAMC = 0; // Marta's QA tasks |
78 | Int_t iPWG4PtSpectra = 0; // Marta's QA tasks | |
79 | Int_t iPWG4PtQATPC = 0; // Marta's QA tasks | |
80 | Int_t iPWG4ThreeJets = 0; // Sona's thrust task | |
b53f2e4f | 81 | Int_t iPWG4KMeans = 0; // Andreas' KMeans task |
d2e6cdd5 | 82 | Int_t iPWG4Cluster = 0; // CKB cluster task |
911a740f | 83 | Int_t iPWG4PartCorrLibs = 0; // Gustavo's part corr analysis |
c38e3b95 | 84 | Int_t iPWG4PartCorr = 0; // Gustavo's part corr analysis |
d2e6cdd5 | 85 | Int_t iPWG4CaloQA = 0; // Gustavo's part corr analysis |
86 | Int_t iPWG4JetCorr = 0; // Paul's jet corr analysis | |
911a740f | 87 | Int_t iPWG4Tagged = 0; // Gustavo's part corr analysis |
121e4bd5 | 88 | Int_t iPWG4omega3pi = 0; // Omega to 3 pi analysis (PWG4) |
53c63663 | 89 | Int_t iPWG4GammaConv = 0; // Gamma Conversio |
c38e3b95 | 90 | Int_t kHighPtFilterMask = 16; // change depending on the used AOD Filter |
e6993a52 | 91 | TString kDeltaAODJetName = "AliAOD.Jets.root"; |
53c63663 | 92 | TString kDeltaAODPartCorrName = "deltaAODPartCorr.root"; |
c38e3b95 | 93 | |
94 | ||
95 | //============================================================================== | |
96 | // ### PROOF Steering varibales | |
97 | //============================================================================== | |
98 | //== proof setup variables | |
99 | TString kProofCluster = "alicecaf.cern.ch"; | |
100 | Bool_t kProofUseAFPAR = kFALSE; // use AF special par file | |
101 | TString kProofAFversion = "AF-v4-17"; | |
102 | //== proof input and output variables | |
103 | TString kProofDataSet = "/COMMON/COMMON/LHC09a4_run8100X#/esdTree"; | |
104 | Bool_t kProofSaveToAlien = kFALSE; // save proof outputs in AliEn train_[trainName]_ddMonthyyyy_time.C | |
105 | TString kProofOutdir = ""; | |
106 | Bool_t kProofClearPackages = kFALSE; | |
107 | Int_t kProofEvents = 10000; | |
108 | Int_t kProofOffset = 0; | |
109 | //== proof process variables | |
110 | ||
111 | ||
112 | //============================================================================== | |
113 | // ### Grid plugin Steering varibiables | |
114 | //============================================================================== | |
115 | //== grid plugin setup variables | |
116 | Bool_t kPluginUse = kTRUE; // do not change | |
117 | Bool_t kPluginUseProductionMode = kFALSE; // use the plugin in production mode | |
10295ac3 | 118 | TString kPluginRootVersion = "v5-26-00b-4"; // *CHANGE ME IF MORE RECENT IN GRID* |
3878a941 | 119 | TString kPluginAliRootVersion = "v4-19-04-AN"; // *CHANGE ME IF MORE RECENT IN GRID* |
9a5c5b1e | 120 | Bool_t kPluginMergeViaJDL = kTRUE; // merge via JDL |
121 | Bool_t kPluginFastReadOption = kFALSE; // use xrootd tweaks | |
122 | Bool_t kPluginOverwriteMode = kTRUE; // overwrite existing collections | |
dc6a7461 | 123 | Int_t kPluginOutputToRunNumber = 1; // write the output to subdirs named after run number |
c38e3b95 | 124 | // TString kPluginExecutableCommand = "root -b -q"; |
125 | TString kPluginExecutableCommand = "source /Users/kleinb/setup_32bit_aliroot_trunk_clean_root_trunk.sh; alienroot -b -q "; | |
9a5c5b1e | 126 | |
c38e3b95 | 127 | // == grid plugin input and output variables |
128 | TString kGridDatadir = "/alice/sim/PDC_08b/LHC09a1/AOD/"; | |
129 | TString kGridLocalRunList = ""; | |
130 | TString kGridOutdir = ""; // AliEn output directory. If blank will become output_<kTrainName> | |
3878a941 | 131 | TString kGridDataSet = ""; // sub working directory not to confuse different run xmls |
c38e3b95 | 132 | Int_t kGridRunRange[2] = {0, -1}; // Set the run range |
133 | TString kGridRunPattern = "%03d"; // important for leading zeroes!! | |
134 | TString kGridPassPattern = ""; | |
135 | TString kGridExtraFiles = ""; // files that will be added to the input list in the JDL... | |
136 | Int_t kGridMaxMergeFiles = 50; // Number of files merged in a chunkgridrunragn | |
137 | TString kGridMergeExclude = "AliAOD.root"; // Files that should not be merged | |
6408fe42 | 138 | TString kGridOutputStorages = "disk=2"; // Make replicas on the storages |
c38e3b95 | 139 | // == grid process variables |
c28abe00 | 140 | Int_t kGridRunsPerMaster = 100; // Number of runs per master job |
e84da0a5 | 141 | Int_t kGridFilesPerJob = 100; // Maximum number of files per job (gives size of AOD) |
c38e3b95 | 142 | |
143 | //============================================================================== | |
144 | // ### Local Steering variables | |
145 | //============================================================================== | |
146 | //== local setup variables | |
147 | //== local input and output variables | |
148 | TString kLocalXMLDataset = ""; // Change local xml dataset for local interactive analysis | |
149 | TString kLocalDataList = "local_deltaaod.txt"; // Change local xml dataset for local interactive analysis | |
150 | // == local process variables | |
151 | ||
152 | ||
153 | ||
154 | // Temporaries. | |
155 | TString anaPars = ""; | |
156 | TString anaLibs = ""; | |
e84da0a5 | 157 | TString anaLibsExtra = ""; |
c38e3b95 | 158 | TString anaSources = ""; |
159 | // Function signatures | |
160 | class AliAnalysisAlien; | |
161 | ||
162 | //______________________________________________________________________________ | |
163 | void AnalysisTrainPWG4Jets(const char *analysis_mode="local", | |
164 | const char *plugin_mode="", | |
165 | const char *config_file="",Int_t iOffset = 0) | |
166 | { | |
167 | // Main analysis train macro. If a configuration file is provided, all parameters | |
168 | // are taken from there but may be altered by CheckModuleFlags. | |
3878a941 | 169 | |
c38e3b95 | 170 | if (strlen(config_file) && !LoadConfig(config_file)) return; |
3878a941 | 171 | |
c38e3b95 | 172 | if(iOffset)kProofOffset = iOffset; |
173 | TString smode(analysis_mode); | |
174 | smode.ToUpper(); | |
175 | if (kSaveTrain)WriteConfig(); | |
176 | // Check compatibility of selected modules | |
177 | CheckModuleFlags(smode); | |
e84da0a5 | 178 | // gROOT->ProcessLine(".trace"); |
c38e3b95 | 179 | |
180 | printf("==================================================================\n"); | |
181 | printf("=========== RUNNING ANALYSIS TRAIN %s IN %s MODE ==========\n", kTrainName.Data(),smode.Data()); | |
182 | printf("==================================================================\n"); | |
183 | printf("= Configuring analysis train for: =\n"); | |
184 | if (iAODanalysis) printf("= AOD analysis =\n"); | |
185 | else printf("= ESD analysis =\n"); | |
e84da0a5 | 186 | if (iPhysicsSelection) printf("= Physics selection =\n"); |
c38e3b95 | 187 | if (iESDfilter) printf("= ESD filter =\n"); |
188 | if (iJETAN) printf("= Jet analysis =\n"); | |
189 | printf("==================================================================\n"); | |
d2e6cdd5 | 190 | printf(":: use Fill AOD %d\n", (UInt_t)kFillAOD); |
c38e3b95 | 191 | printf(":: use MC truth %d\n", (UInt_t)kUseMC); |
192 | printf(":: use KINE filter %d\n", (UInt_t)kUseKinefilter); | |
193 | printf(":: use track refs %d\n", (UInt_t)kUseTR); | |
194 | printf(":: use tags %d\n", (UInt_t)kUseESDTags); | |
195 | printf(":: use AOD tags %d\n", (UInt_t)kUseAODTags); | |
196 | printf(":: use debugging %d\n", (UInt_t)kUseDebug); | |
197 | printf(":: use PAR files %d\n", (UInt_t)kUsePAR); | |
198 | printf(":: use AliEn plugin %d\n", (UInt_t)kPluginUse); | |
53c63663 | 199 | printf(":: use PWG1 QA sym %d\n", iPWG1QASym); |
121e4bd5 | 200 | printf(":: use PWG4 Source Sara %d\n",iPWG4TmpSourceSara); |
c166d299 | 201 | printf(":: use PWG4 Source BB %d\n",iPWG4TmpSourceFrag); |
9f77f0ce | 202 | printf(":: use PWG4 Jet Chem %d\n",iPWG4JetChem); |
53c63663 | 203 | printf(":: use PWG4 Jet tasks %d\n",iPWG4JetTasks); |
204 | printf(":: use PWG4 Jet Services %d\n",iPWG4JetServices); | |
205 | printf(":: use PWG4 Jet Spectrum %d\n",iPWG4JetSpectrum); | |
206 | printf(":: use PWG4 UE %d \n",iPWG4UE); | |
207 | printf(":: use PWG4 Pt QA MC %d\n",iPWG4PtQAMC); | |
208 | printf(":: use PWG4 Pt Spectra %d\n",iPWG4PtSpectra); | |
209 | printf(":: use PWG4 Pt QA TPC %d\n",iPWG4PtQATPC); | |
210 | printf(":: use PWG4 Three Jets %d\n",iPWG4ThreeJets); | |
b53f2e4f | 211 | printf(":: use PWG4 KMeans %d\n",iPWG4KMeans); |
d2e6cdd5 | 212 | printf(":: use PWG4 Cluster %d\n",iPWG4Cluster); |
53c63663 | 213 | printf(":: use PWG4 Part Corr %d\n",iPWG4PartCorr); |
d2e6cdd5 | 214 | printf(":: use PWG4 Calo QA %d\n",iPWG4CaloQA); |
215 | printf(":: use PWG4 Jet Corr %d\n",iPWG4JetCorr); | |
911a740f | 216 | printf(":: use PWG4 Tagged %d\n",iPWG4Tagged); |
121e4bd5 | 217 | printf(":: use PWG4 omega to 3 pions %d\n",iPWG4omega3pi); |
218 | ||
53c63663 | 219 | printf(":: use PWG4 Gamma Conv %d\n",iPWG4GammaConv); |
220 | printf(":: use HighPt FilterMask %d\n",kHighPtFilterMask); | |
3878a941 | 221 | |
c38e3b95 | 222 | //========================================================================== |
223 | // Connect to back-end system | |
224 | if (!Connect(smode)) { | |
225 | ::Error("AnalysisTrain", "Could not connect to %s back-end", analysis_mode); | |
226 | return; | |
227 | } | |
228 | ||
229 | // Load common libraries and set include path | |
230 | if (!LoadCommonLibraries(smode)) { | |
231 | ::Error("AnalysisTrain", "Could not load common libraries"); | |
232 | return; | |
233 | } | |
3878a941 | 234 | |
235 | ||
c38e3b95 | 236 | |
237 | // Make the analysis manager and connect event handlers | |
e84da0a5 | 238 | AliAnalysisManager *mgr = new AliAnalysisManager("PWG4Train", "pwg4 mini train"); |
c38e3b95 | 239 | if (kCommonOutputFileName.Length()>0)mgr->SetCommonFileName(kCommonOutputFileName.Data()); |
240 | if (kProofSaveToAlien) mgr->SetSpecialOutputLocation(kProofOutdir); | |
4a6f59cb | 241 | mgr->SetNSysInfo(0); |
c38e3b95 | 242 | if (!strcmp(plugin_mode, "test")) mgr->SetNSysInfo(1); |
53c63663 | 243 | if (kUseSysInfo)mgr->SetNSysInfo(kUseSysInfo); |
9a5c5b1e | 244 | mgr->SetSkipTerminate(kSkipTerminate); |
4a6f59cb | 245 | |
c38e3b95 | 246 | // Load analysis specific libraries |
247 | if (!LoadAnalysisLibraries(smode)) { | |
248 | ::Error("AnalysisTrain", "Could not load analysis libraries"); | |
249 | return; | |
250 | } | |
251 | ||
252 | // Create input handler (input container created automatically) | |
253 | if (iAODanalysis) { | |
254 | // AOD input handler | |
255 | AliAODInputHandler *aodH = new AliAODInputHandler(); | |
256 | mgr->SetInputEventHandler(aodH); | |
e6993a52 | 257 | if (iPWG4JetTasks) aodH->AddFriend(Form("deltas/%s",kDeltaAODJetName.Data())); |
258 | if (iPWG4PartCorr) aodH->AddFriend(Form("deltas/%s"kDeltaAODJetName.Data())); | |
c38e3b95 | 259 | } else { |
260 | // ESD input handler | |
261 | AliESDInputHandler *esdHandler = new AliESDInputHandler(); | |
262 | if (kUseESDTags) esdHandler->SetReadTags(); | |
c166d299 | 263 | esdHandler->SetReadFriends(kFALSE); |
c38e3b95 | 264 | mgr->SetInputEventHandler(esdHandler); |
4a6f59cb | 265 | // if(iPWG4PtQATPC&& !kTrainName.Contains("pass5"))esdHandler->SetActiveBranches("ESDfriend"); |
c166d299 | 266 | |
c38e3b95 | 267 | } |
f4d11ac8 | 268 | |
c38e3b95 | 269 | // Monte Carlo handler |
270 | if (kUseMC && !iAODanalysis) { | |
271 | AliMCEventHandler* mcHandler = new AliMCEventHandler(); | |
272 | mgr->SetMCtruthEventHandler(mcHandler); | |
273 | mcHandler->SetReadTR(kUseTR); | |
274 | } | |
275 | // AOD output container, created automatically when setting an AOD handler | |
276 | if (iAODhandler) { | |
277 | // AOD output handler | |
278 | AliAODHandler* aodHandler = new AliAODHandler(); | |
279 | aodHandler->SetOutputFileName("AliAOD.root"); | |
6408fe42 | 280 | aodHandler->SetFillAODforRun(kFillAOD); |
c38e3b95 | 281 | |
282 | mgr->SetOutputEventHandler(aodHandler); | |
121e4bd5 | 283 | // |
c38e3b95 | 284 | if (iAODanalysis) { |
285 | ||
286 | // aodHandler->SetCreateNonStandardAOD(); | |
287 | // if (iJETAN)aodHandler->SetOutputFileName(kDeltaAODJetName.Data()); | |
288 | } | |
289 | AliAnalysisDataContainer * cout_aod = mgr->GetCommonOutputContainer(); | |
290 | cout_aod->SetSpecialOutput(); | |
291 | } | |
292 | // Debugging if needed | |
b03b08a3 | 293 | |
3878a941 | 294 | if (kUseDebug){ |
295 | mgr->SetDebugLevel(3); | |
296 | } | |
b03b08a3 | 297 | else{ |
298 | AliLog::SetGlobalLogLevel(AliLog::kError); | |
299 | } | |
c38e3b95 | 300 | //========================================================================== |
301 | // Create the chain. In this example it is created only from ALIEN files but | |
302 | // can be done to work in batch or grid mode as well. | |
303 | TChain *chain = CreateChain(smode, plugin_mode); | |
304 | ||
305 | //========================================================================== | |
306 | // Load the tasks configuration macros for all wagons. These files are supposed now to be | |
307 | // in the current workdir, but in AliEn they will be in the file catalog, | |
308 | // mapped from AliRoot and pecified in the jdl input list. | |
309 | ||
310 | // For now connection to top input container and common AOD output container | |
311 | // is done in this macro, but in future these containers will be connected | |
312 | // from each task configuration macro. | |
e84da0a5 | 313 | if(iPhysicsSelection && !iAODanalysis){ |
d2e6cdd5 | 314 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); |
d8f81b37 | 315 | AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kIsMC,kTRUE,kTRUE); // last flag also adds information on |
e84da0a5 | 316 | } |
317 | ||
c38e3b95 | 318 | if (iESDfilter && !iAODanalysis) { |
319 | // ESD filter task configuration. | |
320 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C"); | |
321 | AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(kUseKinefilter,kUseMuonfilter); | |
322 | } | |
323 | ||
324 | // AOD tags | |
325 | if (kUseAODTags) { | |
326 | AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator"); | |
327 | mgr->AddTask(tagTask); | |
328 | AliAnalysisDataContainer *coutTags = mgr->CreateContainer("cTag", TTree::Class(), | |
329 | AliAnalysisManager::kOutputContainer, "AOD.tag.root"); | |
330 | mgr->ConnectInput (tagTask, 0, mgr->GetCommonInputContainer()); | |
331 | mgr->ConnectOutput(tagTask, 1, coutTags); | |
332 | } | |
333 | ||
334 | // Jet analysis | |
335 | if (iJETAN) { | |
336 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJets.C"); | |
337 | AliAnalysisTaskJets *taskjets = 0; | |
338 | if(iJETAN&1)taskjets = AddTaskJets(kHighPtFilterMask); | |
b53f2e4f | 339 | if(iJETAN&2){ |
340 | UInt_t selection = 0; | |
d2e6cdd5 | 341 | if(!kFillAOD) selection = 0xffffff; //&~(1<<13); |
b53f2e4f | 342 | else selection = 1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9; |
343 | AddTaskJetsDelta(kDeltaAODJetName.Data(),kHighPtFilterMask,kUseAODMC,selection); | |
344 | } | |
c38e3b95 | 345 | if (!taskjets) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED"); |
346 | } | |
347 | ||
348 | if (iDIJETAN) { | |
349 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskDiJets.C"); | |
350 | AliAnalysisTaskDiJets *taskdijets = 0; | |
351 | taskdijets = AddTaskDiJets(); | |
352 | if (!taskdijets) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED"); | |
353 | } | |
354 | ||
c38e3b95 | 355 | if(iPWG1QASym){ |
99bfd7f7 | 356 | gROOT->LoadMacro("$ALICE_ROOT/PWG1/PWG1macros/AddTaskQAsym.C"); |
c38e3b95 | 357 | AliAnalysisTaskQASym *taskQASym = AddTaskQAsym(-1); |
358 | if (!taskQASym) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQASym cannot run for this train conditions - EXCLUDED"); | |
121e4bd5 | 359 | } |
c38e3b95 | 360 | |
121e4bd5 | 361 | |
362 | ||
363 | if(iPWG4TmpSourceSara){ | |
364 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskEta.C"); | |
365 | AliAnalysisTaskEta *taskEta = AddTaskEta(); | |
366 | if (!taskEta) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskEta cannot run for this train conditions - EXCLUDED"); | |
c38e3b95 | 367 | } |
368 | ||
c166d299 | 369 | if(iPWG4TmpSourceFrag){ |
370 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskFragFunc.C"); | |
371 | UInt_t selection = 1<<2; | |
372 | AliAnalysisTaskFragFunc *taskFrag = AddTaskFragFunc(kHighPtFilterMask, kUseAODMC,iPhysicsSelection, selection); | |
373 | if (!taskFrag) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskFragFunc cannot run for this train conditions - EXCLUDED"); | |
374 | } | |
375 | ||
c580ebbb | 376 | |
9f77f0ce | 377 | if(iPWG4JetChem){ |
378 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetChem.C"); | |
379 | AliAnalysisTask *taskChem = AddTaskJetChem(); | |
c580ebbb | 380 | if (!taskChem) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetChem cannot run for this train conditions - EXCLUDED"); |
381 | } | |
382 | ||
383 | ||
c38e3b95 | 384 | if(iPWG4JetServices){ |
385 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetServices.C"); | |
386 | AliAnalysisTaskJetServices *taskjetServ = 0; | |
387 | taskjetServ = AddTaskJetServices(); | |
388 | if (!taskjetServ) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetServices cannot run for this train conditions - EXCLUDED"); | |
53c63663 | 389 | if(kGridRunRange[0]>0)taskjetServ->SetRunRange(kGridRunRange[0],kGridRunRange[1]); |
0971dabc | 390 | else taskjetServ->SetRunRange(104000,125000); |
c28abe00 | 391 | if(!kIsMC) taskjetServ->SetRealData(kTRUE); |
dc6a7461 | 392 | taskjetServ->SetUsePhysicsSelection((Bool_t)iPhysicsSelection); |
9f77f0ce | 393 | taskjetServ->SetDebugLevel(0); |
c38e3b95 | 394 | } |
395 | ||
c38e3b95 | 396 | if(iPWG4JetSpectrum){ |
397 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetSpectrum2.C"); | |
398 | AliAnalysisTaskJetSpectrum2 *taskjetSpectrum = 0; | |
b53f2e4f | 399 | if(iPWG4JetSpectrum&1){ |
400 | taskjetSpectrum = AddTaskJetSpectrum2("jets","",kHighPtFilterMask,iPhysicsSelection); | |
e6993a52 | 401 | if(!iAODanalysis){ |
402 | taskjetSpectrum = AddTaskJetSpectrum2("jets","tracks32",32,iPhysicsSelection); // tmp hack to give it a different name | |
403 | taskjetSpectrum = AddTaskJetSpectrum2("jets","tracks64",64,iPhysicsSelection); | |
404 | } | |
d2e6cdd5 | 405 | if (!taskjetSpectrum) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetSpectrum2 cannot run for this train conditions - EXCLUDED"); |
3878a941 | 406 | taskjetSpectrum->SetDebugLevel(1); |
b53f2e4f | 407 | } |
d2e6cdd5 | 408 | |
e6993a52 | 409 | if(iPWG4JetSpectrum&2){ |
410 | UInt_t selection = 0; | |
411 | if(!iAODanalysis) selection = 0xffffff; | |
412 | else selection = 1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<7|1<<8|1<<9; | |
413 | AddTaskJetSpectrum2Delta(kHighPtFilterMask,kUseAODMC,iPhysicsSelection,selection); | |
414 | } | |
9a5c5b1e | 415 | if(iJETAN==3&&!kFillAOD&!iAODanalysis){ |
565584e8 | 416 | AddTaskJetSpectrum2("jetsAOD_FASTKT00","",kHighPtFilterMask,iPhysicsSelection); |
b53f2e4f | 417 | AddTaskJetSpectrum2("jetsAOD_FASTKT01","",kHighPtFilterMask,iPhysicsSelection); |
418 | AddTaskJetSpectrum2("jetsAOD_FASTKT02","",kHighPtFilterMask,iPhysicsSelection); | |
419 | AddTaskJetSpectrum2("jetsAOD_FASTKT06","",kHighPtFilterMask,iPhysicsSelection); | |
420 | AddTaskJetSpectrum2("jetsAOD_FASTKT08","",kHighPtFilterMask,iPhysicsSelection); | |
565584e8 | 421 | if(kIsMC){ |
565584e8 | 422 | AddTaskJetSpectrum2("jetsAODMC2b_FASTKT00","",kHighPtFilterMask,iPhysicsSelection); |
423 | AddTaskJetSpectrum2("jetsAODMC2b_FASTKT01","",kHighPtFilterMask,iPhysicsSelection); | |
424 | AddTaskJetSpectrum2("jetsAODMC2b_FASTKT02","",kHighPtFilterMask,iPhysicsSelection); | |
425 | AddTaskJetSpectrum2("jetsAODMC2b_FASTKT06","",kHighPtFilterMask,iPhysicsSelection); | |
426 | AddTaskJetSpectrum2("jetsAODMC2b_FASTKT08","",kHighPtFilterMask,iPhysicsSelection); | |
427 | } | |
b53f2e4f | 428 | } |
c38e3b95 | 429 | } |
c38e3b95 | 430 | if(iPWG4UE){ |
431 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskUE.C"); | |
432 | AliAnalysisTaskUE *taskUE = 0; | |
433 | if(iPWG4UE&1)taskUE = AddTaskUE(); | |
434 | if(iPWG4UE&2){ | |
b03b08a3 | 435 | taskUE = AddTaskUE("jetsAOD_CDF07","CDF","LJ","TRANSV","MSP"); |
436 | taskUE = AddTaskUE("jetsAOD_CDF07","CDF","LJCC","TRANSV","MSP"); | |
437 | taskUE = AddTaskUE("jetsAOD_CDF07","CDF","LJ","TRANSV","MAP"); | |
438 | taskUE = AddTaskUE("jetsAOD_ICDF","CDF","LJ","TRANSV","MSP"); | |
439 | taskUE = AddTaskUE("jetsAOD_ICDF","CDF","LJCC","TRANSV","MSP"); | |
440 | taskUE = AddTaskUE("jetsAOD_ICDF","CDF","LJCC","TRANSV","MAP"); | |
441 | taskUE = AddTaskUE("jetsAOD_NONE","CDF","MP","TRANSV","MSP"); | |
6408fe42 | 442 | taskUE = AddTaskUE("jetsAOD_NONE","CDF","MP","TRANSV","MAP"); |
443 | taskUE = AddTaskUE("jetsAOD_FASTKT04","CDF","LJ","TRANSV","MSP"); | |
b03b08a3 | 444 | taskUE = AddTaskUE("jetsAOD_FASTKT04","CDF","LJ","TRANSV","MAP"); |
c38e3b95 | 445 | } |
2bb1f4ca | 446 | |
c38e3b95 | 447 | if (!taskUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskUE cannot run for this train conditions - EXCLUDED"); |
448 | } | |
449 | ||
450 | if(iPWG4ThreeJets){ | |
451 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskThreeJets.C"); | |
452 | AliAnalysisTaskThreeJets *taskThree = AddTaskThreeJets(); | |
453 | if(!taskThree)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskThreets cannot run for this train conditions - EXCLUDED"); | |
454 | } | |
c38e3b95 | 455 | if(iPWG4PtQAMC){ |
456 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQAMC.C"); | |
457 | AliPWG4HighPtQAMC *taskQAMC = AddTaskPWG4HighPtQAMC(); | |
458 | if (!taskQAMC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQAMC cannot run for this train conditions - EXCLUDED"); | |
459 | } | |
460 | ||
461 | if(iPWG4PtQATPC){ | |
462 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQATPConly.C"); | |
10295ac3 | 463 | AliPWG4HighPtQATPConly *taskQATPC = 0; |
464 | if(iPWG4PtQATPC&1)taskQATPC = AddTaskPWG4HighPtQATPConly(1); | |
465 | if(iPWG4PtQATPC&2)taskQATPC = AddTaskPWG4HighPtQATPConly(2); | |
466 | ||
467 | if (!taskQATPC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQATPC cannot run for this train conditions - EXCLUDED"); | |
c38e3b95 | 468 | } |
3878a941 | 469 | |
c38e3b95 | 470 | if(iPWG4PtSpectra){ |
471 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtSpectra.C"); | |
472 | AliPWG4HighPtSpectra *taskPtSpectra = AddTaskPWG4HighPtSpectra(); | |
473 | if (!taskPtSpectra) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskPtSpectra cannot run for this train conditions - EXCLUDED"); | |
474 | } | |
b53f2e4f | 475 | if(iPWG4KMeans){ |
476 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskKMeans.C"); | |
477 | AliAnalysisTaskKMeans *taskKMeans = AddTaskKMeans(); | |
478 | if (!taskKMeans) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskKMenans cannot run for this train conditions - EXCLUDED"); | |
479 | } | |
480 | ||
d2e6cdd5 | 481 | if(iPWG4Cluster){ |
482 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetCluster.C"); | |
483 | AliAnalysisTaskJetCluster *taskCl = 0; | |
6408fe42 | 484 | if(iPWG4Cluster&1){ |
485 | taskCl = AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelection,"KT"); | |
6408fe42 | 486 | } |
d2e6cdd5 | 487 | if(iPWG4Cluster&2){ |
488 | UInt_t selection = 0; | |
489 | if(!iAODanalysis) selection = 0xffffff; | |
490 | else selection = 1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<7|1<<8|1<<9; | |
6408fe42 | 491 | AddTaskJetClusterDelta(kHighPtFilterMask,kUseAODMC,iPhysicsSelection,"KT",selection); |
0971dabc | 492 | } |
493 | if(iPWG4Cluster&4){ | |
494 | UInt_t selection = 0; | |
495 | if(!iAODanalysis) selection = 0xffffff; | |
496 | else selection = 1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<7|1<<8|1<<9; | |
497 | taskCl = AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelection,"CA"); | |
6408fe42 | 498 | AddTaskJetClusterDelta(kHighPtFilterMask,kUseAODMC,iPhysicsSelection,"CA",selection); |
d2e6cdd5 | 499 | } |
0971dabc | 500 | |
501 | ||
d2e6cdd5 | 502 | if (!taskCl) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskCluster cannot run for this train conditions - EXCLUDED"); |
503 | ||
504 | } | |
c38e3b95 | 505 | if(iPWG4PartCorr){ |
506 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPartCorr.C"); | |
14526afb | 507 | AliAnalysisTaskParticleCorrelation *taskpartcorrPHOS = AddTaskPartCorr("AOD", "PHOS",kFALSE,kIsMC); |
c38e3b95 | 508 | if (!taskpartcorrPHOS) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation PHOS cannot run for this train conditions - EXCLUDED"); |
14526afb | 509 | AliAnalysisTaskParticleCorrelation *taskpartcorrEMCAL = AddTaskPartCorr("AOD", "EMCAL",kFALSE,kIsMC); |
c38e3b95 | 510 | if (!taskpartcorrEMCAL) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation EMCAL cannot run for this train conditions - EXCLUDED"); |
511 | if(kDeltaAODPartCorrName.Length()>0)mgr->RegisterExtraFile(kDeltaAODPartCorrName.Data()); // hmm this is written anyway.... but at least we do not register it... | |
121e4bd5 | 512 | } |
513 | ||
d2e6cdd5 | 514 | if(iPWG4CaloQA){ |
515 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/QA/AddTaskCalorimeterQA.C"); | |
f4d11ac8 | 516 | AliAnalysisTaskParticleCorrelation *taskcaloQA = AddTaskCalorimeterQA("ESD",kFALSE,kIsMC); |
d2e6cdd5 | 517 | if(!taskcaloQA)::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation QA cannot run - EXCLUDED"); |
518 | } | |
519 | ||
d2e6cdd5 | 520 | if(iPWG4JetCorr){ |
521 | // using namespace JetCorrelHD; | |
522 | ||
523 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetCorrel.C"); | |
524 | AliAnalysisTaskJetCorrel *taskjetcorr = AddTaskJetCorrel(); | |
c166d299 | 525 | if (!taskjetcorr) ::Warning("AnalysisTrainNew", "AliAnalysisTaskJetCorrel cannot run for this train conditions - EXCLUDED"); |
d2e6cdd5 | 526 | } |
527 | ||
911a740f | 528 | if(iPWG4Tagged){ |
529 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskTaggedPhotons.C"); | |
530 | AliAnalysisTaskTaggedPhotons * taskTagged = AddTaskTaggedPhotons(kFALSE); // EMCAL | |
531 | // taskTagged = AddTaskTaggedPhotons(kTRUE); // PHOS | |
532 | if (!taskTagged) ::Warning("AnalysisTrainNew", "AliAnalysisTaskTaggedPhotons cannot run for this train conditions - EXCLUDED"); | |
533 | } | |
121e4bd5 | 534 | if (iPWG4omega3pi) { |
535 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskomega3pi.C"); | |
536 | AliAnalysisTaskOmegaPi0PiPi *taskomega3pi = AddTaskomega3pi(); | |
537 | if (!taskomega3pi) ::Warning("AnalysisTrainNew", "AliAnalysisTaskomega3pi cannot run\ | |
538 | for these train conditions - EXCLUDED"); | |
539 | } | |
540 | ||
53c63663 | 541 | // PWG4 gamma conversion analysis |
542 | if (iPWG4GammaConv) { | |
543 | gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskGammaConversion.C"); | |
544 | TString cdir = gSystem->WorkingDirectory(); | |
545 | gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/")); | |
546 | // TString gcArguments = "-run-on-train -run-jet -run-chic -run-neutralmeson -run-cf"; | |
d8f81b37 | 547 | TString gcArguments = "-run-on-train -run-jet -run-neutralmeson -run-cf -use-own-xyz"; |
53c63663 | 548 | if(!kIsMC)gcArguments += " -mc-off"; |
549 | AliAnalysisTaskGammaConversion * taskGammaConversion = AddTaskGammaConversion(gcArguments,mgr->GetCommonInputContainer()); | |
550 | gSystem->ChangeDirectory(cdir); | |
121e4bd5 | 551 | taskGammaConversion->SelectCollisionCandidates(); |
53c63663 | 552 | if (!taskGammaConversion) ::Warning("AnalysisTrainNew", "AliAnalysisTaskGammaConversion cannot run for these train conditions - EXCLUDED"); |
553 | } | |
554 | ||
3878a941 | 555 | |
c38e3b95 | 556 | //========================================================================== |
557 | // FOR THE REST OF THE TASKS THE MACRO AddTaskXXX() is not yet implemented/ | |
558 | // Run the analysis | |
559 | // | |
560 | if (kPluginUse) { | |
561 | AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode); | |
562 | AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler); | |
563 | } | |
564 | ||
565 | if (mgr->InitAnalysis()) { | |
566 | mgr->PrintStatus(); | |
567 | // if (kSaveTrain || strlen(config_file)) gSystem->ChangeDirectory(kTrainName); | |
e84da0a5 | 568 | if (!strcmp(plugin_mode,"submit")&&smode=="GRID"){ |
c38e3b95 | 569 | TString alien_workdir = gGrid->GetHomeDirectory(); |
570 | if (iAODanalysis) alien_workdir += "analysisAOD"; | |
571 | else alien_workdir += "analysisESD"; | |
3878a941 | 572 | if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data()); |
c38e3b95 | 573 | AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler(); |
e84da0a5 | 574 | printf("=== AnalysisTrainPWG4Jets:: Registering jdl in the work directory alien://%s/%s, should be done by the manager! ===\n", |
c38e3b95 | 575 | alien_workdir.Data(),gridhandler->GetGridOutputDir()); |
576 | TFile::Cp(Form("file:%s.jdl",kTrainName.Data()), Form("alien://%s/%s/%s.jdl",alien_workdir.Data(), | |
577 | gridhandler->GetGridOutputDir(),kTrainName.Data())); | |
578 | } | |
3878a941 | 579 | AliLog::SetGlobalLogLevel(AliLog::kError); |
c166d299 | 580 | if((kUseSysInfo>0&&smode=="LOCAL")||!strcmp(plugin_mode, "test")){ |
581 | TFile * fM = TFile::Open("manager_local.root","RECREATE"); | |
582 | mgr->Write(); | |
583 | fM->Close(); | |
584 | } | |
585 | ||
c38e3b95 | 586 | StartAnalysis(smode, chain); |
c166d299 | 587 | |
4a6f59cb | 588 | if((kUseSysInfo>0&&smode=="LOCAL")||!strcmp(plugin_mode, "test")){ |
589 | for(int i = 0;i < mgr->GetTopTasks()->GetEntries();i++){ | |
590 | mgr->ProfileTask(i); | |
591 | } | |
592 | } | |
c38e3b95 | 593 | if (!strcmp(plugin_mode, "offline")&&smode=="GRID"){ |
e84da0a5 | 594 | // Offline mode path files |
595 | // PatchJDL(); | |
596 | PatchAnalysisMacro(); | |
597 | } | |
c38e3b95 | 598 | |
e84da0a5 | 599 | if (kSaveTrain && smode=="GRID") { |
600 | AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler(); | |
601 | TString alien_workdir = gGrid->GetHomeDirectory(); | |
602 | if (iAODanalysis) alien_workdir += "analysisAOD"; | |
3878a941 | 603 | else alien_workdir += "analysisESD"; |
604 | if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data()); | |
e84da0a5 | 605 | // kGridOutdir = gridhandler->GetGridOutputDir(); |
606 | printf("=== Registering ConfigTrain.C in the work directory <%s> ===\n", | |
c38e3b95 | 607 | alien_workdir.Data()); |
e84da0a5 | 608 | if (AliAnalysisAlien::FileExists(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()))) |
609 | gGrid->Rm(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data())); | |
610 | if (strcmp(plugin_mode, "test")) | |
611 | TFile::Cp(Form("file:%sConfig.C",kTrainName.Data()), Form("alien://%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data())); | |
612 | } | |
613 | } | |
c38e3b95 | 614 | } |
615 | ||
616 | //______________________________________________________________________________ | |
617 | void StartAnalysis(const char *mode, TChain *chain) { | |
618 | // Start analysis. | |
619 | Int_t imode = -1; | |
620 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
621 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
622 | if (!strcmp(mode, "PROOF")) imode = 1; | |
623 | if (!strcmp(mode, "GRID")) imode = 2; | |
624 | switch (imode) { | |
625 | case 0: | |
626 | if (!chain) { | |
627 | ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain"); | |
628 | return; | |
629 | } | |
630 | mgr->StartAnalysis(mode, chain); | |
631 | return; | |
632 | case 1: | |
633 | if (!kProofDataSet.Length()) { | |
634 | ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "kProofDataSet is empty"); | |
635 | return; | |
636 | } | |
637 | mgr->StartAnalysis(mode, kProofDataSet, kProofEvents,kProofOffset); | |
638 | return; | |
639 | case 2: | |
640 | if (kPluginUse) { | |
641 | if (!mgr->GetGridHandler()) { | |
642 | ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Grid plugin not initialized"); | |
643 | return; | |
644 | } | |
645 | mgr->StartAnalysis("grid"); | |
646 | } else { | |
647 | if (!chain) { | |
648 | ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain"); | |
649 | return; | |
650 | } | |
651 | mgr->StartAnalysis(mode, chain); | |
652 | } | |
653 | return; | |
654 | } | |
655 | } | |
656 | ||
657 | //______________________________________________________________________________ | |
658 | void CheckModuleFlags(const char *mode) { | |
659 | // Checks selected modules and insure compatibility | |
660 | Int_t imode = -1; | |
661 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
662 | if (!strcmp(mode, "PROOF")) imode = 1; | |
663 | if (!strcmp(mode, "GRID")) imode = 2; | |
664 | ||
665 | ||
e84da0a5 | 666 | if (kUseCPAR) { |
667 | kPluginAliRootVersion = ""; // NO aliroot if we use CPAR | |
668 | } | |
c38e3b95 | 669 | |
670 | if (imode==1) { | |
671 | if (!kUsePAR) { | |
672 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis"); | |
673 | kUsePAR = kTRUE; | |
674 | } | |
675 | } | |
676 | if (imode != 2) { | |
677 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode"); | |
678 | kPluginUse = kFALSE; | |
679 | } | |
680 | ||
681 | ||
682 | if(!kIsMC){ | |
683 | // switch off anthin related to MC | |
684 | kUseMC = 0; | |
685 | kUseAODMC = 0; | |
686 | kUseTR = kFALSE; | |
687 | } | |
688 | ||
689 | if (iAODanalysis) { | |
690 | // AOD analysis | |
691 | if (kUseMC) | |
692 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's"); | |
693 | if (kUseAODTags) | |
694 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AOD tags usage disabled in analysis on AOD's"); | |
695 | kUseMC = kFALSE; | |
696 | kUseTR = kFALSE; | |
697 | kUseAODTags = kFALSE; | |
698 | if (iESDfilter) | |
699 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's"); | |
700 | iESDfilter = 0; | |
e84da0a5 | 701 | if (iPhysicsSelection) |
702 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "Physics Selection disabled in analysis on AOD's"); | |
703 | iPhysicsSelection = 0; | |
c38e3b95 | 704 | if (!iAODhandler) { |
705 | if (iJETAN) | |
706 | ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler"); | |
707 | iJETAN = 0; | |
708 | iDIJETAN = 0; | |
709 | } | |
710 | // Disable tasks that do not work yet on AOD data | |
711 | if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's"); | |
712 | iPWG4PtQAMC = 0; | |
713 | if( iPWG4PtQATPC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtTPC disabled in analysis on AOD's"); | |
714 | iPWG4PtQATPC = 0; | |
715 | if( iPWG4PtSpectra)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's"); | |
716 | iPWG4PtSpectra = 0; | |
b53f2e4f | 717 | if(iPWG4KMeans)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4KMeans disabled on AOD's"); |
718 | iPWG4KMeans = 0; | |
d2e6cdd5 | 719 | if (iPWG4JetCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4Jetcorr disabled on AOD's"); |
720 | iPWG4JetCorr = 0; | |
c38e3b95 | 721 | if (iPWG4PartCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4partcorr disabled on AOD's"); |
722 | iPWG4PartCorr = 0; | |
d2e6cdd5 | 723 | if (iPWG4CaloQA)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4CaloQA disabled on AOD's"); |
724 | iPWG4CaloQA = 0; | |
911a740f | 725 | if (iPWG4Tagged)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4tagged disabled on AOD's"); |
726 | iPWG4Tagged = 0; | |
121e4bd5 | 727 | if (iPWG4omega3pi) |
728 | ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4omega3pi disabled on AOD's"); | |
729 | iPWG4omega3pi = 0; | |
c38e3b95 | 730 | if(iPWG1QASym)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG1 QA Sym disabled in analysis on AOD's"); |
53c63663 | 731 | if (iPWG4GammaConv)::Info("AnalysisPWG4Jets.C::CheckModuleFlags", "PWG4gammaconv disabled on AOD's"); |
732 | iPWG4GammaConv = 0; | |
c38e3b95 | 733 | iPWG1QASym = 0; |
734 | } else { | |
735 | // ESD analysis | |
736 | if (!kUseMC){ | |
737 | kUseTR = kFALSE; | |
738 | ||
739 | if(kUseKinefilter)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Kine Filter disabled in analysis without MC"); | |
740 | kUseKinefilter = kFALSE; | |
741 | if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis without MC"); | |
742 | iPWG4PtQAMC = 0; | |
743 | ||
744 | } | |
745 | if (!kUseTR) { | |
c166d299 | 746 | if(iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "iPWG4QATPCMC disabled if not reading track references"); |
b03b08a3 | 747 | iPWG4PtQAMC = 0; |
c38e3b95 | 748 | } |
e84da0a5 | 749 | if (iJETAN){ |
750 | iESDfilter=1; | |
751 | } | |
c38e3b95 | 752 | if (!iESDfilter){ |
753 | kUseKinefilter = kFALSE; | |
754 | kUseMuonfilter = kFALSE; | |
755 | } | |
756 | if(!iJETAN){ | |
757 | iPWG4JetSpectrum = iPWG4UE = iPWG4ThreeJets = iDIJETAN = 0; | |
758 | } | |
759 | } | |
9f77f0ce | 760 | iPWG4JetTasks = iPWG4JetServices||iPWG4JetSpectrum||iPWG4UE||iPWG4PtQAMC||iPWG4PtSpectra||iPWG4PtQATPC||iPWG4ThreeJets||iPWG4JetChem; |
d2e6cdd5 | 761 | iPWG4PartCorrLibs = iPWG4PartCorr||iPWG4Tagged||iPWG4CaloQA; |
e6993a52 | 762 | iJETANLib = iPWG4JetTasks||iJETAN||iDIJETAN; |
c38e3b95 | 763 | if (iESDfilter) {iAODhandler=1;} |
764 | if (kUseKinefilter && !kUseMC) kUseKinefilter = kFALSE; | |
765 | if (kUseAODTags && !iAODhandler) kUseAODTags = kFALSE; | |
766 | ||
767 | ||
768 | ||
769 | } | |
770 | ||
771 | //______________________________________________________________________________ | |
772 | Bool_t Connect(const char *mode) { | |
773 | // Connect <username> to the back-end system. | |
774 | Int_t imode = -1; | |
775 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
776 | if (!strcmp(mode, "PROOF")) imode = 1; | |
777 | if (!strcmp(mode, "GRID")) imode = 2; | |
778 | TString username = gSystem->Getenv("alien_API_USER"); | |
779 | switch (imode) { | |
780 | case 0: | |
781 | break; | |
782 | case 1: | |
783 | if (!username.Length()) { | |
784 | ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \ | |
785 | 1. Have called: alien-token-init <username>\n \ | |
786 | 2. Have called: >source /tmp/gclient_env_$UID"); | |
787 | return kFALSE; | |
788 | } | |
789 | ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to PROOF cluster <%s>", | |
790 | username.Data(), kProofCluster.Data()); | |
791 | gEnv->SetValue("XSec.GSI.DelegProxy", "2"); | |
792 | // TProof::Open(Form("%s@%s:31093", username.Data(), kProofCluster.Data())); | |
793 | TProof::Open(Form("%s@%s", username.Data(), kProofCluster.Data())); | |
794 | if (!gProof) { | |
795 | if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch")) | |
796 | ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch"); | |
797 | return kFALSE; | |
798 | } | |
799 | if(kProofClearPackages)gProof->ClearPackages(); | |
800 | ||
801 | if(kProofSaveToAlien){ | |
802 | TGrid::Connect("alien://"); | |
803 | if (gGrid) { | |
804 | TString homedir = gGrid->GetHomeDirectory(); | |
805 | TString workdir = homedir + kTrainName; | |
806 | if (!gGrid->Cd(workdir)) { | |
807 | gGrid->Cd(homedir); | |
808 | if (gGrid->Mkdir(workdir)) { | |
809 | gGrid->Cd(kTrainName); | |
810 | ::Info("AnalysisTrainPWG4Jets::Connect()", "Directory %s created", gGrid->Pwd()); | |
811 | } | |
812 | } | |
813 | gGrid->Mkdir("proof_output"); | |
814 | gGrid->Cd("proof_output"); | |
815 | kProofOutdir = Form("alien://%s", gGrid->Pwd()); | |
816 | } | |
817 | } | |
818 | break; | |
819 | case 2: | |
820 | if (!username.Length()) { | |
821 | ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \ | |
822 | 1. Have called: alien-token-init <username>\n \ | |
823 | 2. Have called: >source /tmp/gclient_env_$UID"); | |
824 | return kFALSE; | |
825 | } | |
826 | if (kPluginUse && !gSystem->Getenv("alien_CLOSE_SE")) { | |
827 | ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), | |
828 | "When using the AliEn plugin it is preferable to define the \ | |
829 | variable alien_CLOSE_SE in your environment."); | |
830 | return kFALSE; | |
831 | } | |
832 | ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to AliEn ...", | |
833 | username.Data()); | |
834 | TGrid::Connect("alien://"); | |
835 | if (!gGrid || !gGrid->IsConnected()) return kFALSE; | |
836 | break; | |
837 | default: | |
838 | ::Error("AnalysisTrainPWG4Jets.C::Connect", "Unknown run mode: %s", mode); | |
839 | return kFALSE; | |
840 | } | |
841 | ::Info("AnalysisTrainPWG4Jets.C::Connect","Connected in %s mode", mode); | |
842 | return kTRUE; | |
843 | } | |
844 | ||
845 | //______________________________________________________________________________ | |
846 | Bool_t LoadCommonLibraries(const char *mode) | |
847 | { | |
848 | // Load common analysis libraries. | |
849 | Int_t imode = -1; | |
850 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
851 | if (!strcmp(mode, "PROOF")) imode = 1; | |
852 | if (!strcmp(mode, "GRID")) imode = 2; | |
853 | if (!gSystem->Getenv("ALICE_ROOT")) { | |
854 | ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Analysis train requires that analysis libraries are compiled with a local AliRoot"); | |
855 | return kFALSE; | |
856 | } | |
857 | Bool_t success = kTRUE; | |
858 | // ROOT libraries | |
859 | gSystem->Load("libTree.so"); | |
860 | gSystem->Load("libGeom.so"); | |
861 | gSystem->Load("libVMC.so"); | |
862 | gSystem->Load("libPhysics.so"); | |
863 | ||
864 | // Load framework classes. Par option ignored here. | |
865 | switch (imode) { | |
866 | case 0: | |
867 | case 2: | |
868 | if (kUseCPAR) { | |
869 | success &= LoadLibrary("STEERBase", mode, kTRUE); | |
870 | success &= LoadLibrary("ESD", mode, kTRUE); | |
871 | success &= LoadLibrary("AOD", mode, kTRUE); | |
872 | success &= LoadLibrary("ANALYSIS", mode, kTRUE); | |
873 | success &= LoadLibrary("ANALYSISalice", mode, kTRUE); | |
874 | success &= LoadLibrary("CORRFW", mode, kTRUE); | |
875 | } else { | |
876 | success &= LoadLibrary("libSTEERBase.so", mode); | |
877 | success &= LoadLibrary("libESD.so", mode); | |
878 | success &= LoadLibrary("libAOD.so", mode); | |
879 | success &= LoadLibrary("libANALYSIS.so", mode); | |
880 | success &= LoadLibrary("libANALYSISalice.so", mode); | |
881 | success &= LoadLibrary("libCORRFW.so", mode); | |
882 | gROOT->ProcessLine(".include $ALICE_ROOT/include"); | |
883 | } | |
884 | break; | |
885 | case 1: | |
886 | Int_t ires = -1; | |
887 | if (kProofUseAFPAR && !gSystem->AccessPathName(kProofAFversion)) ires = gProof->UploadPackage(kProofAFversion); | |
888 | if (ires < 0) { | |
889 | success &= LoadLibrary("STEERBase", mode); | |
890 | success &= LoadLibrary("ESD", mode); | |
891 | success &= LoadLibrary("AOD", mode); | |
892 | success &= LoadLibrary("ANALYSIS", mode); | |
893 | success &= LoadLibrary("ANALYSISalice", mode); | |
894 | success &= LoadLibrary("CORRFW", mode); | |
895 | } else { | |
896 | ires = gProof->EnablePackage(kProofAFversion); | |
897 | if (ires<0) success = kFALSE; | |
898 | success &= LoadLibrary("CORRFW", mode); | |
899 | } | |
900 | break; | |
901 | default: | |
902 | ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Unknown run mode: %s", mode); | |
903 | return kFALSE; | |
904 | } | |
905 | if (success) { | |
906 | ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: SUCCESS"); | |
907 | ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s", | |
908 | gSystem->GetIncludePath()); | |
909 | } else { | |
910 | ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: FAILED"); | |
911 | } | |
912 | ||
913 | return success; | |
914 | } | |
915 | ||
916 | //______________________________________________________________________________ | |
917 | Bool_t LoadAnalysisLibraries(const char *mode) | |
918 | { | |
919 | // Load common analysis libraries. | |
920 | Bool_t success = kTRUE; | |
921 | if (iESDfilter) { | |
922 | if (!LoadLibrary("PWG3base", mode, kTRUE) || | |
923 | !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE; | |
924 | } | |
925 | // JETAN | |
e6993a52 | 926 | if (iJETANLib) { |
b53f2e4f | 927 | // this part needs some rework in case we do not need the fastjed finders for processing |
928 | if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE; | |
c38e3b95 | 929 | if (!strcmp(mode, "PROOF")){ |
ef1e462f | 930 | gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libCGAL.so\"\)", kTRUE); |
c38e3b95 | 931 | gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libfastjet.so\"\)", kTRUE); |
932 | // problem when loading siscone copiled with different gcc version?? | |
933 | // gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libsiscone.so\"\)", kTRUE); | |
934 | gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libSISConePlugin.so\"\)", kTRUE); | |
935 | } | |
b53f2e4f | 936 | if(!kUsePAR){ |
e84da0a5 | 937 | if (!LoadLibrary("CGAL", mode, kTRUE)) return kFALSE; |
938 | if (!LoadLibrary("fastjet", mode, kTRUE)) return kFALSE; | |
939 | if (!LoadLibrary("siscone", mode, kTRUE)) return kFALSE; | |
940 | if (!LoadLibrary("SISConePlugin", mode, kTRUE)) return kFALSE; | |
941 | } | |
942 | else{ | |
943 | // par files plus FASTJET needs some extra work... need to change | |
944 | // the loading sequence in the auto generated .C file | |
945 | if (!LoadLibrary("libCGAL.so", mode, kTRUE)) return kFALSE; | |
946 | if (!LoadLibrary("libfastjet.so", mode, kTRUE)) return kFALSE; | |
947 | if (!LoadLibrary("libsiscone.so", mode, kTRUE)) return kFALSE; | |
948 | if (!LoadLibrary("libSISConePlugin.so", mode, kTRUE)) return kFALSE; | |
949 | } | |
c38e3b95 | 950 | if (!LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE; |
951 | } | |
952 | if(iPWG4JetTasks){ | |
953 | // PWG4 particle correlations | |
954 | if (!LoadLibrary("PWG4JetTasks", mode, kTRUE)) return kFALSE; | |
955 | } | |
956 | if(iPWG1QASym){ | |
99bfd7f7 | 957 | if (!LoadSource(Form("%s/PWG1/AliAnalysisTaskQASym.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE; |
c38e3b95 | 958 | } |
121e4bd5 | 959 | if(iPWG4TmpSourceSara){ |
c166d299 | 960 | if(!kUsePAR)gSystem->AddIncludePath("-I$ALICE_ROOT/include/JetTasks"); // ugly hack!! |
121e4bd5 | 961 | if(!LoadSource(Form("%s/PWG4/JetTasks/AliAnalysisTaskEta.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE; |
962 | } | |
c166d299 | 963 | if(iPWG4TmpSourceFrag){ |
964 | if(!kUsePAR)gSystem->AddIncludePath("-I$ALICE_ROOT/include/JetTasks"); // ugly hack!! | |
965 | if(!LoadSource(Form("%s/PWG4/JetTasks/AliAnalysisTaskFragFunc.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE; | |
966 | } | |
9f77f0ce | 967 | |
968 | /* | |
969 | if(iPWG4JetChem){ | |
c580ebbb | 970 | if(!kUsePAR)gSystem->AddIncludePath("-I$ALICE_ROOT/include/JetTasks"); // ugly hack!! |
971 | if(!LoadSource(Form("%s/PWG4/JetTasks/AliAnalysisTaskJetChem.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE; | |
972 | } | |
9f77f0ce | 973 | */ |
c166d299 | 974 | |
911a740f | 975 | if (iPWG4PartCorrLibs) { |
c38e3b95 | 976 | if (!LoadLibrary("EMCALUtils", mode, kTRUE) || |
977 | !LoadLibrary("PHOSUtils", mode, kTRUE) || | |
978 | !LoadLibrary("PWG4PartCorrBase", mode, kTRUE) || | |
979 | !LoadLibrary("PWG4PartCorrDep", mode, kTRUE)) return kFALSE; | |
980 | } | |
d2e6cdd5 | 981 | if (iPWG4JetCorr) { |
982 | if (!LoadLibrary("PWG4JetCorrel", mode, kTRUE)) return kFALSE; | |
983 | } | |
121e4bd5 | 984 | if (iPWG4omega3pi) { |
985 | if (!LoadLibrary("PWG4omega3pi", mode, kTRUE)) return kFALSE; | |
986 | } | |
53c63663 | 987 | if (iPWG4GammaConv) { |
988 | if (!LoadLibrary("PWG4GammaConv", mode, kTRUE)) return kFALSE; | |
989 | } | |
c38e3b95 | 990 | |
991 | ::Info("AnalysisTrainPWG4Jets.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS"); | |
992 | return kTRUE; | |
993 | } | |
994 | ||
995 | //______________________________________________________________________________ | |
996 | Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE) | |
997 | { | |
998 | // Load a module library in a given mode. Reports success. | |
999 | Int_t imode = -1; | |
1000 | Int_t result; | |
1001 | TString smodule(module); | |
1002 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
1003 | if (!strcmp(mode, "PROOF")) imode = 1; | |
1004 | if (!strcmp(mode, "GRID")) imode = 2; | |
1005 | TString mod(module); | |
1006 | if (!mod.Length()) { | |
1007 | ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Empty module name"); | |
1008 | return kFALSE; | |
1009 | } | |
1010 | // If a library is specified, just load it | |
1011 | if (smodule.EndsWith(".so")) { | |
1012 | mod.Remove(mod.Index(".so")); | |
1013 | result = gSystem->Load(mod); | |
1014 | if (result < 0) { | |
1015 | ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load library %s", module); | |
1016 | return kFALSE; | |
1017 | } | |
1018 | if (rec) anaLibs += Form("%s.so ",mod.Data()); | |
e84da0a5 | 1019 | if (rec) anaLibsExtra += Form("%s.so ",mod.Data()); |
c38e3b95 | 1020 | return kTRUE; |
1021 | } | |
1022 | // Check if the library is already loaded | |
1023 | if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0) | |
1024 | return kTRUE; | |
1025 | switch (imode) { | |
1026 | case 0: | |
1027 | case 2: | |
1028 | if (kUsePAR) { | |
1029 | result = SetupPar(module); | |
1030 | if (rec) anaPars += Form("%s.par ", module); | |
1031 | } else { | |
1032 | result = gSystem->Load(Form("lib%s.so", module)); | |
1033 | if (rec) anaLibs += Form("lib%s.so ", module); | |
1034 | } | |
1035 | break; | |
1036 | case 1: | |
1037 | if(!gSystem->AccessPathName(module)){ | |
1038 | ::Info("AnalysisTrainPWG4Jets.C::LoadLibrary", "Removing directory %s",module); | |
1039 | gSystem->Exec(Form("rm -rf %s",module)); | |
1040 | } | |
1041 | result = gProof->UploadPackage(module); | |
1042 | if (result<0) { | |
1043 | result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module))); | |
1044 | if (result<0) { | |
1045 | ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module); | |
1046 | return kFALSE; | |
1047 | } | |
1048 | } | |
1049 | result = gProof->EnablePackage(module); | |
1050 | break; | |
1051 | default: | |
1052 | return kFALSE; | |
1053 | } | |
1054 | if (result < 0) { | |
1055 | ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load module %s", module); | |
1056 | return kFALSE; | |
1057 | } | |
1058 | return kTRUE; | |
1059 | } | |
1060 | ||
1061 | ||
1062 | ||
1063 | //______________________________________________________________________________ | |
1064 | Bool_t LoadSource(const char *source, const char *mode, Bool_t rec=kFALSE) | |
1065 | { | |
1066 | // Load a module library in a given mode. Reports success. | |
1067 | Int_t imode = -1; | |
1068 | Int_t result = -1; | |
1069 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
1070 | if (!strcmp(mode, "PROOF")) imode = 1; | |
1071 | if (!strcmp(mode, "GRID")) imode = 2; | |
1072 | TString ssource(source); | |
1073 | TString basename = gSystem->BaseName(ssource.Data()); | |
1074 | if (!ssource.Length()) { | |
1075 | ::Error("AnalysisTrainPWG4Jets.C::LoadSource", "Empty task name"); | |
1076 | return kFALSE; | |
1077 | } | |
1078 | // we have a source code so compile it | |
1079 | if (ssource.EndsWith(".cxx")) { | |
1080 | // need to copy it here other wise the path is also used on grid... | |
1081 | ssource.Remove(ssource.Index(".cxx")); | |
1082 | basename.Remove(basename.Index(".cxx")); | |
1083 | Printf("LoadSources:: Copying... path %s{cxx,h}",ssource.Data()); | |
1084 | gSystem->Exec(Form("cp %s.cxx . ",ssource.Data())); | |
1085 | gSystem->Exec(Form("cp %s.h . ",ssource.Data())); | |
1086 | // Path to code | |
1087 | // only needed for local compilation, in grid and proof mode | |
1088 | // the task headers are uploaded | |
1089 | // path.Remove(path.Index(gSystem->BaseName(path.Data()))); | |
1090 | // Printf("LoadSources:: Including path %s",path.Data()); | |
1091 | // if(path.Length()>0)gROOT->ProcessLine(Form(".include %s",path.Data())); | |
1092 | Printf("LoadSources:: Loading... path %s",basename.Data()); | |
1093 | switch (imode) { | |
1094 | case 0: | |
b53f2e4f | 1095 | result = gROOT->LoadMacro(Form("%s.cxx++g",basename.Data())); |
c38e3b95 | 1096 | break; |
1097 | case 1: | |
b53f2e4f | 1098 | result = gProof->LoadMacro(Form("%s.cxx++g",basename.Data())); |
c38e3b95 | 1099 | break; |
1100 | case 2: | |
b53f2e4f | 1101 | result = gROOT->LoadMacro(Form("%s.cxx++g",basename.Data())); |
c38e3b95 | 1102 | if (rec){ |
1103 | // what we want to compile | |
1104 | anaSources += Form("%s.cxx ",basename.Data()); | |
1105 | // what we need as input... | |
1106 | anaLibs += Form("%s.cxx %s.h ",basename.Data(),basename.Data()); | |
1107 | } | |
1108 | break; | |
1109 | default: | |
1110 | return kFALSE; | |
1111 | } | |
1112 | } | |
1113 | if (result < 0) { | |
1114 | ::Error("AnalysisTrainPWG4Jets.C::LoadSources", "Could not load source %s", source); | |
1115 | return kFALSE; | |
1116 | } | |
1117 | return kTRUE; | |
1118 | } | |
1119 | ||
1120 | ||
1121 | //______________________________________________________________________________ | |
1122 | TChain *CreateChain(const char *mode, const char *plugin_mode) | |
1123 | { | |
1124 | // Create the input chain | |
1125 | Int_t imode = -1; | |
1126 | if (!strcmp(mode, "LOCAL")) imode = 0; | |
1127 | if (!strcmp(mode, "PROOF")) imode = 1; | |
1128 | if (!strcmp(mode, "GRID")) imode = 2; | |
1129 | TChain *chain = NULL; | |
1130 | // Local chain | |
1131 | switch (imode) { | |
1132 | case 0: | |
1133 | if (iAODanalysis) { | |
1134 | if (!kLocalXMLDataset.Length()) { | |
1135 | // Local AOD | |
1136 | chain = new TChain("aodTree"); | |
1137 | TString line; | |
1138 | ifstream in; | |
1139 | in.open(kLocalDataList.Data()); | |
1140 | while (in.good()) { | |
1141 | in >> line; | |
1142 | if (line.Length() == 0) continue; | |
1143 | // cout << " line = " << line << endl; | |
1144 | chain->Add(line.Data()); | |
1145 | } | |
1146 | } else { | |
1147 | // Interactive AOD | |
1148 | chain = CreateChainSingle(kLocalXMLDataset, "aodTree"); | |
1149 | } | |
1150 | } else { | |
1151 | if (!kLocalXMLDataset.Length()) { | |
1152 | // Local ESD | |
1153 | chain = new TChain("esdTree"); | |
1154 | TString line; | |
1155 | ifstream in; | |
1156 | in.open(kLocalDataList.Data()); | |
1157 | while (in.good()) { | |
1158 | in >> line; | |
1159 | if (line.Length() == 0) continue; | |
1160 | cout << " line = " << line << endl; | |
1161 | chain->Add(line.Data()); | |
1162 | } | |
1163 | } else { | |
1164 | // Interactive ESD | |
1165 | chain = CreateChainSingle(kLocalXMLDataset, "esdTree"); | |
1166 | } | |
1167 | } | |
1168 | break; | |
1169 | case 1: | |
1170 | break; | |
1171 | case 2: | |
1172 | if (kPluginUse) { | |
1173 | // AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode); | |
1174 | // AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler); | |
1175 | } else { | |
1176 | TString treeName = "esdTree"; | |
1177 | if (iAODanalysis) treeName = "aodTree"; | |
1178 | chain = CreateChainSingle("wn.xml", treeName); | |
1179 | } | |
1180 | break; | |
1181 | default: | |
1182 | } | |
1183 | if (chain && chain->GetNtrees()) return chain; | |
1184 | return NULL; | |
1185 | } | |
1186 | ||
1187 | //______________________________________________________________________________ | |
1188 | TChain* CreateChainSingle(const char* xmlfile, const char *treeName) | |
1189 | { | |
1190 | printf("*******************************\n"); | |
1191 | printf("*** Getting the ESD Chain ***\n"); | |
1192 | printf("*******************************\n"); | |
1193 | TAlienCollection * myCollection = TAlienCollection::Open(xmlfile); | |
1194 | ||
1195 | if (!myCollection) { | |
1196 | ::Error("AnalysisTrainPWG4Jets.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ; | |
1197 | return NULL ; | |
1198 | } | |
1199 | ||
1200 | TChain* chain = new TChain(treeName); | |
1201 | myCollection->Reset() ; | |
1202 | while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ; | |
1203 | chain->ls(); | |
1204 | return chain; | |
1205 | } | |
1206 | ||
1207 | //______________________________________________________________________________ | |
1208 | Int_t SetupPar(char* pararchivename) | |
1209 | { | |
1210 | if (!pararchivename || !strlen(pararchivename)) return -1; | |
1211 | char processline[1024]; | |
1212 | if (gSystem->AccessPathName(Form("%s.par", pararchivename))) { | |
1213 | if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) { | |
1214 | ::Info("AnalysisTrainPWG4Jets.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename); | |
1215 | TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)), | |
1216 | Form("%s.par",pararchivename)); | |
1217 | } else { | |
1218 | ::Error("AnalysisTrainPWG4Jets.C::SetupPar", "Cannot find %s.par", pararchivename); | |
1219 | return -1; | |
1220 | } | |
1221 | } | |
1222 | if (kPluginUse && kSaveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, kTrainName.Data())); | |
1223 | gSystem->Exec(Form("tar xvzf %s.par", pararchivename)); | |
1224 | ||
1225 | TString ocwd = gSystem->WorkingDirectory(); | |
1226 | if (!gSystem->ChangeDirectory(pararchivename)) return -1; | |
1227 | ||
1228 | // check for BUILD.sh and execute | |
1229 | if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) { | |
1230 | printf("*******************************\n"); | |
1231 | printf("*** Building PAR archive ***\n"); | |
1232 | printf("*******************************\n"); | |
1233 | if (gSystem->Exec("PROOF-INF/BUILD.sh")) { | |
1234 | Error("runProcess","Cannot Build the PAR Archive! - Abort!"); | |
1235 | return -1; | |
1236 | } | |
1237 | } | |
1238 | ||
1239 | // check for SETUP.C and execute | |
1240 | if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) { | |
1241 | printf("*******************************\n"); | |
1242 | printf("*** Setup PAR archive ***\n"); | |
1243 | printf("*******************************\n"); | |
1244 | gROOT->Macro("PROOF-INF/SETUP.C"); | |
1245 | } | |
1246 | if (!gSystem->ChangeDirectory(ocwd.Data())) return -1; | |
1247 | return 0; | |
1248 | } | |
1249 | ||
1250 | //______________________________________________________________________________ | |
1251 | AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode) | |
1252 | { | |
1253 | // Check if user has a valid token, otherwise make one. This has limitations. | |
1254 | // One can always follow the standard procedure of calling alien-token-init then | |
1255 | // source /tmp/gclient_env_$UID in the current shell. | |
1256 | if (!AliAnalysisGrid::CreateToken()) return NULL; | |
1257 | AliAnalysisAlien *plugin = new AliAnalysisAlien(); | |
1258 | // Set the run mode (can be "full", "test", "offline", "submit" or "terminate") | |
1259 | plugin->SetRunMode(plugin_mode); | |
1260 | if (kPluginUseProductionMode) plugin->SetProductionMode(); | |
1261 | plugin->SetJobTag(kJobTag); | |
1262 | plugin->SetNtestFiles(2); | |
1263 | // plugin->SetPreferedSE("ALICE::NIHAM::File"); | |
1264 | // Set versions of used packages | |
e84da0a5 | 1265 | plugin->SetAPIVersion("V1.1x"); |
1266 | // plugin->SetAPIVersion("V1.0x"); | |
1267 | // plugin->SetAPIVersion("V2.4"); | |
c38e3b95 | 1268 | plugin->SetROOTVersion(kPluginRootVersion); |
1269 | plugin->SetAliROOTVersion(kPluginAliRootVersion); | |
1270 | // Declare input data to be processed. | |
1271 | // Method 1: Create automatically XML collections using alien 'find' command. | |
1272 | // Define production directory LFN | |
1273 | plugin->SetGridDataDir(kGridDatadir.Data()); | |
1274 | // Set data search pattern | |
1275 | if (iAODanalysis) plugin->SetDataPattern(" *AliAOD.root"); | |
1276 | else plugin->SetDataPattern(Form(" %s/*/*ESD.tag.root",kGridPassPattern.Data())); | |
1277 | // ...then add run numbers to be considered | |
1278 | // plugin->SetRunRange(kGridRunRange[0], kGridRunRange[1]); | |
1279 | for (Int_t i=kGridRunRange[0]; i<=kGridRunRange[1]; i++) { | |
1280 | Printf("AnalysisTrainPWG4Jets Adding run number %s", Form(kGridRunPattern.Data(),i)); | |
1281 | plugin->AddRunNumber(Form(kGridRunPattern.Data(),i)); | |
1282 | } | |
1283 | ||
1284 | if(kGridLocalRunList.Length()>0){ | |
1285 | ifstream in1; | |
1286 | in1.open(kGridLocalRunList.Data()); | |
1287 | int iRun; | |
9a5c5b1e | 1288 | |
1289 | /* | |
e84da0a5 | 1290 | char c; |
1291 | char cLine[250]; | |
1292 | while(!in1.eof()){ | |
1293 | c = in1.get(); | |
1294 | if ( (c >= '0') && (c <= '9') ) | |
1295 | { | |
1296 | in1.putback (c); | |
1297 | in1>>iRun; | |
1298 | Printf("AnalysisTrainPWG4Jets Adding run number from File %s", Form(kGridRunPattern.Data(),iRun)); | |
1299 | plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun)); | |
1300 | } | |
1301 | else | |
1302 | { | |
1303 | in1.putback (c); | |
1304 | in1.getline(cLine,250); | |
9a5c5b1e | 1305 | |
1306 | } | |
1307 | } | |
1308 | */ | |
1309 | ||
1310 | // just use run numbers, negatives will be excluded | |
1311 | while(in1>>iRun){ | |
1312 | if(iRun>0){ | |
1313 | Printf("AnalysisTrainPWG4Jets Adding run number from File %s", Form(kGridRunPattern.Data(),iRun)); | |
1314 | plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun)); | |
1315 | } | |
1316 | else{ | |
1317 | Printf("AnalysisTrainPWG4Jets Skipping run number from File %d", iRun); | |
e84da0a5 | 1318 | } |
c38e3b95 | 1319 | } |
1320 | } | |
1321 | ||
1322 | // Method 2: Declare existing data files (raw collections, xml collections, root file) | |
1323 | // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir()) | |
1324 | // XML collections added via this method can be combined with the first method if | |
1325 | // the content is compatible (using or not tags) | |
1326 | // plugin->AddDataFile("tag.xml"); | |
1327 | // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root"); | |
1328 | // Define alien work directory where all files will be copied. Relative to alien $HOME. | |
3878a941 | 1329 | TString alien_workdir = ""; |
1330 | ||
1331 | if (iAODanalysis) alien_workdir += "analysisAOD"; | |
1332 | else alien_workdir += "analysisESD"; | |
1333 | if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data()); | |
1334 | plugin->SetGridWorkingDir(alien_workdir.Data()); | |
1335 | ||
c38e3b95 | 1336 | // Declare alien output directory. Relative to working directory. |
1337 | if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data()); | |
1338 | plugin->SetGridOutputDir(kGridOutdir); | |
1339 | ||
1340 | // Add external packages | |
1341 | if (iJETAN||iDIJETAN) { | |
1342 | plugin->AddExternalPackage("boost::v1_38_0"); | |
1343 | plugin->AddExternalPackage("cgal::v3.3.1"); | |
1344 | plugin->AddExternalPackage("fastjet::v2.4.0"); | |
1345 | } | |
1346 | ||
1347 | ||
1348 | // set extra libs before par file compilation | |
1349 | anaLibs += kGridExtraFiles; | |
1350 | anaLibs = anaLibs.Strip(); | |
e84da0a5 | 1351 | Printf("anaLibs %s",anaLibs.Data()); |
1352 | Printf("anaLibsExtra %s",anaLibsExtra.Data()); | |
1353 | ||
1354 | if (anaLibs.Length()) plugin->SetAdditionalLibs(anaLibs.Data()); | |
1355 | if (anaLibsExtra.Length()) plugin->SetAdditionalRootLibs(anaLibsExtra.Data()); | |
c38e3b95 | 1356 | |
1357 | TString ana_sources = ""; | |
1358 | TString ana_add = ""; | |
1359 | if (kUsePAR && anaPars.Length()) { | |
1360 | printf("%s\n", anaPars.Data()); | |
1361 | TObjArray *arr; | |
1362 | TObjString *objstr; | |
1363 | arr = anaPars.Tokenize(" "); | |
1364 | TIter next(arr); | |
1365 | while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString()); | |
1366 | delete arr; | |
1367 | } | |
1368 | ||
1369 | // Declare the analysis source files names separated by blancs. To be compiled runtime | |
1370 | // using ACLiC on the worker nodes. | |
1371 | ana_sources = anaSources.Strip(); | |
1372 | // Declare all libraries (other than the default ones for the framework. These will be | |
1373 | // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here. | |
1374 | ||
1375 | if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources); | |
1376 | plugin->SetExecutableCommand(kPluginExecutableCommand.Data()); | |
1377 | // Declare the output file names separated by blancs. | |
1378 | // (can be like: file.root or file.root@ALICE::Niham::File) | |
1379 | plugin->SetDefaultOutputs(); | |
1380 | plugin->SetMergeExcludes(kGridMergeExclude); | |
1381 | plugin->SetMaxMergeFiles(kGridMaxMergeFiles); | |
1382 | plugin->SetNrunsPerMaster(kGridRunsPerMaster); | |
9a5c5b1e | 1383 | plugin->SetMergeViaJDL(kPluginMergeViaJDL); |
1384 | // Use fastread option | |
1385 | plugin->SetFastReadOption(kPluginFastReadOption); | |
1386 | // UseOverwrite mode | |
1387 | plugin->SetOverwriteMode(kPluginOverwriteMode); | |
c38e3b95 | 1388 | // Optionally define the files to be archived. |
1389 | // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File"); | |
dc6a7461 | 1390 | plugin->SetOutputToRunNo(kPluginOutputToRunNumber); // write the output to subdirs named after run number |
c38e3b95 | 1391 | |
1392 | // Put default output files to archive | |
1393 | TString listhists = ""; | |
1394 | TString listaods = ""; | |
1395 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
1396 | TIter next(mgr->GetOutputs()); | |
1397 | AliAnalysisDataContainer *output; | |
1398 | while ((output=(AliAnalysisDataContainer*)next())) { | |
1399 | const char *filename = output->GetFileName(); | |
1400 | if (!(strcmp(filename, "default"))) { | |
53c63663 | 1401 | if (!mgr->GetOutputEventHandler()) continue; |
c38e3b95 | 1402 | filename = mgr->GetOutputEventHandler()->GetOutputFileName(); |
e84da0a5 | 1403 | if (listaods.Length()) listaods += " "; |
c38e3b95 | 1404 | listaods += filename; |
c38e3b95 | 1405 | } else { |
e84da0a5 | 1406 | if(!listhists.Contains(filename)){ |
1407 | if (listhists.Length()) listhists += " "; | |
c38e3b95 | 1408 | listhists += filename; |
1409 | } | |
1410 | } | |
1411 | } | |
53c63663 | 1412 | |
c28abe00 | 1413 | if(kUseSysInfo>0){ |
e84da0a5 | 1414 | if (listhists.Length()) listhists += " "; |
c28abe00 | 1415 | listhists += "syswatch.root"; |
53c63663 | 1416 | } |
1417 | ||
e84da0a5 | 1418 | if(kIsMC){ |
1419 | if (listaods.Length()) listaods += " "; | |
1420 | listaods += "pyxsec_hists.root"; | |
1421 | } | |
1422 | ||
1423 | ||
53c63663 | 1424 | if (mgr->GetExtraFiles().Length()) { |
e84da0a5 | 1425 | if (listaods.Length()) listaods += " "; |
53c63663 | 1426 | listaods += mgr->GetExtraFiles(); |
c38e3b95 | 1427 | } |
53c63663 | 1428 | |
1429 | // if we do not fill the aod we do not need to store it | |
e84da0a5 | 1430 | kGridMergeExclude = listaods; |
1431 | ||
1432 | if(!kFillAOD){ | |
1433 | listaods=""; | |
1434 | plugin->SetDefaultOutputs(kFALSE); | |
1435 | plugin->SetOutputFiles(listhists.Data()); | |
1436 | } | |
53c63663 | 1437 | |
e84da0a5 | 1438 | |
1439 | listaods.ReplaceAll(" ", ","); | |
1440 | listhists.ReplaceAll(" ", ","); | |
c38e3b95 | 1441 | if (listhists.Length()) listhists = Form("hist_archive.zip:%s@%s", listhists.Data(), kGridOutputStorages.Data());; |
1442 | if (listaods.Length()) listaods = Form("aod_archive.zip:%s@%s", listaods.Data(), kGridOutputStorages.Data());; | |
53c63663 | 1443 | |
c38e3b95 | 1444 | if (!listhists.Length() && !listaods.Length()) { |
1445 | ::Fatal("AnalysisTrainPWG4Jets", "No task output !"); | |
1446 | } | |
53c63663 | 1447 | |
e84da0a5 | 1448 | |
53c63663 | 1449 | |
b2d64ef3 | 1450 | TString outputArchive = "log_archive.zip:stdout,stderr@ALICE::FZK::SE,ALICE::GSI::SE"; |
1451 | if(kUseSysInfo>0)outputArchive = "log_archive.zip:stdout,stderr,syswatch.log@ALICE::FZK::SE,ALICE::GSI::SE"; | |
c38e3b95 | 1452 | if (listaods.Length()) { |
1453 | outputArchive += " "; | |
1454 | outputArchive += listaods; | |
1455 | } | |
1456 | if (listhists.Length()) { | |
1457 | outputArchive += " "; | |
1458 | outputArchive += listhists; | |
1459 | } | |
1460 | plugin->SetOutputArchive(outputArchive); | |
1461 | // Optionally set a name for the generated analysis macro (default MyAnalysis.C) | |
1462 | plugin->SetAnalysisMacro(Form("%s.C", kTrainName.Data())); | |
1463 | // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore) | |
1464 | plugin->SetSplitMaxInputFileNumber(kGridFilesPerJob); | |
1465 | // Optionally set number of failed jobs that will trigger killing waiting sub-jobs. | |
1466 | // plugin->SetMaxInitFailed(5); | |
1467 | // Optionally resubmit threshold. | |
1468 | // plugin->SetMasterResubmitThreshold(90); | |
1469 | // Optionally set time to live (default 30000 sec) | |
1470 | plugin->SetTTL(30000); | |
1471 | // Optionally set input format (default xml-single) | |
1472 | plugin->SetInputFormat("xml-single"); | |
1473 | // Optionally modify the name of the generated JDL (default analysis.jdl) | |
1474 | plugin->SetJDLName(Form("%s.jdl", kTrainName.Data())); | |
1475 | // Optionally modify the executable name (default analysis.sh) | |
1476 | plugin->SetExecutable(Form("%s.sh", kTrainName.Data())); | |
1477 | // Optionally modify job price (default 1) | |
1478 | plugin->SetPrice(1); | |
1479 | // Optionally modify split mode (default 'se') | |
1480 | plugin->SetSplitMode("se"); | |
1481 | return plugin; | |
1482 | } | |
1483 | ||
1484 | //______________________________________________________________________________ | |
1485 | void WriteConfig() | |
1486 | { | |
1487 | // Write train configuration in a file. The file name has the format: | |
1488 | // train_[trainName]_ddMonthyyyy_time.C | |
1489 | if (kUseDate) { | |
1490 | gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp"); | |
1491 | ifstream fdate("date.tmp"); | |
1492 | if (!fdate.is_open()) { | |
1493 | ::Error("AnalysisTrainPWG4Jets.C::Export","Could not generate file name"); | |
1494 | return; | |
1495 | } | |
1496 | const char date[64]; | |
1497 | fdate.getline(date,64); | |
1498 | fdate.close(); | |
1499 | gSystem->Exec("rm date.tmp"); | |
1500 | kTrainName = Form("train_%s_%s", kTrainName.Data(), date); | |
1501 | } else { | |
1502 | kTrainName = Form("train_%s", kTrainName.Data()); | |
1503 | } | |
1504 | TString cdir = gSystem->WorkingDirectory(); | |
1505 | gSystem->MakeDirectory(kTrainName); | |
1506 | gSystem->ChangeDirectory(kTrainName); | |
1507 | ofstream out; | |
1508 | out.open(Form("%sConfig.C",kTrainName.Data()), ios::out); | |
1509 | if (out.bad()) { | |
1510 | ::Error("AnalysisTrainPWG4Jets.C::Export", "Cannot open ConfigTrain.C for writing"); | |
1511 | return; | |
1512 | } | |
1513 | out << "{" << endl; | |
1514 | out << " kTrainName = " << "\"" << kTrainName.Data() << "\";" << endl; | |
1515 | out << " kProofCluster = " << "\"" << kProofCluster.Data() << "\";" << endl; | |
1516 | out << " kProofUseAFPAR = " << kProofUseAFPAR << ";" << endl; | |
1517 | if (kProofUseAFPAR) | |
1518 | out << " kProofAFversion = " << kProofAFversion.Data() << ";" << endl; | |
1519 | out << " kProofDataSet = " << "\"" << kProofDataSet.Data() << "\";" << endl; | |
1520 | out << " kPluginUse = " << kPluginUse << ";" << endl; | |
1521 | out << " kUsePAR = " << kUsePAR << ";" << endl; | |
1522 | out << " kUseCPAR = " << kUseCPAR << ";" << endl; | |
1523 | out << " kPluginRootVersion = " << "\"" << kPluginRootVersion.Data() << "\";" << endl; | |
1524 | out << " kPluginAliRootVersion = " << "\"" << kPluginAliRootVersion.Data() << "\";" << endl; | |
1525 | out << " kGridDatadir = " << "\"" << kGridDatadir.Data() << "\";" << endl; | |
1526 | if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data()); | |
1527 | out << " kGridOutdir = " << "\"" << kGridOutdir.Data() << "\";" << endl; | |
1528 | out << " kGridMaxMergeFiles = " << kGridMaxMergeFiles << ";" << endl; | |
1529 | out << " kGridMergeExclude = " << "\"" << kGridMergeExclude.Data() << "\";" << endl; | |
1530 | out << " kGridRunsPerMaster = " << kGridRunsPerMaster << ";" << endl; | |
1531 | out << " kGridFilesPerJob = " << kGridFilesPerJob << ";" << endl; | |
1532 | out << " kGridRunRange[0] = " << kGridRunRange[0] << ";" << endl; | |
1533 | out << " kGridRunRange[1] = " << kGridRunRange[1] << ";" << endl; | |
1534 | out << " kUseDebug = " << kUseDebug << ";" << endl; | |
1535 | out << " kUseMC = " << kUseMC << ";" << endl; | |
1536 | out << " kUseESDTags = " << kUseESDTags << ";" << endl; | |
1537 | out << " kUseKinefilter = " << kUseKinefilter << ";" << endl; | |
1538 | out << " kUseTR = " << kUseTR << ";" << endl; | |
1539 | out << " kUseAODTags = " << kUseAODTags << ";" << endl; | |
1540 | out << " kSaveTrain = " << "kFALSE;" << endl << endl; | |
1541 | out << " // Analysis modules" << endl; | |
1542 | out << " iAODanalysis = " << iAODanalysis << ";" << endl; | |
1543 | out << " iAODhandler = " << iAODhandler << ";" << endl; | |
1544 | out << " iESDfilter = " << iESDfilter << ";" << endl; | |
1545 | out << " iJETAN = " << iJETAN << ";" << endl; | |
1546 | out << "// Configuration fot the wagons" << endl; | |
1547 | out << "}" << endl; | |
1548 | ::Info("AnalysisTrainPWG4Jets.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", kTrainName.Data())); | |
1549 | gSystem->ChangeDirectory(cdir); | |
1550 | } | |
1551 | ||
1552 | //______________________________________________________________________________ | |
1553 | Bool_t LoadConfig(const char *filename) | |
1554 | { | |
1555 | // Read train configuration from file | |
1556 | if (gSystem->AccessPathName(filename)) { | |
1557 | ::Error("AnalysisTrainPWG4Jets.C::LoadConfig", "Config file name not found"); | |
1558 | return kFALSE; | |
1559 | } | |
1560 | gROOT->ProcessLine(Form(".x %s", filename)); | |
1561 | ::Info("AnalysisTrainPWG4Jets.C::LoadConfig", "Train configuration loaded from file %s", filename); | |
1562 | return kTRUE; | |
1563 | } | |
1564 | ||
1565 | Bool_t PatchJDL(){ | |
1566 | Printf(">>> Patching JDL"); | |
1567 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
1568 | AliAnalysisAlien* gridHandler = (AliAnalysisAlien*)mgr->GetGridHandler(); | |
1569 | TGridJDL *jdl = gridHandler->GetGridJDL(); | |
1570 | if(iJETAN)jdl->AddToPackages("fastjet","v2.4.0"); | |
1571 | gridHandler->WriteJDL(kFALSE); | |
0971dabc | 1572 | Printf("<<< Patching JDL"); |
c38e3b95 | 1573 | return kTRUE; |
1574 | } | |
1575 | ||
1576 | Bool_t PatchAnalysisMacro(){ | |
1577 | Printf(">>> Patching AnalysisMacro"); | |
1578 | gSystem->Exec(Form("mv %s.C %s.C_tmp",kTrainName.Data(),kTrainName.Data())); | |
1579 | ||
1580 | ifstream in1; | |
1581 | in1.open(Form("%s.C_tmp", kTrainName.Data())); | |
1582 | char cLine[250]; | |
1583 | TString st; | |
1584 | while(in1.getline(cLine,250)){ | |
1585 | st += cLine; | |
1586 | st += "\n"; | |
1587 | } | |
1588 | Int_t index; | |
1589 | index = st.Index("gSystem->Load(\"libPhysics\");"); | |
1590 | index += strlen("gSystem->Load(\"libPhysics\");"); | |
e84da0a5 | 1591 | if(iJETAN&&kUsePAR){ |
c38e3b95 | 1592 | TObjArray *arr; |
1593 | TObjString *objstr; | |
1594 | arr = anaLibs.Tokenize(" "); | |
1595 | TIter next(arr); | |
1596 | TString add = ""; | |
1597 | add += "\n\n // added by CKB \n"; | |
1598 | while ((objstr=(TObjString*)next())){ | |
e84da0a5 | 1599 | if(objstr->GetString().Contains("PWG3"))continue; |
c38e3b95 | 1600 | if(objstr->GetString().EndsWith(".so"))add += Form("gSystem->Load(\"%s\");\n",objstr->GetString().Data()); |
1601 | } | |
1602 | delete arr; | |
3878a941 | 1603 | // add += Form("AliLog::SetGlobalLogLevel(%d);\n",AliLog::GetGlobalLogLevel()); |
c38e3b95 | 1604 | add += "// BKC \n\n"; |
1605 | st.Insert(index,add.Data()); | |
1606 | } | |
e84da0a5 | 1607 | |
1608 | if(kUseDebug){ | |
1609 | st.Insert(index,"\n gROOT->ProcessLine(\".trace\"); // CKB \n"); | |
1610 | } | |
1611 | ||
c166d299 | 1612 | index = st.Index("gSystem->AddIncludePath"); |
1613 | st.Insert(index,"// CKB "); | |
1614 | ||
c38e3b95 | 1615 | ofstream out; |
1616 | out.open(Form("%s.C", kTrainName.Data())); | |
1617 | if (out.bad()) { | |
1618 | return kFALSE; | |
1619 | } | |
1620 | out << st << endl; | |
1621 | Printf("<<< Patching AnalysisMacro"); | |
1622 | return kTRUE; | |
1623 | ||
1624 | } |