]>
Commit | Line | Data |
---|---|---|
1 | #include "TChain.h" | |
2 | #include "TTree.h" | |
3 | #include "TList.h" | |
4 | #include "TH1F.h" | |
5 | ||
6 | #include "AliAnalysisTask.h" | |
7 | #include "AliAnalysisManager.h" | |
8 | ||
9 | #include "AliGenEventHeader.h" | |
10 | #include "AliESDEvent.h" | |
11 | #include "AliESDInputHandler.h" | |
12 | #include "AliMCEventHandler.h" | |
13 | #include "AliMCEvent.h" | |
14 | #include "AliStack.h" | |
15 | #include "AliESDVertex.h" | |
16 | #include "AliPhysicsSelection.h" | |
17 | ||
18 | #include "AliProtonQAAnalysis.h" | |
19 | #include "AliProtonAnalysisBase.h" | |
20 | #include "AliAnalysisTaskProtonsQA.h" | |
21 | ||
22 | //----------------------------------------------------------------- | |
23 | // AliAnalysisTakProtonsQA class | |
24 | // This is the task to run the \bar{p}/p QA analysis | |
25 | // Origin: Panos Christakoglou | Panos.Christakoglou@cern.ch | |
26 | //----------------------------------------------------------------- | |
27 | ||
28 | ClassImp(AliAnalysisTaskProtonsQA) | |
29 | ||
30 | //________________________________________________________________________ | |
31 | AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA() | |
32 | : AliAnalysisTask(), fESD(0), fMC(0), fHistEventStats(0), | |
33 | fList0(0), fList1(0), fList2(0), fList3(0), | |
34 | fList4(0), fList5(0), fList6(0), fList7(0), fList8(0), | |
35 | fProtonQAAnalysis(0) { | |
36 | //Dummy constructor | |
37 | } | |
38 | ||
39 | //________________________________________________________________________ | |
40 | AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA(const char *name) | |
41 | : AliAnalysisTask(name, ""), fESD(0), fMC(0), fHistEventStats(0), | |
42 | fList0(0), fList1(0), fList2(0), fList3(0), | |
43 | fList4(0), fList5(0), fList6(0), fList7(0), fList8(0), | |
44 | fProtonQAAnalysis(0) { | |
45 | // Constructor | |
46 | ||
47 | // Define input and output slots here | |
48 | // Input slot #0 works with a TChain | |
49 | DefineInput(0, TChain::Class()); | |
50 | // Output slot #0 writes into a TList container | |
51 | DefineOutput(0, TList::Class()); | |
52 | DefineOutput(1, TList::Class()); | |
53 | DefineOutput(2, TList::Class()); | |
54 | DefineOutput(3, TList::Class()); | |
55 | DefineOutput(4, TList::Class()); | |
56 | DefineOutput(5, TList::Class()); | |
57 | DefineOutput(6, TList::Class()); | |
58 | DefineOutput(7, TList::Class()); | |
59 | DefineOutput(8, TList::Class()); | |
60 | DefineOutput(9, TH1F::Class()); | |
61 | } | |
62 | ||
63 | //________________________________________________________________________ | |
64 | void AliAnalysisTaskProtonsQA::ConnectInputData(Option_t *) { | |
65 | // Connect ESD or AOD here | |
66 | // Called once | |
67 | ||
68 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
69 | if (!tree) { | |
70 | Printf("ERROR: Could not read chain from input slot 0"); | |
71 | } else { | |
72 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); | |
73 | ||
74 | if (!esdH) { | |
75 | Printf("ERROR: Could not get ESDInputHandler"); | |
76 | } else | |
77 | fESD = esdH->GetEvent(); | |
78 | } | |
79 | ||
80 | AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
81 | if (!mcH) { | |
82 | Printf("ERROR: Could not retrieve MC event handler"); | |
83 | } | |
84 | else | |
85 | fMC = mcH->MCEvent(); | |
86 | } | |
87 | ||
88 | //________________________________________________________________________ | |
89 | void AliAnalysisTaskProtonsQA::CreateOutputObjects() { | |
90 | // Create histograms | |
91 | // Called once | |
92 | TString gCutName[5] = {"Total","Triggered","Offline trigger", | |
93 | "Vertex","Analyzed"}; | |
94 | fHistEventStats = new TH1F("fHistEventStats", | |
95 | "Event statistics;;N_{events}", | |
96 | 5,0.5,5.5); | |
97 | for(Int_t i = 1; i <= 5; i++) | |
98 | fHistEventStats->GetXaxis()->SetBinLabel(i,gCutName[i-1].Data()); | |
99 | ||
100 | fList0 = new TList(); | |
101 | fList0 = fProtonQAAnalysis->GetGlobalQAList(); | |
102 | ||
103 | fList1 = new TList(); | |
104 | fList1 = fProtonQAAnalysis->GetPDGList(); | |
105 | ||
106 | fList2 = new TList(); | |
107 | fList2 = fProtonQAAnalysis->GetMCProcessesList(); | |
108 | ||
109 | fList3 = new TList(); | |
110 | fList3 = fProtonQAAnalysis->GetAcceptedCutList(); | |
111 | ||
112 | fList4 = new TList(); | |
113 | fList4 = fProtonQAAnalysis->GetRejectedCutList(); | |
114 | ||
115 | fList5 = new TList(); | |
116 | fList5 = fProtonQAAnalysis->GetAcceptedDCAList(); | |
117 | ||
118 | fList6 = new TList(); | |
119 | fList6 = fProtonQAAnalysis->GetEfficiencyQAList(); | |
120 | ||
121 | fList7 = new TList(); | |
122 | fList7 = fProtonQAAnalysis->GetVertexQAList(); | |
123 | ||
124 | fList8 = new TList(); | |
125 | fList8 = fProtonQAAnalysis->GetCutEfficiencyList(); | |
126 | } | |
127 | ||
128 | //________________________________________________________________________ | |
129 | void AliAnalysisTaskProtonsQA::Exec(Option_t *) { | |
130 | // Main loop | |
131 | // Called for each event | |
132 | ||
133 | if (!fESD) { | |
134 | Printf("ERROR: fESD not available"); | |
135 | return; | |
136 | } | |
137 | ||
138 | if (!fMC) { | |
139 | Printf("ERROR: Could not retrieve MC event"); | |
140 | return; | |
141 | } | |
142 | ||
143 | AliGenEventHeader *header = fMC->GenEventHeader(); | |
144 | if (!header) { | |
145 | Printf("ERROR: Could not retrieve the header"); | |
146 | return; | |
147 | } | |
148 | ||
149 | AliStack* stack = fMC->Stack(); | |
150 | if (!stack) { | |
151 | Printf("ERROR: Could not retrieve the stack"); | |
152 | return; | |
153 | } | |
154 | ||
155 | fHistEventStats->Fill(1); | |
156 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->IsOnlineTriggerUsed()) { | |
157 | //online trigger | |
158 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->IsEventTriggered(fESD,dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetTriggerMode())) { | |
159 | fHistEventStats->Fill(2); | |
160 | ||
161 | //offline trigger | |
162 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->IsOfflineTriggerUsed()) { | |
163 | AliPhysicsSelection *gPhysicselection = dynamic_cast<AliPhysicsSelection *>(dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetPhysicsSelectionObject()); | |
164 | if(gPhysicselection->IsCollisionCandidate(fESD)) { | |
165 | fHistEventStats->Fill(3); | |
166 | ||
167 | fProtonQAAnalysis->RunVertexQA(header, | |
168 | fESD); | |
169 | const AliESDVertex *vertex = dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVertex(fESD,dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisMode(),dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVxMax(),dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVyMax(),dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVzMax()); | |
170 | fHistEventStats->Fill(4); | |
171 | ||
172 | if(vertex) { | |
173 | fHistEventStats->Fill(5); | |
174 | fProtonQAAnalysis->RunQAAnalysis(stack, fESD, vertex); | |
175 | fProtonQAAnalysis->RunMCAnalysis(stack); | |
176 | fProtonQAAnalysis->RunPIDEfficiencyAnalysis(stack, fESD, vertex); | |
177 | fProtonQAAnalysis->RunReconstructionEfficiencyAnalysis(fMC,fESD,vertex); | |
178 | fProtonQAAnalysis->RunCutEfficiencyAnalysis(stack, fESD, vertex); | |
179 | }//accepted vertex | |
180 | }//offline trigger | |
181 | }//offline trigger used | |
182 | else { | |
183 | fHistEventStats->Fill(3); | |
184 | ||
185 | fProtonQAAnalysis->RunVertexQA(header, | |
186 | fESD); | |
187 | const AliESDVertex *vertex = dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVertex(fESD,dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisMode(),dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVxMax(),dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVyMax(),dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVzMax()); | |
188 | fHistEventStats->Fill(4); | |
189 | ||
190 | if(vertex) { | |
191 | fHistEventStats->Fill(5); | |
192 | fProtonQAAnalysis->RunQAAnalysis(stack, fESD, vertex); | |
193 | fProtonQAAnalysis->RunMCAnalysis(stack); | |
194 | fProtonQAAnalysis->RunPIDEfficiencyAnalysis(stack, fESD, vertex); | |
195 | fProtonQAAnalysis->RunReconstructionEfficiencyAnalysis(fMC,fESD,vertex); | |
196 | fProtonQAAnalysis->RunCutEfficiencyAnalysis(stack, fESD, vertex); | |
197 | }//accepted vertex | |
198 | }//offline trigger not used | |
199 | }//triggered event - online | |
200 | }//online trigger used | |
201 | else { | |
202 | fHistEventStats->Fill(2); | |
203 | ||
204 | //offline trigger | |
205 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->IsOfflineTriggerUsed()) { | |
206 | AliPhysicsSelection *gPhysicselection = dynamic_cast<AliPhysicsSelection *>(dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetPhysicsSelectionObject()); | |
207 | if(gPhysicselection->IsCollisionCandidate(fESD)) { | |
208 | fHistEventStats->Fill(3); | |
209 | ||
210 | fProtonQAAnalysis->RunVertexQA(header, | |
211 | fESD); | |
212 | const AliESDVertex *vertex = dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVertex(fESD,dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisMode(),dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVxMax(),dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVyMax(),dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVzMax()); | |
213 | fHistEventStats->Fill(4); | |
214 | ||
215 | if(vertex) { | |
216 | fHistEventStats->Fill(5); | |
217 | fProtonQAAnalysis->RunQAAnalysis(stack, fESD, vertex); | |
218 | fProtonQAAnalysis->RunMCAnalysis(stack); | |
219 | fProtonQAAnalysis->RunPIDEfficiencyAnalysis(stack, fESD, vertex); | |
220 | fProtonQAAnalysis->RunReconstructionEfficiencyAnalysis(fMC,fESD,vertex); | |
221 | fProtonQAAnalysis->RunCutEfficiencyAnalysis(stack, fESD, vertex); | |
222 | }//accepted vertex | |
223 | }//offline trigger | |
224 | }//offline trigger used | |
225 | else { | |
226 | fHistEventStats->Fill(3); | |
227 | ||
228 | fProtonQAAnalysis->RunVertexQA(header, | |
229 | fESD); | |
230 | const AliESDVertex *vertex = dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVertex(fESD,dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetAnalysisMode(),dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVxMax(),dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVyMax(),dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetVzMax()); | |
231 | fHistEventStats->Fill(4); | |
232 | ||
233 | if(vertex) { | |
234 | fHistEventStats->Fill(5); | |
235 | fProtonQAAnalysis->RunQAAnalysis(stack, fESD, vertex); | |
236 | fProtonQAAnalysis->RunMCAnalysis(stack); | |
237 | fProtonQAAnalysis->RunPIDEfficiencyAnalysis(stack, fESD, vertex); | |
238 | fProtonQAAnalysis->RunReconstructionEfficiencyAnalysis(fMC,fESD,vertex); | |
239 | fProtonQAAnalysis->RunCutEfficiencyAnalysis(stack, fESD, vertex); | |
240 | }//accepted vertex | |
241 | }//offline trigger not used | |
242 | }//online trigger not used | |
243 | ||
244 | // Post output data. | |
245 | PostData(0, fList0); | |
246 | PostData(1, fList1); | |
247 | PostData(2, fList2); | |
248 | PostData(3, fList3); | |
249 | PostData(4, fList4); | |
250 | PostData(5, fList5); | |
251 | PostData(6, fList6); | |
252 | PostData(7, fList7); | |
253 | PostData(8, fList8); | |
254 | PostData(9, fHistEventStats); | |
255 | } | |
256 | ||
257 | //________________________________________________________________________ | |
258 | void AliAnalysisTaskProtonsQA::Terminate(Option_t *) { | |
259 | // Draw result to the screen | |
260 | // Called once at the end of the query | |
261 | ||
262 | fList0 = dynamic_cast<TList*> (GetOutputData(0)); | |
263 | if (!fList0) { | |
264 | Printf("ERROR: fList0 not available"); | |
265 | return; | |
266 | } | |
267 | fList1 = dynamic_cast<TList*> (GetOutputData(1)); | |
268 | if (!fList1) { | |
269 | Printf("ERROR: fList1 not available"); | |
270 | return; | |
271 | } | |
272 | fList2 = dynamic_cast<TList*> (GetOutputData(2)); | |
273 | if (!fList2) { | |
274 | Printf("ERROR: fList2 not available"); | |
275 | return; | |
276 | } | |
277 | fList3 = dynamic_cast<TList*> (GetOutputData(3)); | |
278 | if (!fList3) { | |
279 | Printf("ERROR: fList3 not available"); | |
280 | return; | |
281 | } | |
282 | fList4 = dynamic_cast<TList*> (GetOutputData(4)); | |
283 | if (!fList4) { | |
284 | Printf("ERROR: fList4 not available"); | |
285 | return; | |
286 | } | |
287 | fList5 = dynamic_cast<TList*> (GetOutputData(5)); | |
288 | if (!fList5) { | |
289 | Printf("ERROR: fList5 not available"); | |
290 | return; | |
291 | } | |
292 | fList6 = dynamic_cast<TList*> (GetOutputData(6)); | |
293 | if (!fList6) { | |
294 | Printf("ERROR: fList6 not available"); | |
295 | return; | |
296 | } | |
297 | fList7 = dynamic_cast<TList*> (GetOutputData(7)); | |
298 | if (!fList7) { | |
299 | Printf("ERROR: fList7 not available"); | |
300 | return; | |
301 | } | |
302 | fList8 = dynamic_cast<TList*> (GetOutputData(8)); | |
303 | if (!fList8) { | |
304 | Printf("ERROR: fList8 not available"); | |
305 | return; | |
306 | } | |
307 | fHistEventStats = dynamic_cast<TH1F*> (GetOutputData(9)); | |
308 | if (!fHistEventStats) { | |
309 | Printf("ERROR: fHistEventStats not available"); | |
310 | return; | |
311 | } | |
312 | } | |
313 | ||
314 |