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