added explicit option for particle type
[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");
7b90d977 1206 AddTaskPWG4HighPtTrackQAAll(kGridDataSet.Data(),kIsPbPb,iAODanalysis);
7b90d977 1207 }
1208
c38e3b95 1209 if(iPWG4PtQATPC){
34fc6450 1210 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQATPConly.C");
10295ac3 1211 AliPWG4HighPtQATPConly *taskQATPC = 0;
b1cd0099 1212 if(iPWG4PtQATPC&1)taskQATPC = AddTaskPWG4HighPtQATPConly(kGridDataSet.Data(),1);
1213 if(iPWG4PtQATPC&2)taskQATPC = AddTaskPWG4HighPtQATPConly(kGridDataSet.Data(),2);
10295ac3 1214
1215 if (!taskQATPC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQATPC cannot run for this train conditions - EXCLUDED");
c38e3b95 1216 }
3878a941 1217
1f329128 1218 if(iPWG4Cosmics){
34fc6450 1219 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4CosmicCandidates.C");
1f329128 1220
1221 AliPWG4CosmicCandidates *taskPWG4CosmicCandidates = AddTaskPWG4CosmicCandidates(0);
1222 taskPWG4CosmicCandidates = AddTaskPWG4CosmicCandidates(1);
1223
1224 if (!taskPWG4CosmicCandidates) ::Warning("AnalysisTrainPWG4Jets", "AddTaskPWG4CosmicCandidates cannot run for this train conditions - EXCLUDED");
1225 }
1226
1227
c38e3b95 1228 if(iPWG4PtSpectra){
34fc6450 1229 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtSpectra.C");
b6b70f4b 1230 AddTaskPWG4HighPtSpectraAll(kGridDataSet.Data(),kIsPbPb,iAODanalysis);
c38e3b95 1231 }
b6b70f4b 1232
b53f2e4f 1233 if(iPWG4KMeans){
34fc6450 1234 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskKMeans.C");
b53f2e4f 1235 AliAnalysisTaskKMeans *taskKMeans = AddTaskKMeans();
1236 if (!taskKMeans) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskKMenans cannot run for this train conditions - EXCLUDED");
1237 }
1238
c38e3b95 1239 if(iPWG4PartCorr){
34fc6450 1240 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPartCorr.C");
14526afb 1241 AliAnalysisTaskParticleCorrelation *taskpartcorrPHOS = AddTaskPartCorr("AOD", "PHOS",kFALSE,kIsMC);
c38e3b95 1242 if (!taskpartcorrPHOS) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation PHOS cannot run for this train conditions - EXCLUDED");
14526afb 1243 AliAnalysisTaskParticleCorrelation *taskpartcorrEMCAL = AddTaskPartCorr("AOD", "EMCAL",kFALSE,kIsMC);
c38e3b95 1244 if (!taskpartcorrEMCAL) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation EMCAL cannot run for this train conditions - EXCLUDED");
4721d8c5 1245 if(kDeltaAODPartCorrName.Length()>0)mgr->RegisterExtraFile(kDeltaAODPartCorrName.Data());
121e4bd5 1246 }
1247
d2e6cdd5 1248 if(iPWG4CaloQA){
34fc6450 1249 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/QA/AddTaskCalorimeterQA.C");
9748e967 1250 AliAnalysisTaskParticleCorrelation *taskcaloQA = AddTaskCalorimeterQA("ESD",kFALSE,kIsMC,kCaloQAOutputFileName.Data());
d2e6cdd5 1251 if(!taskcaloQA)::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation QA cannot run - EXCLUDED");
aba42fcb 1252 // if(kCaloQAOutputFileName.Length()>0)mgr->RegisterExtraFile(kCaloQAOutputFileName.Data());
d2e6cdd5 1253 }
1254
d2e6cdd5 1255 if(iPWG4JetCorr){
1256 // using namespace JetCorrelHD;
d3af0232 1257 TString cdir = gSystem->WorkingDirectory();
34fc6450 1258 gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/"));
1259 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetCorrel.C");
d2e6cdd5 1260 AliAnalysisTaskJetCorrel *taskjetcorr = AddTaskJetCorrel();
d3af0232 1261 gSystem->ChangeDirectory(cdir);
c166d299 1262 if (!taskjetcorr) ::Warning("AnalysisTrainNew", "AliAnalysisTaskJetCorrel cannot run for this train conditions - EXCLUDED");
d2e6cdd5 1263 }
1264
911a740f 1265 if(iPWG4Tagged){
34fc6450 1266 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskTaggedPhotons.C");
911a740f 1267 AliAnalysisTaskTaggedPhotons * taskTagged = AddTaskTaggedPhotons(kFALSE); // EMCAL
58ef946c 1268 taskTagged = AddTaskTaggedPhotons(kTRUE); // PHOS
911a740f 1269 if (!taskTagged) ::Warning("AnalysisTrainNew", "AliAnalysisTaskTaggedPhotons cannot run for this train conditions - EXCLUDED");
1270 }
121e4bd5 1271 if (iPWG4omega3pi) {
34fc6450 1272 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskomega3pi.C");
121e4bd5 1273 AliAnalysisTaskOmegaPi0PiPi *taskomega3pi = AddTaskomega3pi();
1274 if (!taskomega3pi) ::Warning("AnalysisTrainNew", "AliAnalysisTaskomega3pi cannot run\
1275 for these train conditions - EXCLUDED");
1276 }
1277
53c63663 1278 // PWG4 gamma conversion analysis
1279 if (iPWG4GammaConv) {
34fc6450 1280 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskGammaConversion.C");
53c63663 1281 TString cdir = gSystem->WorkingDirectory();
34fc6450 1282 gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/"));
53c63663 1283 // TString gcArguments = "-run-on-train -run-jet -run-chic -run-neutralmeson -run-cf";
58ef946c 1284 // TString gcArguments = "-run-on-train -run-jet -run-neutralmeson -run-cf -use-own-xyz";
1285 // TString gcArguments = "-run-on-train -run-jet -run-neutralmeson -run-cf -use-own-xyz";
b0a36f28 1286 TString gcArguments = "-run-on-train -run-jet -run-omega-meson -use-own-xyz -run-neutralmeson -no-aod";
27cdf9c4 1287 // TString kGCAnalysisCutSelectionId="9003562000100310";
cfd02305 1288 // TString kGCAnalysisCutSelectionId="9003562000100312";
1289 // gcArguments.Append(Form(" -set-cut-selection %s ",kGCAnalysisCutSelectionId.Data()));
53c63663 1290 if(!kIsMC)gcArguments += " -mc-off";
1291 AliAnalysisTaskGammaConversion * taskGammaConversion = AddTaskGammaConversion(gcArguments,mgr->GetCommonInputContainer());
1292 gSystem->ChangeDirectory(cdir);
121e4bd5 1293 taskGammaConversion->SelectCollisionCandidates();
53c63663 1294 if (!taskGammaConversion) ::Warning("AnalysisTrainNew", "AliAnalysisTaskGammaConversion cannot run for these train conditions - EXCLUDED");
1295 }
1296
17d96675 1297 if (iPWG4CaloConv) {
34fc6450 1298 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskCaloConv.C");
17d96675 1299 AliAnalysisTaskCaloConv * taskCaloConv = AddTaskCaloConv();
1300 if (!taskCaloConv) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCaloConv cannot run for these train conditions - EXCLUDED");
1301 }
1302
1303
3878a941 1304
c38e3b95 1305 //==========================================================================
1306 // FOR THE REST OF THE TASKS THE MACRO AddTaskXXX() is not yet implemented/
1307 // Run the analysis
1308 //
1309 if (kPluginUse) {
1310 AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
1311 AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
1312 }
1313
1314 if (mgr->InitAnalysis()) {
1315 mgr->PrintStatus();
1316 // if (kSaveTrain || strlen(config_file)) gSystem->ChangeDirectory(kTrainName);
e84da0a5 1317 if (!strcmp(plugin_mode,"submit")&&smode=="GRID"){
c38e3b95 1318 TString alien_workdir = gGrid->GetHomeDirectory();
1319 if (iAODanalysis) alien_workdir += "analysisAOD";
1320 else alien_workdir += "analysisESD";
c22feddd 1321 if(kGridDataSet.Length()>0)alien_workdir += Form("/%s%s",kGridDataSet.Data(),kGridExtraAliendirLevel.Data());
c38e3b95 1322 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
e84da0a5 1323 printf("=== AnalysisTrainPWG4Jets:: Registering jdl in the work directory alien://%s/%s, should be done by the manager! ===\n",
c38e3b95 1324 alien_workdir.Data(),gridhandler->GetGridOutputDir());
58ef946c 1325
1326 TString dest;
1327 dest = Form("%s/%s/%s.jdl",alien_workdir.Data(),gridhandler->GetGridOutputDir(),kTrainName.Data());
1328 if(AliAnalysisAlien::FileExists(dest.Data())){
bbb42949 1329 Printf("%s exist on grid removing...",dest.Data());
1330 gGrid->Rm(dest.Data());
58ef946c 1331 }
bbb42949 1332 Printf("%s copy ...",dest.Data());
58ef946c 1333 TFile::Cp(Form("file:%s.jdl",kTrainName.Data()),Form("alien://%s",dest.Data()));
4721d8c5 1334
1335
1336 TString dest;
1337 dest = Form("%s/%s/%s_merge.jdl",alien_workdir.Data(),gridhandler->GetGridOutputDir(),kTrainName.Data());
1338 if(AliAnalysisAlien::FileExists(dest.Data())){
bbb42949 1339 Printf("%s exist on grid removing...",dest.Data());
1340 gGrid->Rm(dest.Data());
4721d8c5 1341 }
bbb42949 1342 Printf("%s copy ...",dest.Data());
4721d8c5 1343 TFile::Cp(Form("file:%s_merge.jdl",kTrainName.Data()),Form("alien://%s",dest.Data()));
f84df50f 1344
bbb42949 1345 dest = Form("%s/%s/%s_merge_final.jdl",alien_workdir.Data(),gridhandler->GetGridOutputDir(),kTrainName.Data());
1346 if(AliAnalysisAlien::FileExists(dest.Data())){
1347 Printf("%s exist on grid removing...",dest.Data());
1348 gGrid->Rm(dest.Data());
1349 }
1350 Printf("%s copy ...",dest.Data());
1351 TFile::Cp(Form("file:%s_merge.jdl",kTrainName.Data()),Form("alien://%s",dest.Data()));
c38e3b95 1352 }
3878a941 1353 AliLog::SetGlobalLogLevel(AliLog::kError);
c166d299 1354 if((kUseSysInfo>0&&smode=="LOCAL")||!strcmp(plugin_mode, "test")){
1355 TFile * fM = TFile::Open("manager_local.root","RECREATE");
1356 mgr->Write();
1357 fM->Close();
1358 }
46534866 1359
1360 // grmpf, aliroot error handler overwrites root
1361 gErrorIgnoreLevel = kErrorIgnoreLevel;
1362 if(gErrorIgnoreLevel>3000) AliLog::SetGlobalLogLevel(AliLog::kFatal);
c38e3b95 1363 StartAnalysis(smode, chain);
4a6f59cb 1364 if((kUseSysInfo>0&&smode=="LOCAL")||!strcmp(plugin_mode, "test")){
1365 for(int i = 0;i < mgr->GetTopTasks()->GetEntries();i++){
1366 mgr->ProfileTask(i);
1367 }
1368 }
c38e3b95 1369 if (!strcmp(plugin_mode, "offline")&&smode=="GRID"){
e84da0a5 1370 // Offline mode path files
1371 // PatchJDL();
d8f21f85 1372 // PatchAnalysisMacro();
e84da0a5 1373 }
c38e3b95 1374
e84da0a5 1375 if (kSaveTrain && smode=="GRID") {
1376 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
1377 TString alien_workdir = gGrid->GetHomeDirectory();
1378 if (iAODanalysis) alien_workdir += "analysisAOD";
3878a941 1379 else alien_workdir += "analysisESD";
c22feddd 1380 if(kGridDataSet.Length()>0)alien_workdir += Form("/%s%s",kGridDataSet.Data(),kGridExtraAliendirLevel.Data());
e84da0a5 1381 // kGridOutdir = gridhandler->GetGridOutputDir();
1382 printf("=== Registering ConfigTrain.C in the work directory <%s> ===\n",
c38e3b95 1383 alien_workdir.Data());
e84da0a5 1384 if (AliAnalysisAlien::FileExists(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data())))
1385 gGrid->Rm(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()));
1386 if (strcmp(plugin_mode, "test"))
1387 TFile::Cp(Form("file:%sConfig.C",kTrainName.Data()), Form("alien://%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()));
1388 }
1389 }
c38e3b95 1390}
1391
1392//______________________________________________________________________________
1393void StartAnalysis(const char *mode, TChain *chain) {
1394// Start analysis.
1395 Int_t imode = -1;
1396 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1397 if (!strcmp(mode, "LOCAL")) imode = 0;
1398 if (!strcmp(mode, "PROOF")) imode = 1;
1399 if (!strcmp(mode, "GRID")) imode = 2;
1400 switch (imode) {
1401 case 0:
1402 if (!chain) {
1403 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain");
1404 return;
1405 }
82ebd295 1406 mgr->StartAnalysis(mode, chain,kNumberOfEvents);
c38e3b95 1407 return;
1408 case 1:
1409 if (!kProofDataSet.Length()) {
1410 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "kProofDataSet is empty");
1411 return;
1412 }
1413 mgr->StartAnalysis(mode, kProofDataSet, kProofEvents,kProofOffset);
1414 return;
1415 case 2:
1416 if (kPluginUse) {
1417 if (!mgr->GetGridHandler()) {
1418 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Grid plugin not initialized");
1419 return;
1420 }
ebad39a9 1421 mgr->StartAnalysis("grid",chain,kNumberOfEvents);
c38e3b95 1422 } else {
1423 if (!chain) {
1424 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain");
1425 return;
1426 }
d5e8640d 1427 // mgr->StartAnalysis(mode, chain);
ebad39a9 1428 mgr->StartAnalysis(mode, chain,kNumberOfEvents);
c38e3b95 1429 }
1430 return;
1431 }
1432}
1433
1434//______________________________________________________________________________
1435void CheckModuleFlags(const char *mode) {
1436// Checks selected modules and insure compatibility
1437 Int_t imode = -1;
1438 if (!strcmp(mode, "LOCAL")) imode = 0;
1439 if (!strcmp(mode, "PROOF")) imode = 1;
1440 if (!strcmp(mode, "GRID")) imode = 2;
1441
1442
e84da0a5 1443 if (kUseCPAR) {
1444 kPluginAliRootVersion = ""; // NO aliroot if we use CPAR
1445 }
c38e3b95 1446
1447 if (imode==1) {
1448 if (!kUsePAR) {
1449 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis");
1450 kUsePAR = kTRUE;
1451 }
1452 }
1453 if (imode != 2) {
1454 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode");
1455 kPluginUse = kFALSE;
1456 }
1457
1458
1459 if(!kIsMC){
1460 // switch off anthin related to MC
1461 kUseMC = 0;
1462 kUseAODMC = 0;
1463 kUseTR = kFALSE;
1464 }
1465
f4132e7d 1466 // Decide if we have PbPb
1c79997e 1467 if(kGridDataSet.CompareTo("LHC10h")==0||kGridDataSet.Contains("LHC10h")) {
1468 Printf("Using settings for Pb+Pb");
f4132e7d 1469 kIsPbPb = true;
1470 }
1471
1472
1473
c38e3b95 1474 if (iAODanalysis) {
1475 // AOD analysis
1476 if (kUseMC)
1477 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's");
1478 if (kUseAODTags)
1479 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AOD tags usage disabled in analysis on AOD's");
1480 kUseMC = kFALSE;
1481 kUseTR = kFALSE;
1482 kUseAODTags = kFALSE;
1483 if (iESDfilter)
1484 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's");
1485 iESDfilter = 0;
e84da0a5 1486 if (iPhysicsSelection)
1487 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "Physics Selection disabled in analysis on AOD's");
1488 iPhysicsSelection = 0;
c38e3b95 1489 if (!iAODhandler) {
1490 if (iJETAN)
1491 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler");
1492 iJETAN = 0;
1493 iDIJETAN = 0;
1494 }
1495 // Disable tasks that do not work yet on AOD data
58ef946c 1496 if(iPWG4JCORRAN)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 JCORRAN disabled in analysis on AOD's");
4d62ae1a 1497 iPWG4JCORRAN = 0;
c38e3b95 1498 if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's");
1499 iPWG4PtQAMC = 0;
1500 if( iPWG4PtQATPC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtTPC disabled in analysis on AOD's");
1501 iPWG4PtQATPC = 0;
1f329128 1502 if( iPWG4Cosmics)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Comics disabled in analysis on AOD's");
1503 iPWG4Cosmics = 0;
1504
b53f2e4f 1505 if(iPWG4KMeans)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4KMeans disabled on AOD's");
1506 iPWG4KMeans = 0;
d2e6cdd5 1507 if (iPWG4JetCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4Jetcorr disabled on AOD's");
1508 iPWG4JetCorr = 0;
c38e3b95 1509 if (iPWG4PartCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4partcorr disabled on AOD's");
1510 iPWG4PartCorr = 0;
d2e6cdd5 1511 if (iPWG4CaloQA)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4CaloQA disabled on AOD's");
1512 iPWG4CaloQA = 0;
911a740f 1513 if (iPWG4Tagged)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4tagged disabled on AOD's");
1514 iPWG4Tagged = 0;
121e4bd5 1515 if (iPWG4omega3pi)
1516 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4omega3pi disabled on AOD's");
1517 iPWG4omega3pi = 0;
c38e3b95 1518 if(iPWG1QASym)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG1 QA Sym disabled in analysis on AOD's");
53c63663 1519 if (iPWG4GammaConv)::Info("AnalysisPWG4Jets.C::CheckModuleFlags", "PWG4gammaconv disabled on AOD's");
1520 iPWG4GammaConv = 0;
c38e3b95 1521 iPWG1QASym = 0;
f4132e7d 1522 iCentralitySelection = 0;
c38e3b95 1523 } else {
1524 // ESD analysis
f4132e7d 1525
1526 if(kIsPbPb){
1527 iCentralitySelection = 1;
1528 }
1529
c38e3b95 1530 if (!kUseMC){
1531 kUseTR = kFALSE;
1532
1533 if(kUseKinefilter)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Kine Filter disabled in analysis without MC");
1534 kUseKinefilter = kFALSE;
1535 if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis without MC");
1536 iPWG4PtQAMC = 0;
9748e967 1537 if( iPWG4CorrectionsUE)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 CorrectionsUE disabled in analysis without MC");
1538 iPWG4CorrectionsUE = 0;
c38e3b95 1539 }
e84da0a5 1540 if (iJETAN){
1541 iESDfilter=1;
1542 }
c38e3b95 1543 if (!iESDfilter){
1544 kUseKinefilter = kFALSE;
1545 kUseMuonfilter = kFALSE;
1546 }
1547 if(!iJETAN){
cc636095 1548 iPWG4JetSpectrum = iPWG4UE = iPWG4CorrectionsUE = iPWG4ThreeJets = iPWG4QGSep = iDIJETAN = 0;
c38e3b95 1549 }
1550 }
7b90d977 1551 iPWG4JetTasks = iPWG4JetServices||iPWG4JetSpectrum||iPWG4UE||iPWG4LeadingUE||iPWG4PtQAMC||iPWG4PtTrackQA||iPWG4PtSpectra||iPWG4PtQATPC||iPWG4Cosmics||iPWG4ThreeJets||iPWG4QGSep||iPWG4JetChem||iPWG4Minijet||iPWG4Fragmentation;
d2e6cdd5 1552 iPWG4PartCorrLibs = iPWG4PartCorr||iPWG4Tagged||iPWG4CaloQA;
17d96675 1553 iPWG4GammaConvLib = iPWG4GammaConv||iPWG4CaloConv;
1554
1555
78bc93b3 1556 iEMCUtilLibs = iPWG4JetTasks||iPWG4PartCorrLibs||iPWG4JCORRAN||iPWG4GammaConvLib||iJETAN;
e6993a52 1557 iJETANLib = iPWG4JetTasks||iJETAN||iDIJETAN;
17d96675 1558
c38e3b95 1559 if (iESDfilter) {iAODhandler=1;}
1560 if (kUseKinefilter && !kUseMC) kUseKinefilter = kFALSE;
1561 if (kUseAODTags && !iAODhandler) kUseAODTags = kFALSE;
1562
1563
1564
1565}
1566
1567//______________________________________________________________________________
1568Bool_t Connect(const char *mode) {
1569// Connect <username> to the back-end system.
1570 Int_t imode = -1;
1571 if (!strcmp(mode, "LOCAL")) imode = 0;
1572 if (!strcmp(mode, "PROOF")) imode = 1;
1573 if (!strcmp(mode, "GRID")) imode = 2;
1574 TString username = gSystem->Getenv("alien_API_USER");
1575 switch (imode) {
1576 case 0:
1577 break;
1578 case 1:
1579 if (!username.Length()) {
1580 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \
1581 1. Have called: alien-token-init <username>\n \
1582 2. Have called: >source /tmp/gclient_env_$UID");
1583 return kFALSE;
1584 }
1585 ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to PROOF cluster <%s>",
1586 username.Data(), kProofCluster.Data());
1587 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
1588// TProof::Open(Form("%s@%s:31093", username.Data(), kProofCluster.Data()));
1589 TProof::Open(Form("%s@%s", username.Data(), kProofCluster.Data()));
1590 if (!gProof) {
1591 if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch"))
1592 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch");
1593 return kFALSE;
1594 }
1595 if(kProofClearPackages)gProof->ClearPackages();
1596
1597 if(kProofSaveToAlien){
1598 TGrid::Connect("alien://");
1599 if (gGrid) {
1600 TString homedir = gGrid->GetHomeDirectory();
1601 TString workdir = homedir + kTrainName;
1602 if (!gGrid->Cd(workdir)) {
1603 gGrid->Cd(homedir);
1604 if (gGrid->Mkdir(workdir)) {
1605 gGrid->Cd(kTrainName);
1606 ::Info("AnalysisTrainPWG4Jets::Connect()", "Directory %s created", gGrid->Pwd());
1607 }
1608 }
1609 gGrid->Mkdir("proof_output");
1610 gGrid->Cd("proof_output");
1611 kProofOutdir = Form("alien://%s", gGrid->Pwd());
1612 }
1613 }
1614 break;
1615 case 2:
1616 if (!username.Length()) {
1617 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \
1618 1. Have called: alien-token-init <username>\n \
1619 2. Have called: >source /tmp/gclient_env_$UID");
1620 return kFALSE;
1621 }
1622 if (kPluginUse && !gSystem->Getenv("alien_CLOSE_SE")) {
1623 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode),
1624 "When using the AliEn plugin it is preferable to define the \
1625 variable alien_CLOSE_SE in your environment.");
1626 return kFALSE;
1627 }
1628 ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to AliEn ...",
1629 username.Data());
1630 TGrid::Connect("alien://");
1631 if (!gGrid || !gGrid->IsConnected()) return kFALSE;
1632 break;
1633 default:
1634 ::Error("AnalysisTrainPWG4Jets.C::Connect", "Unknown run mode: %s", mode);
1635 return kFALSE;
1636 }
1637 ::Info("AnalysisTrainPWG4Jets.C::Connect","Connected in %s mode", mode);
1638 return kTRUE;
1639}
1640
1641//______________________________________________________________________________
1642Bool_t LoadCommonLibraries(const char *mode)
1643{
34fc6450 1644 if (!gSystem->Getenv("ALICE_ROOT")) {
1645 ::Error("AnalysisTrainPWG4Jets.C", "Analysis train requires that ALICE_ROOT is set to pick up Configurations");
f12de05f 1646 return kFALSE;
1647 }
1648
1649 // Load common analysis libraries.
c38e3b95 1650 Int_t imode = -1;
1651 if (!strcmp(mode, "LOCAL")) imode = 0;
1652 if (!strcmp(mode, "PROOF")) imode = 1;
1653 if (!strcmp(mode, "GRID")) imode = 2;
c38e3b95 1654 Bool_t success = kTRUE;
1655 // ROOT libraries
1656 gSystem->Load("libTree.so");
1657 gSystem->Load("libGeom.so");
1658 gSystem->Load("libVMC.so");
1659 gSystem->Load("libPhysics.so");
1660
1661 // Load framework classes. Par option ignored here.
1662 switch (imode) {
1663 case 0:
1664 case 2:
1665 if (kUseCPAR) {
1666 success &= LoadLibrary("STEERBase", mode, kTRUE);
1667 success &= LoadLibrary("ESD", mode, kTRUE);
1668 success &= LoadLibrary("AOD", mode, kTRUE);
1669 success &= LoadLibrary("ANALYSIS", mode, kTRUE);
7b90d977 1670 success &= LoadLibrary("OADB", mode, kTRUE);
78bc93b3 1671 success &= LoadLibrary("ANALYSISalice", mode, kTRUE);
d8f21f85 1672 success &= LoadLibrary("ROOTFILES", mode, kTRUE);
7b90d977 1673 // success &= LoadLibrary("EventMixing", mode,kTRUE);
c38e3b95 1674 success &= LoadLibrary("CORRFW", mode, kTRUE);
1675 } else {
1676 success &= LoadLibrary("libSTEERBase.so", mode);
1677 success &= LoadLibrary("libESD.so", mode);
1678 success &= LoadLibrary("libAOD.so", mode);
1679 success &= LoadLibrary("libANALYSIS.so", mode);
7b90d977 1680 success &= LoadLibrary("libOADB.so", mode, kTRUE);
78bc93b3 1681 success &= LoadLibrary("libANALYSISalice.so", mode);
7b90d977 1682 // success &= LoadLibrary("libEventMixing.so", mode);
c38e3b95 1683 success &= LoadLibrary("libCORRFW.so", mode);
1684 gROOT->ProcessLine(".include $ALICE_ROOT/include");
1685 }
1686 break;
1687 case 1:
1688 Int_t ires = -1;
1689 if (kProofUseAFPAR && !gSystem->AccessPathName(kProofAFversion)) ires = gProof->UploadPackage(kProofAFversion);
1690 if (ires < 0) {
1691 success &= LoadLibrary("STEERBase", mode);
1692 success &= LoadLibrary("ESD", mode);
1693 success &= LoadLibrary("AOD", mode);
1694 success &= LoadLibrary("ANALYSIS", mode);
1695 success &= LoadLibrary("ANALYSISalice", mode);
070f06d2 1696 success &= LoadLibrary("EventMixing", mode);
c38e3b95 1697 success &= LoadLibrary("CORRFW", mode);
1698 } else {
1699 ires = gProof->EnablePackage(kProofAFversion);
1700 if (ires<0) success = kFALSE;
1701 success &= LoadLibrary("CORRFW", mode);
1702 }
1703 break;
1704 default:
1705 ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Unknown run mode: %s", mode);
1706 return kFALSE;
1707 }
1708 if (success) {
1709 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: SUCCESS");
1710 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s",
1711 gSystem->GetIncludePath());
1712 } else {
1713 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: FAILED");
1714 }
1715
1716 return success;
1717}
1718
1719//______________________________________________________________________________
1720Bool_t LoadAnalysisLibraries(const char *mode)
1721{
1722// Load common analysis libraries.
9748e967 1723 Bool_t success = kTRUE;
cfd02305 1724 if (useTender) {
1725 if (!LoadLibrary("TENDER", mode, kTRUE) ||
1726 !LoadLibrary("TENDERSupplies", mode, kTRUE)) return kFALSE;
1727 }
c38e3b95 1728 if (iESDfilter) {
b0a36f28 1729 /*
c38e3b95 1730 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
1731 !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE;
b0a36f28 1732 */
c38e3b95 1733 }
1734 // JETAN
e6993a52 1735 if (iJETANLib) {
b53f2e4f 1736 // this part needs some rework in case we do not need the fastjed finders for processing
7b90d977 1737 if(iEMCUtilLibs){
1738 if (!LoadLibrary("EMCALUtils", mode, kTRUE) ||
1739 !LoadLibrary("PHOSUtils", mode, kTRUE)) return kFALSE;
1740 }
b53f2e4f 1741 if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE;
c38e3b95 1742 if (!strcmp(mode, "PROOF")){
ef1e462f 1743 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libCGAL.so\"\)", kTRUE);
c38e3b95 1744 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libfastjet.so\"\)", kTRUE);
1745 // problem when loading siscone copiled with different gcc version??
1746 // gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libsiscone.so\"\)", kTRUE);
1747 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libSISConePlugin.so\"\)", kTRUE);
1748 }
b53f2e4f 1749 if(!kUsePAR){
e84da0a5 1750 if (!LoadLibrary("CGAL", mode, kTRUE)) return kFALSE;
1751 if (!LoadLibrary("fastjet", mode, kTRUE)) return kFALSE;
1752 if (!LoadLibrary("siscone", mode, kTRUE)) return kFALSE;
1753 if (!LoadLibrary("SISConePlugin", mode, kTRUE)) return kFALSE;
1754 }
1755 else{
1756 // par files plus FASTJET needs some extra work... need to change
1757 // the loading sequence in the auto generated .C file
1758 if (!LoadLibrary("libCGAL.so", mode, kTRUE)) return kFALSE;
1759 if (!LoadLibrary("libfastjet.so", mode, kTRUE)) return kFALSE;
1760 if (!LoadLibrary("libsiscone.so", mode, kTRUE)) return kFALSE;
1761 if (!LoadLibrary("libSISConePlugin.so", mode, kTRUE)) return kFALSE;
1762 }
c38e3b95 1763 if (!LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE;
1764 }
1765 if(iPWG4JetTasks){
c38e3b95 1766 if (!LoadLibrary("PWG4JetTasks", mode, kTRUE)) return kFALSE;
1767 }
58ef946c 1768
c38e3b95 1769 if(iPWG1QASym){
34fc6450 1770 if (!LoadSource(Form("%s/PWG1/AliAnalysisTaskQASym.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
c38e3b95 1771 }
121e4bd5 1772 if(iPWG4TmpSourceSara){
c166d299 1773 if(!kUsePAR)gSystem->AddIncludePath("-I$ALICE_ROOT/include/JetTasks"); // ugly hack!!
34fc6450 1774 if(!LoadSource(Form("%s/PWG4/JetTasks/AliAnalysisTaskEta.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
c580ebbb 1775 }
c166d299 1776
911a740f 1777 if (iPWG4PartCorrLibs) {
4721d8c5 1778 if (!LoadLibrary("PWG4PartCorrBase", mode, kTRUE) ||
c38e3b95 1779 !LoadLibrary("PWG4PartCorrDep", mode, kTRUE)) return kFALSE;
1780 }
4721d8c5 1781 if(iPWG4JCORRAN){
1782 // PWG4 particle correlations
1783 if(!LoadLibrary("PWG4JCORRAN",mode,kTRUE))return kFALSE;
1784 }
d2e6cdd5 1785 if (iPWG4JetCorr) {
1786 if (!LoadLibrary("PWG4JetCorrel", mode, kTRUE)) return kFALSE;
1787 }
121e4bd5 1788 if (iPWG4omega3pi) {
1789 if (!LoadLibrary("PWG4omega3pi", mode, kTRUE)) return kFALSE;
1790 }
17d96675 1791 if (iPWG4GammaConvLib) {
53c63663 1792 if (!LoadLibrary("PWG4GammaConv", mode, kTRUE)) return kFALSE;
1793 }
c38e3b95 1794
1795 ::Info("AnalysisTrainPWG4Jets.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS");
1796 return kTRUE;
1797}
1798
1799//______________________________________________________________________________
1800Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE)
1801{
1802// Load a module library in a given mode. Reports success.
1803 Int_t imode = -1;
1804 Int_t result;
1805 TString smodule(module);
1806 if (!strcmp(mode, "LOCAL")) imode = 0;
1807 if (!strcmp(mode, "PROOF")) imode = 1;
1808 if (!strcmp(mode, "GRID")) imode = 2;
1809 TString mod(module);
1810 if (!mod.Length()) {
1811 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Empty module name");
1812 return kFALSE;
1813 }
1814 // If a library is specified, just load it
1815 if (smodule.EndsWith(".so")) {
1816 mod.Remove(mod.Index(".so"));
1817 result = gSystem->Load(mod);
1818 if (result < 0) {
1819 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load library %s", module);
1820 return kFALSE;
1821 }
1822 if (rec) anaLibs += Form("%s.so ",mod.Data());
e84da0a5 1823 if (rec) anaLibsExtra += Form("%s.so ",mod.Data());
c38e3b95 1824 return kTRUE;
1825 }
1826 // Check if the library is already loaded
1827 if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0)
1828 return kTRUE;
1829 switch (imode) {
1830 case 0:
1831 case 2:
1832 if (kUsePAR) {
1833 result = SetupPar(module);
1834 if (rec) anaPars += Form("%s.par ", module);
1835 } else {
1836 result = gSystem->Load(Form("lib%s.so", module));
1837 if (rec) anaLibs += Form("lib%s.so ", module);
1838 }
1839 break;
1840 case 1:
1841 if(!gSystem->AccessPathName(module)){
1842 ::Info("AnalysisTrainPWG4Jets.C::LoadLibrary", "Removing directory %s",module);
1843 gSystem->Exec(Form("rm -rf %s",module));
1844 }
1845 result = gProof->UploadPackage(module);
1846 if (result<0) {
1847 result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module)));
1848 if (result<0) {
1849 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module);
1850 return kFALSE;
1851 }
1852 }
1853 result = gProof->EnablePackage(module);
1854 break;
1855 default:
1856 return kFALSE;
1857 }
1858 if (result < 0) {
1859 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load module %s", module);
1860 return kFALSE;
1861 }
1862 return kTRUE;
1863}
1864
1865
1866
1867//______________________________________________________________________________
1868Bool_t LoadSource(const char *source, const char *mode, Bool_t rec=kFALSE)
1869{
1870// Load a module library in a given mode. Reports success.
1871 Int_t imode = -1;
1872 Int_t result = -1;
1873 if (!strcmp(mode, "LOCAL")) imode = 0;
1874 if (!strcmp(mode, "PROOF")) imode = 1;
1875 if (!strcmp(mode, "GRID")) imode = 2;
1876 TString ssource(source);
1877 TString basename = gSystem->BaseName(ssource.Data());
1878 if (!ssource.Length()) {
1879 ::Error("AnalysisTrainPWG4Jets.C::LoadSource", "Empty task name");
1880 return kFALSE;
1881 }
4d62ae1a 1882 // we have a source code so compile it
c38e3b95 1883 if (ssource.EndsWith(".cxx")) {
1884 // need to copy it here other wise the path is also used on grid...
1885 ssource.Remove(ssource.Index(".cxx"));
1886 basename.Remove(basename.Index(".cxx"));
1887 Printf("LoadSources:: Copying... path %s{cxx,h}",ssource.Data());
1888 gSystem->Exec(Form("cp %s.cxx . ",ssource.Data()));
1889 gSystem->Exec(Form("cp %s.h . ",ssource.Data()));
1890 // Path to code
1891 // only needed for local compilation, in grid and proof mode
1892 // the task headers are uploaded
1893 // path.Remove(path.Index(gSystem->BaseName(path.Data())));
1894 // Printf("LoadSources:: Including path %s",path.Data());
1895 // if(path.Length()>0)gROOT->ProcessLine(Form(".include %s",path.Data()));
1896 Printf("LoadSources:: Loading... path %s",basename.Data());
1897 switch (imode) {
1898 case 0:
b53f2e4f 1899 result = gROOT->LoadMacro(Form("%s.cxx++g",basename.Data()));
c38e3b95 1900 break;
1901 case 1:
b53f2e4f 1902 result = gProof->LoadMacro(Form("%s.cxx++g",basename.Data()));
c38e3b95 1903 break;
1904 case 2:
b53f2e4f 1905 result = gROOT->LoadMacro(Form("%s.cxx++g",basename.Data()));
c38e3b95 1906 if (rec){
1907 // what we want to compile
1908 anaSources += Form("%s.cxx ",basename.Data());
1909 // what we need as input...
1910 anaLibs += Form("%s.cxx %s.h ",basename.Data(),basename.Data());
1911 }
1912 break;
1913 default:
1914 return kFALSE;
1915 }
1916 }
1917 if (result < 0) {
1918 ::Error("AnalysisTrainPWG4Jets.C::LoadSources", "Could not load source %s", source);
1919 return kFALSE;
1920 }
1921 return kTRUE;
1922}
1923
1924
1925//______________________________________________________________________________
1926TChain *CreateChain(const char *mode, const char *plugin_mode)
1927{
1928// Create the input chain
1929 Int_t imode = -1;
1930 if (!strcmp(mode, "LOCAL")) imode = 0;
1931 if (!strcmp(mode, "PROOF")) imode = 1;
1932 if (!strcmp(mode, "GRID")) imode = 2;
1933 TChain *chain = NULL;
1934 // Local chain
1935 switch (imode) {
1936 case 0:
1937 if (iAODanalysis) {
1938 if (!kLocalXMLDataset.Length()) {
1939 // Local AOD
1940 chain = new TChain("aodTree");
1941 TString line;
1942 ifstream in;
1943 in.open(kLocalDataList.Data());
37eb26ea 1944 Int_t ic = 0;
c38e3b95 1945 while (in.good()) {
1946 in >> line;
1947 if (line.Length() == 0) continue;
37eb26ea 1948 Printf("%d adding %s",ic,line.Data());
c38e3b95 1949 chain->Add(line.Data());
37eb26ea 1950 ic++;
c38e3b95 1951 }
1952 } else {
1953 // Interactive AOD
1954 chain = CreateChainSingle(kLocalXMLDataset, "aodTree");
1955 }
1956 } else {
1957 if (!kLocalXMLDataset.Length()) {
1958 // Local ESD
1959 chain = new TChain("esdTree");
1960 TString line;
1961 ifstream in;
1962 in.open(kLocalDataList.Data());
1963 while (in.good()) {
1964 in >> line;
1965 if (line.Length() == 0) continue;
1966 cout << " line = " << line << endl;
1967 chain->Add(line.Data());
1968 }
1969 } else {
1970 // Interactive ESD
1971 chain = CreateChainSingle(kLocalXMLDataset, "esdTree");
1972 }
1973 }
1974 break;
1975 case 1:
1976 break;
1977 case 2:
1978 if (kPluginUse) {
1979// AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
1980// AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
1981 } else {
1982 TString treeName = "esdTree";
1983 if (iAODanalysis) treeName = "aodTree";
1984 chain = CreateChainSingle("wn.xml", treeName);
1985 }
1986 break;
1987 default:
1988 }
1989 if (chain && chain->GetNtrees()) return chain;
1990 return NULL;
1991}
1992
1993//______________________________________________________________________________
1994TChain* CreateChainSingle(const char* xmlfile, const char *treeName)
1995{
1996 printf("*******************************\n");
1997 printf("*** Getting the ESD Chain ***\n");
1998 printf("*******************************\n");
1999 TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
2000
2001 if (!myCollection) {
2002 ::Error("AnalysisTrainPWG4Jets.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
2003 return NULL ;
2004 }
2005
2006 TChain* chain = new TChain(treeName);
2007 myCollection->Reset() ;
2008 while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
2009 chain->ls();
2010 return chain;
2011}
2012
2013//______________________________________________________________________________
2014Int_t SetupPar(char* pararchivename)
2015{
2016 if (!pararchivename || !strlen(pararchivename)) return -1;
2017 char processline[1024];
2018 if (gSystem->AccessPathName(Form("%s.par", pararchivename))) {
2019 if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) {
2020 ::Info("AnalysisTrainPWG4Jets.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename);
9748e967 2021 TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)),
2022 Form("%s.par",pararchivename));
c38e3b95 2023 } else {
2024 ::Error("AnalysisTrainPWG4Jets.C::SetupPar", "Cannot find %s.par", pararchivename);
2025 return -1;
2026 }
2027 }
2028 if (kPluginUse && kSaveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, kTrainName.Data()));
2029 gSystem->Exec(Form("tar xvzf %s.par", pararchivename));
2030
2031 TString ocwd = gSystem->WorkingDirectory();
2032 if (!gSystem->ChangeDirectory(pararchivename)) return -1;
2033
2034 // check for BUILD.sh and execute
2035 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
2036 printf("*******************************\n");
2037 printf("*** Building PAR archive ***\n");
2038 printf("*******************************\n");
2039 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
2040 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
2041 return -1;
2042 }
2043 }
2044
2045 // check for SETUP.C and execute
2046 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
2047 printf("*******************************\n");
2048 printf("*** Setup PAR archive ***\n");
2049 printf("*******************************\n");
2050 gROOT->Macro("PROOF-INF/SETUP.C");
2051 }
4478beda 2052 if (!gSystem->ChangeDirectory(ocwd.Data())){
2053 Error("Change back directory",Form("Cannot change to %s",ocwd.Data()));
2054 return -1;
2055 }
c38e3b95 2056 return 0;
2057}
2058
2059//______________________________________________________________________________
2060AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
2061{
2062// Check if user has a valid token, otherwise make one. This has limitations.
2063// One can always follow the standard procedure of calling alien-token-init then
2064// source /tmp/gclient_env_$UID in the current shell.
c8fb37dd 2065// if (!AliAnalysisGrid::CreateToken()) return NULL;
c38e3b95 2066 AliAnalysisAlien *plugin = new AliAnalysisAlien();
2067// Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
2068 plugin->SetRunMode(plugin_mode);
2069 if (kPluginUseProductionMode) plugin->SetProductionMode();
2070 plugin->SetJobTag(kJobTag);
d8f21f85 2071 plugin->SetNtestFiles(1);
c38e3b95 2072// plugin->SetPreferedSE("ALICE::NIHAM::File");
2073// Set versions of used packages
e84da0a5 2074 plugin->SetAPIVersion("V1.1x");
2075 // plugin->SetAPIVersion("V1.0x");
2076// plugin->SetAPIVersion("V2.4");
c38e3b95 2077 plugin->SetROOTVersion(kPluginRootVersion);
2078 plugin->SetAliROOTVersion(kPluginAliRootVersion);
2079// Declare input data to be processed.
2080// Method 1: Create automatically XML collections using alien 'find' command.
2081// Define production directory LFN
2082 plugin->SetGridDataDir(kGridDatadir.Data());
2083// Set data search pattern
78bc93b3 2084 if (iAODanalysis) plugin->SetDataPattern(Form(" %s/*/*AliAOD.root",kGridPassPattern.Data()));
c8fb37dd 2085 else plugin->SetDataPattern(Form(" %s/*/*AliESDs.root",kGridPassPattern.Data()));
c38e3b95 2086// ...then add run numbers to be considered
2087// plugin->SetRunRange(kGridRunRange[0], kGridRunRange[1]);
2088 for (Int_t i=kGridRunRange[0]; i<=kGridRunRange[1]; i++) {
2089 Printf("AnalysisTrainPWG4Jets Adding run number %s", Form(kGridRunPattern.Data(),i));
2090 plugin->AddRunNumber(Form(kGridRunPattern.Data(),i));
2091 }
2092
2093 if(kGridLocalRunList.Length()>0){
2094 ifstream in1;
2095 in1.open(kGridLocalRunList.Data());
2096 int iRun;
4d16db9c 2097 int icount = 0;
9748e967 2098 Int_t nRun = 0;
9a5c5b1e 2099 // just use run numbers, negatives will be excluded
2100 while(in1>>iRun){
ffab794c 2101 if(iRun>=0){
2102 if(iRun>=0&&nRun>=kGridOffsetRunFromList&&(nRun<kGridMaxRunsFromList)){
f12de05f 2103 Printf("AnalysisTrainPWG4Jets Adding run number from File %d: %s",nRun,Form(kGridRunPattern.Data(),iRun));
9a5c5b1e 2104 plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun));
ffab794c 2105
2106 }
2107 else{
f12de05f 2108 Printf("AnalysisTrainPWG4Jets Skipping run number from File %d: %d",nRun, iRun);
ffab794c 2109 }
36c36a0c 2110 nRun++;
9a5c5b1e 2111 }
2112 else{
f12de05f 2113 Printf("AnalysisTrainPWG4Jets Skipping run number from File %d: %d",nRun, iRun);
e84da0a5 2114 }
c38e3b95 2115 }
2116 }
c38e3b95 2117// Method 2: Declare existing data files (raw collections, xml collections, root file)
2118// If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
2119// XML collections added via this method can be combined with the first method if
2120// the content is compatible (using or not tags)
2121// plugin->AddDataFile("tag.xml");
2122// plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
2123// Define alien work directory where all files will be copied. Relative to alien $HOME.
3878a941 2124 TString alien_workdir = "";
2125
2126 if (iAODanalysis) alien_workdir += "analysisAOD";
2127 else alien_workdir += "analysisESD";
c22feddd 2128 if(kGridDataSet.Length()>0)alien_workdir += Form("/%s%s",kGridDataSet.Data(),kGridExtraAliendirLevel.Data());
3878a941 2129 plugin->SetGridWorkingDir(alien_workdir.Data());
2130
c38e3b95 2131 // Declare alien output directory. Relative to working directory.
2132 if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
2133 plugin->SetGridOutputDir(kGridOutdir);
2134
2135 // Add external packages
78bc93b3 2136 plugin->AddExternalPackage("boost::v1_43_0");
2137 plugin->AddExternalPackage("cgal::v3.6");
2138 plugin->AddExternalPackage("fastjet::v2.4.2");
c38e3b95 2139
2140
2141 // set extra libs before par file compilation
2142 anaLibs += kGridExtraFiles;
2143 anaLibs = anaLibs.Strip();
e84da0a5 2144 Printf("anaLibs %s",anaLibs.Data());
2145 Printf("anaLibsExtra %s",anaLibsExtra.Data());
2146
2147 if (anaLibs.Length()) plugin->SetAdditionalLibs(anaLibs.Data());
2148 if (anaLibsExtra.Length()) plugin->SetAdditionalRootLibs(anaLibsExtra.Data());
c38e3b95 2149
2150 TString ana_sources = "";
2151 TString ana_add = "";
2152 if (kUsePAR && anaPars.Length()) {
2153 printf("%s\n", anaPars.Data());
2154 TObjArray *arr;
2155 TObjString *objstr;
2156 arr = anaPars.Tokenize(" ");
2157 TIter next(arr);
2158 while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString());
2159 delete arr;
2160 }
2161
2162// Declare the analysis source files names separated by blancs. To be compiled runtime
2163// using ACLiC on the worker nodes.
2164 ana_sources = anaSources.Strip();
2165// Declare all libraries (other than the default ones for the framework. These will be
2166// loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
2167
2168 if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources);
2169 plugin->SetExecutableCommand(kPluginExecutableCommand.Data());
4721d8c5 2170 // Declare the output file names separated by blancs.
2171 // (can be like: file.root or file.root@ALICE::Niham::File)
c38e3b95 2172 plugin->SetMergeExcludes(kGridMergeExclude);
2173 plugin->SetMaxMergeFiles(kGridMaxMergeFiles);
2174 plugin->SetNrunsPerMaster(kGridRunsPerMaster);
9a5c5b1e 2175 plugin->SetMergeViaJDL(kPluginMergeViaJDL);
4721d8c5 2176 // Use fastread option
9a5c5b1e 2177 plugin->SetFastReadOption(kPluginFastReadOption);
4721d8c5 2178 // UseOverwrite mode
9a5c5b1e 2179 plugin->SetOverwriteMode(kPluginOverwriteMode);
4721d8c5 2180 // Optionally define the files to be archived.
2181 // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File");
dc6a7461 2182 plugin->SetOutputToRunNo(kPluginOutputToRunNumber); // write the output to subdirs named after run number
c38e3b95 2183
2184 // Put default output files to archive
2185 TString listhists = "";
2186 TString listaods = "";
2187 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
2188 TIter next(mgr->GetOutputs());
2189 AliAnalysisDataContainer *output;
2190 while ((output=(AliAnalysisDataContainer*)next())) {
2191 const char *filename = output->GetFileName();
2192 if (!(strcmp(filename, "default"))) {
53c63663 2193 if (!mgr->GetOutputEventHandler()) continue;
c38e3b95 2194 filename = mgr->GetOutputEventHandler()->GetOutputFileName();
e84da0a5 2195 if (listaods.Length()) listaods += " ";
c38e3b95 2196 listaods += filename;
c38e3b95 2197 } else {
e84da0a5 2198 if(!listhists.Contains(filename)){
2199 if (listhists.Length()) listhists += " ";
c38e3b95 2200 listhists += filename;
2201 }
2202 }
2203 }
53c63663 2204
53c63663 2205 if (mgr->GetExtraFiles().Length()) {
e84da0a5 2206 if (listaods.Length()) listaods += " ";
53c63663 2207 listaods += mgr->GetExtraFiles();
c38e3b95 2208 }
53c63663 2209
2210 // if we do not fill the aod we do not need to store it
4721d8c5 2211 // kGridMergeExclude = listaods;
e84da0a5 2212
e2afec0c 2213 if(kSaveAOD>=0){
4721d8c5 2214 TString outputFiles = "";
2215 outputFiles += mgr->GetExtraFiles();
2216 if (listhists.Length()) outputFiles += " ";
2217 outputFiles += listhists;
e84da0a5 2218 plugin->SetDefaultOutputs(kFALSE);
4721d8c5 2219 Printf("%s:%d Starting with the files %s",(char*)__FILE__,__LINE__,outputFiles.Data());
2220 // remove
2221 // no harm done when we try to remove something that is not there :)
2222 if(!(kSaveAOD&(1<<0))){
2223 outputFiles.ReplaceAll("AliAOD.root ","");
2224 listaods.ReplaceAll("AliAOD.root ","");
2225 }
2226 if(!(kSaveAOD&(1<<1))){
2227 if(kDeltaAODJetName.Length())outputFiles.ReplaceAll(kDeltaAODJetName.Data(),"");
2228 if(kDeltaAODJetName.Length())listaods.ReplaceAll(kDeltaAODJetName.Data(),"");
2229
2230 }
2231 if(!(kSaveAOD&(1<<2))){
2232 if(kDeltaAODPartCorrName.Length())outputFiles.ReplaceAll(kDeltaAODPartCorrName.Data(),"");
2233 if(kDeltaAODPartCorrName.Length())listaods.ReplaceAll(kDeltaAODPartCorrName.Data(),"");
2234 }
2235 if(!(kSaveAOD&(1<<3))){
2236 if(kDeltaAODJCORRANName.Length())outputFiles.ReplaceAll(kDeltaAODJCORRANName.Data(),"");
2237 if(kDeltaAODJCORRANName.Length())listaods.ReplaceAll(kDeltaAODJCORRANName.Data(),"");
2238 }
2239
2240 //
e2afec0c 2241 plugin->SetDefaultOutputs(kFALSE);
4721d8c5 2242 Printf("%s:%d Saving the files %s",(char*)__FILE__,__LINE__,outputFiles.Data());
2243 plugin->SetOutputFiles(outputFiles.Data());
e84da0a5 2244 }
53c63663 2245
4721d8c5 2246 TString outputArchive;
4d5d766e 2247 outputArchive = Form("log_archive.zip:std*@%s","disk=1");
e84da0a5 2248 listaods.ReplaceAll(" ", ",");
2249 listhists.ReplaceAll(" ", ",");
4d5d766e 2250 if (listhists.Length()){
2251 outputArchive += " ";
2252 outputArchive += "root_archive.zip:";
2253 outputArchive += listhists;
2254 if (listaods.Length()){
2255 outputArchive += ",";
2256 outputArchive += listaods;
2257 }
2258 outputArchive += Form("@%s", kGridOutputStorages.Data());
2259 }
2260 else{
2261
2262 if (listaods.Length()){
2263 // we have only aod'ish output
2264 outputArchive += " ";
2265 outputArchive += "root_archive.zip:";
2266 outputArchive += listaods;
2267 outputArchive += Form("@%s", kGridOutputStorages.Data());
2268 }
2269 else{
2270 // no other outputs than std..
c38e3b95 2271 ::Fatal("AnalysisTrainPWG4Jets", "No task output !");
4d5d766e 2272 }
c38e3b95 2273 }
4d5d766e 2274
17d96675 2275 plugin->SetDefaultOutputs(kFALSE);
c38e3b95 2276 plugin->SetOutputArchive(outputArchive);
17d96675 2277
4721d8c5 2278
4d5d766e 2279 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
c38e3b95 2280 plugin->SetAnalysisMacro(Form("%s.C", kTrainName.Data()));
4d5d766e 2281 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
c38e3b95 2282 plugin->SetSplitMaxInputFileNumber(kGridFilesPerJob);
4d5d766e 2283 // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
27cdf9c4 2284 // plugin->SetMaxInitFailed(5);
4d5d766e 2285 // Optionally resubmit threshold.
c8fb37dd 2286 // plugin->SetMasterResubmitThreshold(90);
4d5d766e 2287 // Optionally set time to live (default 30000 sec)
8dc333da 2288 plugin->SetTTL(80000); // 22h...
4d5d766e 2289 // Optionally set input format (default xml-single)
c38e3b95 2290 plugin->SetInputFormat("xml-single");
4d5d766e 2291 // Optionally modify the name of the generated JDL (default analysis.jdl)
c38e3b95 2292 plugin->SetJDLName(Form("%s.jdl", kTrainName.Data()));
4d5d766e 2293 // Optionally modify the executable name (default analysis.sh)
c38e3b95 2294 plugin->SetExecutable(Form("%s.sh", kTrainName.Data()));
4d5d766e 2295 // Optionally modify job price (default 1)
c38e3b95 2296 plugin->SetPrice(1);
4d5d766e 2297 // Optionally modify split mode (default 'se')
c38e3b95 2298 plugin->SetSplitMode("se");
2299 return plugin;
2300}
2301
2302//______________________________________________________________________________
2303void WriteConfig()
2304{
2305// Write train configuration in a file. The file name has the format:
2306// train_[trainName]_ddMonthyyyy_time.C
2307 if (kUseDate) {
2308 gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp");
2309 ifstream fdate("date.tmp");
2310 if (!fdate.is_open()) {
2311 ::Error("AnalysisTrainPWG4Jets.C::Export","Could not generate file name");
2312 return;
2313 }
2314 const char date[64];
2315 fdate.getline(date,64);
2316 fdate.close();
2317 gSystem->Exec("rm date.tmp");
2318 kTrainName = Form("train_%s_%s", kTrainName.Data(), date);
2319 } else {
2320 kTrainName = Form("train_%s", kTrainName.Data());
2321 }
2322 TString cdir = gSystem->WorkingDirectory();
2323 gSystem->MakeDirectory(kTrainName);
2324 gSystem->ChangeDirectory(kTrainName);
2325 ofstream out;
2326 out.open(Form("%sConfig.C",kTrainName.Data()), ios::out);
2327 if (out.bad()) {
2328 ::Error("AnalysisTrainPWG4Jets.C::Export", "Cannot open ConfigTrain.C for writing");
2329 return;
2330 }
2331 out << "{" << endl;
2332 out << " kTrainName = " << "\"" << kTrainName.Data() << "\";" << endl;
2333 out << " kProofCluster = " << "\"" << kProofCluster.Data() << "\";" << endl;
2334 out << " kProofUseAFPAR = " << kProofUseAFPAR << ";" << endl;
2335 if (kProofUseAFPAR)
2336 out << " kProofAFversion = " << kProofAFversion.Data() << ";" << endl;
2337 out << " kProofDataSet = " << "\"" << kProofDataSet.Data() << "\";" << endl;
2338 out << " kPluginUse = " << kPluginUse << ";" << endl;
2339 out << " kUsePAR = " << kUsePAR << ";" << endl;
2340 out << " kUseCPAR = " << kUseCPAR << ";" << endl;
2341 out << " kPluginRootVersion = " << "\"" << kPluginRootVersion.Data() << "\";" << endl;
2342 out << " kPluginAliRootVersion = " << "\"" << kPluginAliRootVersion.Data() << "\";" << endl;
2343 out << " kGridDatadir = " << "\"" << kGridDatadir.Data() << "\";" << endl;
2344 if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
2345 out << " kGridOutdir = " << "\"" << kGridOutdir.Data() << "\";" << endl;
2346 out << " kGridMaxMergeFiles = " << kGridMaxMergeFiles << ";" << endl;
2347 out << " kGridMergeExclude = " << "\"" << kGridMergeExclude.Data() << "\";" << endl;
2348 out << " kGridRunsPerMaster = " << kGridRunsPerMaster << ";" << endl;
2349 out << " kGridFilesPerJob = " << kGridFilesPerJob << ";" << endl;
2350 out << " kGridRunRange[0] = " << kGridRunRange[0] << ";" << endl;
2351 out << " kGridRunRange[1] = " << kGridRunRange[1] << ";" << endl;
2352 out << " kUseDebug = " << kUseDebug << ";" << endl;
2353 out << " kUseMC = " << kUseMC << ";" << endl;
2354 out << " kUseESDTags = " << kUseESDTags << ";" << endl;
2355 out << " kUseKinefilter = " << kUseKinefilter << ";" << endl;
2356 out << " kUseTR = " << kUseTR << ";" << endl;
2357 out << " kUseAODTags = " << kUseAODTags << ";" << endl;
2358 out << " kSaveTrain = " << "kFALSE;" << endl << endl;
2359 out << " // Analysis modules" << endl;
2360 out << " iAODanalysis = " << iAODanalysis << ";" << endl;
2361 out << " iAODhandler = " << iAODhandler << ";" << endl;
2362 out << " iESDfilter = " << iESDfilter << ";" << endl;
2363 out << " iJETAN = " << iJETAN << ";" << endl;
2364 out << "// Configuration fot the wagons" << endl;
2365 out << "}" << endl;
2366 ::Info("AnalysisTrainPWG4Jets.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", kTrainName.Data()));
2367 gSystem->ChangeDirectory(cdir);
2368}
2369
2370//______________________________________________________________________________
2371Bool_t LoadConfig(const char *filename)
2372{
2373// Read train configuration from file
2374 if (gSystem->AccessPathName(filename)) {
2375 ::Error("AnalysisTrainPWG4Jets.C::LoadConfig", "Config file name not found");
2376 return kFALSE;
2377 }
2378 gROOT->ProcessLine(Form(".x %s", filename));
2379 ::Info("AnalysisTrainPWG4Jets.C::LoadConfig", "Train configuration loaded from file %s", filename);
2380 return kTRUE;
2381}
2382
2383Bool_t PatchJDL(){
2384 Printf(">>> Patching JDL");
2385 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
2386 AliAnalysisAlien* gridHandler = (AliAnalysisAlien*)mgr->GetGridHandler();
2387 TGridJDL *jdl = gridHandler->GetGridJDL();
2388 if(iJETAN)jdl->AddToPackages("fastjet","v2.4.0");
2389 gridHandler->WriteJDL(kFALSE);
0971dabc 2390 Printf("<<< Patching JDL");
c38e3b95 2391 return kTRUE;
2392}
2393
2394Bool_t PatchAnalysisMacro(){
4721d8c5 2395 Printf(">>> Patching AnalysisMacro");
2396 gSystem->Exec(Form("mv %s.C %s.C_tmp",kTrainName.Data(),kTrainName.Data()));
c38e3b95 2397
2398 ifstream in1;
2399 in1.open(Form("%s.C_tmp", kTrainName.Data()));
2400 char cLine[250];
2401 TString st;
2402 while(in1.getline(cLine,250)){
2403 st += cLine;
2404 st += "\n";
2405 }
4721d8c5 2406 Int_t index= -1;
c38e3b95 2407 index = st.Index("gSystem->Load(\"libPhysics\");");
2408 index += strlen("gSystem->Load(\"libPhysics\");");
4721d8c5 2409 /*
c38e3b95 2410 TObjArray *arr;
2411 TObjString *objstr;
2412 arr = anaLibs.Tokenize(" ");
2413 TIter next(arr);
4721d8c5 2414
c38e3b95 2415 add += "\n\n // added by CKB \n";
2416 while ((objstr=(TObjString*)next())){
e84da0a5 2417 if(objstr->GetString().Contains("PWG3"))continue;
c38e3b95 2418 if(objstr->GetString().EndsWith(".so"))add += Form("gSystem->Load(\"%s\");\n",objstr->GetString().Data());
2419 }
2420 delete arr;
4721d8c5 2421 */
3878a941 2422 // add += Form("AliLog::SetGlobalLogLevel(%d);\n",AliLog::GetGlobalLogLevel());
4721d8c5 2423 TString add = "";
2424
2425 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2426 add += "\n\n // added by CKB \n";
46534866 2427 if(kErrorIgnoreLevel>0)add += Form("gErrorIgnoreLevel = %d;\n",kErrorIgnoreLevel);
23adcac8 2428 add += "\n gSystem->AddIncludePath(\"./\"); \n";
f4132e7d 2429 add += "\n gSystem->SetFPEMask(); \n";
2430
2431
4721d8c5 2432 if(gGrid&&kPluginAliRootVersion.Length()==0){
bbb42949 2433 /*
4721d8c5 2434 add += "\n // Dirty hack for TRD reference data \n";
2435 add += "\n gSystem->Setenv(\"ALICE_ROOT\",\"";
2436 add += Form("alien://%s/rootfiles/",gGrid->GetHomeDirectory());
2437 add += "\"); \n";
bbb42949 2438 */
c38e3b95 2439 }
bbb42949 2440
4721d8c5 2441 add += "// BKC \n\n";
2442 st.Insert(index,add.Data());
e84da0a5 2443
2444 if(kUseDebug){
23adcac8 2445 // st.Insert(index,"\n gROOT->ProcessLine(\".trace\"); // CKB \n");
e84da0a5 2446 }
2447
4721d8c5 2448 if(kUseCPAR&&kPluginAliRootVersion.Length()==0){
2449 index = st.Index("gSystem->AddIncludePath(\"-I$"); // uncommen $ALICE_ROOT include for par files
2450 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2451 st.Insert(index,"// CKB comment out whehn no aliroot is provided \n //");
2452 }
c166d299 2453
46534866 2454 if(AliLog::GetGlobalLogLevel()==AliLog::kFatal){
2455 index = st.Index("AliLog::SetGlobal"); // ncomment setting of log level, do my own
2456 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2457 st.Insert(index,"AliLog::SetGlobalLogLevel(AliLog::kFatal);// CKB \n // CKB comment out for own setting \n //");
2458 }
2459
c38e3b95 2460 ofstream out;
2461 out.open(Form("%s.C", kTrainName.Data()));
2462 if (out.bad()) {
2463 return kFALSE;
2464 }
2465 out << st << endl;
2466 Printf("<<< Patching AnalysisMacro");
4721d8c5 2467
2468
2469
2470
2471
2472 Printf(">>> Patching Merge Macro");
2473 gSystem->Exec(Form("mv %s_merge.C %s_merge.C_tmp",kTrainName.Data(),kTrainName.Data()));
2474
2475 ifstream in2;
2476 in2.open(Form("%s_merge.C_tmp", kTrainName.Data()));
2477 TString st2;
2478 while(in2.getline(cLine,250)){
2479 st2 += cLine;
2480 st2 += "\n";
2481 }
2482 index = st2.Index("gSystem->Load(\"libPhysics\");");
2483 index += strlen("gSystem->Load(\"libPhysics\");");
2484 TString add2 = "";
23adcac8 2485 add2 += "\n gSystem->AddIncludePath(\"./\"); \n";
4721d8c5 2486 if(gGrid&&kPluginAliRootVersion.Length()==0){
bbb42949 2487 /*
4721d8c5 2488 add2 += "\n // Dirty hack for TRD reference data \n";
2489 add2 += "\n gSystem->Setenv(\"ALICE_ROOT\",\"";
2490 add2 += Form("alien://%s/rootfiles/",gGrid->GetHomeDirectory());
2491 add2 += "\"); \n";
bbb42949 2492 */
4721d8c5 2493 }
2494 add2 += "// BKC \n\n";
2495 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2496 st2.Insert(index,add.Data());
2497
2498
2499 if(kUseDebug){
23adcac8 2500 // st2.Insert(index,"\n gROOT->ProcessLine(\".trace\"); // CKB \n");
4721d8c5 2501 }
2502
2503 if(kUseCPAR&&kPluginAliRootVersion.Length()==0){
46534866 2504 index = st2.Index("gSystem->AddIncludePath(\"-I$"); // uncomment $ALICE_ROOT include for par files
4721d8c5 2505 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2506 st2.Insert(index,"// CKB comment out whehn no aliroot is provided \n //");
2507 }
2508
2509 // do not exclude the extra files from merign, this is done explicitly in this train script
92d850d5 2510 // index = st2.Index("mergeExcludes +="); // uncommen $ALICE_ROOT include for par files
2511 // if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2512 // st2.Insert(index,"// CKB comment out, handled explicitly by the train macro \n //");
4721d8c5 2513
2514
2515 ofstream out2;
2516 out2.open(Form("%s_merge.C", kTrainName.Data()));
2517 if (out2.bad()) {
2518 return kFALSE;
2519 }
2520 out2 << st2 << endl;
2521 Printf("<<< Patching Merging Macro");
2522
2523
2524
c38e3b95 2525 return kTRUE;
2526
2527}