]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - PWGJE/FlavourJetTasks/macros/AnalysisTrainCorrJetsLocal.C
TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGJE / FlavourJetTasks / macros / AnalysisTrainCorrJetsLocal.C
... / ...
CommitLineData
1// runEMCalJetAnalysis.C
2// =====================
3// This macro can be used to run a jet analysis within the EMCal Jet Framework.
4//
5// Examples:
6// -> Analyze ESDs from the pA pilot run on the AliEn grid with your task in AnaClass.cxx/.h
7// dataType = "ESD", useGrid = kTRUE, pattern = "*ESDs/pass2/*ESDs.root", addCXXs = "AnaClass.cxx",
8// addHs = "AnaClass.h", gridDir = "/alice/data/2012/LHC12g", gridMode = "full", runNumbers = "188359 188362"
9//
10// -> Analyze AODs (up to 96 files) locally given in files_aod.txt
11// dataType = "AOD", useGrid = kFALSE, numLocalFiles = 96
12//
13// MERGING ON ALIEN
14// ++++++++++++++++
15// If you run on the grid, you can monitor the jobs with alimonitor.cern.ch. When enough of them are in DONE state,
16// you have to merge the output. This can be done automatically, if you just change the gridMode to "terminate" and
17// give the EXACT name of the task whose output should be merged in uniqueName.
18//
19//
20// Authors: R. Haake, S. Aiola
21
22#include <ctime>
23#include "TGrid.h"
24
25AliAnalysisGrid* CreateAlienHandler(const char* uniqueName, const char* gridDir, const char* gridMode, const char* runNumbers, const Int_t nrunspermaster,
26 const char* pattern, TString additionalCode, TString additionalHeaders, Int_t maxFilesPerWorker,
27 Int_t workerTTL, Bool_t isMC);
28
29//______________________________________________________________________________
30void AnalysisTrainCorrJetsLocal (
31 const char* dataType = "AOD", // set the analysis type, AOD, ESD or sESD
32 Bool_t useGrid = kTRUE, // local or grid
33 TString localfilename = "/data/Work/jets/testEMCalJetFramework/ptJdistrAug2nd/setMCtasks/map/inheritDev/files_LHC10f7a.txt",
34 const char* gridMode = "test", // set the grid run mode (can be "full", "test", "offline", "submit" or "terminate")
35 const char* pattern = "*AOD136/*AliAOD.root", //"*/*/AliAOD.root" "*ESDs/pass1/AOD106/*AliAOD.root", // file pattern (here one can specify subdirs like passX etc.) (used on grid)
36 const char* gridDir = "/alice/sim/LHC10f7a", // /alice/data/2011/LHC11d /alice/sim/2012/LHC12f2b dir on alien, where the files live (used on grid)
37 const char* runNumbers = /*114931 */" 115186 115193 115393 115401 115414 116102 116288 116402 116403 116562 116571 116574 116643 116645 117048 117050 117052 117053 117054 117059 117060 117063 117065 117077 117086 117092 117099 117109 117112 117116 117220 117222 119159 119161 119163 119841 119842 119844 119845 119846 119849 119853 119856 119859 119862 120067 120069 120072 120073 120076 120079 120244 120503 120504 120505 120616 120617 120671 120741 120750 120758 120820 120821 120822 120823 120824 120825 120829 122374 122375 124187 124191 124355 124358 124362 124367 124378 124380 124381 124604 124605 124606 124607 124608 124702 124746 124750 124751 125023 125085 125097 125100 125101 125133 125134 125139 125140 125156 125186 125296 125628 125630 125632 125633 125842 125843 125844 125847 125848 125849 125850 125851 125855 126004 126007 126008 126073 126078 126081 126082 126088 126090 126097 126158 126160 126167 126168 126283 126284 126285 126350 126351 126352 126359 126403 126404 126405 126406 126407 126408 126409 126422 126424 126425 126432 126437 127719 127724 127729 127730 127814 127819 127930 127940 128263 128778 128913 129536 129599 129639 129641 129654 129659 129666 129667 129723 129725 129726 129729 129735 129736 129738 129742 129744 129959 129960 129961 129962 129966 129983 130149 130151 130157 130158 130172 130178 130179 130342 130343 130354 130356 130358 130360 130375 130479 130480 130481 130517 130519 130520 130524 130526 130601 130608 130620 130621 130623 130628 130696 130704 130793 130795 130798 130799 130834 130840 130842 130844 130847 130848", // considered run numbers (used on grid) /*LHC12g 188359 188362, LHC11a 146860 146859*/ /*LHC12f2b 158285 159582 */
38 const Int_t nrunspermaster= 100,
39 UInt_t numLocalFiles = 10, // number of files analyzed locally
40 const char* runPeriod = "LHC10f7a", // set the run period (used on grid)
41 const char* uniqueName = "DJetNewCodeMCSandBchJ", // sets base string for the name of the task on the grid
42 UInt_t pSel = AliVEvent::kAny, // used event selection for every task except for the analysis tasks
43 Bool_t useTender = kFALSE, // trigger, if tender task should be used
44 Bool_t isMC = kTRUE, // trigger, if MC handler should be used
45 Bool_t isReco = kTRUE,
46 Bool_t isMap = kTRUE,
47 // Here you have to specify additional code files you want to use but that are not in aliroot
48 const char* addCXXs = "",
49 const char* addHs = "",
50
51 // These two settings depend on the dataset and your quotas on the AliEN services
52 Int_t maxFilesPerWorker = 20,
53 Int_t workerTTL = 86000,
54 Int_t nfiletestmode = 3
55 )
56{
57
58 // Some pre-settings and constants
59 TStopwatch watch;
60 watch.Start();
61
62 enum AlgoType {kKT, kANTIKT};
63 enum JetType {kFULLJETS, kCHARGEDJETS, kNEUTRALJETS};
64 gSystem->SetFPEMask();
65 gSystem->Setenv("ETRAIN_ROOT", ".");
66 gSystem->Setenv("ETRAIN_PERIOD", runPeriod);
67 // change this objects to strings
68 TString usedData(dataType);
69 TString additionalCXXs(addCXXs);
70 TString additionalHs(addHs);
71 cout << dataType << " analysis chosen" << endl;
72 if (useGrid)
73 {
74 cout << "-- using AliEn grid.\n";
75 if (usedData == "sESD")
76 {
77 cout << "Skimmed ESD analysis not available on the grid!" << endl;
78 return;
79 }
80 }
81 else
82 cout << "-- using local analysis.\n";
83
84
85 // Load necessary libraries
86 LoadLibs();
87
88 // Create analysis manager
89 AliAnalysisManager* mgr = new AliAnalysisManager(uniqueName);
90
91 // Check type of input and create handler for it
92 TString localFiles("-1");
93 if(usedData == "AOD")
94 {
95 localFiles = localfilename;
96 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddAODHandler.C");
97 AliAODInputHandler* aodH = AddAODHandler();
98 }
99 else if((usedData == "ESD") || (usedData == "sESD"))
100 {
101 if (usedData == "ESD")
102 localFiles = "files_esd.txt";
103 else
104 localFiles = "files_sesd.txt";
105
106 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddESDHandler.C");
107 AliESDInputHandler* esdH = AddESDHandler();
108 }
109 else
110 {
111 cout << "Data type not recognized! You have to specify ESD, AOD, or sESD!\n";
112 }
113
114 if(!useGrid)
115 cout << "Using " << localFiles.Data() << " as input file list.\n";
116
117 gROOT->LoadMacro("$ALICE_ROOT/PWGJE/FlavourJetTasks/macros/AddTasksFlavourJet.C");
118 //List of arguments:
119
120 // const Int_t iCandType = 1 /*0 = D0, 1=Dstar...*/,
121 // const TString sCutFile = "cutsHF/D0toKpiCutsppRecVtxNoPileupRejNoEMCAL.root",
122 // const Double_t dJetPtCut = 1.,
123 // const Double_t dJetAreaCut = 0.,
124 // const char *acctype = "TPC",
125 // const TString sRunPeriod = "LHC10b",
126 // const Int_t uBeamType = 0,
127 // const UInt_t uTriggerMask = AliVEvent::kMB, /*for jets; the D mesons trigger is defined in the cut object*/
128 // const Bool_t bIsMC = kFALSE,
129 // const Bool_t bIsReco = kFALSE,
130 // const Bool_t bIsMap = kFALSE,
131 // TString sText=""/*completes the name of the candidate task lists*/
132
133 //AddTasksFlavourJet(1,"/data/Work/jets/testEMCalJetFramework/CutFilesMB/DStartoKpipiCuts_new.root",10.,0.,"TPC",runPeriod,0,pSel,isMC,isReco,isMap,"");
134 AddTasksFlavourJet(1,"/data/Work/jets/testEMCalJetFramework/CutFilesMB/DStartoKpipiCuts.root",5.,0.,"TPC",runPeriod,0,pSel,isMC,isReco,isMap,"");
135
136 // Set the physics selection for all given tasks
137 TObjArray *toptasks = mgr->GetTasks();
138 for (Int_t i=0; i<toptasks->GetEntries(); ++i)
139 {
140 AliAnalysisTaskSE *task = dynamic_cast<AliAnalysisTaskSE*>(toptasks->At(i));
141 if (!task)
142 continue;
143 if (task->InheritsFrom("AliPhysicsSelectionTask"))
144 continue;
145 ::Info("setPSel", "Set physics selection for %s (%s)", task->GetName(), task->ClassName());
146 task->SelectCollisionCandidates(pSel);
147 }
148
149 if(gridMode=="full") mgr->SetUseProgressBar(1, 25);
150
151 if (!mgr->InitAnalysis())
152 return;
153 mgr->PrintStatus();
154
155 if (useGrid)
156 { // GRID CALCULATION
157
158 AliAnalysisGrid *plugin = CreateAlienHandler(uniqueName, gridDir, gridMode, runNumbers, nrunspermaster, pattern, additionalCXXs, additionalHs, maxFilesPerWorker, workerTTL, isMC);
159 plugin->SetNtestFiles(nfiletestmode);
160
161 mgr->SetGridHandler(plugin);
162
163 // start analysis
164 cout << "Starting GRID Analysis...";
165 if(gridMode=="test") mgr->SetDebugLevel(10);
166 else mgr->SetDebugLevel(0);
167 mgr->StartAnalysis("grid");
168 }
169 else
170 { // LOCAL CALCULATION
171
172 TChain* chain = 0;
173 if (usedData == "AOD")
174 {
175 Printf("Run Create AOD Chain");
176 gROOT->LoadMacro("/data/Work/jets/testEMCalJetFramework/AODchainWithFriend/CreateAODChain.C");
177 chain = CreateAODChain(localFiles.Data(), numLocalFiles,0,kTRUE,kTRUE);
178 //Printf("Chain Friend has %d entries", ((TTree*)chain->GetFriend())->GetEntriesFast());
179 }
180 else
181 { // ESD or skimmed ESD
182 gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/CreateESDChain.C");
183 chain = CreateESDChain(localFiles.Data(), numLocalFiles);
184 }
185
186 // start analysis
187 cout << "Starting LOCAL Analysis...";
188 mgr->SetDebugLevel(10);
189 mgr->StartAnalysis("local", chain);
190 }
191 watch.Stop();
192 watch.Print();
193}
194
195//______________________________________________________________________________
196void LoadLibs()
197{
198 // Load common libraries (better too many than too few)
199 gSystem->Load("libTree");
200 gSystem->Load("libVMC");
201 gSystem->Load("libGeom");
202 gSystem->Load("libGui");
203 gSystem->Load("libXMLParser");
204 gSystem->Load("libMinuit");
205 gSystem->Load("libMinuit2");
206 gSystem->Load("libProof");
207 gSystem->Load("libPhysics");
208 gSystem->Load("libSTEERBase");
209 gSystem->Load("libESD");
210 gSystem->Load("libAOD");
211 gSystem->Load("libOADB");
212 gSystem->Load("libANALYSIS");
213 gSystem->Load("libCDB");
214 gSystem->Load("libRAWDatabase");
215 gSystem->Load("libSTEER");
216 gSystem->Load("libEVGEN");
217 gSystem->Load("libANALYSISalice");
218 gSystem->Load("libCORRFW");
219 //gSystem->Load("libTOFbase");
220 //gSystem->Load("libTOFrec");
221 //gSystem->Load("libRAWDatabase.so");
222 //gSystem->Load("libRAWDatarec.so");
223 //gSystem->Load("libTPCbase.so");
224 //gSystem->Load("libTPCrec.so");
225 //gSystem->Load("libITSbase.so");
226 //gSystem->Load("libITSrec.so");
227 //gSystem->Load("libTRDbase.so");
228 //gSystem->Load("libTender.so");
229 //gSystem->Load("libSTAT.so");
230 //gSystem->Load("libTRDrec.so");
231 //gSystem->Load("libHMPIDbase.so");
232 gSystem->Load("libPWGTools.so");
233 //gSystem->Load("libPWGPP.so");
234 gSystem->Load("libPWGHFbase");
235 //gSystem->Load("libPWGDQdielectron");
236 //gSystem->Load("libPWGHFhfe");
237 gSystem->Load("libPWGflowBase.so");
238 gSystem->Load("libPWGflowTasks.so");
239 gSystem->Load("libPWGHFvertexingHF");
240 gSystem->Load("libEMCALUtils");
241 //gSystem->Load("libPHOSUtils");
242 //gSystem->Load("libPWGCaloTrackCorrBase");
243 gSystem->Load("libEMCALraw");
244 gSystem->Load("libEMCALbase");
245 //gSystem->Load("libEMCALrec");
246 //gSystem->Load("libTRDbase");
247 //gSystem->Load("libVZERObase");
248 //gSystem->Load("libVZEROrec");
249 gSystem->Load("libTender");
250 gSystem->Load("libTenderSupplies");
251 gSystem->Load("libESDfilter");
252 gSystem->Load("libPWGEMCAL");
253 gSystem->Load("libPWGGAEMCALTasks");
254 //gSystem->Load("libPWGCFCorrelationsBase");
255 //gSystem->Load("libPWGCFCorrelationsDPhi");
256
257 //load CGAL, Fastjet3
258 //gSystem->Load("libCGAL");
259 gSystem->Load("libfastjet");
260 gSystem->Load("libfastjet");
261 gSystem->Load("libsiscone");
262 gSystem->Load("libsiscone_spherical");
263 gSystem->Load("libfastjetplugins");
264 gSystem->Load("libfastjettools");
265 gSystem->Load("libfastjetcontribfragile");
266 gSystem->Load("libJETAN");
267 gSystem->Load("libFASTJETAN");
268 gSystem->Load("libPWGGAEMCALTasks");
269
270 gSystem->Load("libPWGJEEMCALJetTasks");
271 gSystem->Load("libPWGJEFlavourJetTasks");
272
273
274 // include paths
275 gSystem->AddIncludePath("-Wno-deprecated");
276 gSystem->AddIncludePath("-I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/EMCAL -I$ALICE_ROOT/PWG/EMCAL -I$ALICE_ROOT/PWGJE/EMCALJetTasks");
277 gSystem->AddIncludePath(" -I$ALICE_ROOT/PWGHF/ -I$ALICE_ROOT/PWGHF/base -I$ALICE_ROOT/PWGHF/vertexingHF -I$ALICE_ROOT/PWGJE/FlavourJetTasks");
278 gSystem->AddIncludePath("-I$ALICE_ROOT/PWGDQ/dielectron -I$ALICE_ROOT/PWGHF/hfe");
279 gSystem->AddIncludePath("-I$ALICE_ROOT/JETAN -I$ALICE_ROOT/JETAN/fastjet");
280}
281
282AliAnalysisGrid* CreateAlienHandler(const char* uniqueName, const char* gridDir, const char* gridMode, const char* runNumbers, const Int_t nrunspermaster,
283 const char* pattern, TString additionalCode, TString additionalHeaders, Int_t maxFilesPerWorker,
284 Int_t workerTTL, Bool_t isMC)
285{
286 TDatime currentTime;
287 TString tmpName(uniqueName);
288 /*
289 // Only add current date and time when not in terminate mode! In this case the exact name has to be supplied by the user
290 if(strcmp(gridMode, "terminate"))
291 {
292 tmpName += "_";
293 tmpName += currentTime.GetDate();
294 tmpName += "_";
295 tmpName += currentTime.GetTime();
296 }else tmpName +="_20130412_122423";
297 */
298 TString tmpAdditionalLibs("");
299 tmpAdditionalLibs = Form("libTree.so libVMC.so libGeom.so libGui.so libXMLParser.so libMinuit.so libMinuit2.so libProof.so libPhysics.so libSTEERBase.so libESD.so libESDfilter.so libAOD.so libOADB.so libANALYSIS.so libCDB.so libRAWDatabase.so libSTEER.so libANALYSISalice.so libCORRFW.so libPWGTools.so libPWGHFbase.so libPWGflowBase.so libPWGflowTasks.so libPWGHFvertexingHF.so libEMCALUtils.so libEMCALraw.so libEMCALbase.so libTender.so libPWGEMCAL.so libPWGGAEMCALTasks.so libPWGTools.so libCGAL.so libfastjet.so libsiscone.so libsiscone_spherical.so libfastjetplugins.so libfastjettools.so libfastjetcontribfragile.so libJETAN.so libFASTJETAN.so libPWGJE.so libPWGJEEMCALJetTasks.so libPWGJEFlavourJetTasks.so %s %s",additionalCode.Data(),additionalHeaders.Data());
300
301
302 TString macroName("");
303 TString execName("");
304 TString jdlName("");
305 macroName = Form("%s.C", tmpName.Data());
306 execName = Form("%s.sh", tmpName.Data());
307 jdlName = Form("%s.jdl", tmpName.Data());
308
309 AliAnalysisAlien *plugin = new AliAnalysisAlien();
310 plugin->SetOverwriteMode();
311 plugin->SetRunMode(gridMode);
312
313 // Here you can set the (Ali)ROOT version you want to use
314 plugin->SetAPIVersion("V1.1x");
315 plugin->SetROOTVersion(":v5-34-08-6");
316 plugin->SetAliROOTVersion("vAN-20141005");
317
318 plugin->SetGridDataDir(gridDir); // e.g. "/alice/sim/LHC10a6"
319 plugin->SetDataPattern(pattern); //dir structure in run directory
320 plugin->SetFriendChainName("./AliAOD.VertexingHF.root");
321 if (!isMC)
322 plugin->SetRunPrefix("000");
323
324 plugin->AddRunList(runNumbers);
325 plugin->SetNrunsPerMaster(nrunspermaster);
326
327 plugin->SetGridWorkingDir(Form("%s",tmpName.Data()));
328 plugin->SetGridOutputDir("output");
329
330 plugin->SetAnalysisSource(additionalCode.Data());
331 plugin->SetAdditionalLibs(tmpAdditionalLibs.Data());
332 plugin->AddIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/STEER/STEER -I$ALICE_ROOT/STEER/STEERBase -I$ALICE_ROOT/STEER/ESD -I$ALICE_ROOT/STEER/AOD -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/OADB -I$ALICE_ROOT/PWGHF -I$ALICE_ROOT/PWGHF/base -I$ALICE_ROOT/PWGHF/vertexingHF -I$ALICE_ROOT/PWG/FLOW/Base -I$ALICE_ROOT/PWG/FLOW/Tasks -I$ALICE_ROOT/PWGJE -I$ALICE_ROOT/JETAN -I$ALICE_ROOT/PWGJE/EMCALJetTasks -I$ALICE_ROOT/PWGJE/FlavourJetTasks -g");
333 plugin->AddExternalPackage("boost::v1_53_0");
334 plugin->AddExternalPackage("cgal::v4.4");
335 plugin->AddExternalPackage("fastjet::v3.0.6_1.012");
336
337 plugin->SetDefaultOutputs(kTRUE);
338 // merging via jdl
339 plugin->SetMergeViaJDL(kTRUE);
340 plugin->SetOneStageMerging(kFALSE);
341 plugin->SetMaxMergeStages(2);
342
343 //plugin->SetMergeExcludes("");
344 plugin->SetAnalysisMacro(macroName.Data());
345 plugin->SetSplitMaxInputFileNumber(maxFilesPerWorker);
346 plugin->SetExecutable(execName.Data());
347 plugin->SetTTL(workerTTL);
348 plugin->SetInputFormat("xml-single");
349 plugin->SetJDLName(jdlName.Data());
350 plugin->SetPrice(1);
351 plugin->SetSplitMode("se");
352
353 return plugin;
354}