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