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