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