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