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