6 #include "AliAnalysisTask.h"
7 #include "AliAnalysisManager.h"
9 #include "AliESDEvent.h"
10 #include "AliESDInputHandler.h"
11 #include "AliESDtrackCuts.h"
13 #include "AliAODEvent.h"
14 #include "AliAODHandler.h"
16 #include "AliAnalysisTaskHFEemcQA.h"
18 //QA task for EMCAL electron analysis
20 ClassImp(AliAnalysisTaskHFEemcQA)
21 //________________________________________________________________________
22 AliAnalysisTaskHFEemcQA::AliAnalysisTaskHFEemcQA(const char *name)
23 : AliAnalysisTaskSE(name),
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());
68 //________________________________________________________________________
69 void AliAnalysisTaskHFEemcQA::UserCreateOutputObjects()
74 fOutputList = new TList();
75 fOutputList->SetOwner();
77 fVtxZ = new TH1F("fVtxZ","Z vertex position;Vtx_{z};counts",1000,-50,50);
78 fOutputList->Add(fVtxZ);
80 fVtxY = new TH1F("fVtxY","Y vertex position;Vtx_{y};counts",1000,-50,50);
81 fOutputList->Add(fVtxY);
83 fVtxX = new TH1F("fVtxX","X vertex position;Vtx_{x};counts",1000,-50,50);
84 fOutputList->Add(fVtxX);
86 fTrigMulti = new TH2F("fTrigMulti","Multiplicity distribution for different triggers; Trigger type; multiplicity",8,-1,7,2000,0,2000);
87 fOutputList->Add(fTrigMulti);
89 fHistClustE = new TH1F("fHistClustE", "EMCAL cluster energy distribution; Cluster E;counts", 500, 0.0, 50.0);
90 fOutputList->Add(fHistClustE);
92 fEMCClsEtaPhi = new TH2F("fEMCClsEtaPhi","EMCAL cluster #eta and #phi distribution;#eta;#phi",100,-0.9,0.9,200,0,6.3);
93 fOutputList->Add(fEMCClsEtaPhi);
95 fNegTrkIDPt = new TH1F("fNegTrkIDPt", "p_{T} distribution of tracks with negative track id;p_{T} (GeV/c);counts", 500, 0.0, 50.0);
96 fOutputList->Add(fNegTrkIDPt);
98 fTrkPt = new TH1F("fTrkPt","p_{T} distribution of all tracks;p_{T} (GeV/c);counts",1000,0,100);
99 fOutputList->Add(fTrkPt);
101 fTrketa = new TH1F("fTrketa","All Track #eta distribution;#eta;counts",100,-1.5,1.5);
102 fOutputList->Add(fTrketa);
104 fTrkphi = new TH1F("fTrkphi","All Track #phi distribution;#phi;counts",100,0,6.3);
105 fOutputList->Add(fTrkphi);
107 fdEdx = new TH2F("fdEdx","All Track dE/dx distribution;p (GeV/c);dE/dx",200,0,20,500,0,100);
108 fOutputList->Add(fdEdx);
110 fTPCNpts = new TH2F("fTPCNpts","All track TPC Npoints used for dE/dx calculation;p (GeV/c);N points",200,0,20,200,0.,200.);
111 fOutputList->Add(fTPCNpts);
113 fHistPtMatch = new TH1F("fHistPtMatch", "p_{T} distribution of tracks matched to EMCAL;p_{T} (GeV/c);counts",1000, 0.0, 100.0);
114 fOutputList->Add(fHistPtMatch);
116 fEMCTrkMatch = new TH2F("fEMCTrkMatch","Distance of EMCAL cluster to its closest track;#phi;z",100,-0.3,0.3,100,-0.3,0.3);
117 fOutputList->Add(fEMCTrkMatch);
119 fEMCTrkPt = new TH1F("fEMCTrkPt","p_{T} distribution of tracks with EMCAL cluster;p_{T} (GeV/c);counts",1000,0,100);
120 fOutputList->Add(fEMCTrkPt);
122 fEMCTrketa = new TH1F("fEMCTrketa","#eta distribution of tracks matched to EMCAL;#eta;counts",100,-1.5,1.5);
123 fOutputList->Add(fEMCTrketa);
125 fEMCTrkphi = new TH1F("fEMCTrkphi","#phi distribution of tracks matched to EMCAL;#phi;counts",100,0,6.3);
126 fOutputList->Add(fEMCTrkphi);
128 fEMCdEdx = new TH2F("fEMCdEdx","dE/dx distribution of tracks matched to EMCAL;p (GeV/c);dE/dx",200,0,20,500,0,100);
129 fOutputList->Add(fEMCdEdx);
131 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.);
132 fOutputList->Add(fEMCTPCNpts);
134 fHistEop = new TH2F("fHistEop", "E/p distribution;p_{T} (GeV/c);E/p", 200,0,20,60, 0.0, 3.0);
135 fOutputList->Add(fHistEop);
137 fHistdEdxEop = new TH2F("fHistdEdxEop", "E/p vs. dE/dx;E/p;dE/dx", 60, 0.0, 3.0, 500,0,100);
138 fOutputList->Add(fHistdEdxEop);
140 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);
141 fOutputList->Add(fEleCanTPCNpts);
143 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);
144 fOutputList->Add(fEleCanTPCNCls);
146 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);
147 fOutputList->Add(fEleCanITSNCls);
149 fEleCanITShit = new TH1F("fEleCanITShit","ITS hit map;ITS layer;counts",7,-0.5,6.5);
150 fOutputList->Add(fEleCanITShit);
152 fEleCanSPD1 = new TH2F("fEleCanSPD1","Hit on SPD layer 1;p_{T} (GeV/c);Hit",200,0,20,1,0,1);
153 fOutputList->Add(fEleCanSPD1);
155 fEleCanSPD2 = new TH2F("fEleCanSPD2","Hit on SPD layer 2;p_{T} (GeV/c);Hit",200,0,20,1,0,1);
156 fOutputList->Add(fEleCanSPD2);
158 fEleCanSPDBoth = new TH2F("fEleCanSPDBoth","Tracks with hits on both SPD layer;p_{T} (GeV/c);Hit",200,0,20,1,0,1);
159 fOutputList->Add(fEleCanSPDBoth);
161 fEleCanSPDOr = new TH2F("fEleCanSPDOr","Tracks with hits on both SPD layer;p_{T} (GeV/c);Hit",200,0,20,1,0,1);
162 fOutputList->Add(fEleCanSPDOr);
164 PostData(1,fOutputList);
167 //________________________________________________________________________
168 void AliAnalysisTaskHFEemcQA::UserExec(Option_t *)
171 // Called for each event
174 UInt_t evSelMask=((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
176 fVevent = dynamic_cast<AliVEvent*>(InputEvent());
178 printf("ERROR: fVEvent not available\n");
182 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
184 printf("fESD available\n");
188 AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
189 esdTrackCutsH->SetMaxDCAToVertexXY(2.4);
190 esdTrackCutsH->SetMaxDCAToVertexZ(3.2);
191 esdTrackCutsH->SetDCAToVertex2D(kTRUE);
193 fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
195 printf("fAOD available\n");
200 ntracks = fVevent->GetNumberOfTracks();
201 printf("There are %d tracks in this event\n",ntracks);
202 // if(fESD)printf("There are %d tracks in this event\n", fESD->GetNumberOfTracks());
203 // if(fAOD)printf("There are %d tracks in this event\n", fAOD->GetNumberOfTracks());
205 double Zvertex = -100, Xvertex = -100, Yvertex = -100;
206 const AliVVertex *pVtx = fVevent->GetPrimaryVertex();
207 Zvertex = pVtx->GetZ();
208 Yvertex = pVtx->GetY();
209 Xvertex = pVtx->GetX();
210 fVtxZ->Fill(Zvertex);
211 fVtxX->Fill(Xvertex);
212 fVtxY->Fill(Yvertex);
216 const AliESDVertex *pVtx = fESD->GetPrimaryVertex();
217 Zvertex = pVtx->GetZ();
221 const AliAODVertex *pVtx = fAOD->GetPrimaryVertex();
222 Zvertex = pVtx->GetZ();
227 TString firedTrigger;
228 TString TriggerEG1("EG1");
229 TString TriggerEG2("EG2");
230 fVevent->GetFiredTriggerClasses();
232 //if(fAOD) firedTrigger = fAOD->GetFiredTriggerClasses();
233 //else if(fESD) firedTrigger = fESD->GetFiredTriggerClasses();
235 Bool_t EG1tr = kFALSE;
236 Bool_t EG2tr = kFALSE;
238 if(firedTrigger.Contains(TriggerEG1))EG1tr = kTRUE;
239 if(firedTrigger.Contains(TriggerEG2))EG2tr = kTRUE;
243 Double_t multiplicity=fAOD->GetHeader()->GetRefMultiplicity();
244 fTrigMulti->Fill(-0.5, multiplicity);
245 if(evSelMask & AliVEvent::kAny) fTrigMulti->Fill(0.5, multiplicity);
246 if(evSelMask & AliVEvent::kMB) fTrigMulti->Fill(1.5, multiplicity);
247 if(evSelMask & AliVEvent::kINT7) fTrigMulti->Fill(1.5, multiplicity);
248 if(evSelMask & AliVEvent::kINT8) fTrigMulti->Fill(1.5, multiplicity);
249 if(evSelMask & AliVEvent::kEMC1) fTrigMulti->Fill(2.5, multiplicity);
250 if(evSelMask & AliVEvent::kEMC8) fTrigMulti->Fill(3.5, multiplicity);
251 if(evSelMask & AliVEvent::kEMCEJE) fTrigMulti->Fill(4.5, multiplicity);
252 if(evSelMask & AliVEvent::kEMCEGA) fTrigMulti->Fill(5.5, multiplicity);
253 if(evSelMask & AliVEvent::kEMCEGA & EG2tr) fTrigMulti->Fill(5.5, multiplicity);
254 if(evSelMask & AliVEvent::kEMCEGA & EG2tr) fTrigMulti->Fill(5.5, multiplicity);
258 if(fabs(Zvertex>10.0))return;
260 //EMCAL cluster information
262 Nclust = fVevent->GetNumberOfCaloClusters();
263 // if(fESD)Nclust = fESD->GetNumberOfCaloClusters();
264 // if(fAOD)Nclust = fAOD->GetNumberOfCaloClusters();
265 for(Int_t icl=0; icl<Nclust; icl++)
267 AliVCluster *clust = 0x0;
268 clust = fVevent->GetCaloCluster(icl);
269 // if(fESD)clust = (AliVCluster*) fESD->GetCaloCluster(icl);
270 // if(fAOD)clust = (AliVCluster*) fAOD->GetCaloCluster(icl);
271 if(clust && clust->IsEMCAL())
273 double clustE = clust->E();
274 float emcx[3]; // cluster pos
275 clust->GetPosition(emcx);
276 TVector3 clustpos(emcx[0],emcx[1],emcx[2]);
277 double emcphi = clustpos.Phi();
278 double emceta = clustpos.Eta();
279 fHistClustE->Fill(clustE);
280 fEMCClsEtaPhi->Fill(emceta,emcphi);
285 for (Int_t iTracks = 0; iTracks < ntracks; iTracks++) {
287 //---------combine both esd and aod tracks -------
288 AliVParticle* Vtrack = fVevent->GetTrack(iTracks);
290 printf("ERROR: Could not receive track %d\n", iTracks);
293 AliVTrack *track = dynamic_cast<AliVTrack*>(Vtrack);
294 AliESDtrack *etrack = dynamic_cast<AliESDtrack*>(Vtrack);
295 AliAODTrack *atrack = dynamic_cast<AliAODTrack*>(Vtrack);
298 if(!atrack->TestFilterMask(AliAODTrack::kTrkGlobalNoDCA)) continue;
301 if(!esdTrackCutsH->AcceptTrack(etrack))continue;
304 double dEdx = track->GetTPCsignal();
305 if(track->GetID()<0) fNegTrkIDPt->Fill(track->Pt());
306 fTrkPt->Fill(track->Pt());
307 fTrketa->Fill(track->Eta());
308 fTrkphi->Fill(track->Phi());
309 fdEdx->Fill(track->P(),dEdx);
310 fTPCNpts->Fill(track->P(),track->GetTPCsignalN());
312 //track matching to EMCAL
314 EMCalIndex = track->GetEMCALcluster();
315 if(EMCalIndex < 0) continue;
316 fHistPtMatch->Fill(track->Pt());
318 AliVCluster *clustMatch = (AliVCluster*)fAOD->GetCaloCluster(EMCalIndex);
319 if(clustMatch && clustMatch->IsEMCAL()) //isnt clustMatch always EMCal cluster?
321 fEMCTrkMatch->Fill(clustMatch->GetTrackDx(),clustMatch->GetTrackDz());
322 //properties of tracks matched to the EMCAL
323 fEMCTrkPt->Fill(track->Pt());
324 fEMCTrketa->Fill(track->Eta());
325 fEMCTrkphi->Fill(track->Phi());
326 fEMCdEdx->Fill(track->P(),dEdx);
327 fEMCTPCNpts->Fill(track->P(),track->GetTPCsignalN());
330 double clustMatchE = clustMatch->E();
332 if(track->P()>0)eop = clustMatchE/track->P();
334 if(track->Pt()>2.0)fHistdEdxEop->Fill(eop,dEdx);
335 fHistEop->Fill(track->Pt(),eop);
337 //track properties of EMCAL electron cadidates
338 if(eop>0.8 and eop<1.2){
339 fEleCanTPCNpts->Fill(track->Pt(),track->GetTPCsignalN());
340 fEleCanTPCNCls->Fill(track->Pt(),track->GetTPCNcls());
343 for(Int_t l=0;l<6;l++) {
344 if(TESTBIT(track->GetITSClusterMap(),l)) {
345 fEleCanITShit->Fill(l);
346 if(l==0) fEleCanSPD1->Fill(track->Pt(),0.5);
347 if(l==1) fEleCanSPD2->Fill(track->Pt(),0.5);
348 if(l==0 && l==1) fEleCanSPDBoth->Fill(track->Pt(),0.5);
349 if(l==0 || l==1) fEleCanSPDOr->Fill(track->Pt(),0.5);
353 fEleCanITSNCls->Fill(track->Pt(),fITSncls++);
358 PostData(1, fOutputList);
360 //________________________________________________________________________
361 void AliAnalysisTaskHFEemcQA::Terminate(Option_t *)
363 // Draw result to the screen
364 // Called once at the end of the query
366 fOutputList = dynamic_cast<TList*> (GetOutputData(1));
368 printf("ERROR: Output list not available\n");