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