3 // Track/cluster matcher
5 // Author: C.Loizides, S.Aiola
7 #include "AliEmcalClusTrackMatcherTask.h"
9 #include <TClonesArray.h>
11 #include "AliEmcalParticle.h"
13 #include "AliPicoTrack.h"
14 #include "AliVCluster.h"
15 #include "AliVTrack.h"
17 ClassImp(AliEmcalClusTrackMatcherTask)
19 //________________________________________________________________________
20 AliEmcalClusTrackMatcherTask::AliEmcalClusTrackMatcherTask() :
21 AliAnalysisTaskEmcal("AliEmcalClusTrackMatcherTask",kFALSE),
26 for(Int_t icent=0; icent<8; ++icent) {
27 for(Int_t ipt=0; ipt<9; ++ipt) {
28 for(Int_t ieta=0; ieta<2; ++ieta) {
29 fHistMatchEta[icent][ipt][ieta] = 0;
30 fHistMatchPhi[icent][ipt][ieta] = 0;
36 //________________________________________________________________________
37 AliEmcalClusTrackMatcherTask::AliEmcalClusTrackMatcherTask(const char *name, Bool_t histo) :
38 AliAnalysisTaskEmcal(name,histo),
41 // Standard constructor.
43 for(Int_t icent=0; icent<8; ++icent) {
44 for(Int_t ipt=0; ipt<9; ++ipt) {
45 for(Int_t ieta=0; ieta<2; ++ieta) {
46 fHistMatchEta[icent][ipt][ieta] = 0;
47 fHistMatchPhi[icent][ipt][ieta] = 0;
53 //________________________________________________________________________
54 AliEmcalClusTrackMatcherTask::~AliEmcalClusTrackMatcherTask()
59 //________________________________________________________________________
60 void AliEmcalClusTrackMatcherTask::UserCreateOutputObjects()
62 // Create my user objects.
67 AliAnalysisTaskEmcal::UserCreateOutputObjects();
69 for(Int_t icent=0; icent<8; ++icent) {
70 for(Int_t ipt=0; ipt<9; ++ipt) {
71 for(Int_t ieta=0; ieta<2; ++ieta) {
72 TString nameEta(Form("fHistMatchEta_%i_%i_%i",icent,ipt,ieta));
73 fHistMatchEta[icent][ipt][ieta] = new TH1F(nameEta, nameEta, 400, -0.2, 0.2);
74 TString namePhi(Form("fHistMatchPhi_%i_%i_%i",icent,ipt,ieta));
75 fHistMatchPhi[icent][ipt][ieta] = new TH1F(namePhi, namePhi, 400, -0.2, 0.2);
76 fOutput->Add(fHistMatchEta[icent][ipt][ieta]);
77 fOutput->Add(fHistMatchPhi[icent][ipt][ieta]);
85 //________________________________________________________________________
86 Int_t AliEmcalClusTrackMatcherTask::GetMomBin(Double_t p) const
93 else if (p>=0.5 && p<1.0)
95 else if (p>=1.0 && p<1.5)
97 else if (p>=1.5 && p<2.)
99 else if (p>=2. && p<3.)
101 else if (p>=3. && p<4.)
103 else if (p>=4. && p<5.)
105 else if (p>=5. && p<8.)
113 //________________________________________________________________________
114 Bool_t AliEmcalClusTrackMatcherTask::Run()
116 // Run the matching for the selected options.
118 const Double_t maxd2 = fMaxDistance*fMaxDistance;
120 const Int_t nC = fCaloClusters->GetEntries();
121 const Int_t nT = fTracks->GetEntries();
123 // set the links between tracks and clusters
124 for (Int_t c = 0; c < nC; ++c) {
125 AliEmcalParticle *partC = static_cast<AliEmcalParticle*>(fCaloClusters->At(c));
128 if (!AcceptEmcalPart(partC))
130 for (Int_t t = 0; t < nT; ++t) {
131 AliEmcalParticle *partT = static_cast<AliEmcalParticle*>(fTracks->At(t));
134 if (!AcceptEmcalPart(partT))
136 AliVCluster *clust = partC->GetCluster();
137 AliVTrack *track = partT->GetTrack() ;
140 AliPicoTrack::GetEtaPhiDiff(track, clust, dphi, deta);
141 Double_t d2 = deta * deta + dphi * dphi;
144 Double_t d = TMath::Sqrt(d2);
145 partC->AddMatchedObj(t, d);
146 partT->AddMatchedObj(c, d);
149 Int_t mombin = GetMomBin(track->P());
150 Int_t centbinch = fCentBin;
151 if (track->Charge()<0)
157 fHistMatchEta[centbinch][mombin][etabin]->Fill(deta);
158 fHistMatchPhi[centbinch][mombin][etabin]->Fill(dphi);
163 for (Int_t c = 0; c < nC; ++c) {
164 AliEmcalParticle *partC = static_cast<AliEmcalParticle*>(fCaloClusters->At(c));
167 if (partC->GetNumberOfMatchedObj() <= 0)
169 const UInt_t matchedId = partC->GetMatchedObjId();
170 AliEmcalParticle *partT = static_cast<AliEmcalParticle*>(fTracks->At(matchedId));
171 AliVCluster *clust = partC->GetCluster();
172 AliVTrack *track = partT->GetTrack() ;
175 AliPicoTrack::GetEtaPhiDiff(track, clust, dphi, deta);
176 clust->SetEmcCpvDistance(matchedId);
177 clust->SetTrackDistance(deta, dphi);
180 for (Int_t t = 0; t < nT; ++t) {
181 AliEmcalParticle *partT = static_cast<AliEmcalParticle*>(fTracks->At(t));
184 if (partT->GetNumberOfMatchedObj() <= 0)
186 AliVTrack *track = partT->GetTrack();
187 track->SetEMCALcluster(partT->GetMatchedObjId());