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