]>
Commit | Line | Data |
---|---|---|
7b59a00b | 1 | #include "TChain.h" |
2 | #include "TTree.h" | |
7b59a00b | 3 | #include "TList.h" |
eff877f9 | 4 | #include "TH1F.h" |
7b59a00b | 5 | |
6 | #include "AliAnalysisTask.h" | |
7 | #include "AliAnalysisManager.h" | |
8 | ||
75decd62 | 9 | #include "AliGenEventHeader.h" |
7b59a00b | 10 | #include "AliESDEvent.h" |
11 | #include "AliESDInputHandler.h" | |
12 | #include "AliMCEventHandler.h" | |
13 | #include "AliMCEvent.h" | |
14 | #include "AliStack.h" | |
5429dd65 | 15 | #include "AliESDVertex.h" |
e56f08ed | 16 | #include "AliPhysicsSelection.h" |
7b59a00b | 17 | |
5ae0977e | 18 | #include "AliProtonQAAnalysis.h" |
e7df5638 | 19 | #include "AliProtonAnalysisBase.h" |
7b59a00b | 20 | #include "AliAnalysisTaskProtonsQA.h" |
21 | ||
73aba974 | 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 | //----------------------------------------------------------------- | |
7b59a00b | 27 | |
28 | ClassImp(AliAnalysisTaskProtonsQA) | |
5429dd65 | 29 | |
7b59a00b | 30 | //________________________________________________________________________ |
31 | AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA() | |
eff877f9 | 32 | : AliAnalysisTask(), fESD(0), fMC(0), fHistEventStats(0), |
5661e210 | 33 | fList0(0), fList1(0), fList2(0), fList3(0), |
df201289 | 34 | fList4(0), fList5(0), fList6(0), fList7(0), fList8(0), |
e7df5638 | 35 | fProtonQAAnalysis(0) { |
5429dd65 | 36 | //Dummy constructor |
7b59a00b | 37 | } |
38 | ||
39 | //________________________________________________________________________ | |
40 | AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA(const char *name) | |
eff877f9 | 41 | : AliAnalysisTask(name, ""), fESD(0), fMC(0), fHistEventStats(0), |
75decd62 | 42 | fList0(0), fList1(0), fList2(0), fList3(0), |
df201289 | 43 | fList4(0), fList5(0), fList6(0), fList7(0), fList8(0), |
e7df5638 | 44 | fProtonQAAnalysis(0) { |
7b59a00b | 45 | // Constructor |
5429dd65 | 46 | |
7b59a00b | 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()); | |
d4733690 | 52 | DefineOutput(1, TList::Class()); |
53 | DefineOutput(2, TList::Class()); | |
5b8133c7 | 54 | DefineOutput(3, TList::Class()); |
55 | DefineOutput(4, TList::Class()); | |
9c0b9f24 | 56 | DefineOutput(5, TList::Class()); |
75decd62 | 57 | DefineOutput(6, TList::Class()); |
5661e210 | 58 | DefineOutput(7, TList::Class()); |
df201289 | 59 | DefineOutput(8, TList::Class()); |
e0def6e4 | 60 | DefineOutput(9, TH1F::Class()); |
7b59a00b | 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 { | |
7b59a00b | 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 | |
e7df5638 | 91 | // Called once |
d7a38708 | 92 | TString gCutName[5] = {"Total","Triggered","Offline trigger", |
93 | "Vertex","Analyzed"}; | |
eff877f9 | 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++) | |
d7a38708 | 98 | fHistEventStats->GetXaxis()->SetBinLabel(i,gCutName[i-1].Data()); |
eff877f9 | 99 | |
d4733690 | 100 | fList0 = new TList(); |
71a67ee1 | 101 | fList0 = fProtonQAAnalysis->GetGlobalQAList(); |
d4733690 | 102 | |
103 | fList1 = new TList(); | |
5429dd65 | 104 | fList1 = fProtonQAAnalysis->GetPDGList(); |
d4733690 | 105 | |
106 | fList2 = new TList(); | |
5429dd65 | 107 | fList2 = fProtonQAAnalysis->GetMCProcessesList(); |
5b8133c7 | 108 | |
109 | fList3 = new TList(); | |
5429dd65 | 110 | fList3 = fProtonQAAnalysis->GetAcceptedCutList(); |
5b8133c7 | 111 | |
112 | fList4 = new TList(); | |
5661e210 | 113 | fList4 = fProtonQAAnalysis->GetRejectedCutList(); |
9c0b9f24 | 114 | |
115 | fList5 = new TList(); | |
5661e210 | 116 | fList5 = fProtonQAAnalysis->GetAcceptedDCAList(); |
75decd62 | 117 | |
118 | fList6 = new TList(); | |
5661e210 | 119 | fList6 = fProtonQAAnalysis->GetEfficiencyQAList(); |
120 | ||
121 | fList7 = new TList(); | |
122 | fList7 = fProtonQAAnalysis->GetVertexQAList(); | |
df201289 | 123 | |
124 | fList8 = new TList(); | |
125 | fList8 = fProtonQAAnalysis->GetCutEfficiencyList(); | |
7b59a00b | 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 | } | |
5429dd65 | 137 | |
7b59a00b | 138 | if (!fMC) { |
139 | Printf("ERROR: Could not retrieve MC event"); | |
140 | return; | |
141 | } | |
142 | ||
75decd62 | 143 | AliGenEventHeader *header = fMC->GenEventHeader(); |
144 | if (!header) { | |
145 | Printf("ERROR: Could not retrieve the header"); | |
146 | return; | |
147 | } | |
148 | ||
7b59a00b | 149 | AliStack* stack = fMC->Stack(); |
150 | if (!stack) { | |
151 | Printf("ERROR: Could not retrieve the stack"); | |
152 | return; | |
153 | } | |
eff877f9 | 154 | |
155 | fHistEventStats->Fill(1); | |
cc2e05cc | 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 { | |
eff877f9 | 202 | fHistEventStats->Fill(2); |
cc2e05cc | 203 | |
eff877f9 | 204 | //offline trigger |
cc2e05cc | 205 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->IsOfflineTriggerUsed()) { |
e56f08ed | 206 | AliPhysicsSelection *gPhysicselection = dynamic_cast<AliPhysicsSelection *>(dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetPhysicsSelectionObject()); |
207 | if(gPhysicselection->IsCollisionCandidate(fESD)) { | |
eff877f9 | 208 | fHistEventStats->Fill(3); |
cc2e05cc | 209 | |
e56f08ed | 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()); | |
eff877f9 | 213 | fHistEventStats->Fill(4); |
cc2e05cc | 214 | |
e56f08ed | 215 | if(vertex) { |
eff877f9 | 216 | fHistEventStats->Fill(5); |
e56f08ed | 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 | |
cc2e05cc | 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 | ||
7b59a00b | 244 | // Post output data. |
d4733690 | 245 | PostData(0, fList0); |
246 | PostData(1, fList1); | |
247 | PostData(2, fList2); | |
5b8133c7 | 248 | PostData(3, fList3); |
249 | PostData(4, fList4); | |
9c0b9f24 | 250 | PostData(5, fList5); |
75decd62 | 251 | PostData(6, fList6); |
5661e210 | 252 | PostData(7, fList7); |
df201289 | 253 | PostData(8, fList8); |
e0def6e4 | 254 | PostData(9, fHistEventStats); |
7b59a00b | 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 | ||
d4733690 | 262 | fList0 = dynamic_cast<TList*> (GetOutputData(0)); |
263 | if (!fList0) { | |
5429dd65 | 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"); | |
7b59a00b | 285 | return; |
286 | } | |
5429dd65 | 287 | fList5 = dynamic_cast<TList*> (GetOutputData(5)); |
288 | if (!fList5) { | |
289 | Printf("ERROR: fList5 not available"); | |
290 | return; | |
291 | } | |
e7df5638 | 292 | fList6 = dynamic_cast<TList*> (GetOutputData(6)); |
293 | if (!fList6) { | |
294 | Printf("ERROR: fList6 not available"); | |
295 | return; | |
5429dd65 | 296 | } |
e7df5638 | 297 | fList7 = dynamic_cast<TList*> (GetOutputData(7)); |
298 | if (!fList7) { | |
299 | Printf("ERROR: fList7 not available"); | |
300 | return; | |
5429dd65 | 301 | } |
df201289 | 302 | fList8 = dynamic_cast<TList*> (GetOutputData(8)); |
303 | if (!fList8) { | |
304 | Printf("ERROR: fList8 not available"); | |
305 | return; | |
306 | } | |
e0def6e4 | 307 | fHistEventStats = dynamic_cast<TH1F*> (GetOutputData(9)); |
308 | if (!fHistEventStats) { | |
309 | Printf("ERROR: fHistEventStats not available"); | |
310 | return; | |
311 | } | |
7b59a00b | 312 | } |
313 | ||
314 |