]>
Commit | Line | Data |
---|---|---|
8cc77df0 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
3d1463c8 | 18 | //----------------------------------------------------------------------------- |
06ca6d7b | 19 | /// \class AliMUONTrackReconstructorK |
06ca6d7b | 20 | /// |
21 | /// MUON track reconstructor using the kalman method | |
22 | /// | |
23 | /// This class contains as data: | |
24 | /// - the parameters for the track reconstruction | |
25 | /// | |
26 | /// It contains as methods, among others: | |
27 | /// - MakeTracks to build the tracks | |
28 | /// | |
3d1463c8 | 29 | //----------------------------------------------------------------------------- |
8cc77df0 | 30 | |
8cc77df0 | 31 | #include "AliMUONTrackReconstructorK.h" |
96ebe67e | 32 | |
8cc77df0 | 33 | #include "AliMUONConstants.h" |
96ebe67e | 34 | #include "AliMUONVCluster.h" |
1fef78c8 | 35 | #include "AliMUONVClusterServer.h" |
96ebe67e | 36 | #include "AliMUONVClusterStore.h" |
ea94c18b | 37 | #include "AliMUONTrack.h" |
38 | #include "AliMUONTrackParam.h" | |
39 | #include "AliMUONTrackExtrap.h" | |
5a240757 | 40 | #include "AliMUONRecoParam.h" |
8cde4af5 | 41 | |
1fef78c8 | 42 | #include "AliMpArea.h" |
43 | ||
8cc77df0 | 44 | #include "AliLog.h" |
45 | ||
8cde4af5 | 46 | #include <Riostream.h> |
ea94c18b | 47 | #include <TMath.h> |
48 | #include <TMatrixD.h> | |
8cde4af5 | 49 | |
50 | /// \cond CLASSIMP | |
8cc77df0 | 51 | ClassImp(AliMUONTrackReconstructorK) // Class implementation in ROOT context |
8cde4af5 | 52 | /// \endcond |
8cc77df0 | 53 | |
019df241 | 54 | //__________________________________________________________________________ |
a0dc65b4 | 55 | AliMUONTrackReconstructorK::AliMUONTrackReconstructorK(const AliMUONRecoParam* recoParam, AliMUONVClusterServer* clusterServer) |
56 | : AliMUONVTrackReconstructor(recoParam, clusterServer) | |
8cc77df0 | 57 | { |
96ebe67e | 58 | /// Constructor |
8cc77df0 | 59 | } |
60 | ||
019df241 | 61 | //__________________________________________________________________________ |
ea94c18b | 62 | AliMUONTrackReconstructorK::~AliMUONTrackReconstructorK() |
8cc77df0 | 63 | { |
ea94c18b | 64 | /// Destructor |
65 | } | |
8cc77df0 | 66 | |
67 | //__________________________________________________________________________ | |
89c8d66d | 68 | Bool_t AliMUONTrackReconstructorK::MakeTrackCandidates(AliMUONVClusterStore& clusterStore) |
8cc77df0 | 69 | { |
89c8d66d | 70 | /// To make track candidates (assuming linear propagation if AliMUONRecoParam::MakeTrackCandidatesFast() return kTRUE): |
ea94c18b | 71 | /// Start with segments station(1..) 4 or 5 then follow track in station 5 or 4. |
89c8d66d | 72 | /// Good candidates are made of at least three clusters if both stations are requested (two otherwise). |
73 | /// Keep only best candidates or all of them according to the flag AliMUONRecoParam::TrackAllTracks(). | |
b709ac13 | 74 | |
208f139e | 75 | TClonesArray *segments; |
89c8d66d | 76 | AliMUONObjectPair *segment; |
ea94c18b | 77 | AliMUONTrack *track; |
78 | Int_t iCandidate = 0; | |
96ebe67e | 79 | Bool_t clusterFound; |
8cc77df0 | 80 | |
ea94c18b | 81 | AliDebug(1,"Enter MakeTrackCandidates"); |
8cc77df0 | 82 | |
1fef78c8 | 83 | // Unless we're doing combined tracking, we'll clusterize all stations at once |
84 | Int_t firstChamber(0); | |
85 | Int_t lastChamber(9); | |
86 | ||
a0dc65b4 | 87 | if (GetRecoParam()->CombineClusterTrackReco()) { |
1fef78c8 | 88 | // ... Here's the exception : ask the clustering to reconstruct |
89 | // clusters *only* in station 4 and 5 for combined tracking | |
90 | firstChamber = 6; | |
91 | } | |
92 | ||
93 | for (Int_t i = firstChamber; i <= lastChamber; ++i ) | |
94 | { | |
35be7ed7 | 95 | if (fClusterServer && GetRecoParam()->UseChamber(i)) fClusterServer->Clusterize(i, clusterStore, AliMpArea(), GetRecoParam()); |
1fef78c8 | 96 | } |
97 | ||
ea94c18b | 98 | // Loop over stations(1..) 5 and 4 and make track candidates |
99 | for (Int_t istat=4; istat>=3; istat--) { | |
100 | ||
208f139e | 101 | // Make segments in the station |
9bf6860b | 102 | segments = MakeSegmentsBetweenChambers(clusterStore, 2*istat, 2*istat+1); |
ea94c18b | 103 | |
104 | // Loop over segments | |
89c8d66d | 105 | for (Int_t iSegment=0; iSegment<segments->GetEntriesFast(); iSegment++) { |
ea94c18b | 106 | AliDebug(1,Form("Making primary candidate(1..) %d",++iCandidate)); |
89c8d66d | 107 | segment = (AliMUONObjectPair*) segments->UncheckedAt(iSegment); |
ea94c18b | 108 | |
109 | // Transform segments to tracks and put them at the end of fRecTracksPtr | |
89c8d66d | 110 | track = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(segment,GetRecoParam()->GetBendingVertexDispersion()); |
ea94c18b | 111 | fNRecTracks++; |
112 | ||
96ebe67e | 113 | // Look for compatible cluster(s) in the other station |
89c8d66d | 114 | if (GetRecoParam()->MakeTrackCandidatesFast()) clusterFound = FollowLinearTrackInStation(*track, clusterStore, 7-istat); |
115 | else clusterFound = FollowTrackInStation(*track, clusterStore, 7-istat); | |
019df241 | 116 | |
9bf6860b | 117 | // Remove track if no cluster found on a requested station |
89c8d66d | 118 | // or abort tracking if there are too many candidates |
6b191dea | 119 | if (GetRecoParam()->RequestStation(7-istat)) { |
120 | if (!clusterFound) { | |
121 | fRecTracksPtr->Remove(track); | |
122 | fNRecTracks--; | |
123 | } else if (fNRecTracks > GetRecoParam()->GetMaxTrackCandidates()) { | |
87976389 | 124 | AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks)); |
6b191dea | 125 | delete segments; |
126 | return kFALSE; | |
127 | } | |
128 | } else { | |
129 | if ((fNRecTracks + segments->GetEntriesFast() - iSegment - 1) > GetRecoParam()->GetMaxTrackCandidates()) { | |
4ea3f013 | 130 | AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks + segments->GetEntriesFast() - iSegment - 1)); |
6b191dea | 131 | delete segments; |
132 | return kFALSE; | |
133 | } | |
ea94c18b | 134 | } |
135 | ||
136 | } | |
89c8d66d | 137 | |
ea94c18b | 138 | // delete the array of segments |
7ec3b9cf | 139 | delete segments; |
ea94c18b | 140 | } |
141 | ||
89c8d66d | 142 | // Keep all different tracks if required |
143 | if (GetRecoParam()->TrackAllTracks()) RemoveIdenticalTracks(); | |
ea94c18b | 144 | |
89c8d66d | 145 | // Retrace tracks using Kalman filter and select them if needed |
146 | Int_t nCurrentTracks = fRecTracksPtr->GetLast()+1; | |
147 | for (Int_t iRecTrack = 0; iRecTrack < nCurrentTracks; iRecTrack++) { | |
148 | track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iRecTrack); | |
ea94c18b | 149 | |
89c8d66d | 150 | // skip empty slots |
151 | if(!track) continue; | |
152 | ||
4ea3f013 | 153 | // retrace tracks using Kalman filter and remove the ones for which extrap failed or that are out of limits |
154 | if (!RetraceTrack(*track,kTRUE) || !IsAcceptable(*((AliMUONTrackParam*)track->GetTrackParamAtCluster()->First()))) { | |
6b191dea | 155 | fRecTracksPtr->Remove(track); |
156 | fNRecTracks--; | |
ea94c18b | 157 | } |
158 | ||
159 | } | |
160 | ||
89c8d66d | 161 | // Keep only the best tracks if required |
162 | if (!GetRecoParam()->TrackAllTracks()) RemoveDoubleTracks(); | |
3e9a7a05 | 163 | else fRecTracksPtr->Compress(); |
ea94c18b | 164 | |
165 | AliDebug(1,Form("Number of good candidates = %d",fNRecTracks)); | |
166 | ||
89c8d66d | 167 | return kTRUE; |
168 | ||
9bf6860b | 169 | } |
170 | ||
171 | //__________________________________________________________________________ | |
89c8d66d | 172 | Bool_t AliMUONTrackReconstructorK::MakeMoreTrackCandidates(AliMUONVClusterStore& clusterStore) |
9bf6860b | 173 | { |
89c8d66d | 174 | /// To make extra track candidates assuming linear propagation: |
9bf6860b | 175 | /// clustering is supposed to be already done |
176 | /// Start with segments made of 1 cluster in each of the stations 4 and 5 then follow track in remaining chambers. | |
89c8d66d | 177 | /// Good candidates are made of at least three clusters if both stations are requested (two otherwise). |
9bf6860b | 178 | /// Keep only best candidates or all of them according to the flag fgkTrackAllTracks. |
179 | ||
180 | TClonesArray *segments; | |
89c8d66d | 181 | AliMUONObjectPair *segment; |
9bf6860b | 182 | AliMUONTrack *track; |
183 | Int_t iCandidate = 0, iCurrentTrack, nCurrentTracks; | |
184 | Int_t initialNRecTracks = fNRecTracks; | |
185 | Bool_t clusterFound; | |
186 | ||
187 | AliDebug(1,"Enter MakeMoreTrackCandidates"); | |
188 | ||
189 | // Double loop over chambers in stations(1..) 4 and 5 to make track candidates | |
190 | for (Int_t ich1 = 6; ich1 <= 7; ich1++) { | |
191 | for (Int_t ich2 = 8; ich2 <= 9; ich2++) { | |
192 | ||
193 | // Make segments between ch1 and ch2 | |
194 | segments = MakeSegmentsBetweenChambers(clusterStore, ich1, ich2); | |
195 | ||
89c8d66d | 196 | /// Remove segments already attached to a track |
197 | RemoveUsedSegments(*segments); | |
198 | ||
9bf6860b | 199 | // Loop over segments |
89c8d66d | 200 | for (Int_t iSegment=0; iSegment<segments->GetEntriesFast(); iSegment++) { |
9bf6860b | 201 | AliDebug(1,Form("Making primary candidate(1..) %d",++iCandidate)); |
89c8d66d | 202 | segment = (AliMUONObjectPair*) segments->UncheckedAt(iSegment); |
9bf6860b | 203 | |
204 | // Transform segments to tracks and put them at the end of fRecTracksPtr | |
205 | iCurrentTrack = fRecTracksPtr->GetLast()+1; | |
89c8d66d | 206 | track = new ((*fRecTracksPtr)[iCurrentTrack]) AliMUONTrack(segment,GetRecoParam()->GetBendingVertexDispersion()); |
9bf6860b | 207 | fNRecTracks++; |
208 | ||
209 | // Look for compatible cluster(s) in the second chamber of station 5 | |
89c8d66d | 210 | clusterFound = FollowLinearTrackInChamber(*track, clusterStore, 17-ich2); |
9bf6860b | 211 | |
212 | // skip the original track in case it has been removed | |
a0dc65b4 | 213 | if (GetRecoParam()->TrackAllTracks() && clusterFound) iCurrentTrack++; |
9bf6860b | 214 | |
215 | // loop over every new tracks | |
216 | nCurrentTracks = fRecTracksPtr->GetLast()+1; | |
217 | while (iCurrentTrack < nCurrentTracks) { | |
218 | track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iCurrentTrack); | |
219 | ||
220 | // Look for compatible cluster(s) in the second chamber of station 4 | |
89c8d66d | 221 | FollowLinearTrackInChamber(*track, clusterStore, 13-ich1); |
9bf6860b | 222 | |
223 | iCurrentTrack++; | |
224 | } | |
225 | ||
89c8d66d | 226 | // abort tracking if there are too many candidates |
6b191dea | 227 | if ((fNRecTracks + segments->GetEntriesFast() - iSegment - 1) > GetRecoParam()->GetMaxTrackCandidates()) { |
87976389 | 228 | AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks + segments->GetEntriesFast() - iSegment - 1)); |
89c8d66d | 229 | delete segments; |
230 | return kFALSE; | |
231 | } | |
232 | ||
9bf6860b | 233 | } |
234 | ||
235 | // delete the array of segments | |
236 | delete segments; | |
237 | } | |
238 | } | |
239 | ||
89c8d66d | 240 | // Retrace tracks using Kalman filter (also compute track chi2) and select them |
241 | nCurrentTracks = fRecTracksPtr->GetLast()+1; | |
242 | for (Int_t iRecTrack = initialNRecTracks; iRecTrack < nCurrentTracks; iRecTrack++) { | |
9bf6860b | 243 | track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iRecTrack); |
244 | ||
89c8d66d | 245 | // skip empty slots |
246 | if(!track) continue; | |
247 | ||
4ea3f013 | 248 | // retrace tracks using Kalman filter and remove the ones for which extrap failed or that are out of limits |
249 | if (!RetraceTrack(*track,kTRUE) || !IsAcceptable(*((AliMUONTrackParam*)track->GetTrackParamAtCluster()->First()))) { | |
6b191dea | 250 | fRecTracksPtr->Remove(track); |
251 | fNRecTracks--; | |
9bf6860b | 252 | } |
253 | ||
254 | } | |
255 | ||
89c8d66d | 256 | // Keep only the best tracks if required |
257 | if (!GetRecoParam()->TrackAllTracks()) RemoveDoubleTracks(); | |
258 | else fRecTracksPtr->Compress(); | |
9bf6860b | 259 | |
260 | AliDebug(1,Form("Number of good candidates = %d",fNRecTracks)); | |
261 | ||
89c8d66d | 262 | return kTRUE; |
263 | ||
8cc77df0 | 264 | } |
265 | ||
ea94c18b | 266 | //__________________________________________________________________________ |
4ea3f013 | 267 | Bool_t AliMUONTrackReconstructorK::RetraceTrack(AliMUONTrack &trackCandidate, Bool_t resetSeed) |
8cc77df0 | 268 | { |
96ebe67e | 269 | /// Re-run the kalman filter from the most downstream cluster to the most uptream one |
4ea3f013 | 270 | /// Return kFALSE in case of failure (i.e. extrapolation problem) |
ea94c18b | 271 | AliDebug(1,"Enter RetraceTrack"); |
272 | ||
7332f213 | 273 | AliMUONTrackParam* lastTrackParam = (AliMUONTrackParam*) trackCandidate.GetTrackParamAtCluster()->Last(); |
ea94c18b | 274 | |
96ebe67e | 275 | // Reset the "seed" (= track parameters and their covariances at last cluster) if required |
ea94c18b | 276 | if (resetSeed) { |
7332f213 | 277 | |
278 | // parameters at last cluster | |
279 | AliMUONVCluster* cluster2 = lastTrackParam->GetClusterPtr(); | |
280 | Double_t x2 = cluster2->GetX(); | |
281 | Double_t y2 = cluster2->GetY(); | |
282 | Double_t z2 = cluster2->GetZ(); | |
283 | ||
284 | // parameters at last but one cluster | |
285 | AliMUONTrackParam* previousTrackParam = (AliMUONTrackParam*) trackCandidate.GetTrackParamAtCluster()->Before(lastTrackParam); | |
286 | AliMUONVCluster* cluster1 = previousTrackParam->GetClusterPtr(); | |
0e894e58 | 287 | // make sure it is on the previous chamber (can have 2 clusters in the same chamber after "ComplementTrack") |
288 | if (cluster2->GetChamberId() == cluster1->GetChamberId()) { | |
289 | previousTrackParam = (AliMUONTrackParam*) trackCandidate.GetTrackParamAtCluster()->Before(previousTrackParam); | |
290 | cluster1 = previousTrackParam->GetClusterPtr(); | |
291 | } | |
7332f213 | 292 | Double_t x1 = cluster1->GetX(); |
293 | Double_t y1 = cluster1->GetY(); | |
294 | Double_t z1 = cluster1->GetZ(); | |
295 | ||
296 | // reset track parameters | |
297 | Double_t dZ = z1 - z2; | |
298 | lastTrackParam->SetNonBendingCoor(x2); | |
299 | lastTrackParam->SetBendingCoor(y2); | |
300 | lastTrackParam->SetZ(z2); | |
301 | lastTrackParam->SetNonBendingSlope((x1 - x2) / dZ); | |
302 | lastTrackParam->SetBendingSlope((y1 - y2) / dZ); | |
303 | Double_t bendingImpact = y2 - z2 * lastTrackParam->GetBendingSlope(); | |
9bf6860b | 304 | Double_t inverseBendingMomentum = 1. / AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(bendingImpact); |
305 | lastTrackParam->SetInverseBendingMomentum(inverseBendingMomentum); | |
7332f213 | 306 | |
307 | // => Reset track parameter covariances at last cluster (as if the other clusters did not exist) | |
308 | TMatrixD lastParamCov(5,5); | |
309 | lastParamCov.Zero(); | |
ea94c18b | 310 | // Non bending plane |
7332f213 | 311 | lastParamCov(0,0) = cluster2->GetErrX2(); |
89c8d66d | 312 | lastParamCov(0,1) = - cluster2->GetErrX2() / dZ; |
313 | lastParamCov(1,0) = lastParamCov(0,1); | |
314 | lastParamCov(1,1) = ( 1000. * cluster1->GetErrX2() + cluster2->GetErrX2() ) / dZ / dZ; | |
ea94c18b | 315 | // Bending plane |
7332f213 | 316 | lastParamCov(2,2) = cluster2->GetErrY2(); |
89c8d66d | 317 | lastParamCov(2,3) = - cluster2->GetErrY2() / dZ; |
318 | lastParamCov(3,2) = lastParamCov(2,3); | |
319 | lastParamCov(3,3) = ( 1000. * cluster1->GetErrY2() + cluster2->GetErrY2() ) / dZ / dZ; | |
9bf6860b | 320 | // Inverse bending momentum (vertex resolution + bending slope resolution + 10% error on dipole parameters+field) |
89c8d66d | 321 | if (AliMUONTrackExtrap::IsFieldON()) { |
322 | lastParamCov(4,4) = ((GetRecoParam()->GetBendingVertexDispersion() * | |
323 | GetRecoParam()->GetBendingVertexDispersion() + | |
324 | (z1 * z1 * cluster2->GetErrY2() + z2 * z2 * 1000. * cluster1->GetErrY2()) / dZ / dZ) / | |
325 | bendingImpact / bendingImpact + 0.1 * 0.1) * inverseBendingMomentum * inverseBendingMomentum; | |
326 | lastParamCov(2,4) = z1 * cluster2->GetErrY2() * inverseBendingMomentum / bendingImpact / dZ; | |
327 | lastParamCov(4,2) = lastParamCov(2,4); | |
328 | lastParamCov(3,4) = - (z1 * cluster2->GetErrY2() + z2 * 1000. * cluster1->GetErrY2()) * | |
329 | inverseBendingMomentum / bendingImpact / dZ / dZ; | |
330 | lastParamCov(4,3) = lastParamCov(3,4); | |
331 | } else lastParamCov(4,4) = inverseBendingMomentum*inverseBendingMomentum; | |
7332f213 | 332 | lastTrackParam->SetCovariances(lastParamCov); |
ea94c18b | 333 | |
334 | // Reset the track chi2 | |
7332f213 | 335 | lastTrackParam->SetTrackChi2(0.); |
ea94c18b | 336 | |
337 | } | |
338 | ||
339 | // Redo the tracking | |
4ea3f013 | 340 | return RetracePartialTrack(trackCandidate, lastTrackParam); |
ea94c18b | 341 | |
342 | } | |
8cc77df0 | 343 | |
ea94c18b | 344 | //__________________________________________________________________________ |
4ea3f013 | 345 | Bool_t AliMUONTrackReconstructorK::RetracePartialTrack(AliMUONTrack &trackCandidate, const AliMUONTrackParam* startingTrackParam) |
ea94c18b | 346 | { |
96ebe67e | 347 | /// Re-run the kalman filter from the cluster attached to startingTrackParam to the most uptream cluster |
4ea3f013 | 348 | /// Return kFALSE in case of failure (i.e. extrapolation problem) |
ea94c18b | 349 | AliDebug(1,"Enter RetracePartialTrack"); |
350 | ||
351 | // Printout for debuging | |
352 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 353 | cout << "RetracePartialTrack: track chi2 before re-tracking: " << trackCandidate.GetGlobalChi2() << endl; |
ea94c18b | 354 | } |
355 | ||
356 | // Reset the track chi2 | |
96ebe67e | 357 | trackCandidate.SetGlobalChi2(startingTrackParam->GetTrackChi2()); |
ea94c18b | 358 | |
96ebe67e | 359 | // loop over attached clusters until the first one and recompute track parameters and covariances using kalman filter |
4ea3f013 | 360 | Bool_t extrapStatus = kTRUE; |
96ebe67e | 361 | Int_t expectedChamber = startingTrackParam->GetClusterPtr()->GetChamberId() - 1; |
ea94c18b | 362 | Int_t currentChamber; |
96ebe67e | 363 | Double_t addChi2TrackAtCluster; |
364 | AliMUONTrackParam* trackParamAtCluster = (AliMUONTrackParam*) trackCandidate.GetTrackParamAtCluster()->Before(startingTrackParam); | |
365 | while (trackParamAtCluster) { | |
ea94c18b | 366 | |
367 | // reset track parameters and their covariances | |
96ebe67e | 368 | trackParamAtCluster->SetParameters(startingTrackParam->GetParameters()); |
369 | trackParamAtCluster->SetZ(startingTrackParam->GetZ()); | |
370 | trackParamAtCluster->SetCovariances(startingTrackParam->GetCovariances()); | |
ea94c18b | 371 | |
372 | // add MCS effect | |
37a615ac | 373 | AliMUONTrackExtrap::AddMCSEffect(trackParamAtCluster,AliMUONConstants::ChamberThicknessInX0(),-1.); |
ea94c18b | 374 | |
375 | // reset propagator for smoother | |
a0dc65b4 | 376 | if (GetRecoParam()->UseSmoother()) trackParamAtCluster->ResetPropagator(); |
ea94c18b | 377 | |
9bf6860b | 378 | // add MCS in missing chambers if any |
96ebe67e | 379 | currentChamber = trackParamAtCluster->GetClusterPtr()->GetChamberId(); |
ea94c18b | 380 | while (currentChamber < expectedChamber) { |
381 | // extrapolation to the missing chamber (update the propagator) | |
4ea3f013 | 382 | if (!AliMUONTrackExtrap::ExtrapToZCov(trackParamAtCluster, AliMUONConstants::DefaultChamberZ(expectedChamber), |
383 | GetRecoParam()->UseSmoother())) extrapStatus = kFALSE; | |
ea94c18b | 384 | // add MCS effect |
37a615ac | 385 | AliMUONTrackExtrap::AddMCSEffect(trackParamAtCluster,AliMUONConstants::ChamberThicknessInX0(),-1.); |
ea94c18b | 386 | expectedChamber--; |
387 | } | |
388 | ||
96ebe67e | 389 | // extrapolation to the plane of the cluster attached to the current trackParamAtCluster (update the propagator) |
4ea3f013 | 390 | if (!AliMUONTrackExtrap::ExtrapToZCov(trackParamAtCluster, trackParamAtCluster->GetClusterPtr()->GetZ(), |
391 | GetRecoParam()->UseSmoother())) extrapStatus = kFALSE; | |
ea94c18b | 392 | |
a0dc65b4 | 393 | if (GetRecoParam()->UseSmoother()) { |
ea94c18b | 394 | // save extrapolated parameters for smoother |
96ebe67e | 395 | trackParamAtCluster->SetExtrapParameters(trackParamAtCluster->GetParameters()); |
ea94c18b | 396 | |
397 | // save extrapolated covariance matrix for smoother | |
96ebe67e | 398 | trackParamAtCluster->SetExtrapCovariances(trackParamAtCluster->GetCovariances()); |
ea94c18b | 399 | } |
400 | ||
9bf6860b | 401 | // Compute new track parameters using kalman filter |
96ebe67e | 402 | addChi2TrackAtCluster = RunKalmanFilter(*trackParamAtCluster); |
ea94c18b | 403 | |
404 | // Update the track chi2 | |
96ebe67e | 405 | trackCandidate.SetGlobalChi2(trackCandidate.GetGlobalChi2() + addChi2TrackAtCluster); |
406 | trackParamAtCluster->SetTrackChi2(trackCandidate.GetGlobalChi2()); | |
ea94c18b | 407 | |
96ebe67e | 408 | // prepare next step |
409 | expectedChamber = currentChamber - 1; | |
410 | startingTrackParam = trackParamAtCluster; | |
411 | trackParamAtCluster = (AliMUONTrackParam*) (trackCandidate.GetTrackParamAtCluster()->Before(startingTrackParam)); | |
ea94c18b | 412 | } |
413 | ||
414 | // Printout for debuging | |
415 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 416 | cout << "RetracePartialTrack: track chi2 after re-tracking: " << trackCandidate.GetGlobalChi2() << endl; |
ea94c18b | 417 | } |
418 | ||
4ea3f013 | 419 | // set global chi2 to max value in case of problem during track extrapolation |
420 | if (!extrapStatus) trackCandidate.SetGlobalChi2(2.*AliMUONTrack::MaxChi2()); | |
421 | return extrapStatus; | |
422 | ||
ea94c18b | 423 | } |
8cc77df0 | 424 | |
ea94c18b | 425 | //__________________________________________________________________________ |
89c8d66d | 426 | Bool_t AliMUONTrackReconstructorK::FollowTracks(AliMUONVClusterStore& clusterStore) |
ea94c18b | 427 | { |
428 | /// Follow tracks in stations(1..) 3, 2 and 1 | |
429 | AliDebug(1,"Enter FollowTracks"); | |
430 | ||
431 | AliMUONTrack *track; | |
432 | Int_t currentNRecTracks; | |
ea94c18b | 433 | |
434 | for (Int_t station = 2; station >= 0; station--) { | |
435 | ||
436 | // Save the actual number of reconstructed track in case of | |
437 | // tracks are added or suppressed during the tracking procedure | |
438 | // !! Do not compress fRecTracksPtr until the end of the loop over tracks !! | |
439 | currentNRecTracks = fNRecTracks; | |
440 | ||
441 | for (Int_t iRecTrack = 0; iRecTrack <currentNRecTracks; iRecTrack++) { | |
442 | AliDebug(1,Form("FollowTracks: track candidate(1..) %d", iRecTrack+1)); | |
443 | ||
444 | track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iRecTrack); | |
445 | ||
96ebe67e | 446 | // Look for compatible cluster(s) in station(0..) "station" |
9bf6860b | 447 | if (!FollowTrackInStation(*track, clusterStore, station)) { |
448 | ||
449 | // Try to recover track if required | |
a0dc65b4 | 450 | if (GetRecoParam()->RecoverTracks()) { |
9bf6860b | 451 | |
452 | // work on a copy of the track if this station is not required | |
453 | // to keep the case where no cluster is reconstructed as a possible candidate | |
a0dc65b4 | 454 | if (!GetRecoParam()->RequestStation(station)) { |
9bf6860b | 455 | track = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(*track); |
456 | fNRecTracks++; | |
457 | } | |
458 | ||
459 | // try to recover | |
460 | if (!RecoverTrack(*track, clusterStore, station)) { | |
461 | // remove track if no cluster found | |
462 | fRecTracksPtr->Remove(track); | |
463 | fNRecTracks--; | |
464 | } | |
465 | ||
a0dc65b4 | 466 | } else if (GetRecoParam()->RequestStation(station)) { |
9bf6860b | 467 | // remove track if no cluster found |
468 | fRecTracksPtr->Remove(track); | |
469 | fNRecTracks--; | |
470 | } | |
471 | ||
8cc77df0 | 472 | } |
ea94c18b | 473 | |
89c8d66d | 474 | // abort tracking if there are too many candidates |
6b191dea | 475 | if (GetRecoParam()->RequestStation(station)) { |
476 | if (fNRecTracks > GetRecoParam()->GetMaxTrackCandidates()) { | |
87976389 | 477 | AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks)); |
6b191dea | 478 | return kFALSE; |
479 | } | |
480 | } else { | |
481 | if ((fNRecTracks + currentNRecTracks - iRecTrack - 1) > GetRecoParam()->GetMaxTrackCandidates()) { | |
87976389 | 482 | AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks + currentNRecTracks - iRecTrack - 1)); |
6b191dea | 483 | return kFALSE; |
484 | } | |
89c8d66d | 485 | } |
486 | ||
8cc77df0 | 487 | } |
ea94c18b | 488 | |
489 | fRecTracksPtr->Compress(); // this is essential before checking tracks | |
490 | ||
ea94c18b | 491 | // Keep only the best tracks if required |
a0dc65b4 | 492 | if (!GetRecoParam()->TrackAllTracks()) RemoveDoubleTracks(); |
ea94c18b | 493 | |
494 | } | |
495 | ||
89c8d66d | 496 | return kTRUE; |
497 | ||
9bf6860b | 498 | } |
499 | ||
500 | //__________________________________________________________________________ | |
501 | Bool_t AliMUONTrackReconstructorK::FollowTrackInChamber(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextChamber) | |
502 | { | |
503 | /// Follow trackCandidate in chamber(0..) nextChamber and search for compatible cluster(s) | |
504 | /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks: | |
505 | /// kTRUE: duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of | |
506 | /// fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure. | |
507 | /// Remove the obsolete "trackCandidate" at the end. | |
508 | /// kFALSE: add only the best cluster(s) to the "trackCandidate". Try to add a couple of clusters in priority. | |
509 | /// return kTRUE if new cluster(s) have been found (otherwise return kFALSE) | |
510 | AliDebug(1,Form("Enter FollowTrackInChamber(1..) %d", nextChamber+1)); | |
511 | ||
9bf6860b | 512 | Double_t chi2OfCluster; |
a0dc65b4 | 513 | Double_t maxChi2OfCluster = 2. * GetRecoParam()->GetSigmaCutForTracking() * |
514 | GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2 | |
9bf6860b | 515 | Double_t addChi2TrackAtCluster; |
4ea3f013 | 516 | Double_t bestAddChi2TrackAtCluster = AliMUONTrack::MaxChi2(); |
9bf6860b | 517 | Bool_t foundOneCluster = kFALSE; |
518 | AliMUONTrack *newTrack = 0x0; | |
519 | AliMUONVCluster *cluster; | |
520 | AliMUONTrackParam extrapTrackParamAtCh; | |
521 | AliMUONTrackParam extrapTrackParamAtCluster; | |
522 | AliMUONTrackParam bestTrackParamAtCluster; | |
523 | ||
524 | // Get track parameters according to the propagation direction | |
525 | if (nextChamber > 7) extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->Last(); | |
526 | else extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First(); | |
527 | ||
528 | // Printout for debuging | |
529 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
530 | cout<<endl<<"Track parameters and covariances at first cluster:"<<endl; | |
531 | extrapTrackParamAtCh.GetParameters().Print(); | |
532 | extrapTrackParamAtCh.GetCovariances().Print(); | |
533 | } | |
534 | ||
535 | // Add MCS effect | |
37a615ac | 536 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),-1.); |
9bf6860b | 537 | |
538 | // reset propagator for smoother | |
a0dc65b4 | 539 | if (GetRecoParam()->UseSmoother()) extrapTrackParamAtCh.ResetPropagator(); |
9bf6860b | 540 | |
541 | // Add MCS in the missing chamber(s) if any | |
542 | Int_t currentChamber = extrapTrackParamAtCh.GetClusterPtr()->GetChamberId(); | |
543 | while (currentChamber > nextChamber + 1) { | |
544 | // extrapolation to the missing chamber | |
545 | currentChamber--; | |
4ea3f013 | 546 | if (!AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(currentChamber), |
547 | GetRecoParam()->UseSmoother())) return kFALSE; | |
9bf6860b | 548 | // add MCS effect |
37a615ac | 549 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),-1.); |
9bf6860b | 550 | } |
551 | ||
552 | //Extrapolate trackCandidate to chamber | |
4ea3f013 | 553 | if (!AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(nextChamber), |
554 | GetRecoParam()->UseSmoother())) return kFALSE; | |
9bf6860b | 555 | |
556 | // Printout for debuging | |
557 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
558 | cout<<endl<<"Track parameters and covariances at first cluster extrapolated to z = "<<AliMUONConstants::DefaultChamberZ(nextChamber)<<":"<<endl; | |
559 | extrapTrackParamAtCh.GetParameters().Print(); | |
560 | extrapTrackParamAtCh.GetCovariances().Print(); | |
561 | } | |
562 | ||
563 | // Printout for debuging | |
564 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
565 | cout << "FollowTrackInChamber: look for clusters in chamber(1..): " << nextChamber+1 << endl; | |
566 | } | |
567 | ||
568 | // Ask the clustering to reconstruct new clusters around the track position in the current chamber | |
569 | // except for station 4 and 5 that are already entirely clusterized | |
a0dc65b4 | 570 | if (GetRecoParam()->CombineClusterTrackReco()) { |
9bf6860b | 571 | if (nextChamber < 6) AskForNewClustersInChamber(extrapTrackParamAtCh, clusterStore, nextChamber); |
572 | } | |
573 | ||
574 | // Create iterators to loop over clusters in both chambers | |
575 | TIter next(clusterStore.CreateChamberIterator(nextChamber,nextChamber)); | |
576 | ||
577 | // look for candidates in chamber | |
578 | while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) ) { | |
579 | ||
580 | // try to add the current cluster fast | |
581 | if (!TryOneClusterFast(extrapTrackParamAtCh, cluster)) continue; | |
582 | ||
583 | // try to add the current cluster accuratly | |
584 | chi2OfCluster = TryOneCluster(extrapTrackParamAtCh, cluster, extrapTrackParamAtCluster, | |
a0dc65b4 | 585 | GetRecoParam()->UseSmoother()); |
9bf6860b | 586 | |
587 | // if good chi2 then consider to add cluster | |
588 | if (chi2OfCluster < maxChi2OfCluster) { | |
9bf6860b | 589 | |
a0dc65b4 | 590 | if (GetRecoParam()->UseSmoother()) { |
9bf6860b | 591 | // save extrapolated parameters for smoother |
592 | extrapTrackParamAtCluster.SetExtrapParameters(extrapTrackParamAtCluster.GetParameters()); | |
593 | ||
594 | // save extrapolated covariance matrix for smoother | |
595 | extrapTrackParamAtCluster.SetExtrapCovariances(extrapTrackParamAtCluster.GetCovariances()); | |
596 | } | |
597 | ||
598 | // Compute new track parameters including new cluster using kalman filter | |
599 | addChi2TrackAtCluster = RunKalmanFilter(extrapTrackParamAtCluster); | |
600 | ||
6b191dea | 601 | // skip track out of limits |
602 | if (!IsAcceptable(extrapTrackParamAtCluster)) continue; | |
89c8d66d | 603 | |
604 | // remember a cluster was found | |
605 | foundOneCluster = kTRUE; | |
606 | ||
607 | // Printout for debuging | |
608 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
609 | cout << "FollowTrackInChamber: found one cluster in chamber(1..): " << nextChamber+1 | |
610 | << " (Chi2 = " << chi2OfCluster << ")" << endl; | |
611 | cluster->Print(); | |
612 | } | |
9bf6860b | 613 | |
a0dc65b4 | 614 | if (GetRecoParam()->TrackAllTracks()) { |
9bf6860b | 615 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster |
616 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); | |
617 | UpdateTrack(*newTrack,extrapTrackParamAtCluster,addChi2TrackAtCluster); | |
618 | fNRecTracks++; | |
619 | ||
620 | // Printout for debuging | |
621 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
622 | cout << "FollowTrackInChamber: added one cluster in chamber(1..): " << nextChamber+1 << endl; | |
623 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); | |
624 | } | |
625 | ||
626 | } else if (addChi2TrackAtCluster < bestAddChi2TrackAtCluster) { | |
627 | // keep track of the best cluster | |
628 | bestAddChi2TrackAtCluster = addChi2TrackAtCluster; | |
629 | bestTrackParamAtCluster = extrapTrackParamAtCluster; | |
630 | } | |
631 | ||
632 | } | |
633 | ||
634 | } | |
635 | ||
636 | // fill out the best track if required else clean up the fRecTracksPtr array | |
a0dc65b4 | 637 | if (!GetRecoParam()->TrackAllTracks()) { |
9bf6860b | 638 | if (foundOneCluster) { |
639 | UpdateTrack(trackCandidate,bestTrackParamAtCluster,bestAddChi2TrackAtCluster); | |
640 | ||
641 | // Printout for debuging | |
642 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
643 | cout << "FollowTrackInChamber: added the best cluster in chamber(1..): " << bestTrackParamAtCluster.GetClusterPtr()->GetChamberId()+1 << endl; | |
644 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); | |
645 | } | |
646 | ||
647 | } else return kFALSE; | |
648 | ||
649 | } else if (foundOneCluster) { | |
650 | ||
651 | // remove obsolete track | |
652 | fRecTracksPtr->Remove(&trackCandidate); | |
653 | fNRecTracks--; | |
654 | ||
655 | } else return kFALSE; | |
656 | ||
657 | return kTRUE; | |
658 | ||
ea94c18b | 659 | } |
b0e4c598 | 660 | |
ea94c18b | 661 | //__________________________________________________________________________ |
1fef78c8 | 662 | Bool_t AliMUONTrackReconstructorK::FollowTrackInStation(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextStation) |
ea94c18b | 663 | { |
96ebe67e | 664 | /// Follow trackCandidate in station(0..) nextStation and search for compatible cluster(s) |
ea94c18b | 665 | /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks: |
666 | /// kTRUE: duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of | |
667 | /// fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure. | |
668 | /// Remove the obsolete "trackCandidate" at the end. | |
96ebe67e | 669 | /// kFALSE: add only the best cluster(s) to the "trackCandidate". Try to add a couple of clusters in priority. |
670 | /// return kTRUE if new cluster(s) have been found (otherwise return kFALSE) | |
ea94c18b | 671 | AliDebug(1,Form("Enter FollowTrackInStation(1..) %d", nextStation+1)); |
672 | ||
673 | // Order the chamber according to the propagation direction (tracking starts with chamber 2): | |
674 | // - nextStation == station(1...) 5 => forward propagation | |
675 | // - nextStation < station(1...) 5 => backward propagation | |
676 | Int_t ch1, ch2; | |
677 | if (nextStation==4) { | |
678 | ch1 = 2*nextStation+1; | |
679 | ch2 = 2*nextStation; | |
680 | } else { | |
681 | ch1 = 2*nextStation; | |
682 | ch2 = 2*nextStation+1; | |
683 | } | |
684 | ||
96ebe67e | 685 | Double_t chi2OfCluster; |
a0dc65b4 | 686 | Double_t maxChi2OfCluster = 2. * GetRecoParam()->GetSigmaCutForTracking() * |
687 | GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2 | |
96ebe67e | 688 | Double_t addChi2TrackAtCluster1; |
689 | Double_t addChi2TrackAtCluster2; | |
4ea3f013 | 690 | Double_t bestAddChi2TrackAtCluster1 = AliMUONTrack::MaxChi2(); |
691 | Double_t bestAddChi2TrackAtCluster2 = AliMUONTrack::MaxChi2(); | |
96ebe67e | 692 | Bool_t foundOneCluster = kFALSE; |
693 | Bool_t foundTwoClusters = kFALSE; | |
ea94c18b | 694 | AliMUONTrack *newTrack = 0x0; |
96ebe67e | 695 | AliMUONVCluster *clusterCh1, *clusterCh2; |
ea94c18b | 696 | AliMUONTrackParam extrapTrackParam; |
7332f213 | 697 | AliMUONTrackParam extrapTrackParamAtCh; |
96ebe67e | 698 | AliMUONTrackParam extrapTrackParamAtCluster1; |
699 | AliMUONTrackParam extrapTrackParamAtCluster2; | |
700 | AliMUONTrackParam bestTrackParamAtCluster1; | |
701 | AliMUONTrackParam bestTrackParamAtCluster2; | |
702 | ||
7332f213 | 703 | // Get track parameters according to the propagation direction |
7332f213 | 704 | if (nextStation==4) extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->Last(); |
705 | else extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First(); | |
ea94c18b | 706 | |
9bf6860b | 707 | // Printout for debuging |
708 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
709 | cout<<endl<<"Track parameters and covariances at first cluster:"<<endl; | |
710 | extrapTrackParamAtCh.GetParameters().Print(); | |
711 | extrapTrackParamAtCh.GetCovariances().Print(); | |
712 | } | |
713 | ||
ea94c18b | 714 | // Add MCS effect |
37a615ac | 715 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),-1.); |
ea94c18b | 716 | |
717 | // reset propagator for smoother | |
a0dc65b4 | 718 | if (GetRecoParam()->UseSmoother()) extrapTrackParamAtCh.ResetPropagator(); |
ea94c18b | 719 | |
9bf6860b | 720 | // Add MCS in the missing chamber(s) if any |
721 | Int_t currentChamber = extrapTrackParamAtCh.GetClusterPtr()->GetChamberId(); | |
722 | while (ch1 < ch2 && currentChamber > ch2 + 1) { | |
ea94c18b | 723 | // extrapolation to the missing chamber |
9bf6860b | 724 | currentChamber--; |
4ea3f013 | 725 | if (!AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(currentChamber), |
726 | GetRecoParam()->UseSmoother())) return kFALSE; | |
ea94c18b | 727 | // add MCS effect |
37a615ac | 728 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),-1.); |
ea94c18b | 729 | } |
730 | ||
731 | //Extrapolate trackCandidate to chamber "ch2" | |
4ea3f013 | 732 | if (!AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch2), |
733 | GetRecoParam()->UseSmoother())) return kFALSE; | |
ea94c18b | 734 | |
735 | // Printout for debuging | |
736 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
9bf6860b | 737 | cout<<endl<<"Track parameters and covariances at first cluster extrapolated to z = "<<AliMUONConstants::DefaultChamberZ(ch2)<<":"<<endl; |
738 | extrapTrackParamAtCh.GetParameters().Print(); | |
019df241 | 739 | extrapTrackParamAtCh.GetCovariances().Print(); |
ea94c18b | 740 | } |
741 | ||
742 | // Printout for debuging | |
743 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 744 | cout << "FollowTrackInStation: look for clusters in chamber(1..): " << ch2+1 << endl; |
ea94c18b | 745 | } |
746 | ||
1fef78c8 | 747 | // Ask the clustering to reconstruct new clusters around the track position in the current station |
748 | // except for station 4 and 5 that are already entirely clusterized | |
a0dc65b4 | 749 | if (GetRecoParam()->CombineClusterTrackReco()) { |
1fef78c8 | 750 | if (nextStation < 3) AskForNewClustersInStation(extrapTrackParamAtCh, clusterStore, nextStation); |
751 | } | |
752 | ||
4ea3f013 | 753 | Int_t nClusters = clusterStore.GetSize(); |
754 | Bool_t *clusterCh1Used = new Bool_t[nClusters]; | |
755 | for (Int_t i = 0; i < nClusters; i++) clusterCh1Used[i] = kFALSE; | |
756 | Int_t iCluster1; | |
757 | ||
96ebe67e | 758 | // Create iterators to loop over clusters in both chambers |
759 | TIter nextInCh1(clusterStore.CreateChamberIterator(ch1,ch1)); | |
760 | TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2)); | |
761 | ||
762 | // look for candidates in chamber 2 | |
763 | while ( ( clusterCh2 = static_cast<AliMUONVCluster*>(nextInCh2()) ) ) { | |
ea94c18b | 764 | |
96ebe67e | 765 | // try to add the current cluster fast |
766 | if (!TryOneClusterFast(extrapTrackParamAtCh, clusterCh2)) continue; | |
019df241 | 767 | |
96ebe67e | 768 | // try to add the current cluster accuratly |
769 | chi2OfCluster = TryOneCluster(extrapTrackParamAtCh, clusterCh2, extrapTrackParamAtCluster2, | |
a0dc65b4 | 770 | GetRecoParam()->UseSmoother()); |
ea94c18b | 771 | |
96ebe67e | 772 | // if good chi2 then try to attach a cluster in the other chamber too |
773 | if (chi2OfCluster < maxChi2OfCluster) { | |
ea94c18b | 774 | |
a0dc65b4 | 775 | if (GetRecoParam()->UseSmoother()) { |
ea94c18b | 776 | // save extrapolated parameters for smoother |
96ebe67e | 777 | extrapTrackParamAtCluster2.SetExtrapParameters(extrapTrackParamAtCluster2.GetParameters()); |
ea94c18b | 778 | |
779 | // save extrapolated covariance matrix for smoother | |
96ebe67e | 780 | extrapTrackParamAtCluster2.SetExtrapCovariances(extrapTrackParamAtCluster2.GetCovariances()); |
ea94c18b | 781 | } |
782 | ||
96ebe67e | 783 | // Compute new track parameters including "clusterCh2" using kalman filter |
784 | addChi2TrackAtCluster2 = RunKalmanFilter(extrapTrackParamAtCluster2); | |
ea94c18b | 785 | |
6b191dea | 786 | // skip track out of limits |
787 | if (!IsAcceptable(extrapTrackParamAtCluster2)) continue; | |
89c8d66d | 788 | |
789 | // Printout for debuging | |
790 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
791 | cout << "FollowTrackInStation: found one cluster in chamber(1..): " << ch2+1 | |
792 | << " (Chi2 = " << chi2OfCluster << ")" << endl; | |
793 | clusterCh2->Print(); | |
794 | cout << " look for second clusters in chamber(1..): " << ch1+1 << " ..." << endl; | |
795 | } | |
796 | ||
ea94c18b | 797 | // copy new track parameters for next step |
96ebe67e | 798 | extrapTrackParam = extrapTrackParamAtCluster2; |
ea94c18b | 799 | |
800 | // add MCS effect | |
37a615ac | 801 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParam,AliMUONConstants::ChamberThicknessInX0(),-1.); |
ea94c18b | 802 | |
803 | // reset propagator for smoother | |
a0dc65b4 | 804 | if (GetRecoParam()->UseSmoother()) extrapTrackParam.ResetPropagator(); |
ea94c18b | 805 | |
019df241 | 806 | //Extrapolate track parameters to chamber "ch1" |
4ea3f013 | 807 | Bool_t normalExtrap = AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParam, AliMUONConstants::DefaultChamberZ(ch1), |
808 | GetRecoParam()->UseSmoother()); | |
019df241 | 809 | |
96ebe67e | 810 | // reset cluster iterator of chamber 1 |
811 | nextInCh1.Reset(); | |
812 | iCluster1 = -1; | |
813 | ||
814 | // look for second candidates in chamber 1 | |
89c8d66d | 815 | Bool_t foundSecondCluster = kFALSE; |
4ea3f013 | 816 | if (normalExtrap) while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) { |
96ebe67e | 817 | iCluster1++; |
ea94c18b | 818 | |
96ebe67e | 819 | // try to add the current cluster fast |
820 | if (!TryOneClusterFast(extrapTrackParam, clusterCh1)) continue; | |
019df241 | 821 | |
96ebe67e | 822 | // try to add the current cluster accuratly |
823 | chi2OfCluster = TryOneCluster(extrapTrackParam, clusterCh1, extrapTrackParamAtCluster1, | |
a0dc65b4 | 824 | GetRecoParam()->UseSmoother()); |
019df241 | 825 | |
96ebe67e | 826 | // if good chi2 then consider to add the 2 clusters to the "trackCandidate" |
827 | if (chi2OfCluster < maxChi2OfCluster) { | |
019df241 | 828 | |
a0dc65b4 | 829 | if (GetRecoParam()->UseSmoother()) { |
ea94c18b | 830 | // save extrapolated parameters for smoother |
96ebe67e | 831 | extrapTrackParamAtCluster1.SetExtrapParameters(extrapTrackParamAtCluster1.GetParameters()); |
ea94c18b | 832 | |
833 | // save extrapolated covariance matrix for smoother | |
96ebe67e | 834 | extrapTrackParamAtCluster1.SetExtrapCovariances(extrapTrackParamAtCluster1.GetCovariances()); |
ea94c18b | 835 | } |
836 | ||
96ebe67e | 837 | // Compute new track parameters including "clusterCh1" using kalman filter |
838 | addChi2TrackAtCluster1 = RunKalmanFilter(extrapTrackParamAtCluster1); | |
ea94c18b | 839 | |
6b191dea | 840 | // skip track out of limits |
841 | if (!IsAcceptable(extrapTrackParamAtCluster1)) continue; | |
89c8d66d | 842 | |
843 | // remember a second cluster was found | |
844 | foundSecondCluster = kTRUE; | |
845 | foundTwoClusters = kTRUE; | |
846 | ||
847 | // Printout for debuging | |
848 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
849 | cout << "FollowTrackInStation: found one cluster in chamber(1..): " << ch1+1 | |
850 | << " (Chi2 = " << chi2OfCluster << ")" << endl; | |
851 | clusterCh1->Print(); | |
852 | } | |
9bf6860b | 853 | |
a0dc65b4 | 854 | if (GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 855 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new clusters |
ea94c18b | 856 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 857 | UpdateTrack(*newTrack,extrapTrackParamAtCluster1,extrapTrackParamAtCluster2,addChi2TrackAtCluster1,addChi2TrackAtCluster2); |
ea94c18b | 858 | fNRecTracks++; |
859 | ||
96ebe67e | 860 | // Tag clusterCh1 as used |
861 | clusterCh1Used[iCluster1] = kTRUE; | |
ea94c18b | 862 | |
863 | // Printout for debuging | |
864 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 865 | cout << "FollowTrackInStation: added two clusters in station(1..): " << nextStation+1 << endl; |
ea94c18b | 866 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
867 | } | |
868 | ||
96ebe67e | 869 | } else if (addChi2TrackAtCluster1+addChi2TrackAtCluster2 < bestAddChi2TrackAtCluster1+bestAddChi2TrackAtCluster2) { |
870 | // keep track of the best couple of clusters | |
871 | bestAddChi2TrackAtCluster1 = addChi2TrackAtCluster1; | |
872 | bestAddChi2TrackAtCluster2 = addChi2TrackAtCluster2; | |
873 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster1; | |
874 | bestTrackParamAtCluster2 = extrapTrackParamAtCluster2; | |
ea94c18b | 875 | } |
876 | ||
b0e4c598 | 877 | } |
ea94c18b | 878 | |
8cc77df0 | 879 | } |
ea94c18b | 880 | |
96ebe67e | 881 | // if no clusterCh1 found then consider to add clusterCh2 only |
882 | if (!foundSecondCluster) { | |
89c8d66d | 883 | |
884 | // remember a cluster was found | |
96ebe67e | 885 | foundOneCluster = kTRUE; |
ea94c18b | 886 | |
a0dc65b4 | 887 | if (GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 888 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster |
ea94c18b | 889 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 890 | UpdateTrack(*newTrack,extrapTrackParamAtCluster2,addChi2TrackAtCluster2); |
ea94c18b | 891 | fNRecTracks++; |
892 | ||
ea94c18b | 893 | // Printout for debuging |
894 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 895 | cout << "FollowTrackInStation: added one cluster in chamber(1..): " << ch2+1 << endl; |
ea94c18b | 896 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
897 | } | |
898 | ||
96ebe67e | 899 | } else if (!foundTwoClusters && addChi2TrackAtCluster2 < bestAddChi2TrackAtCluster1) { |
900 | // keep track of the best single cluster except if a couple of clusters has already been found | |
901 | bestAddChi2TrackAtCluster1 = addChi2TrackAtCluster2; | |
902 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster2; | |
ea94c18b | 903 | } |
904 | ||
905 | } | |
906 | ||
8cc77df0 | 907 | } |
ea94c18b | 908 | |
909 | } | |
910 | ||
911 | // look for candidates in chamber 1 not already attached to a track | |
96ebe67e | 912 | // if we want to keep all possible tracks or if no good couple of clusters has been found |
a0dc65b4 | 913 | if (GetRecoParam()->TrackAllTracks() || !foundTwoClusters) { |
ea94c18b | 914 | |
ea94c18b | 915 | // add MCS effect for next step |
37a615ac | 916 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),-1.); |
019df241 | 917 | |
918 | //Extrapolate trackCandidate to chamber "ch1" | |
4ea3f013 | 919 | Bool_t normalExtrap = AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch1), |
920 | GetRecoParam()->UseSmoother()); | |
019df241 | 921 | |
9bf6860b | 922 | // Printout for debuging |
923 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
924 | cout<<endl<<"Track parameters and covariances at first cluster extrapolated to z = "<<AliMUONConstants::DefaultChamberZ(ch1)<<":"<<endl; | |
925 | extrapTrackParamAtCh.GetParameters().Print(); | |
926 | extrapTrackParamAtCh.GetCovariances().Print(); | |
927 | } | |
928 | ||
929 | // Printout for debuging | |
930 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
931 | cout << "FollowTrackInStation: look for single clusters in chamber(1..): " << ch1+1 << endl; | |
932 | } | |
933 | ||
96ebe67e | 934 | // reset cluster iterator of chamber 1 |
935 | nextInCh1.Reset(); | |
936 | iCluster1 = -1; | |
937 | ||
938 | // look for second candidates in chamber 1 | |
4ea3f013 | 939 | if (normalExtrap) while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) { |
96ebe67e | 940 | iCluster1++; |
ea94c18b | 941 | |
96ebe67e | 942 | if (clusterCh1Used[iCluster1]) continue; // Skip clusters already used |
ea94c18b | 943 | |
96ebe67e | 944 | // try to add the current cluster fast |
945 | if (!TryOneClusterFast(extrapTrackParamAtCh, clusterCh1)) continue; | |
019df241 | 946 | |
96ebe67e | 947 | // try to add the current cluster accuratly |
948 | chi2OfCluster = TryOneCluster(extrapTrackParamAtCh, clusterCh1, extrapTrackParamAtCluster1, | |
a0dc65b4 | 949 | GetRecoParam()->UseSmoother()); |
019df241 | 950 | |
96ebe67e | 951 | // if good chi2 then consider to add clusterCh1 |
952 | // We do not try to attach a cluster in the other chamber too since it has already been done above | |
953 | if (chi2OfCluster < maxChi2OfCluster) { | |
019df241 | 954 | |
a0dc65b4 | 955 | if (GetRecoParam()->UseSmoother()) { |
ea94c18b | 956 | // save extrapolated parameters for smoother |
96ebe67e | 957 | extrapTrackParamAtCluster1.SetExtrapParameters(extrapTrackParamAtCluster1.GetParameters()); |
ea94c18b | 958 | |
959 | // save extrapolated covariance matrix for smoother | |
96ebe67e | 960 | extrapTrackParamAtCluster1.SetExtrapCovariances(extrapTrackParamAtCluster1.GetCovariances()); |
ea94c18b | 961 | } |
962 | ||
96ebe67e | 963 | // Compute new track parameters including "clusterCh1" using kalman filter |
964 | addChi2TrackAtCluster1 = RunKalmanFilter(extrapTrackParamAtCluster1); | |
ea94c18b | 965 | |
6b191dea | 966 | // skip track out of limits |
967 | if (!IsAcceptable(extrapTrackParamAtCluster1)) continue; | |
89c8d66d | 968 | |
969 | // remember a cluster was found | |
970 | foundOneCluster = kTRUE; | |
971 | ||
972 | // Printout for debuging | |
973 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
974 | cout << "FollowTrackInStation: found one cluster in chamber(1..): " << ch1+1 | |
975 | << " (Chi2 = " << chi2OfCluster << ")" << endl; | |
976 | clusterCh1->Print(); | |
977 | } | |
9bf6860b | 978 | |
a0dc65b4 | 979 | if (GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 980 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster |
ea94c18b | 981 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 982 | UpdateTrack(*newTrack,extrapTrackParamAtCluster1,addChi2TrackAtCluster1); |
ea94c18b | 983 | fNRecTracks++; |
984 | ||
ea94c18b | 985 | // Printout for debuging |
986 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 987 | cout << "FollowTrackInStation: added one cluster in chamber(1..): " << ch1+1 << endl; |
ea94c18b | 988 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
989 | } | |
990 | ||
96ebe67e | 991 | } else if (addChi2TrackAtCluster1 < bestAddChi2TrackAtCluster1) { |
992 | // keep track of the best single cluster except if a couple of clusters has already been found | |
993 | bestAddChi2TrackAtCluster1 = addChi2TrackAtCluster1; | |
994 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster1; | |
ea94c18b | 995 | } |
996 | ||
997 | } | |
998 | ||
8cc77df0 | 999 | } |
ea94c18b | 1000 | |
1001 | } | |
1002 | ||
1003 | // fill out the best track if required else clean up the fRecTracksPtr array | |
a0dc65b4 | 1004 | if (!GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 1005 | if (foundTwoClusters) { |
1006 | UpdateTrack(trackCandidate,bestTrackParamAtCluster1,bestTrackParamAtCluster2,bestAddChi2TrackAtCluster1,bestAddChi2TrackAtCluster2); | |
ea94c18b | 1007 | |
ea94c18b | 1008 | // Printout for debuging |
1009 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 1010 | cout << "FollowTrackInStation: added the two best clusters in station(1..): " << nextStation+1 << endl; |
ea94c18b | 1011 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
1012 | } | |
1013 | ||
96ebe67e | 1014 | } else if (foundOneCluster) { |
1015 | UpdateTrack(trackCandidate,bestTrackParamAtCluster1,bestAddChi2TrackAtCluster1); | |
ea94c18b | 1016 | |
ea94c18b | 1017 | // Printout for debuging |
1018 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 1019 | cout << "FollowTrackInStation: added the best cluster in chamber(1..): " << bestTrackParamAtCluster1.GetClusterPtr()->GetChamberId()+1 << endl; |
ea94c18b | 1020 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
1021 | } | |
1022 | ||
17773e2e | 1023 | } else { |
96ebe67e | 1024 | delete [] clusterCh1Used; |
17773e2e | 1025 | return kFALSE; |
1026 | } | |
9bf6860b | 1027 | |
96ebe67e | 1028 | } else if (foundOneCluster || foundTwoClusters) { |
ea94c18b | 1029 | |
1030 | // remove obsolete track | |
1031 | fRecTracksPtr->Remove(&trackCandidate); | |
1032 | fNRecTracks--; | |
1033 | ||
17773e2e | 1034 | } else { |
96ebe67e | 1035 | delete [] clusterCh1Used; |
17773e2e | 1036 | return kFALSE; |
9bf6860b | 1037 | } |
1038 | ||
96ebe67e | 1039 | delete [] clusterCh1Used; |
ea94c18b | 1040 | return kTRUE; |
1041 | ||
1042 | } | |
8cc77df0 | 1043 | |
ea94c18b | 1044 | //__________________________________________________________________________ |
96ebe67e | 1045 | Double_t AliMUONTrackReconstructorK::RunKalmanFilter(AliMUONTrackParam &trackParamAtCluster) |
ea94c18b | 1046 | { |
96ebe67e | 1047 | /// Compute new track parameters and their covariances including new cluster using kalman filter |
ea94c18b | 1048 | /// return the additional track chi2 |
1049 | AliDebug(1,"Enter RunKalmanFilter"); | |
1050 | ||
1051 | // Get actual track parameters (p) | |
96ebe67e | 1052 | TMatrixD param(trackParamAtCluster.GetParameters()); |
ea94c18b | 1053 | |
96ebe67e | 1054 | // Get new cluster parameters (m) |
1055 | AliMUONVCluster *cluster = trackParamAtCluster.GetClusterPtr(); | |
1056 | TMatrixD clusterParam(5,1); | |
1057 | clusterParam.Zero(); | |
1058 | clusterParam(0,0) = cluster->GetX(); | |
1059 | clusterParam(2,0) = cluster->GetY(); | |
ea94c18b | 1060 | |
1061 | // Compute the actual parameter weight (W) | |
96ebe67e | 1062 | TMatrixD paramWeight(trackParamAtCluster.GetCovariances()); |
ea94c18b | 1063 | if (paramWeight.Determinant() != 0) { |
1064 | paramWeight.Invert(); | |
1065 | } else { | |
1066 | AliWarning(" Determinant = 0"); | |
4ea3f013 | 1067 | return 2.*AliMUONTrack::MaxChi2(); |
8cc77df0 | 1068 | } |
ea94c18b | 1069 | |
96ebe67e | 1070 | // Compute the new cluster weight (U) |
1071 | TMatrixD clusterWeight(5,5); | |
1072 | clusterWeight.Zero(); | |
1073 | clusterWeight(0,0) = 1. / cluster->GetErrX2(); | |
1074 | clusterWeight(2,2) = 1. / cluster->GetErrY2(); | |
8cc77df0 | 1075 | |
ea94c18b | 1076 | // Compute the new parameters covariance matrix ( (W+U)^-1 ) |
96ebe67e | 1077 | TMatrixD newParamCov(paramWeight,TMatrixD::kPlus,clusterWeight); |
ea94c18b | 1078 | if (newParamCov.Determinant() != 0) { |
1079 | newParamCov.Invert(); | |
1080 | } else { | |
1081 | AliWarning(" Determinant = 0"); | |
4ea3f013 | 1082 | return 2.*AliMUONTrack::MaxChi2(); |
ea94c18b | 1083 | } |
1084 | ||
1085 | // Save the new parameters covariance matrix | |
96ebe67e | 1086 | trackParamAtCluster.SetCovariances(newParamCov); |
ea94c18b | 1087 | |
1088 | // Compute the new parameters (p' = ((W+U)^-1)U(m-p) + p) | |
96ebe67e | 1089 | TMatrixD tmp(clusterParam,TMatrixD::kMinus,param); |
1090 | TMatrixD tmp2(clusterWeight,TMatrixD::kMult,tmp); // U(m-p) | |
ea94c18b | 1091 | TMatrixD newParam(newParamCov,TMatrixD::kMult,tmp2); // ((W+U)^-1)U(m-p) |
1092 | newParam += param; // ((W+U)^-1)U(m-p) + p | |
1093 | ||
1094 | // Save the new parameters | |
96ebe67e | 1095 | trackParamAtCluster.SetParameters(newParam); |
ea94c18b | 1096 | |
1097 | // Compute the additional chi2 (= ((p'-p)^-1)W(p'-p) + ((p'-m)^-1)U(p'-m)) | |
1098 | tmp = newParam; // p' | |
1099 | tmp -= param; // (p'-p) | |
1100 | TMatrixD tmp3(paramWeight,TMatrixD::kMult,tmp); // W(p'-p) | |
1101 | TMatrixD addChi2Track(tmp,TMatrixD::kTransposeMult,tmp3); // ((p'-p)^-1)W(p'-p) | |
1102 | tmp = newParam; // p' | |
96ebe67e | 1103 | tmp -= clusterParam; // (p'-m) |
1104 | TMatrixD tmp4(clusterWeight,TMatrixD::kMult,tmp); // U(p'-m) | |
ea94c18b | 1105 | addChi2Track += TMatrixD(tmp,TMatrixD::kTransposeMult,tmp4); // ((p'-p)^-1)W(p'-p) + ((p'-m)^-1)U(p'-m) |
1106 | ||
1107 | return addChi2Track(0,0); | |
1108 | ||
8cc77df0 | 1109 | } |
1110 | ||
ea94c18b | 1111 | //__________________________________________________________________________ |
96ebe67e | 1112 | void AliMUONTrackReconstructorK::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtCluster, Double_t addChi2) |
8cc77df0 | 1113 | { |
96ebe67e | 1114 | /// Add 1 cluster to the track candidate |
ea94c18b | 1115 | /// Update chi2 of the track |
1116 | ||
9bf6860b | 1117 | // Flag cluster as being (not) removable |
a0dc65b4 | 1118 | if (GetRecoParam()->RequestStation(trackParamAtCluster.GetClusterPtr()->GetChamberId()/2)) |
9bf6860b | 1119 | trackParamAtCluster.SetRemovable(kFALSE); |
1120 | else trackParamAtCluster.SetRemovable(kTRUE); | |
96ebe67e | 1121 | trackParamAtCluster.SetLocalChi2(0.); // --> Local chi2 not used |
5f4ceff2 | 1122 | |
96ebe67e | 1123 | // Update the track chi2 into trackParamAtCluster |
1124 | trackParamAtCluster.SetTrackChi2(track.GetGlobalChi2() + addChi2); | |
ea94c18b | 1125 | |
1126 | // Update the chi2 of the new track | |
96ebe67e | 1127 | track.SetGlobalChi2(trackParamAtCluster.GetTrackChi2()); |
ea94c18b | 1128 | |
96ebe67e | 1129 | // Update array of TrackParamAtCluster |
1130 | track.AddTrackParamAtCluster(trackParamAtCluster,*(trackParamAtCluster.GetClusterPtr())); | |
ea94c18b | 1131 | |
1132 | } | |
8cc77df0 | 1133 | |
ea94c18b | 1134 | //__________________________________________________________________________ |
96ebe67e | 1135 | void AliMUONTrackReconstructorK::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtCluster1, AliMUONTrackParam &trackParamAtCluster2, |
1136 | Double_t addChi2AtCluster1, Double_t addChi2AtCluster2) | |
ea94c18b | 1137 | { |
96ebe67e | 1138 | /// Add 2 clusters to the track candidate (order is important) |
ea94c18b | 1139 | /// Update track and local chi2 |
1140 | ||
96ebe67e | 1141 | // Update local chi2 at first cluster |
1142 | AliMUONVCluster* cluster1 = trackParamAtCluster1.GetClusterPtr(); | |
1143 | Double_t deltaX = trackParamAtCluster1.GetNonBendingCoor() - cluster1->GetX(); | |
1144 | Double_t deltaY = trackParamAtCluster1.GetBendingCoor() - cluster1->GetY(); | |
1145 | Double_t localChi2AtCluster1 = deltaX*deltaX / cluster1->GetErrX2() + | |
1146 | deltaY*deltaY / cluster1->GetErrY2(); | |
1147 | trackParamAtCluster1.SetLocalChi2(localChi2AtCluster1); | |
ea94c18b | 1148 | |
96ebe67e | 1149 | // Flag first cluster as being removable |
1150 | trackParamAtCluster1.SetRemovable(kTRUE); | |
ea94c18b | 1151 | |
96ebe67e | 1152 | // Update local chi2 at second cluster |
1153 | AliMUONVCluster* cluster2 = trackParamAtCluster2.GetClusterPtr(); | |
1154 | AliMUONTrackParam extrapTrackParamAtCluster2(trackParamAtCluster1); | |
1155 | AliMUONTrackExtrap::ExtrapToZ(&extrapTrackParamAtCluster2, trackParamAtCluster2.GetZ()); | |
1156 | deltaX = extrapTrackParamAtCluster2.GetNonBendingCoor() - cluster2->GetX(); | |
1157 | deltaY = extrapTrackParamAtCluster2.GetBendingCoor() - cluster2->GetY(); | |
1158 | Double_t localChi2AtCluster2 = deltaX*deltaX / cluster2->GetErrX2() + | |
1159 | deltaY*deltaY / cluster2->GetErrY2(); | |
1160 | trackParamAtCluster2.SetLocalChi2(localChi2AtCluster2); | |
ea94c18b | 1161 | |
96ebe67e | 1162 | // Flag second cluster as being removable |
1163 | trackParamAtCluster2.SetRemovable(kTRUE); | |
ea94c18b | 1164 | |
96ebe67e | 1165 | // Update the track chi2 into trackParamAtCluster2 |
1166 | trackParamAtCluster2.SetTrackChi2(track.GetGlobalChi2() + addChi2AtCluster2); | |
ea94c18b | 1167 | |
96ebe67e | 1168 | // Update the track chi2 into trackParamAtCluster1 |
1169 | trackParamAtCluster1.SetTrackChi2(trackParamAtCluster2.GetTrackChi2() + addChi2AtCluster1); | |
ea94c18b | 1170 | |
1171 | // Update the chi2 of the new track | |
96ebe67e | 1172 | track.SetGlobalChi2(trackParamAtCluster1.GetTrackChi2()); |
ea94c18b | 1173 | |
96ebe67e | 1174 | // Update array of trackParamAtCluster |
1175 | track.AddTrackParamAtCluster(trackParamAtCluster1,*cluster1); | |
1176 | track.AddTrackParamAtCluster(trackParamAtCluster2,*cluster2); | |
ea94c18b | 1177 | |
1178 | } | |
8cc77df0 | 1179 | |
ea94c18b | 1180 | //__________________________________________________________________________ |
1fef78c8 | 1181 | Bool_t AliMUONTrackReconstructorK::RecoverTrack(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextStation) |
ea94c18b | 1182 | { |
1183 | /// Try to recover the track candidate in the next station | |
96ebe67e | 1184 | /// by removing the worst of the two clusters attached in the current station |
ea94c18b | 1185 | /// Return kTRUE if recovering succeeds |
1186 | AliDebug(1,"Enter RecoverTrack"); | |
1187 | ||
96ebe67e | 1188 | // Do not try to recover track until we have attached cluster(s) on station(1..) 3 |
ea94c18b | 1189 | if (nextStation > 1) return kFALSE; |
1190 | ||
96ebe67e | 1191 | Int_t worstClusterNumber = -1; |
9bf6860b | 1192 | Double_t localChi2, worstLocalChi2 = -1.; |
ea94c18b | 1193 | |
96ebe67e | 1194 | // Look for the cluster to remove |
1195 | for (Int_t clusterNumber = 0; clusterNumber < 2; clusterNumber++) { | |
1196 | AliMUONTrackParam *trackParamAtCluster = (AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(clusterNumber); | |
ea94c18b | 1197 | |
9bf6860b | 1198 | // check if current cluster is in the previous station |
1199 | if (trackParamAtCluster->GetClusterPtr()->GetChamberId()/2 != nextStation+1) break; | |
1200 | ||
96ebe67e | 1201 | // check if current cluster is removable |
1202 | if (!trackParamAtCluster->IsRemovable()) return kFALSE; | |
ea94c18b | 1203 | |
9bf6860b | 1204 | // reset the current cluster as being not removable if it is on a required station |
a0dc65b4 | 1205 | if (GetRecoParam()->RequestStation(nextStation+1)) trackParamAtCluster->SetRemovable(kFALSE); |
9bf6860b | 1206 | |
96ebe67e | 1207 | // Pick up cluster with the worst chi2 |
1208 | localChi2 = trackParamAtCluster->GetLocalChi2(); | |
1209 | if (localChi2 > worstLocalChi2) { | |
1210 | worstLocalChi2 = localChi2; | |
1211 | worstClusterNumber = clusterNumber; | |
8cc77df0 | 1212 | } |
ea94c18b | 1213 | } |
1214 | ||
9bf6860b | 1215 | // check if worst cluster found |
1216 | if (worstClusterNumber < 0) return kFALSE; | |
ea94c18b | 1217 | |
96ebe67e | 1218 | // Remove the worst cluster |
1219 | trackCandidate.RemoveTrackParamAtCluster((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(worstClusterNumber)); | |
ea94c18b | 1220 | |
96ebe67e | 1221 | // Re-calculate track parameters at the (new) first cluster |
4ea3f013 | 1222 | if (!RetracePartialTrack(trackCandidate,(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(1))) return kFALSE; |
ea94c18b | 1223 | |
6b191dea | 1224 | // skip track out of limits |
1225 | if (!IsAcceptable(*((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First()))) return kFALSE; | |
9bf6860b | 1226 | |
96ebe67e | 1227 | // Look for new cluster(s) in next station |
1228 | return FollowTrackInStation(trackCandidate, clusterStore, nextStation); | |
ea94c18b | 1229 | |
8cc77df0 | 1230 | } |
1231 | ||
1232 | //__________________________________________________________________________ | |
ea94c18b | 1233 | Bool_t AliMUONTrackReconstructorK::RunSmoother(AliMUONTrack &track) |
8cc77df0 | 1234 | { |
ea94c18b | 1235 | /// Compute new track parameters and their covariances using smoother |
3304fa09 | 1236 | AliDebug(1,"Enter UseSmoother"); |
ea94c18b | 1237 | |
96ebe67e | 1238 | AliMUONTrackParam *previousTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->First(); |
ea94c18b | 1239 | |
96ebe67e | 1240 | // Smoothed parameters and covariances at first cluster = filtered parameters and covariances |
ea94c18b | 1241 | previousTrackParam->SetSmoothParameters(previousTrackParam->GetParameters()); |
1242 | previousTrackParam->SetSmoothCovariances(previousTrackParam->GetCovariances()); | |
d1e6fdee | 1243 | |
1244 | AliMUONTrackParam *currentTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(previousTrackParam); | |
ea94c18b | 1245 | |
d1e6fdee | 1246 | // Save local chi2 at first cluster = last additional chi2 provided by Kalman |
1247 | previousTrackParam->SetLocalChi2(previousTrackParam->GetTrackChi2() - currentTrackParam->GetTrackChi2()); | |
ea94c18b | 1248 | |
ff078154 | 1249 | // if the track contains only 2 clusters simply copy the filtered parameters |
1250 | if (track.GetNClusters() == 2) { | |
1251 | currentTrackParam->SetSmoothParameters(currentTrackParam->GetParameters()); | |
1252 | currentTrackParam->SetSmoothCovariances(currentTrackParam->GetCovariances()); | |
1253 | currentTrackParam->SetLocalChi2(currentTrackParam->GetTrackChi2()); | |
1254 | return kTRUE; | |
1255 | } | |
1256 | ||
ea94c18b | 1257 | while (currentTrackParam) { |
1258 | ||
1259 | // Get variables | |
1260 | const TMatrixD &extrapParameters = previousTrackParam->GetExtrapParameters(); // X(k+1 k) | |
1261 | const TMatrixD &filteredParameters = currentTrackParam->GetParameters(); // X(k k) | |
1262 | const TMatrixD &previousSmoothParameters = previousTrackParam->GetSmoothParameters(); // X(k+1 n) | |
1263 | const TMatrixD &propagator = previousTrackParam->GetPropagator(); // F(k) | |
1264 | const TMatrixD &extrapCovariances = previousTrackParam->GetExtrapCovariances(); // C(k+1 k) | |
1265 | const TMatrixD &filteredCovariances = currentTrackParam->GetCovariances(); // C(k k) | |
1266 | const TMatrixD &previousSmoothCovariances = previousTrackParam->GetSmoothCovariances(); // C(k+1 n) | |
1267 | ||
d1e6fdee | 1268 | // Compute smoother gain: A(k) = C(kk) * F(k)^t * (C(k+1 k))^-1 |
ea94c18b | 1269 | TMatrixD extrapWeight(extrapCovariances); |
1270 | if (extrapWeight.Determinant() != 0) { | |
1271 | extrapWeight.Invert(); // (C(k+1 k))^-1 | |
1272 | } else { | |
1273 | AliWarning(" Determinant = 0"); | |
1274 | return kFALSE; | |
1275 | } | |
d1e6fdee | 1276 | TMatrixD smootherGain(filteredCovariances,TMatrixD::kMultTranspose,propagator); // C(kk) * F(k)^t |
1277 | smootherGain *= extrapWeight; // C(kk) * F(k)^t * (C(k+1 k))^-1 | |
ea94c18b | 1278 | |
1279 | // Compute smoothed parameters: X(k n) = X(k k) + A(k) * (X(k+1 n) - X(k+1 k)) | |
1280 | TMatrixD tmpParam(previousSmoothParameters,TMatrixD::kMinus,extrapParameters); // X(k+1 n) - X(k+1 k) | |
1281 | TMatrixD smoothParameters(smootherGain,TMatrixD::kMult,tmpParam); // A(k) * (X(k+1 n) - X(k+1 k)) | |
1282 | smoothParameters += filteredParameters; // X(k k) + A(k) * (X(k+1 n) - X(k+1 k)) | |
1283 | ||
1284 | // Save smoothed parameters | |
1285 | currentTrackParam->SetSmoothParameters(smoothParameters); | |
1286 | ||
1287 | // Compute smoothed covariances: C(k n) = C(k k) + A(k) * (C(k+1 n) - C(k+1 k)) * (A(k))^t | |
1288 | TMatrixD tmpCov(previousSmoothCovariances,TMatrixD::kMinus,extrapCovariances); // C(k+1 n) - C(k+1 k) | |
1289 | TMatrixD tmpCov2(tmpCov,TMatrixD::kMultTranspose,smootherGain); // (C(k+1 n) - C(k+1 k)) * (A(k))^t | |
1290 | TMatrixD smoothCovariances(smootherGain,TMatrixD::kMult,tmpCov2); // A(k) * (C(k+1 n) - C(k+1 k)) * (A(k))^t | |
1291 | smoothCovariances += filteredCovariances; // C(k k) + A(k) * (C(k+1 n) - C(k+1 k)) * (A(k))^t | |
1292 | ||
1293 | // Save smoothed covariances | |
1294 | currentTrackParam->SetSmoothCovariances(smoothCovariances); | |
1295 | ||
96ebe67e | 1296 | // Compute smoothed residual: r(k n) = cluster - X(k n) |
d1e6fdee | 1297 | AliMUONVCluster* cluster = currentTrackParam->GetClusterPtr(); |
ea94c18b | 1298 | TMatrixD smoothResidual(2,1); |
1299 | smoothResidual.Zero(); | |
96ebe67e | 1300 | smoothResidual(0,0) = cluster->GetX() - smoothParameters(0,0); |
1301 | smoothResidual(1,0) = cluster->GetY() - smoothParameters(2,0); | |
ea94c18b | 1302 | |
96ebe67e | 1303 | // Compute weight of smoothed residual: W(k n) = (clusterCov - C(k n))^-1 |
ea94c18b | 1304 | TMatrixD smoothResidualWeight(2,2); |
96ebe67e | 1305 | smoothResidualWeight(0,0) = cluster->GetErrX2() - smoothCovariances(0,0); |
ea94c18b | 1306 | smoothResidualWeight(0,1) = - smoothCovariances(0,2); |
1307 | smoothResidualWeight(1,0) = - smoothCovariances(2,0); | |
96ebe67e | 1308 | smoothResidualWeight(1,1) = cluster->GetErrY2() - smoothCovariances(2,2); |
ea94c18b | 1309 | if (smoothResidualWeight.Determinant() != 0) { |
1310 | smoothResidualWeight.Invert(); | |
1311 | } else { | |
1312 | AliWarning(" Determinant = 0"); | |
1313 | return kFALSE; | |
1314 | } | |
1315 | ||
1316 | // Compute local chi2 = (r(k n))^t * W(k n) * r(k n) | |
1317 | TMatrixD tmpChi2(smoothResidual,TMatrixD::kTransposeMult,smoothResidualWeight); // (r(k n))^t * W(k n) | |
1318 | TMatrixD localChi2(tmpChi2,TMatrixD::kMult,smoothResidual); // (r(k n))^t * W(k n) * r(k n) | |
1319 | ||
1320 | // Save local chi2 | |
1321 | currentTrackParam->SetLocalChi2(localChi2(0,0)); | |
1322 | ||
1323 | previousTrackParam = currentTrackParam; | |
96ebe67e | 1324 | currentTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(previousTrackParam); |
ea94c18b | 1325 | } |
1326 | ||
1327 | return kTRUE; | |
1328 | ||
8cc77df0 | 1329 | } |
1330 | ||
8cc77df0 | 1331 | //__________________________________________________________________________ |
89c8d66d | 1332 | Bool_t AliMUONTrackReconstructorK::ComplementTracks(const AliMUONVClusterStore& clusterStore) |
b709ac13 | 1333 | { |
1334 | /// Complete tracks by adding missing clusters (if there is an overlap between | |
89c8d66d | 1335 | /// two detection elements, the track may have two clusters in the same chamber). |
1336 | /// Recompute track parameters and covariances at each clusters. | |
4ea3f013 | 1337 | /// Remove tracks getting abnormal (i.e. extrapolation failed...) after being complemented. |
1338 | /// Return kTRUE if one or more tracks have been complemented or removed. | |
b709ac13 | 1339 | AliDebug(1,"Enter ComplementTracks"); |
1340 | ||
1341 | Int_t chamberId, detElemId; | |
96ebe67e | 1342 | Double_t chi2OfCluster, addChi2TrackAtCluster, bestAddChi2TrackAtCluster; |
a0dc65b4 | 1343 | Double_t maxChi2OfCluster = 2. * GetRecoParam()->GetSigmaCutForTracking() * |
1344 | GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2 | |
89c8d66d | 1345 | Bool_t foundOneCluster, trackModified, hasChanged = kFALSE; |
96ebe67e | 1346 | AliMUONVCluster *cluster; |
1347 | AliMUONTrackParam *trackParam, *previousTrackParam, *nextTrackParam, trackParamAtCluster, bestTrackParamAtCluster; | |
4ea3f013 | 1348 | AliMUONTrack *nextTrack; |
b709ac13 | 1349 | |
b709ac13 | 1350 | AliMUONTrack *track = (AliMUONTrack*) fRecTracksPtr->First(); |
1351 | while (track) { | |
1352 | trackModified = kFALSE; | |
1353 | ||
96ebe67e | 1354 | trackParam = (AliMUONTrackParam*)track->GetTrackParamAtCluster()->First(); |
b709ac13 | 1355 | previousTrackParam = trackParam; |
1356 | while (trackParam) { | |
96ebe67e | 1357 | foundOneCluster = kFALSE; |
4ea3f013 | 1358 | bestAddChi2TrackAtCluster = AliMUONTrack::MaxChi2(); |
96ebe67e | 1359 | chamberId = trackParam->GetClusterPtr()->GetChamberId(); |
1360 | detElemId = trackParam->GetClusterPtr()->GetDetElemId(); | |
b709ac13 | 1361 | |
1362 | // prepare nextTrackParam before adding new cluster because of the sorting | |
96ebe67e | 1363 | nextTrackParam = (AliMUONTrackParam*)track->GetTrackParamAtCluster()->After(trackParam); |
b709ac13 | 1364 | |
96ebe67e | 1365 | // Create iterators to loop over clusters in current chamber |
1366 | TIter nextInCh(clusterStore.CreateChamberIterator(chamberId,chamberId)); | |
b709ac13 | 1367 | |
1368 | // look for one second candidate in the same chamber | |
96ebe67e | 1369 | while ( ( cluster = static_cast<AliMUONVCluster*>(nextInCh()) ) ) { |
b709ac13 | 1370 | |
1371 | // look for a cluster in another detection element | |
96ebe67e | 1372 | if (cluster->GetDetElemId() == detElemId) continue; |
b709ac13 | 1373 | |
96ebe67e | 1374 | // try to add the current cluster fast |
1375 | if (!TryOneClusterFast(*trackParam, cluster)) continue; | |
b709ac13 | 1376 | |
96ebe67e | 1377 | // try to add the current cluster accurately |
b709ac13 | 1378 | // never use track parameters at last cluster because the covariance matrix is meaningless |
96ebe67e | 1379 | if (nextTrackParam) chi2OfCluster = TryOneCluster(*trackParam, cluster, trackParamAtCluster); |
1380 | else chi2OfCluster = TryOneCluster(*previousTrackParam, cluster, trackParamAtCluster); | |
b709ac13 | 1381 | |
1382 | // if good chi2 then consider to add this cluster to the track | |
96ebe67e | 1383 | if (chi2OfCluster < maxChi2OfCluster) { |
b709ac13 | 1384 | |
96ebe67e | 1385 | // Compute local track parameters including current cluster using kalman filter |
1386 | addChi2TrackAtCluster = RunKalmanFilter(trackParamAtCluster); | |
b709ac13 | 1387 | |
1388 | // keep track of the best cluster | |
96ebe67e | 1389 | if (addChi2TrackAtCluster < bestAddChi2TrackAtCluster) { |
1390 | bestAddChi2TrackAtCluster = addChi2TrackAtCluster; | |
1391 | bestTrackParamAtCluster = trackParamAtCluster; | |
1392 | foundOneCluster = kTRUE; | |
b709ac13 | 1393 | } |
1394 | ||
1395 | } | |
1396 | ||
1397 | } | |
1398 | ||
1399 | // add new cluster if any | |
96ebe67e | 1400 | if (foundOneCluster) { |
0e894e58 | 1401 | |
1402 | // Printout for debuging | |
1403 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
1404 | cout << "ComplementTracks: found one cluster in chamber(1..): " << chamberId+1 << endl; | |
1405 | bestTrackParamAtCluster.GetClusterPtr()->Print(); | |
ad3c6eda | 1406 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { |
1407 | cout<<endl<<"Track parameters and covariances at cluster:"<<endl; | |
1408 | bestTrackParamAtCluster.GetParameters().Print(); | |
1409 | bestTrackParamAtCluster.GetCovariances().Print(); | |
1410 | } | |
0e894e58 | 1411 | } |
1412 | ||
7332f213 | 1413 | trackParam->SetRemovable(kTRUE); |
1414 | bestTrackParamAtCluster.SetRemovable(kTRUE); | |
1415 | track->AddTrackParamAtCluster(bestTrackParamAtCluster,*(bestTrackParamAtCluster.GetClusterPtr())); | |
b709ac13 | 1416 | trackModified = kTRUE; |
89c8d66d | 1417 | hasChanged = kTRUE; |
b709ac13 | 1418 | } |
1419 | ||
1420 | previousTrackParam = trackParam; | |
1421 | trackParam = nextTrackParam; | |
1422 | } | |
1423 | ||
4ea3f013 | 1424 | // prepare next track |
1425 | nextTrack = (AliMUONTrack*) fRecTracksPtr->After(track); | |
1426 | ||
b709ac13 | 1427 | // re-compute track parameters using kalman filter if needed |
4ea3f013 | 1428 | if (trackModified && !RetraceTrack(*track,kTRUE)) { |
1429 | AliWarning("track modified but problem occur during refitting --> remove track"); | |
1430 | fRecTracksPtr->Remove(track); | |
1431 | fNRecTracks--; | |
1432 | } | |
b709ac13 | 1433 | |
4ea3f013 | 1434 | track = nextTrack; |
b709ac13 | 1435 | } |
1436 | ||
89c8d66d | 1437 | return hasChanged; |
1438 | ||
b709ac13 | 1439 | } |
1440 | ||
1441 | //__________________________________________________________________________ | |
7332f213 | 1442 | void AliMUONTrackReconstructorK::ImproveTrack(AliMUONTrack &track) |
8cc77df0 | 1443 | { |
7332f213 | 1444 | /// Improve the given track by removing removable clusters with local chi2 highter than the defined cut |
1445 | /// Removable clusters are identified by the method AliMUONTrack::TagRemovableClusters() | |
ea94c18b | 1446 | /// Recompute track parameters and covariances at the remaining clusters |
4ea3f013 | 1447 | /// and if something goes wrong (i.e. extrapolation failed...) set track chi2 to max value |
7332f213 | 1448 | AliDebug(1,"Enter ImproveTrack"); |
ea94c18b | 1449 | |
1450 | Double_t localChi2, worstLocalChi2; | |
ff078154 | 1451 | AliMUONTrackParam *trackParamAtCluster, *worstTrackParamAtCluster, *nextTrackParam, *next2nextTrackParam; |
1452 | Int_t nextChamber, next2nextChamber; | |
ea94c18b | 1453 | Bool_t smoothed; |
a0dc65b4 | 1454 | Double_t sigmaCut2 = GetRecoParam()->GetSigmaCutForImprovement() * |
1455 | GetRecoParam()->GetSigmaCutForImprovement(); | |
ea94c18b | 1456 | |
7332f213 | 1457 | while (!track.IsImproved()) { |
ea94c18b | 1458 | |
7332f213 | 1459 | // identify removable clusters |
a0dc65b4 | 1460 | track.TagRemovableClusters(GetRecoParam()->RequestedStationMask()); |
b709ac13 | 1461 | |
7332f213 | 1462 | // Run smoother if required |
1463 | smoothed = kFALSE; | |
a0dc65b4 | 1464 | if (GetRecoParam()->UseSmoother()) smoothed = RunSmoother(track); |
7332f213 | 1465 | |
1466 | // Use standard procedure to compute local chi2 if smoother not required or not working | |
1467 | if (!smoothed) { | |
ea94c18b | 1468 | |
7332f213 | 1469 | // Update track parameters and covariances |
4ea3f013 | 1470 | if (!track.UpdateCovTrackParamAtCluster()) { |
1471 | AliWarning("unable to update track parameters and covariances --> stop improvement"); | |
1472 | // restore the kalman parameters | |
1473 | RetraceTrack(track,kTRUE); | |
1474 | break; | |
1475 | } | |
ea94c18b | 1476 | |
7332f213 | 1477 | // Compute local chi2 of each clusters |
1478 | track.ComputeLocalChi2(kTRUE); | |
1479 | } | |
1480 | ||
1481 | // Look for the cluster to remove | |
1482 | worstTrackParamAtCluster = 0x0; | |
ff078154 | 1483 | worstLocalChi2 = -1.; |
7332f213 | 1484 | trackParamAtCluster = (AliMUONTrackParam*)track.GetTrackParamAtCluster()->First(); |
1485 | while (trackParamAtCluster) { | |
ea94c18b | 1486 | |
7332f213 | 1487 | // save parameters into smooth parameters in case of smoother did not work properly |
a0dc65b4 | 1488 | if (GetRecoParam()->UseSmoother() && !smoothed) { |
7332f213 | 1489 | trackParamAtCluster->SetSmoothParameters(trackParamAtCluster->GetParameters()); |
1490 | trackParamAtCluster->SetSmoothCovariances(trackParamAtCluster->GetCovariances()); | |
ea94c18b | 1491 | } |
1492 | ||
7332f213 | 1493 | // Pick up cluster with the worst chi2 |
1494 | localChi2 = trackParamAtCluster->GetLocalChi2(); | |
1495 | if (localChi2 > worstLocalChi2) { | |
1496 | worstLocalChi2 = localChi2; | |
1497 | worstTrackParamAtCluster = trackParamAtCluster; | |
ea94c18b | 1498 | } |
1499 | ||
7332f213 | 1500 | trackParamAtCluster = (AliMUONTrackParam*)track.GetTrackParamAtCluster()->After(trackParamAtCluster); |
1501 | } | |
1502 | ||
7332f213 | 1503 | // Check whether the worst chi2 is under requirement or not |
1504 | if (worstLocalChi2 < 2. * sigmaCut2) { // 2 because 2 quantities in chi2 | |
1505 | track.SetImproved(kTRUE); | |
1506 | break; | |
1507 | } | |
1508 | ||
1509 | // if the worst cluster is not removable then stop improvement | |
ff078154 | 1510 | if (!worstTrackParamAtCluster->IsRemovable()) { |
1511 | // restore the kalman parameters in case they have been lost | |
1512 | if (!smoothed) RetraceTrack(track,kTRUE); | |
1513 | break; | |
1514 | } | |
7332f213 | 1515 | |
1516 | // get track parameters at cluster next to the one to be removed | |
1517 | nextTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(worstTrackParamAtCluster); | |
1518 | ||
1519 | // Remove the worst cluster | |
1520 | track.RemoveTrackParamAtCluster(worstTrackParamAtCluster); | |
1521 | ||
1522 | // Re-calculate track parameters | |
1523 | // - from the cluster immediately downstream the one suppressed | |
1524 | // - or from the begining - if parameters have been re-computed using the standard method (kalman parameters have been lost) | |
ff078154 | 1525 | // - or if the removed cluster was used to compute the tracking seed |
4ea3f013 | 1526 | Bool_t normalExtrap; |
ff078154 | 1527 | if (smoothed && nextTrackParam) { |
1528 | ||
1529 | nextChamber = nextTrackParam->GetClusterPtr()->GetChamberId(); | |
1530 | next2nextTrackParam = nextTrackParam; | |
1531 | do { | |
1532 | ||
1533 | next2nextChamber = next2nextTrackParam->GetClusterPtr()->GetChamberId(); | |
1534 | next2nextTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(next2nextTrackParam); | |
1535 | ||
1536 | } while (next2nextTrackParam && (next2nextChamber == nextChamber)); | |
1537 | ||
4ea3f013 | 1538 | if (next2nextChamber == nextChamber) normalExtrap = RetraceTrack(track,kTRUE); |
1539 | else normalExtrap = RetracePartialTrack(track,nextTrackParam); | |
ff078154 | 1540 | |
4ea3f013 | 1541 | } else normalExtrap = RetraceTrack(track,kTRUE); |
1542 | ||
1543 | // stop in case of extrapolation problem | |
1544 | if (!normalExtrap) { | |
1545 | AliWarning("track partially improved but problem occur during refitting --> stop improvement"); | |
1546 | break; | |
1547 | } | |
7332f213 | 1548 | |
1549 | // Printout for debuging | |
1550 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
1551 | cout << "ImproveTracks: track " << fRecTracksPtr->IndexOf(&track)+1 << " improved " << endl; | |
ea94c18b | 1552 | } |
1553 | ||
ea94c18b | 1554 | } |
1555 | ||
8cc77df0 | 1556 | } |
1557 | ||
7332f213 | 1558 | //__________________________________________________________________________ |
4ea3f013 | 1559 | Bool_t AliMUONTrackReconstructorK::FinalizeTrack(AliMUONTrack &track) |
b0e4c598 | 1560 | { |
96ebe67e | 1561 | /// Update track parameters and covariances at each attached cluster |
7332f213 | 1562 | /// using smoother if required, if not already done |
4ea3f013 | 1563 | /// return kFALSE if the track cannot be extrapolated uo to the last chamber |
b709ac13 | 1564 | |
96ebe67e | 1565 | AliMUONTrackParam *trackParamAtCluster; |
ea94c18b | 1566 | Bool_t smoothed = kFALSE; |
1567 | ||
7332f213 | 1568 | // update track parameters (using smoother if required) if not already done |
4ea3f013 | 1569 | if (track.IsImproved()) smoothed = GetRecoParam()->UseSmoother(); |
1570 | else { | |
a0dc65b4 | 1571 | if (GetRecoParam()->UseSmoother()) smoothed = RunSmoother(track); |
d1e6fdee | 1572 | if (!smoothed) { |
4ea3f013 | 1573 | if (track.UpdateCovTrackParamAtCluster()) track.ComputeLocalChi2(kTRUE); |
1574 | else { | |
1575 | AliWarning("finalization failed due to extrapolation problem"); | |
1576 | return kFALSE; | |
1577 | } | |
d1e6fdee | 1578 | } |
4ea3f013 | 1579 | } |
7332f213 | 1580 | |
1581 | // copy smoothed parameters and covariances if any | |
1582 | if (smoothed) { | |
ea94c18b | 1583 | |
7332f213 | 1584 | trackParamAtCluster = (AliMUONTrackParam*) (track.GetTrackParamAtCluster()->First()); |
1585 | while (trackParamAtCluster) { | |
ea94c18b | 1586 | |
7332f213 | 1587 | trackParamAtCluster->SetParameters(trackParamAtCluster->GetSmoothParameters()); |
1588 | trackParamAtCluster->SetCovariances(trackParamAtCluster->GetSmoothCovariances()); | |
ea94c18b | 1589 | |
7332f213 | 1590 | trackParamAtCluster = (AliMUONTrackParam*) (track.GetTrackParamAtCluster()->After(trackParamAtCluster)); |
ea94c18b | 1591 | } |
1592 | ||
b0e4c598 | 1593 | } |
7332f213 | 1594 | |
4ea3f013 | 1595 | return kTRUE; |
1596 | ||
7deb8eb0 | 1597 | } |
1598 | ||
1599 | //__________________________________________________________________________ | |
b1fea02e | 1600 | Bool_t AliMUONTrackReconstructorK::RefitTrack(AliMUONTrack &track, Bool_t enableImprovement) |
7deb8eb0 | 1601 | { |
1602 | /// re-fit the given track | |
89c8d66d | 1603 | AliDebug(1,"Enter RefitTrack"); |
7deb8eb0 | 1604 | |
ff078154 | 1605 | // check validity of the track (i.e. at least 2 chambers hit on stations 4 and 5) |
1606 | if (!track.IsValid(0)) { | |
1607 | AliWarning("the track is not valid --> unable to refit"); | |
7deb8eb0 | 1608 | return kFALSE; |
1609 | } | |
1610 | ||
1611 | // re-compute track parameters and covariances using Kalman filter | |
4ea3f013 | 1612 | if (!RetraceTrack(track,kTRUE)) { |
1613 | AliWarning("bad track refitting due to extrapolation failure"); | |
1614 | return kFALSE; | |
1615 | } | |
7deb8eb0 | 1616 | |
1617 | // Improve the reconstructed tracks if required | |
b1fea02e | 1618 | track.SetImproved(kFALSE); |
a0dc65b4 | 1619 | if (enableImprovement && GetRecoParam()->ImproveTracks()) ImproveTrack(track); |
7deb8eb0 | 1620 | |
1621 | // Fill AliMUONTrack data members | |
4ea3f013 | 1622 | if (track.GetGlobalChi2() < AliMUONTrack::MaxChi2()) return FinalizeTrack(track); |
1623 | else { | |
1624 | AliWarning("track not finalized due to extrapolation failure"); | |
1625 | return kFALSE; | |
1626 | } | |
7deb8eb0 | 1627 | |
b0e4c598 | 1628 | } |
ea94c18b | 1629 |