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