]>
Commit | Line | Data |
---|---|---|
aee86258 | 1 | // $Id$ |
980821ba | 2 | // |
cd231d42 | 3 | // Track/cluster matcher |
4 | // | |
d258e37e | 5 | // Author: C.Loizides, S.Aiola |
aee86258 | 6 | |
c79b2854 | 7 | #include "AliEmcalClusTrackMatcherTask.h" |
8 | ||
64b4d2f2 | 9 | #include <TClonesArray.h> |
35789a2d | 10 | |
b6f970ad | 11 | #include "AliParticleContainer.h" |
d258e37e | 12 | #include "AliEmcalParticle.h" |
35789a2d | 13 | #include "AliLog.h" |
c79b2854 | 14 | #include "AliPicoTrack.h" |
15 | #include "AliVCluster.h" | |
16 | #include "AliVTrack.h" | |
aee86258 | 17 | |
18 | ClassImp(AliEmcalClusTrackMatcherTask) | |
19 | ||
d258e37e | 20 | //________________________________________________________________________ |
21 | AliEmcalClusTrackMatcherTask::AliEmcalClusTrackMatcherTask() : | |
9239b066 | 22 | AliAnalysisTaskEmcal("AliEmcalClusTrackMatcherTask",kFALSE), |
374d55cc | 23 | fMaxDistance(0.06) |
d258e37e | 24 | { |
25 | // Constructor. | |
938691d1 | 26 | |
27 | for(Int_t icent=0; icent<8; ++icent) { | |
28 | for(Int_t ipt=0; ipt<9; ++ipt) { | |
29 | for(Int_t ieta=0; ieta<2; ++ieta) { | |
30 | fHistMatchEta[icent][ipt][ieta] = 0; | |
31 | fHistMatchPhi[icent][ipt][ieta] = 0; | |
32 | } | |
33 | } | |
34 | } | |
d258e37e | 35 | } |
36 | ||
aee86258 | 37 | //________________________________________________________________________ |
938691d1 | 38 | AliEmcalClusTrackMatcherTask::AliEmcalClusTrackMatcherTask(const char *name, Bool_t histo) : |
9239b066 | 39 | AliAnalysisTaskEmcal(name,histo), |
374d55cc | 40 | fMaxDistance(0.06) |
aee86258 | 41 | { |
42 | // Standard constructor. | |
938691d1 | 43 | |
44 | for(Int_t icent=0; icent<8; ++icent) { | |
45 | for(Int_t ipt=0; ipt<9; ++ipt) { | |
46 | for(Int_t ieta=0; ieta<2; ++ieta) { | |
47 | fHistMatchEta[icent][ipt][ieta] = 0; | |
48 | fHistMatchPhi[icent][ipt][ieta] = 0; | |
49 | } | |
50 | } | |
51 | } | |
aee86258 | 52 | } |
53 | ||
54 | //________________________________________________________________________ | |
55 | AliEmcalClusTrackMatcherTask::~AliEmcalClusTrackMatcherTask() | |
56 | { | |
8bec746d | 57 | // Destructor. |
aee86258 | 58 | } |
59 | ||
b6f970ad | 60 | //________________________________________________________________________ |
61 | void AliEmcalClusTrackMatcherTask::ExecOnce() | |
62 | { | |
63 | // Initialize the analysis. | |
64 | ||
65 | if (fParticleCollArray.GetEntriesFast()<2) { | |
66 | AliError(Form("Wrong number of particle collections (%d), required 2",fParticleCollArray.GetEntriesFast())); | |
67 | return; | |
68 | } | |
69 | ||
70 | for (Int_t i = 0; i < 2; i++) { | |
71 | AliParticleContainer *cont = static_cast<AliParticleContainer*>(fParticleCollArray.At(i)); | |
72 | cont->SetClassName("AliEmcalParticle"); | |
73 | } | |
74 | ||
9239b066 | 75 | AliAnalysisTaskEmcal::ExecOnce(); |
b6f970ad | 76 | } |
77 | ||
938691d1 | 78 | //________________________________________________________________________ |
79 | void AliEmcalClusTrackMatcherTask::UserCreateOutputObjects() | |
80 | { | |
81 | // Create my user objects. | |
82 | ||
83 | if (!fCreateHisto) | |
84 | return; | |
85 | ||
9239b066 | 86 | AliAnalysisTaskEmcal::UserCreateOutputObjects(); |
938691d1 | 87 | |
6fd2f1a9 | 88 | const Int_t nCentChBins = fNcentBins * 2; |
89 | ||
90 | for(Int_t icent=0; icent<nCentChBins; ++icent) { | |
938691d1 | 91 | for(Int_t ipt=0; ipt<9; ++ipt) { |
92 | for(Int_t ieta=0; ieta<2; ++ieta) { | |
93 | TString nameEta(Form("fHistMatchEta_%i_%i_%i",icent,ipt,ieta)); | |
94 | fHistMatchEta[icent][ipt][ieta] = new TH1F(nameEta, nameEta, 400, -0.2, 0.2); | |
95 | TString namePhi(Form("fHistMatchPhi_%i_%i_%i",icent,ipt,ieta)); | |
96 | fHistMatchPhi[icent][ipt][ieta] = new TH1F(namePhi, namePhi, 400, -0.2, 0.2); | |
97 | fOutput->Add(fHistMatchEta[icent][ipt][ieta]); | |
98 | fOutput->Add(fHistMatchPhi[icent][ipt][ieta]); | |
99 | } | |
100 | } | |
101 | } | |
102 | ||
103 | PostData(1, fOutput); | |
104 | } | |
105 | ||
106 | //________________________________________________________________________ | |
107 | Int_t AliEmcalClusTrackMatcherTask::GetMomBin(Double_t p) const | |
108 | { | |
109 | // Get momenum bin. | |
110 | ||
111 | Int_t pbin=-1; | |
112 | if (p<0.5) | |
113 | pbin=0; | |
114 | else if (p>=0.5 && p<1.0) | |
115 | pbin=1; | |
116 | else if (p>=1.0 && p<1.5) | |
117 | pbin=2; | |
118 | else if (p>=1.5 && p<2.) | |
119 | pbin=3; | |
120 | else if (p>=2. && p<3.) | |
121 | pbin=4; | |
122 | else if (p>=3. && p<4.) | |
123 | pbin=5; | |
124 | else if (p>=4. && p<5.) | |
125 | pbin=6; | |
126 | else if (p>=5. && p<8.) | |
127 | pbin=7; | |
128 | else if (p>=8.) | |
129 | pbin=8; | |
130 | ||
131 | return pbin; | |
132 | } | |
133 | ||
aee86258 | 134 | //________________________________________________________________________ |
d258e37e | 135 | Bool_t AliEmcalClusTrackMatcherTask::Run() |
aee86258 | 136 | { |
d258e37e | 137 | // Run the matching for the selected options. |
6421eeb0 | 138 | |
b6f970ad | 139 | AliParticleContainer *tracks = static_cast<AliParticleContainer*>(fParticleCollArray.At(0)); |
140 | AliParticleContainer *clusters = static_cast<AliParticleContainer*>(fParticleCollArray.At(1)); | |
e3d22acf | 141 | |
b6f970ad | 142 | AliEmcalParticle *partC = 0; |
143 | AliEmcalParticle *partT = 0; | |
56bd3193 | 144 | |
ef46ebe5 | 145 | const Double_t maxd2 = fMaxDistance*fMaxDistance; |
146 | ||
147 | // set the links between tracks and clusters | |
b6f970ad | 148 | clusters->ResetCurrentID(); |
149 | while ((partC = static_cast<AliEmcalParticle*>(clusters->GetNextAcceptParticle()))) { | |
150 | AliVCluster *clust = partC->GetCluster(); | |
56bd3193 | 151 | |
b6f970ad | 152 | tracks->ResetCurrentID(); |
153 | while ((partT = static_cast<AliEmcalParticle*>(tracks->GetNextAcceptParticle()))) { | |
154 | AliVTrack *track = partT->GetTrack(); | |
d258e37e | 155 | Double_t deta = 999; |
156 | Double_t dphi = 999; | |
c79b2854 | 157 | AliPicoTrack::GetEtaPhiDiff(track, clust, dphi, deta); |
e3d22acf | 158 | Double_t d2 = deta * deta + dphi * dphi; |
c79b2854 | 159 | if (d2 > maxd2) |
160 | continue; | |
56bd3193 | 161 | |
c79b2854 | 162 | Double_t d = TMath::Sqrt(d2); |
b6f970ad | 163 | partC->AddMatchedObj(tracks->GetCurrentID(), d); |
164 | partT->AddMatchedObj(clusters->GetCurrentID(), d); | |
938691d1 | 165 | |
166 | if (fCreateHisto) { | |
167 | Int_t mombin = GetMomBin(track->P()); | |
168 | Int_t centbinch = fCentBin; | |
169 | if (track->Charge()<0) | |
6fd2f1a9 | 170 | centbinch += fNcentBins; |
938691d1 | 171 | Int_t etabin = 0; |
172 | if(track->Eta() > 0) | |
173 | etabin = 1; | |
174 | ||
175 | fHistMatchEta[centbinch][mombin][etabin]->Fill(deta); | |
176 | fHistMatchPhi[centbinch][mombin][etabin]->Fill(dphi); | |
177 | } | |
aee86258 | 178 | } |
aee86258 | 179 | } |
c79b2854 | 180 | |
b6f970ad | 181 | |
182 | clusters->ResetCurrentID(); | |
183 | while ((partC = static_cast<AliEmcalParticle*>(clusters->GetNextAcceptParticle()))) { | |
c79b2854 | 184 | if (partC->GetNumberOfMatchedObj() <= 0) |
185 | continue; | |
186 | const UInt_t matchedId = partC->GetMatchedObjId(); | |
b6f970ad | 187 | partT = static_cast<AliEmcalParticle*>(tracks->GetParticle(matchedId)); |
c79b2854 | 188 | AliVCluster *clust = partC->GetCluster(); |
189 | AliVTrack *track = partT->GetTrack() ; | |
190 | Double_t deta = 999; | |
191 | Double_t dphi = 999; | |
192 | AliPicoTrack::GetEtaPhiDiff(track, clust, dphi, deta); | |
193 | clust->SetEmcCpvDistance(matchedId); | |
194 | clust->SetTrackDistance(deta, dphi); | |
195 | } | |
b6f970ad | 196 | |
197 | tracks->ResetCurrentID(); | |
198 | while ((partT = static_cast<AliEmcalParticle*>(tracks->GetNextAcceptParticle()))) { | |
c79b2854 | 199 | if (partT->GetNumberOfMatchedObj() <= 0) |
200 | continue; | |
201 | AliVTrack *track = partT->GetTrack(); | |
202 | track->SetEMCALcluster(partT->GetMatchedObjId()); | |
203 | } | |
a18c300f | 204 | |
205 | return kTRUE; | |
aee86258 | 206 | } |