]>
Commit | Line | Data |
---|---|---|
aee86258 | 1 | // $Id$ |
980821ba | 2 | // |
cd231d42 | 3 | // Track/cluster matcher |
4 | // | |
d258e37e | 5 | // Author: C.Loizides, S.Aiola |
aee86258 | 6 | |
64b4d2f2 | 7 | #include <TClonesArray.h> |
35789a2d | 8 | |
9 | #include "AliVCluster.h" | |
10 | #include "AliVTrack.h" | |
64b4d2f2 | 11 | #include "AliPicoTrack.h" |
d258e37e | 12 | #include "AliEmcalParticle.h" |
35789a2d | 13 | #include "AliLog.h" |
14 | ||
15 | #include "AliEmcalClusTrackMatcherTask.h" | |
aee86258 | 16 | |
17 | ClassImp(AliEmcalClusTrackMatcherTask) | |
18 | ||
d258e37e | 19 | //________________________________________________________________________ |
20 | AliEmcalClusTrackMatcherTask::AliEmcalClusTrackMatcherTask() : | |
21 | AliAnalysisTaskEmcal("AliEmcalClusTrackMatcherTask"), | |
22 | fDoClusTrack(1), | |
23 | fDoTrackClus(0), | |
24 | fMaxDistance(0.1) | |
25 | { | |
26 | // Constructor. | |
27 | } | |
28 | ||
aee86258 | 29 | //________________________________________________________________________ |
30 | AliEmcalClusTrackMatcherTask::AliEmcalClusTrackMatcherTask(const char *name) : | |
d258e37e | 31 | AliAnalysisTaskEmcal(name), |
34df23d8 | 32 | fDoClusTrack(1), |
d258e37e | 33 | fDoTrackClus(0), |
34 | fMaxDistance(0.1) | |
aee86258 | 35 | { |
36 | // Standard constructor. | |
aee86258 | 37 | } |
38 | ||
39 | //________________________________________________________________________ | |
40 | AliEmcalClusTrackMatcherTask::~AliEmcalClusTrackMatcherTask() | |
41 | { | |
8bec746d | 42 | // Destructor. |
aee86258 | 43 | } |
44 | ||
45 | //________________________________________________________________________ | |
d258e37e | 46 | Bool_t AliEmcalClusTrackMatcherTask::Run() |
aee86258 | 47 | { |
d258e37e | 48 | // Run the matching for the selected options. |
49 | ||
50 | if (fDoClusTrack) | |
51 | DoMatching(fCaloClusters, fTracks); | |
52 | ||
53 | if (fDoTrackClus) | |
54 | DoMatching(fTracks, fCaloClusters); | |
55 | ||
56 | return kTRUE; | |
aee86258 | 57 | } |
58 | ||
59 | //________________________________________________________________________ | |
d258e37e | 60 | void AliEmcalClusTrackMatcherTask::DoMatching(TClonesArray *array1, TClonesArray *array2) |
aee86258 | 61 | { |
d258e37e | 62 | // Do the actual matching. |
64b4d2f2 | 63 | |
d258e37e | 64 | if (!array1 || !array2) |
64b4d2f2 | 65 | return; |
64b4d2f2 | 66 | |
e3d22acf | 67 | const Double_t maxd2 = fMaxDistance*fMaxDistance; |
68 | ||
d258e37e | 69 | const Int_t n1 = array1->GetEntries(); |
70 | const Int_t n2 = array2->GetEntries(); | |
71 | for (Int_t i = 0; i < n1; ++i) { | |
72 | AliEmcalParticle *part1 = static_cast<AliEmcalParticle*>(array1->At(i)); | |
73 | if (!part1) | |
74 | continue; | |
e3d22acf | 75 | if (!AcceptEmcalPart(part1)) |
76 | continue; | |
77 | ||
d258e37e | 78 | AliVCluster *cluster1 = part1->GetCluster(); |
79 | AliVTrack *track1 = part1->GetTrack() ; | |
80 | ||
d258e37e | 81 | part1->ResetMatchedObjects(); |
82 | ||
83 | for (Int_t j = 0; j < n2; ++j) { | |
84 | ||
85 | AliEmcalParticle *part2 = static_cast<AliEmcalParticle*>(array2->At(j)); | |
86 | if (!part2) | |
87 | continue; | |
e3d22acf | 88 | if (!AcceptEmcalPart(part2)) |
89 | continue; | |
d258e37e | 90 | |
91 | AliVCluster *cluster2 = part2->GetCluster(); | |
92 | AliVTrack *track2 = part2->GetTrack() ; | |
93 | ||
d258e37e | 94 | Double_t deta = 999; |
95 | Double_t dphi = 999; | |
96 | if (track1 && cluster2) | |
97 | AliPicoTrack::GetEtaPhiDiff(track1, cluster2, dphi, deta); | |
98 | else if (track2 && cluster1) | |
99 | AliPicoTrack::GetEtaPhiDiff(track2, cluster1, dphi, deta); | |
100 | else | |
101 | continue; | |
e3d22acf | 102 | |
103 | Double_t d2 = deta * deta + dphi * dphi; | |
104 | if (d2 < maxd2) | |
105 | part1->AddMatchedObj(j, TMath::Sqrt(d2)); | |
34df23d8 | 106 | } |
d258e37e | 107 | |
108 | if (part1->GetNumberOfMatchedObj() > 0) { | |
109 | if (track1) { | |
110 | track1->SetEMCALcluster(part1->GetMatchedObjId()); | |
111 | } else if (cluster1) { | |
112 | const UInt_t matchedId = part1->GetMatchedObjId(); | |
113 | Double_t deta = 999; | |
114 | Double_t dphi = 999; | |
115 | AliEmcalParticle *part2 = static_cast<AliEmcalParticle*>(array2->At(matchedId)); | |
116 | AliVTrack *track2 = 0; | |
117 | if (part2) | |
118 | track2 = part2->GetTrack(); | |
119 | if (track2) { | |
120 | AliPicoTrack::GetEtaPhiDiff(track2, cluster1, dphi, deta); | |
121 | cluster1->SetEmcCpvDistance(matchedId); | |
122 | cluster1->SetTrackDistance(deta, dphi); | |
123 | } | |
64b4d2f2 | 124 | } |
aee86258 | 125 | } |
aee86258 | 126 | } |
aee86258 | 127 | } |