Changes for running with background subtraction
[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
509 taskCl = AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.2,0,1, kDeltaAODJetName.Data(),0.15); // this one is for the background and random jets
f4132e7d 510 taskCl->SetBackgroundCalc(kTRUE);
ffab794c 511 taskCl->SetCentralityCut(fCenLo,fCenUp);
f4132e7d 512 taskCl->SetGhostEtamax(0.9);
513 }
514 else{
515 taskCl = AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.6,0,1,kDeltaAODJetName.Data()); // this one is for the background jets
516 taskCl->SetBackgroundCalc(kTRUE);
d8f21f85 517 kDefaultJetBackgroundBranch = Form("%s_%s",AliAODJetEventBackground::StdBranchName(),taskCl->GetJetOutputBranch());
518 }
4478beda 519
070f06d2 520 taskCl = AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelectionFlag,"ANTIKT",0.4,0,1,kDeltaAODJetName.Data(),0.15);
ffab794c 521 taskCl->SetCentralityCut(fCenLo,fCenUp);
d8f21f85 522 taskCl->SetBackgroundBranch(kDefaultJetBackgroundBranch.Data());
a31b8a87 523 taskCl->SetNRandomCones(10);
d8f21f85 524 kDefaultJetBranch = taskCl->GetJetOutputBranch();
4478beda 525 if(kDeltaAODJetName.Length()==0)taskCl->SetJetTriggerPtCut(40.);
a7e27517 526 kJetSubtractBranches += Form("%s ",taskCl->GetJetOutputBranch());
527
d8f21f85 528 taskCl = AddTaskJetCluster("AOD","",kHighPtFilterMask,iPhysicsSelectionFlag,"ANTIKT",0.2,0,1,kDeltaAODJetName.Data(),0.15);
070f06d2 529 taskCl->SetCentralityCut(fCenLo,fCenUp);
d8f21f85 530 taskCl->SetBackgroundBranch(kDefaultJetBackgroundBranch.Data());
a7e27517 531 kJetSubtractBranches += Form("%s ",taskCl->GetJetOutputBranch());
532
d4e8abc5 533 if(kUseAODMC){
1c79997e 534 if(kIsPbPb){
d8f21f85 535 taskCl = AddTaskJetCluster("AODMC","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.4,0,1, kDeltaAODJetName.Data(),0.15); // this one is for the background and random jets
536 taskCl->SetBackgroundCalc(kTRUE);
537 taskCl->SetGhostEtamax(0.9);
538 kDefaultJetBackgroundBranchMC = Form("%s_%s",AliAODJetEventBackground::StdBranchName(),taskCl->GetJetOutputBranch());
1c79997e 539
d8f21f85 540 taskCl = AddTaskJetCluster("AODMC2","",kHighPtFilterMask,iPhysicsSelectionFlag,"KT",0.4,0,1, kDeltaAODJetName.Data(),0.15); // this one is for the background and random jets
541 taskCl->SetBackgroundCalc(kTRUE);
542 taskCl->SetGhostEtamax(0.9);
543 kDefaultJetBackgroundBranchMC2 = Form("%s_%s",AliAODJetEventBackground::StdBranchName(),taskCl->GetJetOutputBranch());
1c79997e 544 }
545 else{
d8f21f85 546 // pp background calcs...
547 }
548
549 taskCl = AddTaskJetCluster("AODMC","",kHighPtFilterMask,iPhysicsSelectionFlag,"ANTIKT",0.4,0,1, kDeltaAODJetName.Data(),0.15); // this one is for the background and random jets
550 taskCl->SetGhostEtamax(0.9);
551 taskCl->SetBackgroundBranch(kDefaultJetBackgroundBranchMC.Data());
552 kDefaultJetBranchMC = taskCl->GetJetOutputBranch();
1c79997e 553
d8f21f85 554 taskCl = AddTaskJetCluster("AODMC2","",kHighPtFilterMask,iPhysicsSelectionFlag,"ANTIKT",0.4,0,1, kDeltaAODJetName.Data(),0.15); // this one is for the background and random jets
555 taskCl->SetBackgroundBranch(kDefaultJetBackgroundBranchMC2.Data());
556 kDefaultJetBranchMC2 = taskCl->GetJetOutputBranch();
1c79997e 557
d4e8abc5 558 }
d8f21f85 559
560
bd80a748 561 if (!taskCl) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskCluster cannot run for this train conditions - EXCLUDED");
562 }
bd80a748 563 }
564
a7e27517 565 if(iJETSUBTRACT){
566 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetBackgroundSubtract.C");
567 AliAnalysisTaskJetBackgroundSubtract *taskSubtract = 0;
568 if(kJetSubtractBranches.Length()){
a31b8a87 569
4478beda 570 taskSubtract = AddTaskJetBackgroundSubtract(kJetSubtractBranches,3,kJetSubtractMask1.Data(),kJetSubtractMask2.Data());
571 taskSubtract->SetBackgroundBranch(kDefaultJetBackgroundBranch.Data());
572
573 taskSubtract = AddTaskJetBackgroundSubtract(kJetSubtractBranches,2,kJetSubtractMask1.Data(),kJetSubtractMask2.Data());
a7e27517 574 taskSubtract->SetBackgroundBranch(kDefaultJetBackgroundBranch.Data());
a31b8a87 575 taskSubtract->SelectCollisionCandidates(iPhysicsSelectionFlag);
576 // taskSubtract->SetDebugLevel(3);
577
4478beda 578 taskSubtract = AddTaskJetBackgroundSubtract(kJetSubtractBranches,1,kJetSubtractMask1.Data(),kJetSubtractMask2.Data());
a31b8a87 579 taskSubtract->SetBackgroundBranch(kDefaultJetBackgroundBranch.Data());
580 taskSubtract->SelectCollisionCandidates(iPhysicsSelectionFlag);
a7e27517 581 if(kJetSubtractBranches.Contains(kDefaultJetBranch.Data())){
a31b8a87 582 kDefaultJetBranch.ReplaceAll(taskSubtract->GetToReplace(),Form(taskSubtract->GetReplacementMask(),taskSubtract->GetSubtractionMethod()));
a7e27517 583 }
a7e27517 584 }
585 if (!taskSubtract) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetBackgroundSubtrac cannot run for this train conditions - EXCLUDED");
586 }
587
c38e3b95 588 if (iDIJETAN) {
589 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskDiJets.C");
590 AliAnalysisTaskDiJets *taskdijets = 0;
82ebd295 591 if(iDIJETAN&1)taskdijets = AddTaskDiJets();
c38e3b95 592 if (!taskdijets) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJets cannot run for this train conditions - EXCLUDED");
82ebd295 593 if(iDIJETAN&2){
594 taskdijets = AddTaskDiJets("jetsAOD_CDF07");
595 taskdijets = AddTaskDiJets("jetsAOD_DA07");
596 taskdijets = AddTaskDiJets("jetsAOD_FASTJET07");
597 taskdijets = AddTaskDiJets("jetsAOD_FASTKT07");
598 taskdijets = AddTaskDiJets("jetsAOD_SISCONE07");
599 taskdijets = AddTaskDiJets("jetsAOD_UA107");
600 }
c38e3b95 601 }
602
c38e3b95 603 if(iPWG1QASym){
5dbdc61f 604 gROOT->LoadMacro("$ALICE_ROOT/PWG1/PilotTrain/AddTaskQAsym.C");
c38e3b95 605 AliAnalysisTaskQASym *taskQASym = AddTaskQAsym(-1);
606 if (!taskQASym) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQASym cannot run for this train conditions - EXCLUDED");
121e4bd5 607 }
c38e3b95 608
121e4bd5 609
610
611 if(iPWG4TmpSourceSara){
612 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskEta.C");
613 AliAnalysisTaskEta *taskEta = AddTaskEta();
614 if (!taskEta) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskEta cannot run for this train conditions - EXCLUDED");
c38e3b95 615 }
616
c580ebbb 617
c38e3b95 618 if(iPWG4JetServices){
619 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetServices.C");
620 AliAnalysisTaskJetServices *taskjetServ = 0;
621 taskjetServ = AddTaskJetServices();
622 if (!taskjetServ) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetServices cannot run for this train conditions - EXCLUDED");
53c63663 623 if(kGridRunRange[0]>0)taskjetServ->SetRunRange(kGridRunRange[0],kGridRunRange[1]);
27cdf9c4 624 else taskjetServ->SetRunRange(110000,160000);
625 taskjetServ->SetMCData(kIsMC);
dc6a7461 626 taskjetServ->SetUsePhysicsSelection((Bool_t)iPhysicsSelection);
39e7e8ab 627 taskjetServ->SetPhysicsSelectionFlag(iPhysicsSelectionFlag); //
f4132e7d 628 taskjetServ->SetNonStdFile(kDeltaAODJetName.Data());
629 if(kIsPbPb){
d8f21f85 630 if(kDeltaAODJetName.Length()>0)taskjetServ->SetFilterAODCollisions(kTRUE);
631 taskjetServ->SetZVertexCut(8.);
f4132e7d 632 }
ffab794c 633 if(iAODanalysis){
d8f21f85 634 // taskjetServ->SetDebugLevel(3);
ffab794c 635 taskjetServ->SetAODInput(kTRUE);
636 }
c38e3b95 637 }
638
c38e3b95 639 if(iPWG4JetSpectrum){
640 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetSpectrum2.C");
641 AliAnalysisTaskJetSpectrum2 *taskjetSpectrum = 0;
6bd3fdae 642 if(iPWG4JetSpectrum&1){
f4132e7d 643 if(kIsPbPb){
a31b8a87 644 for(int i = 0;i<5;i++){
645 TString tmp(kDefaultJetBranch.Data());
4478beda 646 // tmp.ReplaceAll(Form(kJetSubtractMask2.Data(),1),kJetSubtractMask1.Data());
647 // tmp.ReplaceAll(Form(kJetSubtractMask2.Data(),1),kJetSubtractMask1.Data());
648 tmp.ReplaceAll(Form(kJetSubtractMask2.Data(),1),Form(kJetSubtractMask1.Data(),0));
a31b8a87 649 taskjetSpectrum = AddTaskJetSpectrum2(kDefaultJetBranch.Data(),tmp.Data(),"",kHighPtFilterMask,AliVEvent::kMB,0,kFALSE,0,i);
650 // taskjetSpectrum->SetDebugLevel(3);
651 // taskjetSpectrum->SetMinJetPt(10);
652 taskjetSpectrum->SetTrackEtaWindow(0.8);
653 taskjetSpectrum->SetJetEtaWindow(0.4);
654 if(iAODanalysis)SetAODInput(taskjetSpectrum);
d8f21f85 655
a31b8a87 656
657 // check the old subtracted vs. the new subtracted
658 TString tmp2(kDefaultJetBranch.Data());
4478beda 659 tmp2.ReplaceAll(Form(kJetSubtractMask2.Data(),1),Form(kJetSubtractMask2.Data(),2));
a31b8a87 660 taskjetSpectrum = AddTaskJetSpectrum2(tmp2.Data(),kDefaultJetBranch.Data(),"",kHighPtFilterMask,AliVEvent::kMB,0,kFALSE,0,i);
661 // taskjetSpectrum->SetDebugLevel(3);
662 // taskjetSpectrum->SetMinJetPt(10);
663 taskjetSpectrum->SetTrackEtaWindow(0.8);
664 taskjetSpectrum->SetJetEtaWindow(0.4);
665 if(iAODanalysis)SetAODInput(taskjetSpectrum);
666
4478beda 667 // check the old subtracted vs. the new subtracted
668 TString tmp3(kDefaultJetBranch.Data());
669 tmp3.ReplaceAll(Form(kJetSubtractMask2.Data(),1),Form(kJetSubtractMask2.Data(),3));
a31b8a87 670
4478beda 671 taskjetSpectrum = AddTaskJetSpectrum2(tmp3.Data(),kDefaultJetBranch.Data(),"",kHighPtFilterMask,AliVEvent::kMB,0,kFALSE,0,i);
a31b8a87 672 // taskjetSpectrum->SetDebugLevel(3);
673 // taskjetSpectrum->SetMinJetPt(10);
674 taskjetSpectrum->SetTrackEtaWindow(0.8);
675 taskjetSpectrum->SetJetEtaWindow(0.4);
676 if(iAODanalysis)SetAODInput(taskjetSpectrum);
d8f21f85 677
4478beda 678
679 taskjetSpectrum = AddTaskJetSpectrum2(Form("jetsAOD_UA104_B2_Filter%05d_Cut01000",kHighPtFilterMask),kDefaultJetBranch.Data(),"",kHighPtFilterMask,AliVEvent::kMB,0,kFALSE,0,i);
680 // taskjetSpectrum->SetDebugLevel(3);
681 // taskjetSpectrum->SetMinJetPt(10);
682 taskjetSpectrum->SetTrackEtaWindow(0.8);
683 taskjetSpectrum->SetJetEtaWindow(0.4);
684 if(iAODanalysis)SetAODInput(taskjetSpectrum);
d8f21f85 685
a31b8a87 686 }
f4132e7d 687 }
d8f21f85 688 if (!taskjetSpectrum) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetSpectrum2 cannot run for this train conditions - EXCLUDED");
e6993a52 689 }
d8f21f85 690 }
691
692 if(iPWG4Fragmentation){
693 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskFragmentationFunction.C");
694 AliAnalysisTaskFragmentationFunction *taskFrag = 0;
695 if(kUseAODMC){
696
36c36a0c 697 }
d8f21f85 698 else{
699 taskFrag = AddTaskFragmentationFunction(kDefaultJetBranch.Data(),"","","",kHighPtFilterMask);
700 }
701 if (!taskFrag) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskFragmentationFunction cannot run for this train conditions - EXCLUDED");
702 }
703
704 if(iPWG4JetChem){
705 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetChem.C");
706 AliAnalysisTask *taskChem = AddTaskJetChem(kHighPtFilterMask);
707 if (!taskChem) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetChem cannot run for this train conditions - EXCLUDED");
c38e3b95 708 }
6bd3fdae 709
710
d8f21f85 711
58ef946c 712 if(iPWG4JCORRAN){
713 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJCORRANTask.C");
4721d8c5 714 AliJCORRANTask* corran = AddTaskJCORRAN(kDeltaAODJCORRANName.Data(),0);
58ef946c 715 if(!corran)::Warning("AnalysisTrainPWG4Jets", "AliJCORRANTask cannot run for this train conditions - EXCLUDED");
4721d8c5 716 else{
717 if(kDeltaAODJCORRANName.Length()>0)mgr->RegisterExtraFile(kDeltaAODJCORRANName.Data());
718 }
58ef946c 719 }
720
c38e3b95 721 if(iPWG4UE){
722 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskUE.C");
723 AliAnalysisTaskUE *taskUE = 0;
724 if(iPWG4UE&1)taskUE = AddTaskUE();
725 if(iPWG4UE&2){
94ee88d4 726 taskUE =AddTaskUE("jetsAOD_CDF04","CDF", "LJ", "TRANSV","MSP"); //finder not yet in train
17d96675 727 // taskUE =AddTaskUE("jetsAOD_CDF07","CDF", "LJ", "TRANSV","MSP");
94ee88d4 728 taskUE =AddTaskUE("jetsAOD_SISCONE04","CDF", "LJ", "TRANSV","MSP");
17d96675 729 // taskUE =AddTaskUE("jetsAOD_SISCONE07","CDF", "LJ", "TRANSV","MSP"); //finder not yet in train
94ee88d4 730 taskUE =AddTaskUE("jetsAOD_ICDF","CDF","LJ","TRANSV","MSP");
731 taskUE =AddTaskUE("jetsAOD_FASTKT04","CDF", "LJ", "TRANSV","MSP");
17d96675 732 // taskUE =AddTaskUE("jetsAOD_FASTKT07","CDF", "LJ", "TRANSV","MSP"); //finder not yet in train
58ef946c 733 taskUE =AddTaskUE("jetsAOD_NONE","CDF", "MP_eta05", "TRANSV","MSP");
734 taskUE =AddTaskUE("jetsAOD_NONE","CDF", "MP_eta09", "TRANSV","MSP");
c38e3b95 735 }
2bb1f4ca 736
c38e3b95 737 if (!taskUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskUE cannot run for this train conditions - EXCLUDED");
738 }
e0c120d9 739
740 if(iPWG4LeadingUE){
741 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskLeadingTrackUE.C");
742 AliAnalysisTaskLeadingTrackUE *taskLeadingUE = AddTaskLeadingTrackUE(kUseMC);
743 if (!taskLeadingUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTasLeadingTrackkUE cannot run for this train conditions - EXCLUDED");
27cdf9c4 744 // taskLeadingUE->SetFilterBit(64);
e0c120d9 745 }
746
747
9748e967 748 if(iPWG4CorrectionsUE){
749 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskCorrectionsUE.C");
750 AliAnalysisTaskCorrectionsUE *taskCorrectionsUE = 0;
751 if(iPWG4CorrectionsUE&1)taskCorrectionsUE = AddTaskCorrectionsUE("jetsAOD_NONE","CDF","MP_eta05","TRANSV","MSP",kFALSE);
752 if (!taskCorrectionsUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskCorrectionsUE cannot run for this train conditions - EXCLUDED");
753 }
c38e3b95 754
755 if(iPWG4ThreeJets){
756 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskThreeJets.C");
757 AliAnalysisTaskThreeJets *taskThree = AddTaskThreeJets();
758 if(!taskThree)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskThreets cannot run for this train conditions - EXCLUDED");
759 }
cc636095 760 if(iPWG4QGSep){
761 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskQGSep.C");
762 AliAnalysisTaskQGSep *taskQGSep = AddTaskQGSep(kUseMC,iAODanalysis);
763 if(!taskQGSep)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQGSep cannot run for this train conditions - EXCLUDED");
764 }
765
766
767 if(iPWG4Minijet){
768 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskMinijet.C");
4d16db9c 769 AliAnalysisTaskMinijet *taskMini = AddTaskMinijet(-1,"esd",kUseMC,kGridDataSet);
cc636095 770 // if we ha highmult trigger add another task
771 if(!taskMini)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskMinjet cannot run for this train conditions - EXCLUDED");
772 }
773
774
c38e3b95 775 if(iPWG4PtQAMC){
776 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQAMC.C");
f87effcf 777 AliPWG4HighPtQAMC *taskQAMC = 0;
778 if(kUseMC){
36c36a0c 779 if(iPWG4PtQAMC&1){
780 taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data(),0);
781 taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data(),1);
782 taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data(),2);
783 }
f87effcf 784 }
c38e3b95 785 if (!taskQAMC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQAMC cannot run for this train conditions - EXCLUDED");
786 }
787
788 if(iPWG4PtQATPC){
789 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQATPConly.C");
10295ac3 790 AliPWG4HighPtQATPConly *taskQATPC = 0;
b1cd0099 791 if(iPWG4PtQATPC&1)taskQATPC = AddTaskPWG4HighPtQATPConly(kGridDataSet.Data(),1);
792 if(iPWG4PtQATPC&2)taskQATPC = AddTaskPWG4HighPtQATPConly(kGridDataSet.Data(),2);
10295ac3 793
794 if (!taskQATPC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQATPC cannot run for this train conditions - EXCLUDED");
c38e3b95 795 }
3878a941 796
1f329128 797 if(iPWG4Cosmics){
798 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4CosmicCandidates.C");
799
800 AliPWG4CosmicCandidates *taskPWG4CosmicCandidates = AddTaskPWG4CosmicCandidates(0);
801 taskPWG4CosmicCandidates = AddTaskPWG4CosmicCandidates(1);
802
803 if (!taskPWG4CosmicCandidates) ::Warning("AnalysisTrainPWG4Jets", "AddTaskPWG4CosmicCandidates cannot run for this train conditions - EXCLUDED");
804 }
805
806
c38e3b95 807 if(iPWG4PtSpectra){
808 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtSpectra.C");
b1cd0099 809 AliPWG4HighPtSpectra *taskPtSpectra = AddTaskPWG4HighPtSpectra(kGridDataSet.Data());
c38e3b95 810 if (!taskPtSpectra) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskPtSpectra cannot run for this train conditions - EXCLUDED");
811 }
b53f2e4f 812 if(iPWG4KMeans){
813 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskKMeans.C");
814 AliAnalysisTaskKMeans *taskKMeans = AddTaskKMeans();
815 if (!taskKMeans) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskKMenans cannot run for this train conditions - EXCLUDED");
816 }
817
c38e3b95 818 if(iPWG4PartCorr){
819 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPartCorr.C");
14526afb 820 AliAnalysisTaskParticleCorrelation *taskpartcorrPHOS = AddTaskPartCorr("AOD", "PHOS",kFALSE,kIsMC);
c38e3b95 821 if (!taskpartcorrPHOS) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation PHOS cannot run for this train conditions - EXCLUDED");
14526afb 822 AliAnalysisTaskParticleCorrelation *taskpartcorrEMCAL = AddTaskPartCorr("AOD", "EMCAL",kFALSE,kIsMC);
c38e3b95 823 if (!taskpartcorrEMCAL) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation EMCAL cannot run for this train conditions - EXCLUDED");
4721d8c5 824 if(kDeltaAODPartCorrName.Length()>0)mgr->RegisterExtraFile(kDeltaAODPartCorrName.Data());
121e4bd5 825 }
826
d2e6cdd5 827 if(iPWG4CaloQA){
828 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/QA/AddTaskCalorimeterQA.C");
9748e967 829 AliAnalysisTaskParticleCorrelation *taskcaloQA = AddTaskCalorimeterQA("ESD",kFALSE,kIsMC,kCaloQAOutputFileName.Data());
d2e6cdd5 830 if(!taskcaloQA)::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation QA cannot run - EXCLUDED");
aba42fcb 831 // if(kCaloQAOutputFileName.Length()>0)mgr->RegisterExtraFile(kCaloQAOutputFileName.Data());
d2e6cdd5 832 }
833
d2e6cdd5 834 if(iPWG4JetCorr){
835 // using namespace JetCorrelHD;
d3af0232 836 TString cdir = gSystem->WorkingDirectory();
837 gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/"));
d2e6cdd5 838 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetCorrel.C");
839 AliAnalysisTaskJetCorrel *taskjetcorr = AddTaskJetCorrel();
d3af0232 840 gSystem->ChangeDirectory(cdir);
c166d299 841 if (!taskjetcorr) ::Warning("AnalysisTrainNew", "AliAnalysisTaskJetCorrel cannot run for this train conditions - EXCLUDED");
d2e6cdd5 842 }
843
911a740f 844 if(iPWG4Tagged){
845 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskTaggedPhotons.C");
846 AliAnalysisTaskTaggedPhotons * taskTagged = AddTaskTaggedPhotons(kFALSE); // EMCAL
58ef946c 847 taskTagged = AddTaskTaggedPhotons(kTRUE); // PHOS
911a740f 848 if (!taskTagged) ::Warning("AnalysisTrainNew", "AliAnalysisTaskTaggedPhotons cannot run for this train conditions - EXCLUDED");
849 }
121e4bd5 850 if (iPWG4omega3pi) {
851 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskomega3pi.C");
852 AliAnalysisTaskOmegaPi0PiPi *taskomega3pi = AddTaskomega3pi();
853 if (!taskomega3pi) ::Warning("AnalysisTrainNew", "AliAnalysisTaskomega3pi cannot run\
854 for these train conditions - EXCLUDED");
855 }
856
53c63663 857 // PWG4 gamma conversion analysis
858 if (iPWG4GammaConv) {
859 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskGammaConversion.C");
860 TString cdir = gSystem->WorkingDirectory();
861 gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/"));
862 // TString gcArguments = "-run-on-train -run-jet -run-chic -run-neutralmeson -run-cf";
58ef946c 863 // TString gcArguments = "-run-on-train -run-jet -run-neutralmeson -run-cf -use-own-xyz";
864 // TString gcArguments = "-run-on-train -run-jet -run-neutralmeson -run-cf -use-own-xyz";
b0a36f28 865 TString gcArguments = "-run-on-train -run-jet -run-omega-meson -use-own-xyz -run-neutralmeson -no-aod";
27cdf9c4 866 // TString kGCAnalysisCutSelectionId="9003562000100310";
cfd02305 867 // TString kGCAnalysisCutSelectionId="9003562000100312";
868 // gcArguments.Append(Form(" -set-cut-selection %s ",kGCAnalysisCutSelectionId.Data()));
53c63663 869 if(!kIsMC)gcArguments += " -mc-off";
870 AliAnalysisTaskGammaConversion * taskGammaConversion = AddTaskGammaConversion(gcArguments,mgr->GetCommonInputContainer());
871 gSystem->ChangeDirectory(cdir);
121e4bd5 872 taskGammaConversion->SelectCollisionCandidates();
53c63663 873 if (!taskGammaConversion) ::Warning("AnalysisTrainNew", "AliAnalysisTaskGammaConversion cannot run for these train conditions - EXCLUDED");
874 }
875
17d96675 876 if (iPWG4CaloConv) {
877 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskCaloConv.C");
878 AliAnalysisTaskCaloConv * taskCaloConv = AddTaskCaloConv();
879 if (!taskCaloConv) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCaloConv cannot run for these train conditions - EXCLUDED");
880 }
881
882
3878a941 883
c38e3b95 884 //==========================================================================
885 // FOR THE REST OF THE TASKS THE MACRO AddTaskXXX() is not yet implemented/
886 // Run the analysis
887 //
888 if (kPluginUse) {
889 AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
890 AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
891 }
892
893 if (mgr->InitAnalysis()) {
894 mgr->PrintStatus();
895 // if (kSaveTrain || strlen(config_file)) gSystem->ChangeDirectory(kTrainName);
e84da0a5 896 if (!strcmp(plugin_mode,"submit")&&smode=="GRID"){
c38e3b95 897 TString alien_workdir = gGrid->GetHomeDirectory();
898 if (iAODanalysis) alien_workdir += "analysisAOD";
899 else alien_workdir += "analysisESD";
3878a941 900 if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data());
c38e3b95 901 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
e84da0a5 902 printf("=== AnalysisTrainPWG4Jets:: Registering jdl in the work directory alien://%s/%s, should be done by the manager! ===\n",
c38e3b95 903 alien_workdir.Data(),gridhandler->GetGridOutputDir());
58ef946c 904
905 TString dest;
906 dest = Form("%s/%s/%s.jdl",alien_workdir.Data(),gridhandler->GetGridOutputDir(),kTrainName.Data());
907 if(AliAnalysisAlien::FileExists(dest.Data())){
908 // Printf("%s exist on grid removing...",dest.Data());
909 // gGrid->Rm(dest.Data());
910 }
911 TFile::Cp(Form("file:%s.jdl",kTrainName.Data()),Form("alien://%s",dest.Data()));
4721d8c5 912
913
914 TString dest;
915 dest = Form("%s/%s/%s_merge.jdl",alien_workdir.Data(),gridhandler->GetGridOutputDir(),kTrainName.Data());
916 if(AliAnalysisAlien::FileExists(dest.Data())){
917 // Printf("%s exist on grid removing...",dest.Data());
918 // gGrid->Rm(dest.Data());
919 }
920 TFile::Cp(Form("file:%s_merge.jdl",kTrainName.Data()),Form("alien://%s",dest.Data()));
921
58ef946c 922
73b7619a 923 dest = Form("%s/rootfiles/STEER/LQ1dRef_v1.root",gGrid->GetHomeDirectory());
58ef946c 924 if(AliAnalysisAlien::FileExists(dest.Data())){
925 Printf("%s exist on grid removing...",dest.Data());
926 gGrid->Rm(dest.Data());
927 }
928 TFile::Cp(Form("file:%s/STEER/LQ1dRef_v1.root",
9748e967 929 gSystem->ExpandPathName("$ALICE_ROOT")),Form("alien://%s",dest.Data()));
c38e3b95 930 }
3878a941 931 AliLog::SetGlobalLogLevel(AliLog::kError);
c166d299 932 if((kUseSysInfo>0&&smode=="LOCAL")||!strcmp(plugin_mode, "test")){
933 TFile * fM = TFile::Open("manager_local.root","RECREATE");
934 mgr->Write();
935 fM->Close();
936 }
46534866 937
938 // grmpf, aliroot error handler overwrites root
939 gErrorIgnoreLevel = kErrorIgnoreLevel;
940 if(gErrorIgnoreLevel>3000) AliLog::SetGlobalLogLevel(AliLog::kFatal);
c38e3b95 941 StartAnalysis(smode, chain);
4a6f59cb 942 if((kUseSysInfo>0&&smode=="LOCAL")||!strcmp(plugin_mode, "test")){
943 for(int i = 0;i < mgr->GetTopTasks()->GetEntries();i++){
944 mgr->ProfileTask(i);
945 }
946 }
c38e3b95 947 if (!strcmp(plugin_mode, "offline")&&smode=="GRID"){
e84da0a5 948 // Offline mode path files
949 // PatchJDL();
d8f21f85 950 // PatchAnalysisMacro();
e84da0a5 951 }
c38e3b95 952
e84da0a5 953 if (kSaveTrain && smode=="GRID") {
954 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
955 TString alien_workdir = gGrid->GetHomeDirectory();
956 if (iAODanalysis) alien_workdir += "analysisAOD";
3878a941 957 else alien_workdir += "analysisESD";
958 if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data());
e84da0a5 959 // kGridOutdir = gridhandler->GetGridOutputDir();
960 printf("=== Registering ConfigTrain.C in the work directory <%s> ===\n",
c38e3b95 961 alien_workdir.Data());
e84da0a5 962 if (AliAnalysisAlien::FileExists(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data())))
963 gGrid->Rm(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()));
964 if (strcmp(plugin_mode, "test"))
965 TFile::Cp(Form("file:%sConfig.C",kTrainName.Data()), Form("alien://%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()));
966 }
967 }
c38e3b95 968}
969
970//______________________________________________________________________________
971void StartAnalysis(const char *mode, TChain *chain) {
972// Start analysis.
973 Int_t imode = -1;
974 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
975 if (!strcmp(mode, "LOCAL")) imode = 0;
976 if (!strcmp(mode, "PROOF")) imode = 1;
977 if (!strcmp(mode, "GRID")) imode = 2;
978 switch (imode) {
979 case 0:
980 if (!chain) {
981 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain");
982 return;
983 }
82ebd295 984 mgr->StartAnalysis(mode, chain,kNumberOfEvents);
c38e3b95 985 return;
986 case 1:
987 if (!kProofDataSet.Length()) {
988 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "kProofDataSet is empty");
989 return;
990 }
991 mgr->StartAnalysis(mode, kProofDataSet, kProofEvents,kProofOffset);
992 return;
993 case 2:
994 if (kPluginUse) {
995 if (!mgr->GetGridHandler()) {
996 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Grid plugin not initialized");
997 return;
998 }
ebad39a9 999 mgr->StartAnalysis("grid",chain,kNumberOfEvents);
c38e3b95 1000 } else {
1001 if (!chain) {
1002 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain");
1003 return;
1004 }
1005 mgr->StartAnalysis(mode, chain);
ebad39a9 1006 mgr->StartAnalysis(mode, chain,kNumberOfEvents);
c38e3b95 1007 }
1008 return;
1009 }
1010}
1011
1012//______________________________________________________________________________
1013void CheckModuleFlags(const char *mode) {
1014// Checks selected modules and insure compatibility
1015 Int_t imode = -1;
1016 if (!strcmp(mode, "LOCAL")) imode = 0;
1017 if (!strcmp(mode, "PROOF")) imode = 1;
1018 if (!strcmp(mode, "GRID")) imode = 2;
1019
1020
e84da0a5 1021 if (kUseCPAR) {
1022 kPluginAliRootVersion = ""; // NO aliroot if we use CPAR
1023 }
c38e3b95 1024
1025 if (imode==1) {
1026 if (!kUsePAR) {
1027 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis");
1028 kUsePAR = kTRUE;
1029 }
1030 }
1031 if (imode != 2) {
1032 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode");
1033 kPluginUse = kFALSE;
1034 }
1035
1036
1037 if(!kIsMC){
1038 // switch off anthin related to MC
1039 kUseMC = 0;
1040 kUseAODMC = 0;
1041 kUseTR = kFALSE;
1042 }
1043
f4132e7d 1044 // Decide if we have PbPb
1c79997e 1045 if(kGridDataSet.CompareTo("LHC10h")==0||kGridDataSet.Contains("LHC10h")) {
1046 Printf("Using settings for Pb+Pb");
f4132e7d 1047 kIsPbPb = true;
1048 }
1049
1050
1051
c38e3b95 1052 if (iAODanalysis) {
1053 // AOD analysis
1054 if (kUseMC)
1055 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's");
1056 if (kUseAODTags)
1057 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AOD tags usage disabled in analysis on AOD's");
1058 kUseMC = kFALSE;
1059 kUseTR = kFALSE;
1060 kUseAODTags = kFALSE;
1061 if (iESDfilter)
1062 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's");
1063 iESDfilter = 0;
e84da0a5 1064 if (iPhysicsSelection)
1065 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "Physics Selection disabled in analysis on AOD's");
1066 iPhysicsSelection = 0;
c38e3b95 1067 if (!iAODhandler) {
1068 if (iJETAN)
1069 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler");
1070 iJETAN = 0;
1071 iDIJETAN = 0;
1072 }
1073 // Disable tasks that do not work yet on AOD data
58ef946c 1074 if(iPWG4JCORRAN)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 JCORRAN disabled in analysis on AOD's");
4d62ae1a 1075 iPWG4JCORRAN = 0;
c38e3b95 1076 if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's");
1077 iPWG4PtQAMC = 0;
1078 if( iPWG4PtQATPC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtTPC disabled in analysis on AOD's");
1079 iPWG4PtQATPC = 0;
1f329128 1080 if( iPWG4Cosmics)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Comics disabled in analysis on AOD's");
1081 iPWG4Cosmics = 0;
1082
c38e3b95 1083 if( iPWG4PtSpectra)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's");
1084 iPWG4PtSpectra = 0;
b53f2e4f 1085 if(iPWG4KMeans)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4KMeans disabled on AOD's");
1086 iPWG4KMeans = 0;
d2e6cdd5 1087 if (iPWG4JetCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4Jetcorr disabled on AOD's");
1088 iPWG4JetCorr = 0;
c38e3b95 1089 if (iPWG4PartCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4partcorr disabled on AOD's");
1090 iPWG4PartCorr = 0;
d2e6cdd5 1091 if (iPWG4CaloQA)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4CaloQA disabled on AOD's");
1092 iPWG4CaloQA = 0;
911a740f 1093 if (iPWG4Tagged)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4tagged disabled on AOD's");
1094 iPWG4Tagged = 0;
121e4bd5 1095 if (iPWG4omega3pi)
1096 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4omega3pi disabled on AOD's");
1097 iPWG4omega3pi = 0;
c38e3b95 1098 if(iPWG1QASym)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG1 QA Sym disabled in analysis on AOD's");
53c63663 1099 if (iPWG4GammaConv)::Info("AnalysisPWG4Jets.C::CheckModuleFlags", "PWG4gammaconv disabled on AOD's");
1100 iPWG4GammaConv = 0;
c38e3b95 1101 iPWG1QASym = 0;
f4132e7d 1102 iCentralitySelection = 0;
c38e3b95 1103 } else {
1104 // ESD analysis
f4132e7d 1105
1106 if(kIsPbPb){
1107 iCentralitySelection = 1;
1108 }
1109
c38e3b95 1110 if (!kUseMC){
1111 kUseTR = kFALSE;
1112
1113 if(kUseKinefilter)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Kine Filter disabled in analysis without MC");
1114 kUseKinefilter = kFALSE;
1115 if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis without MC");
1116 iPWG4PtQAMC = 0;
9748e967 1117 if( iPWG4CorrectionsUE)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 CorrectionsUE disabled in analysis without MC");
1118 iPWG4CorrectionsUE = 0;
c38e3b95 1119 }
1120 if (!kUseTR) {
c166d299 1121 if(iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "iPWG4QATPCMC disabled if not reading track references");
b03b08a3 1122 iPWG4PtQAMC = 0;
c38e3b95 1123 }
e84da0a5 1124 if (iJETAN){
1125 iESDfilter=1;
1126 }
c38e3b95 1127 if (!iESDfilter){
1128 kUseKinefilter = kFALSE;
1129 kUseMuonfilter = kFALSE;
1130 }
1131 if(!iJETAN){
cc636095 1132 iPWG4JetSpectrum = iPWG4UE = iPWG4CorrectionsUE = iPWG4ThreeJets = iPWG4QGSep = iDIJETAN = 0;
c38e3b95 1133 }
1134 }
cc636095 1135 iPWG4JetTasks = iPWG4JetServices||iPWG4JetSpectrum||iPWG4UE||iPWG4LeadingUE||iPWG4PtQAMC||iPWG4PtSpectra||iPWG4PtQATPC||iPWG4Cosmics||iPWG4ThreeJets||iPWG4QGSep||iPWG4JetChem||iPWG4Minijet||iPWG4Fragmentation;
d2e6cdd5 1136 iPWG4PartCorrLibs = iPWG4PartCorr||iPWG4Tagged||iPWG4CaloQA;
17d96675 1137 iPWG4GammaConvLib = iPWG4GammaConv||iPWG4CaloConv;
1138
1139
1140 iEMCUtilLibs = iPWG4PartCorrLibs||iPWG4JCORRAN||iPWG4GammaConvLib;
e6993a52 1141 iJETANLib = iPWG4JetTasks||iJETAN||iDIJETAN;
17d96675 1142
c38e3b95 1143 if (iESDfilter) {iAODhandler=1;}
1144 if (kUseKinefilter && !kUseMC) kUseKinefilter = kFALSE;
1145 if (kUseAODTags && !iAODhandler) kUseAODTags = kFALSE;
1146
1147
1148
1149}
1150
1151//______________________________________________________________________________
1152Bool_t Connect(const char *mode) {
1153// Connect <username> to the back-end system.
1154 Int_t imode = -1;
1155 if (!strcmp(mode, "LOCAL")) imode = 0;
1156 if (!strcmp(mode, "PROOF")) imode = 1;
1157 if (!strcmp(mode, "GRID")) imode = 2;
1158 TString username = gSystem->Getenv("alien_API_USER");
1159 switch (imode) {
1160 case 0:
1161 break;
1162 case 1:
1163 if (!username.Length()) {
1164 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \
1165 1. Have called: alien-token-init <username>\n \
1166 2. Have called: >source /tmp/gclient_env_$UID");
1167 return kFALSE;
1168 }
1169 ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to PROOF cluster <%s>",
1170 username.Data(), kProofCluster.Data());
1171 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
1172// TProof::Open(Form("%s@%s:31093", username.Data(), kProofCluster.Data()));
1173 TProof::Open(Form("%s@%s", username.Data(), kProofCluster.Data()));
1174 if (!gProof) {
1175 if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch"))
1176 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch");
1177 return kFALSE;
1178 }
1179 if(kProofClearPackages)gProof->ClearPackages();
1180
1181 if(kProofSaveToAlien){
1182 TGrid::Connect("alien://");
1183 if (gGrid) {
1184 TString homedir = gGrid->GetHomeDirectory();
1185 TString workdir = homedir + kTrainName;
1186 if (!gGrid->Cd(workdir)) {
1187 gGrid->Cd(homedir);
1188 if (gGrid->Mkdir(workdir)) {
1189 gGrid->Cd(kTrainName);
1190 ::Info("AnalysisTrainPWG4Jets::Connect()", "Directory %s created", gGrid->Pwd());
1191 }
1192 }
1193 gGrid->Mkdir("proof_output");
1194 gGrid->Cd("proof_output");
1195 kProofOutdir = Form("alien://%s", gGrid->Pwd());
1196 }
1197 }
1198 break;
1199 case 2:
1200 if (!username.Length()) {
1201 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \
1202 1. Have called: alien-token-init <username>\n \
1203 2. Have called: >source /tmp/gclient_env_$UID");
1204 return kFALSE;
1205 }
1206 if (kPluginUse && !gSystem->Getenv("alien_CLOSE_SE")) {
1207 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode),
1208 "When using the AliEn plugin it is preferable to define the \
1209 variable alien_CLOSE_SE in your environment.");
1210 return kFALSE;
1211 }
1212 ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to AliEn ...",
1213 username.Data());
1214 TGrid::Connect("alien://");
1215 if (!gGrid || !gGrid->IsConnected()) return kFALSE;
1216 break;
1217 default:
1218 ::Error("AnalysisTrainPWG4Jets.C::Connect", "Unknown run mode: %s", mode);
1219 return kFALSE;
1220 }
1221 ::Info("AnalysisTrainPWG4Jets.C::Connect","Connected in %s mode", mode);
1222 return kTRUE;
1223}
1224
1225//______________________________________________________________________________
1226Bool_t LoadCommonLibraries(const char *mode)
1227{
1228// Load common analysis libraries.
1229 Int_t imode = -1;
1230 if (!strcmp(mode, "LOCAL")) imode = 0;
1231 if (!strcmp(mode, "PROOF")) imode = 1;
1232 if (!strcmp(mode, "GRID")) imode = 2;
1233 if (!gSystem->Getenv("ALICE_ROOT")) {
ebad39a9 1234 ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Analysis train requires that ALICE_ROOT is set to pick up Configurations");
c38e3b95 1235 return kFALSE;
1236 }
1237 Bool_t success = kTRUE;
1238 // ROOT libraries
1239 gSystem->Load("libTree.so");
1240 gSystem->Load("libGeom.so");
1241 gSystem->Load("libVMC.so");
1242 gSystem->Load("libPhysics.so");
1243
1244 // Load framework classes. Par option ignored here.
1245 switch (imode) {
1246 case 0:
1247 case 2:
1248 if (kUseCPAR) {
1249 success &= LoadLibrary("STEERBase", mode, kTRUE);
1250 success &= LoadLibrary("ESD", mode, kTRUE);
1251 success &= LoadLibrary("AOD", mode, kTRUE);
1252 success &= LoadLibrary("ANALYSIS", mode, kTRUE);
1253 success &= LoadLibrary("ANALYSISalice", mode, kTRUE);
d8f21f85 1254 success &= LoadLibrary("ROOTFILES", mode, kTRUE);
070f06d2 1255 success &= LoadLibrary("EventMixing", mode,kTRUE);
c38e3b95 1256 success &= LoadLibrary("CORRFW", mode, kTRUE);
1257 } else {
1258 success &= LoadLibrary("libSTEERBase.so", mode);
1259 success &= LoadLibrary("libESD.so", mode);
1260 success &= LoadLibrary("libAOD.so", mode);
1261 success &= LoadLibrary("libANALYSIS.so", mode);
1262 success &= LoadLibrary("libANALYSISalice.so", mode);
070f06d2 1263 success &= LoadLibrary("libEventMixing.so", mode);
c38e3b95 1264 success &= LoadLibrary("libCORRFW.so", mode);
1265 gROOT->ProcessLine(".include $ALICE_ROOT/include");
1266 }
1267 break;
1268 case 1:
1269 Int_t ires = -1;
1270 if (kProofUseAFPAR && !gSystem->AccessPathName(kProofAFversion)) ires = gProof->UploadPackage(kProofAFversion);
1271 if (ires < 0) {
1272 success &= LoadLibrary("STEERBase", mode);
1273 success &= LoadLibrary("ESD", mode);
1274 success &= LoadLibrary("AOD", mode);
1275 success &= LoadLibrary("ANALYSIS", mode);
1276 success &= LoadLibrary("ANALYSISalice", mode);
070f06d2 1277 success &= LoadLibrary("EventMixing", mode);
c38e3b95 1278 success &= LoadLibrary("CORRFW", mode);
1279 } else {
1280 ires = gProof->EnablePackage(kProofAFversion);
1281 if (ires<0) success = kFALSE;
1282 success &= LoadLibrary("CORRFW", mode);
1283 }
1284 break;
1285 default:
1286 ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Unknown run mode: %s", mode);
1287 return kFALSE;
1288 }
1289 if (success) {
1290 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: SUCCESS");
1291 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s",
1292 gSystem->GetIncludePath());
1293 } else {
1294 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: FAILED");
1295 }
1296
1297 return success;
1298}
1299
1300//______________________________________________________________________________
1301Bool_t LoadAnalysisLibraries(const char *mode)
1302{
1303// Load common analysis libraries.
9748e967 1304 Bool_t success = kTRUE;
cfd02305 1305 if (useTender) {
1306 if (!LoadLibrary("TENDER", mode, kTRUE) ||
1307 !LoadLibrary("TENDERSupplies", mode, kTRUE)) return kFALSE;
1308 }
c38e3b95 1309 if (iESDfilter) {
b0a36f28 1310 /*
c38e3b95 1311 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
1312 !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE;
b0a36f28 1313 */
c38e3b95 1314 }
1315 // JETAN
e6993a52 1316 if (iJETANLib) {
b53f2e4f 1317 // this part needs some rework in case we do not need the fastjed finders for processing
1318 if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE;
c38e3b95 1319 if (!strcmp(mode, "PROOF")){
ef1e462f 1320 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libCGAL.so\"\)", kTRUE);
c38e3b95 1321 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libfastjet.so\"\)", kTRUE);
1322 // problem when loading siscone copiled with different gcc version??
1323 // gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libsiscone.so\"\)", kTRUE);
1324 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libSISConePlugin.so\"\)", kTRUE);
1325 }
b53f2e4f 1326 if(!kUsePAR){
e84da0a5 1327 if (!LoadLibrary("CGAL", mode, kTRUE)) return kFALSE;
1328 if (!LoadLibrary("fastjet", mode, kTRUE)) return kFALSE;
1329 if (!LoadLibrary("siscone", mode, kTRUE)) return kFALSE;
1330 if (!LoadLibrary("SISConePlugin", mode, kTRUE)) return kFALSE;
1331 }
1332 else{
1333 // par files plus FASTJET needs some extra work... need to change
1334 // the loading sequence in the auto generated .C file
1335 if (!LoadLibrary("libCGAL.so", mode, kTRUE)) return kFALSE;
1336 if (!LoadLibrary("libfastjet.so", mode, kTRUE)) return kFALSE;
1337 if (!LoadLibrary("libsiscone.so", mode, kTRUE)) return kFALSE;
1338 if (!LoadLibrary("libSISConePlugin.so", mode, kTRUE)) return kFALSE;
1339 }
c38e3b95 1340 if (!LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE;
1341 }
1342 if(iPWG4JetTasks){
c38e3b95 1343 if (!LoadLibrary("PWG4JetTasks", mode, kTRUE)) return kFALSE;
1344 }
58ef946c 1345
c38e3b95 1346 if(iPWG1QASym){
99bfd7f7 1347 if (!LoadSource(Form("%s/PWG1/AliAnalysisTaskQASym.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
c38e3b95 1348 }
121e4bd5 1349 if(iPWG4TmpSourceSara){
c166d299 1350 if(!kUsePAR)gSystem->AddIncludePath("-I$ALICE_ROOT/include/JetTasks"); // ugly hack!!
121e4bd5 1351 if(!LoadSource(Form("%s/PWG4/JetTasks/AliAnalysisTaskEta.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
1352 }
58ef946c 1353
9f77f0ce 1354 /*
1355 if(iPWG4JetChem){
c580ebbb 1356 if(!kUsePAR)gSystem->AddIncludePath("-I$ALICE_ROOT/include/JetTasks"); // ugly hack!!
1357 if(!LoadSource(Form("%s/PWG4/JetTasks/AliAnalysisTaskJetChem.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
1358 }
9f77f0ce 1359 */
c166d299 1360
4721d8c5 1361 if(iEMCUtilLibs){
1362 if (!LoadLibrary("EMCALUtils", mode, kTRUE) ||
1363 !LoadLibrary("PHOSUtils", mode, kTRUE)) return kFALSE;
1364 }
1365
911a740f 1366 if (iPWG4PartCorrLibs) {
4721d8c5 1367 if (!LoadLibrary("PWG4PartCorrBase", mode, kTRUE) ||
c38e3b95 1368 !LoadLibrary("PWG4PartCorrDep", mode, kTRUE)) return kFALSE;
1369 }
4721d8c5 1370 if(iPWG4JCORRAN){
1371 // PWG4 particle correlations
1372 if(!LoadLibrary("PWG4JCORRAN",mode,kTRUE))return kFALSE;
1373 }
d2e6cdd5 1374 if (iPWG4JetCorr) {
1375 if (!LoadLibrary("PWG4JetCorrel", mode, kTRUE)) return kFALSE;
1376 }
121e4bd5 1377 if (iPWG4omega3pi) {
1378 if (!LoadLibrary("PWG4omega3pi", mode, kTRUE)) return kFALSE;
1379 }
17d96675 1380 if (iPWG4GammaConvLib) {
53c63663 1381 if (!LoadLibrary("PWG4GammaConv", mode, kTRUE)) return kFALSE;
1382 }
c38e3b95 1383
1384 ::Info("AnalysisTrainPWG4Jets.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS");
1385 return kTRUE;
1386}
1387
1388//______________________________________________________________________________
1389Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE)
1390{
1391// Load a module library in a given mode. Reports success.
1392 Int_t imode = -1;
1393 Int_t result;
1394 TString smodule(module);
1395 if (!strcmp(mode, "LOCAL")) imode = 0;
1396 if (!strcmp(mode, "PROOF")) imode = 1;
1397 if (!strcmp(mode, "GRID")) imode = 2;
1398 TString mod(module);
1399 if (!mod.Length()) {
1400 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Empty module name");
1401 return kFALSE;
1402 }
1403 // If a library is specified, just load it
1404 if (smodule.EndsWith(".so")) {
1405 mod.Remove(mod.Index(".so"));
1406 result = gSystem->Load(mod);
1407 if (result < 0) {
1408 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load library %s", module);
1409 return kFALSE;
1410 }
1411 if (rec) anaLibs += Form("%s.so ",mod.Data());
e84da0a5 1412 if (rec) anaLibsExtra += Form("%s.so ",mod.Data());
c38e3b95 1413 return kTRUE;
1414 }
1415 // Check if the library is already loaded
1416 if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0)
1417 return kTRUE;
1418 switch (imode) {
1419 case 0:
1420 case 2:
1421 if (kUsePAR) {
1422 result = SetupPar(module);
1423 if (rec) anaPars += Form("%s.par ", module);
1424 } else {
1425 result = gSystem->Load(Form("lib%s.so", module));
1426 if (rec) anaLibs += Form("lib%s.so ", module);
1427 }
1428 break;
1429 case 1:
1430 if(!gSystem->AccessPathName(module)){
1431 ::Info("AnalysisTrainPWG4Jets.C::LoadLibrary", "Removing directory %s",module);
1432 gSystem->Exec(Form("rm -rf %s",module));
1433 }
1434 result = gProof->UploadPackage(module);
1435 if (result<0) {
1436 result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module)));
1437 if (result<0) {
1438 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module);
1439 return kFALSE;
1440 }
1441 }
1442 result = gProof->EnablePackage(module);
1443 break;
1444 default:
1445 return kFALSE;
1446 }
1447 if (result < 0) {
1448 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load module %s", module);
1449 return kFALSE;
1450 }
1451 return kTRUE;
1452}
1453
1454
1455
1456//______________________________________________________________________________
1457Bool_t LoadSource(const char *source, const char *mode, Bool_t rec=kFALSE)
1458{
1459// Load a module library in a given mode. Reports success.
1460 Int_t imode = -1;
1461 Int_t result = -1;
1462 if (!strcmp(mode, "LOCAL")) imode = 0;
1463 if (!strcmp(mode, "PROOF")) imode = 1;
1464 if (!strcmp(mode, "GRID")) imode = 2;
1465 TString ssource(source);
1466 TString basename = gSystem->BaseName(ssource.Data());
1467 if (!ssource.Length()) {
1468 ::Error("AnalysisTrainPWG4Jets.C::LoadSource", "Empty task name");
1469 return kFALSE;
1470 }
4d62ae1a 1471 // we have a source code so compile it
c38e3b95 1472 if (ssource.EndsWith(".cxx")) {
1473 // need to copy it here other wise the path is also used on grid...
1474 ssource.Remove(ssource.Index(".cxx"));
1475 basename.Remove(basename.Index(".cxx"));
1476 Printf("LoadSources:: Copying... path %s{cxx,h}",ssource.Data());
1477 gSystem->Exec(Form("cp %s.cxx . ",ssource.Data()));
1478 gSystem->Exec(Form("cp %s.h . ",ssource.Data()));
1479 // Path to code
1480 // only needed for local compilation, in grid and proof mode
1481 // the task headers are uploaded
1482 // path.Remove(path.Index(gSystem->BaseName(path.Data())));
1483 // Printf("LoadSources:: Including path %s",path.Data());
1484 // if(path.Length()>0)gROOT->ProcessLine(Form(".include %s",path.Data()));
1485 Printf("LoadSources:: Loading... path %s",basename.Data());
1486 switch (imode) {
1487 case 0:
b53f2e4f 1488 result = gROOT->LoadMacro(Form("%s.cxx++g",basename.Data()));
c38e3b95 1489 break;
1490 case 1:
b53f2e4f 1491 result = gProof->LoadMacro(Form("%s.cxx++g",basename.Data()));
c38e3b95 1492 break;
1493 case 2:
b53f2e4f 1494 result = gROOT->LoadMacro(Form("%s.cxx++g",basename.Data()));
c38e3b95 1495 if (rec){
1496 // what we want to compile
1497 anaSources += Form("%s.cxx ",basename.Data());
1498 // what we need as input...
1499 anaLibs += Form("%s.cxx %s.h ",basename.Data(),basename.Data());
1500 }
1501 break;
1502 default:
1503 return kFALSE;
1504 }
1505 }
1506 if (result < 0) {
1507 ::Error("AnalysisTrainPWG4Jets.C::LoadSources", "Could not load source %s", source);
1508 return kFALSE;
1509 }
1510 return kTRUE;
1511}
1512
1513
1514//______________________________________________________________________________
1515TChain *CreateChain(const char *mode, const char *plugin_mode)
1516{
1517// Create the input chain
1518 Int_t imode = -1;
1519 if (!strcmp(mode, "LOCAL")) imode = 0;
1520 if (!strcmp(mode, "PROOF")) imode = 1;
1521 if (!strcmp(mode, "GRID")) imode = 2;
1522 TChain *chain = NULL;
1523 // Local chain
1524 switch (imode) {
1525 case 0:
1526 if (iAODanalysis) {
1527 if (!kLocalXMLDataset.Length()) {
1528 // Local AOD
1529 chain = new TChain("aodTree");
1530 TString line;
1531 ifstream in;
1532 in.open(kLocalDataList.Data());
1533 while (in.good()) {
1534 in >> line;
1535 if (line.Length() == 0) continue;
1536 // cout << " line = " << line << endl;
1537 chain->Add(line.Data());
1538 }
1539 } else {
1540 // Interactive AOD
1541 chain = CreateChainSingle(kLocalXMLDataset, "aodTree");
1542 }
1543 } else {
1544 if (!kLocalXMLDataset.Length()) {
1545 // Local ESD
1546 chain = new TChain("esdTree");
1547 TString line;
1548 ifstream in;
1549 in.open(kLocalDataList.Data());
1550 while (in.good()) {
1551 in >> line;
1552 if (line.Length() == 0) continue;
1553 cout << " line = " << line << endl;
1554 chain->Add(line.Data());
1555 }
1556 } else {
1557 // Interactive ESD
1558 chain = CreateChainSingle(kLocalXMLDataset, "esdTree");
1559 }
1560 }
1561 break;
1562 case 1:
1563 break;
1564 case 2:
1565 if (kPluginUse) {
1566// AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
1567// AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
1568 } else {
1569 TString treeName = "esdTree";
1570 if (iAODanalysis) treeName = "aodTree";
1571 chain = CreateChainSingle("wn.xml", treeName);
1572 }
1573 break;
1574 default:
1575 }
1576 if (chain && chain->GetNtrees()) return chain;
1577 return NULL;
1578}
1579
1580//______________________________________________________________________________
1581TChain* CreateChainSingle(const char* xmlfile, const char *treeName)
1582{
1583 printf("*******************************\n");
1584 printf("*** Getting the ESD Chain ***\n");
1585 printf("*******************************\n");
1586 TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
1587
1588 if (!myCollection) {
1589 ::Error("AnalysisTrainPWG4Jets.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
1590 return NULL ;
1591 }
1592
1593 TChain* chain = new TChain(treeName);
1594 myCollection->Reset() ;
1595 while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
1596 chain->ls();
1597 return chain;
1598}
1599
1600//______________________________________________________________________________
1601Int_t SetupPar(char* pararchivename)
1602{
1603 if (!pararchivename || !strlen(pararchivename)) return -1;
1604 char processline[1024];
1605 if (gSystem->AccessPathName(Form("%s.par", pararchivename))) {
1606 if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) {
1607 ::Info("AnalysisTrainPWG4Jets.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename);
9748e967 1608 TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)),
1609 Form("%s.par",pararchivename));
c38e3b95 1610 } else {
1611 ::Error("AnalysisTrainPWG4Jets.C::SetupPar", "Cannot find %s.par", pararchivename);
1612 return -1;
1613 }
1614 }
1615 if (kPluginUse && kSaveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, kTrainName.Data()));
1616 gSystem->Exec(Form("tar xvzf %s.par", pararchivename));
1617
1618 TString ocwd = gSystem->WorkingDirectory();
1619 if (!gSystem->ChangeDirectory(pararchivename)) return -1;
1620
1621 // check for BUILD.sh and execute
1622 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
1623 printf("*******************************\n");
1624 printf("*** Building PAR archive ***\n");
1625 printf("*******************************\n");
1626 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
1627 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
1628 return -1;
1629 }
1630 }
1631
1632 // check for SETUP.C and execute
1633 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
1634 printf("*******************************\n");
1635 printf("*** Setup PAR archive ***\n");
1636 printf("*******************************\n");
1637 gROOT->Macro("PROOF-INF/SETUP.C");
1638 }
4478beda 1639 if (!gSystem->ChangeDirectory(ocwd.Data())){
1640 Error("Change back directory",Form("Cannot change to %s",ocwd.Data()));
1641 return -1;
1642 }
c38e3b95 1643 return 0;
1644}
1645
1646//______________________________________________________________________________
1647AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
1648{
1649// Check if user has a valid token, otherwise make one. This has limitations.
1650// One can always follow the standard procedure of calling alien-token-init then
1651// source /tmp/gclient_env_$UID in the current shell.
c8fb37dd 1652// if (!AliAnalysisGrid::CreateToken()) return NULL;
c38e3b95 1653 AliAnalysisAlien *plugin = new AliAnalysisAlien();
1654// Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
1655 plugin->SetRunMode(plugin_mode);
1656 if (kPluginUseProductionMode) plugin->SetProductionMode();
1657 plugin->SetJobTag(kJobTag);
d8f21f85 1658 plugin->SetNtestFiles(1);
c38e3b95 1659// plugin->SetPreferedSE("ALICE::NIHAM::File");
1660// Set versions of used packages
e84da0a5 1661 plugin->SetAPIVersion("V1.1x");
1662 // plugin->SetAPIVersion("V1.0x");
1663// plugin->SetAPIVersion("V2.4");
c38e3b95 1664 plugin->SetROOTVersion(kPluginRootVersion);
1665 plugin->SetAliROOTVersion(kPluginAliRootVersion);
1666// Declare input data to be processed.
1667// Method 1: Create automatically XML collections using alien 'find' command.
1668// Define production directory LFN
1669 plugin->SetGridDataDir(kGridDatadir.Data());
1670// Set data search pattern
d8f21f85 1671 if (iAODanalysis) plugin->SetDataPattern(" *AliAOD.Jets.root");
c8fb37dd 1672 // else plugin->SetDataPattern(Form(" %s/*/*ESD.tag.root",kGridPassPattern.Data()));
1673 else plugin->SetDataPattern(Form(" %s/*/*AliESDs.root",kGridPassPattern.Data()));
c38e3b95 1674// ...then add run numbers to be considered
1675// plugin->SetRunRange(kGridRunRange[0], kGridRunRange[1]);
1676 for (Int_t i=kGridRunRange[0]; i<=kGridRunRange[1]; i++) {
1677 Printf("AnalysisTrainPWG4Jets Adding run number %s", Form(kGridRunPattern.Data(),i));
1678 plugin->AddRunNumber(Form(kGridRunPattern.Data(),i));
1679 }
1680
1681 if(kGridLocalRunList.Length()>0){
1682 ifstream in1;
1683 in1.open(kGridLocalRunList.Data());
1684 int iRun;
4d16db9c 1685 int icount = 0;
9a5c5b1e 1686 /*
e84da0a5 1687 char c;
1688 char cLine[250];
1689 while(!in1.eof()){
1690 c = in1.get();
1691 if ( (c >= '0') && (c <= '9') )
1692 {
d8f21f85 1693 in1.putback (c)s;
e84da0a5 1694 in1>>iRun;
1695 Printf("AnalysisTrainPWG4Jets Adding run number from File %s", Form(kGridRunPattern.Data(),iRun));
1696 plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun));
1697 }
1698 else
1699 {
1700 in1.putback (c);
1701 in1.getline(cLine,250);
9a5c5b1e 1702
1703 }
1704 }
1705 */
9748e967 1706
1707 Int_t nRun = 0;
9a5c5b1e 1708
1709 // just use run numbers, negatives will be excluded
1710 while(in1>>iRun){
ffab794c 1711 if(iRun>=0){
1712 if(iRun>=0&&nRun>=kGridOffsetRunFromList&&(nRun<kGridMaxRunsFromList)){
9a5c5b1e 1713 Printf("AnalysisTrainPWG4Jets Adding run number from File %s", Form(kGridRunPattern.Data(),iRun));
1714 plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun));
ffab794c 1715
1716 }
1717 else{
1718 Printf("AnalysisTrainPWG4Jets Skipping run number from File %d", iRun);
1719 }
36c36a0c 1720 nRun++;
9a5c5b1e 1721 }
1722 else{
1723 Printf("AnalysisTrainPWG4Jets Skipping run number from File %d", iRun);
e84da0a5 1724 }
c38e3b95 1725 }
1726 }
1727
1728// Method 2: Declare existing data files (raw collections, xml collections, root file)
1729// If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
1730// XML collections added via this method can be combined with the first method if
1731// the content is compatible (using or not tags)
1732// plugin->AddDataFile("tag.xml");
1733// plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
1734// Define alien work directory where all files will be copied. Relative to alien $HOME.
3878a941 1735 TString alien_workdir = "";
1736
1737 if (iAODanalysis) alien_workdir += "analysisAOD";
1738 else alien_workdir += "analysisESD";
1739 if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data());
1740 plugin->SetGridWorkingDir(alien_workdir.Data());
1741
c38e3b95 1742 // Declare alien output directory. Relative to working directory.
1743 if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
1744 plugin->SetGridOutputDir(kGridOutdir);
1745
1746 // Add external packages
1747 if (iJETAN||iDIJETAN) {
23adcac8 1748 plugin->AddExternalPackage("boost::v1_43_0");
1749 plugin->AddExternalPackage("cgal::v3.6");
1750 plugin->AddExternalPackage("fastjet::v2.4.2");
c38e3b95 1751 }
1752
1753
1754 // set extra libs before par file compilation
1755 anaLibs += kGridExtraFiles;
1756 anaLibs = anaLibs.Strip();
e84da0a5 1757 Printf("anaLibs %s",anaLibs.Data());
1758 Printf("anaLibsExtra %s",anaLibsExtra.Data());
1759
1760 if (anaLibs.Length()) plugin->SetAdditionalLibs(anaLibs.Data());
1761 if (anaLibsExtra.Length()) plugin->SetAdditionalRootLibs(anaLibsExtra.Data());
c38e3b95 1762
1763 TString ana_sources = "";
1764 TString ana_add = "";
1765 if (kUsePAR && anaPars.Length()) {
1766 printf("%s\n", anaPars.Data());
1767 TObjArray *arr;
1768 TObjString *objstr;
1769 arr = anaPars.Tokenize(" ");
1770 TIter next(arr);
1771 while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString());
1772 delete arr;
1773 }
1774
1775// Declare the analysis source files names separated by blancs. To be compiled runtime
1776// using ACLiC on the worker nodes.
1777 ana_sources = anaSources.Strip();
1778// Declare all libraries (other than the default ones for the framework. These will be
1779// loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
1780
1781 if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources);
1782 plugin->SetExecutableCommand(kPluginExecutableCommand.Data());
4721d8c5 1783 // Declare the output file names separated by blancs.
1784 // (can be like: file.root or file.root@ALICE::Niham::File)
c38e3b95 1785 plugin->SetMergeExcludes(kGridMergeExclude);
1786 plugin->SetMaxMergeFiles(kGridMaxMergeFiles);
1787 plugin->SetNrunsPerMaster(kGridRunsPerMaster);
9a5c5b1e 1788 plugin->SetMergeViaJDL(kPluginMergeViaJDL);
4721d8c5 1789 // Use fastread option
9a5c5b1e 1790 plugin->SetFastReadOption(kPluginFastReadOption);
4721d8c5 1791 // UseOverwrite mode
9a5c5b1e 1792 plugin->SetOverwriteMode(kPluginOverwriteMode);
4721d8c5 1793 // Optionally define the files to be archived.
1794 // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File");
dc6a7461 1795 plugin->SetOutputToRunNo(kPluginOutputToRunNumber); // write the output to subdirs named after run number
c38e3b95 1796
1797 // Put default output files to archive
1798 TString listhists = "";
1799 TString listaods = "";
1800 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1801 TIter next(mgr->GetOutputs());
1802 AliAnalysisDataContainer *output;
1803 while ((output=(AliAnalysisDataContainer*)next())) {
1804 const char *filename = output->GetFileName();
1805 if (!(strcmp(filename, "default"))) {
53c63663 1806 if (!mgr->GetOutputEventHandler()) continue;
c38e3b95 1807 filename = mgr->GetOutputEventHandler()->GetOutputFileName();
e84da0a5 1808 if (listaods.Length()) listaods += " ";
c38e3b95 1809 listaods += filename;
c38e3b95 1810 } else {
e84da0a5 1811 if(!listhists.Contains(filename)){
1812 if (listhists.Length()) listhists += " ";
c38e3b95 1813 listhists += filename;
1814 }
1815 }
1816 }
53c63663 1817
53c63663 1818 if (mgr->GetExtraFiles().Length()) {
e84da0a5 1819 if (listaods.Length()) listaods += " ";
53c63663 1820 listaods += mgr->GetExtraFiles();
c38e3b95 1821 }
53c63663 1822
1823 // if we do not fill the aod we do not need to store it
4721d8c5 1824 // kGridMergeExclude = listaods;
e84da0a5 1825
e2afec0c 1826 if(kSaveAOD>=0){
4721d8c5 1827 TString outputFiles = "";
1828 outputFiles += mgr->GetExtraFiles();
1829 if (listhists.Length()) outputFiles += " ";
1830 outputFiles += listhists;
e84da0a5 1831 plugin->SetDefaultOutputs(kFALSE);
4721d8c5 1832 Printf("%s:%d Starting with the files %s",(char*)__FILE__,__LINE__,outputFiles.Data());
1833 // remove
1834 // no harm done when we try to remove something that is not there :)
1835 if(!(kSaveAOD&(1<<0))){
1836 outputFiles.ReplaceAll("AliAOD.root ","");
1837 listaods.ReplaceAll("AliAOD.root ","");
1838 }
1839 if(!(kSaveAOD&(1<<1))){
1840 if(kDeltaAODJetName.Length())outputFiles.ReplaceAll(kDeltaAODJetName.Data(),"");
1841 if(kDeltaAODJetName.Length())listaods.ReplaceAll(kDeltaAODJetName.Data(),"");
1842
1843 }
1844 if(!(kSaveAOD&(1<<2))){
1845 if(kDeltaAODPartCorrName.Length())outputFiles.ReplaceAll(kDeltaAODPartCorrName.Data(),"");
1846 if(kDeltaAODPartCorrName.Length())listaods.ReplaceAll(kDeltaAODPartCorrName.Data(),"");
1847 }
1848 if(!(kSaveAOD&(1<<3))){
1849 if(kDeltaAODJCORRANName.Length())outputFiles.ReplaceAll(kDeltaAODJCORRANName.Data(),"");
1850 if(kDeltaAODJCORRANName.Length())listaods.ReplaceAll(kDeltaAODJCORRANName.Data(),"");
1851 }
1852
1853 //
e2afec0c 1854 plugin->SetDefaultOutputs(kFALSE);
4721d8c5 1855 Printf("%s:%d Saving the files %s",(char*)__FILE__,__LINE__,outputFiles.Data());
1856 plugin->SetOutputFiles(outputFiles.Data());
e84da0a5 1857 }
53c63663 1858
4721d8c5 1859 TString outputArchive;
4d5d766e 1860 outputArchive = Form("log_archive.zip:std*@%s","disk=1");
e84da0a5 1861 listaods.ReplaceAll(" ", ",");
1862 listhists.ReplaceAll(" ", ",");
4d5d766e 1863 if (listhists.Length()){
1864 outputArchive += " ";
1865 outputArchive += "root_archive.zip:";
1866 outputArchive += listhists;
1867 if (listaods.Length()){
1868 outputArchive += ",";
1869 outputArchive += listaods;
1870 }
1871 outputArchive += Form("@%s", kGridOutputStorages.Data());
1872 }
1873 else{
1874
1875 if (listaods.Length()){
1876 // we have only aod'ish output
1877 outputArchive += " ";
1878 outputArchive += "root_archive.zip:";
1879 outputArchive += listaods;
1880 outputArchive += Form("@%s", kGridOutputStorages.Data());
1881 }
1882 else{
1883 // no other outputs than std..
c38e3b95 1884 ::Fatal("AnalysisTrainPWG4Jets", "No task output !");
4d5d766e 1885 }
c38e3b95 1886 }
4d5d766e 1887
17d96675 1888 plugin->SetDefaultOutputs(kFALSE);
c38e3b95 1889 plugin->SetOutputArchive(outputArchive);
17d96675 1890
4721d8c5 1891
4d5d766e 1892 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
c38e3b95 1893 plugin->SetAnalysisMacro(Form("%s.C", kTrainName.Data()));
4d5d766e 1894 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
c38e3b95 1895 plugin->SetSplitMaxInputFileNumber(kGridFilesPerJob);
4d5d766e 1896 // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
27cdf9c4 1897 // plugin->SetMaxInitFailed(5);
4d5d766e 1898 // Optionally resubmit threshold.
c8fb37dd 1899 // plugin->SetMasterResubmitThreshold(90);
4d5d766e 1900 // Optionally set time to live (default 30000 sec)
d4e8abc5 1901 plugin->SetTTL(54000); // 15h...
4d5d766e 1902 // Optionally set input format (default xml-single)
c38e3b95 1903 plugin->SetInputFormat("xml-single");
4d5d766e 1904 // Optionally modify the name of the generated JDL (default analysis.jdl)
c38e3b95 1905 plugin->SetJDLName(Form("%s.jdl", kTrainName.Data()));
4d5d766e 1906 // Optionally modify the executable name (default analysis.sh)
c38e3b95 1907 plugin->SetExecutable(Form("%s.sh", kTrainName.Data()));
4d5d766e 1908 // Optionally modify job price (default 1)
c38e3b95 1909 plugin->SetPrice(1);
4d5d766e 1910 // Optionally modify split mode (default 'se')
c38e3b95 1911 plugin->SetSplitMode("se");
1912 return plugin;
1913}
1914
1915//______________________________________________________________________________
1916void WriteConfig()
1917{
1918// Write train configuration in a file. The file name has the format:
1919// train_[trainName]_ddMonthyyyy_time.C
1920 if (kUseDate) {
1921 gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp");
1922 ifstream fdate("date.tmp");
1923 if (!fdate.is_open()) {
1924 ::Error("AnalysisTrainPWG4Jets.C::Export","Could not generate file name");
1925 return;
1926 }
1927 const char date[64];
1928 fdate.getline(date,64);
1929 fdate.close();
1930 gSystem->Exec("rm date.tmp");
1931 kTrainName = Form("train_%s_%s", kTrainName.Data(), date);
1932 } else {
1933 kTrainName = Form("train_%s", kTrainName.Data());
1934 }
1935 TString cdir = gSystem->WorkingDirectory();
1936 gSystem->MakeDirectory(kTrainName);
1937 gSystem->ChangeDirectory(kTrainName);
1938 ofstream out;
1939 out.open(Form("%sConfig.C",kTrainName.Data()), ios::out);
1940 if (out.bad()) {
1941 ::Error("AnalysisTrainPWG4Jets.C::Export", "Cannot open ConfigTrain.C for writing");
1942 return;
1943 }
1944 out << "{" << endl;
1945 out << " kTrainName = " << "\"" << kTrainName.Data() << "\";" << endl;
1946 out << " kProofCluster = " << "\"" << kProofCluster.Data() << "\";" << endl;
1947 out << " kProofUseAFPAR = " << kProofUseAFPAR << ";" << endl;
1948 if (kProofUseAFPAR)
1949 out << " kProofAFversion = " << kProofAFversion.Data() << ";" << endl;
1950 out << " kProofDataSet = " << "\"" << kProofDataSet.Data() << "\";" << endl;
1951 out << " kPluginUse = " << kPluginUse << ";" << endl;
1952 out << " kUsePAR = " << kUsePAR << ";" << endl;
1953 out << " kUseCPAR = " << kUseCPAR << ";" << endl;
1954 out << " kPluginRootVersion = " << "\"" << kPluginRootVersion.Data() << "\";" << endl;
1955 out << " kPluginAliRootVersion = " << "\"" << kPluginAliRootVersion.Data() << "\";" << endl;
1956 out << " kGridDatadir = " << "\"" << kGridDatadir.Data() << "\";" << endl;
1957 if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
1958 out << " kGridOutdir = " << "\"" << kGridOutdir.Data() << "\";" << endl;
1959 out << " kGridMaxMergeFiles = " << kGridMaxMergeFiles << ";" << endl;
1960 out << " kGridMergeExclude = " << "\"" << kGridMergeExclude.Data() << "\";" << endl;
1961 out << " kGridRunsPerMaster = " << kGridRunsPerMaster << ";" << endl;
1962 out << " kGridFilesPerJob = " << kGridFilesPerJob << ";" << endl;
1963 out << " kGridRunRange[0] = " << kGridRunRange[0] << ";" << endl;
1964 out << " kGridRunRange[1] = " << kGridRunRange[1] << ";" << endl;
1965 out << " kUseDebug = " << kUseDebug << ";" << endl;
1966 out << " kUseMC = " << kUseMC << ";" << endl;
1967 out << " kUseESDTags = " << kUseESDTags << ";" << endl;
1968 out << " kUseKinefilter = " << kUseKinefilter << ";" << endl;
1969 out << " kUseTR = " << kUseTR << ";" << endl;
1970 out << " kUseAODTags = " << kUseAODTags << ";" << endl;
1971 out << " kSaveTrain = " << "kFALSE;" << endl << endl;
1972 out << " // Analysis modules" << endl;
1973 out << " iAODanalysis = " << iAODanalysis << ";" << endl;
1974 out << " iAODhandler = " << iAODhandler << ";" << endl;
1975 out << " iESDfilter = " << iESDfilter << ";" << endl;
1976 out << " iJETAN = " << iJETAN << ";" << endl;
1977 out << "// Configuration fot the wagons" << endl;
1978 out << "}" << endl;
1979 ::Info("AnalysisTrainPWG4Jets.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", kTrainName.Data()));
1980 gSystem->ChangeDirectory(cdir);
1981}
1982
1983//______________________________________________________________________________
1984Bool_t LoadConfig(const char *filename)
1985{
1986// Read train configuration from file
1987 if (gSystem->AccessPathName(filename)) {
1988 ::Error("AnalysisTrainPWG4Jets.C::LoadConfig", "Config file name not found");
1989 return kFALSE;
1990 }
1991 gROOT->ProcessLine(Form(".x %s", filename));
1992 ::Info("AnalysisTrainPWG4Jets.C::LoadConfig", "Train configuration loaded from file %s", filename);
1993 return kTRUE;
1994}
1995
1996Bool_t PatchJDL(){
1997 Printf(">>> Patching JDL");
1998 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1999 AliAnalysisAlien* gridHandler = (AliAnalysisAlien*)mgr->GetGridHandler();
2000 TGridJDL *jdl = gridHandler->GetGridJDL();
2001 if(iJETAN)jdl->AddToPackages("fastjet","v2.4.0");
2002 gridHandler->WriteJDL(kFALSE);
0971dabc 2003 Printf("<<< Patching JDL");
c38e3b95 2004 return kTRUE;
2005}
2006
2007Bool_t PatchAnalysisMacro(){
4721d8c5 2008 Printf(">>> Patching AnalysisMacro");
2009 gSystem->Exec(Form("mv %s.C %s.C_tmp",kTrainName.Data(),kTrainName.Data()));
c38e3b95 2010
2011 ifstream in1;
2012 in1.open(Form("%s.C_tmp", kTrainName.Data()));
2013 char cLine[250];
2014 TString st;
2015 while(in1.getline(cLine,250)){
2016 st += cLine;
2017 st += "\n";
2018 }
4721d8c5 2019 Int_t index= -1;
c38e3b95 2020 index = st.Index("gSystem->Load(\"libPhysics\");");
2021 index += strlen("gSystem->Load(\"libPhysics\");");
4721d8c5 2022 /*
c38e3b95 2023 TObjArray *arr;
2024 TObjString *objstr;
2025 arr = anaLibs.Tokenize(" ");
2026 TIter next(arr);
4721d8c5 2027
c38e3b95 2028 add += "\n\n // added by CKB \n";
2029 while ((objstr=(TObjString*)next())){
e84da0a5 2030 if(objstr->GetString().Contains("PWG3"))continue;
c38e3b95 2031 if(objstr->GetString().EndsWith(".so"))add += Form("gSystem->Load(\"%s\");\n",objstr->GetString().Data());
2032 }
2033 delete arr;
4721d8c5 2034 */
3878a941 2035 // add += Form("AliLog::SetGlobalLogLevel(%d);\n",AliLog::GetGlobalLogLevel());
4721d8c5 2036 TString add = "";
2037
2038 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2039 add += "\n\n // added by CKB \n";
46534866 2040 if(kErrorIgnoreLevel>0)add += Form("gErrorIgnoreLevel = %d;\n",kErrorIgnoreLevel);
23adcac8 2041 add += "\n gSystem->AddIncludePath(\"./\"); \n";
f4132e7d 2042 add += "\n gSystem->SetFPEMask(); \n";
2043
2044
4721d8c5 2045 if(gGrid&&kPluginAliRootVersion.Length()==0){
2046 add += "\n // Dirty hack for TRD reference data \n";
2047 add += "\n gSystem->Setenv(\"ALICE_ROOT\",\"";
2048 add += Form("alien://%s/rootfiles/",gGrid->GetHomeDirectory());
2049 add += "\"); \n";
c38e3b95 2050 }
4721d8c5 2051 add += "// BKC \n\n";
2052 st.Insert(index,add.Data());
e84da0a5 2053
2054 if(kUseDebug){
23adcac8 2055 // st.Insert(index,"\n gROOT->ProcessLine(\".trace\"); // CKB \n");
e84da0a5 2056 }
2057
4721d8c5 2058 if(kUseCPAR&&kPluginAliRootVersion.Length()==0){
2059 index = st.Index("gSystem->AddIncludePath(\"-I$"); // uncommen $ALICE_ROOT include for par files
2060 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2061 st.Insert(index,"// CKB comment out whehn no aliroot is provided \n //");
2062 }
c166d299 2063
46534866 2064 if(AliLog::GetGlobalLogLevel()==AliLog::kFatal){
2065 index = st.Index("AliLog::SetGlobal"); // ncomment setting of log level, do my own
2066 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2067 st.Insert(index,"AliLog::SetGlobalLogLevel(AliLog::kFatal);// CKB \n // CKB comment out for own setting \n //");
2068 }
2069
c38e3b95 2070 ofstream out;
2071 out.open(Form("%s.C", kTrainName.Data()));
2072 if (out.bad()) {
2073 return kFALSE;
2074 }
2075 out << st << endl;
2076 Printf("<<< Patching AnalysisMacro");
4721d8c5 2077
2078
2079
2080
2081
2082 Printf(">>> Patching Merge Macro");
2083 gSystem->Exec(Form("mv %s_merge.C %s_merge.C_tmp",kTrainName.Data(),kTrainName.Data()));
2084
2085 ifstream in2;
2086 in2.open(Form("%s_merge.C_tmp", kTrainName.Data()));
2087 TString st2;
2088 while(in2.getline(cLine,250)){
2089 st2 += cLine;
2090 st2 += "\n";
2091 }
2092 index = st2.Index("gSystem->Load(\"libPhysics\");");
2093 index += strlen("gSystem->Load(\"libPhysics\");");
2094 TString add2 = "";
23adcac8 2095 add2 += "\n gSystem->AddIncludePath(\"./\"); \n";
4721d8c5 2096 if(gGrid&&kPluginAliRootVersion.Length()==0){
2097 add2 += "\n // Dirty hack for TRD reference data \n";
2098 add2 += "\n gSystem->Setenv(\"ALICE_ROOT\",\"";
2099 add2 += Form("alien://%s/rootfiles/",gGrid->GetHomeDirectory());
2100 add2 += "\"); \n";
2101 }
2102 add2 += "// BKC \n\n";
2103 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2104 st2.Insert(index,add.Data());
2105
2106
2107 if(kUseDebug){
23adcac8 2108 // st2.Insert(index,"\n gROOT->ProcessLine(\".trace\"); // CKB \n");
4721d8c5 2109 }
2110
2111 if(kUseCPAR&&kPluginAliRootVersion.Length()==0){
46534866 2112 index = st2.Index("gSystem->AddIncludePath(\"-I$"); // uncomment $ALICE_ROOT include for par files
4721d8c5 2113 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2114 st2.Insert(index,"// CKB comment out whehn no aliroot is provided \n //");
2115 }
2116
2117 // do not exclude the extra files from merign, this is done explicitly in this train script
92d850d5 2118 // index = st2.Index("mergeExcludes +="); // uncommen $ALICE_ROOT include for par files
2119 // if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2120 // st2.Insert(index,"// CKB comment out, handled explicitly by the train macro \n //");
4721d8c5 2121
2122
2123 ofstream out2;
2124 out2.open(Form("%s_merge.C", kTrainName.Data()));
2125 if (out2.bad()) {
2126 return kFALSE;
2127 }
2128 out2 << st2 << endl;
2129 Printf("<<< Patching Merging Macro");
2130
2131
2132
c38e3b95 2133 return kTRUE;
2134
2135}