]>
Commit | Line | Data |
---|---|---|
7b59a00b | 1 | #include "TChain.h" |
2 | #include "TTree.h" | |
3 | #include "TString.h" | |
4 | #include "TList.h" | |
5 | #include "TH2F.h" | |
6 | #include "TH1I.h" | |
7 | #include "TF1.h" | |
8 | #include "TCanvas.h" | |
9 | #include "TLorentzVector.h" | |
10 | ||
11 | #include "AliAnalysisTask.h" | |
12 | #include "AliAnalysisManager.h" | |
13 | ||
75decd62 | 14 | #include "AliGenEventHeader.h" |
7b59a00b | 15 | #include "AliESDEvent.h" |
16 | #include "AliESDInputHandler.h" | |
17 | #include "AliMCEventHandler.h" | |
18 | #include "AliMCEvent.h" | |
19 | #include "AliStack.h" | |
5429dd65 | 20 | #include "AliVertexerTracks.h" |
21 | #include "AliESDVertex.h" | |
7b59a00b | 22 | |
5ae0977e | 23 | #include "AliProtonQAAnalysis.h" |
7b59a00b | 24 | #include "AliAnalysisTaskProtonsQA.h" |
25 | ||
26 | // Analysis task used for the QA of the (anti)proton analysis | |
27 | // Author: Panos Cristakoglou | |
28 | ||
29 | ClassImp(AliAnalysisTaskProtonsQA) | |
5429dd65 | 30 | |
7b59a00b | 31 | //________________________________________________________________________ |
32 | AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA() | |
33 | : AliAnalysisTask(), fESD(0), fMC(0), | |
9c0b9f24 | 34 | fList0(0), fList1(0), fList2(0), fList3(0), fList4(0), fList5(0), |
5429dd65 | 35 | fProtonQAAnalysis(0), |
36 | fTriggerMode(kMB2), fProtonAnalysisMode(kTPC), | |
37 | fVxMax(0), fVyMax(0), fVzMax(0) { | |
38 | //Dummy constructor | |
7b59a00b | 39 | } |
40 | ||
41 | //________________________________________________________________________ | |
42 | AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA(const char *name) | |
5429dd65 | 43 | : AliAnalysisTask(name, ""), fESD(0), fMC(0), |
75decd62 | 44 | fList0(0), fList1(0), fList2(0), fList3(0), |
45 | fList4(0), fList5(0), fList6(0), | |
5429dd65 | 46 | fProtonQAAnalysis(0), |
47 | fTriggerMode(kMB2), fProtonAnalysisMode(kTPC), | |
48 | fVxMax(0), fVyMax(0), fVzMax(0) { | |
7b59a00b | 49 | // Constructor |
5429dd65 | 50 | |
7b59a00b | 51 | // Define input and output slots here |
52 | // Input slot #0 works with a TChain | |
53 | DefineInput(0, TChain::Class()); | |
54 | // Output slot #0 writes into a TList container | |
55 | DefineOutput(0, TList::Class()); | |
d4733690 | 56 | DefineOutput(1, TList::Class()); |
57 | DefineOutput(2, TList::Class()); | |
5b8133c7 | 58 | DefineOutput(3, TList::Class()); |
59 | DefineOutput(4, TList::Class()); | |
9c0b9f24 | 60 | DefineOutput(5, TList::Class()); |
75decd62 | 61 | DefineOutput(6, TList::Class()); |
7b59a00b | 62 | } |
63 | ||
64 | //________________________________________________________________________ | |
65 | void AliAnalysisTaskProtonsQA::ConnectInputData(Option_t *) { | |
66 | // Connect ESD or AOD here | |
67 | // Called once | |
68 | ||
69 | TTree* tree = dynamic_cast<TTree*> (GetInputData(0)); | |
70 | if (!tree) { | |
71 | Printf("ERROR: Could not read chain from input slot 0"); | |
72 | } else { | |
7b59a00b | 73 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); |
74 | ||
75 | if (!esdH) { | |
76 | Printf("ERROR: Could not get ESDInputHandler"); | |
77 | } else | |
78 | fESD = esdH->GetEvent(); | |
79 | } | |
80 | ||
81 | AliMCEventHandler* mcH = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
82 | if (!mcH) { | |
83 | Printf("ERROR: Could not retrieve MC event handler"); | |
84 | } | |
85 | else | |
86 | fMC = mcH->MCEvent(); | |
75decd62 | 87 | |
7b59a00b | 88 | } |
89 | ||
90 | //________________________________________________________________________ | |
91 | void AliAnalysisTaskProtonsQA::CreateOutputObjects() { | |
92 | // Create histograms | |
93 | // Called once | |
94 | //Prior probabilities | |
95 | Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05}; | |
96 | ||
97 | //proton analysis object | |
5429dd65 | 98 | fProtonQAAnalysis = new AliProtonQAAnalysis(); |
dd3fa486 | 99 | fProtonQAAnalysis->SetEtaMode(); //in case you want eta-Pt instead of y-Pt |
5429dd65 | 100 | fProtonQAAnalysis->SetRunMCAnalysis(); |
dd3fa486 | 101 | fProtonQAAnalysis->SetRunEfficiencyAnalysis(kFALSE); //kTRUE if the cuts should be used in the reco and pid efficiencies |
5429dd65 | 102 | //fProtonQAAnalysis->SetMCProcessId(13);//4: weak decay - 13: hadronic interaction |
103 | //fProtonQAAnalysis->SetMotherParticlePDGCode(3122);//3122: Lambda | |
7b59a00b | 104 | |
3a954fe7 | 105 | //Use of TPConly tracks |
5429dd65 | 106 | if(fProtonAnalysisMode == kTPC) { |
3e23254a | 107 | //fProtonQAAnalysis->SetQAYPtBins(20, -1.0, 1.0, 28, 0.1, 1.5); //TPC only |
6667f3a7 | 108 | fProtonQAAnalysis->SetQAYPtBins(10, -0.5, 0.5, 16, 0.5, 0.9); //TPC only |
5429dd65 | 109 | fProtonQAAnalysis->UseTPCOnly(); |
110 | //fProtonQAAnalysis->SetTPCpid(); | |
111 | fProtonQAAnalysis->SetMinTPCClusters(100); | |
112 | fProtonQAAnalysis->SetMaxChi2PerTPCCluster(2.2); | |
113 | fProtonQAAnalysis->SetMaxCov11(0.5); | |
114 | fProtonQAAnalysis->SetMaxCov22(0.5); | |
115 | fProtonQAAnalysis->SetMaxCov33(0.5); | |
116 | fProtonQAAnalysis->SetMaxCov44(0.5); | |
117 | fProtonQAAnalysis->SetMaxCov55(0.5); | |
118 | fProtonQAAnalysis->SetMaxSigmaToVertexTPC(2.0); | |
119 | //fProtonQAAnalysis->SetMaxDCAXYTPC(1.5); | |
120 | //fProtonQAAnalysis->SetMaxDCAZTPC(1.5); | |
121 | } | |
0326e385 | 122 | //Use of HybridTPC tracks |
5429dd65 | 123 | else if(fProtonAnalysisMode == kHybrid) { |
6667f3a7 | 124 | fProtonQAAnalysis->SetQAYPtBins(10, -0.5, 0.5, 16, 0.5, 0.9); //HybridTPC |
5429dd65 | 125 | fProtonQAAnalysis->UseHybridTPC(); |
126 | fProtonQAAnalysis->SetTPCpid(); | |
127 | fProtonQAAnalysis->SetMinTPCClusters(110); | |
128 | fProtonQAAnalysis->SetMaxChi2PerTPCCluster(2.2); | |
129 | fProtonQAAnalysis->SetMaxCov11(0.5); | |
130 | fProtonQAAnalysis->SetMaxCov22(0.5); | |
131 | fProtonQAAnalysis->SetMaxCov33(0.5); | |
132 | fProtonQAAnalysis->SetMaxCov44(0.5); | |
133 | fProtonQAAnalysis->SetMaxCov55(0.5); | |
134 | fProtonQAAnalysis->SetMaxSigmaToVertex(2.0); | |
135 | /*fProtonQAAnalysis->SetMaxDCAXY(1.5); | |
136 | fProtonQAAnalysis->SetMaxDCAZ(1.5);*/ | |
3e23254a | 137 | //fProtonQAAnalysis->SetPointOnITSLayer6(); |
138 | //fProtonQAAnalysis->SetPointOnITSLayer5(); | |
139 | //fProtonQAAnalysis->SetPointOnITSLayer4(); | |
140 | //fProtonQAAnalysis->SetPointOnITSLayer3(); | |
141 | //fProtonQAAnalysis->SetPointOnITSLayer2(); | |
142 | //fProtonQAAnalysis->SetPointOnITSLayer1(); | |
dd3fa486 | 143 | //fProtonQAAnalysis->SetMinITSClusters(4); |
5429dd65 | 144 | } |
7b59a00b | 145 | //Combined tracking |
5429dd65 | 146 | else if(fProtonAnalysisMode == kGlobal) { |
dd3fa486 | 147 | fProtonQAAnalysis->SetQAYPtBins(20, -1.0, 1.0, 48, 0.3, 1.5); //combined tracking |
5429dd65 | 148 | fProtonQAAnalysis->SetMinTPCClusters(110); |
149 | fProtonQAAnalysis->SetMaxChi2PerTPCCluster(2.2); | |
150 | fProtonQAAnalysis->SetMaxCov11(0.5); | |
151 | fProtonQAAnalysis->SetMaxCov22(0.5); | |
152 | fProtonQAAnalysis->SetMaxCov33(0.5); | |
153 | fProtonQAAnalysis->SetMaxCov44(0.5); | |
154 | fProtonQAAnalysis->SetMaxCov55(0.5); | |
155 | fProtonQAAnalysis->SetMaxSigmaToVertex(2.0); | |
156 | //fProtonQAAnalysis->SetMaxDCAXY(2.0); | |
157 | //fProtonQAAnalysis->SetMaxDCAZ(2.0); | |
158 | fProtonQAAnalysis->SetTPCRefit(); | |
159 | fProtonQAAnalysis->SetPointOnITSLayer1(); | |
160 | fProtonQAAnalysis->SetPointOnITSLayer2(); | |
161 | //fProtonQAAnalysis->SetPointOnITSLayer3(); | |
162 | //fProtonQAAnalysis->SetPointOnITSLayer4(); | |
163 | fProtonQAAnalysis->SetPointOnITSLayer5(); | |
164 | fProtonQAAnalysis->SetPointOnITSLayer6(); | |
165 | fProtonQAAnalysis->SetMinITSClusters(5); | |
166 | fProtonQAAnalysis->SetITSRefit(); | |
167 | fProtonQAAnalysis->SetESDpid(); | |
168 | } | |
7b59a00b | 169 | |
5429dd65 | 170 | fProtonQAAnalysis->SetPriorProbabilities(partFrac); |
171 | ||
d4733690 | 172 | fList0 = new TList(); |
5429dd65 | 173 | fList0 = fProtonQAAnalysis->GetGlobalQAList(); |
d4733690 | 174 | |
175 | fList1 = new TList(); | |
5429dd65 | 176 | fList1 = fProtonQAAnalysis->GetPDGList(); |
d4733690 | 177 | |
178 | fList2 = new TList(); | |
5429dd65 | 179 | fList2 = fProtonQAAnalysis->GetMCProcessesList(); |
5b8133c7 | 180 | |
181 | fList3 = new TList(); | |
5429dd65 | 182 | fList3 = fProtonQAAnalysis->GetAcceptedCutList(); |
5b8133c7 | 183 | |
184 | fList4 = new TList(); | |
5429dd65 | 185 | fList4 = fProtonQAAnalysis->GetAcceptedDCAList(); |
9c0b9f24 | 186 | |
187 | fList5 = new TList(); | |
5429dd65 | 188 | fList5 = fProtonQAAnalysis->GetEfficiencyQAList(); |
75decd62 | 189 | |
190 | fList6 = new TList(); | |
191 | fList6 = fProtonQAAnalysis->GetVertexQAList(); | |
7b59a00b | 192 | } |
193 | ||
194 | //________________________________________________________________________ | |
195 | void AliAnalysisTaskProtonsQA::Exec(Option_t *) { | |
196 | // Main loop | |
197 | // Called for each event | |
198 | ||
199 | if (!fESD) { | |
200 | Printf("ERROR: fESD not available"); | |
201 | return; | |
202 | } | |
5429dd65 | 203 | |
7b59a00b | 204 | if (!fMC) { |
205 | Printf("ERROR: Could not retrieve MC event"); | |
206 | return; | |
207 | } | |
208 | ||
75decd62 | 209 | AliGenEventHeader *header = fMC->GenEventHeader(); |
210 | if (!header) { | |
211 | Printf("ERROR: Could not retrieve the header"); | |
212 | return; | |
213 | } | |
214 | ||
7b59a00b | 215 | AliStack* stack = fMC->Stack(); |
216 | if (!stack) { | |
217 | Printf("ERROR: Could not retrieve the stack"); | |
218 | return; | |
219 | } | |
220 | ||
5429dd65 | 221 | if(IsEventTriggered(fESD,fTriggerMode)) { |
75decd62 | 222 | fProtonQAAnalysis->RunVertexQA(header, |
223 | stack, | |
224 | fESD); | |
5429dd65 | 225 | const AliESDVertex *vertex = GetVertex(fESD,fProtonAnalysisMode, |
226 | fVxMax,fVyMax,fVzMax); | |
227 | if(vertex) { | |
6667f3a7 | 228 | fProtonQAAnalysis->RunQAAnalysis(stack, fESD, vertex); |
5429dd65 | 229 | fProtonQAAnalysis->RunMCAnalysis(stack); |
6667f3a7 | 230 | fProtonQAAnalysis->RunEfficiencyAnalysis(stack, fESD, vertex); |
5429dd65 | 231 | }//accepted vertex |
232 | }//triggered event | |
233 | ||
7b59a00b | 234 | // Post output data. |
d4733690 | 235 | PostData(0, fList0); |
236 | PostData(1, fList1); | |
237 | PostData(2, fList2); | |
5b8133c7 | 238 | PostData(3, fList3); |
239 | PostData(4, fList4); | |
9c0b9f24 | 240 | PostData(5, fList5); |
75decd62 | 241 | PostData(6, fList6); |
7b59a00b | 242 | } |
243 | ||
244 | //________________________________________________________________________ | |
245 | void AliAnalysisTaskProtonsQA::Terminate(Option_t *) { | |
246 | // Draw result to the screen | |
247 | // Called once at the end of the query | |
248 | ||
d4733690 | 249 | fList0 = dynamic_cast<TList*> (GetOutputData(0)); |
250 | if (!fList0) { | |
5429dd65 | 251 | Printf("ERROR: fList0 not available"); |
252 | return; | |
253 | } | |
254 | fList1 = dynamic_cast<TList*> (GetOutputData(1)); | |
255 | if (!fList1) { | |
256 | Printf("ERROR: fList1 not available"); | |
257 | return; | |
258 | } | |
259 | fList2 = dynamic_cast<TList*> (GetOutputData(2)); | |
260 | if (!fList2) { | |
261 | Printf("ERROR: fList2 not available"); | |
262 | return; | |
263 | } | |
264 | fList3 = dynamic_cast<TList*> (GetOutputData(3)); | |
265 | if (!fList3) { | |
266 | Printf("ERROR: fList3 not available"); | |
267 | return; | |
268 | } | |
269 | fList4 = dynamic_cast<TList*> (GetOutputData(4)); | |
270 | if (!fList4) { | |
271 | Printf("ERROR: fList4 not available"); | |
7b59a00b | 272 | return; |
273 | } | |
5429dd65 | 274 | fList5 = dynamic_cast<TList*> (GetOutputData(5)); |
275 | if (!fList5) { | |
276 | Printf("ERROR: fList5 not available"); | |
277 | return; | |
278 | } | |
279 | } | |
280 | ||
281 | //________________________________________________________________________ | |
282 | Bool_t AliAnalysisTaskProtonsQA::IsEventTriggered(const AliESDEvent *esd, | |
283 | TriggerMode trigger) { | |
284 | // check if the event was triggered | |
285 | ULong64_t triggerMask = esd->GetTriggerMask(); | |
286 | ||
287 | // definitions from p-p.cfg | |
288 | ULong64_t spdFO = (1 << 14); | |
289 | ULong64_t v0left = (1 << 11); | |
290 | ULong64_t v0right = (1 << 12); | |
291 | ||
292 | switch (trigger) { | |
293 | case kMB1: { | |
294 | if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right))) | |
295 | return kTRUE; | |
296 | break; | |
297 | } | |
298 | case kMB2: { | |
299 | if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right))) | |
300 | return kTRUE; | |
301 | break; | |
302 | } | |
303 | case kSPDFASTOR: { | |
304 | if (triggerMask & spdFO) | |
305 | return kTRUE; | |
306 | break; | |
307 | } | |
308 | }//switch | |
309 | ||
310 | return kFALSE; | |
7b59a00b | 311 | } |
312 | ||
5429dd65 | 313 | //________________________________________________________________________ |
314 | const AliESDVertex* AliAnalysisTaskProtonsQA::GetVertex(AliESDEvent* esd, | |
315 | AnalysisMode mode, | |
316 | Double_t gVxMax, | |
317 | Double_t gVyMax, | |
318 | Double_t gVzMax) { | |
319 | // Get the vertex from the ESD and returns it if the vertex is valid | |
320 | // Second argument decides which vertex is used (this selects | |
321 | // also the quality criteria that are applied) | |
322 | const AliESDVertex* vertex = 0; | |
323 | if(mode == kHybrid) | |
324 | vertex = esd->GetPrimaryVertexSPD(); | |
325 | else if(mode == kTPC){ | |
326 | Double_t kBz = esd->GetMagneticField(); | |
327 | AliVertexerTracks vertexer(kBz); | |
328 | vertexer.SetTPCMode(); | |
329 | AliESDVertex *vTPC = vertexer.FindPrimaryVertex(esd); | |
330 | esd->SetPrimaryVertexTPC(vTPC); | |
331 | for (Int_t i=0; i<esd->GetNumberOfTracks(); i++) { | |
332 | AliESDtrack *t = esd->GetTrack(i); | |
333 | t->RelateToVertexTPC(vTPC, kBz, kVeryBig); | |
334 | } | |
335 | delete vTPC; | |
336 | vertex = esd->GetPrimaryVertexTPC(); | |
337 | } | |
338 | else if(mode == kGlobal) | |
339 | vertex = esd->GetPrimaryVertex(); | |
340 | else | |
341 | Printf("GetVertex: ERROR: Invalid second argument %d", mode); | |
342 | ||
343 | if(!vertex) return 0; | |
344 | ||
345 | // check Ncontributors | |
346 | if(vertex->GetNContributors() <= 0) return 0; | |
347 | ||
348 | // check resolution | |
349 | Double_t zRes = vertex->GetZRes(); | |
350 | if(zRes == 0) return 0; | |
351 | ||
352 | //check position | |
353 | if(TMath::Abs(vertex->GetXv()) > gVxMax) return 0; | |
354 | if(TMath::Abs(vertex->GetYv()) > gVyMax) return 0; | |
355 | if(TMath::Abs(vertex->GetZv()) > gVzMax) return 0; | |
356 | ||
357 | return vertex; | |
358 | } | |
359 | ||
360 | ||
361 | ||
7b59a00b | 362 |