]>
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 |
eff877f9 | 92 | char *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]); | |
99 | ||
d4733690 | 100 | fList0 = new TList(); |
5429dd65 | 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); | |
e56f08ed | 156 | //online trigger |
157 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->IsEventTriggered(fESD,dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetTriggerMode())) { | |
eff877f9 | 158 | fHistEventStats->Fill(2); |
159 | ||
160 | //offline trigger | |
161 | if(dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->IsOfflineTriggerUsed()) { | |
e56f08ed | 162 | AliPhysicsSelection *gPhysicselection = dynamic_cast<AliPhysicsSelection *>(dynamic_cast<AliProtonAnalysisBase*>(fProtonQAAnalysis->GetProtonAnalysisBaseObject())->GetPhysicsSelectionObject()); |
163 | if(gPhysicselection->IsCollisionCandidate(fESD)) { | |
eff877f9 | 164 | fHistEventStats->Fill(3); |
165 | ||
e56f08ed | 166 | fProtonQAAnalysis->RunVertexQA(header, |
167 | fESD); | |
168 | 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 | 169 | fHistEventStats->Fill(4); |
170 | ||
e56f08ed | 171 | if(vertex) { |
eff877f9 | 172 | fHistEventStats->Fill(5); |
e56f08ed | 173 | fProtonQAAnalysis->RunQAAnalysis(stack, fESD, vertex); |
174 | fProtonQAAnalysis->RunMCAnalysis(stack); | |
175 | fProtonQAAnalysis->RunPIDEfficiencyAnalysis(stack, fESD, vertex); | |
176 | fProtonQAAnalysis->RunReconstructionEfficiencyAnalysis(fMC,fESD,vertex); | |
177 | fProtonQAAnalysis->RunCutEfficiencyAnalysis(stack, fESD, vertex); | |
178 | }//accepted vertex | |
179 | }//offline trigger | |
180 | }//offline trigger used | |
181 | }//online trigger | |
5429dd65 | 182 | |
7b59a00b | 183 | // Post output data. |
d4733690 | 184 | PostData(0, fList0); |
185 | PostData(1, fList1); | |
186 | PostData(2, fList2); | |
5b8133c7 | 187 | PostData(3, fList3); |
188 | PostData(4, fList4); | |
9c0b9f24 | 189 | PostData(5, fList5); |
75decd62 | 190 | PostData(6, fList6); |
5661e210 | 191 | PostData(7, fList7); |
df201289 | 192 | PostData(8, fList8); |
e0def6e4 | 193 | PostData(9, fHistEventStats); |
7b59a00b | 194 | } |
195 | ||
196 | //________________________________________________________________________ | |
197 | void AliAnalysisTaskProtonsQA::Terminate(Option_t *) { | |
198 | // Draw result to the screen | |
199 | // Called once at the end of the query | |
200 | ||
d4733690 | 201 | fList0 = dynamic_cast<TList*> (GetOutputData(0)); |
202 | if (!fList0) { | |
5429dd65 | 203 | Printf("ERROR: fList0 not available"); |
204 | return; | |
205 | } | |
206 | fList1 = dynamic_cast<TList*> (GetOutputData(1)); | |
207 | if (!fList1) { | |
208 | Printf("ERROR: fList1 not available"); | |
209 | return; | |
210 | } | |
211 | fList2 = dynamic_cast<TList*> (GetOutputData(2)); | |
212 | if (!fList2) { | |
213 | Printf("ERROR: fList2 not available"); | |
214 | return; | |
215 | } | |
216 | fList3 = dynamic_cast<TList*> (GetOutputData(3)); | |
217 | if (!fList3) { | |
218 | Printf("ERROR: fList3 not available"); | |
219 | return; | |
220 | } | |
221 | fList4 = dynamic_cast<TList*> (GetOutputData(4)); | |
222 | if (!fList4) { | |
223 | Printf("ERROR: fList4 not available"); | |
7b59a00b | 224 | return; |
225 | } | |
5429dd65 | 226 | fList5 = dynamic_cast<TList*> (GetOutputData(5)); |
227 | if (!fList5) { | |
228 | Printf("ERROR: fList5 not available"); | |
229 | return; | |
230 | } | |
e7df5638 | 231 | fList6 = dynamic_cast<TList*> (GetOutputData(6)); |
232 | if (!fList6) { | |
233 | Printf("ERROR: fList6 not available"); | |
234 | return; | |
5429dd65 | 235 | } |
e7df5638 | 236 | fList7 = dynamic_cast<TList*> (GetOutputData(7)); |
237 | if (!fList7) { | |
238 | Printf("ERROR: fList7 not available"); | |
239 | return; | |
5429dd65 | 240 | } |
df201289 | 241 | fList8 = dynamic_cast<TList*> (GetOutputData(8)); |
242 | if (!fList8) { | |
243 | Printf("ERROR: fList8 not available"); | |
244 | return; | |
245 | } | |
e0def6e4 | 246 | fHistEventStats = dynamic_cast<TH1F*> (GetOutputData(9)); |
247 | if (!fHistEventStats) { | |
248 | Printf("ERROR: fHistEventStats not available"); | |
249 | return; | |
250 | } | |
7b59a00b | 251 | } |
252 | ||
253 |