]>
Commit | Line | Data |
---|---|---|
aee86258 | 1 | // $Id$ |
980821ba | 2 | // |
3 | // Track/cluster matcher. | |
4 | // | |
5 | // | |
aee86258 | 6 | |
64b4d2f2 | 7 | #include <TClonesArray.h> |
8 | #include <TString.h> | |
35789a2d | 9 | |
10 | #include "AliVCluster.h" | |
11 | #include "AliVTrack.h" | |
64b4d2f2 | 12 | #include "AliPicoTrack.h" |
35789a2d | 13 | #include "AliLog.h" |
14 | ||
15 | #include "AliEmcalClusTrackMatcherTask.h" | |
aee86258 | 16 | |
17 | ClassImp(AliEmcalClusTrackMatcherTask) | |
18 | ||
aee86258 | 19 | //________________________________________________________________________ |
20 | AliEmcalClusTrackMatcherTask::AliEmcalClusTrackMatcherTask(const char *name) : | |
21 | AliAnalysisTaskSE("AliEmcalClusTrackMatcherTask"), | |
22 | fTracksName("Tracks"), | |
34df23d8 | 23 | fCaloName("CaloClusters"), |
24 | fDoClusTrack(1), | |
25 | fDoTrackClus(0) | |
aee86258 | 26 | { |
27 | // Standard constructor. | |
e6fc4207 | 28 | |
aee86258 | 29 | if (!name) |
30 | return; | |
31 | SetName(name); | |
64b4d2f2 | 32 | fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.,CaloClusters,Tracks"; |
aee86258 | 33 | } |
34 | ||
35 | //________________________________________________________________________ | |
36 | AliEmcalClusTrackMatcherTask::~AliEmcalClusTrackMatcherTask() | |
37 | { | |
8bec746d | 38 | // Destructor. |
aee86258 | 39 | } |
40 | ||
41 | //________________________________________________________________________ | |
42 | void AliEmcalClusTrackMatcherTask::UserCreateOutputObjects() | |
43 | { | |
44 | // Create user objects. | |
aee86258 | 45 | } |
46 | ||
47 | //________________________________________________________________________ | |
48 | void AliEmcalClusTrackMatcherTask::UserExec(Option_t *) | |
49 | { | |
50 | // Main loop, called for each event. | |
51 | ||
aee86258 | 52 | TList *l = InputEvent()->GetList(); |
e6fc4207 | 53 | if (!l) |
54 | return; | |
64b4d2f2 | 55 | |
56 | TClonesArray *tracks = dynamic_cast<TClonesArray*>(l->FindObject(fTracksName)); | |
57 | if (!tracks) { | |
58 | AliError(Form("Pointer to tracks %s == 0", fTracksName.Data() )); | |
59 | return; | |
60 | } | |
61 | ||
62 | TClonesArray *clus = dynamic_cast<TClonesArray*>(l->FindObject(fCaloName)); | |
63 | if (!clus) { | |
64 | AliError(Form("Pointer to clus %s == 0", fCaloName.Data() )); | |
65 | return; | |
66 | } | |
67 | ||
68 | const Int_t Ntrks = tracks->GetEntries(); | |
69 | const Int_t Ncls = clus->GetEntries(); | |
64b4d2f2 | 70 | |
34df23d8 | 71 | if (fDoClusTrack) { |
64b4d2f2 | 72 | for(Int_t i=0; i < Ncls; ++i) { |
73 | AliVCluster *c = dynamic_cast<AliVCluster*>(clus->At(i)); | |
74 | if (!c) | |
75 | continue; | |
34df23d8 | 76 | c->SetEmcCpvDistance(-1); |
77 | c->SetTrackDistance(999,999); | |
78 | Double_t dEtaMin = 1e9; | |
79 | Double_t dPhiMin = 1e9; | |
7b41e6d4 | 80 | Double_t dRMin = 1e9; |
34df23d8 | 81 | Int_t imin = -1; |
82 | for(Int_t t = 0; t<Ntrks; ++t) { | |
83 | AliVTrack *track = dynamic_cast<AliVTrack*>(tracks->At(t)); | |
8bec746d | 84 | if (!track) |
85 | continue; | |
86 | if (!track->IsEMCAL()) | |
87 | continue; | |
34df23d8 | 88 | Double_t etadiff=999; |
89 | Double_t phidiff=999; | |
90 | AliPicoTrack::GetEtaPhiDiff(track,c,phidiff,etadiff); | |
91 | Double_t dR = TMath::Sqrt(etadiff*etadiff+phidiff*phidiff); | |
edf4acc0 | 92 | if(dR<dRMin) { |
34df23d8 | 93 | dEtaMin = etadiff; |
94 | dPhiMin = phidiff; | |
edf4acc0 | 95 | dRMin=dR; |
34df23d8 | 96 | imin = t; |
97 | } | |
98 | } | |
99 | c->SetEmcCpvDistance(imin); | |
100 | c->SetTrackDistance(dPhiMin, dEtaMin); | |
101 | } | |
102 | } | |
103 | ||
104 | if (fDoTrackClus) { | |
105 | for(Int_t t = 0; t<Ntrks; ++t) { | |
106 | AliVTrack *track = dynamic_cast<AliVTrack*>(tracks->At(t)); | |
107 | if (!track) | |
64b4d2f2 | 108 | continue; |
8bec746d | 109 | if (!track->IsEMCAL()) |
110 | continue; | |
34df23d8 | 111 | Double_t dEtaMin = 1e9; |
112 | Double_t dPhiMin = 1e9; | |
7b41e6d4 | 113 | Double_t dRMin = 1e9; |
34df23d8 | 114 | Int_t imin = -1; |
115 | for(Int_t i=0; i < Ncls; ++i) { | |
116 | AliVCluster *c = dynamic_cast<AliVCluster*>(clus->At(i)); | |
117 | if (!c) | |
118 | continue; | |
119 | Double_t etadiff=999; | |
120 | Double_t phidiff=999; | |
121 | AliPicoTrack::GetEtaPhiDiff(track,c,phidiff,etadiff); | |
122 | Double_t dR = TMath::Sqrt(etadiff*etadiff+phidiff*phidiff); | |
edf4acc0 | 123 | if(dR<dRMin){ |
34df23d8 | 124 | dEtaMin = etadiff; |
125 | dPhiMin = phidiff; | |
7b41e6d4 | 126 | dRMin = dR; |
27fde6c7 | 127 | imin = i; |
34df23d8 | 128 | } |
64b4d2f2 | 129 | } |
34df23d8 | 130 | track->SetEMCALcluster(imin); |
aee86258 | 131 | } |
aee86258 | 132 | } |
aee86258 | 133 | } |
134 | ||
135 | //________________________________________________________________________ | |
136 | void AliEmcalClusTrackMatcherTask::Terminate(Option_t *) | |
137 | { | |
138 | // Called once at the end of the analysis. | |
aee86258 | 139 | } |