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