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