1 // runEMCalJetAnalysis.C
2 // =====================
3 // This macro can be used to run a jet analysis within the EMCal Jet Framework.
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"
10 // -> Analyze AODs (up to 96 files) locally given in files_aod.txt
11 // dataType = "AOD", useGrid = kFALSE, numLocalFiles = 96
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.
20 // Authors: R. Haake, S. Aiola
25 AliAnalysisGrid* 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);
29 //______________________________________________________________________________
30 void 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 = "file_aodlhc10d.txt",
34 const char* gridMode = "test", // set the grid run mode (can be "full", "test", "offline", "submit" or "terminate")
35 const char* pattern = "*ESDs/pass2/AOD135/*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/data/2010/LHC10d", // /alice/data/2011/LHC11d /alice/sim/2012/LHC12f2b dir on alien, where the files live (used on grid)
37 const char* runNumbers = /*126437*/" 126432 126425 126424 126422 126409 126408 126407 126406 126405 126404 126403 126359 126352 126351 126350 126285 126284 126283 126168 126167 126160 126158 126097 126090 126088 126082 126081 126078 126073 126008 126007 126004 125855 125851 125850 125849 125848 125847 125844 125843 125842 125633 125632 125630 125296 125134 125101 125100 125097 125085 125023 124751 122375 122374", // 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 = 3, // number of files analyzed locally
40 const char* runPeriod = "LHC10d", // set the run period (used on grid)
41 const char* uniqueName = "DJetNewCode", // 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 = kFALSE, // trigger, if MC handler should be used
46 // Here you have to specify additional code files you want to use but that are not in aliroot
47 const char* addCXXs = "AliAnalysisTaskSEDmesonsFilterCJ.cxx AliAnalysisTaskFlavourJetCorrelations.cxx",
48 const char* addHs = "AliAnalysisTaskSEDmesonsFilterCJ.h AliAnalysisTaskFlavourJetCorrelations.h",
50 // These two settings depend on the dataset and your quotas on the AliEN services
51 Int_t maxFilesPerWorker = 20,
52 Int_t workerTTL = 86000,
53 Int_t nfiletestmode = 1
57 // Some pre-settings and constants
59 enum AlgoType {kKT, kANTIKT};
60 enum JetType {kFULLJETS, kCHARGEDJETS, kNEUTRALJETS};
61 gSystem->SetFPEMask();
62 gSystem->Setenv("ETRAIN_ROOT", ".");
63 gSystem->Setenv("ETRAIN_PERIOD", runPeriod);
64 // change this objects to strings
65 TString usedData(dataType);
66 TString additionalCXXs(addCXXs);
67 TString additionalHs(addHs);
68 cout << dataType << " analysis chosen" << endl;
71 cout << "-- using AliEn grid.\n";
72 if (usedData == "sESD")
74 cout << "Skimmed ESD analysis not available on the grid!" << endl;
79 cout << "-- using local analysis.\n";
82 // Load necessary libraries
85 // Create analysis manager
86 AliAnalysisManager* mgr = new AliAnalysisManager(uniqueName);
88 // Check type of input and create handler for it
89 TString localFiles("-1");
92 localFiles = localfilename;
93 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddAODHandler.C");
94 AliAODInputHandler* aodH = AddAODHandler();
96 else if((usedData == "ESD") || (usedData == "sESD"))
98 if (usedData == "ESD")
99 localFiles = "files_esd.txt";
101 localFiles = "files_sesd.txt";
103 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddESDHandler.C");
104 AliESDInputHandler* esdH = AddESDHandler();
108 cout << "Data type not recognized! You have to specify ESD, AOD, or sESD!\n";
112 cout << "Using " << localFiles.Data() << " as input file list.\n";
114 gROOT->LoadMacro("AddTasksFlavourJet.C");
117 // const Int_t iCandtype=1 /*0 = D0, 1=Dstar...*/,
118 // const TString sCutFile = "cutsHF/D0toKpiCutsppRecVtxNoPileupRejNoEMCAL.root",
119 // const Double_t dJetPtCut = 1.,
120 // const Double_t dJetAreaCut = 0.,
121 // const Int_t iAccCut = 1,
122 // const TString sRunPeriod = "LHC10b",
123 // const Int_t uBeamType = 0,
124 // const UInt_t uTriggerMask = AliVEvent::kMB, /*for jets and phys sel; the D mesons trigger is defined in the cut object*/
125 // const Bool_t bIsMC=kFALSE,
126 // TString sText=""/*completes the name of the candidate task lists*/
128 AddTasksFlavourJet(1,"/data/Work/jets/testEMCalJetFramework/CutFilesMB/DStartoKpipiCuts_new.root",10.,0.,1,runPeriod,0,pSel,isMC,"");
130 // Set the physics selection for all given tasks
131 TObjArray *toptasks = mgr->GetTasks();
132 for (Int_t i=0; i<toptasks->GetEntries(); ++i)
134 AliAnalysisTaskSE *task = dynamic_cast<AliAnalysisTaskSE*>(toptasks->At(i));
137 if (task->InheritsFrom("AliPhysicsSelectionTask"))
139 ::Info("setPSel", "Set physics selection for %s (%s)", task->GetName(), task->ClassName());
140 task->SelectCollisionCandidates(pSel);
143 if(gridMode=="full") mgr->SetUseProgressBar(1, 25);
145 if (!mgr->InitAnalysis())
150 { // GRID CALCULATION
152 AliAnalysisGrid *plugin = CreateAlienHandler(uniqueName, gridDir, gridMode, runNumbers, nrunspermaster, pattern, additionalCXXs, additionalHs, maxFilesPerWorker, workerTTL, isMC);
153 plugin->SetNtestFiles(nfiletestmode);
155 mgr->SetGridHandler(plugin);
158 cout << "Starting GRID Analysis...";
159 if(gridMode=="test") mgr->SetDebugLevel(10);
160 else mgr->SetDebugLevel(0);
161 mgr->StartAnalysis("grid");
164 { // LOCAL CALCULATION
167 if (usedData == "AOD")
169 Printf("Run Create AOD Chain");
170 gROOT->LoadMacro("/data/Work/jets/testEMCalJetFramework/AODchainWithFriend/CreateAODChain.C");
171 chain = CreateAODChain(localFiles.Data(), numLocalFiles,0,kTRUE,kTRUE);
172 //Printf("Chain Friend has %d entries", ((TTree*)chain->GetFriend())->GetEntriesFast());
175 { // ESD or skimmed ESD
176 gROOT->LoadMacro("$ALICE_ROOT/PWG/EMCAL/macros/CreateESDChain.C");
177 chain = CreateESDChain(localFiles.Data(), numLocalFiles);
181 cout << "Starting LOCAL Analysis...";
182 mgr->SetDebugLevel(10);
183 mgr->StartAnalysis("local", chain);
187 //______________________________________________________________________________
190 // Load common libraries (better too many than too few)
191 gSystem->Load("libTree");
192 gSystem->Load("libVMC");
193 gSystem->Load("libGeom");
194 gSystem->Load("libGui");
195 gSystem->Load("libXMLParser");
196 gSystem->Load("libMinuit");
197 gSystem->Load("libMinuit2");
198 gSystem->Load("libProof");
199 gSystem->Load("libPhysics");
200 gSystem->Load("libSTEERBase");
201 gSystem->Load("libESD");
202 gSystem->Load("libAOD");
203 gSystem->Load("libOADB");
204 gSystem->Load("libANALYSIS");
205 gSystem->Load("libCDB");
206 gSystem->Load("libRAWDatabase");
207 gSystem->Load("libSTEER");
208 gSystem->Load("libEVGEN");
209 gSystem->Load("libANALYSISalice");
210 gSystem->Load("libCORRFW");
211 gSystem->Load("libTOFbase");
212 //gSystem->Load("libTOFrec");
213 gSystem->Load("libRAWDatabase.so");
214 gSystem->Load("libRAWDatarec.so");
215 gSystem->Load("libTPCbase.so");
216 gSystem->Load("libTPCrec.so");
217 gSystem->Load("libITSbase.so");
218 gSystem->Load("libITSrec.so");
219 gSystem->Load("libTRDbase.so");
220 gSystem->Load("libTENDER.so");
221 gSystem->Load("libSTAT.so");
222 gSystem->Load("libTRDrec.so");
223 gSystem->Load("libHMPIDbase.so");
224 gSystem->Load("libPWGPP.so");
225 gSystem->Load("libPWGHFbase");
226 gSystem->Load("libPWGDQdielectron");
227 gSystem->Load("libPWGHFhfe");
228 gSystem->Load("libPWGflowBase.so");
229 gSystem->Load("libPWGflowTasks.so");
230 gSystem->Load("libPWGHFvertexingHF");
231 gSystem->Load("libEMCALUtils");
232 gSystem->Load("libPHOSUtils");
233 gSystem->Load("libPWGCaloTrackCorrBase");
234 gSystem->Load("libEMCALraw");
235 gSystem->Load("libEMCALbase");
236 gSystem->Load("libEMCALrec");
237 gSystem->Load("libTRDbase");
238 gSystem->Load("libVZERObase");
239 gSystem->Load("libVZEROrec");
240 gSystem->Load("libTENDER");
241 gSystem->Load("libTENDERSupplies");
242 gSystem->Load("libPWGEMCAL");
243 gSystem->Load("libPWGGAEMCALTasks");
244 gSystem->Load("libPWGTools");
245 gSystem->Load("libPWGCFCorrelationsBase");
246 gSystem->Load("libPWGCFCorrelationsDPhi");
248 //load CGAL, Fastjet and SISCone
249 //gSystem->Load("libCGAL");
250 gSystem->Load("libfastjet");
251 gSystem->Load("libSISConePlugin");
253 gSystem->Load("libJETAN");
254 gSystem->Load("libFASTJETAN");
255 gSystem->Load("libPWGJEEMCALJetTasks");
259 gSystem->AddIncludePath("-Wno-deprecated");
260 gSystem->AddIncludePath("-I$ALICE_ROOT -I$ALICE_ROOT/include -I$ALICE_ROOT/EMCAL -I$ALICE_ROOT/PWG/EMCAL -I$ALICE_ROOT/PWGJE/EMCALJetTasks");
261 gSystem->AddIncludePath("-I$ALICE_ROOT/PWGDQ/dielectron -I$ALICE_ROOT/PWGHF/hfe");
262 gSystem->AddIncludePath("-I$ALICE_ROOT/JETAN -I$ALICE_ROOT/JETAN/fastjet");
265 AliAnalysisGrid* CreateAlienHandler(const char* uniqueName, const char* gridDir, const char* gridMode, const char* runNumbers, const Int_t nrunspermaster,
266 const char* pattern, TString additionalCode, TString additionalHeaders, Int_t maxFilesPerWorker,
267 Int_t workerTTL, Bool_t isMC)
270 TString tmpName(uniqueName);
272 // Only add current date and time when not in terminate mode! In this case the exact name has to be supplied by the user
273 if(strcmp(gridMode, "terminate"))
276 tmpName += currentTime.GetDate();
278 tmpName += currentTime.GetTime();
279 }else tmpName +="_20130412_122423";
281 TString tmpAdditionalLibs("");
282 tmpAdditionalLibs = Form("libTree.so libVMC.so libGeom.so libGui.so libXMLParser.so libMinuit.so libMinuit2.so libProof.so libPhysics.so libSTEERBase.so libESD.so libAOD.so libOADB.so libANALYSIS.so libCDB.so libRAWDatabase.so libSTEER.so libANALYSISalice.so libCORRFW.so libTOFbase.so libRAWDatabase.so libRAWDatarec.so libTPCbase.so libTPCrec.so libITSbase.so libITSrec.so libTRDbase.so libTENDER.so libSTAT.so libTRDrec.so libHMPIDbase.so libPWGPP.so libPWGHFbase.so libPWGDQdielectron.so libPWGHFhfe.so libPWGflowBase.so libPWGflowTasks.so libPWGHFvertexingHF.so libEMCALUtils.so libPHOSUtils.so libPWGCaloTrackCorrBase.so libEMCALraw.so libEMCALbase.so libEMCALrec.so libTRDbase.so libVZERObase.so libVZEROrec.so libTENDER.so libTENDERSupplies.so libPWGEMCAL.so libPWGGAEMCALTasks.so libPWGTools.so libPWGCFCorrelationsBase.so libPWGCFCorrelationsDPhi.so libCGAL.so libJETAN.so libfastjet.so libSISConePlugin.so libFASTJETAN.so libPWGJE.so libPWGmuon.so libPWGJEEMCALJetTasks.so %s %s",additionalCode.Data(),additionalHeaders.Data());
285 TString macroName("");
286 TString execName("");
288 macroName = Form("%s.C", tmpName.Data());
289 execName = Form("%s.sh", tmpName.Data());
290 jdlName = Form("%s.jdl", tmpName.Data());
292 AliAnalysisAlien *plugin = new AliAnalysisAlien();
293 plugin->SetOverwriteMode();
294 plugin->SetRunMode(gridMode);
296 // Here you can set the (Ali)ROOT version you want to use
297 plugin->SetAPIVersion("V1.1x");
298 plugin->SetROOTVersion("v5-34-05");
299 plugin->SetAliROOTVersion("v5-04-38-AN");
301 plugin->SetGridDataDir(gridDir); // e.g. "/alice/sim/LHC10a6"
302 plugin->SetDataPattern(pattern); //dir structure in run directory
303 plugin->SetFriendChainName("./AliAOD.VertexingHF.root");
305 plugin->SetRunPrefix("000");
307 plugin->AddRunList(runNumbers);
308 plugin->SetNrunsPerMaster(nrunspermaster);
310 plugin->SetGridWorkingDir(Form("%s",tmpName.Data()));
311 plugin->SetGridOutputDir("output");
313 plugin->SetAnalysisSource(additionalCode.Data());
314 plugin->SetAdditionalLibs(tmpAdditionalLibs.Data());
315 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 -g");
316 plugin->AddExternalPackage("boost::v1_43_0");
317 plugin->AddExternalPackage("cgal::v3.6");
318 plugin->AddExternalPackage("fastjet::v2.4.2");
320 plugin->SetDefaultOutputs(kTRUE);
322 plugin->SetMergeViaJDL(kTRUE);
323 plugin->SetOneStageMerging(kFALSE);
324 plugin->SetMaxMergeStages(2);
326 //plugin->SetMergeExcludes("");
327 plugin->SetAnalysisMacro(macroName.Data());
328 plugin->SetSplitMaxInputFileNumber(maxFilesPerWorker);
329 plugin->SetExecutable(execName.Data());
330 plugin->SetTTL(workerTTL);
331 plugin->SetInputFormat("xml-single");
332 plugin->SetJDLName(jdlName.Data());
334 plugin->SetSplitMode("se");