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