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