]>
Commit | Line | Data |
---|---|---|
00514d01 | 1 | // $Id$ |
91f4b7c5 | 2 | // |
3 | // General QA task (S.Aiola) | |
4 | // | |
5 | // | |
00514d01 | 6 | |
7 | #include <TChain.h> | |
8 | #include <TClonesArray.h> | |
9 | #include <TH1F.h> | |
10 | #include <TH2F.h> | |
11 | #include <TList.h> | |
12 | #include <TLorentzVector.h> | |
13 | #include <TParticle.h> | |
14 | ||
15 | #include "AliAnalysisManager.h" | |
16 | #include "AliCentrality.h" | |
17 | #include "AliVCluster.h" | |
18 | #include "AliESDtrack.h" | |
19 | #include "AliEmcalJet.h" | |
20 | #include "AliAODTrack.h" | |
21 | #include "AliESDtrack.h" | |
00514d01 | 22 | #include "AliVEventHandler.h" |
23 | #include "AliPicoTrack.h" | |
24 | ||
25 | #include "AliAnalysisTaskSAQA.h" | |
26 | ||
27 | ClassImp(AliAnalysisTaskSAQA) | |
28 | ||
29 | //________________________________________________________________________ | |
30 | AliAnalysisTaskSAQA::AliAnalysisTaskSAQA() : | |
31 | AliAnalysisTaskSE("AliAnalysisTaskSAQA"), | |
32 | fOutput(0), | |
33 | fTracksName("Tracks"), | |
34 | fCaloName("CaloClusters"), | |
00514d01 | 35 | fTrgClusName("ClustersL1GAMMAFEE"), |
36 | fTracks(0), | |
37 | fCaloClusters(0), | |
38 | fJets(0), | |
39 | fTrgClusters(0), | |
40 | fCent(0), | |
41 | fHistCentrality(0), | |
42 | fHistTracksCent(0), | |
43 | fHistClusCent(0), | |
44 | fHistTracksPt(0), | |
45 | fHistClustersEnergy(0), | |
46 | fHistEPcorrelation(0), | |
00514d01 | 47 | fHistTrPhiEta(0), |
48 | fHistClusPhiEta(0), | |
00514d01 | 49 | fHistMaxTrgCluster(0), |
50 | Ptbins(100), | |
51 | Ptlow(0), | |
52 | Ptup(50), | |
53 | Ebins(100), | |
54 | Elow(0), | |
55 | Eup(50) | |
56 | { | |
57 | // Default constructor. | |
58 | ||
59 | for (Int_t i = 0; i < 5; i++) { | |
60 | fHistTrackPhi[i] = 0; | |
61 | fHistTrackEta[i] = 0; | |
62 | } | |
63 | ||
91f4b7c5 | 64 | // Output slot #1 writes into a TH1 container |
65 | DefineOutput(1, TList::Class()); | |
00514d01 | 66 | } |
67 | ||
68 | //________________________________________________________________________ | |
69 | AliAnalysisTaskSAQA::AliAnalysisTaskSAQA(const char *name) : | |
70 | AliAnalysisTaskSE(name), | |
71 | fOutput(0), | |
72 | fTracksName("Tracks"), | |
73 | fCaloName("CaloClusters"), | |
00514d01 | 74 | fTrgClusName("ClustersL1GAMMAFEE"), |
75 | fTracks(0), | |
76 | fCaloClusters(0), | |
77 | fJets(0), | |
78 | fTrgClusters(0), | |
79 | fCent(0), | |
80 | fHistCentrality(0), | |
81 | fHistTracksCent(0), | |
82 | fHistClusCent(0), | |
83 | fHistTracksPt(0), | |
84 | fHistClustersEnergy(0), | |
85 | fHistEPcorrelation(0), | |
00514d01 | 86 | fHistTrPhiEta(0), |
87 | fHistClusPhiEta(0), | |
00514d01 | 88 | fHistMaxTrgCluster(0), |
89 | Ptbins(100), | |
90 | Ptlow(0), | |
91 | Ptup(50), | |
92 | Ebins(100), | |
93 | Elow(0), | |
94 | Eup(50) | |
95 | { | |
96 | // Standard constructor. | |
97 | ||
98 | for (Int_t i = 0; i < 5; i++) { | |
99 | fHistTrackPhi[i] = 0; | |
100 | fHistTrackEta[i] = 0; | |
101 | } | |
102 | ||
91f4b7c5 | 103 | // Output slot #1 writes into a TH1 container |
104 | DefineOutput(1, TList::Class()); | |
00514d01 | 105 | } |
106 | ||
107 | //________________________________________________________________________ | |
108 | AliAnalysisTaskSAQA::~AliAnalysisTaskSAQA() | |
109 | { | |
110 | // Destructor | |
111 | } | |
112 | ||
113 | //________________________________________________________________________ | |
114 | void AliAnalysisTaskSAQA::UserCreateOutputObjects() | |
115 | { | |
116 | // Create histograms | |
117 | ||
118 | fOutput = new TList(); | |
119 | fOutput->SetOwner(); // IMPORTANT! | |
120 | ||
121 | fHistCentrality = new TH1F("fHistCentrality","Event centrality distribution", Ebins, 0, 100); | |
122 | fHistCentrality->GetXaxis()->SetTitle("Centrality (%)"); | |
123 | fHistCentrality->GetYaxis()->SetTitle("counts"); | |
124 | fOutput->Add(fHistCentrality); | |
125 | ||
126 | fHistTracksCent = new TH2F("fHistTracksCent","Tracks vs. centrality", Ebins, 0, 100, Ebins, 0, 4000); | |
127 | fHistTracksCent->GetXaxis()->SetTitle("Centrality (%)"); | |
128 | fHistTracksCent->GetYaxis()->SetTitle("No. of tracks"); | |
129 | fOutput->Add(fHistTracksCent); | |
130 | ||
131 | fHistClusCent = new TH2F("fHistClusCent","Clusters vs. centrality", Ebins, 0, 100, Ebins, 0, 2000); | |
132 | fHistClusCent->GetXaxis()->SetTitle("Centrality (%)"); | |
133 | fHistClusCent->GetYaxis()->SetTitle("No. of clusters"); | |
134 | fOutput->Add(fHistClusCent); | |
135 | ||
136 | fHistTracksPt = new TH1F("fHistTracksPt","P_{T} spectrum of reconstructed tracks", Ptbins, Ptlow, Ptup); | |
137 | fHistTracksPt->GetXaxis()->SetTitle("P_{T} [GeV/c]"); | |
138 | fHistTracksPt->GetYaxis()->SetTitle("counts"); | |
139 | fOutput->Add(fHistTracksPt); | |
140 | ||
141 | fHistClustersEnergy = new TH1F("fHistClustersEnergy","Energy spectrum of clusters", Ebins, Elow, Eup); | |
142 | fHistClustersEnergy->GetXaxis()->SetTitle("E [GeV]"); | |
143 | fHistClustersEnergy->GetYaxis()->SetTitle("counts"); | |
144 | fOutput->Add(fHistClustersEnergy); | |
145 | ||
146 | fHistEPcorrelation = new TH2F("fHistEPcorrelation","Energy-momentum correlation", Ptbins, Ptlow, Ptup, Ebins, Elow, Eup); | |
147 | fHistEPcorrelation->GetXaxis()->SetTitle("P [GeV/c]"); | |
148 | fHistEPcorrelation->GetYaxis()->SetTitle("E [GeV]"); | |
149 | fOutput->Add(fHistEPcorrelation); | |
00514d01 | 150 | |
151 | fHistTrPhiEta = new TH2F("fHistTrPhiEta","Phi-Eta distribution of tracks", 20, -2, 2, 32, 0, 6.4); | |
152 | fHistTrPhiEta->GetXaxis()->SetTitle("Eta"); | |
153 | fHistTrPhiEta->GetYaxis()->SetTitle("Phi"); | |
154 | fOutput->Add(fHistTrPhiEta); | |
155 | ||
156 | fHistClusPhiEta = new TH2F("fHistClusPhiEta","Phi-Eta distribution of clusters", 20, -2, 2, 32, 0, 6.4); | |
157 | fHistClusPhiEta->GetXaxis()->SetTitle("Eta"); | |
158 | fHistClusPhiEta->GetYaxis()->SetTitle("Phi"); | |
159 | fOutput->Add(fHistClusPhiEta); | |
160 | ||
00514d01 | 161 | fHistMaxTrgCluster = new TH1F("fHistMaxTrgCluster","Energy distribution of max trigger clusters", Ebins, Elow, Eup); |
162 | fHistMaxTrgCluster->GetXaxis()->SetTitle("E [GeV]"); | |
163 | fHistMaxTrgCluster->GetYaxis()->SetTitle("counts"); | |
164 | fOutput->Add(fHistMaxTrgCluster); | |
165 | ||
166 | for (Int_t i = 0; i < 5; i++) { | |
167 | TString histnamephi("fHistTrackPhi_"); | |
168 | histnamephi += i; | |
169 | fHistTrackPhi[i] = new TH1F(histnamephi.Data(),histnamephi.Data(), 128, 0, 6.4); | |
170 | fHistTrackPhi[i]->GetXaxis()->SetTitle("Phi"); | |
171 | fOutput->Add(fHistTrackPhi[i]); | |
172 | ||
173 | TString histnameeta("fHistTrackEta_"); | |
174 | histnameeta += i; | |
175 | fHistTrackEta[i] = new TH1F(histnameeta.Data(),histnameeta.Data(), 100, -2, 2); | |
176 | fHistTrackEta[i]->GetXaxis()->SetTitle("Eta"); | |
177 | fOutput->Add(fHistTrackEta[i]); | |
178 | } | |
179 | ||
180 | fHistTrackPhi[0]->SetLineColor(kRed); | |
181 | fHistTrackEta[0]->SetLineColor(kRed); | |
182 | fHistTrackPhi[1]->SetLineColor(kBlue); | |
183 | fHistTrackEta[1]->SetLineColor(kBlue); | |
184 | fHistTrackPhi[2]->SetLineColor(kGreen); | |
185 | fHistTrackEta[2]->SetLineColor(kGreen); | |
186 | fHistTrackPhi[3]->SetLineColor(kOrange); | |
187 | fHistTrackEta[3]->SetLineColor(kOrange); | |
188 | fHistTrackPhi[4]->SetLineColor(kBlack); | |
189 | fHistTrackEta[4]->SetLineColor(kBlack); | |
190 | ||
191 | PostData(1, fOutput); // Post data for ALL output slots >0 here, to get at least an empty histogram | |
192 | } | |
193 | ||
194 | void AliAnalysisTaskSAQA::RetrieveEventObjects() | |
195 | { | |
196 | fCaloClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fCaloName)); | |
197 | if (!fCaloClusters) { | |
198 | AliWarning(Form("Could not retrieve clusters!")); | |
199 | } | |
200 | ||
201 | fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksName)); | |
202 | if (!fTracks) { | |
203 | AliWarning(Form("Could not retrieve tracks!")); | |
204 | } | |
205 | ||
00514d01 | 206 | if (strcmp(fTrgClusName,"")) { |
207 | fTrgClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTrgClusName)); | |
208 | if (!fTrgClusters) { | |
209 | AliWarning(Form("Could not retrieve trigger clusters!")); | |
210 | } | |
211 | } | |
212 | ||
213 | fCent = InputEvent()->GetCentrality(); | |
214 | } | |
215 | ||
216 | AliVTrack* AliAnalysisTaskSAQA::GetTrack(const Int_t i) const | |
217 | { | |
218 | if (fTracks) | |
219 | return dynamic_cast<AliVTrack*>(fTracks->At(i)); | |
220 | else | |
221 | return 0; | |
222 | } | |
223 | ||
224 | Int_t AliAnalysisTaskSAQA::GetNumberOfTracks() const | |
225 | { | |
226 | if (fTracks) | |
227 | return fTracks->GetEntriesFast(); | |
228 | else | |
229 | return 0; | |
230 | } | |
231 | ||
232 | AliVCluster* AliAnalysisTaskSAQA::GetCaloCluster(const Int_t i) const | |
233 | { | |
234 | if (fCaloClusters) | |
235 | return dynamic_cast<AliVCluster*>(fCaloClusters->At(i)); | |
236 | else | |
237 | return 0; | |
238 | } | |
239 | ||
240 | Int_t AliAnalysisTaskSAQA::GetNumberOfCaloClusters() const | |
241 | { | |
242 | if (fCaloClusters) | |
243 | return fCaloClusters->GetEntriesFast(); | |
244 | else | |
245 | return 0; | |
246 | } | |
247 | ||
00514d01 | 248 | AliVCluster* AliAnalysisTaskSAQA::GetTrgCluster(const Int_t i) const |
249 | { | |
250 | if (fTrgClusters) | |
251 | return dynamic_cast<AliVCluster*>(fTrgClusters->At(i)); | |
252 | else | |
253 | return 0; | |
254 | } | |
255 | ||
256 | Int_t AliAnalysisTaskSAQA::GetNumberOfTrgClusters() const | |
257 | { | |
258 | if (fTrgClusters) | |
259 | return fTrgClusters->GetEntriesFast(); | |
260 | else | |
261 | return 0; | |
262 | } | |
263 | ||
264 | void AliAnalysisTaskSAQA::FillHistograms() | |
265 | { | |
91f4b7c5 | 266 | Float_t cent = 100; |
00514d01 | 267 | |
91f4b7c5 | 268 | if (fCent) |
269 | cent = fCent->GetCentralityPercentile("V0M"); | |
270 | else | |
271 | AliWarning("Centrality not available!"); | |
272 | ||
273 | fHistCentrality->Fill(cent); | |
274 | fHistTracksCent->Fill(cent, GetNumberOfTracks()); | |
275 | fHistClusCent->Fill(cent, GetNumberOfCaloClusters()); | |
00514d01 | 276 | |
277 | // Cluster loop | |
278 | Int_t nclusters = GetNumberOfCaloClusters(); | |
279 | //cout << nclusters << " clusters" << endl; | |
280 | for (Int_t iClusters = 0; iClusters < nclusters; iClusters++) { | |
281 | AliVCluster* cluster = GetCaloCluster(iClusters); | |
282 | if (!cluster) { | |
283 | printf("ERROR: Could not receive cluster %d\n", iClusters); | |
284 | continue; | |
285 | } | |
286 | ||
287 | if (!(cluster->IsEMCAL())) continue; | |
288 | ||
289 | fHistClustersEnergy->Fill(cluster->E()); | |
290 | ||
291 | Float_t pos[3]; | |
292 | cluster->GetPosition(pos); | |
293 | TVector3 clusVec(pos); | |
294 | fHistClusPhiEta->Fill(clusVec.Eta(), clusVec.Phi()); | |
295 | } //cluster loop | |
296 | ||
297 | ||
298 | // Track loop | |
299 | Int_t ntracks = GetNumberOfTracks(); | |
300 | //cout << ntracks << " tracks" << endl; | |
301 | for(Int_t i = 0; i < ntracks; i++) { | |
302 | //cout << "track n. " << i << endl; | |
303 | AliVTrack* track = GetTrack(i); // pointer to reconstructed to track | |
304 | if(!track) { | |
305 | AliError(Form("ERROR: Could not retrieve esdtrack %d",i)); | |
306 | continue; | |
307 | } | |
308 | ||
309 | if (!AcceptTrack(track)) continue; | |
310 | ||
311 | fHistTracksPt->Fill(track->Pt()); | |
312 | ||
313 | Int_t clId = track->GetEMCALcluster(); | |
314 | if (clId > -1) { | |
315 | AliVCluster* cluster = GetCaloCluster(clId); | |
316 | if (cluster) | |
317 | fHistEPcorrelation->Fill(track->P(),cluster->E()); | |
318 | } | |
319 | ||
320 | Float_t eta,phi; | |
321 | Int_t label; | |
322 | ||
323 | if(track->InheritsFrom("AliESDtrack")) { | |
324 | AliESDtrack *esdtrack = dynamic_cast<AliESDtrack*>(track); | |
325 | eta = esdtrack->Eta(); | |
326 | phi = esdtrack->Phi(); | |
327 | label = esdtrack->GetLabel(); | |
328 | } | |
329 | else if (track->InheritsFrom("AliAODTrack")) { | |
330 | AliAODTrack *aodtrack = dynamic_cast<AliAODTrack*>(track); | |
331 | eta = aodtrack->Eta(); | |
332 | phi = aodtrack->Phi(); | |
333 | label = aodtrack->GetLabel(); | |
334 | } | |
335 | else if (track->InheritsFrom("AliPicoTrack")) { | |
336 | AliPicoTrack *picotrack = dynamic_cast<AliPicoTrack*>(track); | |
337 | eta = picotrack->Eta(); | |
338 | phi = picotrack->Phi(); | |
339 | label = picotrack->GetLabel(); | |
340 | } | |
341 | else { | |
342 | AliWarning("Track type not recognized! Will not plot phi\eta distributions!"); | |
343 | continue; | |
344 | } | |
345 | ||
346 | fHistTrPhiEta->Fill(eta, phi); | |
347 | ||
348 | fHistTrackEta[4]->Fill(eta); | |
349 | fHistTrackPhi[4]->Fill(phi); | |
350 | ||
351 | if (label >= 0 && label < 4) { | |
352 | fHistTrackEta[label]->Fill(eta); | |
353 | fHistTrackPhi[label]->Fill(phi); | |
354 | } | |
355 | else { | |
356 | AliWarning(Form("Track label %d not recognized!",label)); | |
357 | } | |
358 | ||
359 | } | |
360 | ||
00514d01 | 361 | Int_t ntrgclusters = GetNumberOfTrgClusters(); |
362 | Float_t maxe = 0; | |
363 | //cout << ntrgclusters << " clusters" << endl; | |
364 | for (Int_t iClusters = 0; iClusters < ntrgclusters; iClusters++) { | |
365 | AliVCluster* cluster = GetTrgCluster(iClusters); | |
366 | if (!cluster) { | |
367 | printf("ERROR: Could not receive cluster %d\n", iClusters); | |
368 | continue; | |
369 | } | |
370 | ||
371 | if (!(cluster->IsEMCAL())) continue; | |
372 | ||
373 | if (cluster->E() > maxe) | |
374 | maxe = cluster->E(); | |
375 | ||
376 | } //cluster loop | |
377 | fHistMaxTrgCluster->Fill(maxe); | |
378 | ||
379 | } | |
380 | ||
381 | //________________________________________________________________________ | |
382 | Bool_t AliAnalysisTaskSAQA::AcceptTrack(AliVTrack* /*track*/) | |
383 | { | |
384 | return kTRUE; | |
385 | } | |
386 | ||
387 | //________________________________________________________________________ | |
388 | void AliAnalysisTaskSAQA::UserExec(Option_t *) | |
389 | { | |
390 | // Main loop, called for each event. | |
391 | // Add jets to event if not yet there | |
392 | ||
393 | RetrieveEventObjects(); | |
394 | ||
395 | FillHistograms(); | |
396 | ||
397 | // information for this iteration of the UserExec in the container | |
398 | PostData(1, fOutput); | |
399 | } | |
400 | ||
401 | //________________________________________________________________________ | |
402 | void AliAnalysisTaskSAQA::Terminate(Option_t *) | |
403 | { | |
404 | // Called once at the end of the analysis. | |
405 | } |