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