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