some debug information
[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
b101fa2e 110Int_t iPWG4Fragmentation = 1; // 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{
b101fa2e 862 // Anti-kT
863 taskFrag = AddTaskFragmentationFunction(1<<23,kHighPtFilterMask, 1);
864 taskFrag = AddTaskFragmentationFunction(1<<23,kHighPtFilterMask, 2);
865 taskFrag = AddTaskFragmentationFunction(1<<23,kHighPtFilterMask, 3);
866 taskFrag = AddTaskFragmentationFunction(1<<23,kHighPtFilterMask, 4);
867
868 // UA1
869 taskFrag = AddTaskFragmentationFunction(1<<0,kHighPtFilterMask, 1);
870
871 // SISCONE
872 taskFrag = AddTaskFragmentationFunction(1<<28,kHighPtFilterMask, 1);
873 taskFrag = AddTaskFragmentationFunction(1<<29,kHighPtFilterMask, 1);
874 taskFrag = AddTaskFragmentationFunction(1<<30,kHighPtFilterMask, 1);
875
876 // Anti-kT B2 - B3
877 taskFrag = AddTaskFragmentationFunction(1<<26,kHighPtFilterMask, 1);
878 taskFrag = AddTaskFragmentationFunction(1<<27,kHighPtFilterMask, 1);
879
7b90d977 880 }
881 if (!taskFrag) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskFragmentationFunction cannot run for this train conditions - EXCLUDED");
d8f21f85 882 }
883
884 if(iPWG4JetChem){
34fc6450 885 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetChem.C");
d8f21f85 886 AliAnalysisTask *taskChem = AddTaskJetChem(kHighPtFilterMask);
887 if (!taskChem) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetChem cannot run for this train conditions - EXCLUDED");
c38e3b95 888 }
6bd3fdae 889
bbb42949 890 if (iPWG4JetResponse) {
34fc6450 891 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetResponse.C");
1a2bb6d5 892 AliAnalysisTask *taskJetResponse = 0;
893
894 if(iJETAN){
895 taskJetResponse = AddTaskJetResponse("jets", "FASTJET", 0.4, kHighPtFilterMask, 0.15, 0);
896 taskJetResponse = AddTaskJetResponse("jets", "FASTJET", 0.4, kHighPtFilterMask, 0.15, 1);
897
898 taskJetResponse = AddTaskJetResponse("jets", "UA1", 0.4, kHighPtFilterMask, 1., 0);
899 taskJetResponse = AddTaskJetResponse("jets", "UA1", 0.4, kHighPtFilterMask, 1., 2);
900 }
901 if(iPWG4Cluster){
902 taskJetResponse = AddTaskJetResponse("clusters", "ANTIKT", 0.4, kHighPtFilterMask, 0.15, 0);
903 taskJetResponse = AddTaskJetResponse("clusters", "ANTIKT", 0.4, kHighPtFilterMask, 0.15, 1);
904 }
905 if (!taskJetResponse) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskJetResponse cannot run for this train conditions - EXCLUDED");
906
bbb42949 907 }
6bd3fdae 908
58ef946c 909 if(iPWG4JCORRAN){
34fc6450 910 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJCORRANTask.C");
4721d8c5 911 AliJCORRANTask* corran = AddTaskJCORRAN(kDeltaAODJCORRANName.Data(),0);
58ef946c 912 if(!corran)::Warning("AnalysisTrainPWG4Jets", "AliJCORRANTask cannot run for this train conditions - EXCLUDED");
4721d8c5 913 else{
914 if(kDeltaAODJCORRANName.Length()>0)mgr->RegisterExtraFile(kDeltaAODJCORRANName.Data());
915 }
58ef946c 916 }
917
c38e3b95 918 if(iPWG4UE){
34fc6450 919 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskUE.C");
c38e3b95 920 AliAnalysisTaskUE *taskUE = 0;
921 if(iPWG4UE&1)taskUE = AddTaskUE();
922 if(iPWG4UE&2){
94ee88d4 923 taskUE =AddTaskUE("jetsAOD_CDF04","CDF", "LJ", "TRANSV","MSP"); //finder not yet in train
17d96675 924 // taskUE =AddTaskUE("jetsAOD_CDF07","CDF", "LJ", "TRANSV","MSP");
94ee88d4 925 taskUE =AddTaskUE("jetsAOD_SISCONE04","CDF", "LJ", "TRANSV","MSP");
17d96675 926 // taskUE =AddTaskUE("jetsAOD_SISCONE07","CDF", "LJ", "TRANSV","MSP"); //finder not yet in train
94ee88d4 927 taskUE =AddTaskUE("jetsAOD_ICDF","CDF","LJ","TRANSV","MSP");
928 taskUE =AddTaskUE("jetsAOD_FASTKT04","CDF", "LJ", "TRANSV","MSP");
17d96675 929 // taskUE =AddTaskUE("jetsAOD_FASTKT07","CDF", "LJ", "TRANSV","MSP"); //finder not yet in train
58ef946c 930 taskUE =AddTaskUE("jetsAOD_NONE","CDF", "MP_eta05", "TRANSV","MSP");
931 taskUE =AddTaskUE("jetsAOD_NONE","CDF", "MP_eta09", "TRANSV","MSP");
c38e3b95 932 }
2bb1f4ca 933
c38e3b95 934 if (!taskUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskUE cannot run for this train conditions - EXCLUDED");
935 }
e0c120d9 936
937 if(iPWG4LeadingUE){
34fc6450 938 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskLeadingTrackUE.C");
e0c120d9 939 AliAnalysisTaskLeadingTrackUE *taskLeadingUE = AddTaskLeadingTrackUE(kUseMC);
940 if (!taskLeadingUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTasLeadingTrackkUE cannot run for this train conditions - EXCLUDED");
27cdf9c4 941 // taskLeadingUE->SetFilterBit(64);
e0c120d9 942 }
943
944
9748e967 945 if(iPWG4CorrectionsUE){
34fc6450 946 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskCorrectionsUE.C");
9748e967 947 AliAnalysisTaskCorrectionsUE *taskCorrectionsUE = 0;
948 if(iPWG4CorrectionsUE&1)taskCorrectionsUE = AddTaskCorrectionsUE("jetsAOD_NONE","CDF","MP_eta05","TRANSV","MSP",kFALSE);
949 if (!taskCorrectionsUE) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskCorrectionsUE cannot run for this train conditions - EXCLUDED");
950 }
c38e3b95 951
952 if(iPWG4ThreeJets){
34fc6450 953 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskThreeJets.C");
c38e3b95 954 AliAnalysisTaskThreeJets *taskThree = AddTaskThreeJets();
955 if(!taskThree)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskThreets cannot run for this train conditions - EXCLUDED");
956 }
cc636095 957 if(iPWG4QGSep){
34fc6450 958 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskQGSep.C");
cc636095 959 AliAnalysisTaskQGSep *taskQGSep = AddTaskQGSep(kUseMC,iAODanalysis);
960 if(!taskQGSep)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQGSep cannot run for this train conditions - EXCLUDED");
961 }
962
963
964 if(iPWG4Minijet){
34fc6450 965 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskMinijet.C");
4d16db9c 966 AliAnalysisTaskMinijet *taskMini = AddTaskMinijet(-1,"esd",kUseMC,kGridDataSet);
cc636095 967 // if we ha highmult trigger add another task
968 if(!taskMini)::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskMinjet cannot run for this train conditions - EXCLUDED");
969 }
970
971
c38e3b95 972 if(iPWG4PtQAMC){
34fc6450 973 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQAMC.C");
f87effcf 974 AliPWG4HighPtQAMC *taskQAMC = 0;
975 if(kUseMC){
36c36a0c 976 if(iPWG4PtQAMC&1){
977 taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data(),0);
978 taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data(),1);
979 taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data(),2);
34fc6450 980 taskQAMC = AddTaskPWG4HighPtQAMC(kGridDataSet.Data(),3);
36c36a0c 981 }
f87effcf 982 }
c38e3b95 983 if (!taskQAMC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQAMC cannot run for this train conditions - EXCLUDED");
984 }
985
7b90d977 986 if(iPWG4PtTrackQA){
987 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtTrackQA.C");
988
989 AddTaskPWG4HighPtTrackQAAll(kGridDataSet.Data(),kIsPbPb,iAODanalysis);
990
991 }
992
c38e3b95 993 if(iPWG4PtQATPC){
34fc6450 994 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtQATPConly.C");
10295ac3 995 AliPWG4HighPtQATPConly *taskQATPC = 0;
b1cd0099 996 if(iPWG4PtQATPC&1)taskQATPC = AddTaskPWG4HighPtQATPConly(kGridDataSet.Data(),1);
997 if(iPWG4PtQATPC&2)taskQATPC = AddTaskPWG4HighPtQATPConly(kGridDataSet.Data(),2);
10295ac3 998
999 if (!taskQATPC) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskQATPC cannot run for this train conditions - EXCLUDED");
c38e3b95 1000 }
3878a941 1001
1f329128 1002 if(iPWG4Cosmics){
34fc6450 1003 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4CosmicCandidates.C");
1f329128 1004
1005 AliPWG4CosmicCandidates *taskPWG4CosmicCandidates = AddTaskPWG4CosmicCandidates(0);
1006 taskPWG4CosmicCandidates = AddTaskPWG4CosmicCandidates(1);
1007
1008 if (!taskPWG4CosmicCandidates) ::Warning("AnalysisTrainPWG4Jets", "AddTaskPWG4CosmicCandidates cannot run for this train conditions - EXCLUDED");
1009 }
1010
1011
c38e3b95 1012 if(iPWG4PtSpectra){
34fc6450 1013 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPWG4HighPtSpectra.C");
7b90d977 1014 AddTaskPWG4HighPtSpectraAll(kGridDataSet.Data(),kIsPbPb);
c38e3b95 1015 }
34fc6450 1016
b53f2e4f 1017 if(iPWG4KMeans){
34fc6450 1018 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskKMeans.C");
b53f2e4f 1019 AliAnalysisTaskKMeans *taskKMeans = AddTaskKMeans();
1020 if (!taskKMeans) ::Warning("AnalysisTrainPWG4Jets", "AliAnalysisTaskKMenans cannot run for this train conditions - EXCLUDED");
1021 }
1022
c38e3b95 1023 if(iPWG4PartCorr){
34fc6450 1024 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskPartCorr.C");
14526afb 1025 AliAnalysisTaskParticleCorrelation *taskpartcorrPHOS = AddTaskPartCorr("AOD", "PHOS",kFALSE,kIsMC);
c38e3b95 1026 if (!taskpartcorrPHOS) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation PHOS cannot run for this train conditions - EXCLUDED");
14526afb 1027 AliAnalysisTaskParticleCorrelation *taskpartcorrEMCAL = AddTaskPartCorr("AOD", "EMCAL",kFALSE,kIsMC);
c38e3b95 1028 if (!taskpartcorrEMCAL) ::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation EMCAL cannot run for this train conditions - EXCLUDED");
4721d8c5 1029 if(kDeltaAODPartCorrName.Length()>0)mgr->RegisterExtraFile(kDeltaAODPartCorrName.Data());
121e4bd5 1030 }
1031
d2e6cdd5 1032 if(iPWG4CaloQA){
34fc6450 1033 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/QA/AddTaskCalorimeterQA.C");
9748e967 1034 AliAnalysisTaskParticleCorrelation *taskcaloQA = AddTaskCalorimeterQA("ESD",kFALSE,kIsMC,kCaloQAOutputFileName.Data());
d2e6cdd5 1035 if(!taskcaloQA)::Warning("AnalysisTrainNew", "AliAnalysisTaskParticleCorrelation QA cannot run - EXCLUDED");
aba42fcb 1036 // if(kCaloQAOutputFileName.Length()>0)mgr->RegisterExtraFile(kCaloQAOutputFileName.Data());
d2e6cdd5 1037 }
1038
d2e6cdd5 1039 if(iPWG4JetCorr){
1040 // using namespace JetCorrelHD;
d3af0232 1041 TString cdir = gSystem->WorkingDirectory();
34fc6450 1042 gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/"));
1043 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskJetCorrel.C");
d2e6cdd5 1044 AliAnalysisTaskJetCorrel *taskjetcorr = AddTaskJetCorrel();
d3af0232 1045 gSystem->ChangeDirectory(cdir);
c166d299 1046 if (!taskjetcorr) ::Warning("AnalysisTrainNew", "AliAnalysisTaskJetCorrel cannot run for this train conditions - EXCLUDED");
d2e6cdd5 1047 }
1048
911a740f 1049 if(iPWG4Tagged){
34fc6450 1050 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskTaggedPhotons.C");
911a740f 1051 AliAnalysisTaskTaggedPhotons * taskTagged = AddTaskTaggedPhotons(kFALSE); // EMCAL
58ef946c 1052 taskTagged = AddTaskTaggedPhotons(kTRUE); // PHOS
911a740f 1053 if (!taskTagged) ::Warning("AnalysisTrainNew", "AliAnalysisTaskTaggedPhotons cannot run for this train conditions - EXCLUDED");
1054 }
121e4bd5 1055 if (iPWG4omega3pi) {
34fc6450 1056 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskomega3pi.C");
121e4bd5 1057 AliAnalysisTaskOmegaPi0PiPi *taskomega3pi = AddTaskomega3pi();
1058 if (!taskomega3pi) ::Warning("AnalysisTrainNew", "AliAnalysisTaskomega3pi cannot run\
1059 for these train conditions - EXCLUDED");
1060 }
1061
53c63663 1062 // PWG4 gamma conversion analysis
1063 if (iPWG4GammaConv) {
34fc6450 1064 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskGammaConversion.C");
53c63663 1065 TString cdir = gSystem->WorkingDirectory();
34fc6450 1066 gSystem->ChangeDirectory(gSystem->ExpandPathName("$ALICE_ROOT/PWG4/macros/"));
53c63663 1067 // TString gcArguments = "-run-on-train -run-jet -run-chic -run-neutralmeson -run-cf";
58ef946c 1068 // TString gcArguments = "-run-on-train -run-jet -run-neutralmeson -run-cf -use-own-xyz";
1069 // TString gcArguments = "-run-on-train -run-jet -run-neutralmeson -run-cf -use-own-xyz";
b0a36f28 1070 TString gcArguments = "-run-on-train -run-jet -run-omega-meson -use-own-xyz -run-neutralmeson -no-aod";
27cdf9c4 1071 // TString kGCAnalysisCutSelectionId="9003562000100310";
cfd02305 1072 // TString kGCAnalysisCutSelectionId="9003562000100312";
1073 // gcArguments.Append(Form(" -set-cut-selection %s ",kGCAnalysisCutSelectionId.Data()));
53c63663 1074 if(!kIsMC)gcArguments += " -mc-off";
1075 AliAnalysisTaskGammaConversion * taskGammaConversion = AddTaskGammaConversion(gcArguments,mgr->GetCommonInputContainer());
1076 gSystem->ChangeDirectory(cdir);
121e4bd5 1077 taskGammaConversion->SelectCollisionCandidates();
53c63663 1078 if (!taskGammaConversion) ::Warning("AnalysisTrainNew", "AliAnalysisTaskGammaConversion cannot run for these train conditions - EXCLUDED");
1079 }
1080
17d96675 1081 if (iPWG4CaloConv) {
34fc6450 1082 gROOT->LoadMacro("$ALICE_ROOT/PWG4/macros/AddTaskCaloConv.C");
17d96675 1083 AliAnalysisTaskCaloConv * taskCaloConv = AddTaskCaloConv();
1084 if (!taskCaloConv) ::Warning("AnalysisTrainNew", "AliAnalysisTaskCaloConv cannot run for these train conditions - EXCLUDED");
1085 }
1086
1087
3878a941 1088
c38e3b95 1089 //==========================================================================
1090 // FOR THE REST OF THE TASKS THE MACRO AddTaskXXX() is not yet implemented/
1091 // Run the analysis
1092 //
1093 if (kPluginUse) {
1094 AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
1095 AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
1096 }
1097
1098 if (mgr->InitAnalysis()) {
1099 mgr->PrintStatus();
1100 // if (kSaveTrain || strlen(config_file)) gSystem->ChangeDirectory(kTrainName);
e84da0a5 1101 if (!strcmp(plugin_mode,"submit")&&smode=="GRID"){
c38e3b95 1102 TString alien_workdir = gGrid->GetHomeDirectory();
1103 if (iAODanalysis) alien_workdir += "analysisAOD";
1104 else alien_workdir += "analysisESD";
3878a941 1105 if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data());
c38e3b95 1106 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
e84da0a5 1107 printf("=== AnalysisTrainPWG4Jets:: Registering jdl in the work directory alien://%s/%s, should be done by the manager! ===\n",
c38e3b95 1108 alien_workdir.Data(),gridhandler->GetGridOutputDir());
58ef946c 1109
1110 TString dest;
1111 dest = Form("%s/%s/%s.jdl",alien_workdir.Data(),gridhandler->GetGridOutputDir(),kTrainName.Data());
1112 if(AliAnalysisAlien::FileExists(dest.Data())){
bbb42949 1113 Printf("%s exist on grid removing...",dest.Data());
1114 gGrid->Rm(dest.Data());
58ef946c 1115 }
bbb42949 1116 Printf("%s copy ...",dest.Data());
58ef946c 1117 TFile::Cp(Form("file:%s.jdl",kTrainName.Data()),Form("alien://%s",dest.Data()));
4721d8c5 1118
1119
1120 TString dest;
1121 dest = Form("%s/%s/%s_merge.jdl",alien_workdir.Data(),gridhandler->GetGridOutputDir(),kTrainName.Data());
1122 if(AliAnalysisAlien::FileExists(dest.Data())){
bbb42949 1123 Printf("%s exist on grid removing...",dest.Data());
1124 gGrid->Rm(dest.Data());
4721d8c5 1125 }
bbb42949 1126 Printf("%s copy ...",dest.Data());
4721d8c5 1127 TFile::Cp(Form("file:%s_merge.jdl",kTrainName.Data()),Form("alien://%s",dest.Data()));
f84df50f 1128
bbb42949 1129 dest = Form("%s/%s/%s_merge_final.jdl",alien_workdir.Data(),gridhandler->GetGridOutputDir(),kTrainName.Data());
1130 if(AliAnalysisAlien::FileExists(dest.Data())){
1131 Printf("%s exist on grid removing...",dest.Data());
1132 gGrid->Rm(dest.Data());
1133 }
1134 Printf("%s copy ...",dest.Data());
1135 TFile::Cp(Form("file:%s_merge.jdl",kTrainName.Data()),Form("alien://%s",dest.Data()));
f84df50f 1136
bbb42949 1137
1138 /*
73b7619a 1139 dest = Form("%s/rootfiles/STEER/LQ1dRef_v1.root",gGrid->GetHomeDirectory());
58ef946c 1140 if(AliAnalysisAlien::FileExists(dest.Data())){
1141 Printf("%s exist on grid removing...",dest.Data());
1142 gGrid->Rm(dest.Data());
1143 }
1144 TFile::Cp(Form("file:%s/STEER/LQ1dRef_v1.root",
9748e967 1145 gSystem->ExpandPathName("$ALICE_ROOT")),Form("alien://%s",dest.Data()));
bbb42949 1146 */
c38e3b95 1147 }
3878a941 1148 AliLog::SetGlobalLogLevel(AliLog::kError);
c166d299 1149 if((kUseSysInfo>0&&smode=="LOCAL")||!strcmp(plugin_mode, "test")){
1150 TFile * fM = TFile::Open("manager_local.root","RECREATE");
1151 mgr->Write();
1152 fM->Close();
1153 }
46534866 1154
1155 // grmpf, aliroot error handler overwrites root
1156 gErrorIgnoreLevel = kErrorIgnoreLevel;
1157 if(gErrorIgnoreLevel>3000) AliLog::SetGlobalLogLevel(AliLog::kFatal);
c38e3b95 1158 StartAnalysis(smode, chain);
4a6f59cb 1159 if((kUseSysInfo>0&&smode=="LOCAL")||!strcmp(plugin_mode, "test")){
1160 for(int i = 0;i < mgr->GetTopTasks()->GetEntries();i++){
1161 mgr->ProfileTask(i);
1162 }
1163 }
c38e3b95 1164 if (!strcmp(plugin_mode, "offline")&&smode=="GRID"){
e84da0a5 1165 // Offline mode path files
1166 // PatchJDL();
d8f21f85 1167 // PatchAnalysisMacro();
e84da0a5 1168 }
c38e3b95 1169
e84da0a5 1170 if (kSaveTrain && smode=="GRID") {
1171 AliAnalysisAlien *gridhandler = (AliAnalysisAlien*)mgr->GetGridHandler();
1172 TString alien_workdir = gGrid->GetHomeDirectory();
1173 if (iAODanalysis) alien_workdir += "analysisAOD";
3878a941 1174 else alien_workdir += "analysisESD";
1175 if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data());
e84da0a5 1176 // kGridOutdir = gridhandler->GetGridOutputDir();
1177 printf("=== Registering ConfigTrain.C in the work directory <%s> ===\n",
c38e3b95 1178 alien_workdir.Data());
e84da0a5 1179 if (AliAnalysisAlien::FileExists(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data())))
1180 gGrid->Rm(Form("%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()));
1181 if (strcmp(plugin_mode, "test"))
1182 TFile::Cp(Form("file:%sConfig.C",kTrainName.Data()), Form("alien://%s/%sConfig.C", alien_workdir.Data(), kTrainName.Data()));
1183 }
1184 }
c38e3b95 1185}
1186
1187//______________________________________________________________________________
1188void StartAnalysis(const char *mode, TChain *chain) {
1189// Start analysis.
1190 Int_t imode = -1;
1191 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1192 if (!strcmp(mode, "LOCAL")) imode = 0;
1193 if (!strcmp(mode, "PROOF")) imode = 1;
1194 if (!strcmp(mode, "GRID")) imode = 2;
1195 switch (imode) {
1196 case 0:
1197 if (!chain) {
1198 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain");
1199 return;
1200 }
82ebd295 1201 mgr->StartAnalysis(mode, chain,kNumberOfEvents);
c38e3b95 1202 return;
1203 case 1:
1204 if (!kProofDataSet.Length()) {
1205 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "kProofDataSet is empty");
1206 return;
1207 }
1208 mgr->StartAnalysis(mode, kProofDataSet, kProofEvents,kProofOffset);
1209 return;
1210 case 2:
1211 if (kPluginUse) {
1212 if (!mgr->GetGridHandler()) {
1213 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Grid plugin not initialized");
1214 return;
1215 }
ebad39a9 1216 mgr->StartAnalysis("grid",chain,kNumberOfEvents);
c38e3b95 1217 } else {
1218 if (!chain) {
1219 ::Error("AnalysisTrainPWG4Jets.C::StartAnalysis", "Cannot create the chain");
1220 return;
1221 }
1222 mgr->StartAnalysis(mode, chain);
ebad39a9 1223 mgr->StartAnalysis(mode, chain,kNumberOfEvents);
c38e3b95 1224 }
1225 return;
1226 }
1227}
1228
1229//______________________________________________________________________________
1230void CheckModuleFlags(const char *mode) {
1231// Checks selected modules and insure compatibility
1232 Int_t imode = -1;
1233 if (!strcmp(mode, "LOCAL")) imode = 0;
1234 if (!strcmp(mode, "PROOF")) imode = 1;
1235 if (!strcmp(mode, "GRID")) imode = 2;
1236
1237
e84da0a5 1238 if (kUseCPAR) {
1239 kPluginAliRootVersion = ""; // NO aliroot if we use CPAR
1240 }
c38e3b95 1241
1242 if (imode==1) {
1243 if (!kUsePAR) {
1244 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PAR files enabled due to PROOF analysis");
1245 kUsePAR = kTRUE;
1246 }
1247 }
1248 if (imode != 2) {
1249 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AliEn plugin disabled since not in GRID mode");
1250 kPluginUse = kFALSE;
1251 }
1252
1253
1254 if(!kIsMC){
1255 // switch off anthin related to MC
1256 kUseMC = 0;
1257 kUseAODMC = 0;
1258 kUseTR = kFALSE;
1259 }
1260
f4132e7d 1261 // Decide if we have PbPb
1c79997e 1262 if(kGridDataSet.CompareTo("LHC10h")==0||kGridDataSet.Contains("LHC10h")) {
1263 Printf("Using settings for Pb+Pb");
f4132e7d 1264 kIsPbPb = true;
1265 }
1266
1267
1268
c38e3b95 1269 if (iAODanalysis) {
1270 // AOD analysis
1271 if (kUseMC)
1272 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "MC usage disabled in analysis on AOD's");
1273 if (kUseAODTags)
1274 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "AOD tags usage disabled in analysis on AOD's");
1275 kUseMC = kFALSE;
1276 kUseTR = kFALSE;
1277 kUseAODTags = kFALSE;
1278 if (iESDfilter)
1279 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "ESD filter disabled in analysis on AOD's");
1280 iESDfilter = 0;
e84da0a5 1281 if (iPhysicsSelection)
1282 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "Physics Selection disabled in analysis on AOD's");
1283 iPhysicsSelection = 0;
c38e3b95 1284 if (!iAODhandler) {
1285 if (iJETAN)
1286 ::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "JETAN disabled in analysis on AOD's without AOD handler");
1287 iJETAN = 0;
1288 iDIJETAN = 0;
1289 }
1290 // Disable tasks that do not work yet on AOD data
58ef946c 1291 if(iPWG4JCORRAN)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 JCORRAN disabled in analysis on AOD's");
4d62ae1a 1292 iPWG4JCORRAN = 0;
c38e3b95 1293 if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's");
1294 iPWG4PtQAMC = 0;
1295 if( iPWG4PtQATPC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtTPC disabled in analysis on AOD's");
1296 iPWG4PtQATPC = 0;
1f329128 1297 if( iPWG4Cosmics)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Comics disabled in analysis on AOD's");
1298 iPWG4Cosmics = 0;
1299
c38e3b95 1300 if( iPWG4PtSpectra)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis on AOD's");
1301 iPWG4PtSpectra = 0;
b53f2e4f 1302 if(iPWG4KMeans)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4KMeans disabled on AOD's");
1303 iPWG4KMeans = 0;
d2e6cdd5 1304 if (iPWG4JetCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4Jetcorr disabled on AOD's");
1305 iPWG4JetCorr = 0;
c38e3b95 1306 if (iPWG4PartCorr)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4partcorr disabled on AOD's");
1307 iPWG4PartCorr = 0;
d2e6cdd5 1308 if (iPWG4CaloQA)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4CaloQA disabled on AOD's");
1309 iPWG4CaloQA = 0;
911a740f 1310 if (iPWG4Tagged)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4tagged disabled on AOD's");
1311 iPWG4Tagged = 0;
121e4bd5 1312 if (iPWG4omega3pi)
1313 ::Info("AnalysisTrainNew.C::CheckModuleFlags", "PWG4omega3pi disabled on AOD's");
1314 iPWG4omega3pi = 0;
c38e3b95 1315 if(iPWG1QASym)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG1 QA Sym disabled in analysis on AOD's");
53c63663 1316 if (iPWG4GammaConv)::Info("AnalysisPWG4Jets.C::CheckModuleFlags", "PWG4gammaconv disabled on AOD's");
1317 iPWG4GammaConv = 0;
c38e3b95 1318 iPWG1QASym = 0;
f4132e7d 1319 iCentralitySelection = 0;
c38e3b95 1320 } else {
1321 // ESD analysis
f4132e7d 1322
1323 if(kIsPbPb){
1324 iCentralitySelection = 1;
1325 }
1326
c38e3b95 1327 if (!kUseMC){
1328 kUseTR = kFALSE;
1329
1330 if(kUseKinefilter)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 Kine Filter disabled in analysis without MC");
1331 kUseKinefilter = kFALSE;
1332 if( iPWG4PtQAMC)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 PtQAMC disabled in analysis without MC");
1333 iPWG4PtQAMC = 0;
9748e967 1334 if( iPWG4CorrectionsUE)::Info("AnalysisTrainPWG4Jets.C::CheckModuleFlags", "PWG4 CorrectionsUE disabled in analysis without MC");
1335 iPWG4CorrectionsUE = 0;
c38e3b95 1336 }
e84da0a5 1337 if (iJETAN){
1338 iESDfilter=1;
1339 }
c38e3b95 1340 if (!iESDfilter){
1341 kUseKinefilter = kFALSE;
1342 kUseMuonfilter = kFALSE;
1343 }
1344 if(!iJETAN){
cc636095 1345 iPWG4JetSpectrum = iPWG4UE = iPWG4CorrectionsUE = iPWG4ThreeJets = iPWG4QGSep = iDIJETAN = 0;
c38e3b95 1346 }
1347 }
7b90d977 1348 iPWG4JetTasks = iPWG4JetServices||iPWG4JetSpectrum||iPWG4UE||iPWG4LeadingUE||iPWG4PtQAMC||iPWG4PtTrackQA||iPWG4PtSpectra||iPWG4PtQATPC||iPWG4Cosmics||iPWG4ThreeJets||iPWG4QGSep||iPWG4JetChem||iPWG4Minijet||iPWG4Fragmentation;
d2e6cdd5 1349 iPWG4PartCorrLibs = iPWG4PartCorr||iPWG4Tagged||iPWG4CaloQA;
17d96675 1350 iPWG4GammaConvLib = iPWG4GammaConv||iPWG4CaloConv;
1351
1352
7b90d977 1353 iEMCUtilLibs = iPWG4PartCorrLibs||iPWG4JCORRAN||iPWG4GammaConvLib||iJETAN;
e6993a52 1354 iJETANLib = iPWG4JetTasks||iJETAN||iDIJETAN;
17d96675 1355
c38e3b95 1356 if (iESDfilter) {iAODhandler=1;}
1357 if (kUseKinefilter && !kUseMC) kUseKinefilter = kFALSE;
1358 if (kUseAODTags && !iAODhandler) kUseAODTags = kFALSE;
1359
1360
1361
1362}
1363
1364//______________________________________________________________________________
1365Bool_t Connect(const char *mode) {
1366// Connect <username> to the back-end system.
1367 Int_t imode = -1;
1368 if (!strcmp(mode, "LOCAL")) imode = 0;
1369 if (!strcmp(mode, "PROOF")) imode = 1;
1370 if (!strcmp(mode, "GRID")) imode = 2;
1371 TString username = gSystem->Getenv("alien_API_USER");
1372 switch (imode) {
1373 case 0:
1374 break;
1375 case 1:
1376 if (!username.Length()) {
1377 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \
1378 1. Have called: alien-token-init <username>\n \
1379 2. Have called: >source /tmp/gclient_env_$UID");
1380 return kFALSE;
1381 }
1382 ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to PROOF cluster <%s>",
1383 username.Data(), kProofCluster.Data());
1384 gEnv->SetValue("XSec.GSI.DelegProxy", "2");
1385// TProof::Open(Form("%s@%s:31093", username.Data(), kProofCluster.Data()));
1386 TProof::Open(Form("%s@%s", username.Data(), kProofCluster.Data()));
1387 if (!gProof) {
1388 if (strcmp(gSystem->Getenv("XrdSecGSISRVNAMES"), "lxfsrd0506.cern.ch"))
1389 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Environment XrdSecGSISRVNAMES different from lxfsrd0506.cern.ch");
1390 return kFALSE;
1391 }
1392 if(kProofClearPackages)gProof->ClearPackages();
1393
1394 if(kProofSaveToAlien){
1395 TGrid::Connect("alien://");
1396 if (gGrid) {
1397 TString homedir = gGrid->GetHomeDirectory();
1398 TString workdir = homedir + kTrainName;
1399 if (!gGrid->Cd(workdir)) {
1400 gGrid->Cd(homedir);
1401 if (gGrid->Mkdir(workdir)) {
1402 gGrid->Cd(kTrainName);
1403 ::Info("AnalysisTrainPWG4Jets::Connect()", "Directory %s created", gGrid->Pwd());
1404 }
1405 }
1406 gGrid->Mkdir("proof_output");
1407 gGrid->Cd("proof_output");
1408 kProofOutdir = Form("alien://%s", gGrid->Pwd());
1409 }
1410 }
1411 break;
1412 case 2:
1413 if (!username.Length()) {
1414 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode), "Make sure you:\n \
1415 1. Have called: alien-token-init <username>\n \
1416 2. Have called: >source /tmp/gclient_env_$UID");
1417 return kFALSE;
1418 }
1419 if (kPluginUse && !gSystem->Getenv("alien_CLOSE_SE")) {
1420 ::Error(Form("AnalysisTrainPWG4Jets.C::Connect <%s>", mode),
1421 "When using the AliEn plugin it is preferable to define the \
1422 variable alien_CLOSE_SE in your environment.");
1423 return kFALSE;
1424 }
1425 ::Info("AnalysisTrainPWG4Jets.C::Connect", "Connecting user <%s> to AliEn ...",
1426 username.Data());
1427 TGrid::Connect("alien://");
1428 if (!gGrid || !gGrid->IsConnected()) return kFALSE;
1429 break;
1430 default:
1431 ::Error("AnalysisTrainPWG4Jets.C::Connect", "Unknown run mode: %s", mode);
1432 return kFALSE;
1433 }
1434 ::Info("AnalysisTrainPWG4Jets.C::Connect","Connected in %s mode", mode);
1435 return kTRUE;
1436}
1437
1438//______________________________________________________________________________
1439Bool_t LoadCommonLibraries(const char *mode)
1440{
34fc6450 1441 if (!gSystem->Getenv("ALICE_ROOT")) {
1442 ::Error("AnalysisTrainPWG4Jets.C", "Analysis train requires that ALICE_ROOT is set to pick up Configurations");
f12de05f 1443 return kFALSE;
1444 }
1445
1446 // Load common analysis libraries.
c38e3b95 1447 Int_t imode = -1;
1448 if (!strcmp(mode, "LOCAL")) imode = 0;
1449 if (!strcmp(mode, "PROOF")) imode = 1;
1450 if (!strcmp(mode, "GRID")) imode = 2;
c38e3b95 1451 Bool_t success = kTRUE;
1452 // ROOT libraries
1453 gSystem->Load("libTree.so");
1454 gSystem->Load("libGeom.so");
1455 gSystem->Load("libVMC.so");
1456 gSystem->Load("libPhysics.so");
1457
1458 // Load framework classes. Par option ignored here.
1459 switch (imode) {
1460 case 0:
1461 case 2:
1462 if (kUseCPAR) {
1463 success &= LoadLibrary("STEERBase", mode, kTRUE);
1464 success &= LoadLibrary("ESD", mode, kTRUE);
1465 success &= LoadLibrary("AOD", mode, kTRUE);
1466 success &= LoadLibrary("ANALYSIS", mode, kTRUE);
1467 success &= LoadLibrary("ANALYSISalice", mode, kTRUE);
7b90d977 1468 success &= LoadLibrary("OADB", mode, kTRUE);
d8f21f85 1469 success &= LoadLibrary("ROOTFILES", mode, kTRUE);
7b90d977 1470 // success &= LoadLibrary("EventMixing", mode,kTRUE);
c38e3b95 1471 success &= LoadLibrary("CORRFW", mode, kTRUE);
1472 } else {
1473 success &= LoadLibrary("libSTEERBase.so", mode);
1474 success &= LoadLibrary("libESD.so", mode);
1475 success &= LoadLibrary("libAOD.so", mode);
1476 success &= LoadLibrary("libANALYSIS.so", mode);
1477 success &= LoadLibrary("libANALYSISalice.so", mode);
7b90d977 1478 success &= LoadLibrary("libOADB.so", mode, kTRUE);
1479 // success &= LoadLibrary("libEventMixing.so", mode);
c38e3b95 1480 success &= LoadLibrary("libCORRFW.so", mode);
1481 gROOT->ProcessLine(".include $ALICE_ROOT/include");
1482 }
1483 break;
1484 case 1:
1485 Int_t ires = -1;
1486 if (kProofUseAFPAR && !gSystem->AccessPathName(kProofAFversion)) ires = gProof->UploadPackage(kProofAFversion);
1487 if (ires < 0) {
1488 success &= LoadLibrary("STEERBase", mode);
1489 success &= LoadLibrary("ESD", mode);
1490 success &= LoadLibrary("AOD", mode);
1491 success &= LoadLibrary("ANALYSIS", mode);
1492 success &= LoadLibrary("ANALYSISalice", mode);
070f06d2 1493 success &= LoadLibrary("EventMixing", mode);
c38e3b95 1494 success &= LoadLibrary("CORRFW", mode);
1495 } else {
1496 ires = gProof->EnablePackage(kProofAFversion);
1497 if (ires<0) success = kFALSE;
1498 success &= LoadLibrary("CORRFW", mode);
1499 }
1500 break;
1501 default:
1502 ::Error("AnalysisTrainPWG4Jets.C::LoadCommonLibraries", "Unknown run mode: %s", mode);
1503 return kFALSE;
1504 }
1505 if (success) {
1506 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: SUCCESS");
1507 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Include path for Aclic compilation:\n%s",
1508 gSystem->GetIncludePath());
1509 } else {
1510 ::Info("AnalysisTrainPWG4Jets.C::LoadCommodLibraries", "Load common libraries: FAILED");
1511 }
1512
1513 return success;
1514}
1515
1516//______________________________________________________________________________
1517Bool_t LoadAnalysisLibraries(const char *mode)
1518{
1519// Load common analysis libraries.
9748e967 1520 Bool_t success = kTRUE;
cfd02305 1521 if (useTender) {
1522 if (!LoadLibrary("TENDER", mode, kTRUE) ||
1523 !LoadLibrary("TENDERSupplies", mode, kTRUE)) return kFALSE;
1524 }
c38e3b95 1525 if (iESDfilter) {
b0a36f28 1526 /*
c38e3b95 1527 if (!LoadLibrary("PWG3base", mode, kTRUE) ||
1528 !LoadLibrary("PWG3muon", mode, kTRUE)) return kFALSE;
b0a36f28 1529 */
c38e3b95 1530 }
1531 // JETAN
e6993a52 1532 if (iJETANLib) {
b53f2e4f 1533 // this part needs some rework in case we do not need the fastjed finders for processing
7b90d977 1534 if(iEMCUtilLibs){
1535 if (!LoadLibrary("EMCALUtils", mode, kTRUE) ||
1536 !LoadLibrary("PHOSUtils", mode, kTRUE)) return kFALSE;
1537 }
b53f2e4f 1538 if (!LoadLibrary("JETAN", mode, kTRUE)) return kFALSE;
c38e3b95 1539 if (!strcmp(mode, "PROOF")){
ef1e462f 1540 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libCGAL.so\"\)", kTRUE);
c38e3b95 1541 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libfastjet.so\"\)", kTRUE);
1542 // problem when loading siscone copiled with different gcc version??
1543 // gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libsiscone.so\"\)", kTRUE);
1544 gProof->Exec("gSystem->Load\(\"/afs/cern.ch/user/d/dperrino/public/libSISConePlugin.so\"\)", kTRUE);
1545 }
b53f2e4f 1546 if(!kUsePAR){
e84da0a5 1547 if (!LoadLibrary("CGAL", mode, kTRUE)) return kFALSE;
1548 if (!LoadLibrary("fastjet", mode, kTRUE)) return kFALSE;
1549 if (!LoadLibrary("siscone", mode, kTRUE)) return kFALSE;
1550 if (!LoadLibrary("SISConePlugin", mode, kTRUE)) return kFALSE;
1551 }
1552 else{
1553 // par files plus FASTJET needs some extra work... need to change
1554 // the loading sequence in the auto generated .C file
1555 if (!LoadLibrary("libCGAL.so", mode, kTRUE)) return kFALSE;
1556 if (!LoadLibrary("libfastjet.so", mode, kTRUE)) return kFALSE;
1557 if (!LoadLibrary("libsiscone.so", mode, kTRUE)) return kFALSE;
1558 if (!LoadLibrary("libSISConePlugin.so", mode, kTRUE)) return kFALSE;
1559 }
c38e3b95 1560 if (!LoadLibrary("FASTJETAN", mode, kTRUE)) return kFALSE;
1561 }
1562 if(iPWG4JetTasks){
c38e3b95 1563 if (!LoadLibrary("PWG4JetTasks", mode, kTRUE)) return kFALSE;
1564 }
58ef946c 1565
c38e3b95 1566 if(iPWG1QASym){
34fc6450 1567 if (!LoadSource(Form("%s/PWG1/AliAnalysisTaskQASym.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
c38e3b95 1568 }
121e4bd5 1569 if(iPWG4TmpSourceSara){
c166d299 1570 if(!kUsePAR)gSystem->AddIncludePath("-I$ALICE_ROOT/include/JetTasks"); // ugly hack!!
34fc6450 1571 if(!LoadSource(Form("%s/PWG4/JetTasks/AliAnalysisTaskEta.cxx",gSystem->ExpandPathName("$ALICE_ROOT")), mode, kTRUE))return kFALSE;
c580ebbb 1572 }
c166d299 1573
911a740f 1574 if (iPWG4PartCorrLibs) {
4721d8c5 1575 if (!LoadLibrary("PWG4PartCorrBase", mode, kTRUE) ||
c38e3b95 1576 !LoadLibrary("PWG4PartCorrDep", mode, kTRUE)) return kFALSE;
1577 }
4721d8c5 1578 if(iPWG4JCORRAN){
1579 // PWG4 particle correlations
1580 if(!LoadLibrary("PWG4JCORRAN",mode,kTRUE))return kFALSE;
1581 }
d2e6cdd5 1582 if (iPWG4JetCorr) {
1583 if (!LoadLibrary("PWG4JetCorrel", mode, kTRUE)) return kFALSE;
1584 }
121e4bd5 1585 if (iPWG4omega3pi) {
1586 if (!LoadLibrary("PWG4omega3pi", mode, kTRUE)) return kFALSE;
1587 }
17d96675 1588 if (iPWG4GammaConvLib) {
53c63663 1589 if (!LoadLibrary("PWG4GammaConv", mode, kTRUE)) return kFALSE;
1590 }
c38e3b95 1591
1592 ::Info("AnalysisTrainPWG4Jets.C::LoadAnalysisLibraries", "Load other libraries: SUCCESS");
1593 return kTRUE;
1594}
1595
1596//______________________________________________________________________________
1597Bool_t LoadLibrary(const char *module, const char *mode, Bool_t rec=kFALSE)
1598{
1599// Load a module library in a given mode. Reports success.
1600 Int_t imode = -1;
1601 Int_t result;
1602 TString smodule(module);
1603 if (!strcmp(mode, "LOCAL")) imode = 0;
1604 if (!strcmp(mode, "PROOF")) imode = 1;
1605 if (!strcmp(mode, "GRID")) imode = 2;
1606 TString mod(module);
1607 if (!mod.Length()) {
1608 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Empty module name");
1609 return kFALSE;
1610 }
1611 // If a library is specified, just load it
1612 if (smodule.EndsWith(".so")) {
1613 mod.Remove(mod.Index(".so"));
1614 result = gSystem->Load(mod);
1615 if (result < 0) {
1616 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load library %s", module);
1617 return kFALSE;
1618 }
1619 if (rec) anaLibs += Form("%s.so ",mod.Data());
e84da0a5 1620 if (rec) anaLibsExtra += Form("%s.so ",mod.Data());
c38e3b95 1621 return kTRUE;
1622 }
1623 // Check if the library is already loaded
1624 if (strlen(gSystem->GetLibraries(Form("%s.so", module), "", kFALSE)) > 0)
1625 return kTRUE;
1626 switch (imode) {
1627 case 0:
1628 case 2:
1629 if (kUsePAR) {
1630 result = SetupPar(module);
1631 if (rec) anaPars += Form("%s.par ", module);
1632 } else {
1633 result = gSystem->Load(Form("lib%s.so", module));
1634 if (rec) anaLibs += Form("lib%s.so ", module);
1635 }
1636 break;
1637 case 1:
1638 if(!gSystem->AccessPathName(module)){
1639 ::Info("AnalysisTrainPWG4Jets.C::LoadLibrary", "Removing directory %s",module);
1640 gSystem->Exec(Form("rm -rf %s",module));
1641 }
1642 result = gProof->UploadPackage(module);
1643 if (result<0) {
1644 result = gProof->UploadPackage(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", module)));
1645 if (result<0) {
1646 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not find module %s.par in current directory nor in $ALICE_ROOT", module);
1647 return kFALSE;
1648 }
1649 }
1650 result = gProof->EnablePackage(module);
1651 break;
1652 default:
1653 return kFALSE;
1654 }
1655 if (result < 0) {
1656 ::Error("AnalysisTrainPWG4Jets.C::LoadLibrary", "Could not load module %s", module);
1657 return kFALSE;
1658 }
1659 return kTRUE;
1660}
1661
1662
1663
1664//______________________________________________________________________________
1665Bool_t LoadSource(const char *source, const char *mode, Bool_t rec=kFALSE)
1666{
1667// Load a module library in a given mode. Reports success.
1668 Int_t imode = -1;
1669 Int_t result = -1;
1670 if (!strcmp(mode, "LOCAL")) imode = 0;
1671 if (!strcmp(mode, "PROOF")) imode = 1;
1672 if (!strcmp(mode, "GRID")) imode = 2;
1673 TString ssource(source);
1674 TString basename = gSystem->BaseName(ssource.Data());
1675 if (!ssource.Length()) {
1676 ::Error("AnalysisTrainPWG4Jets.C::LoadSource", "Empty task name");
1677 return kFALSE;
1678 }
4d62ae1a 1679 // we have a source code so compile it
c38e3b95 1680 if (ssource.EndsWith(".cxx")) {
1681 // need to copy it here other wise the path is also used on grid...
1682 ssource.Remove(ssource.Index(".cxx"));
1683 basename.Remove(basename.Index(".cxx"));
1684 Printf("LoadSources:: Copying... path %s{cxx,h}",ssource.Data());
1685 gSystem->Exec(Form("cp %s.cxx . ",ssource.Data()));
1686 gSystem->Exec(Form("cp %s.h . ",ssource.Data()));
1687 // Path to code
1688 // only needed for local compilation, in grid and proof mode
1689 // the task headers are uploaded
1690 // path.Remove(path.Index(gSystem->BaseName(path.Data())));
1691 // Printf("LoadSources:: Including path %s",path.Data());
1692 // if(path.Length()>0)gROOT->ProcessLine(Form(".include %s",path.Data()));
1693 Printf("LoadSources:: Loading... path %s",basename.Data());
1694 switch (imode) {
1695 case 0:
b53f2e4f 1696 result = gROOT->LoadMacro(Form("%s.cxx++g",basename.Data()));
c38e3b95 1697 break;
1698 case 1:
b53f2e4f 1699 result = gProof->LoadMacro(Form("%s.cxx++g",basename.Data()));
c38e3b95 1700 break;
1701 case 2:
b53f2e4f 1702 result = gROOT->LoadMacro(Form("%s.cxx++g",basename.Data()));
c38e3b95 1703 if (rec){
1704 // what we want to compile
1705 anaSources += Form("%s.cxx ",basename.Data());
1706 // what we need as input...
1707 anaLibs += Form("%s.cxx %s.h ",basename.Data(),basename.Data());
1708 }
1709 break;
1710 default:
1711 return kFALSE;
1712 }
1713 }
1714 if (result < 0) {
1715 ::Error("AnalysisTrainPWG4Jets.C::LoadSources", "Could not load source %s", source);
1716 return kFALSE;
1717 }
1718 return kTRUE;
1719}
1720
1721
1722//______________________________________________________________________________
1723TChain *CreateChain(const char *mode, const char *plugin_mode)
1724{
1725// Create the input chain
1726 Int_t imode = -1;
1727 if (!strcmp(mode, "LOCAL")) imode = 0;
1728 if (!strcmp(mode, "PROOF")) imode = 1;
1729 if (!strcmp(mode, "GRID")) imode = 2;
1730 TChain *chain = NULL;
1731 // Local chain
1732 switch (imode) {
1733 case 0:
1734 if (iAODanalysis) {
1735 if (!kLocalXMLDataset.Length()) {
1736 // Local AOD
1737 chain = new TChain("aodTree");
1738 TString line;
1739 ifstream in;
1740 in.open(kLocalDataList.Data());
37eb26ea 1741 Int_t ic = 0;
c38e3b95 1742 while (in.good()) {
1743 in >> line;
1744 if (line.Length() == 0) continue;
37eb26ea 1745 Printf("%d adding %s",ic,line.Data());
c38e3b95 1746 chain->Add(line.Data());
37eb26ea 1747 ic++;
c38e3b95 1748 }
1749 } else {
1750 // Interactive AOD
1751 chain = CreateChainSingle(kLocalXMLDataset, "aodTree");
1752 }
1753 } else {
1754 if (!kLocalXMLDataset.Length()) {
1755 // Local ESD
1756 chain = new TChain("esdTree");
1757 TString line;
1758 ifstream in;
1759 in.open(kLocalDataList.Data());
1760 while (in.good()) {
1761 in >> line;
1762 if (line.Length() == 0) continue;
1763 cout << " line = " << line << endl;
1764 chain->Add(line.Data());
1765 }
1766 } else {
1767 // Interactive ESD
1768 chain = CreateChainSingle(kLocalXMLDataset, "esdTree");
1769 }
1770 }
1771 break;
1772 case 1:
1773 break;
1774 case 2:
1775 if (kPluginUse) {
1776// AliAnalysisGrid *alienHandler = CreateAlienHandler(plugin_mode);
1777// AliAnalysisManager::GetAnalysisManager()->SetGridHandler(alienHandler);
1778 } else {
1779 TString treeName = "esdTree";
1780 if (iAODanalysis) treeName = "aodTree";
1781 chain = CreateChainSingle("wn.xml", treeName);
1782 }
1783 break;
1784 default:
1785 }
1786 if (chain && chain->GetNtrees()) return chain;
1787 return NULL;
1788}
1789
1790//______________________________________________________________________________
1791TChain* CreateChainSingle(const char* xmlfile, const char *treeName)
1792{
1793 printf("*******************************\n");
1794 printf("*** Getting the ESD Chain ***\n");
1795 printf("*******************************\n");
1796 TAlienCollection * myCollection = TAlienCollection::Open(xmlfile);
1797
1798 if (!myCollection) {
1799 ::Error("AnalysisTrainPWG4Jets.C::CreateChainSingle", "Cannot create an AliEn collection from %s", xmlfile) ;
1800 return NULL ;
1801 }
1802
1803 TChain* chain = new TChain(treeName);
1804 myCollection->Reset() ;
1805 while ( myCollection->Next() ) chain->Add(myCollection->GetTURL("")) ;
1806 chain->ls();
1807 return chain;
1808}
1809
1810//______________________________________________________________________________
1811Int_t SetupPar(char* pararchivename)
1812{
1813 if (!pararchivename || !strlen(pararchivename)) return -1;
1814 char processline[1024];
1815 if (gSystem->AccessPathName(Form("%s.par", pararchivename))) {
1816 if (!gSystem->AccessPathName(Form("%s/%s.par", gSystem->Getenv("ALICE_ROOT"),pararchivename))) {
1817 ::Info("AnalysisTrainPWG4Jets.C::SetupPar", "Getting %s.par from $ALICE_ROOT", pararchivename);
9748e967 1818 TFile::Cp(gSystem->ExpandPathName(Form("$ALICE_ROOT/%s.par", pararchivename)),
1819 Form("%s.par",pararchivename));
c38e3b95 1820 } else {
1821 ::Error("AnalysisTrainPWG4Jets.C::SetupPar", "Cannot find %s.par", pararchivename);
1822 return -1;
1823 }
1824 }
1825 if (kPluginUse && kSaveTrain) gSystem->Exec(Form("ln -s ../%s.par %s",pararchivename, kTrainName.Data()));
1826 gSystem->Exec(Form("tar xvzf %s.par", pararchivename));
1827
1828 TString ocwd = gSystem->WorkingDirectory();
1829 if (!gSystem->ChangeDirectory(pararchivename)) return -1;
1830
1831 // check for BUILD.sh and execute
1832 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
1833 printf("*******************************\n");
1834 printf("*** Building PAR archive ***\n");
1835 printf("*******************************\n");
1836 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
1837 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
1838 return -1;
1839 }
1840 }
1841
1842 // check for SETUP.C and execute
1843 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
1844 printf("*******************************\n");
1845 printf("*** Setup PAR archive ***\n");
1846 printf("*******************************\n");
1847 gROOT->Macro("PROOF-INF/SETUP.C");
1848 }
4478beda 1849 if (!gSystem->ChangeDirectory(ocwd.Data())){
1850 Error("Change back directory",Form("Cannot change to %s",ocwd.Data()));
1851 return -1;
1852 }
c38e3b95 1853 return 0;
1854}
1855
1856//______________________________________________________________________________
1857AliAnalysisAlien* CreateAlienHandler(const char *plugin_mode)
1858{
1859// Check if user has a valid token, otherwise make one. This has limitations.
1860// One can always follow the standard procedure of calling alien-token-init then
1861// source /tmp/gclient_env_$UID in the current shell.
c8fb37dd 1862// if (!AliAnalysisGrid::CreateToken()) return NULL;
c38e3b95 1863 AliAnalysisAlien *plugin = new AliAnalysisAlien();
1864// Set the run mode (can be "full", "test", "offline", "submit" or "terminate")
1865 plugin->SetRunMode(plugin_mode);
1866 if (kPluginUseProductionMode) plugin->SetProductionMode();
1867 plugin->SetJobTag(kJobTag);
d8f21f85 1868 plugin->SetNtestFiles(1);
c38e3b95 1869// plugin->SetPreferedSE("ALICE::NIHAM::File");
1870// Set versions of used packages
e84da0a5 1871 plugin->SetAPIVersion("V1.1x");
1872 // plugin->SetAPIVersion("V1.0x");
1873// plugin->SetAPIVersion("V2.4");
c38e3b95 1874 plugin->SetROOTVersion(kPluginRootVersion);
1875 plugin->SetAliROOTVersion(kPluginAliRootVersion);
1876// Declare input data to be processed.
1877// Method 1: Create automatically XML collections using alien 'find' command.
1878// Define production directory LFN
1879 plugin->SetGridDataDir(kGridDatadir.Data());
1880// Set data search pattern
d8f21f85 1881 if (iAODanalysis) plugin->SetDataPattern(" *AliAOD.Jets.root");
c8fb37dd 1882 // else plugin->SetDataPattern(Form(" %s/*/*ESD.tag.root",kGridPassPattern.Data()));
1883 else plugin->SetDataPattern(Form(" %s/*/*AliESDs.root",kGridPassPattern.Data()));
c38e3b95 1884// ...then add run numbers to be considered
1885// plugin->SetRunRange(kGridRunRange[0], kGridRunRange[1]);
1886 for (Int_t i=kGridRunRange[0]; i<=kGridRunRange[1]; i++) {
1887 Printf("AnalysisTrainPWG4Jets Adding run number %s", Form(kGridRunPattern.Data(),i));
1888 plugin->AddRunNumber(Form(kGridRunPattern.Data(),i));
1889 }
1890
1891 if(kGridLocalRunList.Length()>0){
1892 ifstream in1;
1893 in1.open(kGridLocalRunList.Data());
1894 int iRun;
4d16db9c 1895 int icount = 0;
9a5c5b1e 1896 /*
e84da0a5 1897 char c;
1898 char cLine[250];
1899 while(!in1.eof()){
1900 c = in1.get();
1901 if ( (c >= '0') && (c <= '9') )
1902 {
d8f21f85 1903 in1.putback (c)s;
e84da0a5 1904 in1>>iRun;
1905 Printf("AnalysisTrainPWG4Jets Adding run number from File %s", Form(kGridRunPattern.Data(),iRun));
1906 plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun));
1907 }
1908 else
1909 {
1910 in1.putback (c);
1911 in1.getline(cLine,250);
9a5c5b1e 1912
1913 }
1914 }
1915 */
9748e967 1916
1917 Int_t nRun = 0;
9a5c5b1e 1918
1919 // just use run numbers, negatives will be excluded
1920 while(in1>>iRun){
ffab794c 1921 if(iRun>=0){
1922 if(iRun>=0&&nRun>=kGridOffsetRunFromList&&(nRun<kGridMaxRunsFromList)){
f12de05f 1923 Printf("AnalysisTrainPWG4Jets Adding run number from File %d: %s",nRun,Form(kGridRunPattern.Data(),iRun));
9a5c5b1e 1924 plugin->AddRunNumber(Form(kGridRunPattern.Data(),iRun));
ffab794c 1925
1926 }
1927 else{
f12de05f 1928 Printf("AnalysisTrainPWG4Jets Skipping run number from File %d: %d",nRun, iRun);
ffab794c 1929 }
36c36a0c 1930 nRun++;
9a5c5b1e 1931 }
1932 else{
f12de05f 1933 Printf("AnalysisTrainPWG4Jets Skipping run number from File %d: %d",nRun, iRun);
e84da0a5 1934 }
c38e3b95 1935 }
1936 }
1937
1938// Method 2: Declare existing data files (raw collections, xml collections, root file)
1939// If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir())
1940// XML collections added via this method can be combined with the first method if
1941// the content is compatible (using or not tags)
1942// plugin->AddDataFile("tag.xml");
1943// plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root");
1944// Define alien work directory where all files will be copied. Relative to alien $HOME.
3878a941 1945 TString alien_workdir = "";
1946
1947 if (iAODanalysis) alien_workdir += "analysisAOD";
1948 else alien_workdir += "analysisESD";
1949 if(kGridDataSet.Length()>0)alien_workdir += Form("/%s",kGridDataSet.Data());
1950 plugin->SetGridWorkingDir(alien_workdir.Data());
1951
c38e3b95 1952 // Declare alien output directory. Relative to working directory.
1953 if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
1954 plugin->SetGridOutputDir(kGridOutdir);
1955
1956 // Add external packages
1957 if (iJETAN||iDIJETAN) {
23adcac8 1958 plugin->AddExternalPackage("boost::v1_43_0");
1959 plugin->AddExternalPackage("cgal::v3.6");
1960 plugin->AddExternalPackage("fastjet::v2.4.2");
c38e3b95 1961 }
1962
1963
1964 // set extra libs before par file compilation
1965 anaLibs += kGridExtraFiles;
1966 anaLibs = anaLibs.Strip();
e84da0a5 1967 Printf("anaLibs %s",anaLibs.Data());
1968 Printf("anaLibsExtra %s",anaLibsExtra.Data());
1969
1970 if (anaLibs.Length()) plugin->SetAdditionalLibs(anaLibs.Data());
1971 if (anaLibsExtra.Length()) plugin->SetAdditionalRootLibs(anaLibsExtra.Data());
c38e3b95 1972
1973 TString ana_sources = "";
1974 TString ana_add = "";
1975 if (kUsePAR && anaPars.Length()) {
1976 printf("%s\n", anaPars.Data());
1977 TObjArray *arr;
1978 TObjString *objstr;
1979 arr = anaPars.Tokenize(" ");
1980 TIter next(arr);
1981 while ((objstr=(TObjString*)next())) plugin->EnablePackage(objstr->GetString());
1982 delete arr;
1983 }
1984
1985// Declare the analysis source files names separated by blancs. To be compiled runtime
1986// using ACLiC on the worker nodes.
1987 ana_sources = anaSources.Strip();
1988// Declare all libraries (other than the default ones for the framework. These will be
1989// loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here.
1990
1991 if (ana_sources.Length()) plugin->SetAnalysisSource(ana_sources);
1992 plugin->SetExecutableCommand(kPluginExecutableCommand.Data());
4721d8c5 1993 // Declare the output file names separated by blancs.
1994 // (can be like: file.root or file.root@ALICE::Niham::File)
c38e3b95 1995 plugin->SetMergeExcludes(kGridMergeExclude);
1996 plugin->SetMaxMergeFiles(kGridMaxMergeFiles);
1997 plugin->SetNrunsPerMaster(kGridRunsPerMaster);
9a5c5b1e 1998 plugin->SetMergeViaJDL(kPluginMergeViaJDL);
4721d8c5 1999 // Use fastread option
9a5c5b1e 2000 plugin->SetFastReadOption(kPluginFastReadOption);
4721d8c5 2001 // UseOverwrite mode
9a5c5b1e 2002 plugin->SetOverwriteMode(kPluginOverwriteMode);
4721d8c5 2003 // Optionally define the files to be archived.
2004 // plugin->SetOutputArchive("log_archive.zip:stdout,stderr@ALICE::NIHAM::File root_archive.zip:AliAOD.root,AOD.tag.root@ALICE::NIHAM::File");
dc6a7461 2005 plugin->SetOutputToRunNo(kPluginOutputToRunNumber); // write the output to subdirs named after run number
c38e3b95 2006
2007 // Put default output files to archive
2008 TString listhists = "";
2009 TString listaods = "";
2010 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
2011 TIter next(mgr->GetOutputs());
2012 AliAnalysisDataContainer *output;
2013 while ((output=(AliAnalysisDataContainer*)next())) {
2014 const char *filename = output->GetFileName();
2015 if (!(strcmp(filename, "default"))) {
53c63663 2016 if (!mgr->GetOutputEventHandler()) continue;
c38e3b95 2017 filename = mgr->GetOutputEventHandler()->GetOutputFileName();
e84da0a5 2018 if (listaods.Length()) listaods += " ";
c38e3b95 2019 listaods += filename;
c38e3b95 2020 } else {
e84da0a5 2021 if(!listhists.Contains(filename)){
2022 if (listhists.Length()) listhists += " ";
c38e3b95 2023 listhists += filename;
2024 }
2025 }
2026 }
53c63663 2027
53c63663 2028 if (mgr->GetExtraFiles().Length()) {
e84da0a5 2029 if (listaods.Length()) listaods += " ";
53c63663 2030 listaods += mgr->GetExtraFiles();
c38e3b95 2031 }
53c63663 2032
2033 // if we do not fill the aod we do not need to store it
4721d8c5 2034 // kGridMergeExclude = listaods;
e84da0a5 2035
e2afec0c 2036 if(kSaveAOD>=0){
4721d8c5 2037 TString outputFiles = "";
2038 outputFiles += mgr->GetExtraFiles();
2039 if (listhists.Length()) outputFiles += " ";
2040 outputFiles += listhists;
e84da0a5 2041 plugin->SetDefaultOutputs(kFALSE);
4721d8c5 2042 Printf("%s:%d Starting with the files %s",(char*)__FILE__,__LINE__,outputFiles.Data());
2043 // remove
2044 // no harm done when we try to remove something that is not there :)
2045 if(!(kSaveAOD&(1<<0))){
2046 outputFiles.ReplaceAll("AliAOD.root ","");
2047 listaods.ReplaceAll("AliAOD.root ","");
2048 }
2049 if(!(kSaveAOD&(1<<1))){
2050 if(kDeltaAODJetName.Length())outputFiles.ReplaceAll(kDeltaAODJetName.Data(),"");
2051 if(kDeltaAODJetName.Length())listaods.ReplaceAll(kDeltaAODJetName.Data(),"");
2052
2053 }
2054 if(!(kSaveAOD&(1<<2))){
2055 if(kDeltaAODPartCorrName.Length())outputFiles.ReplaceAll(kDeltaAODPartCorrName.Data(),"");
2056 if(kDeltaAODPartCorrName.Length())listaods.ReplaceAll(kDeltaAODPartCorrName.Data(),"");
2057 }
2058 if(!(kSaveAOD&(1<<3))){
2059 if(kDeltaAODJCORRANName.Length())outputFiles.ReplaceAll(kDeltaAODJCORRANName.Data(),"");
2060 if(kDeltaAODJCORRANName.Length())listaods.ReplaceAll(kDeltaAODJCORRANName.Data(),"");
2061 }
2062
2063 //
e2afec0c 2064 plugin->SetDefaultOutputs(kFALSE);
4721d8c5 2065 Printf("%s:%d Saving the files %s",(char*)__FILE__,__LINE__,outputFiles.Data());
2066 plugin->SetOutputFiles(outputFiles.Data());
e84da0a5 2067 }
53c63663 2068
4721d8c5 2069 TString outputArchive;
4d5d766e 2070 outputArchive = Form("log_archive.zip:std*@%s","disk=1");
e84da0a5 2071 listaods.ReplaceAll(" ", ",");
2072 listhists.ReplaceAll(" ", ",");
4d5d766e 2073 if (listhists.Length()){
2074 outputArchive += " ";
2075 outputArchive += "root_archive.zip:";
2076 outputArchive += listhists;
2077 if (listaods.Length()){
2078 outputArchive += ",";
2079 outputArchive += listaods;
2080 }
2081 outputArchive += Form("@%s", kGridOutputStorages.Data());
2082 }
2083 else{
2084
2085 if (listaods.Length()){
2086 // we have only aod'ish output
2087 outputArchive += " ";
2088 outputArchive += "root_archive.zip:";
2089 outputArchive += listaods;
2090 outputArchive += Form("@%s", kGridOutputStorages.Data());
2091 }
2092 else{
2093 // no other outputs than std..
c38e3b95 2094 ::Fatal("AnalysisTrainPWG4Jets", "No task output !");
4d5d766e 2095 }
c38e3b95 2096 }
4d5d766e 2097
17d96675 2098 plugin->SetDefaultOutputs(kFALSE);
c38e3b95 2099 plugin->SetOutputArchive(outputArchive);
17d96675 2100
4721d8c5 2101
4d5d766e 2102 // Optionally set a name for the generated analysis macro (default MyAnalysis.C)
c38e3b95 2103 plugin->SetAnalysisMacro(Form("%s.C", kTrainName.Data()));
4d5d766e 2104 // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore)
c38e3b95 2105 plugin->SetSplitMaxInputFileNumber(kGridFilesPerJob);
4d5d766e 2106 // Optionally set number of failed jobs that will trigger killing waiting sub-jobs.
27cdf9c4 2107 // plugin->SetMaxInitFailed(5);
4d5d766e 2108 // Optionally resubmit threshold.
c8fb37dd 2109 // plugin->SetMasterResubmitThreshold(90);
4d5d766e 2110 // Optionally set time to live (default 30000 sec)
d4e8abc5 2111 plugin->SetTTL(54000); // 15h...
4d5d766e 2112 // Optionally set input format (default xml-single)
c38e3b95 2113 plugin->SetInputFormat("xml-single");
4d5d766e 2114 // Optionally modify the name of the generated JDL (default analysis.jdl)
c38e3b95 2115 plugin->SetJDLName(Form("%s.jdl", kTrainName.Data()));
4d5d766e 2116 // Optionally modify the executable name (default analysis.sh)
c38e3b95 2117 plugin->SetExecutable(Form("%s.sh", kTrainName.Data()));
4d5d766e 2118 // Optionally modify job price (default 1)
c38e3b95 2119 plugin->SetPrice(1);
4d5d766e 2120 // Optionally modify split mode (default 'se')
c38e3b95 2121 plugin->SetSplitMode("se");
2122 return plugin;
2123}
2124
2125//______________________________________________________________________________
2126void WriteConfig()
2127{
2128// Write train configuration in a file. The file name has the format:
2129// train_[trainName]_ddMonthyyyy_time.C
2130 if (kUseDate) {
2131 gSystem->Exec("date +%d%b%Y_%Hh%M > date.tmp");
2132 ifstream fdate("date.tmp");
2133 if (!fdate.is_open()) {
2134 ::Error("AnalysisTrainPWG4Jets.C::Export","Could not generate file name");
2135 return;
2136 }
2137 const char date[64];
2138 fdate.getline(date,64);
2139 fdate.close();
2140 gSystem->Exec("rm date.tmp");
2141 kTrainName = Form("train_%s_%s", kTrainName.Data(), date);
2142 } else {
2143 kTrainName = Form("train_%s", kTrainName.Data());
2144 }
2145 TString cdir = gSystem->WorkingDirectory();
2146 gSystem->MakeDirectory(kTrainName);
2147 gSystem->ChangeDirectory(kTrainName);
2148 ofstream out;
2149 out.open(Form("%sConfig.C",kTrainName.Data()), ios::out);
2150 if (out.bad()) {
2151 ::Error("AnalysisTrainPWG4Jets.C::Export", "Cannot open ConfigTrain.C for writing");
2152 return;
2153 }
2154 out << "{" << endl;
2155 out << " kTrainName = " << "\"" << kTrainName.Data() << "\";" << endl;
2156 out << " kProofCluster = " << "\"" << kProofCluster.Data() << "\";" << endl;
2157 out << " kProofUseAFPAR = " << kProofUseAFPAR << ";" << endl;
2158 if (kProofUseAFPAR)
2159 out << " kProofAFversion = " << kProofAFversion.Data() << ";" << endl;
2160 out << " kProofDataSet = " << "\"" << kProofDataSet.Data() << "\";" << endl;
2161 out << " kPluginUse = " << kPluginUse << ";" << endl;
2162 out << " kUsePAR = " << kUsePAR << ";" << endl;
2163 out << " kUseCPAR = " << kUseCPAR << ";" << endl;
2164 out << " kPluginRootVersion = " << "\"" << kPluginRootVersion.Data() << "\";" << endl;
2165 out << " kPluginAliRootVersion = " << "\"" << kPluginAliRootVersion.Data() << "\";" << endl;
2166 out << " kGridDatadir = " << "\"" << kGridDatadir.Data() << "\";" << endl;
2167 if (!kGridOutdir.Length()) kGridOutdir = Form("output_%s",kTrainName.Data());
2168 out << " kGridOutdir = " << "\"" << kGridOutdir.Data() << "\";" << endl;
2169 out << " kGridMaxMergeFiles = " << kGridMaxMergeFiles << ";" << endl;
2170 out << " kGridMergeExclude = " << "\"" << kGridMergeExclude.Data() << "\";" << endl;
2171 out << " kGridRunsPerMaster = " << kGridRunsPerMaster << ";" << endl;
2172 out << " kGridFilesPerJob = " << kGridFilesPerJob << ";" << endl;
2173 out << " kGridRunRange[0] = " << kGridRunRange[0] << ";" << endl;
2174 out << " kGridRunRange[1] = " << kGridRunRange[1] << ";" << endl;
2175 out << " kUseDebug = " << kUseDebug << ";" << endl;
2176 out << " kUseMC = " << kUseMC << ";" << endl;
2177 out << " kUseESDTags = " << kUseESDTags << ";" << endl;
2178 out << " kUseKinefilter = " << kUseKinefilter << ";" << endl;
2179 out << " kUseTR = " << kUseTR << ";" << endl;
2180 out << " kUseAODTags = " << kUseAODTags << ";" << endl;
2181 out << " kSaveTrain = " << "kFALSE;" << endl << endl;
2182 out << " // Analysis modules" << endl;
2183 out << " iAODanalysis = " << iAODanalysis << ";" << endl;
2184 out << " iAODhandler = " << iAODhandler << ";" << endl;
2185 out << " iESDfilter = " << iESDfilter << ";" << endl;
2186 out << " iJETAN = " << iJETAN << ";" << endl;
2187 out << "// Configuration fot the wagons" << endl;
2188 out << "}" << endl;
2189 ::Info("AnalysisTrainPWG4Jets.C::WriteConfig", "Train configuration wrote to file %s", Form("config_%s.C", kTrainName.Data()));
2190 gSystem->ChangeDirectory(cdir);
2191}
2192
2193//______________________________________________________________________________
2194Bool_t LoadConfig(const char *filename)
2195{
2196// Read train configuration from file
2197 if (gSystem->AccessPathName(filename)) {
2198 ::Error("AnalysisTrainPWG4Jets.C::LoadConfig", "Config file name not found");
2199 return kFALSE;
2200 }
2201 gROOT->ProcessLine(Form(".x %s", filename));
2202 ::Info("AnalysisTrainPWG4Jets.C::LoadConfig", "Train configuration loaded from file %s", filename);
2203 return kTRUE;
2204}
2205
2206Bool_t PatchJDL(){
2207 Printf(">>> Patching JDL");
2208 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
2209 AliAnalysisAlien* gridHandler = (AliAnalysisAlien*)mgr->GetGridHandler();
2210 TGridJDL *jdl = gridHandler->GetGridJDL();
2211 if(iJETAN)jdl->AddToPackages("fastjet","v2.4.0");
2212 gridHandler->WriteJDL(kFALSE);
0971dabc 2213 Printf("<<< Patching JDL");
c38e3b95 2214 return kTRUE;
2215}
2216
2217Bool_t PatchAnalysisMacro(){
4721d8c5 2218 Printf(">>> Patching AnalysisMacro");
2219 gSystem->Exec(Form("mv %s.C %s.C_tmp",kTrainName.Data(),kTrainName.Data()));
c38e3b95 2220
2221 ifstream in1;
2222 in1.open(Form("%s.C_tmp", kTrainName.Data()));
2223 char cLine[250];
2224 TString st;
2225 while(in1.getline(cLine,250)){
2226 st += cLine;
2227 st += "\n";
2228 }
4721d8c5 2229 Int_t index= -1;
c38e3b95 2230 index = st.Index("gSystem->Load(\"libPhysics\");");
2231 index += strlen("gSystem->Load(\"libPhysics\");");
4721d8c5 2232 /*
c38e3b95 2233 TObjArray *arr;
2234 TObjString *objstr;
2235 arr = anaLibs.Tokenize(" ");
2236 TIter next(arr);
4721d8c5 2237
c38e3b95 2238 add += "\n\n // added by CKB \n";
2239 while ((objstr=(TObjString*)next())){
e84da0a5 2240 if(objstr->GetString().Contains("PWG3"))continue;
c38e3b95 2241 if(objstr->GetString().EndsWith(".so"))add += Form("gSystem->Load(\"%s\");\n",objstr->GetString().Data());
2242 }
2243 delete arr;
4721d8c5 2244 */
3878a941 2245 // add += Form("AliLog::SetGlobalLogLevel(%d);\n",AliLog::GetGlobalLogLevel());
4721d8c5 2246 TString add = "";
2247
2248 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2249 add += "\n\n // added by CKB \n";
46534866 2250 if(kErrorIgnoreLevel>0)add += Form("gErrorIgnoreLevel = %d;\n",kErrorIgnoreLevel);
23adcac8 2251 add += "\n gSystem->AddIncludePath(\"./\"); \n";
f4132e7d 2252 add += "\n gSystem->SetFPEMask(); \n";
2253
2254
4721d8c5 2255 if(gGrid&&kPluginAliRootVersion.Length()==0){
bbb42949 2256 /*
4721d8c5 2257 add += "\n // Dirty hack for TRD reference data \n";
2258 add += "\n gSystem->Setenv(\"ALICE_ROOT\",\"";
2259 add += Form("alien://%s/rootfiles/",gGrid->GetHomeDirectory());
2260 add += "\"); \n";
bbb42949 2261 */
c38e3b95 2262 }
bbb42949 2263
4721d8c5 2264 add += "// BKC \n\n";
2265 st.Insert(index,add.Data());
e84da0a5 2266
2267 if(kUseDebug){
23adcac8 2268 // st.Insert(index,"\n gROOT->ProcessLine(\".trace\"); // CKB \n");
e84da0a5 2269 }
2270
4721d8c5 2271 if(kUseCPAR&&kPluginAliRootVersion.Length()==0){
2272 index = st.Index("gSystem->AddIncludePath(\"-I$"); // uncommen $ALICE_ROOT include for par files
2273 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2274 st.Insert(index,"// CKB comment out whehn no aliroot is provided \n //");
2275 }
c166d299 2276
46534866 2277 if(AliLog::GetGlobalLogLevel()==AliLog::kFatal){
2278 index = st.Index("AliLog::SetGlobal"); // ncomment setting of log level, do my own
2279 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2280 st.Insert(index,"AliLog::SetGlobalLogLevel(AliLog::kFatal);// CKB \n // CKB comment out for own setting \n //");
2281 }
2282
c38e3b95 2283 ofstream out;
2284 out.open(Form("%s.C", kTrainName.Data()));
2285 if (out.bad()) {
2286 return kFALSE;
2287 }
2288 out << st << endl;
2289 Printf("<<< Patching AnalysisMacro");
4721d8c5 2290
2291
2292
2293
2294
2295 Printf(">>> Patching Merge Macro");
2296 gSystem->Exec(Form("mv %s_merge.C %s_merge.C_tmp",kTrainName.Data(),kTrainName.Data()));
2297
2298 ifstream in2;
2299 in2.open(Form("%s_merge.C_tmp", kTrainName.Data()));
2300 TString st2;
2301 while(in2.getline(cLine,250)){
2302 st2 += cLine;
2303 st2 += "\n";
2304 }
2305 index = st2.Index("gSystem->Load(\"libPhysics\");");
2306 index += strlen("gSystem->Load(\"libPhysics\");");
2307 TString add2 = "";
23adcac8 2308 add2 += "\n gSystem->AddIncludePath(\"./\"); \n";
4721d8c5 2309 if(gGrid&&kPluginAliRootVersion.Length()==0){
bbb42949 2310 /*
4721d8c5 2311 add2 += "\n // Dirty hack for TRD reference data \n";
2312 add2 += "\n gSystem->Setenv(\"ALICE_ROOT\",\"";
2313 add2 += Form("alien://%s/rootfiles/",gGrid->GetHomeDirectory());
2314 add2 += "\"); \n";
bbb42949 2315 */
4721d8c5 2316 }
2317 add2 += "// BKC \n\n";
2318 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2319 st2.Insert(index,add.Data());
2320
2321
2322 if(kUseDebug){
23adcac8 2323 // st2.Insert(index,"\n gROOT->ProcessLine(\".trace\"); // CKB \n");
4721d8c5 2324 }
2325
2326 if(kUseCPAR&&kPluginAliRootVersion.Length()==0){
46534866 2327 index = st2.Index("gSystem->AddIncludePath(\"-I$"); // uncomment $ALICE_ROOT include for par files
4721d8c5 2328 if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2329 st2.Insert(index,"// CKB comment out whehn no aliroot is provided \n //");
2330 }
2331
2332 // do not exclude the extra files from merign, this is done explicitly in this train script
92d850d5 2333 // index = st2.Index("mergeExcludes +="); // uncommen $ALICE_ROOT include for par files
2334 // if(index<0)Printf("%s:%d index out of bounds",(char*)__FILE__,__LINE__);
2335 // st2.Insert(index,"// CKB comment out, handled explicitly by the train macro \n //");
4721d8c5 2336
2337
2338 ofstream out2;
2339 out2.open(Form("%s_merge.C", kTrainName.Data()));
2340 if (out2.bad()) {
2341 return kFALSE;
2342 }
2343 out2 << st2 << endl;
2344 Printf("<<< Patching Merging Macro");
2345
2346
2347
c38e3b95 2348 return kTRUE;
2349
2350}