]>
Commit | Line | Data |
---|---|---|
3cfb9c56 | 1 | //$Id$ |
2 | ||
3 | /************************************************************************** | |
4 | * This file is property of and copyright by the ALICE HLT Project * | |
5 | * ALICE Experiment at CERN, All rights reserved. * | |
6 | * * | |
434146d0 | 7 | * Primary Authors: Svein Lindal (slindal@fys.uio.no) * |
3cfb9c56 | 8 | * for The ALICE HLT Project. * |
9 | * * | |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
19 | /** @file AliHLTGlobalTrackMatcher.cxx | |
bad7877b | 20 | @author Svein Lindal |
3cfb9c56 | 21 | @date |
bad7877b | 22 | @brief The HLT class Matching Calorimeter clusters to TPC tracks |
3cfb9c56 | 23 | */ |
24 | ||
3cfb9c56 | 25 | #include "AliHLTGlobalTrackMatcher.h" |
434146d0 | 26 | #include "AliESDCaloCluster.h" |
3cfb9c56 | 27 | |
28 | #if __GNUC__>= 3 | |
29 | using namespace std; | |
30 | #endif | |
31 | ||
32 | ClassImp(AliHLTGlobalTrackMatcher) | |
33 | ||
434146d0 | 34 | |
3cfb9c56 | 35 | AliHLTGlobalTrackMatcher::AliHLTGlobalTrackMatcher() : |
434146d0 | 36 | fPhosMaxZ(0), |
37 | fPhosMaxX(0), | |
38 | fEmcalMaxZ(0), | |
39 | fEmcalMaxX(0), | |
40 | fPhosRadius(460), | |
41 | fEmcalRadius(448), | |
42 | fMatchDistance(0), | |
43 | fPhosClustersArray(NULL), | |
44 | fEmcalClustersArray(NULL) | |
3cfb9c56 | 45 | { |
434146d0 | 46 | //Default constructor |
47 | ||
48 | DoInit(); | |
3cfb9c56 | 49 | } |
50 | ||
51 | //_____________________________________________________________________________ | |
52 | AliHLTGlobalTrackMatcher::~AliHLTGlobalTrackMatcher() | |
53 | { | |
54 | //Destructor | |
3cfb9c56 | 55 | |
bad7877b | 56 | } |
3cfb9c56 | 57 | |
434146d0 | 58 | void AliHLTGlobalTrackMatcher::DoInit( ) { |
3cfb9c56 | 59 | |
434146d0 | 60 | fMatchDistance = 40*40; |
61 | ||
62 | fPhosMaxX = 355 + TMath::Sqrt(fMatchDistance) + 30; | |
63 | fPhosMaxZ = 64.+ TMath::Sqrt(fMatchDistance) + 30; | |
64 | ||
65 | fEmcalMaxZ = 350 + TMath::Sqrt(fMatchDistance) + 30; | |
66 | fEmcalMaxX = 3000; | |
67 | ||
68 | fPhosClustersArray = new TRefArray(); | |
69 | fEmcalClustersArray = new TRefArray(); | |
70 | ||
71 | } | |
72 | ||
73 | Bool_t AliHLTGlobalTrackMatcher::Match( AliESDEvent* event ){ | |
74 | ||
75 | Int_t nTracks = event->GetNumberOfTracks(); | |
76 | ||
77 | //Fill arrays with clusters | |
78 | Int_t nPhosClusters = event->GetPHOSClusters(fPhosClustersArray); | |
79 | Int_t nEmcalClusters = event->GetEMCALClusters(fEmcalClustersArray); | |
80 | ||
81 | if ( ( nTracks <= 0 ) || ( (nEmcalClusters <= 0) && (nPhosClusters <= 0)) ) { | |
82 | //printf(Form("No tracks or clusters in event")); | |
de31859c | 83 | return 0; |
434146d0 | 84 | } |
de31859c | 85 | |
3cfb9c56 | 86 | |
434146d0 | 87 | Float_t bestMatchPhos[nPhosClusters]; |
88 | for(int ic = 0; ic < nPhosClusters; ic++) { | |
89 | bestMatchPhos[ic] = 999999; | |
de31859c | 90 | } |
434146d0 | 91 | |
92 | Float_t bestMatchEmcal[nEmcalClusters]; | |
93 | for(int ic = 0; ic < nEmcalClusters; ic++) { | |
94 | bestMatchEmcal[ic] = 999999; | |
95 | } | |
96 | ||
97 | ||
98 | Double_t trackPosition[3]; | |
bad7877b | 99 | |
434146d0 | 100 | //Loop over tracks |
101 | for (int it = 0; it < nTracks; it++ ) { | |
102 | ||
103 | AliESDtrack * track = event->GetTrack(it); | |
104 | ||
105 | Double_t bz = event->GetMagneticField(); | |
bad7877b | 106 | |
434146d0 | 107 | //Does track pass close to either calorimeter volume |
108 | if ( IsTrackCloseToDetector(track, bz, trackPosition, fPhosMaxX, kFALSE, fPhosMaxZ ) ) { | |
109 | MatchTrackToClusters( track, fPhosClustersArray, nPhosClusters, bestMatchPhos, bz); | |
110 | ||
111 | } else if ( IsTrackCloseToDetector(track, bz, trackPosition, fEmcalMaxX, kTRUE, fEmcalMaxZ ) ) { | |
112 | MatchTrackToClusters( track, fEmcalClustersArray, nEmcalClusters, bestMatchEmcal, bz); | |
113 | } | |
114 | } // track loop | |
3cfb9c56 | 115 | |
434146d0 | 116 | |
117 | return 0; | |
118 | } | |
119 | ||
120 | ||
121 | ||
122 | void AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliESDtrack * track, TRefArray * clustersArray, Int_t nClusters, Float_t * bestMatch, Double_t bz) { | |
3cfb9c56 | 123 | |
434146d0 | 124 | //loop over clusters to find matches with track |
125 | ||
126 | Float_t clusterPosition[3]; | |
127 | Double_t trackPosition[3]; | |
128 | ||
129 | for(int ic = 0; ic < nClusters; ic++) { | |
130 | ||
131 | AliESDCaloCluster * cluster = static_cast<AliESDCaloCluster*>(clustersArray->At(ic)); | |
de31859c | 132 | |
434146d0 | 133 | //Get Cluster Global Coordinates |
134 | cluster->GetPosition(clusterPosition); | |
135 | ||
136 | //Get track postion at radius of cluster | |
137 | Double_t rCluster = TMath::Sqrt(clusterPosition[0]*clusterPosition[0] + clusterPosition[1]*clusterPosition[1]); | |
138 | if (! (track->GetXYZAt(rCluster, bz, trackPosition)) ) { | |
139 | cout << "XXXXXXXXXXXXX BALLE Track reached detector but not cluster, needs to be handled no? !!!!!!" << endl; | |
140 | } | |
141 | ||
142 | Float_t match = 0; | |
143 | Float_t dxyz = 0; | |
144 | for(int i = 0; i < 3; i++) { | |
145 | dxyz = trackPosition[i] - clusterPosition[i]; | |
146 | match += dxyz*dxyz; | |
147 | } | |
bad7877b | 148 | |
434146d0 | 149 | |
150 | if( match > fMatchDistance ) { | |
151 | continue; | |
152 | } | |
153 | ||
154 | ||
155 | //Track is close to cluster, add to cluster's array of matching tracks | |
156 | TArrayI *matchedTracksArray = cluster->GetTracksMatched(); | |
157 | matchedTracksArray->Set(matchedTracksArray->GetSize() + 1); | |
158 | if ( match < bestMatch[ic] ) { | |
159 | bestMatch[ic] = match; | |
160 | matchedTracksArray->AddAt(matchedTracksArray->At(0), matchedTracksArray->GetSize() - 1); | |
161 | matchedTracksArray->AddAt(track->GetID(), 0); | |
162 | } else { | |
163 | matchedTracksArray->AddAt(track->GetID(), matchedTracksArray->GetSize() - 1); | |
164 | } | |
165 | } //cluster loop | |
166 | } | |
3cfb9c56 | 167 | |
434146d0 | 168 | |
169 | Bool_t AliHLTGlobalTrackMatcher::IsTrackCloseToDetector(AliESDtrack * track, Double_t bz, Double_t * trackPosition, Double_t fMaxX, Bool_t ySign, Double_t fMaxZ) { | |
170 | ||
171 | //See header file for documentation | |
172 | ||
173 | ||
174 | //Get track instersection with cylinder defined by detector radius | |
175 | if (! (track->GetXYZAt(fPhosRadius, bz, trackPosition)) ) | |
176 | return kFALSE; | |
177 | ||
178 | //Positive y for EMCAL, negative for PHOS | |
179 | if(ySign) { | |
180 | if (trackPosition[1] < 0 ) | |
181 | return kFALSE; | |
182 | } else { | |
183 | if (trackPosition[1] > 0 ) | |
184 | return kFALSE; | |
185 | } | |
186 | ||
187 | ||
188 | if ( (TMath::Abs(trackPosition[2]) > fMaxZ) ) | |
189 | return kFALSE; | |
190 | ||
191 | if (TMath::Abs(trackPosition[0]) > fMaxX ) | |
192 | return kFALSE; | |
193 | ||
194 | ||
195 | ||
196 | return kTRUE; | |
197 | } | |
198 | ||
199 | ||
200 | // Bool_t AliHLTGlobalTrackMatcher::IsTrackCloseToEmcal(AliESDtrack * track, Double_t bz, Double_t * trackPosition) { | |
201 | ||
202 | // //Get track instersection with cylinder defined by detector radius | |
203 | // if (! (track->GetXYZAt(fEmcalRadius, bz, trackPosition)) ) | |
204 | // return kFALSE; | |
de31859c | 205 | |
3cfb9c56 | 206 | |
434146d0 | 207 | // //See header file for documentation |
208 | ||
209 | ||
210 | ||
211 | // return kTRUE; | |
212 | ||
213 | // if (trackPosition[1] < 0 ) | |
214 | // return kFALSE; | |
215 | ||
216 | ||
217 | // if ( TMath::Abs(trackPosition[2]) > fEmcalMaxZ ) | |
218 | // return kFALSE; | |
219 | ||
220 | // if ( TMath::Abs(trackPosition[0]) > fEmcalMaxX ) | |
221 | // return kFALSE; | |
222 | ||
223 | ||
224 | // // | |
225 | // return kTRUE; | |
226 | // } | |
3cfb9c56 | 227 |