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