updated for mini train analysis
[u/mrichter/AliRoot.git] / PWG4 / macros / AddTaskJets.C
CommitLineData
5bf1593b 1AliJetReader *CreateJetReader(Char_t *jr,UInt_t filterMask); // Common config\r
76f9015f 2AliJetFinder *CreateJetFinder(Char_t *jf,Float_t radius = -1);\r
0651dd18 3\r
5bf1593b 4AliAnalysisTaskJets *AddTaskJets(Char_t *jr, Char_t *jf,Float_t radius = -1,UInt_t filterMask = 0); // for the new AF\r
5Int_t AddTaskJetsDelta(char *nonStdFile = "",UInt_t filterMask = 0);\r
6AliAnalysisTaskJets *AddTaskJets(UInt_t filterMask = 0);\r
0651dd18 7\r
5bf1593b 8AliAnalysisTaskJets *AddTaskJets(UInt_t filterMask ){\r
9902ce1e 9 // fills the standard "jets" branch in the AOD\r
10 // need the ESDFilter to run before, to access the AODtracks\r
11 // Tracks selected by the first Filter (1<<0)\r
12 // needs to be adapted for different cuts\r
13 \r
14 // UA1 as standard chosen, since it is the most robust and simple JF\r
15 // R = 0.4 suffficient to provide accurate jet axis for correlation studies\r
16 // energy resolution suffers a little\r
17 // Acceptance of jets not limited by the Jet Finder but should be done\r
18 // by user to abs(eta) < 0.5 \r
19\r
5bf1593b 20 return AddTaskJets("AOD","UA1",0.4,filterMask);\r
9902ce1e 21\r
22}\r
23\r
24\r
25\r
5bf1593b 26Int_t AddTaskJetsDelta(char *nonStdFile,UInt_t filterMask){\r
b486b6c5 27\r
28 // Adds a whole set of jet finders all to be written\r
29 // to a delta AOD\r
30 \r
31 // this can in principle be done also with on the fly \r
32 // if we have an ESD input jet fidner task does automatically fetch the ouput aod\r
33\r
34 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
35 if (!mgr) {\r
36 ::Error("AddTaskJetsDelta", "No analysis manager to connect to.");\r
37 return 0;\r
38 } \r
39 \r
40 // Check the analysis type using the event handlers connected to the analysis manager.\r
41 //==============================================================================\r
42 if (!mgr->GetInputEventHandler()) {\r
43 ::Error("AddTaskJetsDelta", "This task requires an input event handler");\r
44 return 0;\r
45 }\r
46\r
47 AliAODHandler *aodh = (AliAODHandler*)mgr->GetOutputEventHandler();\r
48 if (!aodh) {\r
49 ::Error("AddTaskJetsDelta", "This task needs an output event handler");\r
50 return 0;\r
51 } \r
52\r
f6d6265b 53 TString outFile(nonStdFile);\r
b486b6c5 54\r
55 TString type = mgr->GetInputEventHandler()->GetDataType();\r
56\r
57 AliAnalysisTaskJets *jetana = 0;\r
58 Int_t iCount = 0;\r
59\r
60\r
8a4430e1 61 const char *cJF[7] = {"UA1","UA1","UA1","CDF","DA","SISCONE","FASTJET"};\r
62 const Float_t radius[7] = { 0.4, 0.7, 1.0, 0.7, 0.7, 0.4, 0.4};\r
63 const UInt_t flag[7] = { 6, 7, 7, 7, 7, 7, 7};\r
b486b6c5 64 // flag first bit AOD, second bit AODMC2 third bit AODMC2\r
65 // i.e. 7 all, 6 only MC2 and MC\r
66 // this stay at three\r
b486b6c5 67 const char *cReader[3] = {"AOD","AODMC","AODMC2"}; \r
68\r
8a4430e1 69 for(int i = 0; i< 7;i++){\r
b1e89487 70 for(int ib = 0;ib<3;ib++){ \r
b486b6c5 71 if(flag[i]&(1<<ib)){\r
5bf1593b 72 jetana = AddTaskJets(cReader[ib],cJF[i],radius[i],filterMask);\r
b486b6c5 73 if(jetana){\r
74 char *cRadius = "";\r
8a4430e1 75 if(radius[i]>0)cRadius = Form("%02d",(int)((radius[i]+0.01)*10.)); // add an offset beacuse of precision\r
b486b6c5 76 jetana->SetNonStdBranch(Form("jets%s_%s%s",cReader[ib],cJF[i],cRadius));\r
f6d6265b 77 if(outFile.Length()>0)jetana->SetNonStdOutputFile(outFile.Data());\r
b486b6c5 78 iCount++;\r
79 }\r
80 }\r
81 }\r
82 }\r
83 \r
84 Printf("Added %d JetFinders",iCount);\r
85}\r
86\r
87\r
88\r
89\r
90\r
91\r
5bf1593b 92AliAnalysisTaskJets *AddTaskJets(Char_t *jr, Char_t *jf, Float_t radius,UInt_t filterMask)\r
672f1183 93{\r
0651dd18 94 // Creates a jet finder task, configures it and adds it to the analysis manager.\r
672f1183 95\r
96 // Get the pointer to the existing analysis manager via the static access method.\r
97 //==============================================================================\r
98 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
99 if (!mgr) {\r
100 ::Error("AddTaskJets", "No analysis manager to connect to.");\r
101 return NULL;\r
102 } \r
103 \r
104 // Check the analysis type using the event handlers connected to the analysis manager.\r
105 //==============================================================================\r
106 if (!mgr->GetInputEventHandler()) {\r
107 ::Error("AddTaskJets", "This task requires an input event handler");\r
108 return NULL;\r
109 }\r
110\r
0511798f 111 AliAODHandler *aodh = (AliAODHandler*)mgr->GetOutputEventHandler();\r
112 if (!aodh) {\r
113 ::Error("AddTaskJets", "This task needs an output event handler");\r
114 return NULL;\r
115 } \r
116\r
117\r
672f1183 118 // Create the task and configure it.\r
119 //===========================================================================\r
120 AliAnalysisTaskJets *jetana;\r
5bf1593b 121 AliJetReader *er = CreateJetReader(jr,filterMask);\r
672f1183 122 // Define jet header and jet finder\r
76f9015f 123 AliJetFinder *jetFinder = CreateJetFinder(jf,radius);\r
0651dd18 124\r
672f1183 125 if (jetFinder){\r
672f1183 126 if (er) jetFinder->SetJetReader(er);\r
127 }\r
128\r
76f9015f 129 char *cRadius = "";\r
8a4430e1 130 if(radius>0)cRadius = Form("%02d",(int)((radius+0.01)*10.));\r
76f9015f 131\r
b486b6c5 132 jetana = new AliAnalysisTaskJets(Form("JetAnalysis%s_%s%s",jr,jf,cRadius));\r
06847475 133 TString type = mgr->GetInputEventHandler()->GetDataType();\r
134 if (type == "AOD") jetana->SetNonStdBranch(Form("jets%s",jf));\r
06847475 135 \r
be60d38b 136 TString c_jr(jr);\r
137 c_jr.ToLower();\r
138 TString c_jf(jf);\r
139 c_jf.ToLower();\r
140\r
b486b6c5 141 AliAnalysisDataContainer *cout_jet = mgr->CreateContainer(Form("jethist_%s_%s%s",c_jr.Data(),c_jf.Data(),cRadius), TList::Class(),\r
561a15fa 142 AliAnalysisManager::kOutputContainer, Form("%s:PWG4_jethist_%s_%s%s",AliAnalysisManager::GetCommonFileName(),\r
143 c_jr.Data(),c_jf.Data(),cRadius));\r
672f1183 144 // Connect jet finder to task.\r
145 jetana->SetJetFinder(jetFinder);\r
146 jetana->SetConfigFile("");\r
19027d3e 147 jetana->SetDebugLevel(0);\r
672f1183 148 mgr->AddTask(jetana);\r
149\r
150 // Create ONLY the output containers for the data produced by the task.\r
151 // Get and connect other common input/output containers via the manager as below\r
152 //==============================================================================\r
153 mgr->ConnectInput (jetana, 0, mgr->GetCommonInputContainer());\r
154// AOD output slot will be used in a different way in future\r
155 mgr->ConnectOutput (jetana, 0, mgr->GetCommonOutputContainer());\r
156 mgr->ConnectOutput (jetana, 1, cout_jet);\r
157 \r
158 return jetana;\r
159}\r
0651dd18 160\r
76f9015f 161AliJetFinder *CreateJetFinder(Char_t *jf,Float_t radius){\r
70144f07 162 AliJetFinder *jetFinder = 0;\r
0651dd18 163\r
164 switch (jf) {\r
165 case "CDF":\r
166 AliCdfJetHeader *jh = new AliCdfJetHeader();\r
167 jh->SetRadius(0.7);\r
8a4430e1 168 if(radius>0)jh->SetRadius(radius); \r
5bf1593b 169 jh->SetAODwrite(kTRUE);\r
170 // jh->SetDebugCDF(1);\r
0651dd18 171 jetFinder = new AliCdfJetFinder();\r
0651dd18 172 if (jh) jetFinder->SetJetHeader(jh);\r
173 break;\r
174\r
175 case "DA":\r
176 AliDAJetHeader *jh=new AliDAJetHeader();\r
177 jh->SetComment("DA jet code with default parameters");\r
178 jh->SelectJets(kTRUE);\r
4be01860 179 jh->SetRadius(0.7);\r
8a4430e1 180 if(radius>0)jh->SetRadius(radius);\r
198864bf 181 jh->SetEtMin(5.);\r
0651dd18 182 jetFinder = new AliDAJetFinder();\r
183 if (jh) jetFinder->SetJetHeader(jh);\r
184 break;\r
185\r
70144f07 186 case "FASTJET":\r
b486b6c5 187 // DEFAULT is ANTI KT\r
70144f07 188 AliFastJetHeaderV1 *jh = new AliFastJetHeaderV1();\r
189 jh->SetRparam(0.4); // setup parameters \r
190 if(radius>0)jh->SetRparam(radius);\r
191 jh->SetAlgorithm(2); // antikt from fastjet/JetDefinition.hh\r
0651dd18 192 jetFinder = new AliFastJetFinder();\r
0651dd18 193 if (jh) jetFinder->SetJetHeader(jh);\r
194 break;\r
195\r
8a4430e1 196 case "FASTKT":\r
197 AliFastJetHeaderV1 *jh = new AliFastJetHeaderV1();\r
198 jh->SetRparam(0.4); // setup parameters \r
199 if(radius>0)jh->SetRparam(radius);\r
200 jh->SetAlgorithm(0); // kt from fastjet/JetDefinition.hh\r
201 jetFinder = new AliFastJetFinder();\r
202 if (jh) jetFinder->SetJetHeader(jh);\r
203 break;\r
204\r
205 case "SISCONE":\r
206 AliSISConeJetHeader * jh = new AliSISConeJetHeader();\r
207\r
208 jh->SetJetEtaMax(1.5);\r
209 jh->SetJetEtaMin(-1.5);\r
210\r
211 //siscone parameters\r
212 jh->SetConeRadius(0.4); // default cone radius\r
213 if(radius>0)jh->SetConeRadius(radius); // cone radius\r
214\r
215 jh->SetOverlapThreshold(0.75); // overlap parameter, between 0 and 1 excluded!! 0.75 value is advised\r
216 jh->SetPtProtojetMin(0); // pt min of protojets\r
217 jh->SetMinJetPt(10); // Ptmin of jets (GeV)\r
218\r
219 //do you want to subtract BG (0 = no, 1 = yes)\r
220 jh->SetBGMode(0);\r
221\r
222 //for background\r
223 jh->SetRapRange( -0.9, 0.9); // rapidity range for subtracting background must be < ghostmaxrap-0.95*R\r
224 jh->SetPhiRange(0 , 2*TMath::Pi()); // phi range for subtracting background\r
225 \r
226 //to determine jets area\r
227 jh->SetBGAlgorithm(1); // algorithm for rho calculation : 0 = kT, 1 = Cambridge\r
228 jh->SetGhostEtaMax(4); // eta max where ghosts are generated \r
229 jh->SetGhostArea(0.05); // area of a ghost \r
230 jh->SetMeanGhostKt(1e-100); // average transverse momentum of the ghosts.\r
231 jh->SetAreaTypeNumber(4); // from 1 to 5 : 1 = active_area, 2 = active_area_explicit_ghosts, 3 = one_ghost_passive_area, 4 = passive_area, 5 = voronoi_area\r
232 jetFinder = new AliSISConeJetFinder();\r
233 if (jh) jetFinder->SetJetHeader(jh);\r
234 break;\r
235\r
0651dd18 236 case "UA1":\r
237 AliUA1JetHeaderV1 *jh=new AliUA1JetHeaderV1();\r
238 jh->SetComment("UA1 jet code with default parameters");\r
ba146e16 239 jh->BackgMode(0);\r
240 jh->SetRadius(0.4);\r
76f9015f 241 if(radius>0)jh->SetRadius(radius);\r
0651dd18 242 jh->SetEtSeed(4.);\r
c40ab9fa 243 jh->SetEtSeed(4.);\r
244 jh->SetNAcceptJets(6);\r
0651dd18 245 jh->SetLegoNbinPhi(432);\r
246 jh->SetLegoNbinEta(274);\r
247 jh->SetLegoEtaMin(-2);\r
248 jh->SetLegoEtaMax(+2);\r
9902ce1e 249 jh->SetMinJetEt(5.);\r
ba146e16 250 jh->SetJetEtaMax(1.5);\r
251 jh->SetJetEtaMin(-1.5);\r
0651dd18 252\r
253 jetFinder = new AliUA1JetFinderV1();\r
254 if (jh) jetFinder->SetJetHeader(jh);\r
255 break;\r
256\r
ba146e16 257 case "UA1MC":\r
258 AliUA1JetHeaderV1 *jh=new AliUA1JetHeaderV1();\r
259 jh->SetComment("UA1 jet code with default MC parameters");\r
260 jh->BackgMode(0);\r
261 jh->SetRadius(1.0);\r
76f9015f 262 if(radius>0)jh->SetRadius(radius);\r
ba146e16 263 jh->SetEtSeed(4.);\r
c40ab9fa 264 jh->SetNAcceptJets(6);\r
ba146e16 265 jh->SetLegoNbinPhi(432);\r
266 jh->SetLegoNbinEta(274);\r
267 jh->SetLegoEtaMin(-2);\r
268 jh->SetLegoEtaMax(+2);\r
9902ce1e 269 jh->SetMinJetEt(5.);\r
ba146e16 270 jh->SetJetEtaMax(1.5);\r
271 jh->SetJetEtaMin(-1.5);\r
ba146e16 272 jetFinder = new AliUA1JetFinderV1();\r
273 if (jh) jetFinder->SetJetHeader(jh);\r
274 break;\r
70144f07 275 default:\r
276 Printf("\n >>>>>>> AddTaskJets Error Wrong jet finder selected\n");\r
277 break;\r
0651dd18 278 }\r
279\r
280 return jetFinder;\r
281\r
282}\r
283\r
5bf1593b 284AliJetReader *CreateJetReader(Char_t *jr,UInt_t filterMask){\r
0651dd18 285 AliJetReader *er = 0;\r
286\r
287 switch (jr) {\r
288 case "MC":\r
289 AliJetKineReaderHeader *jrh = new AliJetKineReaderHeader();\r
290 jrh->SetComment("MC full Kinematics");\r
291 jrh->SetFastSimTPC(kFALSE);\r
292 jrh->SetFastSimEMCAL(kFALSE);\r
293 jrh->SetPtCut(0.);\r
294 jrh->SetFiducialEta(-2.1,2.1); // to take all MC particles default is 0 .9 \r
295 // Define reader and set its header \r
296 er = new AliJetKineReader();\r
297 er->SetReaderHeader(jrh);\r
298 break;\r
ba146e16 299 case "MC2":\r
300 AliJetKineReaderHeader *jrh = new AliJetKineReaderHeader();\r
5dbee319 301 jrh->SetComment("MC full Kinematics spearate config charged only");\r
ba146e16 302 jrh->SetFastSimTPC(kFALSE);\r
303 jrh->SetFastSimEMCAL(kFALSE);\r
5dbee319 304 jrh->SetChargedOnly(kTRUE);\r
ba146e16 305 jrh->SetPtCut(0.);\r
306 jrh->SetFiducialEta(-2.1,2.1); // to take all MC particles default is 0 .9 \r
307 // Define reader and set its header \r
308 er = new AliJetKineReader();\r
309 er->SetReaderHeader(jrh);\r
310 break;\r
0651dd18 311 case "ESD":\r
312 AliJetESDReaderHeader *jrh = new AliJetESDReaderHeader();\r
313 jrh->SetComment("Testing");\r
314 jrh->SetFirstEvent(0);\r
315 jrh->SetLastEvent(1000);\r
316 jrh->SetPtCut(0.);\r
317 jrh->SetReadSignalOnly(kFALSE);\r
318 // Define reader and set its header \r
319 er = new AliJetESDReader();\r
320 er->SetReaderHeader(jrh);\r
321 break;\r
322\r
323 case "AOD":\r
324 AliJetAODReaderHeader *jrh = new AliJetAODReaderHeader();\r
325 jrh->SetComment("AOD Reader");\r
326 jrh->SetPtCut(0.);\r
8a4430e1 327 jrh->SetTestFilterMask(16); // Change this one for a different set of cuts\r
5bf1593b 328 if(filterMask>0)jrh->SetTestFilterMask(filterMask); \r
0651dd18 329 // Define reader and set its header\r
330 er = new AliJetAODReader();\r
331 er->SetReaderHeader(jrh);\r
332 break;\r
0c43aaa9 333 case "AODMC":\r
334 AliJetAODReaderHeader *jrh = new AliJetAODReaderHeader();\r
335 jrh->SetComment("AOD MC Reader");\r
336 jrh->SetPtCut(0.);\r
337 jrh->SetFiducialEta(-2.1,2.1); // to take all MC particles default is 0.9\r
338 jrh->SetReadAODMC(1);// 1 all primary MC , 2 all primary charged\r
339 // Define reader and set its header\r
340 er = new AliJetAODReader();\r
341 er->SetReaderHeader(jrh);\r
342 break;\r
5dbee319 343 case "AODMC2":\r
344 AliJetAODReaderHeader *jrh = new AliJetAODReaderHeader();\r
345 jrh->SetComment("AOD MC Reader");\r
346 jrh->SetPtCut(0.);\r
347 jrh->SetFiducialEta(-2.1,2.1); // to take all MC particles default is 0.9\r
348 jrh->SetReadAODMC(2);// 1 all primary MC , 2 all primary charged\r
349 // Define reader and set its header\r
350 er = new AliJetAODReader();\r
351 er->SetReaderHeader(jrh);\r
352 break;\r
353\r
0651dd18 354 default:\r
355 ::Error("AddTaskJets", "Wrong jet reader selected\n");\r
356 return 0;\r
357 }\r
358\r
359 return er;\r
360\r
361}\r