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