updated EMCal HFelectron QA
[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"
76e813d0 5#include "THnSparse.h"
824c6477 6
7#include "AliAnalysisTask.h"
8#include "AliAnalysisManager.h"
9
10#include "AliESDEvent.h"
11#include "AliESDInputHandler.h"
12#include "AliESDtrackCuts.h"
824c6477 13#include "AliAODEvent.h"
14#include "AliAODHandler.h"
15
76e813d0 16#include "AliPID.h"
17#include "AliESDpid.h"
18#include "AliAODPid.h"
19#include "AliPIDResponse.h"
20#include "AliHFEcontainer.h"
21#include "AliHFEcuts.h"
22#include "AliHFEpid.h"
23#include "AliHFEpidBase.h"
24#include "AliHFEpidQAmanager.h"
25#include "AliHFEtools.h"
26#include "AliCFContainer.h"
27#include "AliCFManager.h"
28
824c6477 29#include "AliAnalysisTaskHFEemcQA.h"
30
31//QA task for EMCAL electron analysis
32
33ClassImp(AliAnalysisTaskHFEemcQA)
34 //________________________________________________________________________
35 AliAnalysisTaskHFEemcQA::AliAnalysisTaskHFEemcQA(const char *name)
36: AliAnalysisTaskSE(name),
37 fVevent(0),
38 fESD(0),
39 fAOD(0),
76e813d0 40 fpidResponse(0),
41 fFlagSparse(kFALSE),
165b851a 42 fUseTender(kTRUE),
43 fTracks_tender(0),
44 fCaloClusters_tender(0),
824c6477 45 fOutputList(0),
bf5e5d9d 46 fNevents(0),
824c6477 47 fVtxZ(0),
48 fVtxX(0),
49 fVtxY(0),
50 fTrigMulti(0),
51 fHistClustE(0),
52 fEMCClsEtaPhi(0),
53 fNegTrkIDPt(0),
54 fTrkPt(0),
55 fTrketa(0),
56 fTrkphi(0),
57 fdEdx(0),
58 fTPCNpts(0),
76e813d0 59 fTPCnsig(0),
824c6477 60 fHistPtMatch(0),
61 fEMCTrkMatch(0),
62 fEMCTrkPt(0),
63 fEMCTrketa(0),
64 fEMCTrkphi(0),
65 fEMCdEdx(0),
bf5e5d9d 66 fEMCTPCnsig(0),
824c6477 67 fEMCTPCNpts(0),
68 fHistdEdxEop(0),
bf5e5d9d 69 fHistNsigEop(0),
824c6477 70 fHistEop(0),
165b851a 71 fM20(0),
72 fM02(0),
73 fM20EovP(0),
74 fM02EovP(0),
824c6477 75 fEleCanTPCNpts(0),
76 fEleCanTPCNCls(0),
77 fEleCanITSNCls(0),
78 fEleCanITShit(0),
79 fEleCanSPD1(0),
80 fEleCanSPD2(0),
81 fEleCanSPDBoth(0),
76e813d0 82 fEleCanSPDOr(0),
83 fSparseElectron(0),
84 fvalueElectron(0)
824c6477 85{
86 // Constructor
87
76e813d0 88 fvalueElectron = new Double_t[6];
824c6477 89 // Define input and output slots here
90 // Input slot #0 works with a TChain
91 DefineInput(0, TChain::Class());
92 // Output slot #0 id reserved by the base class for AOD
93 // Output slot #1 writes into a TH1 container
94 DefineOutput(1, TList::Class());
95}
76e813d0 96//________________________________________________________________________
97AliAnalysisTaskHFEemcQA::AliAnalysisTaskHFEemcQA()
98 : AliAnalysisTaskSE("DefaultTask_HfeEMCQA"),
99 fVevent(0),
100 fESD(0),
101 fAOD(0),
102 fpidResponse(0),
103 fFlagSparse(kFALSE),
165b851a 104 fUseTender(kTRUE),
105 fTracks_tender(0),
106 fCaloClusters_tender(0),
76e813d0 107 fOutputList(0),
bf5e5d9d 108 fNevents(0),
76e813d0 109 fVtxZ(0),
110 fVtxX(0),
111 fVtxY(0),
112 fTrigMulti(0),
113 fHistClustE(0),
114 fEMCClsEtaPhi(0),
115 fNegTrkIDPt(0),
116 fTrkPt(0),
117 fTrketa(0),
118 fTrkphi(0),
119 fdEdx(0),
120 fTPCNpts(0),
121 fTPCnsig(0),
122 fHistPtMatch(0),
123 fEMCTrkMatch(0),
124 fEMCTrkPt(0),
125 fEMCTrketa(0),
126 fEMCTrkphi(0),
127 fEMCdEdx(0),
bf5e5d9d 128 fEMCTPCnsig(0),
76e813d0 129 fEMCTPCNpts(0),
130 fHistdEdxEop(0),
bf5e5d9d 131 fHistNsigEop(0),
76e813d0 132 fHistEop(0),
165b851a 133 fM20(0),
134 fM02(0),
135 fM20EovP(0),
136 fM02EovP(0),
76e813d0 137 fEleCanTPCNpts(0),
138 fEleCanTPCNCls(0),
139 fEleCanITSNCls(0),
140 fEleCanITShit(0),
141 fEleCanSPD1(0),
142 fEleCanSPD2(0),
143 fEleCanSPDBoth(0),
144 fEleCanSPDOr(0),
145 fSparseElectron(0),
146 fvalueElectron(0)
147{
148 //Default constructor
824c6477 149
76e813d0 150 fvalueElectron = new Double_t[6];
151 // Define input and output slots here
152 // Input slot #0 works with a TChain
153 DefineInput(0, TChain::Class());
154 // Output slot #0 id reserved by the base class for AOD
155 // Output slot #1 writes into a TH1 container
156 // DefineOutput(1, TH1I::Class());
157 DefineOutput(1, TList::Class());
158 //DefineOutput(3, TTree::Class());
159}
160//________________________________________________________________________
161AliAnalysisTaskHFEemcQA::~AliAnalysisTaskHFEemcQA()
162{
163 //Destructor
164 delete fOutputList;
165b851a 165 delete fTracks_tender;
166 delete fCaloClusters_tender;
76e813d0 167 delete fSparseElectron;
168 delete []fvalueElectron;
169}
824c6477 170//________________________________________________________________________
171void AliAnalysisTaskHFEemcQA::UserCreateOutputObjects()
172{
173 // Create histograms
174 // Called once
76e813d0 175 AliDebug(3, "Creating Output Objects");
176
177 /////////////////////////////////////////////////
178 //Automatic determination of the analysis mode//
179 ////////////////////////////////////////////////
180 AliVEventHandler *inputHandler = dynamic_cast<AliVEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
181 if(!TString(inputHandler->IsA()->GetName()).CompareTo("AliAODInputHandler")){
182 SetAODAnalysis();
183 } else {
184 SetESDAnalysis();
185 }
186 printf("Analysis Mode: %s Analysis\n", IsAODanalysis() ? "AOD" : "ESD");
824c6477 187
76e813d0 188 ////////////////
189 //Output list//
190 ///////////////
824c6477 191 fOutputList = new TList();
a68bbaf6 192 fOutputList->SetOwner();
824c6477 193
bf5e5d9d 194 fNevents = new TH1F("fNevents","No of events",3,-0.5,2.5);
195 fOutputList->Add(fNevents);
196 fNevents->GetYaxis()->SetTitle("counts");
197 fNevents->GetXaxis()->SetBinLabel(1,"All");
198 fNevents->GetXaxis()->SetBinLabel(2,"With >2 Trks");
199 fNevents->GetXaxis()->SetBinLabel(3,"Vtx_{z}<10cm");
200
824c6477 201 fVtxZ = new TH1F("fVtxZ","Z vertex position;Vtx_{z};counts",1000,-50,50);
202 fOutputList->Add(fVtxZ);
203
204 fVtxY = new TH1F("fVtxY","Y vertex position;Vtx_{y};counts",1000,-50,50);
205 fOutputList->Add(fVtxY);
206
207 fVtxX = new TH1F("fVtxX","X vertex position;Vtx_{x};counts",1000,-50,50);
208 fOutputList->Add(fVtxX);
209
76e813d0 210 fTrigMulti = new TH2F("fTrigMulti","Multiplicity distribution for different triggers; Trigger type; multiplicity",11,-1,10,2000,0,2000);
824c6477 211 fOutputList->Add(fTrigMulti);
212
213 fHistClustE = new TH1F("fHistClustE", "EMCAL cluster energy distribution; Cluster E;counts", 500, 0.0, 50.0);
214 fOutputList->Add(fHistClustE);
215
216 fEMCClsEtaPhi = new TH2F("fEMCClsEtaPhi","EMCAL cluster #eta and #phi distribution;#eta;#phi",100,-0.9,0.9,200,0,6.3);
217 fOutputList->Add(fEMCClsEtaPhi);
218
219 fNegTrkIDPt = new TH1F("fNegTrkIDPt", "p_{T} distribution of tracks with negative track id;p_{T} (GeV/c);counts", 500, 0.0, 50.0);
220 fOutputList->Add(fNegTrkIDPt);
221
222 fTrkPt = new TH1F("fTrkPt","p_{T} distribution of all tracks;p_{T} (GeV/c);counts",1000,0,100);
223 fOutputList->Add(fTrkPt);
224
225 fTrketa = new TH1F("fTrketa","All Track #eta distribution;#eta;counts",100,-1.5,1.5);
226 fOutputList->Add(fTrketa);
227
228 fTrkphi = new TH1F("fTrkphi","All Track #phi distribution;#phi;counts",100,0,6.3);
229 fOutputList->Add(fTrkphi);
230
76e813d0 231 fdEdx = new TH2F("fdEdx","All Track dE/dx distribution;p (GeV/c);dE/dx",200,0,20,500,0,160);
824c6477 232 fOutputList->Add(fdEdx);
233
234 fTPCNpts = new TH2F("fTPCNpts","All track TPC Npoints used for dE/dx calculation;p (GeV/c);N points",200,0,20,200,0.,200.);
235 fOutputList->Add(fTPCNpts);
236
76e813d0 237 fTPCnsig = new TH2F("fTPCnsig","All Track TPC Nsigma distribution;p (GeV/c);#sigma_{TPC-dE/dx}",1000,0,50,200,-10,10);
238 fOutputList->Add(fTPCnsig);
239
824c6477 240 fHistPtMatch = new TH1F("fHistPtMatch", "p_{T} distribution of tracks matched to EMCAL;p_{T} (GeV/c);counts",1000, 0.0, 100.0);
241 fOutputList->Add(fHistPtMatch);
242
243 fEMCTrkMatch = new TH2F("fEMCTrkMatch","Distance of EMCAL cluster to its closest track;#phi;z",100,-0.3,0.3,100,-0.3,0.3);
244 fOutputList->Add(fEMCTrkMatch);
245
246 fEMCTrkPt = new TH1F("fEMCTrkPt","p_{T} distribution of tracks with EMCAL cluster;p_{T} (GeV/c);counts",1000,0,100);
247 fOutputList->Add(fEMCTrkPt);
248
249 fEMCTrketa = new TH1F("fEMCTrketa","#eta distribution of tracks matched to EMCAL;#eta;counts",100,-1.5,1.5);
250 fOutputList->Add(fEMCTrketa);
251
252 fEMCTrkphi = new TH1F("fEMCTrkphi","#phi distribution of tracks matched to EMCAL;#phi;counts",100,0,6.3);
253 fOutputList->Add(fEMCTrkphi);
254
76e813d0 255 fEMCdEdx = new TH2F("fEMCdEdx","dE/dx distribution of tracks matched to EMCAL;p (GeV/c);dE/dx",200,0,20,500,0,160);
824c6477 256 fOutputList->Add(fEMCdEdx);
165b851a 257
bf5e5d9d 258 fEMCTPCnsig = new TH2F("fEMCTPCnsig","TPC Nsigma distribution of tracks matched to EMCAL;p (GeV/c);#sigma_{TPC-dE/dx}",1000,0,50,200,-10,10);
259 fOutputList->Add(fEMCTPCnsig);
824c6477 260
261 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.);
262 fOutputList->Add(fEMCTPCNpts);
263
264 fHistEop = new TH2F("fHistEop", "E/p distribution;p_{T} (GeV/c);E/p", 200,0,20,60, 0.0, 3.0);
265 fOutputList->Add(fHistEop);
266
bf5e5d9d 267 fHistdEdxEop = new TH2F("fHistdEdxEop", "E/p vs dE/dx;E/p;dE/dx", 60, 0.0, 3.0, 500,0,160);
824c6477 268 fOutputList->Add(fHistdEdxEop);
165b851a 269
bf5e5d9d 270 fHistNsigEop = new TH2F ("fHistNsigEop", "E/p vs TPC nsig",60, 0.0, 3.0, 200, -10,10);
271 fOutputList->Add(fHistNsigEop);
824c6477 272
165b851a 273 fM20 = new TH2F ("fM20","M20 vs pt distribution",200,0,20,400,0,2);
274 fOutputList->Add(fM20);
275
276 fM02 = new TH2F ("fM02","M02 vs pt distribution",200,0,20,400,0,2);
277 fOutputList->Add(fM02);
278
279 fM20EovP = new TH2F ("fM20EovP","M20 vs E/p distribution",400,0,3,400,0,2);
280 fOutputList->Add(fM20EovP);
281
282 fM02EovP = new TH2F ("fM02EovP","M02 vs E/p distribution",400,0,3,400,0,2);
283 fOutputList->Add(fM02EovP);
284
824c6477 285 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);
286 fOutputList->Add(fEleCanTPCNpts);
287
288 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);
289 fOutputList->Add(fEleCanTPCNCls);
290
291 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);
292 fOutputList->Add(fEleCanITSNCls);
293
294 fEleCanITShit = new TH1F("fEleCanITShit","ITS hit map;ITS layer;counts",7,-0.5,6.5);
295 fOutputList->Add(fEleCanITShit);
296
297 fEleCanSPD1 = new TH2F("fEleCanSPD1","Hit on SPD layer 1;p_{T} (GeV/c);Hit",200,0,20,1,0,1);
298 fOutputList->Add(fEleCanSPD1);
299
300 fEleCanSPD2 = new TH2F("fEleCanSPD2","Hit on SPD layer 2;p_{T} (GeV/c);Hit",200,0,20,1,0,1);
301 fOutputList->Add(fEleCanSPD2);
302
303 fEleCanSPDBoth = new TH2F("fEleCanSPDBoth","Tracks with hits on both SPD layer;p_{T} (GeV/c);Hit",200,0,20,1,0,1);
304 fOutputList->Add(fEleCanSPDBoth);
305
306 fEleCanSPDOr = new TH2F("fEleCanSPDOr","Tracks with hits on both SPD layer;p_{T} (GeV/c);Hit",200,0,20,1,0,1);
307 fOutputList->Add(fEleCanSPDOr);
308
bf5e5d9d 309 Int_t bins[6]={8,500,200,400,400,400}; //trigger, pt, TPCnsig, E/p, M20, M02
310 Double_t xmin[6]={-0.5,0,-10,0,0,0};
311 Double_t xmax[6]={7.5,25,10,2,2,2};
76e813d0 312 fSparseElectron = new THnSparseD ("Electron","Electron",6,bins,xmin,xmax);
313 fOutputList->Add(fSparseElectron);
314
824c6477 315 PostData(1,fOutputList);
316}
317
318//________________________________________________________________________
319void AliAnalysisTaskHFEemcQA::UserExec(Option_t *)
320{
321 // Main loop
322 // Called for each event
323 // Post output data.
324
325 UInt_t evSelMask=((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
326
327 fVevent = dynamic_cast<AliVEvent*>(InputEvent());
328 if (!fVevent) {
329 printf("ERROR: fVEvent not available\n");
330 return;
331 }
332
333 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
334 if (fESD) {
76e813d0 335 // printf("fESD available\n");
824c6477 336 //return;
337 }
165b851a 338
339 //////////////
340 //if Tender //
341 //////////////
342 if(fUseTender){
343 //new branches with calibrated tracks and clusters
344 if(IsAODanalysis()) fTracks_tender = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("AODFilterTracks"));
345 if(!IsAODanalysis()) fTracks_tender = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("ESDFilterTracks"));
346
347 fCaloClusters_tender = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("EmcCaloClusters"));
348 }
824c6477 349
76e813d0 350 ////////////////////
351 //cuts initialised//
352 ///////////////////
824c6477 353 AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
354 esdTrackCutsH->SetMaxDCAToVertexXY(2.4);
355 esdTrackCutsH->SetMaxDCAToVertexZ(3.2);
356 esdTrackCutsH->SetDCAToVertex2D(kTRUE);
357
358 fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
359 if (fAOD) {
76e813d0 360 // printf("fAOD available\n");
824c6477 361 //return;
362 }
363
76e813d0 364 ///////////////////
365 //PID initialised//
366 //////////////////
367 fpidResponse = fInputHandler->GetPIDResponse();
368
369 ////////////////
370 //Event vertex//
371 ///////////////
372 Int_t ntracks;
165b851a 373 if(!fUseTender)ntracks = fVevent->GetNumberOfTracks();
374 if(fUseTender) ntracks = fTracks_tender->GetEntries();
824c6477 375 printf("There are %d tracks in this event\n",ntracks);
824c6477 376
bf5e5d9d 377 fNevents->Fill(0); //all events
76e813d0 378 Double_t Zvertex = -100, Xvertex = -100, Yvertex = -100;
824c6477 379 const AliVVertex *pVtx = fVevent->GetPrimaryVertex();
76e813d0 380 Double_t NcontV = pVtx->GetNContributors();
381 if(NcontV<2)return;
bf5e5d9d 382 fNevents->Fill(1); //events with 2 tracks
76e813d0 383
824c6477 384 Zvertex = pVtx->GetZ();
385 Yvertex = pVtx->GetY();
386 Xvertex = pVtx->GetX();
387 fVtxZ->Fill(Zvertex);
388 fVtxX->Fill(Xvertex);
389 fVtxY->Fill(Yvertex);
76e813d0 390
391 /////////////////
392 //trigger check//
393 /////////////////
824c6477 394 TString firedTrigger;
395 TString TriggerEG1("EG1");
396 TString TriggerEG2("EG2");
397 fVevent->GetFiredTriggerClasses();
824c6477 398
399 Bool_t EG1tr = kFALSE;
400 Bool_t EG2tr = kFALSE;
401
402 if(firedTrigger.Contains(TriggerEG1))EG1tr = kTRUE;
403 if(firedTrigger.Contains(TriggerEG2))EG2tr = kTRUE;
824c6477 404
76e813d0 405 Int_t trigger = -1;
824c6477 406 if (fAOD){
407 Double_t multiplicity=fAOD->GetHeader()->GetRefMultiplicity();
408 fTrigMulti->Fill(-0.5, multiplicity);
409 if(evSelMask & AliVEvent::kAny) fTrigMulti->Fill(0.5, multiplicity);
410 if(evSelMask & AliVEvent::kMB) fTrigMulti->Fill(1.5, multiplicity);
76e813d0 411 if(evSelMask & AliVEvent::kINT7) fTrigMulti->Fill(2.5, multiplicity);
412 if(evSelMask & AliVEvent::kINT8) fTrigMulti->Fill(3.5, multiplicity);
413 if(evSelMask & AliVEvent::kEMC1) fTrigMulti->Fill(4.5, multiplicity);
414 if(evSelMask & AliVEvent::kEMC7) fTrigMulti->Fill(5.5, multiplicity);
415 if(evSelMask & AliVEvent::kEMC8) fTrigMulti->Fill(6.5, multiplicity);
416 if(evSelMask & AliVEvent::kEMCEJE) fTrigMulti->Fill(7.5, multiplicity);
417 if(evSelMask & AliVEvent::kEMCEGA) fTrigMulti->Fill(8.5, multiplicity);
418 if(evSelMask & AliVEvent::kEMCEGA & EG2tr) fTrigMulti->Fill(9.5, multiplicity);
419
bf5e5d9d 420 if(evSelMask & AliVEvent::kMB) trigger =0;
421 if(evSelMask & AliVEvent::kINT7) trigger =1;
422 if(evSelMask & AliVEvent::kINT8) trigger =2;
423 if(evSelMask & AliVEvent::kEMC1) trigger =3;
424 if(evSelMask & AliVEvent::kEMC7) trigger =4;
425 if(evSelMask & AliVEvent::kEMC8) trigger =5;
426 if(evSelMask & AliVEvent::kEMCEJE) trigger =6;
427 if(evSelMask & AliVEvent::kEMCEGA) trigger =7;
824c6477 428 }
429
76e813d0 430 ////////////////////
431 //event selection//
432 ///////////////////
824c6477 433 if(fabs(Zvertex>10.0))return;
bf5e5d9d 434 fNevents->Fill(2); //events after z vtx cut
76e813d0 435
436 /////////////////////////////
437 //EMCAL cluster information//
438 ////////////////////////////
165b851a 439 Int_t Nclust = -999;
440 if(!fUseTender) Nclust = fVevent->GetNumberOfCaloClusters();
441 if(fUseTender) Nclust = fCaloClusters_tender->GetEntries();
824c6477 442 for(Int_t icl=0; icl<Nclust; icl++)
443 {
444 AliVCluster *clust = 0x0;
165b851a 445 if(!fUseTender) clust = fVevent->GetCaloCluster(icl);
446 if(fUseTender) clust = dynamic_cast<AliVCluster*>(fCaloClusters_tender->At(icl));
447 if(!clust) printf("ERROR: Could not receive cluster matched calibrated from track %d\n", icl);
448
824c6477 449 if(clust && clust->IsEMCAL())
450 {
76e813d0 451 Double_t clustE = clust->E();
452 Float_t emcx[3]; // cluster pos
824c6477 453 clust->GetPosition(emcx);
454 TVector3 clustpos(emcx[0],emcx[1],emcx[2]);
76e813d0 455 Double_t emcphi = clustpos.Phi();
456 Double_t emceta = clustpos.Eta();
824c6477 457 fHistClustE->Fill(clustE);
458 fEMCClsEtaPhi->Fill(emceta,emcphi);
459 }
460 }
461
76e813d0 462 /////////////////////////////////
463 //Look for kink mother for AOD//
464 /////////////////////////////////
bf5e5d9d 465 Int_t numberofvertices = 100;
466 if(fAOD) numberofvertices = fAOD->GetNumberOfVertices();
76e813d0 467 Double_t listofmotherkink[numberofvertices];
468 Int_t numberofmotherkink = 0;
bf5e5d9d 469 if(IsAODanalysis())
470 {
76e813d0 471 for(Int_t ivertex=0; ivertex < numberofvertices; ivertex++) {
472 AliAODVertex *aodvertex = fAOD->GetVertex(ivertex);
473 if(!aodvertex) continue;
474 if(aodvertex->GetType()==AliAODVertex::kKink) {
475 AliAODTrack *mother = (AliAODTrack *) aodvertex->GetParent();
476 if(!mother) continue;
477 Int_t idmother = mother->GetID();
478 listofmotherkink[numberofmotherkink] = idmother;
479 numberofmotherkink++;
480 }
481 }
bf5e5d9d 482 } //+++
483
76e813d0 484
485 ///////////////
bf5e5d9d 486 //Track loop///
76e813d0 487 ///////////////
824c6477 488 for (Int_t iTracks = 0; iTracks < ntracks; iTracks++) {
76e813d0 489
165b851a 490 AliVParticle* Vtrack = 0x0;
491 if(!fUseTender) Vtrack = fVevent->GetTrack(iTracks);
492 if(fUseTender) Vtrack = dynamic_cast<AliVTrack*>(fTracks_tender->At(iTracks));
493
824c6477 494 if (!Vtrack) {
495 printf("ERROR: Could not receive track %d\n", iTracks);
496 continue;
497 }
498 AliVTrack *track = dynamic_cast<AliVTrack*>(Vtrack);
499 AliESDtrack *etrack = dynamic_cast<AliESDtrack*>(Vtrack);
500 AliAODTrack *atrack = dynamic_cast<AliAODTrack*>(Vtrack);
501
76e813d0 502 ////////////////////
503 //Apply track cuts//
504 ////////////////////
824c6477 505 if(fAOD)
bf5e5d9d 506 if(!atrack->TestFilterMask(AliAODTrack::kTrkGlobalNoDCA)) continue; //mimimum cuts
824c6477 507
508 if(fESD)
509 if(!esdTrackCutsH->AcceptTrack(etrack))continue;
510
bf5e5d9d 511 //reject kink
76e813d0 512 if(IsAODanalysis()){
513 Bool_t kinkmotherpass = kTRUE;
514 for(Int_t kinkmother = 0; kinkmother < numberofmotherkink; kinkmother++) {
515 if(track->GetID() == listofmotherkink[kinkmother]) {
516 kinkmotherpass = kFALSE;
517 continue;
518 }
519 }
520 if(!kinkmotherpass) continue;
521 }
522 else{
523 if(etrack->GetKinkIndex(0) != 0) continue;
524 }
525
526 ////////////////////
527 //Track properties//
528 ///////////////////
529 Double_t dEdx =-999, fTPCnSigma=-999;
530 dEdx = track->GetTPCsignal();
531 fTPCnSigma = fpidResponse->NumberOfSigmasTPC(track, AliPID::kElectron);
bf5e5d9d 532
824c6477 533 if(track->GetID()<0) fNegTrkIDPt->Fill(track->Pt());
534 fTrkPt->Fill(track->Pt());
535 fTrketa->Fill(track->Eta());
536 fTrkphi->Fill(track->Phi());
537 fdEdx->Fill(track->P(),dEdx);
538 fTPCNpts->Fill(track->P(),track->GetTPCsignalN());
76e813d0 539 fTPCnsig->Fill(track->P(),fTPCnSigma);
824c6477 540
76e813d0 541 ///////////////////////////
542 //Track matching to EMCAL//
543 //////////////////////////
544 Int_t EMCalIndex = -1;
824c6477 545 EMCalIndex = track->GetEMCALcluster();
546 if(EMCalIndex < 0) continue;
547 fHistPtMatch->Fill(track->Pt());
548
76e813d0 549 AliVCluster *clustMatch = (AliVCluster*)fVevent->GetCaloCluster(EMCalIndex);
550 if(clustMatch && clustMatch->IsEMCAL())
824c6477 551 {
76e813d0 552 /////////////////////////////////////////////
553 //Properties of tracks matched to the EMCAL//
554 /////////////////////////////////////////////
824c6477 555 fEMCTrkMatch->Fill(clustMatch->GetTrackDx(),clustMatch->GetTrackDz());
824c6477 556 fEMCTrkPt->Fill(track->Pt());
557 fEMCTrketa->Fill(track->Eta());
558 fEMCTrkphi->Fill(track->Phi());
559 fEMCdEdx->Fill(track->P(),dEdx);
bf5e5d9d 560 fEMCTPCnsig->Fill(track->P(),fTPCnSigma);
824c6477 561 fEMCTPCNpts->Fill(track->P(),track->GetTPCsignalN());
562
563 //E/p distribution
76e813d0 564 Double_t clustMatchE = clustMatch->E();
565 Double_t eop = -1.0;
165b851a 566 Double_t m02 = -99999;
824c6477 567 if(track->P()>0)eop = clustMatchE/track->P();
165b851a 568 m02 =clustMatch->GetM02();
824c6477 569
bf5e5d9d 570 if(track->Pt()>1.0){
571 fHistdEdxEop->Fill(eop,dEdx);
572 fHistNsigEop->Fill(eop,fTPCnSigma);
165b851a 573 fM20EovP->Fill(eop,clustMatch->GetM20());
574 fM02EovP->Fill(eop,clustMatch->GetM02());
bf5e5d9d 575 }
165b851a 576
824c6477 577 fHistEop->Fill(track->Pt(),eop);
165b851a 578 fM20->Fill(track->Pt(),clustMatch->GetM20());
579 fM02->Fill(track->Pt(),clustMatch->GetM02());
824c6477 580
76e813d0 581 //EID THnsparse
582 fvalueElectron[0] = trigger;
583 fvalueElectron[1] = track->Pt();
584 fvalueElectron[2] = fTPCnSigma;
585 fvalueElectron[3] = eop;
586 fvalueElectron[4] = clustMatch->GetM20();
587 fvalueElectron[5] = clustMatch->GetM02();
588
76e813d0 589 if(fFlagSparse){
590 cout << "filling sparse"<<endl;
591 fSparseElectron->Fill(fvalueElectron);
592 }
593
594 ////////////////////////////////////////////////
595 //Track properties of EMCAL electron cadidates//
596 ///////////////////////////////////////////////
165b851a 597 if(fTPCnSigma > -1 && fTPCnSigma < 3 && eop>0.9 && eop<1.2 && m02 > 0.006 && m02 < 0.035){
824c6477 598 fEleCanTPCNpts->Fill(track->Pt(),track->GetTPCsignalN());
599 fEleCanTPCNCls->Fill(track->Pt(),track->GetTPCNcls());
600
601 Int_t fITSncls=0;
602 for(Int_t l=0;l<6;l++) {
603 if(TESTBIT(track->GetITSClusterMap(),l)) {
604 fEleCanITShit->Fill(l);
605 if(l==0) fEleCanSPD1->Fill(track->Pt(),0.5);
606 if(l==1) fEleCanSPD2->Fill(track->Pt(),0.5);
607 if(l==0 && l==1) fEleCanSPDBoth->Fill(track->Pt(),0.5);
608 if(l==0 || l==1) fEleCanSPDOr->Fill(track->Pt(),0.5);
609 fITSncls++;
610 }
611 }
612 fEleCanITSNCls->Fill(track->Pt(),fITSncls++);
613 }
614 }
615 } //track loop
616
617 PostData(1, fOutputList);
618}
619//________________________________________________________________________
620void AliAnalysisTaskHFEemcQA::Terminate(Option_t *)
621{
622 // Draw result to the screen
623 // Called once at the end of the query
624
625 fOutputList = dynamic_cast<TList*> (GetOutputData(1));
626 if (!fOutputList) {
627 printf("ERROR: Output list not available\n");
628 return;
629 }
630
631}