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