]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/AliAnalysisTaskHFEemcQA.cxx
added EMCal QA task
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliAnalysisTaskHFEemcQA.cxx
CommitLineData
824c6477 1#include "TChain.h"
2#include "TTree.h"
3#include "TH1F.h"
4#include "TCanvas.h"
5
6#include "AliAnalysisTask.h"
7#include "AliAnalysisManager.h"
8
9#include "AliESDEvent.h"
10#include "AliESDInputHandler.h"
11#include "AliESDtrackCuts.h"
12
13#include "AliAODEvent.h"
14#include "AliAODHandler.h"
15
16#include "AliAnalysisTaskHFEemcQA.h"
17
18//QA task for EMCAL electron analysis
19
20ClassImp(AliAnalysisTaskHFEemcQA)
21 //________________________________________________________________________
22 AliAnalysisTaskHFEemcQA::AliAnalysisTaskHFEemcQA(const char *name)
23: AliAnalysisTaskSE(name),
24 fVevent(0),
25 fESD(0),
26 fAOD(0),
27 fOutputList(0),
28 fVtxZ(0),
29 fVtxX(0),
30 fVtxY(0),
31 fTrigMulti(0),
32 fHistClustE(0),
33 fEMCClsEtaPhi(0),
34 fNegTrkIDPt(0),
35 fTrkPt(0),
36 fTrketa(0),
37 fTrkphi(0),
38 fdEdx(0),
39 fTPCNpts(0),
40 fHistPtMatch(0),
41 fEMCTrkMatch(0),
42 fEMCTrkPt(0),
43 fEMCTrketa(0),
44 fEMCTrkphi(0),
45 fEMCdEdx(0),
46 fEMCTPCNpts(0),
47 fHistdEdxEop(0),
48 fHistEop(0),
49 fEleCanTPCNpts(0),
50 fEleCanTPCNCls(0),
51 fEleCanITSNCls(0),
52 fEleCanITShit(0),
53 fEleCanSPD1(0),
54 fEleCanSPD2(0),
55 fEleCanSPDBoth(0),
56 fEleCanSPDOr(0)
57{
58 // Constructor
59
60 // Define input and output slots here
61 // Input slot #0 works with a TChain
62 DefineInput(0, TChain::Class());
63 // Output slot #0 id reserved by the base class for AOD
64 // Output slot #1 writes into a TH1 container
65 DefineOutput(1, TList::Class());
66}
67
68//________________________________________________________________________
69void AliAnalysisTaskHFEemcQA::UserCreateOutputObjects()
70{
71 // Create histograms
72 // Called once
73
74 fOutputList = new TList();
75
76 fVtxZ = new TH1F("fVtxZ","Z vertex position;Vtx_{z};counts",1000,-50,50);
77 fOutputList->Add(fVtxZ);
78
79 fVtxY = new TH1F("fVtxY","Y vertex position;Vtx_{y};counts",1000,-50,50);
80 fOutputList->Add(fVtxY);
81
82 fVtxX = new TH1F("fVtxX","X vertex position;Vtx_{x};counts",1000,-50,50);
83 fOutputList->Add(fVtxX);
84
85 fTrigMulti = new TH2F("fTrigMulti","Multiplicity distribution for different triggers; Trigger type; multiplicity",8,-1,7,2000,0,2000);
86 fOutputList->Add(fTrigMulti);
87
88 fHistClustE = new TH1F("fHistClustE", "EMCAL cluster energy distribution; Cluster E;counts", 500, 0.0, 50.0);
89 fOutputList->Add(fHistClustE);
90
91 fEMCClsEtaPhi = new TH2F("fEMCClsEtaPhi","EMCAL cluster #eta and #phi distribution;#eta;#phi",100,-0.9,0.9,200,0,6.3);
92 fOutputList->Add(fEMCClsEtaPhi);
93
94 fNegTrkIDPt = new TH1F("fNegTrkIDPt", "p_{T} distribution of tracks with negative track id;p_{T} (GeV/c);counts", 500, 0.0, 50.0);
95 fOutputList->Add(fNegTrkIDPt);
96
97 fTrkPt = new TH1F("fTrkPt","p_{T} distribution of all tracks;p_{T} (GeV/c);counts",1000,0,100);
98 fOutputList->Add(fTrkPt);
99
100 fTrketa = new TH1F("fTrketa","All Track #eta distribution;#eta;counts",100,-1.5,1.5);
101 fOutputList->Add(fTrketa);
102
103 fTrkphi = new TH1F("fTrkphi","All Track #phi distribution;#phi;counts",100,0,6.3);
104 fOutputList->Add(fTrkphi);
105
106 fdEdx = new TH2F("fdEdx","All Track dE/dx distribution;p (GeV/c);dE/dx",200,0,20,500,0,100);
107 fOutputList->Add(fdEdx);
108
109 fTPCNpts = new TH2F("fTPCNpts","All track TPC Npoints used for dE/dx calculation;p (GeV/c);N points",200,0,20,200,0.,200.);
110 fOutputList->Add(fTPCNpts);
111
112 fHistPtMatch = new TH1F("fHistPtMatch", "p_{T} distribution of tracks matched to EMCAL;p_{T} (GeV/c);counts",1000, 0.0, 100.0);
113 fOutputList->Add(fHistPtMatch);
114
115 fEMCTrkMatch = new TH2F("fEMCTrkMatch","Distance of EMCAL cluster to its closest track;#phi;z",100,-0.3,0.3,100,-0.3,0.3);
116 fOutputList->Add(fEMCTrkMatch);
117
118 fEMCTrkPt = new TH1F("fEMCTrkPt","p_{T} distribution of tracks with EMCAL cluster;p_{T} (GeV/c);counts",1000,0,100);
119 fOutputList->Add(fEMCTrkPt);
120
121 fEMCTrketa = new TH1F("fEMCTrketa","#eta distribution of tracks matched to EMCAL;#eta;counts",100,-1.5,1.5);
122 fOutputList->Add(fEMCTrketa);
123
124 fEMCTrkphi = new TH1F("fEMCTrkphi","#phi distribution of tracks matched to EMCAL;#phi;counts",100,0,6.3);
125 fOutputList->Add(fEMCTrkphi);
126
127 fEMCdEdx = new TH2F("fEMCdEdx","dE/dx distribution of tracks matched to EMCAL;p (GeV/c);dE/dx",200,0,20,500,0,100);
128 fOutputList->Add(fEMCdEdx);
129
130 fEMCTPCNpts = new TH2F("fEMCTPCNpts","TPC Npoints used for dE/dx for tracks matched to EMCAL;p (GeV/c);N points",200,0,20,200,0.,200.);
131 fOutputList->Add(fEMCTPCNpts);
132
133 fHistEop = new TH2F("fHistEop", "E/p distribution;p_{T} (GeV/c);E/p", 200,0,20,60, 0.0, 3.0);
134 fOutputList->Add(fHistEop);
135
136 fHistdEdxEop = new TH2F("fHistdEdxEop", "E/p vs. dE/dx;E/p;dE/dx", 60, 0.0, 3.0, 500,0,100);
137 fOutputList->Add(fHistdEdxEop);
138
139 fEleCanTPCNpts = new TH2F("fEleCanTPCNpts","TPC Npoints used for dE/dx for electron candidates;p_{T} (GeV/c);N points",200,0,20,200,0,200);
140 fOutputList->Add(fEleCanTPCNpts);
141
142 fEleCanTPCNCls = new TH2F("fEleCanTPCNCls","TPC N clusters for electron candidates;p_{T} (GeV/c);N TPC clusters",200,0,20,171,-0.5,170.5);
143 fOutputList->Add(fEleCanTPCNCls);
144
145 fEleCanITSNCls = new TH2F("fEleCanITSNCls","ITS N clusters for electron candidates;p_{T} (GeV/c);N ITS clusters",200,0,20,8,-0.5,7.5);
146 fOutputList->Add(fEleCanITSNCls);
147
148 fEleCanITShit = new TH1F("fEleCanITShit","ITS hit map;ITS layer;counts",7,-0.5,6.5);
149 fOutputList->Add(fEleCanITShit);
150
151 fEleCanSPD1 = new TH2F("fEleCanSPD1","Hit on SPD layer 1;p_{T} (GeV/c);Hit",200,0,20,1,0,1);
152 fOutputList->Add(fEleCanSPD1);
153
154 fEleCanSPD2 = new TH2F("fEleCanSPD2","Hit on SPD layer 2;p_{T} (GeV/c);Hit",200,0,20,1,0,1);
155 fOutputList->Add(fEleCanSPD2);
156
157 fEleCanSPDBoth = new TH2F("fEleCanSPDBoth","Tracks with hits on both SPD layer;p_{T} (GeV/c);Hit",200,0,20,1,0,1);
158 fOutputList->Add(fEleCanSPDBoth);
159
160 fEleCanSPDOr = new TH2F("fEleCanSPDOr","Tracks with hits on both SPD layer;p_{T} (GeV/c);Hit",200,0,20,1,0,1);
161 fOutputList->Add(fEleCanSPDOr);
162
163 PostData(1,fOutputList);
164}
165
166//________________________________________________________________________
167void AliAnalysisTaskHFEemcQA::UserExec(Option_t *)
168{
169 // Main loop
170 // Called for each event
171 // Post output data.
172
173 UInt_t evSelMask=((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
174
175 fVevent = dynamic_cast<AliVEvent*>(InputEvent());
176 if (!fVevent) {
177 printf("ERROR: fVEvent not available\n");
178 return;
179 }
180
181 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
182 if (fESD) {
183 printf("fESD available\n");
184 //return;
185 }
186
187 AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
188 esdTrackCutsH->SetMaxDCAToVertexXY(2.4);
189 esdTrackCutsH->SetMaxDCAToVertexZ(3.2);
190 esdTrackCutsH->SetDCAToVertex2D(kTRUE);
191
192 fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
193 if (fAOD) {
194 printf("fAOD available\n");
195 //return;
196 }
197
198 int ntracks;
199 ntracks = fVevent->GetNumberOfTracks();
200 printf("There are %d tracks in this event\n",ntracks);
201 // if(fESD)printf("There are %d tracks in this event\n", fESD->GetNumberOfTracks());
202 // if(fAOD)printf("There are %d tracks in this event\n", fAOD->GetNumberOfTracks());
203
204 double Zvertex = -100, Xvertex = -100, Yvertex = -100;
205 const AliVVertex *pVtx = fVevent->GetPrimaryVertex();
206 Zvertex = pVtx->GetZ();
207 Yvertex = pVtx->GetY();
208 Xvertex = pVtx->GetX();
209 fVtxZ->Fill(Zvertex);
210 fVtxX->Fill(Xvertex);
211 fVtxY->Fill(Yvertex);
212 /*
213 if(fESD)
214 {
215 const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
216 Zvertex = pVtx->GetZ();
217 }
218 if(fAOD)
219 {
220 const AliAODVertex *pVtx = fAOD->GetPrimaryVertex();
221 Zvertex = pVtx->GetZ();
222 }
223 */
224 // trigger check
225
226 TString firedTrigger;
227 TString TriggerEG1("EG1");
228 TString TriggerEG2("EG2");
229 fVevent->GetFiredTriggerClasses();
230
231 //if(fAOD) firedTrigger = fAOD->GetFiredTriggerClasses();
232 //else if(fESD) firedTrigger = fESD->GetFiredTriggerClasses();
233
234 Bool_t EG1tr = kFALSE;
235 Bool_t EG2tr = kFALSE;
236
237 if(firedTrigger.Contains(TriggerEG1))EG1tr = kTRUE;
238 if(firedTrigger.Contains(TriggerEG2))EG2tr = kTRUE;
239
240
241 if (fAOD){
242 Double_t multiplicity=fAOD->GetHeader()->GetRefMultiplicity();
243 fTrigMulti->Fill(-0.5, multiplicity);
244 if(evSelMask & AliVEvent::kAny) fTrigMulti->Fill(0.5, multiplicity);
245 if(evSelMask & AliVEvent::kMB) fTrigMulti->Fill(1.5, multiplicity);
246 if(evSelMask & AliVEvent::kINT7) fTrigMulti->Fill(1.5, multiplicity);
247 if(evSelMask & AliVEvent::kINT8) fTrigMulti->Fill(1.5, multiplicity);
248 if(evSelMask & AliVEvent::kEMC1) fTrigMulti->Fill(2.5, multiplicity);
249 if(evSelMask & AliVEvent::kEMC8) fTrigMulti->Fill(3.5, multiplicity);
250 if(evSelMask & AliVEvent::kEMCEJE) fTrigMulti->Fill(4.5, multiplicity);
251 if(evSelMask & AliVEvent::kEMCEGA) fTrigMulti->Fill(5.5, multiplicity);
252 if(evSelMask & AliVEvent::kEMCEGA & EG2tr) fTrigMulti->Fill(5.5, multiplicity);
253 if(evSelMask & AliVEvent::kEMCEGA & EG2tr) fTrigMulti->Fill(5.5, multiplicity);
254 }
255
256 // event selection
257 if(fabs(Zvertex>10.0))return;
258
259 //EMCAL cluster information
260 int Nclust = 0;
261 Nclust = fVevent->GetNumberOfCaloClusters();
262 // if(fESD)Nclust = fESD->GetNumberOfCaloClusters();
263 // if(fAOD)Nclust = fAOD->GetNumberOfCaloClusters();
264 for(Int_t icl=0; icl<Nclust; icl++)
265 {
266 AliVCluster *clust = 0x0;
267 clust = fVevent->GetCaloCluster(icl);
268 // if(fESD)clust = (AliVCluster*) fESD->GetCaloCluster(icl);
269 // if(fAOD)clust = (AliVCluster*) fAOD->GetCaloCluster(icl);
270 if(clust && clust->IsEMCAL())
271 {
272 double clustE = clust->E();
273 float emcx[3]; // cluster pos
274 clust->GetPosition(emcx);
275 TVector3 clustpos(emcx[0],emcx[1],emcx[2]);
276 double emcphi = clustpos.Phi();
277 double emceta = clustpos.Eta();
278 fHistClustE->Fill(clustE);
279 fEMCClsEtaPhi->Fill(emceta,emcphi);
280 }
281 }
282
283 // Track loop
284 for (Int_t iTracks = 0; iTracks < ntracks; iTracks++) {
285
286 //---------combine both esd and aod tracks -------
287 AliVParticle* Vtrack = fVevent->GetTrack(iTracks);
288 if (!Vtrack) {
289 printf("ERROR: Could not receive track %d\n", iTracks);
290 continue;
291 }
292 AliVTrack *track = dynamic_cast<AliVTrack*>(Vtrack);
293 AliESDtrack *etrack = dynamic_cast<AliESDtrack*>(Vtrack);
294 AliAODTrack *atrack = dynamic_cast<AliAODTrack*>(Vtrack);
295
296 if(fAOD)
297 if(!atrack->TestFilterMask(AliAODTrack::kTrkGlobalNoDCA)) continue;
298
299 if(fESD)
300 if(!esdTrackCutsH->AcceptTrack(etrack))continue;
301
302 //track properties
303 double dEdx = track->GetTPCsignal();
304 if(track->GetID()<0) fNegTrkIDPt->Fill(track->Pt());
305 fTrkPt->Fill(track->Pt());
306 fTrketa->Fill(track->Eta());
307 fTrkphi->Fill(track->Phi());
308 fdEdx->Fill(track->P(),dEdx);
309 fTPCNpts->Fill(track->P(),track->GetTPCsignalN());
310
311 //track matching to EMCAL
312 int EMCalIndex = -1;
313 EMCalIndex = track->GetEMCALcluster();
314 if(EMCalIndex < 0) continue;
315 fHistPtMatch->Fill(track->Pt());
316
317 AliVCluster *clustMatch = (AliVCluster*)fAOD->GetCaloCluster(EMCalIndex);
318 if(clustMatch && clustMatch->IsEMCAL()) //isnt clustMatch always EMCal cluster?
319 {
320 fEMCTrkMatch->Fill(clustMatch->GetTrackDx(),clustMatch->GetTrackDz());
321 //properties of tracks matched to the EMCAL
322 fEMCTrkPt->Fill(track->Pt());
323 fEMCTrketa->Fill(track->Eta());
324 fEMCTrkphi->Fill(track->Phi());
325 fEMCdEdx->Fill(track->P(),dEdx);
326 fEMCTPCNpts->Fill(track->P(),track->GetTPCsignalN());
327
328 //E/p distribution
329 double clustMatchE = clustMatch->E();
330 double eop = -1.0;
331 if(track->P()>0)eop = clustMatchE/track->P();
332
333 if(track->Pt()>2.0)fHistdEdxEop->Fill(eop,dEdx);
334 fHistEop->Fill(track->Pt(),eop);
335
336 //track properties of EMCAL electron cadidates
337 if(eop>0.8 and eop<1.2){
338 fEleCanTPCNpts->Fill(track->Pt(),track->GetTPCsignalN());
339 fEleCanTPCNCls->Fill(track->Pt(),track->GetTPCNcls());
340
341 Int_t fITSncls=0;
342 for(Int_t l=0;l<6;l++) {
343 if(TESTBIT(track->GetITSClusterMap(),l)) {
344 fEleCanITShit->Fill(l);
345 if(l==0) fEleCanSPD1->Fill(track->Pt(),0.5);
346 if(l==1) fEleCanSPD2->Fill(track->Pt(),0.5);
347 if(l==0 && l==1) fEleCanSPDBoth->Fill(track->Pt(),0.5);
348 if(l==0 || l==1) fEleCanSPDOr->Fill(track->Pt(),0.5);
349 fITSncls++;
350 }
351 }
352 fEleCanITSNCls->Fill(track->Pt(),fITSncls++);
353 }
354 }
355 } //track loop
356
357 PostData(1, fOutputList);
358}
359//________________________________________________________________________
360void AliAnalysisTaskHFEemcQA::Terminate(Option_t *)
361{
362 // Draw result to the screen
363 // Called once at the end of the query
364
365 fOutputList = dynamic_cast<TList*> (GetOutputData(1));
366 if (!fOutputList) {
367 printf("ERROR: Output list not available\n");
368 return;
369 }
370
371}