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