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