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