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