TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / trains / AODTrain.C
CommitLineData
33438b4c 1/**
2 * @file AODTrain.C
3 * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk>
4 * @date Wed Feb 6 23:10:29 2013
5 *
6 * @brief Setup of train like the `official' AODtrain.C script
7 *
8 *
9 * @ingroup pwglf_forward_trains_examples
10 */
11#ifndef __CINT__
12# include <AliAnalysisManager.h>
13#else
14class AliAnalysisManager;
15#endif
16#include "TrainSetup.C"
17
18/**
19 * Setup of train like the `official' AODtrain.C script
20 *
21 * @ingroup pwglf_forward_trains_examples
22 */
23class AODTrain : public TrainSetup
24{
25public:
26 //------------------------------------------------------------------
27 /**
28 * Constructor
29 *
30 * @param name Name of job
31 */
32 AODTrain(const char* name="myTest") : TrainSetup(name)
33 {
34 fOptions.Set("type", "ESD");
35 // over all options
36 fOptions.Add("collision", "TYPE", "Collision system", 0);
37 fOptions.Add("year", "YEAR", "Year", 2011);
38 fOptions.Add("cdb", "Connect to CDB", true);
39 fOptions.Add("physics-selection", "Use PhysicsSelection", true);
40 fOptions.Add("tender", "Use of Tenders", false);
41 fOptions.Add("centrality", "Use centrality", false);
42 fOptions.Add("v0-tender", "Use of V0 tender", false);
43 fOptions.Add("track-refs", "Also read track references");
44 fOptions.Add("kinematics-filter", "Use kinematics fitler");
45 fOptions.Add("sys-info", "Use sys info");
46 fOptions.Add("run", "RUNNUMBER", "Set initial run number", 0);
47
48 // Task options
49 fOptions.Add("esd-filter", "Use ESD fitler", true);
50 fOptions.Add("muon-copy", "Make additional MUON specific AOD", true);
51 fOptions.Add("jetan", "Use Jet analysis", true);
52 fOptions.Add("jetan-delta", "Make Jet analysis delta AOD", true);
53 fOptions.Add("vertexing", "Use PWGHF vertexing", true);
54 fOptions.Add("jpsi-filter", "Use PWGDQ J/Psi filter", false);
55 fOptions.Add("d0-decay", "Use PWGHF D0->h+h", true);
56 fOptions.Add("high-pt", "Use high pt", true);
57 fOptions.Add("forward-nch", "Forward charged particle", true);
58 // Other
59 fOptions.Add("pid-response", "Use PID response", true);
60 fOptions.Add("pid-qa", "Do PID QA", true);
61 }
62 //------------------------------------------------------------------
63 /**
64 * Create our tasks
65 *
66 * @param mgr Manager
67 */
68 void CreateTasks(AliAnalysisManager* mgr)
69 {
70
ba144d92 71 fRailway->LoadLibrary("libCORRFW");
33438b4c 72
73 Bool_t cdb = fOptions.Has("cdb");
74 Bool_t tender = fOptions.Has("tender");
75 Bool_t physicsSelection = fOptions.Has("physics-selection");
76
77 if (cdb || tender) {
ba144d92 78 fRailway->LoadLibrary("libCDB");
79 fRailway->LoadLibrary("libProof");
80 fRailway->LoadLibrary("libRAWDatabase");
81 fRailway->LoadLibrary("libSTEER");
82 fRailway->LoadLibrary("libSTAT");
83 fRailway->LoadLibrary("libTRDbase");
84 fRailway->LoadLibrary("libVZERObase");
85 fRailway->LoadLibrary("libTPCbase");
86 fRailway->LoadLibrary("libITSbase");
87 fRailway->LoadLibrary("libHMPIDbase");
af472fff 88 fRailway->LoadLibrary("libTender");
89 fRailway->LoadLibrary("libTenderSupplies");
33438b4c 90 }
91
92 if (fOptions.Has("sys-info")) mgr->SetNSysInfo(100);
93
94 // AliAnalysisTask* task = 0;
95 AliAnalysisTaskSE* seTask = 0;
96
97 AliAnalysisManager::SetCommonFileName("AODQA.root");
98 if (tender)
ba144d92 99 CoupleCar("$ALICE_ROOT/ANALYSIS/TenderSupplies/AddTaskTender.C",
33438b4c 100 Form("%d", fOptions.Has("v0-tender")));
101
102 if (fOptions.Has("pid-response"))
ba144d92 103 CoupleCar("AddTaskPIDResponse.C");
33438b4c 104
105 if (fOptions.Has("pid-qa")) {
ba144d92 106 seTask = CoupleSECar("AddTaskPIDqa.C");
33438b4c 107 seTask->SelectCollisionCandidates(AliVEvent::kAny);
108 }
109
110 if (cdb && !tender) {
ba144d92 111 fRailway->LoadLibrary("libRAWDatarec");
112 fRailway->LoadLibrary("libTRDrec");
113 fRailway->LoadLibrary("libVZEROrec");
114 fRailway->LoadLibrary("libTPCrec");
115 fRailway->LoadLibrary("libITSrec");
116 fRailway->LoadLibrary("libPWGPP");
33438b4c 117
ba144d92 118 // CoupleCar("$ALICE_ROOT/PWGPP/PilotTrain/AddTaskCDBconnect.C");
33438b4c 119 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/PilotTrain/AddTaskCDBconnect.C");
120 gROOT->ProcessLine(Form("AddTaskCDBconnect(%d)", fOptions.AsInt("run")));
121 gROOT->ProcessLine("AliCDBManager* cdb = AliCDBManager::Instance();"
122 "cdb->SetDefaultStorage(\"raw://\");");
123 }
124
125 if (fOptions.Has("high-pt"))
ba144d92 126 CoupleCar("AddTaskFilteredTree.C");
33438b4c 127
128 if (fOptions.Has("esd-filter")) {
ba144d92 129 fRailway->LoadLibrary("PWGmuon");
33438b4c 130 if (fOptions.Has("muon-copy")) {
131 mgr->RegisterExtraFile("AliAOD.Muons.root");
132 mgr->RegisterExtraFile("AliAOD.Dimuons.root");
133 }
134 Int_t runFlag = (fOptions.AsInt("year") % 100) * 100;
135 TString args =
136 TString::Format("%d,%d,false,false,false,false,true,false,false,%d",
137 fOptions.Has("kinematics-filter"),
138 fOptions.Has("muon-copy"), runFlag);
ba144d92 139 CoupleCar("AddTaskESDFilter.C", args);
33438b4c 140 }
141
142 Bool_t vertexing = fOptions.Has("vertexing");
143 Bool_t d0Decay = fOptions.Has("d0-decay");
144 if (vertexing || d0Decay) {
145 TString src = "$ALICE_ROOT/PWGHF/vertexingHF/ConfigVertexingHF.C";
146 if (fOptions.AsInt("collision") == 1)
147 src.ReplaceAll(".C", "highmult.C");
148 TFile::Cp(src, "ConfigVertexingHF.C");
ba144d92 149 fRailway->LoadAux("ConfigVertexingHF.C");
33438b4c 150 }
151
152 if (vertexing) {
ba144d92 153 fRailway->LoadLibrary("PWGflowBase");
154 fRailway->LoadLibrary("PWGflowTasks");
155 fRailway->LoadLibrary("PWGHFvertexingHF");
33438b4c 156 seTask =
ba144d92 157 CoupleSECar("$ALICE_ROOT/PWGHF/vertexingHF/macros/AddTaskVertexingHF.C");
33438b4c 158 seTask->SelectCollisionCandidates(0);
159 mgr->RegisterExtraFile("AliAOD.VertexingHF.root");
160 }
161
162 if (fOptions.Has("jpsi-filtering")) {
ba144d92 163 fRailway->LoadLibrary("PWGDQdielectron");
33438b4c 164 seTask =
ba144d92 165 CoupleSECar("$ALICE_ROOT/PWGDQ/dielectron/macros/AddTaskJPSIFilter.C");
33438b4c 166 seTask->SelectCollisionCandidates(0);
167 mgr->RegisterExtraFile("AliAOD.Dielectron.root");
168 }
169
170 if (d0Decay)
ba144d92 171 CoupleCar("$ALICE_ROOT/PWGHF/vertexingHF/AddD2HTrain.C",
33438b4c 172 "kFALSE, 1,0,0,0,0,0,0,0,0,0,0");
173
174 if (fOptions.Has("jetan")) {
ba144d92 175 fRailway->LoadLibrary("JETAN");
33438b4c 176
177 Bool_t jetanDelta = fOptions.Has("jetan-delta");
178 if (jetanDelta) {
ba144d92 179 fRailway->LoadLibrary("CGAL");
180 fRailway->LoadLibrary("fastjet");
181 fRailway->LoadLibrary("siscone");
182 fRailway->LoadLibrary("SISConePlugin");
183 fRailway->LoadLibrary("FASTJETAN");
33438b4c 184 // --- For newer fastjet ---
ba144d92 185 // fRailway->LoadLibrary("CGAL");
186 // fRailway->LoadLibrary("fastjet");
187 // fRailway->LoadLibrary("fastjettools");
188 // fRailway->LoadLibrary("siscone");
189 // fRailway->LoadLibrary("siscone_spherical");
190 // fRailway->LoadLibrary("fastjetplugins");
191 // fRailway->LoadLibrary("FASTJETAN");
33438b4c 192 }
193
194 // Write script to do this - avoid useless links against loadable
195 // library
196 std::ofstream o("AddJets.C");
197 o << "void AddJets(AliAnalysisManager* mgr,\n"
198 << " UInt_t highPt,\n"
199 << " const char* deltaAOD,\n"
200 << " Bool_t useDelta,\n"
201 << " Bool_t usePS,\n"
202 << " Bool_t pbpb,\n"
203 << " Float_t etaCut,\n"
204 << " Float_t centLow,\n"
205 << " Float_t centHigh)\n"
206 << "{\n"
207 << " gROOT->SetMacroPath(Form(\"%s:$ALICE_ROOT/PWGJE/macros\",\n"
208 << " gROOT->GetMacroPath()));\n"
209 << " \n"
210 << " gROOT->LoadMacro(\"AddTaskJets.C\");\n"
211 << " AliAnalysisTaskJets *jTask = 0;\n"
212 << " jTask = AddTaskJets(\"AOD\",\"UA1\",0.4,highPt,1.,0);\n"
213 << " jTask->SetNonStdOutputFile(deltaAOD);\n"
214 << " \n"
215 << " if (useDelta) {\n"
216 << " mgr->RegisterExtraFile(deltaAOD);\n"
217 << " if (pbpb) {\n"
218 << " jTask = AddTaskJets(\"AOD\",\"UA1\",0.4,highPt,1.,2);\n"
219 << " jTask->SetNonStdOutputFile(deltaAOD);\n"
220 << " }\n"
221 << " }\n"
222 << " \n";
223 o << " jTask =AddTaskJets(\"AOD\",\"SISCONE\",0.4,highPt,0.15,0);\n"
224 << " jTask->SetNonStdOutputFile(deltaAOD);\n"
225 << " TString subBranches = jTask->GetNonStdBranch();\n"
226 << " \n";
227 o << " gROOT->LoadMacro(\"AddTaskJetCluster.C\");\n"
228 << " AliAnalysisTaskJetCluster* cTask = 0;\n"
229 << " cTask = AddTaskJetCluster(\"AOD\",\"\",highPt,usePS,\n"
230 << " \"KT\",0.4,0,1,deltaAOD,0.15,etaCut,0);\n"
231 << " cTask->SetBackgroundCalc(kTRUE);\n"
232 << " cTask->SetNRandomCones(10);\n"
233 << " cTask->SetCentralityCut(centLow,centHigh);\n"
234 << " cTask->SetGhostEtamax(etaCut);\n"
235 << " TString bgBranch = Form(\"%s_%s\",\n"
236 << " AliAODJetEventBackground::StdBranchName(),\n"
237 << " cTask->GetJetOutputBranch());\n"
238 << " \n";
239 o << " cTask = AddTaskJetCluster(\"AOD\",\"\",highPt,usePS,\n"
240 << " \"ANTIKT\",0.4,2,1,deltaAOD,0.15);\n"
241 << " cTask->SetNRandomCones(10);\n"
242 << " cTask->SetCentralityCut(centLow,centHigh);\n"
243 << " if (pbpb) cTask->SetBackgroundBranch(bgBranch);\n"
244 << " subBranches += Form(\" %s\",cTask->GetJetOutputBranch());\n"
245 << " \n";
246 o << " cTask = AddTaskJetCluster(\"AOD\",\"\",highPt,usePS,\n"
247 << "\"ANTIKT\",0.2,0,1,deltaAOD,0.15);\n"
248 << " cTask->SetCentralityCut(centLow,centHigh);\n"
249 << " if (pbpb) cTask->SetBackgroundBranch(bgBranch);\n"
250 << " subBranches += Form(\" %s\",cTask->GetJetOutputBranch());\n"
251 << " \n";
252 o << " if (pbpb) {\n"
253 << " gROOT->LoadMacro(\"AddTaskJetBackgroundSubtract.C\");\n"
254 << " AliAnalysisTaskJetBackgroundSubtract* sTask = 0;\n"
255 << " sTask = AddTaskJetBackgroundSubtract(subBranches,1,\"B0\",\n"
256 << " \"B%d\");\n"
257 << " sTask->SetBackgroundBranch(bgBranch);\n"
258 << " sTask->SetNonStdOutputFile(deltaAOD);\n"
259 << " }\n"
260 << "}\n"
261 << std::endl;
262 o.close();
263
264 UInt_t highPtFilterMask = 272;
265 TString deltaAODJetName = "AliAOD.Jets.root";
266 Float_t trackEtaWindow = 0.9;
267 Float_t centLow = 0;
268 Float_t centHigh = 0;
269 gROOT->Macro(Form("./AddJets.C((AliAnalysisManager*)%p,"
270 "%d,\"%s\",%d,%d,%d,%f,%f,%f);",
271 mgr, highPtFilterMask, deltaAODJetName.Data(),
272 jetanDelta, physicsSelection,
273 fOptions.AsInt("collision") == 1, // pbpb
274 trackEtaWindow, centLow, centHigh));
275 }
276 if (fOptions.Has("forward-nch") && physicsSelection) {
277 Bool_t fwdMC = (mgr->GetMCtruthEventHandler() != 0 &&
278 fOptions.Has("track-refs"));
279
ba144d92 280 CoupleCar("$ALICE_ROOT/PWGLF/FORWARD/analysis2/AddTaskForwardMult.C",
33438b4c 281 Form("%d", fwdMC));
282 }
283 }
284 //------------------------------------------------------------------
285 /**
286 * Create physics selection, and add to manager
287 *
288 * @param mc Whether this is for MC
289 * @param mgr Manager
290 */
291 virtual void CreatePhysicsSelection(Bool_t mc, AliAnalysisManager* mgr)
292 {
293 if (fOptions.Has("physics-selection"))
294 TrainSetup::CreatePhysicsSelection(mc, mgr);
295 }
296 //------------------------------------------------------------------
297 /**
298 * Create centrality selection, and add to manager
299 *
300 * @param mc Whether this is for MC
301 * @param mgr Manager
302 */
303 virtual void CreateCentralitySelection(Bool_t mc, AliAnalysisManager* mgr)
304 {
305 if (fOptions.Has("centrality"))
306 TrainSetup::CreateCentralitySelection(mc, mgr);
307 }
308 //------------------------------------------------------------------
309 /**
310 * Create MC input handler
311 *
312 * @param mc Assume monte-carlo input
313 *
314 * @return
315 */
316 virtual AliVEventHandler* CreateMCHandler(UShort_t /*type*/, bool mc)
317 {
318 if (!mc) return 0;
319 AliMCEventHandler* mcHandler = new AliMCEventHandler();
320 mcHandler->SetReadTR(fOptions.Has("track-refs"));
321 return mcHandler;
322 }
323 //------------------------------------------------------------------
324 /**
325 * Get the name of this set-up
326 *
327 * @return Name of this setup
328 */
329 const char* ClassName() const { return "AODTrain"; }
330};
331//
332// EOF
333//