7 #include "AliAnalysisTask.h"
8 #include "AliAnalysisManager.h"
10 #include "AliESDEvent.h"
11 #include "AliESDInputHandler.h"
12 #include "AliESDtrackCuts.h"
13 #include "AliAODEvent.h"
14 #include "AliAODHandler.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"
29 #include "AliAnalysisTaskHFEemcQA.h"
31 //QA task for EMCAL electron analysis
33 ClassImp(AliAnalysisTaskHFEemcQA)
34 //________________________________________________________________________
35 AliAnalysisTaskHFEemcQA::AliAnalysisTaskHFEemcQA(const char *name)
36 : AliAnalysisTaskSE(name),
44 fCaloClusters_tender(0),
88 fvalueElectron = new Double_t[6];
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());
96 //________________________________________________________________________
97 AliAnalysisTaskHFEemcQA::AliAnalysisTaskHFEemcQA()
98 : AliAnalysisTaskSE("DefaultTask_HfeEMCQA"),
106 fCaloClusters_tender(0),
148 //Default constructor
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());
160 //________________________________________________________________________
161 AliAnalysisTaskHFEemcQA::~AliAnalysisTaskHFEemcQA()
165 delete fTracks_tender;
166 delete fCaloClusters_tender;
167 delete fSparseElectron;
168 delete []fvalueElectron;
170 //________________________________________________________________________
171 void AliAnalysisTaskHFEemcQA::UserCreateOutputObjects()
175 AliDebug(3, "Creating Output Objects");
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")){
186 printf("Analysis Mode: %s Analysis\n", IsAODanalysis() ? "AOD" : "ESD");
191 fOutputList = new TList();
192 fOutputList->SetOwner();
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");
201 fVtxZ = new TH1F("fVtxZ","Z vertex position;Vtx_{z};counts",1000,-50,50);
202 fOutputList->Add(fVtxZ);
204 fVtxY = new TH1F("fVtxY","Y vertex position;Vtx_{y};counts",1000,-50,50);
205 fOutputList->Add(fVtxY);
207 fVtxX = new TH1F("fVtxX","X vertex position;Vtx_{x};counts",1000,-50,50);
208 fOutputList->Add(fVtxX);
210 fTrigMulti = new TH2F("fTrigMulti","Multiplicity distribution for different triggers; Trigger type; multiplicity",11,-1,10,2000,0,2000);
211 fOutputList->Add(fTrigMulti);
213 fHistClustE = new TH1F("fHistClustE", "EMCAL cluster energy distribution; Cluster E;counts", 500, 0.0, 50.0);
214 fOutputList->Add(fHistClustE);
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);
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);
222 fTrkPt = new TH1F("fTrkPt","p_{T} distribution of all tracks;p_{T} (GeV/c);counts",1000,0,100);
223 fOutputList->Add(fTrkPt);
225 fTrketa = new TH1F("fTrketa","All Track #eta distribution;#eta;counts",100,-1.5,1.5);
226 fOutputList->Add(fTrketa);
228 fTrkphi = new TH1F("fTrkphi","All Track #phi distribution;#phi;counts",100,0,6.3);
229 fOutputList->Add(fTrkphi);
231 fdEdx = new TH2F("fdEdx","All Track dE/dx distribution;p (GeV/c);dE/dx",200,0,20,500,0,160);
232 fOutputList->Add(fdEdx);
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);
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);
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);
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);
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);
249 fEMCTrketa = new TH1F("fEMCTrketa","#eta distribution of tracks matched to EMCAL;#eta;counts",100,-1.5,1.5);
250 fOutputList->Add(fEMCTrketa);
252 fEMCTrkphi = new TH1F("fEMCTrkphi","#phi distribution of tracks matched to EMCAL;#phi;counts",100,0,6.3);
253 fOutputList->Add(fEMCTrkphi);
255 fEMCdEdx = new TH2F("fEMCdEdx","dE/dx distribution of tracks matched to EMCAL;p (GeV/c);dE/dx",200,0,20,500,0,160);
256 fOutputList->Add(fEMCdEdx);
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);
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);
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);
267 fHistdEdxEop = new TH2F("fHistdEdxEop", "E/p vs dE/dx;E/p;dE/dx", 60, 0.0, 3.0, 500,0,160);
268 fOutputList->Add(fHistdEdxEop);
270 fHistNsigEop = new TH2F ("fHistNsigEop", "E/p vs TPC nsig",60, 0.0, 3.0, 200, -10,10);
271 fOutputList->Add(fHistNsigEop);
273 fM20 = new TH2F ("fM20","M20 vs pt distribution",200,0,20,400,0,2);
274 fOutputList->Add(fM20);
276 fM02 = new TH2F ("fM02","M02 vs pt distribution",200,0,20,400,0,2);
277 fOutputList->Add(fM02);
279 fM20EovP = new TH2F ("fM20EovP","M20 vs E/p distribution",400,0,3,400,0,2);
280 fOutputList->Add(fM20EovP);
282 fM02EovP = new TH2F ("fM02EovP","M02 vs E/p distribution",400,0,3,400,0,2);
283 fOutputList->Add(fM02EovP);
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);
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);
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);
294 fEleCanITShit = new TH1F("fEleCanITShit","ITS hit map;ITS layer;counts",7,-0.5,6.5);
295 fOutputList->Add(fEleCanITShit);
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);
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);
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);
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);
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};
312 fSparseElectron = new THnSparseD ("Electron","Electron",6,bins,xmin,xmax);
313 fOutputList->Add(fSparseElectron);
315 PostData(1,fOutputList);
318 //________________________________________________________________________
319 void AliAnalysisTaskHFEemcQA::UserExec(Option_t *)
322 // Called for each event
325 UInt_t evSelMask=((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
327 fVevent = dynamic_cast<AliVEvent*>(InputEvent());
329 printf("ERROR: fVEvent not available\n");
333 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
335 // printf("fESD available\n");
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"));
347 fCaloClusters_tender = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("EmcCaloClusters"));
353 AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kFALSE);
354 esdTrackCutsH->SetMaxDCAToVertexXY(2.4);
355 esdTrackCutsH->SetMaxDCAToVertexZ(3.2);
356 esdTrackCutsH->SetDCAToVertex2D(kTRUE);
358 fAOD = dynamic_cast<AliAODEvent*>(InputEvent());
360 // printf("fAOD available\n");
367 fpidResponse = fInputHandler->GetPIDResponse();
373 if(!fUseTender)ntracks = fVevent->GetNumberOfTracks();
374 if(fUseTender) ntracks = fTracks_tender->GetEntries();
375 printf("There are %d tracks in this event\n",ntracks);
377 fNevents->Fill(0); //all events
378 Double_t Zvertex = -100, Xvertex = -100, Yvertex = -100;
379 const AliVVertex *pVtx = fVevent->GetPrimaryVertex();
380 Double_t NcontV = pVtx->GetNContributors();
382 fNevents->Fill(1); //events with 2 tracks
384 Zvertex = pVtx->GetZ();
385 Yvertex = pVtx->GetY();
386 Xvertex = pVtx->GetX();
387 fVtxZ->Fill(Zvertex);
388 fVtxX->Fill(Xvertex);
389 fVtxY->Fill(Yvertex);
394 TString firedTrigger;
395 TString TriggerEG1("EG1");
396 TString TriggerEG2("EG2");
397 fVevent->GetFiredTriggerClasses();
399 Bool_t EG1tr = kFALSE;
400 Bool_t EG2tr = kFALSE;
402 if(firedTrigger.Contains(TriggerEG1))EG1tr = kTRUE;
403 if(firedTrigger.Contains(TriggerEG2))EG2tr = kTRUE;
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);
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);
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;
433 if(fabs(Zvertex>10.0))return;
434 fNevents->Fill(2); //events after z vtx cut
436 /////////////////////////////
437 //EMCAL cluster information//
438 ////////////////////////////
440 if(!fUseTender) Nclust = fVevent->GetNumberOfCaloClusters();
441 if(fUseTender) Nclust = fCaloClusters_tender->GetEntries();
442 for(Int_t icl=0; icl<Nclust; icl++)
444 AliVCluster *clust = 0x0;
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);
449 if(clust && clust->IsEMCAL())
451 Double_t clustE = clust->E();
452 Float_t emcx[3]; // cluster pos
453 clust->GetPosition(emcx);
454 TVector3 clustpos(emcx[0],emcx[1],emcx[2]);
455 Double_t emcphi = clustpos.Phi();
456 Double_t emceta = clustpos.Eta();
457 fHistClustE->Fill(clustE);
458 fEMCClsEtaPhi->Fill(emceta,emcphi);
462 /////////////////////////////////
463 //Look for kink mother for AOD//
464 /////////////////////////////////
465 Int_t numberofvertices = 100;
466 if(fAOD) numberofvertices = fAOD->GetNumberOfVertices();
467 Double_t listofmotherkink[numberofvertices];
468 Int_t numberofmotherkink = 0;
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++;
488 for (Int_t iTracks = 0; iTracks < ntracks; iTracks++) {
490 AliVParticle* Vtrack = 0x0;
491 if(!fUseTender) Vtrack = fVevent->GetTrack(iTracks);
492 if(fUseTender) Vtrack = dynamic_cast<AliVTrack*>(fTracks_tender->At(iTracks));
495 printf("ERROR: Could not receive track %d\n", iTracks);
498 AliVTrack *track = dynamic_cast<AliVTrack*>(Vtrack);
499 AliESDtrack *etrack = dynamic_cast<AliESDtrack*>(Vtrack);
500 AliAODTrack *atrack = dynamic_cast<AliAODTrack*>(Vtrack);
506 if(!atrack->TestFilterMask(AliAODTrack::kTrkGlobalNoDCA)) continue; //mimimum cuts
509 if(!esdTrackCutsH->AcceptTrack(etrack))continue;
513 Bool_t kinkmotherpass = kTRUE;
514 for(Int_t kinkmother = 0; kinkmother < numberofmotherkink; kinkmother++) {
515 if(track->GetID() == listofmotherkink[kinkmother]) {
516 kinkmotherpass = kFALSE;
520 if(!kinkmotherpass) continue;
523 if(etrack->GetKinkIndex(0) != 0) continue;
529 Double_t dEdx =-999, fTPCnSigma=-999;
530 dEdx = track->GetTPCsignal();
531 fTPCnSigma = fpidResponse->NumberOfSigmasTPC(track, AliPID::kElectron);
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());
539 fTPCnsig->Fill(track->P(),fTPCnSigma);
541 ///////////////////////////
542 //Track matching to EMCAL//
543 //////////////////////////
544 Int_t EMCalIndex = -1;
545 EMCalIndex = track->GetEMCALcluster();
546 if(EMCalIndex < 0) continue;
547 fHistPtMatch->Fill(track->Pt());
549 AliVCluster *clustMatch = (AliVCluster*)fVevent->GetCaloCluster(EMCalIndex);
550 if(clustMatch && clustMatch->IsEMCAL())
552 /////////////////////////////////////////////
553 //Properties of tracks matched to the EMCAL//
554 /////////////////////////////////////////////
555 fEMCTrkMatch->Fill(clustMatch->GetTrackDx(),clustMatch->GetTrackDz());
556 fEMCTrkPt->Fill(track->Pt());
557 fEMCTrketa->Fill(track->Eta());
558 fEMCTrkphi->Fill(track->Phi());
559 fEMCdEdx->Fill(track->P(),dEdx);
560 fEMCTPCnsig->Fill(track->P(),fTPCnSigma);
561 fEMCTPCNpts->Fill(track->P(),track->GetTPCsignalN());
564 Double_t clustMatchE = clustMatch->E();
566 Double_t m02 = -99999;
567 if(track->P()>0)eop = clustMatchE/track->P();
568 m02 =clustMatch->GetM02();
571 fHistdEdxEop->Fill(eop,dEdx);
572 fHistNsigEop->Fill(eop,fTPCnSigma);
573 fM20EovP->Fill(eop,clustMatch->GetM20());
574 fM02EovP->Fill(eop,clustMatch->GetM02());
577 fHistEop->Fill(track->Pt(),eop);
578 fM20->Fill(track->Pt(),clustMatch->GetM20());
579 fM02->Fill(track->Pt(),clustMatch->GetM02());
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();
590 cout << "filling sparse"<<endl;
591 fSparseElectron->Fill(fvalueElectron);
594 ////////////////////////////////////////////////
595 //Track properties of EMCAL electron cadidates//
596 ///////////////////////////////////////////////
597 if(fTPCnSigma > -1 && fTPCnSigma < 3 && eop>0.9 && eop<1.2 && m02 > 0.006 && m02 < 0.035){
598 fEleCanTPCNpts->Fill(track->Pt(),track->GetTPCsignalN());
599 fEleCanTPCNCls->Fill(track->Pt(),track->GetTPCNcls());
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);
612 fEleCanITSNCls->Fill(track->Pt(),fITSncls++);
617 PostData(1, fOutputList);
619 //________________________________________________________________________
620 void AliAnalysisTaskHFEemcQA::Terminate(Option_t *)
622 // Draw result to the screen
623 // Called once at the end of the query
625 fOutputList = dynamic_cast<TList*> (GetOutputData(1));
627 printf("ERROR: Output list not available\n");