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