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)
6 // root[1] AnalysisTrainPWG4Jets("grid", "full")
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.
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")
18 // For Usage with fastjet run in "offline" first and then "submit"
19 // jdl and analysismacro are automatically patched after "offline" mode
21 // =============================================================================
22 // ### General Steering variables
23 // =============================================================================
24 //== general setup variables
25 TString kTrainName = "testAnalysis"; // *CHANGE ME* (no blancs or special characters)
26 TString kJobTag = "PWG4 Jet Tasks analysis train configured"; // *CHANGE ME*
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
32 Bool_t kUsePAR = kFALSE; // use par files for extra libs
33 Bool_t kUseCPAR = kFALSE; // use par files for common libs
34 Bool_t kFillAOD = kFALSE; // switch of AOD filling for on the fly analysis
36 //== general input and output variables
37 Int_t iAODanalysis = 1; // Analysis on input AOD's
38 Int_t iAODhandler = 1; // Analysis produces an AOD or dAOD's
39 Int_t iESDfilter = 0; // ESD to AOD filter (barrel + muon tracks)
40 Bool_t kUseKinefilter = kFALSE; // use Kinematics filter
41 Bool_t kUseMuonfilter = kFALSE; // use Kinematics filter
42 TString kCommonOutputFileName = "PWG4_JetTasksOutput.root";
45 //== general process variables
47 // ### Other flags to steer the analysis
48 //==============================================================================
49 Bool_t kUseDate = kFALSE; // use date in train name
50 Bool_t kUseDebug = kTRUE; // activate debugging
51 Bool_t kUseMC = kTRUE; // use MC info
52 Bool_t kIsMC = kTRUE; // is MC info, if false it overwrites Use(AOD)MC
53 Bool_t kUseAODMC = kTRUE; // use MC infA
54 Bool_t kUseESDTags = kFALSE; // use ESD tags for selection
55 Bool_t kUseTR = kFALSE; // use track references
56 Bool_t kUseAODTags = kFALSE; // use AOD tags
57 Bool_t kSaveTrain = kFALSE; // save train configuration as:
59 // ### Analysis modules to be included. Some may not be yet fully implemented.
60 //==============================================================================
61 Int_t iJETAN = 1; // Jet analysis (PWG4) // 1 write standard 2 write non-standard jets, 3 wrtie both
63 Int_t iPWG1QASym = 0; // Eva's QA task compiled on the fly...
64 Int_t iPWG4JetTasks = 0; // all jet tasks flag for lib laoding
65 Int_t iPWG4JetServices = 0; // jet spectrum analysis
66 Int_t iPWG4JetSpectrum = 0; // jet spectrum analysis
67 Int_t iPWG4UE = 0; // Underlying Event analysis
68 Int_t iPWG4PtQAMC = 0; // Marta's QA tasks
69 Int_t iPWG4PtSpectra = 0; // Marta's QA tasks
70 Int_t iPWG4PtQATPC = 0; // Marta's QA tasks
71 Int_t iPWG4ThreeJets = 0; // Sona's thrust task
72 Int_t iPWG4PartCorr = 0; // Gustavo's part corr analysis
74 Int_t kHighPtFilterMask = 16; // change depending on the used AOD Filter
75 TString kDeltaAODJetName = "AliAOD.Jet.root";
76 TString kDeltaAODPartCorrName = "AliAOD.Jet.root";
79 //==============================================================================
80 // ### PROOF Steering varibales
81 //==============================================================================
82 //== proof setup variables
83 TString kProofCluster = "alicecaf.cern.ch";
84 Bool_t kProofUseAFPAR = kFALSE; // use AF special par file
85 TString kProofAFversion = "AF-v4-17";
86 //== proof input and output variables
87 TString kProofDataSet = "/COMMON/COMMON/LHC09a4_run8100X#/esdTree";
88 Bool_t kProofSaveToAlien = kFALSE; // save proof outputs in AliEn train_[trainName]_ddMonthyyyy_time.C
89 TString kProofOutdir = "";
90 Bool_t kProofClearPackages = kFALSE;
91 Int_t kProofEvents = 10000;
92 Int_t kProofOffset = 0;
93 //== proof process variables
96 //==============================================================================
97 // ### Grid plugin Steering varibiables
98 //==============================================================================
99 //== grid plugin setup variables
100 Bool_t kPluginUse = kTRUE; // do not change
101 Bool_t kPluginUseProductionMode = kFALSE; // use the plugin in production mode
102 TString kPluginRootVersion = "v20091109"; // *CHANGE ME IF MORE RECENT IN GRID*
103 TString kPluginAliRootVersion = "v4-18-13-AN"; // *CHANGE ME IF MORE RECENT IN GRID*
104 // TString kPluginExecutableCommand = "root -b -q";
105 TString kPluginExecutableCommand = "source /Users/kleinb/setup_32bit_aliroot_trunk_clean_root_trunk.sh; alienroot -b -q ";
106 // == grid plugin input and output variables
107 TString kGridDatadir = "/alice/sim/PDC_08b/LHC09a1/AOD/";
108 TString kGridLocalRunList = "";
109 TString kGridOutdir = ""; // AliEn output directory. If blank will become output_<kTrainName>
110 Int_t kGridRunRange[2] = {0, -1}; // Set the run range
111 TString kGridRunPattern = "%03d"; // important for leading zeroes!!
112 TString kGridPassPattern = "";
113 TString kGridExtraFiles = ""; // files that will be added to the input list in the JDL...
114 Int_t kGridMaxMergeFiles = 50; // Number of files merged in a chunkgridrunragn
115 TString kGridMergeExclude = "AliAOD.root"; // Files that should not be merged
116 TString kGridOutputStorages = "ALICE::NIHAM::File,ALICE::CNAF::SE,ALICE::FZK::SE,ALICE::GSI::SE,ALICE::Legnaro::SE"; // Make replicas on the storages
117 // == grid process variables
118 Int_t kGridRunsPerMaster = 10; // Number of runs per master job
119 Int_t kGridFilesPerJob = 200; // Maximum number of files per job (gives size of AOD)
121 //==============================================================================
122 // ### Local Steering variables
123 //==============================================================================
124 //== local setup variables
125 //== local input and output variables
126 TString kLocalXMLDataset = ""; // Change local xml dataset for local interactive analysis
127 TString kLocalDataList = "local_deltaaod.txt"; // Change local xml dataset for local interactive analysis
128 // == local process variables
133 TString anaPars = "";
134 TString anaLibs = "";
135 TString anaSources = "";
136 // Function signatures
137 class AliAnalysisAlien;
139 //______________________________________________________________________________
140 void AnalysisTrainPWG4Jets(const char *analysis_mode="local",
141 const char *plugin_mode="",
142 const char *config_file="",Int_t iOffset = 0)
144 // Main analysis train macro. If a configuration file is provided, all parameters
145 // are taken from there but may be altered by CheckModuleFlags.
146 if (strlen(config_file) && !LoadConfig(config_file)) return;
147 if(iOffset)kProofOffset = iOffset;
148 TString smode(analysis_mode);
150 if (kSaveTrain)WriteConfig();
151 // Check compatibility of selected modules
152 CheckModuleFlags(smode);
154 printf("==================================================================\n");
155 printf("=========== RUNNING ANALYSIS TRAIN %s IN %s MODE ==========\n", kTrainName.Data(),smode.Data());
156 printf("==================================================================\n");
157 printf("= Configuring analysis train for: =\n");
158 if (iAODanalysis) printf("= AOD analysis =\n");
159 else printf("= ESD analysis =\n");
160 if (iESDfilter) printf("= ESD filter =\n");
161 if (iJETAN) printf("= Jet analysis =\n");
162 printf("==================================================================\n");
163 printf(":: use MC truth %d\n", (UInt_t)kUseMC);
164 printf(":: use KINE filter %d\n", (UInt_t)kUseKinefilter);
165 printf(":: use track refs %d\n", (UInt_t)kUseTR);
166 printf(":: use tags %d\n", (UInt_t)kUseESDTags);
167 printf(":: use AOD tags %d\n", (UInt_t)kUseAODTags);
168 printf(":: use debugging %d\n", (UInt_t)kUseDebug);
169 printf(":: use PAR files %d\n", (UInt_t)kUsePAR);
170 printf(":: use AliEn plugin %d\n", (UInt_t)kPluginUse);
172 //==========================================================================
173 // Connect to back-end system
174 if (!Connect(smode)) {
175 ::Error("AnalysisTrain", "Could not connect to %s back-end", analysis_mode);
179 // Load common libraries and set include path
180 if (!LoadCommonLibraries(smode)) {
181 ::Error("AnalysisTrain", "Could not load common libraries");
185 // Make the analysis manager and connect event handlers
186 AliAnalysisManager *mgr = new AliAnalysisManager("Analysis Train", "Production train");
187 if (kCommonOutputFileName.Length()>0)mgr->SetCommonFileName(kCommonOutputFileName.Data());
188 if (kProofSaveToAlien) mgr->SetSpecialOutputLocation(kProofOutdir);
189 if (!strcmp(plugin_mode, "test")) mgr->SetNSysInfo(1);
190 // Load analysis specific libraries
191 if (!LoadAnalysisLibraries(smode)) {
192 ::Error("AnalysisTrain", "Could not load analysis libraries");
196 // Create input handler (input container created automatically)
199 AliAODInputHandler *aodH = new AliAODInputHandler();
200 mgr->SetInputEventHandler(aodH);
203 AliESDInputHandler *esdHandler = new AliESDInputHandler();
204 if (kUseESDTags) esdHandler->SetReadTags();
205 mgr->SetInputEventHandler(esdHandler);
207 // Monte Carlo handler
208 if (kUseMC && !iAODanalysis) {
209 AliMCEventHandler* mcHandler = new AliMCEventHandler();
210 mgr->SetMCtruthEventHandler(mcHandler);
211 mcHandler->SetReadTR(kUseTR);
213 // AOD output container, created automatically when setting an AOD handler
215 // AOD output handler
216 AliAODHandler* aodHandler = new AliAODHandler();
217 aodHandler->SetOutputFileName("AliAOD.root");
218 aodHandler->SetFillAOD(kFillAOD);
220 mgr->SetOutputEventHandler(aodHandler);
224 // aodHandler->SetCreateNonStandardAOD();
225 // if (iJETAN)aodHandler->SetOutputFileName(kDeltaAODJetName.Data());
227 AliAnalysisDataContainer * cout_aod = mgr->GetCommonOutputContainer();
228 cout_aod->SetSpecialOutput();
230 // Debugging if needed
231 if (kUseDebug) mgr->SetDebugLevel(3);
233 //==========================================================================
234 // Create the chain. In this example it is created only from ALIEN files but
235 // can be done to work in batch or grid mode as well.
236 TChain *chain = CreateChain(smode, plugin_mode);
238 //==========================================================================
239 // Load the tasks configuration macros for all wagons. These files are supposed now to be
240 // in the current workdir, but in AliEn they will be in the file catalog,
241 // mapped from AliRoot and pecified in the jdl input list.
243 // For now connection to top input container and common AOD output container
244 // is done in this macro, but in future these containers will be connected
245 // from each task configuration macro.
247 if (iESDfilter && !iAODanalysis) {
248 // ESD filter task configuration.
249 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C");
250 AliAnalysisTaskESDfilter *taskesdfilter = AddTaskESDFilter(kUseKinefilter,kUseMuonfilter);
255 AliAnalysisTaskTagCreator* tagTask = new AliAnalysisTaskTagCreator("AOD Tag Creator");
256 mgr->AddTask(tagTask);
257 AliAnalysisDataContainer *coutTags = mgr->CreateContainer("cTag", TTree::Class(),
258 AliAnalysisManager::kOutputContainer, "AOD.tag.root");
259 mgr->ConnectInput (tagTask, 0, mgr->GetCommonInputContainer());
260 mgr->ConnectOutput(tagTask, 1, coutTags);
265 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJets.C");
266 AliAnalysisTaskJets *taskjets = 0;
267 if(iJETAN&1)taskjets = AddTaskJets(kHighPtFilterMask);
268 if(iJETAN&2)AddTaskJetsDelta(kDeltaAODJetName.Data(),kHighPtFilterMask,kUseAODMC);
269 if (!taskjets) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED");
273 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskDiJets.C");
274 AliAnalysisTaskDiJets *taskdijets = 0;
275 taskdijets = AddTaskDiJets();
276 if (!taskdijets) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED");
281 gROOT->LoadMacro("$ALICE_ROOT/prod/acrcaf/qa_pp/AddTaskQAsym.C");
282 AliAnalysisTaskQASym *taskQASym = AddTaskQAsym(-1);
283 if (!taskQASym) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQASym cannot run for this train conditions - EXCLUDED");
287 if(iPWG4JetServices){
288 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetServices.C");
289 AliAnalysisTaskJetServices *taskjetServ = 0;
290 taskjetServ = AddTaskJetServices();
291 if (!taskjetServ) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetServices cannot run for this train conditions - EXCLUDED");
295 if(iPWG4JetSpectrum){
296 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetSpectrum2.C");
297 AliAnalysisTaskJetSpectrum2 *taskjetSpectrum = 0;
298 if(iPWG4JetSpectrum&1)taskjetSpectrum = AddTaskJetSpectrum2("jets","",kHighPtFilterMask);
299 if (!taskjetSpectrum) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetSpectrum2 cannot run for this train conditions - EXCLUDED");
300 if(iPWG4JetSpectrum&2)AddTaskJetSpectrum2Delta(kHighPtFilterMask,kUseAODMC);
301 if(kUseMC)taskjetSpectrum->SetAnalysisType( AliAnalysisTaskJetSpectrum2::kAnaMCESD);
302 taskjetSpectrum->SetDebugLevel(1);
306 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskUE.C");
307 AliAnalysisTaskUE *taskUE = 0;
308 if(iPWG4UE&1)taskUE = AddTaskUE();
310 taskUE = AddTaskUE("jetsAOD_CDF07");
311 taskUE = AddTaskUE("jetsAOD_UA1LO07");
313 if (!taskUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskUE cannot run for this train conditions - EXCLUDED");
317 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskThreeJets.C");
318 AliAnalysisTaskThreeJets *taskThree = AddTaskThreeJets();
319 if(!taskThree)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskThreets cannot run for this train conditions - EXCLUDED");
323 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQAMC.C");
324 AliPWG4HighPtQAMC *taskQAMC = AddTaskPWG4HighPtQAMC();
325 if (!taskQAMC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQAMC cannot run for this train conditions - EXCLUDED");
329 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQATPConly.C");
330 AliPWG4HighPtQATPConly *taskQATPC = AddTaskPWG4HighPtQATPConly();
331 if (!taskQATPC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQATPC cannot run for this train conditions - EXCLUDED");
335 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtSpectra.C");
336 AliPWG4HighPtSpectra *taskPtSpectra = AddTaskPWG4HighPtSpectra();
337 if (!taskPtSpectra) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskPtSpectra cannot run for this train conditions - EXCLUDED");
341 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPartCorr.C");
342 AliAnalysisTaskParticleCorrelation *taskpartcorrPHOS = AddTaskPartCorr("AOD", "PHOS",kUseMC,kFALSE,kIsMC);
343 if (!taskpartcorrPHOS) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation PHOS cannot run for this train conditions - EXCLUDED");
344 AliAnalysisTaskParticleCorrelation *taskpartcorrEMCAL = AddTaskPartCorr("AOD", "EMCAL",kUseMC,kFALSE,kIsMC);
345 if (!taskpartcorrEMCAL) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation EMCAL cannot run for this train conditions - EXCLUDED");
346 if(kDeltaAODPartCorrName.Length()>0)mgr->RegisterExtraFile(kDeltaAODPartCorrName.Data()); // hmm this is written anyway.... but at least we do not register it...
349 //==========================================================================
350 // FOR THE REST OF THE TASKS THE MACRO AddTaskXXX() is not yet implemented/
354 AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
355 AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
358 if (mgr->InitAnalysis()) {
360 // if (kSaveTrain || strlen(config_file)) gSystem->ChangeDirectory(kTrainName);
361 if (!strcmp(plugin_mode, "submit")&&smode=="GRID"){
362 TString alien_workdir = gGrid->GetHomeDirectory();
363 if (iAODanalysis) alien_workdir += "analysisAOD";
364 else alien_workdir += "analysisESD";
365 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
366 printf("=== Registering jdl in the work directory alien://%s/%s, should be done by the manager! ===\n",
367 alien_workdir.Data(),gridhandler->GetGridOutputDir());
368 TFile::Cp(Form("file:%s.jdl",kTrainName.Data()), Form("alien://%s/%s/%s.jdl",alien_workdir.Data(),
369 gridhandler->GetGridOutputDir(),kTrainName.Data()));
372 StartAnalysis(smode, chain);
373 if (!strcmp(plugin_mode, "offline")&&smode=="GRID"){
374 // Offline mode path files
376 PatchAnalysisMacro();
379 if (kSaveTrain && smode=="GRID") {
380 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
381 TString alien_workdir = gGrid->GetHomeDirectory();
382 if (iAODanalysis) alien_workdir += "analysisAOD";
383 else alien_workdir += "analysisESD";
384 // kGridOutdir = gridhandler->GetGridOutputDir();
385 printf("=== Registering ConfigTrain.C in the work directory <%s> ===\n",
386 alien_workdir.Data());
387 if (AliAnalysisAlien::FileExists(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data())))
388 gGrid->Rm(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()));
389 if (strcmp(plugin_mode, "test"))
390 TFile::Cp(Form("file:%sConfig.C",kTrainName.Data()), Form("alien://%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()));
395 //______________________________________________________________________________
396 void StartAnalysis(const char *mode, TChain *chain) {
399 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
400 if (!strcmp(mode, "LOCAL")) imode = 0;
401 if (!strcmp(mode, "PROOF")) imode = 1;
402 if (!strcmp(mode, "GRID")) imode = 2;
406 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain");
409 mgr->StartAnalysis(mode, chain);
412 if (!kProofDataSet.Length()) {
413 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "kProofDataSet is empty");
416 mgr->StartAnalysis(mode, kProofDataSet, kProofEvents,kProofOffset);
420 if (!mgr->GetGridHandler()) {
421 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Grid plugin not initialized");
424 mgr->StartAnalysis("grid");
427 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain");
430 mgr->StartAnalysis(mode, chain);
436 //______________________________________________________________________________
437 void CheckModuleFlags(const char *mode) {
438 // Checks selected modules and insure compatibility
440 if (!strcmp(mode, "LOCAL")) imode = 0;
441 if (!strcmp(mode, "PROOF")) imode = 1;
442 if (!strcmp(mode, "GRID")) imode = 2;
449 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis");
454 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode");
460 // switch off anthin related to MC
469 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's");
471 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AOD tags usage disabled in analysis on AOD's");
474 kUseAODTags = kFALSE;
476 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's");
480 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler");
484 // Disable tasks that do not work yet on AOD data
485 if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's");
487 if( iPWG4PtQATPC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtTPC disabled in analysis on AOD's");
489 if( iPWG4PtSpectra)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's");
491 if (iPWG4PartCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4partcorr disabled on AOD's");
493 if(iPWG1QASym)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG1 QA Sym disabled in analysis on AOD's");
500 if(kUseKinefilter)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Kine Filter disabled in analysis without MC");
501 kUseKinefilter = kFALSE;
502 if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis without MC");
507 // ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "iPWG2evchar disabled if not reading track references");
509 if (iJETAN) iESDfilter=1;
511 kUseKinefilter = kFALSE;
512 kUseMuonfilter = kFALSE;
515 iPWG4JetSpectrum = iPWG4UE = iPWG4ThreeJets = iDIJETAN = 0;
518 iPWG4JetTasks = iPWG4JetServices||iPWG4JetSpectrum||iPWG4UE||iPWG4PtQAMC||iPWG4PtSpectra||iPWG4PtQATPC||iPWG4ThreeJets;
520 if (iESDfilter) {iAODhandler=1;}
521 if (kUseKinefilter && !kUseMC) kUseKinefilter = kFALSE;
522 if (kUseAODTags && !iAODhandler) kUseAODTags = kFALSE;
528 //______________________________________________________________________________
529 Bool_t Connect(const char *mode) {
530 // Connect <username> to the back-end system.
532 if (!strcmp(mode, "LOCAL")) imode = 0;
533 if (!strcmp(mode, "PROOF")) imode = 1;
534 if (!strcmp(mode, "GRID")) imode = 2;
535 TString username = gSystem->Getenv("alien_API_USER");
540 if (!username.Length()) {
541 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \
542 1. Have called: alien-token-init <username>\n \
543 2. Have called: >source /tmp/gclient_env_$UID");
546 ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to PROOF cluster <%s>",
547 username.Data(), kProofCluster.Data());
548 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
549 // TProof::Open(Form("%s@%s:31093", username.Data(), kProofCluster.Data()));
550 TProof::Open(Form("%s@%s", username.Data(), kProofCluster.Data()));
552 if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch"))
553 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch");
556 if(kProofClearPackages)gProof->ClearPackages();
558 if(kProofSaveToAlien){
559 TGrid::Connect("alien://");
561 TString homedir = gGrid->GetHomeDirectory();
562 TString workdir = homedir + kTrainName;
563 if (!gGrid->Cd(workdir)) {
565 if (gGrid->Mkdir(workdir)) {
566 gGrid->Cd(kTrainName);
567 ::Info("AnalysisTrainPWG4Jets::Connect()", "Directory %s created", gGrid->Pwd());
570 gGrid->Mkdir("proof_output");
571 gGrid->Cd("proof_output");
572 kProofOutdir = Form("alien://%s", gGrid->Pwd());
577 if (!username.Length()) {
578 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \
579 1. Have called: alien-token-init <username>\n \
580 2. Have called: >source /tmp/gclient_env_$UID");
583 if (kPluginUse && !gSystem->Getenv("alien_CLOSE_SE")) {
584 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode),
585 "When using the AliEn plugin it is preferable to define the \
586 variable alien_CLOSE_SE in your environment.");
589 ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to AliEn ...",
591 TGrid::Connect("alien://");
592 if (!gGrid || !gGrid->IsConnected()) return kFALSE;
595 ::Error("AnalysisTrainPWG4Jets.C::Connect", "Unknown run mode: %s", mode);
598 ::Info("AnalysisTrainPWG4Jets.C::Connect","Connected in %s mode", mode);
602 //______________________________________________________________________________
603 Bool_t LoadCommonLibraries(const char *mode)
605 // Load common analysis libraries.
607 if (!strcmp(mode, "LOCAL")) imode = 0;
608 if (!strcmp(mode, "PROOF")) imode = 1;
609 if (!strcmp(mode, "GRID")) imode = 2;
610 if (!gSystem->Getenv("ALICE_ROOT")) {
611 ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Analysis train requires that analysis libraries are compiled with a local AliRoot");
614 Bool_t success = kTRUE;
616 gSystem->Load("libTree.so");
617 gSystem->Load("libGeom.so");
618 gSystem->Load("libVMC.so");
619 gSystem->Load("libPhysics.so");
621 // Load framework classes. Par option ignored here.
626 success &= LoadLibrary("STEERBase", mode, kTRUE);
627 success &= LoadLibrary("ESD", mode, kTRUE);
628 success &= LoadLibrary("AOD", mode, kTRUE);
629 success &= LoadLibrary("ANALYSIS", mode, kTRUE);
630 success &= LoadLibrary("ANALYSISalice", mode, kTRUE);
631 success &= LoadLibrary("CORRFW", mode, kTRUE);
633 success &= LoadLibrary("libSTEERBase.so", mode);
634 success &= LoadLibrary("libESD.so", mode);
635 success &= LoadLibrary("libAOD.so", mode);
636 success &= LoadLibrary("libANALYSIS.so", mode);
637 success &= LoadLibrary("libANALYSISalice.so", mode);
638 success &= LoadLibrary("libCORRFW.so", mode);
639 gROOT->ProcessLine(".include $ALICE_ROOT/include");
644 if (kProofUseAFPAR && !gSystem->AccessPathName(kProofAFversion)) ires = gProof->UploadPackage(kProofAFversion);
646 success &= LoadLibrary("STEERBase", mode);
647 success &= LoadLibrary("ESD", mode);
648 success &= LoadLibrary("AOD", mode);
649 success &= LoadLibrary("ANALYSIS", mode);
650 success &= LoadLibrary("ANALYSISalice", mode);
651 success &= LoadLibrary("CORRFW", mode);
653 ires = gProof->EnablePackage(kProofAFversion);
654 if (ires<0) success = kFALSE;
655 success &= LoadLibrary("CORRFW", mode);
659 ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Unknown run mode: %s", mode);
663 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: SUCCESS");
664 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s",
665 gSystem->GetIncludePath());
667 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: FAILED");
673 //______________________________________________________________________________
674 Bool_t LoadAnalysisLibraries(const char *mode)
676 // Load common analysis libraries.
677 Bool_t success = kTRUE;
679 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
680 !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE;
683 if (iJETAN||iDIJETAN) {
684 if (!strcmp(mode, "PROOF")){
685 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libCGAL.so\"\)", kTRUE);
686 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libfastjet.so\"\)", kTRUE);
687 // problem when loading siscone copiled with different gcc version??
688 // gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libsiscone.so\"\)", kTRUE);
689 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libSISConePlugin.so\"\)", kTRUE);
691 if (!LoadLibrary("libCGAL.so", mode, kTRUE)) return kFALSE;
692 if (!LoadLibrary("libfastjet.so", mode, kTRUE)) return kFALSE;
693 if (!LoadLibrary("libsiscone.so", mode, kTRUE)) return kFALSE;
694 if (!LoadLibrary("libSISConePlugin.so", mode, kTRUE)) return kFALSE;
695 if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE;
696 if (!LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE;
699 // PWG4 particle correlations
700 if (!LoadLibrary("PWG4JetTasks", mode, kTRUE)) return kFALSE;
703 if (!LoadSource(Form("%s/PWG1/AliAnalysisTaskQASym.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
706 if (!LoadLibrary("EMCALUtils", mode, kTRUE) ||
707 !LoadLibrary("PHOSUtils", mode, kTRUE) ||
708 !LoadLibrary("PWG4PartCorrBase", mode, kTRUE) ||
709 !LoadLibrary("PWG4PartCorrDep", mode, kTRUE)) return kFALSE;
712 ::Info("AnalysisTrainPWG4Jets.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS");
716 //______________________________________________________________________________
717 Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE)
719 // Load a module library in a given mode. Reports success.
722 TString smodule(module);
723 if (!strcmp(mode, "LOCAL")) imode = 0;
724 if (!strcmp(mode, "PROOF")) imode = 1;
725 if (!strcmp(mode, "GRID")) imode = 2;
728 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Empty module name");
731 // If a library is specified, just load it
732 if (smodule.EndsWith(".so")) {
733 mod.Remove(mod.Index(".so"));
734 result = gSystem->Load(mod);
736 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load library %s", module);
739 if (rec) anaLibs += Form("%s.so ",mod.Data());
742 // Check if the library is already loaded
743 if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0)
749 result = SetupPar(module);
750 if (rec) anaPars += Form("%s.par ", module);
752 result = gSystem->Load(Form("lib%s.so", module));
753 if (rec) anaLibs += Form("lib%s.so ", module);
757 if(!gSystem->AccessPathName(module)){
758 ::Info("AnalysisTrainPWG4Jets.C::LoadLibrary", "Removing directory %s",module);
759 gSystem->Exec(Form("rm -rf %s",module));
761 result = gProof->UploadPackage(module);
763 result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module)));
765 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module);
769 result = gProof->EnablePackage(module);
775 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load module %s", module);
783 //______________________________________________________________________________
784 Bool_t LoadSource(const char *source, const char *mode, Bool_t rec=kFALSE)
786 // Load a module library in a given mode. Reports success.
789 if (!strcmp(mode, "LOCAL")) imode = 0;
790 if (!strcmp(mode, "PROOF")) imode = 1;
791 if (!strcmp(mode, "GRID")) imode = 2;
792 TString ssource(source);
793 TString basename = gSystem->BaseName(ssource.Data());
794 if (!ssource.Length()) {
795 ::Error("AnalysisTrainPWG4Jets.C::LoadSource", "Empty task name");
798 // we have a source code so compile it
799 if (ssource.EndsWith(".cxx")) {
800 // need to copy it here other wise the path is also used on grid...
801 ssource.Remove(ssource.Index(".cxx"));
802 basename.Remove(basename.Index(".cxx"));
803 Printf("LoadSources:: Copying... path %s{cxx,h}",ssource.Data());
804 gSystem->Exec(Form("cp %s.cxx . ",ssource.Data()));
805 gSystem->Exec(Form("cp %s.h . ",ssource.Data()));
807 // only needed for local compilation, in grid and proof mode
808 // the task headers are uploaded
809 // path.Remove(path.Index(gSystem->BaseName(path.Data())));
810 // Printf("LoadSources:: Including path %s",path.Data());
811 // if(path.Length()>0)gROOT->ProcessLine(Form(".include %s",path.Data()));
812 Printf("LoadSources:: Loading... path %s",basename.Data());
815 result = gROOT->LoadMacro(Form("%s.cxx+g",basename.Data()));
818 result = gProof->LoadMacro(Form("%s.cxx+g",basename.Data()));
821 result = gROOT->LoadMacro(Form("%s.cxx+g",basename.Data()));
823 // what we want to compile
824 anaSources += Form("%s.cxx ",basename.Data());
825 // what we need as input...
826 anaLibs += Form("%s.cxx %s.h ",basename.Data(),basename.Data());
834 ::Error("AnalysisTrainPWG4Jets.C::LoadSources", "Could not load source %s", source);
841 //______________________________________________________________________________
842 TChain *CreateChain(const char *mode, const char *plugin_mode)
844 // Create the input chain
846 if (!strcmp(mode, "LOCAL")) imode = 0;
847 if (!strcmp(mode, "PROOF")) imode = 1;
848 if (!strcmp(mode, "GRID")) imode = 2;
849 TChain *chain = NULL;
854 if (!kLocalXMLDataset.Length()) {
856 chain = new TChain("aodTree");
859 in.open(kLocalDataList.Data());
862 if (line.Length() == 0) continue;
863 // cout << " line = " << line << endl;
864 chain->Add(line.Data());
868 chain = CreateChainSingle(kLocalXMLDataset, "aodTree");
871 if (!kLocalXMLDataset.Length()) {
873 chain = new TChain("esdTree");
876 in.open(kLocalDataList.Data());
879 if (line.Length() == 0) continue;
880 cout << " line = " << line << endl;
881 chain->Add(line.Data());
885 chain = CreateChainSingle(kLocalXMLDataset, "esdTree");
893 // AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
894 // AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
896 TString treeName = "esdTree";
897 if (iAODanalysis) treeName = "aodTree";
898 chain = CreateChainSingle("wn.xml", treeName);
903 if (chain && chain->GetNtrees()) return chain;
907 //______________________________________________________________________________
908 TChain* CreateChainSingle(const char* xmlfile, const char *treeName)
910 printf("*******************************\n");
911 printf("*** Getting the ESD Chain ***\n");
912 printf("*******************************\n");
913 TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
916 ::Error("AnalysisTrainPWG4Jets.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
920 TChain* chain = new TChain(treeName);
921 myCollection->Reset() ;
922 while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
927 //______________________________________________________________________________
928 Int_t SetupPar(char* pararchivename)
930 if (!pararchivename || !strlen(pararchivename)) return -1;
931 char processline[1024];
932 if (gSystem->AccessPathName(Form("%s.par", pararchivename))) {
933 if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) {
934 ::Info("AnalysisTrainPWG4Jets.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename);
935 TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)),
936 Form("%s.par",pararchivename));
938 ::Error("AnalysisTrainPWG4Jets.C::SetupPar", "Cannot find %s.par", pararchivename);
942 if (kPluginUse && kSaveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, kTrainName.Data()));
943 gSystem->Exec(Form("tar xvzf %s.par", pararchivename));
945 TString ocwd = gSystem->WorkingDirectory();
946 if (!gSystem->ChangeDirectory(pararchivename)) return -1;
948 // check for BUILD.sh and execute
949 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
950 printf("*******************************\n");
951 printf("*** Building PAR archive ***\n");
952 printf("*******************************\n");
953 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
954 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
959 // check for SETUP.C and execute
960 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
961 printf("*******************************\n");
962 printf("*** Setup PAR archive ***\n");
963 printf("*******************************\n");
964 gROOT->Macro("PROOF-INF/SETUP.C");
966 if (!gSystem->ChangeDirectory(ocwd.Data())) return -1;
970 //______________________________________________________________________________
971 AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
973 // Check if user has a valid token, otherwise make one. This has limitations.
974 // One can always follow the standard procedure of calling alien-token-init then
975 // source /tmp/gclient_env_$UID in the current shell.
976 if (!AliAnalysisGrid::CreateToken()) return NULL;
977 AliAnalysisAlien *plugin = new AliAnalysisAlien();
978 // Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
979 plugin->SetRunMode(plugin_mode);
980 if (kPluginUseProductionMode) plugin->SetProductionMode();
981 plugin->SetJobTag(kJobTag);
982 plugin->SetNtestFiles(2);
983 // plugin->SetPreferedSE("ALICE::NIHAM::File");
984 // Set versions of used packages
985 plugin->SetAPIVersion("V2.4");
986 plugin->SetROOTVersion(kPluginRootVersion);
987 plugin->SetAliROOTVersion(kPluginAliRootVersion);
988 // Declare input data to be processed.
989 // Method 1: Create automatically XML collections using alien 'find' command.
990 // Define production directory LFN
991 plugin->SetGridDataDir(kGridDatadir.Data());
992 // Set data search pattern
993 if (iAODanalysis) plugin->SetDataPattern(" *AliAOD.root");
994 else plugin->SetDataPattern(Form(" %s/*/*ESD.tag.root",kGridPassPattern.Data()));
995 // ...then add run numbers to be considered
996 // plugin->SetRunRange(kGridRunRange[0], kGridRunRange[1]);
997 for (Int_t i=kGridRunRange[0]; i<=kGridRunRange[1]; i++) {
998 Printf("AnalysisTrainPWG4Jets Adding run number %s", Form(kGridRunPattern.Data(),i));
999 plugin->AddRunNumber(Form(kGridRunPattern.Data(),i));
1002 if(kGridLocalRunList.Length()>0){
1004 in1.open(kGridLocalRunList.Data());
1007 Printf("AnalysisTrainPWG4Jets Adding run number from File %s", Form(kGridRunPattern.Data(),iRun));
1008 plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun));
1012 // Method 2: Declare existing data files (raw collections, xml collections, root file)
1013 // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
1014 // XML collections added via this method can be combined with the first method if
1015 // the content is compatible (using or not tags)
1016 // plugin->AddDataFile("tag.xml");
1017 // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
1018 // Define alien work directory where all files will be copied. Relative to alien $HOME.
1019 if (iAODanalysis) plugin->SetGridWorkingDir("analysisAOD");
1020 else plugin->SetGridWorkingDir("analysisESD");
1021 // Declare alien output directory. Relative to working directory.
1022 if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
1023 plugin->SetGridOutputDir(kGridOutdir);
1025 // Add external packages
1026 if (iJETAN||iDIJETAN) {
1027 plugin->AddExternalPackage("boost::v1_38_0");
1028 plugin->AddExternalPackage("cgal::v3.3.1");
1029 plugin->AddExternalPackage("fastjet::v2.4.0");
1033 // set extra libs before par file compilation
1034 anaLibs += kGridExtraFiles;
1035 anaLibs = anaLibs.Strip();
1036 Printf("%s",anaLibs.Data());
1037 if (anaLibs.Length()) plugin->SetAdditionalLibs(anaLibs.Data());
1039 TString ana_sources = "";
1040 TString ana_add = "";
1041 if (kUsePAR && anaPars.Length()) {
1042 printf("%s\n", anaPars.Data());
1045 arr = anaPars.Tokenize(" ");
1047 while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString());
1051 // Declare the analysis source files names separated by blancs. To be compiled runtime
1052 // using ACLiC on the worker nodes.
1053 ana_sources = anaSources.Strip();
1054 // Declare all libraries (other than the default ones for the framework. These will be
1055 // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
1057 if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources);
1058 plugin->SetExecutableCommand(kPluginExecutableCommand.Data());
1059 // Declare the output file names separated by blancs.
1060 // (can be like: file.root or file.root@ALICE::Niham::File)
1061 plugin->SetDefaultOutputs();
1062 plugin->SetMergeExcludes(kGridMergeExclude);
1063 plugin->SetMaxMergeFiles(kGridMaxMergeFiles);
1064 plugin->SetNrunsPerMaster(kGridRunsPerMaster);
1065 // Optionally define the files to be archived.
1066 // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File");
1069 // Put default output files to archive
1070 TString listhists = "";
1071 TString listaods = "";
1072 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1073 TIter next(mgr->GetOutputs());
1074 AliAnalysisDataContainer *output;
1075 while ((output=(AliAnalysisDataContainer*)next())) {
1076 const char *filename = output->GetFileName();
1077 if (!(strcmp(filename, "default"))) {
1078 if (!mgr->GetOutputEventHandler()) continue;
1079 filename = mgr->GetOutputEventHandler()->GetOutputFileName();
1080 if (listaods.Length()) listaods += ",";
1081 listaods += filename;
1084 listaods += "pyxsec_hists.root";
1088 if(!listhists->Contains(filename)){
1089 if (listhists.Length()) listhists += ",";
1090 listhists += filename;
1094 if (mgr->GetExtraFiles().Length()) {
1095 if (!strcmp(filename, "pyxsec_hists.root")) continue;
1096 if (listhists.Contains(filename)) continue;
1097 if (listhists.Length()) listhists += ",";
1098 if (listaods.Length()) listaods += ",";
1100 if (listhists.Length()) listhists = Form("hist_archive.zip:%s@%s", listhists.Data(), kGridOutputStorages.Data());;
1101 if (listaods.Length()) listaods = Form("aod_archive.zip:%s@%s", listaods.Data(), kGridOutputStorages.Data());;
1102 if (!listhists.Length() && !listaods.Length()) {
1103 ::Fatal("AnalysisTrainPWG4Jets", "No task output !");
1105 TString outputArchive = "log_archive.zip:stdout,stderr@ALICE::CERN::SE";
1106 if (listaods.Length()) {
1107 outputArchive += " ";
1108 outputArchive += listaods;
1110 if (listhists.Length()) {
1111 outputArchive += " ";
1112 outputArchive += listhists;
1114 plugin->SetOutputArchive(outputArchive);
1115 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
1116 plugin->SetAnalysisMacro(Form("%s.C", kTrainName.Data()));
1117 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
1118 plugin->SetSplitMaxInputFileNumber(kGridFilesPerJob);
1119 // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
1120 // plugin->SetMaxInitFailed(5);
1121 // Optionally resubmit threshold.
1122 // plugin->SetMasterResubmitThreshold(90);
1123 // Optionally set time to live (default 30000 sec)
1124 plugin->SetTTL(30000);
1125 // Optionally set input format (default xml-single)
1126 plugin->SetInputFormat("xml-single");
1127 // Optionally modify the name of the generated JDL (default analysis.jdl)
1128 plugin->SetJDLName(Form("%s.jdl", kTrainName.Data()));
1129 // Optionally modify the executable name (default analysis.sh)
1130 plugin->SetExecutable(Form("%s.sh", kTrainName.Data()));
1131 // Optionally modify job price (default 1)
1132 plugin->SetPrice(1);
1133 // Optionally modify split mode (default 'se')
1134 plugin->SetSplitMode("se");
1138 //______________________________________________________________________________
1141 // Write train configuration in a file. The file name has the format:
1142 // train_[trainName]_ddMonthyyyy_time.C
1144 gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp");
1145 ifstream fdate("date.tmp");
1146 if (!fdate.is_open()) {
1147 ::Error("AnalysisTrainPWG4Jets.C::Export","Could not generate file name");
1150 const char date[64];
1151 fdate.getline(date,64);
1153 gSystem->Exec("rm date.tmp");
1154 kTrainName = Form("train_%s_%s", kTrainName.Data(), date);
1156 kTrainName = Form("train_%s", kTrainName.Data());
1158 TString cdir = gSystem->WorkingDirectory();
1159 gSystem->MakeDirectory(kTrainName);
1160 gSystem->ChangeDirectory(kTrainName);
1162 out.open(Form("%sConfig.C",kTrainName.Data()), ios::out);
1164 ::Error("AnalysisTrainPWG4Jets.C::Export", "Cannot open ConfigTrain.C for writing");
1168 out << " kTrainName = " << "\"" << kTrainName.Data() << "\";" << endl;
1169 out << " kProofCluster = " << "\"" << kProofCluster.Data() << "\";" << endl;
1170 out << " kProofUseAFPAR = " << kProofUseAFPAR << ";" << endl;
1172 out << " kProofAFversion = " << kProofAFversion.Data() << ";" << endl;
1173 out << " kProofDataSet = " << "\"" << kProofDataSet.Data() << "\";" << endl;
1174 out << " kPluginUse = " << kPluginUse << ";" << endl;
1175 out << " kUsePAR = " << kUsePAR << ";" << endl;
1176 out << " kUseCPAR = " << kUseCPAR << ";" << endl;
1177 out << " kPluginRootVersion = " << "\"" << kPluginRootVersion.Data() << "\";" << endl;
1178 out << " kPluginAliRootVersion = " << "\"" << kPluginAliRootVersion.Data() << "\";" << endl;
1179 out << " kGridDatadir = " << "\"" << kGridDatadir.Data() << "\";" << endl;
1180 if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
1181 out << " kGridOutdir = " << "\"" << kGridOutdir.Data() << "\";" << endl;
1182 out << " kGridMaxMergeFiles = " << kGridMaxMergeFiles << ";" << endl;
1183 out << " kGridMergeExclude = " << "\"" << kGridMergeExclude.Data() << "\";" << endl;
1184 out << " kGridRunsPerMaster = " << kGridRunsPerMaster << ";" << endl;
1185 out << " kGridFilesPerJob = " << kGridFilesPerJob << ";" << endl;
1186 out << " kGridRunRange[0] = " << kGridRunRange[0] << ";" << endl;
1187 out << " kGridRunRange[1] = " << kGridRunRange[1] << ";" << endl;
1188 out << " kUseDebug = " << kUseDebug << ";" << endl;
1189 out << " kUseMC = " << kUseMC << ";" << endl;
1190 out << " kUseESDTags = " << kUseESDTags << ";" << endl;
1191 out << " kUseKinefilter = " << kUseKinefilter << ";" << endl;
1192 out << " kUseTR = " << kUseTR << ";" << endl;
1193 out << " kUseAODTags = " << kUseAODTags << ";" << endl;
1194 out << " kSaveTrain = " << "kFALSE;" << endl << endl;
1195 out << " // Analysis modules" << endl;
1196 out << " iAODanalysis = " << iAODanalysis << ";" << endl;
1197 out << " iAODhandler = " << iAODhandler << ";" << endl;
1198 out << " iESDfilter = " << iESDfilter << ";" << endl;
1199 out << " iJETAN = " << iJETAN << ";" << endl;
1200 out << "// Configuration fot the wagons" << endl;
1202 ::Info("AnalysisTrainPWG4Jets.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", kTrainName.Data()));
1203 gSystem->ChangeDirectory(cdir);
1206 //______________________________________________________________________________
1207 Bool_t LoadConfig(const char *filename)
1209 // Read train configuration from file
1210 if (gSystem->AccessPathName(filename)) {
1211 ::Error("AnalysisTrainPWG4Jets.C::LoadConfig", "Config file name not found");
1214 gROOT->ProcessLine(Form(".x %s", filename));
1215 ::Info("AnalysisTrainPWG4Jets.C::LoadConfig", "Train configuration loaded from file %s", filename);
1220 Printf(">>> Patching JDL");
1221 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1222 AliAnalysisAlien* gridHandler = (AliAnalysisAlien*)mgr->GetGridHandler();
1223 TGridJDL *jdl = gridHandler->GetGridJDL();
1224 if(iJETAN)jdl->AddToPackages("fastjet","v2.4.0");
1225 gridHandler->WriteJDL(kFALSE);
1226 Printf("<<< Patching JDL");
1230 Bool_t PatchAnalysisMacro(){
1231 Printf(">>> Patching AnalysisMacro");
1232 gSystem->Exec(Form("mv %s.C %s.C_tmp",kTrainName.Data(),kTrainName.Data()));
1235 in1.open(Form("%s.C_tmp", kTrainName.Data()));
1238 while(in1.getline(cLine,250)){
1243 index = st.Index("gSystem->Load(\"libPhysics\");");
1244 index += strlen("gSystem->Load(\"libPhysics\");");
1248 arr = anaLibs.Tokenize(" ");
1251 add += "\n\n // added by CKB \n";
1252 while ((objstr=(TObjString*)next())){
1253 if(objstr->GetString().EndsWith(".so"))add += Form("gSystem->Load(\"%s\");\n",objstr->GetString().Data());
1256 add += "// BKC \n\n";
1257 st.Insert(index,add.Data());
1260 out.open(Form("%s.C", kTrainName.Data()));
1265 Printf("<<< Patching AnalysisMacro");