allow to select events with AliPhysicsSelection directly, added some control histos...
[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
35
36//== general input and output variables
37Int_t iAODanalysis = 1; // Analysis on input AOD's
38Int_t iAODhandler = 1; // Analysis produces an AOD or dAOD's
39Int_t iESDfilter = 0; // ESD to AOD filter (barrel + muon tracks)
e84da0a5 40Int_t iPhysicsSelection = 1; // ESD to AOD filter (barrel + muon tracks)
c38e3b95 41Bool_t kUseKinefilter = kFALSE; // use Kinematics filter
42Bool_t kUseMuonfilter = kFALSE; // use Kinematics filter
43TString kCommonOutputFileName = "PWG4_JetTasksOutput.root";
44
45
46//== general process variables
47
48// ### Other flags to steer the analysis
49//==============================================================================
50Bool_t kUseDate = kFALSE; // use date in train name
51Bool_t kUseDebug = kTRUE; // activate debugging
c28abe00 52Int_t kUseSysInfo = 0; // activate debugging
c38e3b95 53Bool_t kUseMC = kTRUE; // use MC info
54Bool_t kIsMC = kTRUE; // is MC info, if false it overwrites Use(AOD)MC
55Bool_t kUseAODMC = kTRUE; // use MC infA
56Bool_t kUseESDTags = kFALSE; // use ESD tags for selection
57Bool_t kUseTR = kFALSE; // use track references
58Bool_t kUseAODTags = kFALSE; // use AOD tags
59Bool_t kSaveTrain = kFALSE; // save train configuration as:
60
61// ### Analysis modules to be included. Some may not be yet fully implemented.
62//==============================================================================
63Int_t iJETAN = 1; // Jet analysis (PWG4) // 1 write standard 2 write non-standard jets, 3 wrtie both
64Int_t iDIJETAN = 1;
65Int_t iPWG1QASym = 0; // Eva's QA task compiled on the fly...
66Int_t iPWG4JetTasks = 0; // all jet tasks flag for lib laoding
67Int_t iPWG4JetServices = 0; // jet spectrum analysis
68Int_t iPWG4JetSpectrum = 0; // jet spectrum analysis
69Int_t iPWG4UE = 0; // Underlying Event analysis
121e4bd5 70Int_t iPWG4TmpSourceSara = 0; // Underlying Event analysis
c38e3b95 71Int_t iPWG4PtQAMC = 0; // Marta's QA tasks
72Int_t iPWG4PtSpectra = 0; // Marta's QA tasks
73Int_t iPWG4PtQATPC = 0; // Marta's QA tasks
74Int_t iPWG4ThreeJets = 0; // Sona's thrust task
75Int_t iPWG4PartCorr = 0; // Gustavo's part corr analysis
121e4bd5 76Int_t iPWG4omega3pi = 0; // Omega to 3 pi analysis (PWG4)
53c63663 77Int_t iPWG4GammaConv = 0; // Gamma Conversio
c38e3b95 78Int_t kHighPtFilterMask = 16; // change depending on the used AOD Filter
79TString kDeltaAODJetName = "AliAOD.Jet.root";
53c63663 80TString kDeltaAODPartCorrName = "deltaAODPartCorr.root";
c38e3b95 81
82
83//==============================================================================
84// ### PROOF Steering varibales
85//==============================================================================
86//== proof setup variables
87TString kProofCluster = "alicecaf.cern.ch";
88Bool_t kProofUseAFPAR = kFALSE; // use AF special par file
89TString kProofAFversion = "AF-v4-17";
90//== proof input and output variables
91TString kProofDataSet = "/COMMON/COMMON/LHC09a4_run8100X#/esdTree";
92Bool_t kProofSaveToAlien = kFALSE; // save proof outputs in AliEn train_[trainName]_ddMonthyyyy_time.C
93TString kProofOutdir = "";
94Bool_t kProofClearPackages = kFALSE;
95Int_t kProofEvents = 10000;
96Int_t kProofOffset = 0;
97//== proof process variables
98
99
100//==============================================================================
101// ### Grid plugin Steering varibiables
102//==============================================================================
103//== grid plugin setup variables
104Bool_t kPluginUse = kTRUE; // do not change
105Bool_t kPluginUseProductionMode = kFALSE; // use the plugin in production mode
e84da0a5 106TString kPluginRootVersion = "v5-25-04-3"; // *CHANGE ME IF MORE RECENT IN GRID*
121e4bd5 107TString kPluginAliRootVersion = "v4-18-15-AN"; // *CHANGE ME IF MORE RECENT IN GRID*
c38e3b95 108// TString kPluginExecutableCommand = "root -b -q";
109TString kPluginExecutableCommand = "source /Users/kleinb/setup_32bit_aliroot_trunk_clean_root_trunk.sh; alienroot -b -q ";
110// == grid plugin input and output variables
111TString kGridDatadir = "/alice/sim/PDC_08b/LHC09a1/AOD/";
112TString kGridLocalRunList = "";
113TString kGridOutdir = ""; // AliEn output directory. If blank will become output_<kTrainName>
114Int_t kGridRunRange[2] = {0, -1}; // Set the run range
115TString kGridRunPattern = "%03d"; // important for leading zeroes!!
116TString kGridPassPattern = "";
117TString kGridExtraFiles = ""; // files that will be added to the input list in the JDL...
118Int_t kGridMaxMergeFiles = 50; // Number of files merged in a chunkgridrunragn
119TString kGridMergeExclude = "AliAOD.root"; // Files that should not be merged
120TString kGridOutputStorages = "ALICE::NIHAM::File,ALICE::CNAF::SE,ALICE::FZK::SE,ALICE::GSI::SE,ALICE::Legnaro::SE"; // Make replicas on the storages
121// == grid process variables
c28abe00 122Int_t kGridRunsPerMaster = 100; // Number of runs per master job
e84da0a5 123Int_t kGridFilesPerJob = 100; // Maximum number of files per job (gives size of AOD)
c38e3b95 124
125//==============================================================================
126// ### Local Steering variables
127//==============================================================================
128//== local setup variables
129//== local input and output variables
130TString kLocalXMLDataset = ""; // Change local xml dataset for local interactive analysis
131TString kLocalDataList = "local_deltaaod.txt"; // Change local xml dataset for local interactive analysis
132// == local process variables
133
134
135
136// Temporaries.
137TString anaPars = "";
138TString anaLibs = "";
e84da0a5 139TString anaLibsExtra = "";
c38e3b95 140TString anaSources = "";
141// Function signatures
142class AliAnalysisAlien;
143
144//______________________________________________________________________________
145void AnalysisTrainPWG4Jets(const char *analysis_mode="local",
146 const char *plugin_mode="",
147 const char *config_file="",Int_t iOffset = 0)
148{
149// Main analysis train macro. If a configuration file is provided, all parameters
150// are taken from there but may be altered by CheckModuleFlags.
151 if (strlen(config_file) && !LoadConfig(config_file)) return;
152 if(iOffset)kProofOffset = iOffset;
153 TString smode(analysis_mode);
154 smode.ToUpper();
155 if (kSaveTrain)WriteConfig();
156 // Check compatibility of selected modules
157 CheckModuleFlags(smode);
e84da0a5 158 // gROOT->ProcessLine(".trace");
c38e3b95 159
160 printf("==================================================================\n");
161 printf("=========== RUNNING ANALYSIS TRAIN %s IN %s MODE ==========\n", kTrainName.Data(),smode.Data());
162 printf("==================================================================\n");
163 printf("= Configuring analysis train for: =\n");
164 if (iAODanalysis) printf("= AOD analysis =\n");
165 else printf("= ESD analysis =\n");
e84da0a5 166 if (iPhysicsSelection) printf("= Physics selection =\n");
c38e3b95 167 if (iESDfilter) printf("= ESD filter =\n");
168 if (iJETAN) printf("= Jet analysis =\n");
169 printf("==================================================================\n");
170 printf(":: use MC truth %d\n", (UInt_t)kUseMC);
171 printf(":: use KINE filter %d\n", (UInt_t)kUseKinefilter);
172 printf(":: use track refs %d\n", (UInt_t)kUseTR);
173 printf(":: use tags %d\n", (UInt_t)kUseESDTags);
174 printf(":: use AOD tags %d\n", (UInt_t)kUseAODTags);
175 printf(":: use debugging %d\n", (UInt_t)kUseDebug);
176 printf(":: use PAR files %d\n", (UInt_t)kUsePAR);
177 printf(":: use AliEn plugin %d\n", (UInt_t)kPluginUse);
53c63663 178 printf(":: use PWG1 QA sym %d\n", iPWG1QASym);
121e4bd5 179 printf(":: use PWG4 Source Sara %d\n",iPWG4TmpSourceSara);
53c63663 180 printf(":: use PWG4 Jet tasks %d\n",iPWG4JetTasks);
181 printf(":: use PWG4 Jet Services %d\n",iPWG4JetServices);
182 printf(":: use PWG4 Jet Spectrum %d\n",iPWG4JetSpectrum);
183 printf(":: use PWG4 UE %d \n",iPWG4UE);
184 printf(":: use PWG4 Pt QA MC %d\n",iPWG4PtQAMC);
185 printf(":: use PWG4 Pt Spectra %d\n",iPWG4PtSpectra);
186 printf(":: use PWG4 Pt QA TPC %d\n",iPWG4PtQATPC);
187 printf(":: use PWG4 Three Jets %d\n",iPWG4ThreeJets);
188 printf(":: use PWG4 Part Corr %d\n",iPWG4PartCorr);
121e4bd5 189 printf(":: use PWG4 omega to 3 pions %d\n",iPWG4omega3pi);
190
53c63663 191 printf(":: use PWG4 Gamma Conv %d\n",iPWG4GammaConv);
192 printf(":: use HighPt FilterMask %d\n",kHighPtFilterMask);
193
c38e3b95 194
195 //==========================================================================
196 // Connect to back-end system
197 if (!Connect(smode)) {
198 ::Error("AnalysisTrain", "Could not connect to %s back-end", analysis_mode);
199 return;
200 }
201
202 // Load common libraries and set include path
203 if (!LoadCommonLibraries(smode)) {
204 ::Error("AnalysisTrain", "Could not load common libraries");
205 return;
206 }
207
208 // Make the analysis manager and connect event handlers
e84da0a5 209 AliAnalysisManager *mgr = new AliAnalysisManager("PWG4Train", "pwg4 mini train");
c38e3b95 210 if (kCommonOutputFileName.Length()>0)mgr->SetCommonFileName(kCommonOutputFileName.Data());
211 if (kProofSaveToAlien) mgr->SetSpecialOutputLocation(kProofOutdir);
212 if (!strcmp(plugin_mode, "test")) mgr->SetNSysInfo(1);
53c63663 213 if (kUseSysInfo)mgr->SetNSysInfo(kUseSysInfo);
c38e3b95 214 // Load analysis specific libraries
215 if (!LoadAnalysisLibraries(smode)) {
216 ::Error("AnalysisTrain", "Could not load analysis libraries");
217 return;
218 }
219
220 // Create input handler (input container created automatically)
221 if (iAODanalysis) {
222 // AOD input handler
223 AliAODInputHandler *aodH = new AliAODInputHandler();
224 mgr->SetInputEventHandler(aodH);
225 } else {
226 // ESD input handler
227 AliESDInputHandler *esdHandler = new AliESDInputHandler();
228 if (kUseESDTags) esdHandler->SetReadTags();
229 mgr->SetInputEventHandler(esdHandler);
230 }
231 // Monte Carlo handler
232 if (kUseMC && !iAODanalysis) {
233 AliMCEventHandler* mcHandler = new AliMCEventHandler();
234 mgr->SetMCtruthEventHandler(mcHandler);
235 mcHandler->SetReadTR(kUseTR);
236 }
237 // AOD output container, created automatically when setting an AOD handler
238 if (iAODhandler) {
239 // AOD output handler
240 AliAODHandler* aodHandler = new AliAODHandler();
241 aodHandler->SetOutputFileName("AliAOD.root");
242 aodHandler->SetFillAOD(kFillAOD);
243
244 mgr->SetOutputEventHandler(aodHandler);
121e4bd5 245 //
c38e3b95 246 if (iAODanalysis) {
247
248 // aodHandler->SetCreateNonStandardAOD();
249 // if (iJETAN)aodHandler->SetOutputFileName(kDeltaAODJetName.Data());
250 }
251 AliAnalysisDataContainer * cout_aod = mgr->GetCommonOutputContainer();
252 cout_aod->SetSpecialOutput();
253 }
254 // Debugging if needed
255 if (kUseDebug) mgr->SetDebugLevel(3);
256
257 //==========================================================================
258 // Create the chain. In this example it is created only from ALIEN files but
259 // can be done to work in batch or grid mode as well.
260 TChain *chain = CreateChain(smode, plugin_mode);
261
262 //==========================================================================
263 // Load the tasks configuration macros for all wagons. These files are supposed now to be
264 // in the current workdir, but in AliEn they will be in the file catalog,
265 // mapped from AliRoot and pecified in the jdl input list.
266
267 // For now connection to top input container and common AOD output container
268 // is done in this macro, but in future these containers will be connected
269 // from each task configuration macro.
270
e84da0a5 271 if(iPhysicsSelection && !iAODanalysis){
272 gROOT->LoadMacro("$ALICE_ROOT/PWG1/PilotTrain/AddTaskPhysicsSelection.C");
b2d64ef3 273 AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kTRUE);
e84da0a5 274 if(kIsMC)physSelTask->GetPhysicsSelection()->SetAnalyzeMC();
275 physSelTask->GetPhysicsSelection()->AddBackgroundIdentification(new AliBackgroundSelection());
276 }
277
c38e3b95 278 if (iESDfilter && !iAODanalysis) {
279 // ESD filter task configuration.
280 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C");
281 AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(kUseKinefilter,kUseMuonfilter);
282 }
283
284 // AOD tags
285 if (kUseAODTags) {
286 AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator");
287 mgr->AddTask(tagTask);
288 AliAnalysisDataContainer *coutTags = mgr->CreateContainer("cTag", TTree::Class(),
289 AliAnalysisManager::kOutputContainer, "AOD.tag.root");
290 mgr->ConnectInput (tagTask, 0, mgr->GetCommonInputContainer());
291 mgr->ConnectOutput(tagTask, 1, coutTags);
292 }
293
294 // Jet analysis
295 if (iJETAN) {
296 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJets.C");
297 AliAnalysisTaskJets *taskjets = 0;
298 if(iJETAN&1)taskjets = AddTaskJets(kHighPtFilterMask);
121e4bd5 299 if(iJETAN&2)AddTaskJetsDelta(kDeltaAODJetName.Data(),kHighPtFilterMask,kUseAODMC,0xfffffff);
c38e3b95 300 if (!taskjets) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED");
301 }
302
303 if (iDIJETAN) {
304 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskDiJets.C");
305 AliAnalysisTaskDiJets *taskdijets = 0;
306 taskdijets = AddTaskDiJets();
307 if (!taskdijets) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED");
308 }
309
310
311 if(iPWG1QASym){
312 gROOT->LoadMacro("$ALICE_ROOT/prod/acrcaf/qa_pp/AddTaskQAsym.C");
313 AliAnalysisTaskQASym *taskQASym = AddTaskQAsym(-1);
314 if (!taskQASym) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQASym cannot run for this train conditions - EXCLUDED");
121e4bd5 315 }
c38e3b95 316
121e4bd5 317
318
319 if(iPWG4TmpSourceSara){
320 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskEta.C");
321 AliAnalysisTaskEta *taskEta = AddTaskEta();
322 if (!taskEta) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskEta cannot run for this train conditions - EXCLUDED");
c38e3b95 323 }
324
121e4bd5 325
c38e3b95 326 if(iPWG4JetServices){
327 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetServices.C");
328 AliAnalysisTaskJetServices *taskjetServ = 0;
329 taskjetServ = AddTaskJetServices();
330 if (!taskjetServ) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetServices cannot run for this train conditions - EXCLUDED");
53c63663 331 if(kGridRunRange[0]>0)taskjetServ->SetRunRange(kGridRunRange[0],kGridRunRange[1]);
332 else taskjetServ->SetRunRange(104000,105000);
c28abe00 333 if(!kIsMC) taskjetServ->SetRealData(kTRUE);
c38e3b95 334 }
335
336
337 if(iPWG4JetSpectrum){
338 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetSpectrum2.C");
339 AliAnalysisTaskJetSpectrum2 *taskjetSpectrum = 0;
340 if(iPWG4JetSpectrum&1)taskjetSpectrum = AddTaskJetSpectrum2("jets","",kHighPtFilterMask);
341 if (!taskjetSpectrum) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetSpectrum2 cannot run for this train conditions - EXCLUDED");
342 if(iPWG4JetSpectrum&2)AddTaskJetSpectrum2Delta(kHighPtFilterMask,kUseAODMC);
343 if(kUseMC)taskjetSpectrum->SetAnalysisType( AliAnalysisTaskJetSpectrum2::kAnaMCESD);
344 taskjetSpectrum->SetDebugLevel(1);
345 }
346
347 if(iPWG4UE){
348 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskUE.C");
349 AliAnalysisTaskUE *taskUE = 0;
350 if(iPWG4UE&1)taskUE = AddTaskUE();
351 if(iPWG4UE&2){
2bb1f4ca 352 taskUE = AddTaskUE("jetsAOD_CDF07","CDF","LJ","TRANSV");
353 taskUE = AddTaskUE("jetsAOD_UA1LO07","CDF","LJ","TRANSV");
354 taskUE = AddTaskUE("jetsAOD_UA1LO07","CDF","BB","TRANSV");
355 taskUE = AddTaskUE("jetsAOD_FASTKT04","CDF","LJ","TRANSV");
356 taskUE = AddTaskUE("jetsAOD_FASTJET04","CDF","LJ","TRANSV");
357 taskUE = AddTaskUE("jetsAOD_SISCONE04","CDF","LJ","TRANSV");
358
c38e3b95 359 }
2bb1f4ca 360
c38e3b95 361 if (!taskUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskUE cannot run for this train conditions - EXCLUDED");
362 }
363
364 if(iPWG4ThreeJets){
365 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskThreeJets.C");
366 AliAnalysisTaskThreeJets *taskThree = AddTaskThreeJets();
367 if(!taskThree)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskThreets cannot run for this train conditions - EXCLUDED");
368 }
369
370 if(iPWG4PtQAMC){
371 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQAMC.C");
372 AliPWG4HighPtQAMC *taskQAMC = AddTaskPWG4HighPtQAMC();
373 if (!taskQAMC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQAMC cannot run for this train conditions - EXCLUDED");
374 }
375
376 if(iPWG4PtQATPC){
377 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQATPConly.C");
378 AliPWG4HighPtQATPConly *taskQATPC = AddTaskPWG4HighPtQATPConly();
379 if (!taskQATPC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQATPC cannot run for this train conditions - EXCLUDED");
380 }
381
382 if(iPWG4PtSpectra){
383 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtSpectra.C");
384 AliPWG4HighPtSpectra *taskPtSpectra = AddTaskPWG4HighPtSpectra();
385 if (!taskPtSpectra) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskPtSpectra cannot run for this train conditions - EXCLUDED");
386 }
387
388 if(iPWG4PartCorr){
389 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPartCorr.C");
390 AliAnalysisTaskParticleCorrelation *taskpartcorrPHOS = AddTaskPartCorr("AOD", "PHOS",kUseMC,kFALSE,kIsMC);
391 if (!taskpartcorrPHOS) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation PHOS cannot run for this train conditions - EXCLUDED");
392 AliAnalysisTaskParticleCorrelation *taskpartcorrEMCAL = AddTaskPartCorr("AOD", "EMCAL",kUseMC,kFALSE,kIsMC);
393 if (!taskpartcorrEMCAL) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation EMCAL cannot run for this train conditions - EXCLUDED");
394 if(kDeltaAODPartCorrName.Length()>0)mgr->RegisterExtraFile(kDeltaAODPartCorrName.Data()); // hmm this is written anyway.... but at least we do not register it...
121e4bd5 395 }
396
397 if (iPWG4omega3pi) {
398 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskomega3pi.C");
399 AliAnalysisTaskOmegaPi0PiPi *taskomega3pi = AddTaskomega3pi();
400 if (!taskomega3pi) ::Warning("AnalysisTrainNew", "AliAnalysisTaskomega3pi cannot run\
401 for these train conditions - EXCLUDED");
402 }
403
c38e3b95 404
53c63663 405 // PWG4 gamma conversion analysis
406 if (iPWG4GammaConv) {
407 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskGammaConversion.C");
408 TString cdir = gSystem->WorkingDirectory();
409 gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/"));
410 // TString gcArguments = "-run-on-train -run-jet -run-chic -run-neutralmeson -run-cf";
121e4bd5 411 TString gcArguments = "-run-on-train -run-jet -run-neutralmeson -run-cf -use-own-xyz";
53c63663 412 if(!kIsMC)gcArguments += " -mc-off";
413 AliAnalysisTaskGammaConversion * taskGammaConversion = AddTaskGammaConversion(gcArguments,mgr->GetCommonInputContainer());
414 gSystem->ChangeDirectory(cdir);
121e4bd5 415 taskGammaConversion->SelectCollisionCandidates();
53c63663 416 if (!taskGammaConversion) ::Warning("AnalysisTrainNew", "AliAnalysisTaskGammaConversion cannot run for these train conditions - EXCLUDED");
417 }
418
c38e3b95 419 //==========================================================================
420 // FOR THE REST OF THE TASKS THE MACRO AddTaskXXX() is not yet implemented/
421 // Run the analysis
422 //
423 if (kPluginUse) {
424 AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
425 AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
426 }
427
428 if (mgr->InitAnalysis()) {
429 mgr->PrintStatus();
430 // if (kSaveTrain || strlen(config_file)) gSystem->ChangeDirectory(kTrainName);
e84da0a5 431 if (!strcmp(plugin_mode,"submit")&&smode=="GRID"){
c38e3b95 432 TString alien_workdir = gGrid->GetHomeDirectory();
433 if (iAODanalysis) alien_workdir += "analysisAOD";
434 else alien_workdir += "analysisESD";
435 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
e84da0a5 436 printf("=== AnalysisTrainPWG4Jets:: Registering jdl in the work directory alien://%s/%s, should be done by the manager! ===\n",
c38e3b95 437 alien_workdir.Data(),gridhandler->GetGridOutputDir());
438 TFile::Cp(Form("file:%s.jdl",kTrainName.Data()), Form("alien://%s/%s/%s.jdl",alien_workdir.Data(),
439 gridhandler->GetGridOutputDir(),kTrainName.Data()));
440 }
441
442 StartAnalysis(smode, chain);
443 if (!strcmp(plugin_mode, "offline")&&smode=="GRID"){
e84da0a5 444 // Offline mode path files
445 // PatchJDL();
446 PatchAnalysisMacro();
447 }
c38e3b95 448
e84da0a5 449 if (kSaveTrain && smode=="GRID") {
450 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
451 TString alien_workdir = gGrid->GetHomeDirectory();
452 if (iAODanalysis) alien_workdir += "analysisAOD";
c38e3b95 453 else alien_workdir += "analysisESD";
e84da0a5 454 // kGridOutdir = gridhandler->GetGridOutputDir();
455 printf("=== Registering ConfigTrain.C in the work directory <%s> ===\n",
c38e3b95 456 alien_workdir.Data());
e84da0a5 457 if (AliAnalysisAlien::FileExists(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data())))
458 gGrid->Rm(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()));
459 if (strcmp(plugin_mode, "test"))
460 TFile::Cp(Form("file:%sConfig.C",kTrainName.Data()), Form("alien://%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()));
461 }
462 }
c38e3b95 463}
464
465//______________________________________________________________________________
466void StartAnalysis(const char *mode, TChain *chain) {
467// Start analysis.
468 Int_t imode = -1;
469 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
470 if (!strcmp(mode, "LOCAL")) imode = 0;
471 if (!strcmp(mode, "PROOF")) imode = 1;
472 if (!strcmp(mode, "GRID")) imode = 2;
473 switch (imode) {
474 case 0:
475 if (!chain) {
476 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain");
477 return;
478 }
479 mgr->StartAnalysis(mode, chain);
480 return;
481 case 1:
482 if (!kProofDataSet.Length()) {
483 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "kProofDataSet is empty");
484 return;
485 }
486 mgr->StartAnalysis(mode, kProofDataSet, kProofEvents,kProofOffset);
487 return;
488 case 2:
489 if (kPluginUse) {
490 if (!mgr->GetGridHandler()) {
491 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Grid plugin not initialized");
492 return;
493 }
494 mgr->StartAnalysis("grid");
495 } else {
496 if (!chain) {
497 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain");
498 return;
499 }
500 mgr->StartAnalysis(mode, chain);
501 }
502 return;
503 }
504}
505
506//______________________________________________________________________________
507void CheckModuleFlags(const char *mode) {
508// Checks selected modules and insure compatibility
509 Int_t imode = -1;
510 if (!strcmp(mode, "LOCAL")) imode = 0;
511 if (!strcmp(mode, "PROOF")) imode = 1;
512 if (!strcmp(mode, "GRID")) imode = 2;
513
514
e84da0a5 515 if (kUseCPAR) {
516 kPluginAliRootVersion = ""; // NO aliroot if we use CPAR
517 }
c38e3b95 518
519 if (imode==1) {
520 if (!kUsePAR) {
521 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis");
522 kUsePAR = kTRUE;
523 }
524 }
525 if (imode != 2) {
526 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode");
527 kPluginUse = kFALSE;
528 }
529
530
531 if(!kIsMC){
532 // switch off anthin related to MC
533 kUseMC = 0;
534 kUseAODMC = 0;
535 kUseTR = kFALSE;
536 }
537
538 if (iAODanalysis) {
539 // AOD analysis
540 if (kUseMC)
541 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's");
542 if (kUseAODTags)
543 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AOD tags usage disabled in analysis on AOD's");
544 kUseMC = kFALSE;
545 kUseTR = kFALSE;
546 kUseAODTags = kFALSE;
547 if (iESDfilter)
548 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's");
549 iESDfilter = 0;
e84da0a5 550 if (iPhysicsSelection)
551 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "Physics Selection disabled in analysis on AOD's");
552 iPhysicsSelection = 0;
c38e3b95 553 if (!iAODhandler) {
554 if (iJETAN)
555 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler");
556 iJETAN = 0;
557 iDIJETAN = 0;
558 }
559 // Disable tasks that do not work yet on AOD data
560 if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's");
561 iPWG4PtQAMC = 0;
562 if( iPWG4PtQATPC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtTPC disabled in analysis on AOD's");
563 iPWG4PtQATPC = 0;
564 if( iPWG4PtSpectra)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's");
565 iPWG4PtSpectra = 0;
566 if (iPWG4PartCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4partcorr disabled on AOD's");
567 iPWG4PartCorr = 0;
121e4bd5 568 if (iPWG4omega3pi)
569 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4omega3pi disabled on AOD's");
570 iPWG4omega3pi = 0;
c38e3b95 571 if(iPWG1QASym)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG1 QA Sym disabled in analysis on AOD's");
53c63663 572 if (iPWG4GammaConv)::Info("AnalysisPWG4Jets.C::CheckModuleFlags", "PWG4gammaconv disabled on AOD's");
573 iPWG4GammaConv = 0;
574
c38e3b95 575 iPWG1QASym = 0;
576 } else {
577 // ESD analysis
578 if (!kUseMC){
579 kUseTR = kFALSE;
580
581 if(kUseKinefilter)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Kine Filter disabled in analysis without MC");
582 kUseKinefilter = kFALSE;
583 if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis without MC");
584 iPWG4PtQAMC = 0;
585
586 }
587 if (!kUseTR) {
588 // ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "iPWG2evchar disabled if not reading track references");
589 }
e84da0a5 590 if (iJETAN){
591 iESDfilter=1;
592 }
c38e3b95 593 if (!iESDfilter){
594 kUseKinefilter = kFALSE;
595 kUseMuonfilter = kFALSE;
596 }
597 if(!iJETAN){
598 iPWG4JetSpectrum = iPWG4UE = iPWG4ThreeJets = iDIJETAN = 0;
599 }
600 }
601 iPWG4JetTasks = iPWG4JetServices||iPWG4JetSpectrum||iPWG4UE||iPWG4PtQAMC||iPWG4PtSpectra||iPWG4PtQATPC||iPWG4ThreeJets;
602
603 if (iESDfilter) {iAODhandler=1;}
604 if (kUseKinefilter && !kUseMC) kUseKinefilter = kFALSE;
605 if (kUseAODTags && !iAODhandler) kUseAODTags = kFALSE;
606
607
608
609}
610
611//______________________________________________________________________________
612Bool_t Connect(const char *mode) {
613// Connect <username> to the back-end system.
614 Int_t imode = -1;
615 if (!strcmp(mode, "LOCAL")) imode = 0;
616 if (!strcmp(mode, "PROOF")) imode = 1;
617 if (!strcmp(mode, "GRID")) imode = 2;
618 TString username = gSystem->Getenv("alien_API_USER");
619 switch (imode) {
620 case 0:
621 break;
622 case 1:
623 if (!username.Length()) {
624 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \
625 1. Have called: alien-token-init <username>\n \
626 2. Have called: >source /tmp/gclient_env_$UID");
627 return kFALSE;
628 }
629 ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to PROOF cluster <%s>",
630 username.Data(), kProofCluster.Data());
631 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
632// TProof::Open(Form("%s@%s:31093", username.Data(), kProofCluster.Data()));
633 TProof::Open(Form("%s@%s", username.Data(), kProofCluster.Data()));
634 if (!gProof) {
635 if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch"))
636 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch");
637 return kFALSE;
638 }
639 if(kProofClearPackages)gProof->ClearPackages();
640
641 if(kProofSaveToAlien){
642 TGrid::Connect("alien://");
643 if (gGrid) {
644 TString homedir = gGrid->GetHomeDirectory();
645 TString workdir = homedir + kTrainName;
646 if (!gGrid->Cd(workdir)) {
647 gGrid->Cd(homedir);
648 if (gGrid->Mkdir(workdir)) {
649 gGrid->Cd(kTrainName);
650 ::Info("AnalysisTrainPWG4Jets::Connect()", "Directory %s created", gGrid->Pwd());
651 }
652 }
653 gGrid->Mkdir("proof_output");
654 gGrid->Cd("proof_output");
655 kProofOutdir = Form("alien://%s", gGrid->Pwd());
656 }
657 }
658 break;
659 case 2:
660 if (!username.Length()) {
661 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \
662 1. Have called: alien-token-init <username>\n \
663 2. Have called: >source /tmp/gclient_env_$UID");
664 return kFALSE;
665 }
666 if (kPluginUse && !gSystem->Getenv("alien_CLOSE_SE")) {
667 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode),
668 "When using the AliEn plugin it is preferable to define the \
669 variable alien_CLOSE_SE in your environment.");
670 return kFALSE;
671 }
672 ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to AliEn ...",
673 username.Data());
674 TGrid::Connect("alien://");
675 if (!gGrid || !gGrid->IsConnected()) return kFALSE;
676 break;
677 default:
678 ::Error("AnalysisTrainPWG4Jets.C::Connect", "Unknown run mode: %s", mode);
679 return kFALSE;
680 }
681 ::Info("AnalysisTrainPWG4Jets.C::Connect","Connected in %s mode", mode);
682 return kTRUE;
683}
684
685//______________________________________________________________________________
686Bool_t LoadCommonLibraries(const char *mode)
687{
688// Load common analysis libraries.
689 Int_t imode = -1;
690 if (!strcmp(mode, "LOCAL")) imode = 0;
691 if (!strcmp(mode, "PROOF")) imode = 1;
692 if (!strcmp(mode, "GRID")) imode = 2;
693 if (!gSystem->Getenv("ALICE_ROOT")) {
694 ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Analysis train requires that analysis libraries are compiled with a local AliRoot");
695 return kFALSE;
696 }
697 Bool_t success = kTRUE;
698 // ROOT libraries
699 gSystem->Load("libTree.so");
700 gSystem->Load("libGeom.so");
701 gSystem->Load("libVMC.so");
702 gSystem->Load("libPhysics.so");
703
704 // Load framework classes. Par option ignored here.
705 switch (imode) {
706 case 0:
707 case 2:
708 if (kUseCPAR) {
709 success &= LoadLibrary("STEERBase", mode, kTRUE);
710 success &= LoadLibrary("ESD", mode, kTRUE);
711 success &= LoadLibrary("AOD", mode, kTRUE);
712 success &= LoadLibrary("ANALYSIS", mode, kTRUE);
713 success &= LoadLibrary("ANALYSISalice", mode, kTRUE);
714 success &= LoadLibrary("CORRFW", mode, kTRUE);
715 } else {
716 success &= LoadLibrary("libSTEERBase.so", mode);
717 success &= LoadLibrary("libESD.so", mode);
718 success &= LoadLibrary("libAOD.so", mode);
719 success &= LoadLibrary("libANALYSIS.so", mode);
720 success &= LoadLibrary("libANALYSISalice.so", mode);
721 success &= LoadLibrary("libCORRFW.so", mode);
722 gROOT->ProcessLine(".include $ALICE_ROOT/include");
723 }
724 break;
725 case 1:
726 Int_t ires = -1;
727 if (kProofUseAFPAR && !gSystem->AccessPathName(kProofAFversion)) ires = gProof->UploadPackage(kProofAFversion);
728 if (ires < 0) {
729 success &= LoadLibrary("STEERBase", mode);
730 success &= LoadLibrary("ESD", mode);
731 success &= LoadLibrary("AOD", mode);
732 success &= LoadLibrary("ANALYSIS", mode);
733 success &= LoadLibrary("ANALYSISalice", mode);
734 success &= LoadLibrary("CORRFW", mode);
735 } else {
736 ires = gProof->EnablePackage(kProofAFversion);
737 if (ires<0) success = kFALSE;
738 success &= LoadLibrary("CORRFW", mode);
739 }
740 break;
741 default:
742 ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Unknown run mode: %s", mode);
743 return kFALSE;
744 }
745 if (success) {
746 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: SUCCESS");
747 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s",
748 gSystem->GetIncludePath());
749 } else {
750 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: FAILED");
751 }
752
753 return success;
754}
755
756//______________________________________________________________________________
757Bool_t LoadAnalysisLibraries(const char *mode)
758{
759// Load common analysis libraries.
760 Bool_t success = kTRUE;
761 if (iESDfilter) {
762 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
763 !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE;
764 }
765 // JETAN
766 if (iJETAN||iDIJETAN) {
767 if (!strcmp(mode, "PROOF")){
ef1e462f 768 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libCGAL.so\"\)", kTRUE);
c38e3b95 769 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libfastjet.so\"\)", kTRUE);
770 // problem when loading siscone copiled with different gcc version??
771 // gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libsiscone.so\"\)", kTRUE);
772 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libSISConePlugin.so\"\)", kTRUE);
773 }
c38e3b95 774 if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE;
e84da0a5 775 if(!kUsePAR){
776 if (!LoadLibrary("CGAL", mode, kTRUE)) return kFALSE;
777 if (!LoadLibrary("fastjet", mode, kTRUE)) return kFALSE;
778 if (!LoadLibrary("siscone", mode, kTRUE)) return kFALSE;
779 if (!LoadLibrary("SISConePlugin", mode, kTRUE)) return kFALSE;
780 }
781 else{
782 // par files plus FASTJET needs some extra work... need to change
783 // the loading sequence in the auto generated .C file
784 if (!LoadLibrary("libCGAL.so", mode, kTRUE)) return kFALSE;
785 if (!LoadLibrary("libfastjet.so", mode, kTRUE)) return kFALSE;
786 if (!LoadLibrary("libsiscone.so", mode, kTRUE)) return kFALSE;
787 if (!LoadLibrary("libSISConePlugin.so", mode, kTRUE)) return kFALSE;
788 }
c38e3b95 789 if (!LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE;
790 }
791 if(iPWG4JetTasks){
792 // PWG4 particle correlations
793 if (!LoadLibrary("PWG4JetTasks", mode, kTRUE)) return kFALSE;
794 }
795 if(iPWG1QASym){
796 if (!LoadSource(Form("%s/PWG1/AliAnalysisTaskQASym.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
797 }
121e4bd5 798 if(iPWG4TmpSourceSara){
2bb1f4ca 799 // gSystem->AddIncludePath("-I$ALICE_ROOT/include/JetTasks"); // ugly hack!!
121e4bd5 800 if(!LoadSource(Form("%s/PWG4/JetTasks/AliAnalysisTaskEta.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
801 }
c38e3b95 802 if (iPWG4PartCorr) {
803 if (!LoadLibrary("EMCALUtils", mode, kTRUE) ||
804 !LoadLibrary("PHOSUtils", mode, kTRUE) ||
805 !LoadLibrary("PWG4PartCorrBase", mode, kTRUE) ||
806 !LoadLibrary("PWG4PartCorrDep", mode, kTRUE)) return kFALSE;
807 }
121e4bd5 808 if (iPWG4omega3pi) {
809 if (!LoadLibrary("PWG4omega3pi", mode, kTRUE)) return kFALSE;
810 }
53c63663 811 if (iPWG4GammaConv) {
812 if (!LoadLibrary("PWG4GammaConv", mode, kTRUE)) return kFALSE;
813 }
c38e3b95 814
815 ::Info("AnalysisTrainPWG4Jets.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS");
816 return kTRUE;
817}
818
819//______________________________________________________________________________
820Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE)
821{
822// Load a module library in a given mode. Reports success.
823 Int_t imode = -1;
824 Int_t result;
825 TString smodule(module);
826 if (!strcmp(mode, "LOCAL")) imode = 0;
827 if (!strcmp(mode, "PROOF")) imode = 1;
828 if (!strcmp(mode, "GRID")) imode = 2;
829 TString mod(module);
830 if (!mod.Length()) {
831 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Empty module name");
832 return kFALSE;
833 }
834 // If a library is specified, just load it
835 if (smodule.EndsWith(".so")) {
836 mod.Remove(mod.Index(".so"));
837 result = gSystem->Load(mod);
838 if (result < 0) {
839 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load library %s", module);
840 return kFALSE;
841 }
842 if (rec) anaLibs += Form("%s.so ",mod.Data());
e84da0a5 843 if (rec) anaLibsExtra += Form("%s.so ",mod.Data());
c38e3b95 844 return kTRUE;
845 }
846 // Check if the library is already loaded
847 if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0)
848 return kTRUE;
849 switch (imode) {
850 case 0:
851 case 2:
852 if (kUsePAR) {
853 result = SetupPar(module);
854 if (rec) anaPars += Form("%s.par ", module);
855 } else {
856 result = gSystem->Load(Form("lib%s.so", module));
857 if (rec) anaLibs += Form("lib%s.so ", module);
858 }
859 break;
860 case 1:
861 if(!gSystem->AccessPathName(module)){
862 ::Info("AnalysisTrainPWG4Jets.C::LoadLibrary", "Removing directory %s",module);
863 gSystem->Exec(Form("rm -rf %s",module));
864 }
865 result = gProof->UploadPackage(module);
866 if (result<0) {
867 result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module)));
868 if (result<0) {
869 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module);
870 return kFALSE;
871 }
872 }
873 result = gProof->EnablePackage(module);
874 break;
875 default:
876 return kFALSE;
877 }
878 if (result < 0) {
879 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load module %s", module);
880 return kFALSE;
881 }
882 return kTRUE;
883}
884
885
886
887//______________________________________________________________________________
888Bool_t LoadSource(const char *source, const char *mode, Bool_t rec=kFALSE)
889{
890// Load a module library in a given mode. Reports success.
891 Int_t imode = -1;
892 Int_t result = -1;
893 if (!strcmp(mode, "LOCAL")) imode = 0;
894 if (!strcmp(mode, "PROOF")) imode = 1;
895 if (!strcmp(mode, "GRID")) imode = 2;
896 TString ssource(source);
897 TString basename = gSystem->BaseName(ssource.Data());
898 if (!ssource.Length()) {
899 ::Error("AnalysisTrainPWG4Jets.C::LoadSource", "Empty task name");
900 return kFALSE;
901 }
902 // we have a source code so compile it
903 if (ssource.EndsWith(".cxx")) {
904 // need to copy it here other wise the path is also used on grid...
905 ssource.Remove(ssource.Index(".cxx"));
906 basename.Remove(basename.Index(".cxx"));
907 Printf("LoadSources:: Copying... path %s{cxx,h}",ssource.Data());
908 gSystem->Exec(Form("cp %s.cxx . ",ssource.Data()));
909 gSystem->Exec(Form("cp %s.h . ",ssource.Data()));
910 // Path to code
911 // only needed for local compilation, in grid and proof mode
912 // the task headers are uploaded
913 // path.Remove(path.Index(gSystem->BaseName(path.Data())));
914 // Printf("LoadSources:: Including path %s",path.Data());
915 // if(path.Length()>0)gROOT->ProcessLine(Form(".include %s",path.Data()));
916 Printf("LoadSources:: Loading... path %s",basename.Data());
917 switch (imode) {
918 case 0:
919 result = gROOT->LoadMacro(Form("%s.cxx+g",basename.Data()));
920 break;
921 case 1:
922 result = gProof->LoadMacro(Form("%s.cxx+g",basename.Data()));
923 break;
924 case 2:
925 result = gROOT->LoadMacro(Form("%s.cxx+g",basename.Data()));
926 if (rec){
927 // what we want to compile
928 anaSources += Form("%s.cxx ",basename.Data());
929 // what we need as input...
930 anaLibs += Form("%s.cxx %s.h ",basename.Data(),basename.Data());
931 }
932 break;
933 default:
934 return kFALSE;
935 }
936 }
937 if (result < 0) {
938 ::Error("AnalysisTrainPWG4Jets.C::LoadSources", "Could not load source %s", source);
939 return kFALSE;
940 }
941 return kTRUE;
942}
943
944
945//______________________________________________________________________________
946TChain *CreateChain(const char *mode, const char *plugin_mode)
947{
948// Create the input chain
949 Int_t imode = -1;
950 if (!strcmp(mode, "LOCAL")) imode = 0;
951 if (!strcmp(mode, "PROOF")) imode = 1;
952 if (!strcmp(mode, "GRID")) imode = 2;
953 TChain *chain = NULL;
954 // Local chain
955 switch (imode) {
956 case 0:
957 if (iAODanalysis) {
958 if (!kLocalXMLDataset.Length()) {
959 // Local AOD
960 chain = new TChain("aodTree");
961 TString line;
962 ifstream in;
963 in.open(kLocalDataList.Data());
964 while (in.good()) {
965 in >> line;
966 if (line.Length() == 0) continue;
967 // cout << " line = " << line << endl;
968 chain->Add(line.Data());
969 }
970 } else {
971 // Interactive AOD
972 chain = CreateChainSingle(kLocalXMLDataset, "aodTree");
973 }
974 } else {
975 if (!kLocalXMLDataset.Length()) {
976 // Local ESD
977 chain = new TChain("esdTree");
978 TString line;
979 ifstream in;
980 in.open(kLocalDataList.Data());
981 while (in.good()) {
982 in >> line;
983 if (line.Length() == 0) continue;
984 cout << " line = " << line << endl;
985 chain->Add(line.Data());
986 }
987 } else {
988 // Interactive ESD
989 chain = CreateChainSingle(kLocalXMLDataset, "esdTree");
990 }
991 }
992 break;
993 case 1:
994 break;
995 case 2:
996 if (kPluginUse) {
997// AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
998// AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
999 } else {
1000 TString treeName = "esdTree";
1001 if (iAODanalysis) treeName = "aodTree";
1002 chain = CreateChainSingle("wn.xml", treeName);
1003 }
1004 break;
1005 default:
1006 }
1007 if (chain && chain->GetNtrees()) return chain;
1008 return NULL;
1009}
1010
1011//______________________________________________________________________________
1012TChain* CreateChainSingle(const char* xmlfile, const char *treeName)
1013{
1014 printf("*******************************\n");
1015 printf("*** Getting the ESD Chain ***\n");
1016 printf("*******************************\n");
1017 TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
1018
1019 if (!myCollection) {
1020 ::Error("AnalysisTrainPWG4Jets.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
1021 return NULL ;
1022 }
1023
1024 TChain* chain = new TChain(treeName);
1025 myCollection->Reset() ;
1026 while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
1027 chain->ls();
1028 return chain;
1029}
1030
1031//______________________________________________________________________________
1032Int_t SetupPar(char* pararchivename)
1033{
1034 if (!pararchivename || !strlen(pararchivename)) return -1;
1035 char processline[1024];
1036 if (gSystem->AccessPathName(Form("%s.par", pararchivename))) {
1037 if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) {
1038 ::Info("AnalysisTrainPWG4Jets.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename);
1039 TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)),
1040 Form("%s.par",pararchivename));
1041 } else {
1042 ::Error("AnalysisTrainPWG4Jets.C::SetupPar", "Cannot find %s.par", pararchivename);
1043 return -1;
1044 }
1045 }
1046 if (kPluginUse && kSaveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, kTrainName.Data()));
1047 gSystem->Exec(Form("tar xvzf %s.par", pararchivename));
1048
1049 TString ocwd = gSystem->WorkingDirectory();
1050 if (!gSystem->ChangeDirectory(pararchivename)) return -1;
1051
1052 // check for BUILD.sh and execute
1053 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
1054 printf("*******************************\n");
1055 printf("*** Building PAR archive ***\n");
1056 printf("*******************************\n");
1057 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
1058 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
1059 return -1;
1060 }
1061 }
1062
1063 // check for SETUP.C and execute
1064 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
1065 printf("*******************************\n");
1066 printf("*** Setup PAR archive ***\n");
1067 printf("*******************************\n");
1068 gROOT->Macro("PROOF-INF/SETUP.C");
1069 }
1070 if (!gSystem->ChangeDirectory(ocwd.Data())) return -1;
1071 return 0;
1072}
1073
1074//______________________________________________________________________________
1075AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
1076{
1077// Check if user has a valid token, otherwise make one. This has limitations.
1078// One can always follow the standard procedure of calling alien-token-init then
1079// source /tmp/gclient_env_$UID in the current shell.
1080 if (!AliAnalysisGrid::CreateToken()) return NULL;
1081 AliAnalysisAlien *plugin = new AliAnalysisAlien();
1082// Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
1083 plugin->SetRunMode(plugin_mode);
1084 if (kPluginUseProductionMode) plugin->SetProductionMode();
1085 plugin->SetJobTag(kJobTag);
1086 plugin->SetNtestFiles(2);
1087// plugin->SetPreferedSE("ALICE::NIHAM::File");
1088// Set versions of used packages
e84da0a5 1089 plugin->SetAPIVersion("V1.1x");
1090 // plugin->SetAPIVersion("V1.0x");
1091// plugin->SetAPIVersion("V2.4");
c38e3b95 1092 plugin->SetROOTVersion(kPluginRootVersion);
1093 plugin->SetAliROOTVersion(kPluginAliRootVersion);
1094// Declare input data to be processed.
1095// Method 1: Create automatically XML collections using alien 'find' command.
1096// Define production directory LFN
1097 plugin->SetGridDataDir(kGridDatadir.Data());
1098// Set data search pattern
1099 if (iAODanalysis) plugin->SetDataPattern(" *AliAOD.root");
1100 else plugin->SetDataPattern(Form(" %s/*/*ESD.tag.root",kGridPassPattern.Data()));
1101// ...then add run numbers to be considered
1102// plugin->SetRunRange(kGridRunRange[0], kGridRunRange[1]);
1103 for (Int_t i=kGridRunRange[0]; i<=kGridRunRange[1]; i++) {
1104 Printf("AnalysisTrainPWG4Jets Adding run number %s", Form(kGridRunPattern.Data(),i));
1105 plugin->AddRunNumber(Form(kGridRunPattern.Data(),i));
1106 }
1107
1108 if(kGridLocalRunList.Length()>0){
1109 ifstream in1;
1110 in1.open(kGridLocalRunList.Data());
1111 int iRun;
e84da0a5 1112 char c;
1113 char cLine[250];
1114 while(!in1.eof()){
1115 c = in1.get();
1116 if ( (c >= '0') && (c <= '9') )
1117 {
1118 in1.putback (c);
1119 in1>>iRun;
1120 Printf("AnalysisTrainPWG4Jets Adding run number from File %s", Form(kGridRunPattern.Data(),iRun));
1121 plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun));
1122 }
1123 else
1124 {
1125 in1.putback (c);
1126 in1.getline(cLine,250);
1127 Printf("AnalysisTrainPWG4Jets Skipping run number from File %s", cLine);
1128 }
c38e3b95 1129 }
1130 }
1131
1132// Method 2: Declare existing data files (raw collections, xml collections, root file)
1133// If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
1134// XML collections added via this method can be combined with the first method if
1135// the content is compatible (using or not tags)
1136// plugin->AddDataFile("tag.xml");
1137// plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
1138// Define alien work directory where all files will be copied. Relative to alien $HOME.
1139 if (iAODanalysis) plugin->SetGridWorkingDir("analysisAOD");
1140 else plugin->SetGridWorkingDir("analysisESD");
1141 // Declare alien output directory. Relative to working directory.
1142 if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
1143 plugin->SetGridOutputDir(kGridOutdir);
1144
1145 // Add external packages
1146 if (iJETAN||iDIJETAN) {
1147 plugin->AddExternalPackage("boost::v1_38_0");
1148 plugin->AddExternalPackage("cgal::v3.3.1");
1149 plugin->AddExternalPackage("fastjet::v2.4.0");
1150 }
1151
1152
1153 // set extra libs before par file compilation
1154 anaLibs += kGridExtraFiles;
1155 anaLibs = anaLibs.Strip();
e84da0a5 1156 Printf("anaLibs %s",anaLibs.Data());
1157 Printf("anaLibsExtra %s",anaLibsExtra.Data());
1158
1159 if (anaLibs.Length()) plugin->SetAdditionalLibs(anaLibs.Data());
1160 if (anaLibsExtra.Length()) plugin->SetAdditionalRootLibs(anaLibsExtra.Data());
c38e3b95 1161
1162 TString ana_sources = "";
1163 TString ana_add = "";
1164 if (kUsePAR && anaPars.Length()) {
1165 printf("%s\n", anaPars.Data());
1166 TObjArray *arr;
1167 TObjString *objstr;
1168 arr = anaPars.Tokenize(" ");
1169 TIter next(arr);
1170 while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString());
1171 delete arr;
1172 }
1173
1174// Declare the analysis source files names separated by blancs. To be compiled runtime
1175// using ACLiC on the worker nodes.
1176 ana_sources = anaSources.Strip();
1177// Declare all libraries (other than the default ones for the framework. These will be
1178// loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
1179
1180 if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources);
1181 plugin->SetExecutableCommand(kPluginExecutableCommand.Data());
1182// Declare the output file names separated by blancs.
1183// (can be like: file.root or file.root@ALICE::Niham::File)
1184 plugin->SetDefaultOutputs();
1185 plugin->SetMergeExcludes(kGridMergeExclude);
1186 plugin->SetMaxMergeFiles(kGridMaxMergeFiles);
1187 plugin->SetNrunsPerMaster(kGridRunsPerMaster);
1188// Optionally define the files to be archived.
1189// plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File");
1190
1191
1192 // Put default output files to archive
1193 TString listhists = "";
1194 TString listaods = "";
1195 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1196 TIter next(mgr->GetOutputs());
1197 AliAnalysisDataContainer *output;
1198 while ((output=(AliAnalysisDataContainer*)next())) {
1199 const char *filename = output->GetFileName();
1200 if (!(strcmp(filename, "default"))) {
53c63663 1201 if (!mgr->GetOutputEventHandler()) continue;
c38e3b95 1202 filename = mgr->GetOutputEventHandler()->GetOutputFileName();
e84da0a5 1203 if (listaods.Length()) listaods += " ";
c38e3b95 1204 listaods += filename;
c38e3b95 1205 } else {
e84da0a5 1206 if(!listhists.Contains(filename)){
1207 if (listhists.Length()) listhists += " ";
c38e3b95 1208 listhists += filename;
1209 }
1210 }
1211 }
53c63663 1212
c28abe00 1213 if(kUseSysInfo>0){
e84da0a5 1214 if (listhists.Length()) listhists += " ";
c28abe00 1215 listhists += "syswatch.root";
53c63663 1216 }
1217
e84da0a5 1218 if(kIsMC){
1219 if (listaods.Length()) listaods += " ";
1220 listaods += "pyxsec_hists.root";
1221 }
1222
1223
53c63663 1224 if (mgr->GetExtraFiles().Length()) {
e84da0a5 1225 if (listaods.Length()) listaods += " ";
53c63663 1226 listaods += mgr->GetExtraFiles();
c38e3b95 1227 }
53c63663 1228
1229 // if we do not fill the aod we do not need to store it
e84da0a5 1230 kGridMergeExclude = listaods;
1231
1232 if(!kFillAOD){
1233 listaods="";
1234 plugin->SetDefaultOutputs(kFALSE);
1235 plugin->SetOutputFiles(listhists.Data());
1236 }
53c63663 1237
e84da0a5 1238
1239 listaods.ReplaceAll(" ", ",");
1240 listhists.ReplaceAll(" ", ",");
c38e3b95 1241 if (listhists.Length()) listhists = Form("hist_archive.zip:%s@%s", listhists.Data(), kGridOutputStorages.Data());;
1242 if (listaods.Length()) listaods = Form("aod_archive.zip:%s@%s", listaods.Data(), kGridOutputStorages.Data());;
53c63663 1243
c38e3b95 1244 if (!listhists.Length() && !listaods.Length()) {
1245 ::Fatal("AnalysisTrainPWG4Jets", "No task output !");
1246 }
53c63663 1247
e84da0a5 1248
53c63663 1249
b2d64ef3 1250 TString outputArchive = "log_archive.zip:stdout,stderr@ALICE::FZK::SE,ALICE::GSI::SE";
1251 if(kUseSysInfo>0)outputArchive = "log_archive.zip:stdout,stderr,syswatch.log@ALICE::FZK::SE,ALICE::GSI::SE";
c38e3b95 1252 if (listaods.Length()) {
1253 outputArchive += " ";
1254 outputArchive += listaods;
1255 }
1256 if (listhists.Length()) {
1257 outputArchive += " ";
1258 outputArchive += listhists;
1259 }
1260 plugin->SetOutputArchive(outputArchive);
1261// Optionally set a name for the generated analysis macro (default MyAnalysis.C)
1262 plugin->SetAnalysisMacro(Form("%s.C", kTrainName.Data()));
1263// Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
1264 plugin->SetSplitMaxInputFileNumber(kGridFilesPerJob);
1265// Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
1266// plugin->SetMaxInitFailed(5);
1267// Optionally resubmit threshold.
1268// plugin->SetMasterResubmitThreshold(90);
1269// Optionally set time to live (default 30000 sec)
1270 plugin->SetTTL(30000);
1271// Optionally set input format (default xml-single)
1272 plugin->SetInputFormat("xml-single");
1273// Optionally modify the name of the generated JDL (default analysis.jdl)
1274 plugin->SetJDLName(Form("%s.jdl", kTrainName.Data()));
1275// Optionally modify the executable name (default analysis.sh)
1276 plugin->SetExecutable(Form("%s.sh", kTrainName.Data()));
1277// Optionally modify job price (default 1)
1278 plugin->SetPrice(1);
1279// Optionally modify split mode (default 'se')
1280 plugin->SetSplitMode("se");
1281 return plugin;
1282}
1283
1284//______________________________________________________________________________
1285void WriteConfig()
1286{
1287// Write train configuration in a file. The file name has the format:
1288// train_[trainName]_ddMonthyyyy_time.C
1289 if (kUseDate) {
1290 gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp");
1291 ifstream fdate("date.tmp");
1292 if (!fdate.is_open()) {
1293 ::Error("AnalysisTrainPWG4Jets.C::Export","Could not generate file name");
1294 return;
1295 }
1296 const char date[64];
1297 fdate.getline(date,64);
1298 fdate.close();
1299 gSystem->Exec("rm date.tmp");
1300 kTrainName = Form("train_%s_%s", kTrainName.Data(), date);
1301 } else {
1302 kTrainName = Form("train_%s", kTrainName.Data());
1303 }
1304 TString cdir = gSystem->WorkingDirectory();
1305 gSystem->MakeDirectory(kTrainName);
1306 gSystem->ChangeDirectory(kTrainName);
1307 ofstream out;
1308 out.open(Form("%sConfig.C",kTrainName.Data()), ios::out);
1309 if (out.bad()) {
1310 ::Error("AnalysisTrainPWG4Jets.C::Export", "Cannot open ConfigTrain.C for writing");
1311 return;
1312 }
1313 out << "{" << endl;
1314 out << " kTrainName = " << "\"" << kTrainName.Data() << "\";" << endl;
1315 out << " kProofCluster = " << "\"" << kProofCluster.Data() << "\";" << endl;
1316 out << " kProofUseAFPAR = " << kProofUseAFPAR << ";" << endl;
1317 if (kProofUseAFPAR)
1318 out << " kProofAFversion = " << kProofAFversion.Data() << ";" << endl;
1319 out << " kProofDataSet = " << "\"" << kProofDataSet.Data() << "\";" << endl;
1320 out << " kPluginUse = " << kPluginUse << ";" << endl;
1321 out << " kUsePAR = " << kUsePAR << ";" << endl;
1322 out << " kUseCPAR = " << kUseCPAR << ";" << endl;
1323 out << " kPluginRootVersion = " << "\"" << kPluginRootVersion.Data() << "\";" << endl;
1324 out << " kPluginAliRootVersion = " << "\"" << kPluginAliRootVersion.Data() << "\";" << endl;
1325 out << " kGridDatadir = " << "\"" << kGridDatadir.Data() << "\";" << endl;
1326 if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
1327 out << " kGridOutdir = " << "\"" << kGridOutdir.Data() << "\";" << endl;
1328 out << " kGridMaxMergeFiles = " << kGridMaxMergeFiles << ";" << endl;
1329 out << " kGridMergeExclude = " << "\"" << kGridMergeExclude.Data() << "\";" << endl;
1330 out << " kGridRunsPerMaster = " << kGridRunsPerMaster << ";" << endl;
1331 out << " kGridFilesPerJob = " << kGridFilesPerJob << ";" << endl;
1332 out << " kGridRunRange[0] = " << kGridRunRange[0] << ";" << endl;
1333 out << " kGridRunRange[1] = " << kGridRunRange[1] << ";" << endl;
1334 out << " kUseDebug = " << kUseDebug << ";" << endl;
1335 out << " kUseMC = " << kUseMC << ";" << endl;
1336 out << " kUseESDTags = " << kUseESDTags << ";" << endl;
1337 out << " kUseKinefilter = " << kUseKinefilter << ";" << endl;
1338 out << " kUseTR = " << kUseTR << ";" << endl;
1339 out << " kUseAODTags = " << kUseAODTags << ";" << endl;
1340 out << " kSaveTrain = " << "kFALSE;" << endl << endl;
1341 out << " // Analysis modules" << endl;
1342 out << " iAODanalysis = " << iAODanalysis << ";" << endl;
1343 out << " iAODhandler = " << iAODhandler << ";" << endl;
1344 out << " iESDfilter = " << iESDfilter << ";" << endl;
1345 out << " iJETAN = " << iJETAN << ";" << endl;
1346 out << "// Configuration fot the wagons" << endl;
1347 out << "}" << endl;
1348 ::Info("AnalysisTrainPWG4Jets.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", kTrainName.Data()));
1349 gSystem->ChangeDirectory(cdir);
1350}
1351
1352//______________________________________________________________________________
1353Bool_t LoadConfig(const char *filename)
1354{
1355// Read train configuration from file
1356 if (gSystem->AccessPathName(filename)) {
1357 ::Error("AnalysisTrainPWG4Jets.C::LoadConfig", "Config file name not found");
1358 return kFALSE;
1359 }
1360 gROOT->ProcessLine(Form(".x %s", filename));
1361 ::Info("AnalysisTrainPWG4Jets.C::LoadConfig", "Train configuration loaded from file %s", filename);
1362 return kTRUE;
1363}
1364
1365Bool_t PatchJDL(){
1366 Printf(">>> Patching JDL");
1367 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1368 AliAnalysisAlien* gridHandler = (AliAnalysisAlien*)mgr->GetGridHandler();
1369 TGridJDL *jdl = gridHandler->GetGridJDL();
1370 if(iJETAN)jdl->AddToPackages("fastjet","v2.4.0");
1371 gridHandler->WriteJDL(kFALSE);
1372 Printf("<<< Patching JDL");
1373 return kTRUE;
1374}
1375
1376Bool_t PatchAnalysisMacro(){
1377 Printf(">>> Patching AnalysisMacro");
1378 gSystem->Exec(Form("mv %s.C %s.C_tmp",kTrainName.Data(),kTrainName.Data()));
1379
1380 ifstream in1;
1381 in1.open(Form("%s.C_tmp", kTrainName.Data()));
1382 char cLine[250];
1383 TString st;
1384 while(in1.getline(cLine,250)){
1385 st += cLine;
1386 st += "\n";
1387 }
1388 Int_t index;
1389 index = st.Index("gSystem->Load(\"libPhysics\");");
1390 index += strlen("gSystem->Load(\"libPhysics\");");
e84da0a5 1391 if(iJETAN&&kUsePAR){
c38e3b95 1392 TObjArray *arr;
1393 TObjString *objstr;
1394 arr = anaLibs.Tokenize(" ");
1395 TIter next(arr);
1396 TString add = "";
1397 add += "\n\n // added by CKB \n";
1398 while ((objstr=(TObjString*)next())){
e84da0a5 1399 if(objstr->GetString().Contains("PWG3"))continue;
c38e3b95 1400 if(objstr->GetString().EndsWith(".so"))add += Form("gSystem->Load(\"%s\");\n",objstr->GetString().Data());
1401 }
1402 delete arr;
1403 add += "// BKC \n\n";
1404 st.Insert(index,add.Data());
1405 }
e84da0a5 1406
1407 if(kUseDebug){
1408 st.Insert(index,"\n gROOT->ProcessLine(\".trace\"); // CKB \n");
1409 }
1410
c38e3b95 1411 ofstream out;
1412 out.open(Form("%s.C", kTrainName.Data()));
1413 if (out.bad()) {
1414 return kFALSE;
1415 }
1416 out << st << endl;
1417 Printf("<<< Patching AnalysisMacro");
1418 return kTRUE;
1419
1420}