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