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