Changing the list of chunks used to validate
[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
23adcac8 138TString kPluginRootVersion = "v5-26-00b-6"; // *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);
461 }
462 else{
463 taskFrag = AddTaskFragmentationFunction(1<<0,kHighPtFilterMask);
464 }
465
aba42fcb 466 if (!taskFrag) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskFragmentationFunction cannot run for this train conditions - EXCLUDED");
c166d299 467 }
468
c580ebbb 469
9f77f0ce 470 if(iPWG4JetChem){
471 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetChem.C");
472 AliAnalysisTask *taskChem = AddTaskJetChem();
c580ebbb 473 if (!taskChem) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetChem cannot run for this train conditions - EXCLUDED");
474 }
475
476
c38e3b95 477 if(iPWG4JetServices){
478 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetServices.C");
479 AliAnalysisTaskJetServices *taskjetServ = 0;
480 taskjetServ = AddTaskJetServices();
481 if (!taskjetServ) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetServices cannot run for this train conditions - EXCLUDED");
53c63663 482 if(kGridRunRange[0]>0)taskjetServ->SetRunRange(kGridRunRange[0],kGridRunRange[1]);
8be7acf2 483 else taskjetServ->SetRunRange(100000,150000);
c28abe00 484 if(!kIsMC) taskjetServ->SetRealData(kTRUE);
dc6a7461 485 taskjetServ->SetUsePhysicsSelection((Bool_t)iPhysicsSelection);
9f77f0ce 486 taskjetServ->SetDebugLevel(0);
c38e3b95 487 }
488
c38e3b95 489 if(iPWG4JetSpectrum){
490 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetSpectrum2.C");
491 AliAnalysisTaskJetSpectrum2 *taskjetSpectrum = 0;
b53f2e4f 492 if(iPWG4JetSpectrum&1){
17d96675 493 taskjetSpectrum = AddTaskJetSpectrum2("jets","","",kHighPtFilterMask,iPhysicsSelection);
e6993a52 494 if(!iAODanalysis){
d3af0232 495 // taskjetSpectrum = AddTaskJetSpectrum2("jets","tracks32",32,iPhysicsSelection); // tmp hack to give it a different name
4d5d766e 496 // taskjetSpectrum = AddTaskJetSpectrum2("jets","64",64,iPhysicsSelection);
46534866 497
5ad2b067 498 taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","clustersAOD_ANTIKT04","",kHighPtFilterMask,iPhysicsSelection);
499
f2dd0695 500 if(kIsMC){
17d96675 501
502 UInt_t eventSelection = AliAnalysisHelperJetTasks::kIsPileUp|AliAnalysisHelperJetTasks::kVertexIn;
503 if(iPhysicsSelection)eventSelection |= AliAnalysisHelperJetTasks::kPhysicsSelection;
504 taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC_FASTJET04","",kHighPtFilterMask,iPhysicsSelection,eventSelection);
505 taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC2_FASTJET04","",kHighPtFilterMask,iPhysicsSelection,eventSelection);
506
507 eventSelection = AliAnalysisHelperJetTasks::kIsCosmic|AliAnalysisHelperJetTasks::kVertexIn;
508 if(iPhysicsSelection)eventSelection |= AliAnalysisHelperJetTasks::kPhysicsSelection;
509 taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC_FASTJET04","",kHighPtFilterMask,iPhysicsSelection,eventSelection);
510
511 eventSelection = AliAnalysisHelperJetTasks::kNone;
512 taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC2_FASTJET04","",kHighPtFilterMask,iPhysicsSelection,eventSelection);
513 taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","jetsAODMC_FASTJET04","",kHighPtFilterMask,iPhysicsSelection,eventSelection);
46534866 514
515 }
516 else{
17d96675 517 UInt_t eventSelection = AliAnalysisHelperJetTasks::kIsPileUp|AliAnalysisHelperJetTasks::kVertexIn;
518 if(iPhysicsSelection)eventSelection |= AliAnalysisHelperJetTasks::kPhysicsSelection;
519 taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","","",kHighPtFilterMask,iPhysicsSelection,eventSelection);
520
521 eventSelection = AliAnalysisHelperJetTasks::kIsCosmic|AliAnalysisHelperJetTasks::kVertexIn;
522 if(iPhysicsSelection)eventSelection |= AliAnalysisHelperJetTasks::kPhysicsSelection;
523 taskjetSpectrum = AddTaskJetSpectrum2("jetsAOD_FASTJET04","","",kHighPtFilterMask,iPhysicsSelection,eventSelection);
f2dd0695 524 }
e6993a52 525 }
d2e6cdd5 526 if (!taskjetSpectrum) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetSpectrum2 cannot run for this train conditions - EXCLUDED");
17d96675 527 // taskjetSpectrum->SetDebugLevel(1);
b53f2e4f 528 }
d2e6cdd5 529
e6993a52 530 if(iPWG4JetSpectrum&2){
531 UInt_t selection = 0;
17d96675 532 if(!iAODanalysis){
533 selection = 0xffffff;
534 // switch off 07 radii
535 selection &= ~(1<<6)&~(1<<11)&~(1<<12)&~(1<<13)&~(1<<14);
536 }
e6993a52 537 else selection = 1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<7|1<<8|1<<9;
e0c120d9 538 AddTaskJetSpectrum2Delta(kHighPtFilterMask,kUseAODMC,iPhysicsSelection,selection,0,kTRUE);
e6993a52 539 }
c38e3b95 540 }
58ef946c 541 if(iPWG4JCORRAN){
542 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJCORRANTask.C");
4721d8c5 543 AliJCORRANTask* corran = AddTaskJCORRAN(kDeltaAODJCORRANName.Data(),0);
58ef946c 544 if(!corran)::Warning("AnalysisTrainPWG4Jets", "AliJCORRANTask cannot run for this train conditions - EXCLUDED");
4721d8c5 545 else{
546 if(kDeltaAODJCORRANName.Length()>0)mgr->RegisterExtraFile(kDeltaAODJCORRANName.Data());
547 }
58ef946c 548 }
549
c38e3b95 550 if(iPWG4UE){
551 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskUE.C");
552 AliAnalysisTaskUE *taskUE = 0;
553 if(iPWG4UE&1)taskUE = AddTaskUE();
554 if(iPWG4UE&2){
94ee88d4 555 taskUE =AddTaskUE("jetsAOD_CDF04","CDF", "LJ", "TRANSV","MSP"); //finder not yet in train
17d96675 556 // taskUE =AddTaskUE("jetsAOD_CDF07","CDF", "LJ", "TRANSV","MSP");
94ee88d4 557 taskUE =AddTaskUE("jetsAOD_SISCONE04","CDF", "LJ", "TRANSV","MSP");
17d96675 558 // taskUE =AddTaskUE("jetsAOD_SISCONE07","CDF", "LJ", "TRANSV","MSP"); //finder not yet in train
94ee88d4 559 taskUE =AddTaskUE("jetsAOD_ICDF","CDF","LJ","TRANSV","MSP");
560 taskUE =AddTaskUE("jetsAOD_FASTKT04","CDF", "LJ", "TRANSV","MSP");
17d96675 561 // taskUE =AddTaskUE("jetsAOD_FASTKT07","CDF", "LJ", "TRANSV","MSP"); //finder not yet in train
58ef946c 562 taskUE =AddTaskUE("jetsAOD_NONE","CDF", "MP_eta05", "TRANSV","MSP");
563 taskUE =AddTaskUE("jetsAOD_NONE","CDF", "MP_eta09", "TRANSV","MSP");
c38e3b95 564 }
2bb1f4ca 565
c38e3b95 566 if (!taskUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskUE cannot run for this train conditions - EXCLUDED");
567 }
e0c120d9 568
569 if(iPWG4LeadingUE){
570 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskLeadingTrackUE.C");
571 AliAnalysisTaskLeadingTrackUE *taskLeadingUE = AddTaskLeadingTrackUE(kUseMC);
572 if (!taskLeadingUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTasLeadingTrackkUE cannot run for this train conditions - EXCLUDED");
573 taskLeadingUE->SetFilterBit(64);
574 }
575
576
9748e967 577 if(iPWG4CorrectionsUE){
578 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskCorrectionsUE.C");
579 AliAnalysisTaskCorrectionsUE *taskCorrectionsUE = 0;
580 if(iPWG4CorrectionsUE&1)taskCorrectionsUE = AddTaskCorrectionsUE("jetsAOD_NONE","CDF","MP_eta05","TRANSV","MSP",kFALSE);
581 if (!taskCorrectionsUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskCorrectionsUE cannot run for this train conditions - EXCLUDED");
582 }
c38e3b95 583
584 if(iPWG4ThreeJets){
585 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskThreeJets.C");
586 AliAnalysisTaskThreeJets *taskThree = AddTaskThreeJets();
587 if(!taskThree)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskThreets cannot run for this train conditions - EXCLUDED");
588 }
c38e3b95 589 if(iPWG4PtQAMC){
590 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQAMC.C");
b1cd0099 591 AliPWG4HighPtQAMC *taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data());
c38e3b95 592 if (!taskQAMC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQAMC cannot run for this train conditions - EXCLUDED");
593 }
594
595 if(iPWG4PtQATPC){
596 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQATPConly.C");
10295ac3 597 AliPWG4HighPtQATPConly *taskQATPC = 0;
b1cd0099 598 if(iPWG4PtQATPC&1)taskQATPC = AddTaskPWG4HighPtQATPConly(kGridDataSet.Data(),1);
599 if(iPWG4PtQATPC&2)taskQATPC = AddTaskPWG4HighPtQATPConly(kGridDataSet.Data(),2);
10295ac3 600
601 if (!taskQATPC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQATPC cannot run for this train conditions - EXCLUDED");
c38e3b95 602 }
3878a941 603
1f329128 604 if(iPWG4Cosmics){
605 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4CosmicCandidates.C");
606
607 AliPWG4CosmicCandidates *taskPWG4CosmicCandidates = AddTaskPWG4CosmicCandidates(0);
608 taskPWG4CosmicCandidates = AddTaskPWG4CosmicCandidates(1);
609
610 if (!taskPWG4CosmicCandidates) ::Warning("AnalysisTrainPWG4Jets", "AddTaskPWG4CosmicCandidates cannot run for this train conditions - EXCLUDED");
611 }
612
613
c38e3b95 614 if(iPWG4PtSpectra){
615 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtSpectra.C");
b1cd0099 616 AliPWG4HighPtSpectra *taskPtSpectra = AddTaskPWG4HighPtSpectra(kGridDataSet.Data());
c38e3b95 617 if (!taskPtSpectra) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskPtSpectra cannot run for this train conditions - EXCLUDED");
618 }
b53f2e4f 619 if(iPWG4KMeans){
620 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskKMeans.C");
621 AliAnalysisTaskKMeans *taskKMeans = AddTaskKMeans();
622 if (!taskKMeans) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskKMenans cannot run for this train conditions - EXCLUDED");
623 }
624
c38e3b95 625 if(iPWG4PartCorr){
626 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPartCorr.C");
14526afb 627 AliAnalysisTaskParticleCorrelation *taskpartcorrPHOS = AddTaskPartCorr("AOD", "PHOS",kFALSE,kIsMC);
c38e3b95 628 if (!taskpartcorrPHOS) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation PHOS cannot run for this train conditions - EXCLUDED");
14526afb 629 AliAnalysisTaskParticleCorrelation *taskpartcorrEMCAL = AddTaskPartCorr("AOD", "EMCAL",kFALSE,kIsMC);
c38e3b95 630 if (!taskpartcorrEMCAL) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation EMCAL cannot run for this train conditions - EXCLUDED");
4721d8c5 631 if(kDeltaAODPartCorrName.Length()>0)mgr->RegisterExtraFile(kDeltaAODPartCorrName.Data());
121e4bd5 632 }
633
d2e6cdd5 634 if(iPWG4CaloQA){
635 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/QA/AddTaskCalorimeterQA.C");
9748e967 636 AliAnalysisTaskParticleCorrelation *taskcaloQA = AddTaskCalorimeterQA("ESD",kFALSE,kIsMC,kCaloQAOutputFileName.Data());
d2e6cdd5 637 if(!taskcaloQA)::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation QA cannot run - EXCLUDED");
aba42fcb 638 // if(kCaloQAOutputFileName.Length()>0)mgr->RegisterExtraFile(kCaloQAOutputFileName.Data());
d2e6cdd5 639 }
640
d2e6cdd5 641 if(iPWG4JetCorr){
642 // using namespace JetCorrelHD;
d3af0232 643 TString cdir = gSystem->WorkingDirectory();
644 gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/"));
d2e6cdd5 645 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetCorrel.C");
646 AliAnalysisTaskJetCorrel *taskjetcorr = AddTaskJetCorrel();
d3af0232 647 gSystem->ChangeDirectory(cdir);
c166d299 648 if (!taskjetcorr) ::Warning("AnalysisTrainNew", "AliAnalysisTaskJetCorrel cannot run for this train conditions - EXCLUDED");
d2e6cdd5 649 }
650
911a740f 651 if(iPWG4Tagged){
652 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskTaggedPhotons.C");
653 AliAnalysisTaskTaggedPhotons * taskTagged = AddTaskTaggedPhotons(kFALSE); // EMCAL
58ef946c 654 taskTagged = AddTaskTaggedPhotons(kTRUE); // PHOS
911a740f 655 if (!taskTagged) ::Warning("AnalysisTrainNew", "AliAnalysisTaskTaggedPhotons cannot run for this train conditions - EXCLUDED");
656 }
121e4bd5 657 if (iPWG4omega3pi) {
658 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskomega3pi.C");
659 AliAnalysisTaskOmegaPi0PiPi *taskomega3pi = AddTaskomega3pi();
660 if (!taskomega3pi) ::Warning("AnalysisTrainNew", "AliAnalysisTaskomega3pi cannot run\
661 for these train conditions - EXCLUDED");
662 }
663
53c63663 664 // PWG4 gamma conversion analysis
665 if (iPWG4GammaConv) {
666 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskGammaConversion.C");
667 TString cdir = gSystem->WorkingDirectory();
668 gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/"));
669 // TString gcArguments = "-run-on-train -run-jet -run-chic -run-neutralmeson -run-cf";
58ef946c 670 // TString gcArguments = "-run-on-train -run-jet -run-neutralmeson -run-cf -use-own-xyz";
671 // TString gcArguments = "-run-on-train -run-jet -run-neutralmeson -run-cf -use-own-xyz";
4d5d766e 672 TString gcArguments = "-run-on-train -run-jet -run-omega-meson -run-neutralmeson -no-aod";
673 TString kGCAnalysisCutSelectionId="900356200010031";
674 gcArguments.Append(Form(" -set-cut-selection %s ",kGCAnalysisCutSelectionId.Data()));
53c63663 675 if(!kIsMC)gcArguments += " -mc-off";
676 AliAnalysisTaskGammaConversion * taskGammaConversion = AddTaskGammaConversion(gcArguments,mgr->GetCommonInputContainer());
677 gSystem->ChangeDirectory(cdir);
121e4bd5 678 taskGammaConversion->SelectCollisionCandidates();
53c63663 679 if (!taskGammaConversion) ::Warning("AnalysisTrainNew", "AliAnalysisTaskGammaConversion cannot run for these train conditions - EXCLUDED");
680 }
681
17d96675 682 if (iPWG4CaloConv) {
683 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskCaloConv.C");
684 AliAnalysisTaskCaloConv * taskCaloConv = AddTaskCaloConv();
685 if (!taskCaloConv) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCaloConv cannot run for these train conditions - EXCLUDED");
686 }
687
688
3878a941 689
c38e3b95 690 //==========================================================================
691 // FOR THE REST OF THE TASKS THE MACRO AddTaskXXX() is not yet implemented/
692 // Run the analysis
693 //
694 if (kPluginUse) {
695 AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
696 AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
697 }
698
699 if (mgr->InitAnalysis()) {
700 mgr->PrintStatus();
701 // if (kSaveTrain || strlen(config_file)) gSystem->ChangeDirectory(kTrainName);
e84da0a5 702 if (!strcmp(plugin_mode,"submit")&&smode=="GRID"){
c38e3b95 703 TString alien_workdir = gGrid->GetHomeDirectory();
704 if (iAODanalysis) alien_workdir += "analysisAOD";
705 else alien_workdir += "analysisESD";
3878a941 706 if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data());
c38e3b95 707 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
e84da0a5 708 printf("=== AnalysisTrainPWG4Jets:: Registering jdl in the work directory alien://%s/%s, should be done by the manager! ===\n",
c38e3b95 709 alien_workdir.Data(),gridhandler->GetGridOutputDir());
58ef946c 710
711 TString dest;
712 dest = Form("%s/%s/%s.jdl",alien_workdir.Data(),gridhandler->GetGridOutputDir(),kTrainName.Data());
713 if(AliAnalysisAlien::FileExists(dest.Data())){
714 // Printf("%s exist on grid removing...",dest.Data());
715 // gGrid->Rm(dest.Data());
716 }
717 TFile::Cp(Form("file:%s.jdl",kTrainName.Data()),Form("alien://%s",dest.Data()));
4721d8c5 718
719
720 TString dest;
721 dest = Form("%s/%s/%s_merge.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_merge.jdl",kTrainName.Data()),Form("alien://%s",dest.Data()));
727
58ef946c 728
73b7619a 729 dest = Form("%s/rootfiles/STEER/LQ1dRef_v1.root",gGrid->GetHomeDirectory());
58ef946c 730 if(AliAnalysisAlien::FileExists(dest.Data())){
731 Printf("%s exist on grid removing...",dest.Data());
732 gGrid->Rm(dest.Data());
733 }
734 TFile::Cp(Form("file:%s/STEER/LQ1dRef_v1.root",
9748e967 735 gSystem->ExpandPathName("$ALICE_ROOT")),Form("alien://%s",dest.Data()));
c38e3b95 736 }
3878a941 737 AliLog::SetGlobalLogLevel(AliLog::kError);
c166d299 738 if((kUseSysInfo>0&&smode=="LOCAL")||!strcmp(plugin_mode, "test")){
739 TFile * fM = TFile::Open("manager_local.root","RECREATE");
740 mgr->Write();
741 fM->Close();
742 }
46534866 743
744 // grmpf, aliroot error handler overwrites root
745 gErrorIgnoreLevel = kErrorIgnoreLevel;
746 if(gErrorIgnoreLevel>3000) AliLog::SetGlobalLogLevel(AliLog::kFatal);
c38e3b95 747 StartAnalysis(smode, chain);
4a6f59cb 748 if((kUseSysInfo>0&&smode=="LOCAL")||!strcmp(plugin_mode, "test")){
749 for(int i = 0;i < mgr->GetTopTasks()->GetEntries();i++){
750 mgr->ProfileTask(i);
751 }
752 }
c38e3b95 753 if (!strcmp(plugin_mode, "offline")&&smode=="GRID"){
e84da0a5 754 // Offline mode path files
755 // PatchJDL();
756 PatchAnalysisMacro();
757 }
c38e3b95 758
e84da0a5 759 if (kSaveTrain && smode=="GRID") {
760 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
761 TString alien_workdir = gGrid->GetHomeDirectory();
762 if (iAODanalysis) alien_workdir += "analysisAOD";
3878a941 763 else alien_workdir += "analysisESD";
764 if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data());
e84da0a5 765 // kGridOutdir = gridhandler->GetGridOutputDir();
766 printf("=== Registering ConfigTrain.C in the work directory <%s> ===\n",
c38e3b95 767 alien_workdir.Data());
e84da0a5 768 if (AliAnalysisAlien::FileExists(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data())))
769 gGrid->Rm(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()));
770 if (strcmp(plugin_mode, "test"))
771 TFile::Cp(Form("file:%sConfig.C",kTrainName.Data()), Form("alien://%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()));
772 }
773 }
c38e3b95 774}
775
776//______________________________________________________________________________
777void StartAnalysis(const char *mode, TChain *chain) {
778// Start analysis.
779 Int_t imode = -1;
780 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
781 if (!strcmp(mode, "LOCAL")) imode = 0;
782 if (!strcmp(mode, "PROOF")) imode = 1;
783 if (!strcmp(mode, "GRID")) imode = 2;
784 switch (imode) {
785 case 0:
786 if (!chain) {
787 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain");
788 return;
789 }
82ebd295 790 mgr->StartAnalysis(mode, chain,kNumberOfEvents);
c38e3b95 791 return;
792 case 1:
793 if (!kProofDataSet.Length()) {
794 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "kProofDataSet is empty");
795 return;
796 }
797 mgr->StartAnalysis(mode, kProofDataSet, kProofEvents,kProofOffset);
798 return;
799 case 2:
800 if (kPluginUse) {
801 if (!mgr->GetGridHandler()) {
802 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Grid plugin not initialized");
803 return;
804 }
ebad39a9 805 mgr->StartAnalysis("grid",chain,kNumberOfEvents);
c38e3b95 806 } else {
807 if (!chain) {
808 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain");
809 return;
810 }
811 mgr->StartAnalysis(mode, chain);
ebad39a9 812 mgr->StartAnalysis(mode, chain,kNumberOfEvents);
c38e3b95 813 }
814 return;
815 }
816}
817
818//______________________________________________________________________________
819void CheckModuleFlags(const char *mode) {
820// Checks selected modules and insure compatibility
821 Int_t imode = -1;
822 if (!strcmp(mode, "LOCAL")) imode = 0;
823 if (!strcmp(mode, "PROOF")) imode = 1;
824 if (!strcmp(mode, "GRID")) imode = 2;
825
826
e84da0a5 827 if (kUseCPAR) {
828 kPluginAliRootVersion = ""; // NO aliroot if we use CPAR
829 }
c38e3b95 830
831 if (imode==1) {
832 if (!kUsePAR) {
833 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis");
834 kUsePAR = kTRUE;
835 }
836 }
837 if (imode != 2) {
838 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode");
839 kPluginUse = kFALSE;
840 }
841
842
843 if(!kIsMC){
844 // switch off anthin related to MC
845 kUseMC = 0;
846 kUseAODMC = 0;
847 kUseTR = kFALSE;
848 }
849
850 if (iAODanalysis) {
851 // AOD analysis
852 if (kUseMC)
853 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's");
854 if (kUseAODTags)
855 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AOD tags usage disabled in analysis on AOD's");
856 kUseMC = kFALSE;
857 kUseTR = kFALSE;
858 kUseAODTags = kFALSE;
859 if (iESDfilter)
860 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's");
861 iESDfilter = 0;
e84da0a5 862 if (iPhysicsSelection)
863 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "Physics Selection disabled in analysis on AOD's");
864 iPhysicsSelection = 0;
c38e3b95 865 if (!iAODhandler) {
866 if (iJETAN)
867 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler");
868 iJETAN = 0;
869 iDIJETAN = 0;
870 }
871 // Disable tasks that do not work yet on AOD data
58ef946c 872 if(iPWG4JCORRAN)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 JCORRAN disabled in analysis on AOD's");
4d62ae1a 873 iPWG4JCORRAN = 0;
c38e3b95 874 if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's");
875 iPWG4PtQAMC = 0;
876 if( iPWG4PtQATPC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtTPC disabled in analysis on AOD's");
877 iPWG4PtQATPC = 0;
1f329128 878 if( iPWG4Cosmics)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Comics disabled in analysis on AOD's");
879 iPWG4Cosmics = 0;
880
c38e3b95 881 if( iPWG4PtSpectra)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's");
882 iPWG4PtSpectra = 0;
b53f2e4f 883 if(iPWG4KMeans)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4KMeans disabled on AOD's");
884 iPWG4KMeans = 0;
d2e6cdd5 885 if (iPWG4JetCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4Jetcorr disabled on AOD's");
886 iPWG4JetCorr = 0;
c38e3b95 887 if (iPWG4PartCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4partcorr disabled on AOD's");
888 iPWG4PartCorr = 0;
d2e6cdd5 889 if (iPWG4CaloQA)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4CaloQA disabled on AOD's");
890 iPWG4CaloQA = 0;
911a740f 891 if (iPWG4Tagged)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4tagged disabled on AOD's");
892 iPWG4Tagged = 0;
121e4bd5 893 if (iPWG4omega3pi)
894 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4omega3pi disabled on AOD's");
895 iPWG4omega3pi = 0;
c38e3b95 896 if(iPWG1QASym)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG1 QA Sym disabled in analysis on AOD's");
53c63663 897 if (iPWG4GammaConv)::Info("AnalysisPWG4Jets.C::CheckModuleFlags", "PWG4gammaconv disabled on AOD's");
898 iPWG4GammaConv = 0;
c38e3b95 899 iPWG1QASym = 0;
900 } else {
901 // ESD analysis
902 if (!kUseMC){
903 kUseTR = kFALSE;
904
905 if(kUseKinefilter)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Kine Filter disabled in analysis without MC");
906 kUseKinefilter = kFALSE;
907 if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis without MC");
908 iPWG4PtQAMC = 0;
9748e967 909 if( iPWG4CorrectionsUE)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 CorrectionsUE disabled in analysis without MC");
910 iPWG4CorrectionsUE = 0;
c38e3b95 911 }
912 if (!kUseTR) {
c166d299 913 if(iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "iPWG4QATPCMC disabled if not reading track references");
b03b08a3 914 iPWG4PtQAMC = 0;
c38e3b95 915 }
e84da0a5 916 if (iJETAN){
917 iESDfilter=1;
918 }
c38e3b95 919 if (!iESDfilter){
920 kUseKinefilter = kFALSE;
921 kUseMuonfilter = kFALSE;
922 }
923 if(!iJETAN){
9748e967 924 iPWG4JetSpectrum = iPWG4UE = iPWG4CorrectionsUE = iPWG4ThreeJets = iDIJETAN = 0;
c38e3b95 925 }
926 }
e0c120d9 927 iPWG4JetTasks = iPWG4JetServices||iPWG4JetSpectrum||iPWG4UE||iPWG4LeadingUE||iPWG4PtQAMC||iPWG4PtSpectra||iPWG4PtQATPC||iPWG4Cosmics||iPWG4ThreeJets||iPWG4JetChem||iPWG4Fragmentation;
d2e6cdd5 928 iPWG4PartCorrLibs = iPWG4PartCorr||iPWG4Tagged||iPWG4CaloQA;
17d96675 929 iPWG4GammaConvLib = iPWG4GammaConv||iPWG4CaloConv;
930
931
932 iEMCUtilLibs = iPWG4PartCorrLibs||iPWG4JCORRAN||iPWG4GammaConvLib;
e6993a52 933 iJETANLib = iPWG4JetTasks||iJETAN||iDIJETAN;
17d96675 934
c38e3b95 935 if (iESDfilter) {iAODhandler=1;}
936 if (kUseKinefilter && !kUseMC) kUseKinefilter = kFALSE;
937 if (kUseAODTags && !iAODhandler) kUseAODTags = kFALSE;
938
939
940
941}
942
943//______________________________________________________________________________
944Bool_t Connect(const char *mode) {
945// Connect <username> to the back-end system.
946 Int_t imode = -1;
947 if (!strcmp(mode, "LOCAL")) imode = 0;
948 if (!strcmp(mode, "PROOF")) imode = 1;
949 if (!strcmp(mode, "GRID")) imode = 2;
950 TString username = gSystem->Getenv("alien_API_USER");
951 switch (imode) {
952 case 0:
953 break;
954 case 1:
955 if (!username.Length()) {
956 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \
957 1. Have called: alien-token-init <username>\n \
958 2. Have called: >source /tmp/gclient_env_$UID");
959 return kFALSE;
960 }
961 ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to PROOF cluster <%s>",
962 username.Data(), kProofCluster.Data());
963 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
964// TProof::Open(Form("%s@%s:31093", username.Data(), kProofCluster.Data()));
965 TProof::Open(Form("%s@%s", username.Data(), kProofCluster.Data()));
966 if (!gProof) {
967 if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch"))
968 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch");
969 return kFALSE;
970 }
971 if(kProofClearPackages)gProof->ClearPackages();
972
973 if(kProofSaveToAlien){
974 TGrid::Connect("alien://");
975 if (gGrid) {
976 TString homedir = gGrid->GetHomeDirectory();
977 TString workdir = homedir + kTrainName;
978 if (!gGrid->Cd(workdir)) {
979 gGrid->Cd(homedir);
980 if (gGrid->Mkdir(workdir)) {
981 gGrid->Cd(kTrainName);
982 ::Info("AnalysisTrainPWG4Jets::Connect()", "Directory %s created", gGrid->Pwd());
983 }
984 }
985 gGrid->Mkdir("proof_output");
986 gGrid->Cd("proof_output");
987 kProofOutdir = Form("alien://%s", gGrid->Pwd());
988 }
989 }
990 break;
991 case 2:
992 if (!username.Length()) {
993 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \
994 1. Have called: alien-token-init <username>\n \
995 2. Have called: >source /tmp/gclient_env_$UID");
996 return kFALSE;
997 }
998 if (kPluginUse && !gSystem->Getenv("alien_CLOSE_SE")) {
999 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode),
1000 "When using the AliEn plugin it is preferable to define the \
1001 variable alien_CLOSE_SE in your environment.");
1002 return kFALSE;
1003 }
1004 ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to AliEn ...",
1005 username.Data());
1006 TGrid::Connect("alien://");
1007 if (!gGrid || !gGrid->IsConnected()) return kFALSE;
1008 break;
1009 default:
1010 ::Error("AnalysisTrainPWG4Jets.C::Connect", "Unknown run mode: %s", mode);
1011 return kFALSE;
1012 }
1013 ::Info("AnalysisTrainPWG4Jets.C::Connect","Connected in %s mode", mode);
1014 return kTRUE;
1015}
1016
1017//______________________________________________________________________________
1018Bool_t LoadCommonLibraries(const char *mode)
1019{
1020// Load common analysis libraries.
1021 Int_t imode = -1;
1022 if (!strcmp(mode, "LOCAL")) imode = 0;
1023 if (!strcmp(mode, "PROOF")) imode = 1;
1024 if (!strcmp(mode, "GRID")) imode = 2;
1025 if (!gSystem->Getenv("ALICE_ROOT")) {
ebad39a9 1026 ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Analysis train requires that ALICE_ROOT is set to pick up Configurations");
c38e3b95 1027 return kFALSE;
1028 }
1029 Bool_t success = kTRUE;
1030 // ROOT libraries
1031 gSystem->Load("libTree.so");
1032 gSystem->Load("libGeom.so");
1033 gSystem->Load("libVMC.so");
1034 gSystem->Load("libPhysics.so");
1035
1036 // Load framework classes. Par option ignored here.
1037 switch (imode) {
1038 case 0:
1039 case 2:
1040 if (kUseCPAR) {
1041 success &= LoadLibrary("STEERBase", mode, kTRUE);
1042 success &= LoadLibrary("ESD", mode, kTRUE);
1043 success &= LoadLibrary("AOD", mode, kTRUE);
1044 success &= LoadLibrary("ANALYSIS", mode, kTRUE);
1045 success &= LoadLibrary("ANALYSISalice", mode, kTRUE);
1046 success &= LoadLibrary("CORRFW", mode, kTRUE);
1047 } else {
1048 success &= LoadLibrary("libSTEERBase.so", mode);
1049 success &= LoadLibrary("libESD.so", mode);
1050 success &= LoadLibrary("libAOD.so", mode);
1051 success &= LoadLibrary("libANALYSIS.so", mode);
1052 success &= LoadLibrary("libANALYSISalice.so", mode);
1053 success &= LoadLibrary("libCORRFW.so", mode);
1054 gROOT->ProcessLine(".include $ALICE_ROOT/include");
1055 }
1056 break;
1057 case 1:
1058 Int_t ires = -1;
1059 if (kProofUseAFPAR && !gSystem->AccessPathName(kProofAFversion)) ires = gProof->UploadPackage(kProofAFversion);
1060 if (ires < 0) {
1061 success &= LoadLibrary("STEERBase", mode);
1062 success &= LoadLibrary("ESD", mode);
1063 success &= LoadLibrary("AOD", mode);
1064 success &= LoadLibrary("ANALYSIS", mode);
1065 success &= LoadLibrary("ANALYSISalice", mode);
1066 success &= LoadLibrary("CORRFW", mode);
1067 } else {
1068 ires = gProof->EnablePackage(kProofAFversion);
1069 if (ires<0) success = kFALSE;
1070 success &= LoadLibrary("CORRFW", mode);
1071 }
1072 break;
1073 default:
1074 ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Unknown run mode: %s", mode);
1075 return kFALSE;
1076 }
1077 if (success) {
1078 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: SUCCESS");
1079 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s",
1080 gSystem->GetIncludePath());
1081 } else {
1082 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: FAILED");
1083 }
1084
1085 return success;
1086}
1087
1088//______________________________________________________________________________
1089Bool_t LoadAnalysisLibraries(const char *mode)
1090{
1091// Load common analysis libraries.
9748e967 1092 Bool_t success = kTRUE;
c38e3b95 1093 if (iESDfilter) {
1094 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
1095 !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE;
1096 }
1097 // JETAN
e6993a52 1098 if (iJETANLib) {
b53f2e4f 1099 // this part needs some rework in case we do not need the fastjed finders for processing
1100 if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE;
c38e3b95 1101 if (!strcmp(mode, "PROOF")){
ef1e462f 1102 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libCGAL.so\"\)", kTRUE);
c38e3b95 1103 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libfastjet.so\"\)", kTRUE);
1104 // problem when loading siscone copiled with different gcc version??
1105 // gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libsiscone.so\"\)", kTRUE);
1106 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libSISConePlugin.so\"\)", kTRUE);
1107 }
b53f2e4f 1108 if(!kUsePAR){
e84da0a5 1109 if (!LoadLibrary("CGAL", mode, kTRUE)) return kFALSE;
1110 if (!LoadLibrary("fastjet", mode, kTRUE)) return kFALSE;
1111 if (!LoadLibrary("siscone", mode, kTRUE)) return kFALSE;
1112 if (!LoadLibrary("SISConePlugin", mode, kTRUE)) return kFALSE;
1113 }
1114 else{
1115 // par files plus FASTJET needs some extra work... need to change
1116 // the loading sequence in the auto generated .C file
1117 if (!LoadLibrary("libCGAL.so", mode, kTRUE)) return kFALSE;
1118 if (!LoadLibrary("libfastjet.so", mode, kTRUE)) return kFALSE;
1119 if (!LoadLibrary("libsiscone.so", mode, kTRUE)) return kFALSE;
1120 if (!LoadLibrary("libSISConePlugin.so", mode, kTRUE)) return kFALSE;
1121 }
c38e3b95 1122 if (!LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE;
1123 }
1124 if(iPWG4JetTasks){
c38e3b95 1125 if (!LoadLibrary("PWG4JetTasks", mode, kTRUE)) return kFALSE;
1126 }
58ef946c 1127
c38e3b95 1128 if(iPWG1QASym){
99bfd7f7 1129 if (!LoadSource(Form("%s/PWG1/AliAnalysisTaskQASym.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
c38e3b95 1130 }
121e4bd5 1131 if(iPWG4TmpSourceSara){
c166d299 1132 if(!kUsePAR)gSystem->AddIncludePath("-I$ALICE_ROOT/include/JetTasks"); // ugly hack!!
121e4bd5 1133 if(!LoadSource(Form("%s/PWG4/JetTasks/AliAnalysisTaskEta.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
1134 }
58ef946c 1135
9f77f0ce 1136 /*
1137 if(iPWG4JetChem){
c580ebbb 1138 if(!kUsePAR)gSystem->AddIncludePath("-I$ALICE_ROOT/include/JetTasks"); // ugly hack!!
1139 if(!LoadSource(Form("%s/PWG4/JetTasks/AliAnalysisTaskJetChem.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
1140 }
9f77f0ce 1141 */
c166d299 1142
4721d8c5 1143 if(iEMCUtilLibs){
1144 if (!LoadLibrary("EMCALUtils", mode, kTRUE) ||
1145 !LoadLibrary("PHOSUtils", mode, kTRUE)) return kFALSE;
1146 }
1147
911a740f 1148 if (iPWG4PartCorrLibs) {
4721d8c5 1149 if (!LoadLibrary("PWG4PartCorrBase", mode, kTRUE) ||
c38e3b95 1150 !LoadLibrary("PWG4PartCorrDep", mode, kTRUE)) return kFALSE;
1151 }
4721d8c5 1152 if(iPWG4JCORRAN){
1153 // PWG4 particle correlations
1154 if(!LoadLibrary("PWG4JCORRAN",mode,kTRUE))return kFALSE;
1155 }
d2e6cdd5 1156 if (iPWG4JetCorr) {
1157 if (!LoadLibrary("PWG4JetCorrel", mode, kTRUE)) return kFALSE;
1158 }
121e4bd5 1159 if (iPWG4omega3pi) {
1160 if (!LoadLibrary("PWG4omega3pi", mode, kTRUE)) return kFALSE;
1161 }
17d96675 1162 if (iPWG4GammaConvLib) {
53c63663 1163 if (!LoadLibrary("PWG4GammaConv", mode, kTRUE)) return kFALSE;
1164 }
c38e3b95 1165
1166 ::Info("AnalysisTrainPWG4Jets.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS");
1167 return kTRUE;
1168}
1169
1170//______________________________________________________________________________
1171Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE)
1172{
1173// Load a module library in a given mode. Reports success.
1174 Int_t imode = -1;
1175 Int_t result;
1176 TString smodule(module);
1177 if (!strcmp(mode, "LOCAL")) imode = 0;
1178 if (!strcmp(mode, "PROOF")) imode = 1;
1179 if (!strcmp(mode, "GRID")) imode = 2;
1180 TString mod(module);
1181 if (!mod.Length()) {
1182 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Empty module name");
1183 return kFALSE;
1184 }
1185 // If a library is specified, just load it
1186 if (smodule.EndsWith(".so")) {
1187 mod.Remove(mod.Index(".so"));
1188 result = gSystem->Load(mod);
1189 if (result < 0) {
1190 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load library %s", module);
1191 return kFALSE;
1192 }
1193 if (rec) anaLibs += Form("%s.so ",mod.Data());
e84da0a5 1194 if (rec) anaLibsExtra += Form("%s.so ",mod.Data());
c38e3b95 1195 return kTRUE;
1196 }
1197 // Check if the library is already loaded
1198 if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0)
1199 return kTRUE;
1200 switch (imode) {
1201 case 0:
1202 case 2:
1203 if (kUsePAR) {
1204 result = SetupPar(module);
1205 if (rec) anaPars += Form("%s.par ", module);
1206 } else {
1207 result = gSystem->Load(Form("lib%s.so", module));
1208 if (rec) anaLibs += Form("lib%s.so ", module);
1209 }
1210 break;
1211 case 1:
1212 if(!gSystem->AccessPathName(module)){
1213 ::Info("AnalysisTrainPWG4Jets.C::LoadLibrary", "Removing directory %s",module);
1214 gSystem->Exec(Form("rm -rf %s",module));
1215 }
1216 result = gProof->UploadPackage(module);
1217 if (result<0) {
1218 result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module)));
1219 if (result<0) {
1220 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module);
1221 return kFALSE;
1222 }
1223 }
1224 result = gProof->EnablePackage(module);
1225 break;
1226 default:
1227 return kFALSE;
1228 }
1229 if (result < 0) {
1230 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load module %s", module);
1231 return kFALSE;
1232 }
1233 return kTRUE;
1234}
1235
1236
1237
1238//______________________________________________________________________________
1239Bool_t LoadSource(const char *source, const char *mode, Bool_t rec=kFALSE)
1240{
1241// Load a module library in a given mode. Reports success.
1242 Int_t imode = -1;
1243 Int_t result = -1;
1244 if (!strcmp(mode, "LOCAL")) imode = 0;
1245 if (!strcmp(mode, "PROOF")) imode = 1;
1246 if (!strcmp(mode, "GRID")) imode = 2;
1247 TString ssource(source);
1248 TString basename = gSystem->BaseName(ssource.Data());
1249 if (!ssource.Length()) {
1250 ::Error("AnalysisTrainPWG4Jets.C::LoadSource", "Empty task name");
1251 return kFALSE;
1252 }
4d62ae1a 1253 // we have a source code so compile it
c38e3b95 1254 if (ssource.EndsWith(".cxx")) {
1255 // need to copy it here other wise the path is also used on grid...
1256 ssource.Remove(ssource.Index(".cxx"));
1257 basename.Remove(basename.Index(".cxx"));
1258 Printf("LoadSources:: Copying... path %s{cxx,h}",ssource.Data());
1259 gSystem->Exec(Form("cp %s.cxx . ",ssource.Data()));
1260 gSystem->Exec(Form("cp %s.h . ",ssource.Data()));
1261 // Path to code
1262 // only needed for local compilation, in grid and proof mode
1263 // the task headers are uploaded
1264 // path.Remove(path.Index(gSystem->BaseName(path.Data())));
1265 // Printf("LoadSources:: Including path %s",path.Data());
1266 // if(path.Length()>0)gROOT->ProcessLine(Form(".include %s",path.Data()));
1267 Printf("LoadSources:: Loading... path %s",basename.Data());
1268 switch (imode) {
1269 case 0:
b53f2e4f 1270 result = gROOT->LoadMacro(Form("%s.cxx++g",basename.Data()));
c38e3b95 1271 break;
1272 case 1:
b53f2e4f 1273 result = gProof->LoadMacro(Form("%s.cxx++g",basename.Data()));
c38e3b95 1274 break;
1275 case 2:
b53f2e4f 1276 result = gROOT->LoadMacro(Form("%s.cxx++g",basename.Data()));
c38e3b95 1277 if (rec){
1278 // what we want to compile
1279 anaSources += Form("%s.cxx ",basename.Data());
1280 // what we need as input...
1281 anaLibs += Form("%s.cxx %s.h ",basename.Data(),basename.Data());
1282 }
1283 break;
1284 default:
1285 return kFALSE;
1286 }
1287 }
1288 if (result < 0) {
1289 ::Error("AnalysisTrainPWG4Jets.C::LoadSources", "Could not load source %s", source);
1290 return kFALSE;
1291 }
1292 return kTRUE;
1293}
1294
1295
1296//______________________________________________________________________________
1297TChain *CreateChain(const char *mode, const char *plugin_mode)
1298{
1299// Create the input chain
1300 Int_t imode = -1;
1301 if (!strcmp(mode, "LOCAL")) imode = 0;
1302 if (!strcmp(mode, "PROOF")) imode = 1;
1303 if (!strcmp(mode, "GRID")) imode = 2;
1304 TChain *chain = NULL;
1305 // Local chain
1306 switch (imode) {
1307 case 0:
1308 if (iAODanalysis) {
1309 if (!kLocalXMLDataset.Length()) {
1310 // Local AOD
1311 chain = new TChain("aodTree");
1312 TString line;
1313 ifstream in;
1314 in.open(kLocalDataList.Data());
1315 while (in.good()) {
1316 in >> line;
1317 if (line.Length() == 0) continue;
1318 // cout << " line = " << line << endl;
1319 chain->Add(line.Data());
1320 }
1321 } else {
1322 // Interactive AOD
1323 chain = CreateChainSingle(kLocalXMLDataset, "aodTree");
1324 }
1325 } else {
1326 if (!kLocalXMLDataset.Length()) {
1327 // Local ESD
1328 chain = new TChain("esdTree");
1329 TString line;
1330 ifstream in;
1331 in.open(kLocalDataList.Data());
1332 while (in.good()) {
1333 in >> line;
1334 if (line.Length() == 0) continue;
1335 cout << " line = " << line << endl;
1336 chain->Add(line.Data());
1337 }
1338 } else {
1339 // Interactive ESD
1340 chain = CreateChainSingle(kLocalXMLDataset, "esdTree");
1341 }
1342 }
1343 break;
1344 case 1:
1345 break;
1346 case 2:
1347 if (kPluginUse) {
1348// AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
1349// AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
1350 } else {
1351 TString treeName = "esdTree";
1352 if (iAODanalysis) treeName = "aodTree";
1353 chain = CreateChainSingle("wn.xml", treeName);
1354 }
1355 break;
1356 default:
1357 }
1358 if (chain && chain->GetNtrees()) return chain;
1359 return NULL;
1360}
1361
1362//______________________________________________________________________________
1363TChain* CreateChainSingle(const char* xmlfile, const char *treeName)
1364{
1365 printf("*******************************\n");
1366 printf("*** Getting the ESD Chain ***\n");
1367 printf("*******************************\n");
1368 TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
1369
1370 if (!myCollection) {
1371 ::Error("AnalysisTrainPWG4Jets.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
1372 return NULL ;
1373 }
1374
1375 TChain* chain = new TChain(treeName);
1376 myCollection->Reset() ;
1377 while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
1378 chain->ls();
1379 return chain;
1380}
1381
1382//______________________________________________________________________________
1383Int_t SetupPar(char* pararchivename)
1384{
1385 if (!pararchivename || !strlen(pararchivename)) return -1;
1386 char processline[1024];
1387 if (gSystem->AccessPathName(Form("%s.par", pararchivename))) {
1388 if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) {
1389 ::Info("AnalysisTrainPWG4Jets.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename);
9748e967 1390 TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)),
1391 Form("%s.par",pararchivename));
c38e3b95 1392 } else {
1393 ::Error("AnalysisTrainPWG4Jets.C::SetupPar", "Cannot find %s.par", pararchivename);
1394 return -1;
1395 }
1396 }
1397 if (kPluginUse && kSaveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, kTrainName.Data()));
1398 gSystem->Exec(Form("tar xvzf %s.par", pararchivename));
1399
1400 TString ocwd = gSystem->WorkingDirectory();
1401 if (!gSystem->ChangeDirectory(pararchivename)) return -1;
1402
1403 // check for BUILD.sh and execute
1404 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
1405 printf("*******************************\n");
1406 printf("*** Building PAR archive ***\n");
1407 printf("*******************************\n");
1408 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
1409 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
1410 return -1;
1411 }
1412 }
1413
1414 // check for SETUP.C and execute
1415 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
1416 printf("*******************************\n");
1417 printf("*** Setup PAR archive ***\n");
1418 printf("*******************************\n");
1419 gROOT->Macro("PROOF-INF/SETUP.C");
1420 }
1421 if (!gSystem->ChangeDirectory(ocwd.Data())) return -1;
1422 return 0;
1423}
1424
1425//______________________________________________________________________________
1426AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
1427{
1428// Check if user has a valid token, otherwise make one. This has limitations.
1429// One can always follow the standard procedure of calling alien-token-init then
1430// source /tmp/gclient_env_$UID in the current shell.
1431 if (!AliAnalysisGrid::CreateToken()) return NULL;
1432 AliAnalysisAlien *plugin = new AliAnalysisAlien();
1433// Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
1434 plugin->SetRunMode(plugin_mode);
1435 if (kPluginUseProductionMode) plugin->SetProductionMode();
1436 plugin->SetJobTag(kJobTag);
e0c120d9 1437 plugin->SetNtestFiles(1);
c38e3b95 1438// plugin->SetPreferedSE("ALICE::NIHAM::File");
1439// Set versions of used packages
e84da0a5 1440 plugin->SetAPIVersion("V1.1x");
1441 // plugin->SetAPIVersion("V1.0x");
1442// plugin->SetAPIVersion("V2.4");
c38e3b95 1443 plugin->SetROOTVersion(kPluginRootVersion);
1444 plugin->SetAliROOTVersion(kPluginAliRootVersion);
1445// Declare input data to be processed.
1446// Method 1: Create automatically XML collections using alien 'find' command.
1447// Define production directory LFN
1448 plugin->SetGridDataDir(kGridDatadir.Data());
1449// Set data search pattern
1450 if (iAODanalysis) plugin->SetDataPattern(" *AliAOD.root");
1451 else plugin->SetDataPattern(Form(" %s/*/*ESD.tag.root",kGridPassPattern.Data()));
1452// ...then add run numbers to be considered
1453// plugin->SetRunRange(kGridRunRange[0], kGridRunRange[1]);
1454 for (Int_t i=kGridRunRange[0]; i<=kGridRunRange[1]; i++) {
1455 Printf("AnalysisTrainPWG4Jets Adding run number %s", Form(kGridRunPattern.Data(),i));
1456 plugin->AddRunNumber(Form(kGridRunPattern.Data(),i));
1457 }
1458
1459 if(kGridLocalRunList.Length()>0){
1460 ifstream in1;
1461 in1.open(kGridLocalRunList.Data());
1462 int iRun;
9a5c5b1e 1463
1464 /*
e84da0a5 1465 char c;
1466 char cLine[250];
1467 while(!in1.eof()){
1468 c = in1.get();
1469 if ( (c >= '0') && (c <= '9') )
1470 {
1471 in1.putback (c);
1472 in1>>iRun;
1473 Printf("AnalysisTrainPWG4Jets Adding run number from File %s", Form(kGridRunPattern.Data(),iRun));
1474 plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun));
1475 }
1476 else
1477 {
1478 in1.putback (c);
1479 in1.getline(cLine,250);
9a5c5b1e 1480
1481 }
1482 }
1483 */
9748e967 1484
1485 Int_t nRun = 0;
9a5c5b1e 1486
1487 // just use run numbers, negatives will be excluded
1488 while(in1>>iRun){
9748e967 1489
4d5d766e 1490 if(iRun>=0&&(nRun<kGridMaxRunsFromList)){
9a5c5b1e 1491 Printf("AnalysisTrainPWG4Jets Adding run number from File %s", Form(kGridRunPattern.Data(),iRun));
1492 plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun));
9748e967 1493 nRun++;
9a5c5b1e 1494 }
1495 else{
1496 Printf("AnalysisTrainPWG4Jets Skipping run number from File %d", iRun);
e84da0a5 1497 }
c38e3b95 1498 }
1499 }
1500
1501// Method 2: Declare existing data files (raw collections, xml collections, root file)
1502// If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
1503// XML collections added via this method can be combined with the first method if
1504// the content is compatible (using or not tags)
1505// plugin->AddDataFile("tag.xml");
1506// plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
1507// Define alien work directory where all files will be copied. Relative to alien $HOME.
3878a941 1508 TString alien_workdir = "";
1509
1510 if (iAODanalysis) alien_workdir += "analysisAOD";
1511 else alien_workdir += "analysisESD";
1512 if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data());
1513 plugin->SetGridWorkingDir(alien_workdir.Data());
1514
c38e3b95 1515 // Declare alien output directory. Relative to working directory.
1516 if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
1517 plugin->SetGridOutputDir(kGridOutdir);
1518
1519 // Add external packages
1520 if (iJETAN||iDIJETAN) {
23adcac8 1521 plugin->AddExternalPackage("boost::v1_43_0");
1522 plugin->AddExternalPackage("cgal::v3.6");
1523 plugin->AddExternalPackage("fastjet::v2.4.2");
c38e3b95 1524 }
1525
1526
1527 // set extra libs before par file compilation
1528 anaLibs += kGridExtraFiles;
1529 anaLibs = anaLibs.Strip();
e84da0a5 1530 Printf("anaLibs %s",anaLibs.Data());
1531 Printf("anaLibsExtra %s",anaLibsExtra.Data());
1532
1533 if (anaLibs.Length()) plugin->SetAdditionalLibs(anaLibs.Data());
1534 if (anaLibsExtra.Length()) plugin->SetAdditionalRootLibs(anaLibsExtra.Data());
c38e3b95 1535
1536 TString ana_sources = "";
1537 TString ana_add = "";
1538 if (kUsePAR && anaPars.Length()) {
1539 printf("%s\n", anaPars.Data());
1540 TObjArray *arr;
1541 TObjString *objstr;
1542 arr = anaPars.Tokenize(" ");
1543 TIter next(arr);
1544 while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString());
1545 delete arr;
1546 }
1547
1548// Declare the analysis source files names separated by blancs. To be compiled runtime
1549// using ACLiC on the worker nodes.
1550 ana_sources = anaSources.Strip();
1551// Declare all libraries (other than the default ones for the framework. These will be
1552// loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
1553
1554 if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources);
1555 plugin->SetExecutableCommand(kPluginExecutableCommand.Data());
4721d8c5 1556 // Declare the output file names separated by blancs.
1557 // (can be like: file.root or file.root@ALICE::Niham::File)
c38e3b95 1558 plugin->SetMergeExcludes(kGridMergeExclude);
1559 plugin->SetMaxMergeFiles(kGridMaxMergeFiles);
1560 plugin->SetNrunsPerMaster(kGridRunsPerMaster);
9a5c5b1e 1561 plugin->SetMergeViaJDL(kPluginMergeViaJDL);
4721d8c5 1562 // Use fastread option
9a5c5b1e 1563 plugin->SetFastReadOption(kPluginFastReadOption);
4721d8c5 1564 // UseOverwrite mode
9a5c5b1e 1565 plugin->SetOverwriteMode(kPluginOverwriteMode);
4721d8c5 1566 // Optionally define the files to be archived.
1567 // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File");
dc6a7461 1568 plugin->SetOutputToRunNo(kPluginOutputToRunNumber); // write the output to subdirs named after run number
c38e3b95 1569
1570 // Put default output files to archive
1571 TString listhists = "";
1572 TString listaods = "";
1573 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1574 TIter next(mgr->GetOutputs());
1575 AliAnalysisDataContainer *output;
1576 while ((output=(AliAnalysisDataContainer*)next())) {
1577 const char *filename = output->GetFileName();
1578 if (!(strcmp(filename, "default"))) {
53c63663 1579 if (!mgr->GetOutputEventHandler()) continue;
c38e3b95 1580 filename = mgr->GetOutputEventHandler()->GetOutputFileName();
e84da0a5 1581 if (listaods.Length()) listaods += " ";
c38e3b95 1582 listaods += filename;
c38e3b95 1583 } else {
e84da0a5 1584 if(!listhists.Contains(filename)){
1585 if (listhists.Length()) listhists += " ";
c38e3b95 1586 listhists += filename;
1587 }
1588 }
1589 }
53c63663 1590
53c63663 1591 if (mgr->GetExtraFiles().Length()) {
e84da0a5 1592 if (listaods.Length()) listaods += " ";
53c63663 1593 listaods += mgr->GetExtraFiles();
c38e3b95 1594 }
53c63663 1595
1596 // if we do not fill the aod we do not need to store it
4721d8c5 1597 // kGridMergeExclude = listaods;
e84da0a5 1598
4721d8c5 1599 if(kSaveAOD!=0){
1600 TString outputFiles = "";
1601 outputFiles += mgr->GetExtraFiles();
1602 if (listhists.Length()) outputFiles += " ";
1603 outputFiles += listhists;
e84da0a5 1604 plugin->SetDefaultOutputs(kFALSE);
4721d8c5 1605 Printf("%s:%d Starting with the files %s",(char*)__FILE__,__LINE__,outputFiles.Data());
1606 // remove
1607 // no harm done when we try to remove something that is not there :)
1608 if(!(kSaveAOD&(1<<0))){
1609 outputFiles.ReplaceAll("AliAOD.root ","");
1610 listaods.ReplaceAll("AliAOD.root ","");
1611 }
1612 if(!(kSaveAOD&(1<<1))){
1613 if(kDeltaAODJetName.Length())outputFiles.ReplaceAll(kDeltaAODJetName.Data(),"");
1614 if(kDeltaAODJetName.Length())listaods.ReplaceAll(kDeltaAODJetName.Data(),"");
1615
1616 }
1617 if(!(kSaveAOD&(1<<2))){
1618 if(kDeltaAODPartCorrName.Length())outputFiles.ReplaceAll(kDeltaAODPartCorrName.Data(),"");
1619 if(kDeltaAODPartCorrName.Length())listaods.ReplaceAll(kDeltaAODPartCorrName.Data(),"");
1620 }
1621 if(!(kSaveAOD&(1<<3))){
1622 if(kDeltaAODJCORRANName.Length())outputFiles.ReplaceAll(kDeltaAODJCORRANName.Data(),"");
1623 if(kDeltaAODJCORRANName.Length())listaods.ReplaceAll(kDeltaAODJCORRANName.Data(),"");
1624 }
1625
1626 //
1627 Printf("%s:%d Saving the files %s",(char*)__FILE__,__LINE__,outputFiles.Data());
1628 plugin->SetOutputFiles(outputFiles.Data());
e84da0a5 1629 }
53c63663 1630
4721d8c5 1631 TString outputArchive;
4d5d766e 1632 outputArchive = Form("log_archive.zip:std*@%s","disk=1");
e84da0a5 1633 listaods.ReplaceAll(" ", ",");
1634 listhists.ReplaceAll(" ", ",");
4d5d766e 1635 if (listhists.Length()){
1636 outputArchive += " ";
1637 outputArchive += "root_archive.zip:";
1638 outputArchive += listhists;
1639 if (listaods.Length()){
1640 outputArchive += ",";
1641 outputArchive += listaods;
1642 }
1643 outputArchive += Form("@%s", kGridOutputStorages.Data());
1644 }
1645 else{
1646
1647 if (listaods.Length()){
1648 // we have only aod'ish output
1649 outputArchive += " ";
1650 outputArchive += "root_archive.zip:";
1651 outputArchive += listaods;
1652 outputArchive += Form("@%s", kGridOutputStorages.Data());
1653 }
1654 else{
1655 // no other outputs than std..
c38e3b95 1656 ::Fatal("AnalysisTrainPWG4Jets", "No task output !");
4d5d766e 1657 }
c38e3b95 1658 }
4d5d766e 1659
17d96675 1660 plugin->SetDefaultOutputs(kFALSE);
c38e3b95 1661 plugin->SetOutputArchive(outputArchive);
17d96675 1662
4721d8c5 1663
4d5d766e 1664 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
c38e3b95 1665 plugin->SetAnalysisMacro(Form("%s.C", kTrainName.Data()));
4d5d766e 1666 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
c38e3b95 1667 plugin->SetSplitMaxInputFileNumber(kGridFilesPerJob);
4d5d766e 1668 // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
1669 plugin->SetMaxInitFailed(5);
1670 // Optionally resubmit threshold.
1671 // plugin->SetMasterResubmitThreshold(90);
1672 // Optionally set time to live (default 30000 sec)
17d96675 1673 plugin->SetTTL(50400); // 14h...
4d5d766e 1674 // Optionally set input format (default xml-single)
c38e3b95 1675 plugin->SetInputFormat("xml-single");
4d5d766e 1676 // Optionally modify the name of the generated JDL (default analysis.jdl)
c38e3b95 1677 plugin->SetJDLName(Form("%s.jdl", kTrainName.Data()));
4d5d766e 1678 // Optionally modify the executable name (default analysis.sh)
c38e3b95 1679 plugin->SetExecutable(Form("%s.sh", kTrainName.Data()));
4d5d766e 1680 // Optionally modify job price (default 1)
c38e3b95 1681 plugin->SetPrice(1);
4d5d766e 1682 // Optionally modify split mode (default 'se')
c38e3b95 1683 plugin->SetSplitMode("se");
1684 return plugin;
1685}
1686
1687//______________________________________________________________________________
1688void WriteConfig()
1689{
1690// Write train configuration in a file. The file name has the format:
1691// train_[trainName]_ddMonthyyyy_time.C
1692 if (kUseDate) {
1693 gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp");
1694 ifstream fdate("date.tmp");
1695 if (!fdate.is_open()) {
1696 ::Error("AnalysisTrainPWG4Jets.C::Export","Could not generate file name");
1697 return;
1698 }
1699 const char date[64];
1700 fdate.getline(date,64);
1701 fdate.close();
1702 gSystem->Exec("rm date.tmp");
1703 kTrainName = Form("train_%s_%s", kTrainName.Data(), date);
1704 } else {
1705 kTrainName = Form("train_%s", kTrainName.Data());
1706 }
1707 TString cdir = gSystem->WorkingDirectory();
1708 gSystem->MakeDirectory(kTrainName);
1709 gSystem->ChangeDirectory(kTrainName);
1710 ofstream out;
1711 out.open(Form("%sConfig.C",kTrainName.Data()), ios::out);
1712 if (out.bad()) {
1713 ::Error("AnalysisTrainPWG4Jets.C::Export", "Cannot open ConfigTrain.C for writing");
1714 return;
1715 }
1716 out << "{" << endl;
1717 out << " kTrainName = " << "\"" << kTrainName.Data() << "\";" << endl;
1718 out << " kProofCluster = " << "\"" << kProofCluster.Data() << "\";" << endl;
1719 out << " kProofUseAFPAR = " << kProofUseAFPAR << ";" << endl;
1720 if (kProofUseAFPAR)
1721 out << " kProofAFversion = " << kProofAFversion.Data() << ";" << endl;
1722 out << " kProofDataSet = " << "\"" << kProofDataSet.Data() << "\";" << endl;
1723 out << " kPluginUse = " << kPluginUse << ";" << endl;
1724 out << " kUsePAR = " << kUsePAR << ";" << endl;
1725 out << " kUseCPAR = " << kUseCPAR << ";" << endl;
1726 out << " kPluginRootVersion = " << "\"" << kPluginRootVersion.Data() << "\";" << endl;
1727 out << " kPluginAliRootVersion = " << "\"" << kPluginAliRootVersion.Data() << "\";" << endl;
1728 out << " kGridDatadir = " << "\"" << kGridDatadir.Data() << "\";" << endl;
1729 if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
1730 out << " kGridOutdir = " << "\"" << kGridOutdir.Data() << "\";" << endl;
1731 out << " kGridMaxMergeFiles = " << kGridMaxMergeFiles << ";" << endl;
1732 out << " kGridMergeExclude = " << "\"" << kGridMergeExclude.Data() << "\";" << endl;
1733 out << " kGridRunsPerMaster = " << kGridRunsPerMaster << ";" << endl;
1734 out << " kGridFilesPerJob = " << kGridFilesPerJob << ";" << endl;
1735 out << " kGridRunRange[0] = " << kGridRunRange[0] << ";" << endl;
1736 out << " kGridRunRange[1] = " << kGridRunRange[1] << ";" << endl;
1737 out << " kUseDebug = " << kUseDebug << ";" << endl;
1738 out << " kUseMC = " << kUseMC << ";" << endl;
1739 out << " kUseESDTags = " << kUseESDTags << ";" << endl;
1740 out << " kUseKinefilter = " << kUseKinefilter << ";" << endl;
1741 out << " kUseTR = " << kUseTR << ";" << endl;
1742 out << " kUseAODTags = " << kUseAODTags << ";" << endl;
1743 out << " kSaveTrain = " << "kFALSE;" << endl << endl;
1744 out << " // Analysis modules" << endl;
1745 out << " iAODanalysis = " << iAODanalysis << ";" << endl;
1746 out << " iAODhandler = " << iAODhandler << ";" << endl;
1747 out << " iESDfilter = " << iESDfilter << ";" << endl;
1748 out << " iJETAN = " << iJETAN << ";" << endl;
1749 out << "// Configuration fot the wagons" << endl;
1750 out << "}" << endl;
1751 ::Info("AnalysisTrainPWG4Jets.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", kTrainName.Data()));
1752 gSystem->ChangeDirectory(cdir);
1753}
1754
1755//______________________________________________________________________________
1756Bool_t LoadConfig(const char *filename)
1757{
1758// Read train configuration from file
1759 if (gSystem->AccessPathName(filename)) {
1760 ::Error("AnalysisTrainPWG4Jets.C::LoadConfig", "Config file name not found");
1761 return kFALSE;
1762 }
1763 gROOT->ProcessLine(Form(".x %s", filename));
1764 ::Info("AnalysisTrainPWG4Jets.C::LoadConfig", "Train configuration loaded from file %s", filename);
1765 return kTRUE;
1766}
1767
1768Bool_t PatchJDL(){
1769 Printf(">>> Patching JDL");
1770 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1771 AliAnalysisAlien* gridHandler = (AliAnalysisAlien*)mgr->GetGridHandler();
1772 TGridJDL *jdl = gridHandler->GetGridJDL();
1773 if(iJETAN)jdl->AddToPackages("fastjet","v2.4.0");
1774 gridHandler->WriteJDL(kFALSE);
0971dabc 1775 Printf("<<< Patching JDL");
c38e3b95 1776 return kTRUE;
1777}
1778
1779Bool_t PatchAnalysisMacro(){
4721d8c5 1780 Printf(">>> Patching AnalysisMacro");
1781 gSystem->Exec(Form("mv %s.C %s.C_tmp",kTrainName.Data(),kTrainName.Data()));
c38e3b95 1782
1783 ifstream in1;
1784 in1.open(Form("%s.C_tmp", kTrainName.Data()));
1785 char cLine[250];
1786 TString st;
1787 while(in1.getline(cLine,250)){
1788 st += cLine;
1789 st += "\n";
1790 }
4721d8c5 1791 Int_t index= -1;
c38e3b95 1792 index = st.Index("gSystem->Load(\"libPhysics\");");
1793 index += strlen("gSystem->Load(\"libPhysics\");");
4721d8c5 1794 /*
c38e3b95 1795 TObjArray *arr;
1796 TObjString *objstr;
1797 arr = anaLibs.Tokenize(" ");
1798 TIter next(arr);
4721d8c5 1799
c38e3b95 1800 add += "\n\n // added by CKB \n";
1801 while ((objstr=(TObjString*)next())){
e84da0a5 1802 if(objstr->GetString().Contains("PWG3"))continue;
c38e3b95 1803 if(objstr->GetString().EndsWith(".so"))add += Form("gSystem->Load(\"%s\");\n",objstr->GetString().Data());
1804 }
1805 delete arr;
4721d8c5 1806 */
3878a941 1807 // add += Form("AliLog::SetGlobalLogLevel(%d);\n",AliLog::GetGlobalLogLevel());
4721d8c5 1808 TString add = "";
1809
1810 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
1811 add += "\n\n // added by CKB \n";
46534866 1812 if(kErrorIgnoreLevel>0)add += Form("gErrorIgnoreLevel = %d;\n",kErrorIgnoreLevel);
23adcac8 1813 add += "\n gSystem->AddIncludePath(\"./\"); \n";
4721d8c5 1814 if(gGrid&&kPluginAliRootVersion.Length()==0){
1815 add += "\n // Dirty hack for TRD reference data \n";
1816 add += "\n gSystem->Setenv(\"ALICE_ROOT\",\"";
1817 add += Form("alien://%s/rootfiles/",gGrid->GetHomeDirectory());
1818 add += "\"); \n";
c38e3b95 1819 }
4721d8c5 1820 add += "// BKC \n\n";
1821 st.Insert(index,add.Data());
e84da0a5 1822
1823 if(kUseDebug){
23adcac8 1824 // st.Insert(index,"\n gROOT->ProcessLine(\".trace\"); // CKB \n");
e84da0a5 1825 }
1826
4721d8c5 1827 if(kUseCPAR&&kPluginAliRootVersion.Length()==0){
1828 index = st.Index("gSystem->AddIncludePath(\"-I$"); // uncommen $ALICE_ROOT include for par files
1829 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
1830 st.Insert(index,"// CKB comment out whehn no aliroot is provided \n //");
1831 }
c166d299 1832
46534866 1833 if(AliLog::GetGlobalLogLevel()==AliLog::kFatal){
1834 index = st.Index("AliLog::SetGlobal"); // ncomment setting of log level, do my own
1835 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
1836 st.Insert(index,"AliLog::SetGlobalLogLevel(AliLog::kFatal);// CKB \n // CKB comment out for own setting \n //");
1837 }
1838
c38e3b95 1839 ofstream out;
1840 out.open(Form("%s.C", kTrainName.Data()));
1841 if (out.bad()) {
1842 return kFALSE;
1843 }
1844 out << st << endl;
1845 Printf("<<< Patching AnalysisMacro");
4721d8c5 1846
1847
1848
1849
1850
1851 Printf(">>> Patching Merge Macro");
1852 gSystem->Exec(Form("mv %s_merge.C %s_merge.C_tmp",kTrainName.Data(),kTrainName.Data()));
1853
1854 ifstream in2;
1855 in2.open(Form("%s_merge.C_tmp", kTrainName.Data()));
1856 TString st2;
1857 while(in2.getline(cLine,250)){
1858 st2 += cLine;
1859 st2 += "\n";
1860 }
1861 index = st2.Index("gSystem->Load(\"libPhysics\");");
1862 index += strlen("gSystem->Load(\"libPhysics\");");
1863 TString add2 = "";
23adcac8 1864 add2 += "\n gSystem->AddIncludePath(\"./\"); \n";
4721d8c5 1865 if(gGrid&&kPluginAliRootVersion.Length()==0){
1866 add2 += "\n // Dirty hack for TRD reference data \n";
1867 add2 += "\n gSystem->Setenv(\"ALICE_ROOT\",\"";
1868 add2 += Form("alien://%s/rootfiles/",gGrid->GetHomeDirectory());
1869 add2 += "\"); \n";
1870 }
1871 add2 += "// BKC \n\n";
1872 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
1873 st2.Insert(index,add.Data());
1874
1875
1876 if(kUseDebug){
23adcac8 1877 // st2.Insert(index,"\n gROOT->ProcessLine(\".trace\"); // CKB \n");
4721d8c5 1878 }
1879
1880 if(kUseCPAR&&kPluginAliRootVersion.Length()==0){
46534866 1881 index = st2.Index("gSystem->AddIncludePath(\"-I$"); // uncomment $ALICE_ROOT include for par files
4721d8c5 1882 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
1883 st2.Insert(index,"// CKB comment out whehn no aliroot is provided \n //");
1884 }
1885
1886 // do not exclude the extra files from merign, this is done explicitly in this train script
1887 index = st2.Index("mergeExcludes +="); // uncommen $ALICE_ROOT include for par files
1888 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
1889 st2.Insert(index,"// CKB comment out, handled explicitly by the train macro \n //");
1890
1891
1892 ofstream out2;
1893 out2.open(Form("%s_merge.C", kTrainName.Data()));
1894 if (out2.bad()) {
1895 return kFALSE;
1896 }
1897 out2 << st2 << endl;
1898 Printf("<<< Patching Merging Macro");
1899
1900
1901
c38e3b95 1902 return kTRUE;
1903
1904}