]>
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" | |
8cde4af5 | 40 | |
1fef78c8 | 41 | #include "AliMpArea.h" |
42 | ||
8cc77df0 | 43 | #include "AliLog.h" |
44 | ||
8cde4af5 | 45 | #include <Riostream.h> |
ea94c18b | 46 | #include <TMath.h> |
47 | #include <TMatrixD.h> | |
8cde4af5 | 48 | |
49 | /// \cond CLASSIMP | |
8cc77df0 | 50 | ClassImp(AliMUONTrackReconstructorK) // Class implementation in ROOT context |
8cde4af5 | 51 | /// \endcond |
8cc77df0 | 52 | |
019df241 | 53 | //__________________________________________________________________________ |
1fef78c8 | 54 | AliMUONTrackReconstructorK::AliMUONTrackReconstructorK(AliMUONVClusterServer& clusterServer) |
55 | : AliMUONVTrackReconstructor(clusterServer) | |
8cc77df0 | 56 | { |
96ebe67e | 57 | /// Constructor |
8cc77df0 | 58 | } |
59 | ||
019df241 | 60 | //__________________________________________________________________________ |
ea94c18b | 61 | AliMUONTrackReconstructorK::~AliMUONTrackReconstructorK() |
8cc77df0 | 62 | { |
ea94c18b | 63 | /// Destructor |
64 | } | |
8cc77df0 | 65 | |
66 | //__________________________________________________________________________ | |
1fef78c8 | 67 | void AliMUONTrackReconstructorK::MakeTrackCandidates(AliMUONVClusterStore& clusterStore) |
8cc77df0 | 68 | { |
019df241 | 69 | /// To make track candidates (assuming linear propagation if the flag fgkMakeTrackCandidatesFast is set to kTRUE): |
ea94c18b | 70 | /// Start with segments station(1..) 4 or 5 then follow track in station 5 or 4. |
96ebe67e | 71 | /// Good candidates are made of at least three clusters. |
ea94c18b | 72 | /// Keep only best candidates or all of them according to the flag fgkTrackAllTracks. |
b709ac13 | 73 | |
208f139e | 74 | TClonesArray *segments; |
ea94c18b | 75 | AliMUONTrack *track; |
76 | Int_t iCandidate = 0; | |
96ebe67e | 77 | Bool_t clusterFound; |
8cc77df0 | 78 | |
ea94c18b | 79 | AliDebug(1,"Enter MakeTrackCandidates"); |
8cc77df0 | 80 | |
1fef78c8 | 81 | // Unless we're doing combined tracking, we'll clusterize all stations at once |
82 | Int_t firstChamber(0); | |
83 | Int_t lastChamber(9); | |
84 | ||
85 | if (AliMUONReconstructor::GetRecoParam()->CombineClusterTrackReco()) { | |
86 | // ... Here's the exception : ask the clustering to reconstruct | |
87 | // clusters *only* in station 4 and 5 for combined tracking | |
88 | firstChamber = 6; | |
89 | } | |
90 | ||
91 | for (Int_t i = firstChamber; i <= lastChamber; ++i ) | |
92 | { | |
93 | fClusterServer.Clusterize(i, clusterStore, AliMpArea()); | |
94 | } | |
95 | ||
ea94c18b | 96 | // Loop over stations(1..) 5 and 4 and make track candidates |
97 | for (Int_t istat=4; istat>=3; istat--) { | |
98 | ||
208f139e | 99 | // Make segments in the station |
96ebe67e | 100 | segments = MakeSegmentsInStation(clusterStore, istat); |
ea94c18b | 101 | |
102 | // Loop over segments | |
103 | for (Int_t iseg=0; iseg<segments->GetEntriesFast(); iseg++) { | |
104 | AliDebug(1,Form("Making primary candidate(1..) %d",++iCandidate)); | |
105 | ||
106 | // Transform segments to tracks and put them at the end of fRecTracksPtr | |
107 | track = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack((AliMUONObjectPair*)((*segments)[iseg])); | |
108 | fNRecTracks++; | |
109 | ||
ea94c18b | 110 | // Printout for debuging |
111 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
96ebe67e | 112 | cout<<endl<<"Track parameter covariances at first cluster:"<<endl; |
113 | ((AliMUONTrackParam*) (track->GetTrackParamAtCluster()->First()))->GetCovariances().Print(); | |
ea94c18b | 114 | } |
115 | ||
96ebe67e | 116 | // Look for compatible cluster(s) in the other station |
117 | if (AliMUONReconstructor::GetRecoParam()->MakeTrackCandidatesFast()) | |
118 | clusterFound = FollowLinearTrackInStation(*track, clusterStore, 7-istat); | |
019df241 | 119 | else { |
120 | // First recompute track parameters and covariances on station(1..) 5 using Kalman filter | |
121 | // (to make sure all tracks are treated in the same way) | |
96ebe67e | 122 | if (istat == 4) RetraceTrack(*track, kFALSE); |
123 | clusterFound = FollowTrackInStation(*track, clusterStore, 7-istat); | |
019df241 | 124 | } |
125 | ||
96ebe67e | 126 | // Remove track if no cluster found |
127 | if (!clusterFound) { | |
ea94c18b | 128 | fRecTracksPtr->Remove(track); |
129 | fNRecTracks--; | |
130 | } | |
131 | ||
132 | } | |
133 | // delete the array of segments | |
7ec3b9cf | 134 | delete segments; |
ea94c18b | 135 | } |
136 | ||
ea94c18b | 137 | |
019df241 | 138 | // Retrace tracks using Kalman filter and remove bad ones |
3304fa09 | 139 | if (AliMUONReconstructor::GetRecoParam()->MakeTrackCandidatesFast()) { |
019df241 | 140 | fRecTracksPtr->Compress(); // this is essential before checking tracks |
ea94c18b | 141 | |
019df241 | 142 | Int_t currentNRecTracks = fNRecTracks; |
143 | for (Int_t iRecTrack = 0; iRecTrack < currentNRecTracks; iRecTrack++) { | |
144 | track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iRecTrack); | |
145 | ||
146 | // Recompute track parameters and covariances using Kalman filter | |
147 | RetraceTrack(*track,kTRUE); | |
148 | ||
149 | // Remove the track if the normalized chi2 is too high | |
3304fa09 | 150 | if (track->GetNormalizedChi2() > AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking() * |
151 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking()) { | |
019df241 | 152 | fRecTracksPtr->Remove(track); |
153 | fNRecTracks--; | |
154 | } | |
155 | ||
ea94c18b | 156 | } |
157 | ||
158 | } | |
159 | ||
160 | fRecTracksPtr->Compress(); // this is essential before checking tracks | |
161 | ||
162 | // Keep all different tracks or only the best ones as required | |
3304fa09 | 163 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) RemoveIdenticalTracks(); |
ea94c18b | 164 | else RemoveDoubleTracks(); |
165 | ||
166 | AliDebug(1,Form("Number of good candidates = %d",fNRecTracks)); | |
167 | ||
8cc77df0 | 168 | } |
169 | ||
ea94c18b | 170 | //__________________________________________________________________________ |
171 | void AliMUONTrackReconstructorK::RetraceTrack(AliMUONTrack &trackCandidate, Bool_t resetSeed) | |
8cc77df0 | 172 | { |
96ebe67e | 173 | /// Re-run the kalman filter from the most downstream cluster to the most uptream one |
ea94c18b | 174 | AliDebug(1,"Enter RetraceTrack"); |
175 | ||
7332f213 | 176 | AliMUONTrackParam* lastTrackParam = (AliMUONTrackParam*) trackCandidate.GetTrackParamAtCluster()->Last(); |
ea94c18b | 177 | |
96ebe67e | 178 | // Reset the "seed" (= track parameters and their covariances at last cluster) if required |
ea94c18b | 179 | if (resetSeed) { |
7332f213 | 180 | |
181 | // parameters at last cluster | |
182 | AliMUONVCluster* cluster2 = lastTrackParam->GetClusterPtr(); | |
183 | Double_t x2 = cluster2->GetX(); | |
184 | Double_t y2 = cluster2->GetY(); | |
185 | Double_t z2 = cluster2->GetZ(); | |
186 | ||
187 | // parameters at last but one cluster | |
188 | AliMUONTrackParam* previousTrackParam = (AliMUONTrackParam*) trackCandidate.GetTrackParamAtCluster()->Before(lastTrackParam); | |
189 | AliMUONVCluster* cluster1 = previousTrackParam->GetClusterPtr(); | |
190 | Double_t x1 = cluster1->GetX(); | |
191 | Double_t y1 = cluster1->GetY(); | |
192 | Double_t z1 = cluster1->GetZ(); | |
193 | ||
194 | // reset track parameters | |
195 | Double_t dZ = z1 - z2; | |
196 | lastTrackParam->SetNonBendingCoor(x2); | |
197 | lastTrackParam->SetBendingCoor(y2); | |
198 | lastTrackParam->SetZ(z2); | |
199 | lastTrackParam->SetNonBendingSlope((x1 - x2) / dZ); | |
200 | lastTrackParam->SetBendingSlope((y1 - y2) / dZ); | |
201 | Double_t bendingImpact = y2 - z2 * lastTrackParam->GetBendingSlope(); | |
202 | lastTrackParam->SetInverseBendingMomentum(1. / AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(bendingImpact)); | |
203 | ||
204 | // => Reset track parameter covariances at last cluster (as if the other clusters did not exist) | |
205 | TMatrixD lastParamCov(5,5); | |
206 | lastParamCov.Zero(); | |
ea94c18b | 207 | // Non bending plane |
7332f213 | 208 | lastParamCov(0,0) = cluster2->GetErrX2(); |
209 | lastParamCov(1,1) = 100. * ( cluster1->GetErrX2() + cluster2->GetErrX2() ) / dZ / dZ; | |
ea94c18b | 210 | // Bending plane |
7332f213 | 211 | lastParamCov(2,2) = cluster2->GetErrY2(); |
212 | lastParamCov(3,3) = 100. * ( cluster1->GetErrY2() + cluster2->GetErrY2() ) / dZ / dZ; | |
213 | // Inverse bending momentum (50% error) | |
214 | lastParamCov(4,4) = 0.5*lastTrackParam->GetInverseBendingMomentum() * 0.5*lastTrackParam->GetInverseBendingMomentum(); | |
215 | lastTrackParam->SetCovariances(lastParamCov); | |
ea94c18b | 216 | |
217 | // Reset the track chi2 | |
7332f213 | 218 | lastTrackParam->SetTrackChi2(0.); |
ea94c18b | 219 | |
220 | } | |
221 | ||
222 | // Redo the tracking | |
7332f213 | 223 | RetracePartialTrack(trackCandidate, lastTrackParam); |
ea94c18b | 224 | |
225 | } | |
8cc77df0 | 226 | |
ea94c18b | 227 | //__________________________________________________________________________ |
228 | void AliMUONTrackReconstructorK::RetracePartialTrack(AliMUONTrack &trackCandidate, const AliMUONTrackParam* startingTrackParam) | |
229 | { | |
96ebe67e | 230 | /// Re-run the kalman filter from the cluster attached to startingTrackParam to the most uptream cluster |
ea94c18b | 231 | AliDebug(1,"Enter RetracePartialTrack"); |
232 | ||
233 | // Printout for debuging | |
234 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 235 | cout << "RetracePartialTrack: track chi2 before re-tracking: " << trackCandidate.GetGlobalChi2() << endl; |
ea94c18b | 236 | } |
237 | ||
238 | // Reset the track chi2 | |
96ebe67e | 239 | trackCandidate.SetGlobalChi2(startingTrackParam->GetTrackChi2()); |
ea94c18b | 240 | |
96ebe67e | 241 | // loop over attached clusters until the first one and recompute track parameters and covariances using kalman filter |
242 | Int_t expectedChamber = startingTrackParam->GetClusterPtr()->GetChamberId() - 1; | |
ea94c18b | 243 | Int_t currentChamber; |
96ebe67e | 244 | Double_t addChi2TrackAtCluster; |
245 | AliMUONTrackParam* trackParamAtCluster = (AliMUONTrackParam*) trackCandidate.GetTrackParamAtCluster()->Before(startingTrackParam); | |
246 | while (trackParamAtCluster) { | |
ea94c18b | 247 | |
248 | // reset track parameters and their covariances | |
96ebe67e | 249 | trackParamAtCluster->SetParameters(startingTrackParam->GetParameters()); |
250 | trackParamAtCluster->SetZ(startingTrackParam->GetZ()); | |
251 | trackParamAtCluster->SetCovariances(startingTrackParam->GetCovariances()); | |
ea94c18b | 252 | |
253 | // add MCS effect | |
96ebe67e | 254 | AliMUONTrackExtrap::AddMCSEffect(trackParamAtCluster,AliMUONConstants::ChamberThicknessInX0(),1.); |
ea94c18b | 255 | |
256 | // reset propagator for smoother | |
96ebe67e | 257 | if (AliMUONReconstructor::GetRecoParam()->UseSmoother()) trackParamAtCluster->ResetPropagator(); |
ea94c18b | 258 | |
259 | // add MCS in missing chambers if any (at most 2 chambers can be missing according to tracking criteria) | |
96ebe67e | 260 | currentChamber = trackParamAtCluster->GetClusterPtr()->GetChamberId(); |
ea94c18b | 261 | while (currentChamber < expectedChamber) { |
262 | // extrapolation to the missing chamber (update the propagator) | |
96ebe67e | 263 | AliMUONTrackExtrap::ExtrapToZCov(trackParamAtCluster, AliMUONConstants::DefaultChamberZ(expectedChamber), |
3304fa09 | 264 | AliMUONReconstructor::GetRecoParam()->UseSmoother()); |
ea94c18b | 265 | // add MCS effect |
96ebe67e | 266 | AliMUONTrackExtrap::AddMCSEffect(trackParamAtCluster,AliMUONConstants::ChamberThicknessInX0(),1.); |
ea94c18b | 267 | expectedChamber--; |
268 | } | |
269 | ||
96ebe67e | 270 | // extrapolation to the plane of the cluster attached to the current trackParamAtCluster (update the propagator) |
271 | AliMUONTrackExtrap::ExtrapToZCov(trackParamAtCluster, trackParamAtCluster->GetClusterPtr()->GetZ(), | |
3304fa09 | 272 | AliMUONReconstructor::GetRecoParam()->UseSmoother()); |
ea94c18b | 273 | |
3304fa09 | 274 | if (AliMUONReconstructor::GetRecoParam()->UseSmoother()) { |
ea94c18b | 275 | // save extrapolated parameters for smoother |
96ebe67e | 276 | trackParamAtCluster->SetExtrapParameters(trackParamAtCluster->GetParameters()); |
ea94c18b | 277 | |
278 | // save extrapolated covariance matrix for smoother | |
96ebe67e | 279 | trackParamAtCluster->SetExtrapCovariances(trackParamAtCluster->GetCovariances()); |
ea94c18b | 280 | } |
281 | ||
96ebe67e | 282 | // Compute new track parameters including "clusterCh2" using kalman filter |
283 | addChi2TrackAtCluster = RunKalmanFilter(*trackParamAtCluster); | |
ea94c18b | 284 | |
285 | // Update the track chi2 | |
96ebe67e | 286 | trackCandidate.SetGlobalChi2(trackCandidate.GetGlobalChi2() + addChi2TrackAtCluster); |
287 | trackParamAtCluster->SetTrackChi2(trackCandidate.GetGlobalChi2()); | |
ea94c18b | 288 | |
96ebe67e | 289 | // prepare next step |
290 | expectedChamber = currentChamber - 1; | |
291 | startingTrackParam = trackParamAtCluster; | |
292 | trackParamAtCluster = (AliMUONTrackParam*) (trackCandidate.GetTrackParamAtCluster()->Before(startingTrackParam)); | |
ea94c18b | 293 | } |
294 | ||
295 | // Printout for debuging | |
296 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 297 | cout << "RetracePartialTrack: track chi2 after re-tracking: " << trackCandidate.GetGlobalChi2() << endl; |
ea94c18b | 298 | } |
299 | ||
300 | } | |
8cc77df0 | 301 | |
ea94c18b | 302 | //__________________________________________________________________________ |
1fef78c8 | 303 | void AliMUONTrackReconstructorK::FollowTracks(AliMUONVClusterStore& clusterStore) |
ea94c18b | 304 | { |
305 | /// Follow tracks in stations(1..) 3, 2 and 1 | |
306 | AliDebug(1,"Enter FollowTracks"); | |
307 | ||
308 | AliMUONTrack *track; | |
309 | Int_t currentNRecTracks; | |
96ebe67e | 310 | Bool_t clusterFound; |
ea94c18b | 311 | |
312 | for (Int_t station = 2; station >= 0; station--) { | |
313 | ||
314 | // Save the actual number of reconstructed track in case of | |
315 | // tracks are added or suppressed during the tracking procedure | |
316 | // !! Do not compress fRecTracksPtr until the end of the loop over tracks !! | |
317 | currentNRecTracks = fNRecTracks; | |
318 | ||
319 | for (Int_t iRecTrack = 0; iRecTrack <currentNRecTracks; iRecTrack++) { | |
320 | AliDebug(1,Form("FollowTracks: track candidate(1..) %d", iRecTrack+1)); | |
321 | ||
322 | track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iRecTrack); | |
323 | ||
324 | // Printout for debuging | |
325 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
96ebe67e | 326 | cout<<endl<<"Track parameter covariances at first cluster:"<<endl; |
327 | ((AliMUONTrackParam*) (track->GetTrackParamAtCluster()->First()))->GetCovariances().Print(); | |
ea94c18b | 328 | } |
329 | ||
96ebe67e | 330 | // Look for compatible cluster(s) in station(0..) "station" |
331 | clusterFound = FollowTrackInStation(*track, clusterStore, station); | |
ea94c18b | 332 | |
333 | // Try to recover track if required | |
96ebe67e | 334 | if (!clusterFound && AliMUONReconstructor::GetRecoParam()->RecoverTracks()) |
335 | clusterFound = RecoverTrack(*track, clusterStore, station); | |
ea94c18b | 336 | |
96ebe67e | 337 | // remove track if no cluster found |
338 | if (!clusterFound) { | |
ea94c18b | 339 | fRecTracksPtr->Remove(track); |
340 | fNRecTracks--; | |
8cc77df0 | 341 | } |
ea94c18b | 342 | |
8cc77df0 | 343 | } |
ea94c18b | 344 | |
345 | fRecTracksPtr->Compress(); // this is essential before checking tracks | |
346 | ||
ea94c18b | 347 | // Keep only the best tracks if required |
3304fa09 | 348 | if (!AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) RemoveDoubleTracks(); |
ea94c18b | 349 | |
350 | } | |
351 | ||
352 | } | |
b0e4c598 | 353 | |
ea94c18b | 354 | //__________________________________________________________________________ |
1fef78c8 | 355 | Bool_t AliMUONTrackReconstructorK::FollowTrackInStation(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextStation) |
ea94c18b | 356 | { |
96ebe67e | 357 | /// Follow trackCandidate in station(0..) nextStation and search for compatible cluster(s) |
ea94c18b | 358 | /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks: |
359 | /// kTRUE: duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of | |
360 | /// fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure. | |
361 | /// Remove the obsolete "trackCandidate" at the end. | |
96ebe67e | 362 | /// kFALSE: add only the best cluster(s) to the "trackCandidate". Try to add a couple of clusters in priority. |
363 | /// return kTRUE if new cluster(s) have been found (otherwise return kFALSE) | |
ea94c18b | 364 | AliDebug(1,Form("Enter FollowTrackInStation(1..) %d", nextStation+1)); |
365 | ||
366 | // Order the chamber according to the propagation direction (tracking starts with chamber 2): | |
367 | // - nextStation == station(1...) 5 => forward propagation | |
368 | // - nextStation < station(1...) 5 => backward propagation | |
369 | Int_t ch1, ch2; | |
370 | if (nextStation==4) { | |
371 | ch1 = 2*nextStation+1; | |
372 | ch2 = 2*nextStation; | |
373 | } else { | |
374 | ch1 = 2*nextStation; | |
375 | ch2 = 2*nextStation+1; | |
376 | } | |
377 | ||
96ebe67e | 378 | Double_t chi2OfCluster; |
379 | Double_t maxChi2OfCluster = 2. * AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking() * | |
380 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2 | |
381 | Double_t addChi2TrackAtCluster1; | |
382 | Double_t addChi2TrackAtCluster2; | |
383 | Double_t bestAddChi2TrackAtCluster1 = 1.e10; | |
384 | Double_t bestAddChi2TrackAtCluster2 = 1.e10; | |
385 | Bool_t foundOneCluster = kFALSE; | |
386 | Bool_t foundTwoClusters = kFALSE; | |
ea94c18b | 387 | AliMUONTrack *newTrack = 0x0; |
96ebe67e | 388 | AliMUONVCluster *clusterCh1, *clusterCh2; |
ea94c18b | 389 | AliMUONTrackParam extrapTrackParam; |
7332f213 | 390 | AliMUONTrackParam extrapTrackParamAtCh; |
96ebe67e | 391 | AliMUONTrackParam extrapTrackParamAtCluster1; |
392 | AliMUONTrackParam extrapTrackParamAtCluster2; | |
393 | AliMUONTrackParam bestTrackParamAtCluster1; | |
394 | AliMUONTrackParam bestTrackParamAtCluster2; | |
395 | ||
396 | Int_t nClusters = clusterStore.GetSize(); | |
397 | Bool_t *clusterCh1Used = new Bool_t[nClusters]; | |
398 | for (Int_t i = 0; i < nClusters; i++) clusterCh1Used[i] = kFALSE; | |
399 | Int_t iCluster1; | |
400 | ||
7332f213 | 401 | // Get track parameters according to the propagation direction |
402 | ||
403 | if (nextStation==4) extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->Last(); | |
404 | else extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First(); | |
ea94c18b | 405 | |
406 | // Add MCS effect | |
019df241 | 407 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.); |
ea94c18b | 408 | |
409 | // reset propagator for smoother | |
3304fa09 | 410 | if (AliMUONReconstructor::GetRecoParam()->UseSmoother()) extrapTrackParamAtCh.ResetPropagator(); |
ea94c18b | 411 | |
412 | // Add MCS in the missing chamber if any (only 1 chamber can be missing according to tracking criteria) | |
96ebe67e | 413 | if (ch1 < ch2 && extrapTrackParamAtCh.GetClusterPtr()->GetChamberId() > ch2 + 1) { |
ea94c18b | 414 | // extrapolation to the missing chamber |
3304fa09 | 415 | AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch2 + 1), |
416 | AliMUONReconstructor::GetRecoParam()->UseSmoother()); | |
ea94c18b | 417 | // add MCS effect |
019df241 | 418 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.); |
ea94c18b | 419 | } |
420 | ||
421 | //Extrapolate trackCandidate to chamber "ch2" | |
3304fa09 | 422 | AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch2), |
423 | AliMUONReconstructor::GetRecoParam()->UseSmoother()); | |
ea94c18b | 424 | |
425 | // Printout for debuging | |
426 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) { | |
96ebe67e | 427 | cout<<endl<<"Track parameter covariances at first cluster extrapolated to z = "<<AliMUONConstants::DefaultChamberZ(ch2)<<":"<<endl; |
019df241 | 428 | extrapTrackParamAtCh.GetCovariances().Print(); |
ea94c18b | 429 | } |
430 | ||
431 | // Printout for debuging | |
432 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 433 | cout << "FollowTrackInStation: look for clusters in chamber(1..): " << ch2+1 << endl; |
ea94c18b | 434 | } |
435 | ||
1fef78c8 | 436 | // Ask the clustering to reconstruct new clusters around the track position in the current station |
437 | // except for station 4 and 5 that are already entirely clusterized | |
438 | if (AliMUONReconstructor::GetRecoParam()->CombineClusterTrackReco()) { | |
439 | if (nextStation < 3) AskForNewClustersInStation(extrapTrackParamAtCh, clusterStore, nextStation); | |
440 | } | |
441 | ||
96ebe67e | 442 | // Create iterators to loop over clusters in both chambers |
443 | TIter nextInCh1(clusterStore.CreateChamberIterator(ch1,ch1)); | |
444 | TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2)); | |
445 | ||
446 | // look for candidates in chamber 2 | |
447 | while ( ( clusterCh2 = static_cast<AliMUONVCluster*>(nextInCh2()) ) ) { | |
ea94c18b | 448 | |
96ebe67e | 449 | // try to add the current cluster fast |
450 | if (!TryOneClusterFast(extrapTrackParamAtCh, clusterCh2)) continue; | |
019df241 | 451 | |
96ebe67e | 452 | // try to add the current cluster accuratly |
453 | chi2OfCluster = TryOneCluster(extrapTrackParamAtCh, clusterCh2, extrapTrackParamAtCluster2, | |
454 | AliMUONReconstructor::GetRecoParam()->UseSmoother()); | |
ea94c18b | 455 | |
96ebe67e | 456 | // if good chi2 then try to attach a cluster in the other chamber too |
457 | if (chi2OfCluster < maxChi2OfCluster) { | |
458 | Bool_t foundSecondCluster = kFALSE; | |
ea94c18b | 459 | |
460 | // Printout for debuging | |
461 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 462 | cout << "FollowTrackInStation: found one cluster in chamber(1..): " << ch2+1 |
463 | << " (Chi2 = " << chi2OfCluster << ")" << endl; | |
464 | cout << " look for second clusters in chamber(1..): " << ch1+1 << " ..." << endl; | |
8cc77df0 | 465 | } |
ea94c18b | 466 | |
3304fa09 | 467 | if (AliMUONReconstructor::GetRecoParam()->UseSmoother()) { |
ea94c18b | 468 | // save extrapolated parameters for smoother |
96ebe67e | 469 | extrapTrackParamAtCluster2.SetExtrapParameters(extrapTrackParamAtCluster2.GetParameters()); |
ea94c18b | 470 | |
471 | // save extrapolated covariance matrix for smoother | |
96ebe67e | 472 | extrapTrackParamAtCluster2.SetExtrapCovariances(extrapTrackParamAtCluster2.GetCovariances()); |
ea94c18b | 473 | } |
474 | ||
96ebe67e | 475 | // Compute new track parameters including "clusterCh2" using kalman filter |
476 | addChi2TrackAtCluster2 = RunKalmanFilter(extrapTrackParamAtCluster2); | |
ea94c18b | 477 | |
478 | // copy new track parameters for next step | |
96ebe67e | 479 | extrapTrackParam = extrapTrackParamAtCluster2; |
ea94c18b | 480 | |
481 | // add MCS effect | |
482 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParam,AliMUONConstants::ChamberThicknessInX0(),1.); | |
483 | ||
484 | // reset propagator for smoother | |
3304fa09 | 485 | if (AliMUONReconstructor::GetRecoParam()->UseSmoother()) extrapTrackParam.ResetPropagator(); |
ea94c18b | 486 | |
019df241 | 487 | //Extrapolate track parameters to chamber "ch1" |
3304fa09 | 488 | AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParam, AliMUONConstants::DefaultChamberZ(ch1), |
489 | AliMUONReconstructor::GetRecoParam()->UseSmoother()); | |
019df241 | 490 | |
96ebe67e | 491 | // reset cluster iterator of chamber 1 |
492 | nextInCh1.Reset(); | |
493 | iCluster1 = -1; | |
494 | ||
495 | // look for second candidates in chamber 1 | |
496 | while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) { | |
497 | iCluster1++; | |
ea94c18b | 498 | |
96ebe67e | 499 | // try to add the current cluster fast |
500 | if (!TryOneClusterFast(extrapTrackParam, clusterCh1)) continue; | |
019df241 | 501 | |
96ebe67e | 502 | // try to add the current cluster accuratly |
503 | chi2OfCluster = TryOneCluster(extrapTrackParam, clusterCh1, extrapTrackParamAtCluster1, | |
3304fa09 | 504 | AliMUONReconstructor::GetRecoParam()->UseSmoother()); |
019df241 | 505 | |
96ebe67e | 506 | // if good chi2 then consider to add the 2 clusters to the "trackCandidate" |
507 | if (chi2OfCluster < maxChi2OfCluster) { | |
508 | foundSecondCluster = kTRUE; | |
509 | foundTwoClusters = kTRUE; | |
ea94c18b | 510 | |
511 | // Printout for debuging | |
512 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 513 | cout << "FollowTrackInStation: found one cluster in chamber(1..): " << ch1+1 |
514 | << " (Chi2 = " << chi2OfCluster << ")" << endl; | |
ea94c18b | 515 | } |
019df241 | 516 | |
3304fa09 | 517 | if (AliMUONReconstructor::GetRecoParam()->UseSmoother()) { |
ea94c18b | 518 | // save extrapolated parameters for smoother |
96ebe67e | 519 | extrapTrackParamAtCluster1.SetExtrapParameters(extrapTrackParamAtCluster1.GetParameters()); |
ea94c18b | 520 | |
521 | // save extrapolated covariance matrix for smoother | |
96ebe67e | 522 | extrapTrackParamAtCluster1.SetExtrapCovariances(extrapTrackParamAtCluster1.GetCovariances()); |
ea94c18b | 523 | } |
524 | ||
96ebe67e | 525 | // Compute new track parameters including "clusterCh1" using kalman filter |
526 | addChi2TrackAtCluster1 = RunKalmanFilter(extrapTrackParamAtCluster1); | |
ea94c18b | 527 | |
3304fa09 | 528 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 529 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new clusters |
ea94c18b | 530 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 531 | UpdateTrack(*newTrack,extrapTrackParamAtCluster1,extrapTrackParamAtCluster2,addChi2TrackAtCluster1,addChi2TrackAtCluster2); |
ea94c18b | 532 | fNRecTracks++; |
533 | ||
534 | // if we are arrived on station(1..) 5, recompute track parameters and covariances starting from this station | |
535 | // (going in the right direction) | |
536 | if (nextStation == 4) RetraceTrack(*newTrack,kTRUE); | |
537 | ||
96ebe67e | 538 | // Tag clusterCh1 as used |
539 | clusterCh1Used[iCluster1] = kTRUE; | |
ea94c18b | 540 | |
541 | // Printout for debuging | |
542 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 543 | cout << "FollowTrackInStation: added two clusters in station(1..): " << nextStation+1 << endl; |
ea94c18b | 544 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
545 | } | |
546 | ||
96ebe67e | 547 | } else if (addChi2TrackAtCluster1+addChi2TrackAtCluster2 < bestAddChi2TrackAtCluster1+bestAddChi2TrackAtCluster2) { |
548 | // keep track of the best couple of clusters | |
549 | bestAddChi2TrackAtCluster1 = addChi2TrackAtCluster1; | |
550 | bestAddChi2TrackAtCluster2 = addChi2TrackAtCluster2; | |
551 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster1; | |
552 | bestTrackParamAtCluster2 = extrapTrackParamAtCluster2; | |
ea94c18b | 553 | } |
554 | ||
b0e4c598 | 555 | } |
ea94c18b | 556 | |
8cc77df0 | 557 | } |
ea94c18b | 558 | |
96ebe67e | 559 | // if no clusterCh1 found then consider to add clusterCh2 only |
560 | if (!foundSecondCluster) { | |
561 | foundOneCluster = kTRUE; | |
ea94c18b | 562 | |
3304fa09 | 563 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 564 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster |
ea94c18b | 565 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 566 | UpdateTrack(*newTrack,extrapTrackParamAtCluster2,addChi2TrackAtCluster2); |
ea94c18b | 567 | fNRecTracks++; |
568 | ||
569 | // if we are arrived on station(1..) 5, recompute track parameters and covariances starting from this station | |
570 | // (going in the right direction) | |
571 | if (nextStation == 4) RetraceTrack(*newTrack,kTRUE); | |
572 | ||
573 | // Printout for debuging | |
574 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 575 | cout << "FollowTrackInStation: added one cluster in chamber(1..): " << ch2+1 << endl; |
ea94c18b | 576 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
577 | } | |
578 | ||
96ebe67e | 579 | } else if (!foundTwoClusters && addChi2TrackAtCluster2 < bestAddChi2TrackAtCluster1) { |
580 | // keep track of the best single cluster except if a couple of clusters has already been found | |
581 | bestAddChi2TrackAtCluster1 = addChi2TrackAtCluster2; | |
582 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster2; | |
ea94c18b | 583 | } |
584 | ||
585 | } | |
586 | ||
8cc77df0 | 587 | } |
ea94c18b | 588 | |
589 | } | |
590 | ||
591 | // look for candidates in chamber 1 not already attached to a track | |
96ebe67e | 592 | // if we want to keep all possible tracks or if no good couple of clusters has been found |
593 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks() || !foundTwoClusters) { | |
ea94c18b | 594 | |
595 | // Printout for debuging | |
596 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 597 | cout << "FollowTrackInStation: look for single clusters in chamber(1..): " << ch1+1 << endl; |
8cc77df0 | 598 | } |
ea94c18b | 599 | |
600 | // add MCS effect for next step | |
019df241 | 601 | AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.); |
602 | ||
603 | //Extrapolate trackCandidate to chamber "ch1" | |
3304fa09 | 604 | AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch1), |
605 | AliMUONReconstructor::GetRecoParam()->UseSmoother()); | |
019df241 | 606 | |
96ebe67e | 607 | // reset cluster iterator of chamber 1 |
608 | nextInCh1.Reset(); | |
609 | iCluster1 = -1; | |
610 | ||
611 | // look for second candidates in chamber 1 | |
612 | while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) { | |
613 | iCluster1++; | |
ea94c18b | 614 | |
96ebe67e | 615 | if (clusterCh1Used[iCluster1]) continue; // Skip clusters already used |
ea94c18b | 616 | |
96ebe67e | 617 | // try to add the current cluster fast |
618 | if (!TryOneClusterFast(extrapTrackParamAtCh, clusterCh1)) continue; | |
019df241 | 619 | |
96ebe67e | 620 | // try to add the current cluster accuratly |
621 | chi2OfCluster = TryOneCluster(extrapTrackParamAtCh, clusterCh1, extrapTrackParamAtCluster1, | |
622 | AliMUONReconstructor::GetRecoParam()->UseSmoother()); | |
019df241 | 623 | |
96ebe67e | 624 | // if good chi2 then consider to add clusterCh1 |
625 | // We do not try to attach a cluster in the other chamber too since it has already been done above | |
626 | if (chi2OfCluster < maxChi2OfCluster) { | |
627 | foundOneCluster = kTRUE; | |
ea94c18b | 628 | |
629 | // Printout for debuging | |
630 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 631 | cout << "FollowTrackInStation: found one cluster in chamber(1..): " << ch1+1 |
632 | << " (Chi2 = " << chi2OfCluster << ")" << endl; | |
ea94c18b | 633 | } |
019df241 | 634 | |
3304fa09 | 635 | if (AliMUONReconstructor::GetRecoParam()->UseSmoother()) { |
ea94c18b | 636 | // save extrapolated parameters for smoother |
96ebe67e | 637 | extrapTrackParamAtCluster1.SetExtrapParameters(extrapTrackParamAtCluster1.GetParameters()); |
ea94c18b | 638 | |
639 | // save extrapolated covariance matrix for smoother | |
96ebe67e | 640 | extrapTrackParamAtCluster1.SetExtrapCovariances(extrapTrackParamAtCluster1.GetCovariances()); |
ea94c18b | 641 | } |
642 | ||
96ebe67e | 643 | // Compute new track parameters including "clusterCh1" using kalman filter |
644 | addChi2TrackAtCluster1 = RunKalmanFilter(extrapTrackParamAtCluster1); | |
ea94c18b | 645 | |
3304fa09 | 646 | if (AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 647 | // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster |
ea94c18b | 648 | newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate); |
96ebe67e | 649 | UpdateTrack(*newTrack,extrapTrackParamAtCluster1,addChi2TrackAtCluster1); |
ea94c18b | 650 | fNRecTracks++; |
651 | ||
652 | // if we are arrived on station(1..) 5, recompute track parameters and covariances starting from this station | |
653 | // (going in the right direction) | |
654 | if (nextStation == 4) RetraceTrack(*newTrack,kTRUE); | |
655 | ||
656 | // Printout for debuging | |
657 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 658 | cout << "FollowTrackInStation: added one cluster in chamber(1..): " << ch1+1 << endl; |
ea94c18b | 659 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
660 | } | |
661 | ||
96ebe67e | 662 | } else if (addChi2TrackAtCluster1 < bestAddChi2TrackAtCluster1) { |
663 | // keep track of the best single cluster except if a couple of clusters has already been found | |
664 | bestAddChi2TrackAtCluster1 = addChi2TrackAtCluster1; | |
665 | bestTrackParamAtCluster1 = extrapTrackParamAtCluster1; | |
ea94c18b | 666 | } |
667 | ||
668 | } | |
669 | ||
8cc77df0 | 670 | } |
ea94c18b | 671 | |
672 | } | |
673 | ||
674 | // fill out the best track if required else clean up the fRecTracksPtr array | |
3304fa09 | 675 | if (!AliMUONReconstructor::GetRecoParam()->TrackAllTracks()) { |
96ebe67e | 676 | if (foundTwoClusters) { |
677 | UpdateTrack(trackCandidate,bestTrackParamAtCluster1,bestTrackParamAtCluster2,bestAddChi2TrackAtCluster1,bestAddChi2TrackAtCluster2); | |
ea94c18b | 678 | |
679 | // if we are arrived on station(1..) 5, recompute track parameters and covariances starting from this station | |
680 | // (going in the right direction) | |
681 | if (nextStation == 4) RetraceTrack(trackCandidate,kTRUE); | |
8cc77df0 | 682 | |
ea94c18b | 683 | // Printout for debuging |
684 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 685 | cout << "FollowTrackInStation: added the two best clusters in station(1..): " << nextStation+1 << endl; |
ea94c18b | 686 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
687 | } | |
688 | ||
96ebe67e | 689 | } else if (foundOneCluster) { |
690 | UpdateTrack(trackCandidate,bestTrackParamAtCluster1,bestAddChi2TrackAtCluster1); | |
ea94c18b | 691 | |
692 | // if we are arrived on station(1..) 5, recompute track parameters and covariances starting from this station | |
693 | // (going in the right direction) | |
694 | if (nextStation == 4) RetraceTrack(trackCandidate,kTRUE); | |
695 | ||
696 | // Printout for debuging | |
697 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
96ebe67e | 698 | cout << "FollowTrackInStation: added the best cluster in chamber(1..): " << bestTrackParamAtCluster1.GetClusterPtr()->GetChamberId()+1 << endl; |
ea94c18b | 699 | if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump(); |
700 | } | |
701 | ||
17773e2e | 702 | } else { |
96ebe67e | 703 | delete [] clusterCh1Used; |
17773e2e | 704 | return kFALSE; |
705 | } | |
96ebe67e | 706 | } else if (foundOneCluster || foundTwoClusters) { |
ea94c18b | 707 | |
708 | // remove obsolete track | |
709 | fRecTracksPtr->Remove(&trackCandidate); | |
710 | fNRecTracks--; | |
711 | ||
17773e2e | 712 | } else { |
96ebe67e | 713 | delete [] clusterCh1Used; |
17773e2e | 714 | return kFALSE; |
715 | } | |
96ebe67e | 716 | delete [] clusterCh1Used; |
ea94c18b | 717 | return kTRUE; |
718 | ||
719 | } | |
8cc77df0 | 720 | |
ea94c18b | 721 | //__________________________________________________________________________ |
96ebe67e | 722 | Double_t AliMUONTrackReconstructorK::RunKalmanFilter(AliMUONTrackParam &trackParamAtCluster) |
ea94c18b | 723 | { |
96ebe67e | 724 | /// Compute new track parameters and their covariances including new cluster using kalman filter |
ea94c18b | 725 | /// return the additional track chi2 |
726 | AliDebug(1,"Enter RunKalmanFilter"); | |
727 | ||
728 | // Get actual track parameters (p) | |
96ebe67e | 729 | TMatrixD param(trackParamAtCluster.GetParameters()); |
ea94c18b | 730 | |
96ebe67e | 731 | // Get new cluster parameters (m) |
732 | AliMUONVCluster *cluster = trackParamAtCluster.GetClusterPtr(); | |
733 | TMatrixD clusterParam(5,1); | |
734 | clusterParam.Zero(); | |
735 | clusterParam(0,0) = cluster->GetX(); | |
736 | clusterParam(2,0) = cluster->GetY(); | |
ea94c18b | 737 | |
738 | // Compute the actual parameter weight (W) | |
96ebe67e | 739 | TMatrixD paramWeight(trackParamAtCluster.GetCovariances()); |
ea94c18b | 740 | if (paramWeight.Determinant() != 0) { |
741 | paramWeight.Invert(); | |
742 | } else { | |
743 | AliWarning(" Determinant = 0"); | |
744 | return 1.e10; | |
8cc77df0 | 745 | } |
ea94c18b | 746 | |
96ebe67e | 747 | // Compute the new cluster weight (U) |
748 | TMatrixD clusterWeight(5,5); | |
749 | clusterWeight.Zero(); | |
750 | clusterWeight(0,0) = 1. / cluster->GetErrX2(); | |
751 | clusterWeight(2,2) = 1. / cluster->GetErrY2(); | |
8cc77df0 | 752 | |
ea94c18b | 753 | // Compute the new parameters covariance matrix ( (W+U)^-1 ) |
96ebe67e | 754 | TMatrixD newParamCov(paramWeight,TMatrixD::kPlus,clusterWeight); |
ea94c18b | 755 | if (newParamCov.Determinant() != 0) { |
756 | newParamCov.Invert(); | |
757 | } else { | |
758 | AliWarning(" Determinant = 0"); | |
759 | return 1.e10; | |
760 | } | |
761 | ||
762 | // Save the new parameters covariance matrix | |
96ebe67e | 763 | trackParamAtCluster.SetCovariances(newParamCov); |
ea94c18b | 764 | |
765 | // Compute the new parameters (p' = ((W+U)^-1)U(m-p) + p) | |
96ebe67e | 766 | TMatrixD tmp(clusterParam,TMatrixD::kMinus,param); |
767 | TMatrixD tmp2(clusterWeight,TMatrixD::kMult,tmp); // U(m-p) | |
ea94c18b | 768 | TMatrixD newParam(newParamCov,TMatrixD::kMult,tmp2); // ((W+U)^-1)U(m-p) |
769 | newParam += param; // ((W+U)^-1)U(m-p) + p | |
770 | ||
771 | // Save the new parameters | |
96ebe67e | 772 | trackParamAtCluster.SetParameters(newParam); |
ea94c18b | 773 | |
774 | // Compute the additional chi2 (= ((p'-p)^-1)W(p'-p) + ((p'-m)^-1)U(p'-m)) | |
775 | tmp = newParam; // p' | |
776 | tmp -= param; // (p'-p) | |
777 | TMatrixD tmp3(paramWeight,TMatrixD::kMult,tmp); // W(p'-p) | |
778 | TMatrixD addChi2Track(tmp,TMatrixD::kTransposeMult,tmp3); // ((p'-p)^-1)W(p'-p) | |
779 | tmp = newParam; // p' | |
96ebe67e | 780 | tmp -= clusterParam; // (p'-m) |
781 | TMatrixD tmp4(clusterWeight,TMatrixD::kMult,tmp); // U(p'-m) | |
ea94c18b | 782 | addChi2Track += TMatrixD(tmp,TMatrixD::kTransposeMult,tmp4); // ((p'-p)^-1)W(p'-p) + ((p'-m)^-1)U(p'-m) |
783 | ||
784 | return addChi2Track(0,0); | |
785 | ||
8cc77df0 | 786 | } |
787 | ||
ea94c18b | 788 | //__________________________________________________________________________ |
96ebe67e | 789 | void AliMUONTrackReconstructorK::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtCluster, Double_t addChi2) |
8cc77df0 | 790 | { |
96ebe67e | 791 | /// Add 1 cluster to the track candidate |
ea94c18b | 792 | /// Update chi2 of the track |
793 | ||
96ebe67e | 794 | // Flag cluster as being not removable |
795 | trackParamAtCluster.SetRemovable(kFALSE); | |
796 | trackParamAtCluster.SetLocalChi2(0.); // --> Local chi2 not used | |
5f4ceff2 | 797 | |
96ebe67e | 798 | // Update the track chi2 into trackParamAtCluster |
799 | trackParamAtCluster.SetTrackChi2(track.GetGlobalChi2() + addChi2); | |
ea94c18b | 800 | |
801 | // Update the chi2 of the new track | |
96ebe67e | 802 | track.SetGlobalChi2(trackParamAtCluster.GetTrackChi2()); |
ea94c18b | 803 | |
96ebe67e | 804 | // Update array of TrackParamAtCluster |
805 | track.AddTrackParamAtCluster(trackParamAtCluster,*(trackParamAtCluster.GetClusterPtr())); | |
ea94c18b | 806 | |
807 | } | |
8cc77df0 | 808 | |
ea94c18b | 809 | //__________________________________________________________________________ |
96ebe67e | 810 | void AliMUONTrackReconstructorK::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtCluster1, AliMUONTrackParam &trackParamAtCluster2, |
811 | Double_t addChi2AtCluster1, Double_t addChi2AtCluster2) | |
ea94c18b | 812 | { |
96ebe67e | 813 | /// Add 2 clusters to the track candidate (order is important) |
ea94c18b | 814 | /// Update track and local chi2 |
815 | ||
96ebe67e | 816 | // Update local chi2 at first cluster |
817 | AliMUONVCluster* cluster1 = trackParamAtCluster1.GetClusterPtr(); | |
818 | Double_t deltaX = trackParamAtCluster1.GetNonBendingCoor() - cluster1->GetX(); | |
819 | Double_t deltaY = trackParamAtCluster1.GetBendingCoor() - cluster1->GetY(); | |
820 | Double_t localChi2AtCluster1 = deltaX*deltaX / cluster1->GetErrX2() + | |
821 | deltaY*deltaY / cluster1->GetErrY2(); | |
822 | trackParamAtCluster1.SetLocalChi2(localChi2AtCluster1); | |
ea94c18b | 823 | |
96ebe67e | 824 | // Flag first cluster as being removable |
825 | trackParamAtCluster1.SetRemovable(kTRUE); | |
ea94c18b | 826 | |
96ebe67e | 827 | // Update local chi2 at second cluster |
828 | AliMUONVCluster* cluster2 = trackParamAtCluster2.GetClusterPtr(); | |
829 | AliMUONTrackParam extrapTrackParamAtCluster2(trackParamAtCluster1); | |
830 | AliMUONTrackExtrap::ExtrapToZ(&extrapTrackParamAtCluster2, trackParamAtCluster2.GetZ()); | |
831 | deltaX = extrapTrackParamAtCluster2.GetNonBendingCoor() - cluster2->GetX(); | |
832 | deltaY = extrapTrackParamAtCluster2.GetBendingCoor() - cluster2->GetY(); | |
833 | Double_t localChi2AtCluster2 = deltaX*deltaX / cluster2->GetErrX2() + | |
834 | deltaY*deltaY / cluster2->GetErrY2(); | |
835 | trackParamAtCluster2.SetLocalChi2(localChi2AtCluster2); | |
ea94c18b | 836 | |
96ebe67e | 837 | // Flag second cluster as being removable |
838 | trackParamAtCluster2.SetRemovable(kTRUE); | |
ea94c18b | 839 | |
96ebe67e | 840 | // Update the track chi2 into trackParamAtCluster2 |
841 | trackParamAtCluster2.SetTrackChi2(track.GetGlobalChi2() + addChi2AtCluster2); | |
ea94c18b | 842 | |
96ebe67e | 843 | // Update the track chi2 into trackParamAtCluster1 |
844 | trackParamAtCluster1.SetTrackChi2(trackParamAtCluster2.GetTrackChi2() + addChi2AtCluster1); | |
ea94c18b | 845 | |
846 | // Update the chi2 of the new track | |
96ebe67e | 847 | track.SetGlobalChi2(trackParamAtCluster1.GetTrackChi2()); |
ea94c18b | 848 | |
96ebe67e | 849 | // Update array of trackParamAtCluster |
850 | track.AddTrackParamAtCluster(trackParamAtCluster1,*cluster1); | |
851 | track.AddTrackParamAtCluster(trackParamAtCluster2,*cluster2); | |
ea94c18b | 852 | |
853 | } | |
8cc77df0 | 854 | |
ea94c18b | 855 | //__________________________________________________________________________ |
1fef78c8 | 856 | Bool_t AliMUONTrackReconstructorK::RecoverTrack(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextStation) |
ea94c18b | 857 | { |
858 | /// Try to recover the track candidate in the next station | |
96ebe67e | 859 | /// by removing the worst of the two clusters attached in the current station |
ea94c18b | 860 | /// Return kTRUE if recovering succeeds |
861 | AliDebug(1,"Enter RecoverTrack"); | |
862 | ||
96ebe67e | 863 | // Do not try to recover track until we have attached cluster(s) on station(1..) 3 |
ea94c18b | 864 | if (nextStation > 1) return kFALSE; |
865 | ||
96ebe67e | 866 | Int_t worstClusterNumber = -1; |
867 | Double_t localChi2, worstLocalChi2 = 0.; | |
ea94c18b | 868 | |
96ebe67e | 869 | // Look for the cluster to remove |
870 | for (Int_t clusterNumber = 0; clusterNumber < 2; clusterNumber++) { | |
871 | AliMUONTrackParam *trackParamAtCluster = (AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(clusterNumber); | |
ea94c18b | 872 | |
96ebe67e | 873 | // check if current cluster is removable |
874 | if (!trackParamAtCluster->IsRemovable()) return kFALSE; | |
ea94c18b | 875 | |
96ebe67e | 876 | // Pick up cluster with the worst chi2 |
877 | localChi2 = trackParamAtCluster->GetLocalChi2(); | |
878 | if (localChi2 > worstLocalChi2) { | |
879 | worstLocalChi2 = localChi2; | |
880 | worstClusterNumber = clusterNumber; | |
8cc77df0 | 881 | } |
ea94c18b | 882 | } |
883 | ||
96ebe67e | 884 | // Reset best cluster as being NOT removable |
885 | ((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt((worstClusterNumber+1)%2))->SetRemovable(kFALSE); | |
ea94c18b | 886 | |
96ebe67e | 887 | // Remove the worst cluster |
888 | trackCandidate.RemoveTrackParamAtCluster((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(worstClusterNumber)); | |
ea94c18b | 889 | |
96ebe67e | 890 | // Re-calculate track parameters at the (new) first cluster |
891 | RetracePartialTrack(trackCandidate,(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(1)); | |
ea94c18b | 892 | |
96ebe67e | 893 | // Look for new cluster(s) in next station |
894 | return FollowTrackInStation(trackCandidate, clusterStore, nextStation); | |
ea94c18b | 895 | |
8cc77df0 | 896 | } |
897 | ||
898 | //__________________________________________________________________________ | |
ea94c18b | 899 | Bool_t AliMUONTrackReconstructorK::RunSmoother(AliMUONTrack &track) |
8cc77df0 | 900 | { |
ea94c18b | 901 | /// Compute new track parameters and their covariances using smoother |
3304fa09 | 902 | AliDebug(1,"Enter UseSmoother"); |
ea94c18b | 903 | |
96ebe67e | 904 | AliMUONTrackParam *previousTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->First(); |
ea94c18b | 905 | |
96ebe67e | 906 | // Smoothed parameters and covariances at first cluster = filtered parameters and covariances |
ea94c18b | 907 | previousTrackParam->SetSmoothParameters(previousTrackParam->GetParameters()); |
908 | previousTrackParam->SetSmoothCovariances(previousTrackParam->GetCovariances()); | |
909 | ||
96ebe67e | 910 | // Compute local chi2 at first cluster |
911 | AliMUONVCluster *cluster = previousTrackParam->GetClusterPtr(); | |
912 | Double_t dX = cluster->GetX() - previousTrackParam->GetNonBendingCoor(); | |
913 | Double_t dY = cluster->GetY() - previousTrackParam->GetBendingCoor(); | |
914 | Double_t localChi2 = dX * dX / cluster->GetErrX2() + dY * dY / cluster->GetErrY2(); | |
ea94c18b | 915 | |
96ebe67e | 916 | // Save local chi2 at first cluster |
ea94c18b | 917 | previousTrackParam->SetLocalChi2(localChi2); |
918 | ||
96ebe67e | 919 | AliMUONTrackParam *currentTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(previousTrackParam); |
ea94c18b | 920 | while (currentTrackParam) { |
921 | ||
922 | // Get variables | |
923 | const TMatrixD &extrapParameters = previousTrackParam->GetExtrapParameters(); // X(k+1 k) | |
924 | const TMatrixD &filteredParameters = currentTrackParam->GetParameters(); // X(k k) | |
925 | const TMatrixD &previousSmoothParameters = previousTrackParam->GetSmoothParameters(); // X(k+1 n) | |
926 | const TMatrixD &propagator = previousTrackParam->GetPropagator(); // F(k) | |
927 | const TMatrixD &extrapCovariances = previousTrackParam->GetExtrapCovariances(); // C(k+1 k) | |
928 | const TMatrixD &filteredCovariances = currentTrackParam->GetCovariances(); // C(k k) | |
929 | const TMatrixD &previousSmoothCovariances = previousTrackParam->GetSmoothCovariances(); // C(k+1 n) | |
930 | ||
931 | // Compute smoother gain: A(k) = C(kk) * F(f)^t * (C(k+1 k))^-1 | |
932 | TMatrixD extrapWeight(extrapCovariances); | |
933 | if (extrapWeight.Determinant() != 0) { | |
934 | extrapWeight.Invert(); // (C(k+1 k))^-1 | |
935 | } else { | |
936 | AliWarning(" Determinant = 0"); | |
937 | return kFALSE; | |
938 | } | |
939 | TMatrixD smootherGain(filteredCovariances,TMatrixD::kMultTranspose,propagator); // C(kk) * F(f)^t | |
940 | smootherGain *= extrapWeight; // C(kk) * F(f)^t * (C(k+1 k))^-1 | |
941 | ||
942 | // Compute smoothed parameters: X(k n) = X(k k) + A(k) * (X(k+1 n) - X(k+1 k)) | |
943 | TMatrixD tmpParam(previousSmoothParameters,TMatrixD::kMinus,extrapParameters); // X(k+1 n) - X(k+1 k) | |
944 | TMatrixD smoothParameters(smootherGain,TMatrixD::kMult,tmpParam); // A(k) * (X(k+1 n) - X(k+1 k)) | |
945 | smoothParameters += filteredParameters; // X(k k) + A(k) * (X(k+1 n) - X(k+1 k)) | |
946 | ||
947 | // Save smoothed parameters | |
948 | currentTrackParam->SetSmoothParameters(smoothParameters); | |
949 | ||
950 | // Compute smoothed covariances: C(k n) = C(k k) + A(k) * (C(k+1 n) - C(k+1 k)) * (A(k))^t | |
951 | TMatrixD tmpCov(previousSmoothCovariances,TMatrixD::kMinus,extrapCovariances); // C(k+1 n) - C(k+1 k) | |
952 | TMatrixD tmpCov2(tmpCov,TMatrixD::kMultTranspose,smootherGain); // (C(k+1 n) - C(k+1 k)) * (A(k))^t | |
953 | TMatrixD smoothCovariances(smootherGain,TMatrixD::kMult,tmpCov2); // A(k) * (C(k+1 n) - C(k+1 k)) * (A(k))^t | |
954 | smoothCovariances += filteredCovariances; // C(k k) + A(k) * (C(k+1 n) - C(k+1 k)) * (A(k))^t | |
955 | ||
956 | // Save smoothed covariances | |
957 | currentTrackParam->SetSmoothCovariances(smoothCovariances); | |
958 | ||
96ebe67e | 959 | // Compute smoothed residual: r(k n) = cluster - X(k n) |
960 | cluster = currentTrackParam->GetClusterPtr(); | |
ea94c18b | 961 | TMatrixD smoothResidual(2,1); |
962 | smoothResidual.Zero(); | |
96ebe67e | 963 | smoothResidual(0,0) = cluster->GetX() - smoothParameters(0,0); |
964 | smoothResidual(1,0) = cluster->GetY() - smoothParameters(2,0); | |
ea94c18b | 965 | |
96ebe67e | 966 | // Compute weight of smoothed residual: W(k n) = (clusterCov - C(k n))^-1 |
ea94c18b | 967 | TMatrixD smoothResidualWeight(2,2); |
96ebe67e | 968 | smoothResidualWeight(0,0) = cluster->GetErrX2() - smoothCovariances(0,0); |
ea94c18b | 969 | smoothResidualWeight(0,1) = - smoothCovariances(0,2); |
970 | smoothResidualWeight(1,0) = - smoothCovariances(2,0); | |
96ebe67e | 971 | smoothResidualWeight(1,1) = cluster->GetErrY2() - smoothCovariances(2,2); |
ea94c18b | 972 | if (smoothResidualWeight.Determinant() != 0) { |
973 | smoothResidualWeight.Invert(); | |
974 | } else { | |
975 | AliWarning(" Determinant = 0"); | |
976 | return kFALSE; | |
977 | } | |
978 | ||
979 | // Compute local chi2 = (r(k n))^t * W(k n) * r(k n) | |
980 | TMatrixD tmpChi2(smoothResidual,TMatrixD::kTransposeMult,smoothResidualWeight); // (r(k n))^t * W(k n) | |
981 | TMatrixD localChi2(tmpChi2,TMatrixD::kMult,smoothResidual); // (r(k n))^t * W(k n) * r(k n) | |
982 | ||
983 | // Save local chi2 | |
984 | currentTrackParam->SetLocalChi2(localChi2(0,0)); | |
985 | ||
986 | previousTrackParam = currentTrackParam; | |
96ebe67e | 987 | currentTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(previousTrackParam); |
ea94c18b | 988 | } |
989 | ||
990 | return kTRUE; | |
991 | ||
8cc77df0 | 992 | } |
993 | ||
8cc77df0 | 994 | //__________________________________________________________________________ |
96ebe67e | 995 | void AliMUONTrackReconstructorK::ComplementTracks(const AliMUONVClusterStore& clusterStore) |
b709ac13 | 996 | { |
997 | /// Complete tracks by adding missing clusters (if there is an overlap between | |
998 | /// two detection elements, the track may have two clusters in the same chamber) | |
999 | /// Recompute track parameters and covariances at each clusters | |
1000 | AliDebug(1,"Enter ComplementTracks"); | |
1001 | ||
1002 | Int_t chamberId, detElemId; | |
96ebe67e | 1003 | Double_t chi2OfCluster, addChi2TrackAtCluster, bestAddChi2TrackAtCluster; |
1004 | Double_t maxChi2OfCluster = 2. * AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking() * | |
1005 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2 | |
1006 | Bool_t foundOneCluster, trackModified; | |
1007 | AliMUONVCluster *cluster; | |
1008 | AliMUONTrackParam *trackParam, *previousTrackParam, *nextTrackParam, trackParamAtCluster, bestTrackParamAtCluster; | |
b709ac13 | 1009 | |
1010 | // Remove double track to complete only "good" tracks | |
1011 | RemoveDoubleTracks(); | |
1012 | ||
1013 | AliMUONTrack *track = (AliMUONTrack*) fRecTracksPtr->First(); | |
1014 | while (track) { | |
1015 | trackModified = kFALSE; | |
1016 | ||
96ebe67e | 1017 | trackParam = (AliMUONTrackParam*)track->GetTrackParamAtCluster()->First(); |
b709ac13 | 1018 | previousTrackParam = trackParam; |
1019 | while (trackParam) { | |
96ebe67e | 1020 | foundOneCluster = kFALSE; |
1021 | bestAddChi2TrackAtCluster = 1.e10; | |
1022 | chamberId = trackParam->GetClusterPtr()->GetChamberId(); | |
1023 | detElemId = trackParam->GetClusterPtr()->GetDetElemId(); | |
b709ac13 | 1024 | |
1025 | // prepare nextTrackParam before adding new cluster because of the sorting | |
96ebe67e | 1026 | nextTrackParam = (AliMUONTrackParam*)track->GetTrackParamAtCluster()->After(trackParam); |
b709ac13 | 1027 | |
96ebe67e | 1028 | // Create iterators to loop over clusters in current chamber |
1029 | TIter nextInCh(clusterStore.CreateChamberIterator(chamberId,chamberId)); | |
b709ac13 | 1030 | |
1031 | // look for one second candidate in the same chamber | |
96ebe67e | 1032 | while ( ( cluster = static_cast<AliMUONVCluster*>(nextInCh()) ) ) { |
b709ac13 | 1033 | |
1034 | // look for a cluster in another detection element | |
96ebe67e | 1035 | if (cluster->GetDetElemId() == detElemId) continue; |
b709ac13 | 1036 | |
96ebe67e | 1037 | // try to add the current cluster fast |
1038 | if (!TryOneClusterFast(*trackParam, cluster)) continue; | |
b709ac13 | 1039 | |
96ebe67e | 1040 | // try to add the current cluster accurately |
b709ac13 | 1041 | // never use track parameters at last cluster because the covariance matrix is meaningless |
96ebe67e | 1042 | if (nextTrackParam) chi2OfCluster = TryOneCluster(*trackParam, cluster, trackParamAtCluster); |
1043 | else chi2OfCluster = TryOneCluster(*previousTrackParam, cluster, trackParamAtCluster); | |
b709ac13 | 1044 | |
1045 | // if good chi2 then consider to add this cluster to the track | |
96ebe67e | 1046 | if (chi2OfCluster < maxChi2OfCluster) { |
b709ac13 | 1047 | |
96ebe67e | 1048 | // Compute local track parameters including current cluster using kalman filter |
1049 | addChi2TrackAtCluster = RunKalmanFilter(trackParamAtCluster); | |
b709ac13 | 1050 | |
1051 | // keep track of the best cluster | |
96ebe67e | 1052 | if (addChi2TrackAtCluster < bestAddChi2TrackAtCluster) { |
1053 | bestAddChi2TrackAtCluster = addChi2TrackAtCluster; | |
1054 | bestTrackParamAtCluster = trackParamAtCluster; | |
1055 | foundOneCluster = kTRUE; | |
b709ac13 | 1056 | } |
1057 | ||
1058 | } | |
1059 | ||
1060 | } | |
1061 | ||
1062 | // add new cluster if any | |
96ebe67e | 1063 | if (foundOneCluster) { |
7332f213 | 1064 | trackParam->SetRemovable(kTRUE); |
1065 | bestTrackParamAtCluster.SetRemovable(kTRUE); | |
1066 | track->AddTrackParamAtCluster(bestTrackParamAtCluster,*(bestTrackParamAtCluster.GetClusterPtr())); | |
b709ac13 | 1067 | trackModified = kTRUE; |
1068 | } | |
1069 | ||
1070 | previousTrackParam = trackParam; | |
1071 | trackParam = nextTrackParam; | |
1072 | } | |
1073 | ||
1074 | // re-compute track parameters using kalman filter if needed | |
1075 | if (trackModified) RetraceTrack(*track,kTRUE); | |
1076 | ||
1077 | track = (AliMUONTrack*) fRecTracksPtr->After(track); | |
1078 | } | |
1079 | ||
1080 | } | |
1081 | ||
1082 | //__________________________________________________________________________ | |
7332f213 | 1083 | void AliMUONTrackReconstructorK::ImproveTrack(AliMUONTrack &track) |
8cc77df0 | 1084 | { |
7332f213 | 1085 | /// Improve the given track by removing removable clusters with local chi2 highter than the defined cut |
1086 | /// Removable clusters are identified by the method AliMUONTrack::TagRemovableClusters() | |
ea94c18b | 1087 | /// Recompute track parameters and covariances at the remaining clusters |
7332f213 | 1088 | AliDebug(1,"Enter ImproveTrack"); |
ea94c18b | 1089 | |
1090 | Double_t localChi2, worstLocalChi2; | |
7332f213 | 1091 | AliMUONTrackParam *trackParamAtCluster, *worstTrackParamAtCluster, *nextTrackParam; |
ea94c18b | 1092 | Bool_t smoothed; |
3304fa09 | 1093 | Double_t sigmaCut2 = AliMUONReconstructor::GetRecoParam()->GetSigmaCutForImprovement() * |
1094 | AliMUONReconstructor::GetRecoParam()->GetSigmaCutForImprovement(); | |
ea94c18b | 1095 | |
7332f213 | 1096 | while (!track.IsImproved()) { |
ea94c18b | 1097 | |
7332f213 | 1098 | // identify removable clusters |
1099 | track.TagRemovableClusters(); | |
b709ac13 | 1100 | |
7332f213 | 1101 | // Run smoother if required |
1102 | smoothed = kFALSE; | |
1103 | if (AliMUONReconstructor::GetRecoParam()->UseSmoother()) smoothed = RunSmoother(track); | |
1104 | ||
1105 | // Use standard procedure to compute local chi2 if smoother not required or not working | |
1106 | if (!smoothed) { | |
ea94c18b | 1107 | |
7332f213 | 1108 | // Update track parameters and covariances |
1109 | track.UpdateCovTrackParamAtCluster(); | |
ea94c18b | 1110 | |
7332f213 | 1111 | // Compute local chi2 of each clusters |
1112 | track.ComputeLocalChi2(kTRUE); | |
1113 | } | |
1114 | ||
1115 | // Look for the cluster to remove | |
1116 | worstTrackParamAtCluster = 0x0; | |
1117 | worstLocalChi2 = 0.; | |
1118 | trackParamAtCluster = (AliMUONTrackParam*)track.GetTrackParamAtCluster()->First(); | |
1119 | while (trackParamAtCluster) { | |
ea94c18b | 1120 | |
7332f213 | 1121 | // save parameters into smooth parameters in case of smoother did not work properly |
1122 | if (AliMUONReconstructor::GetRecoParam()->UseSmoother() && !smoothed) { | |
1123 | trackParamAtCluster->SetSmoothParameters(trackParamAtCluster->GetParameters()); | |
1124 | trackParamAtCluster->SetSmoothCovariances(trackParamAtCluster->GetCovariances()); | |
ea94c18b | 1125 | } |
1126 | ||
7332f213 | 1127 | // Pick up cluster with the worst chi2 |
1128 | localChi2 = trackParamAtCluster->GetLocalChi2(); | |
1129 | if (localChi2 > worstLocalChi2) { | |
1130 | worstLocalChi2 = localChi2; | |
1131 | worstTrackParamAtCluster = trackParamAtCluster; | |
ea94c18b | 1132 | } |
1133 | ||
7332f213 | 1134 | trackParamAtCluster = (AliMUONTrackParam*)track.GetTrackParamAtCluster()->After(trackParamAtCluster); |
1135 | } | |
1136 | ||
1137 | // Check if worst cluster found | |
1138 | if (!worstTrackParamAtCluster) { | |
1139 | AliWarning("Bad local chi2 values?"); | |
1140 | break; | |
1141 | } | |
1142 | ||
1143 | // Check whether the worst chi2 is under requirement or not | |
1144 | if (worstLocalChi2 < 2. * sigmaCut2) { // 2 because 2 quantities in chi2 | |
1145 | track.SetImproved(kTRUE); | |
1146 | break; | |
1147 | } | |
1148 | ||
1149 | // if the worst cluster is not removable then stop improvement | |
1150 | if (!worstTrackParamAtCluster->IsRemovable()) break; | |
1151 | ||
1152 | // get track parameters at cluster next to the one to be removed | |
1153 | nextTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(worstTrackParamAtCluster); | |
1154 | ||
1155 | // Remove the worst cluster | |
1156 | track.RemoveTrackParamAtCluster(worstTrackParamAtCluster); | |
1157 | ||
1158 | // Re-calculate track parameters | |
1159 | // - from the cluster immediately downstream the one suppressed | |
1160 | // - or from the begining - if parameters have been re-computed using the standard method (kalman parameters have been lost) | |
1161 | // - or if the removed cluster was the last one | |
1162 | if (smoothed && nextTrackParam) RetracePartialTrack(track,nextTrackParam); | |
1163 | else RetraceTrack(track,kTRUE); | |
1164 | ||
1165 | // Printout for debuging | |
1166 | if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) { | |
1167 | cout << "ImproveTracks: track " << fRecTracksPtr->IndexOf(&track)+1 << " improved " << endl; | |
ea94c18b | 1168 | } |
1169 | ||
ea94c18b | 1170 | } |
1171 | ||
8cc77df0 | 1172 | } |
1173 | ||
7332f213 | 1174 | //__________________________________________________________________________ |
1175 | void AliMUONTrackReconstructorK::FinalizeTrack(AliMUONTrack &track) | |
b0e4c598 | 1176 | { |
96ebe67e | 1177 | /// Update track parameters and covariances at each attached cluster |
7332f213 | 1178 | /// using smoother if required, if not already done |
b709ac13 | 1179 | |
96ebe67e | 1180 | AliMUONTrackParam *trackParamAtCluster; |
ea94c18b | 1181 | Bool_t smoothed = kFALSE; |
1182 | ||
7332f213 | 1183 | // update track parameters (using smoother if required) if not already done |
1184 | if (!track.IsImproved()) { | |
1185 | smoothed = kFALSE; | |
1186 | if (AliMUONReconstructor::GetRecoParam()->UseSmoother()) smoothed = RunSmoother(track); | |
1187 | if (!smoothed) track.UpdateCovTrackParamAtCluster(); | |
1188 | } else smoothed = AliMUONReconstructor::GetRecoParam()->UseSmoother(); | |
1189 | ||
1190 | // copy smoothed parameters and covariances if any | |
1191 | if (smoothed) { | |
ea94c18b | 1192 | |
7332f213 | 1193 | trackParamAtCluster = (AliMUONTrackParam*) (track.GetTrackParamAtCluster()->First()); |
1194 | while (trackParamAtCluster) { | |
ea94c18b | 1195 | |
7332f213 | 1196 | trackParamAtCluster->SetParameters(trackParamAtCluster->GetSmoothParameters()); |
1197 | trackParamAtCluster->SetCovariances(trackParamAtCluster->GetSmoothCovariances()); | |
ea94c18b | 1198 | |
7332f213 | 1199 | trackParamAtCluster = (AliMUONTrackParam*) (track.GetTrackParamAtCluster()->After(trackParamAtCluster)); |
ea94c18b | 1200 | } |
1201 | ||
b0e4c598 | 1202 | } |
7332f213 | 1203 | |
7deb8eb0 | 1204 | } |
1205 | ||
1206 | //__________________________________________________________________________ | |
1207 | Bool_t AliMUONTrackReconstructorK::RefitTrack(AliMUONTrack &track) | |
1208 | { | |
1209 | /// re-fit the given track | |
1210 | ||
1211 | // check validity of the track | |
1212 | if (!track.IsValid()) { | |
1213 | AliWarning("the track does not contain enough clusters --> unable to refit"); | |
1214 | return kFALSE; | |
1215 | } | |
1216 | ||
1217 | // re-compute track parameters and covariances using Kalman filter | |
1218 | RetraceTrack(track,kTRUE); | |
1219 | ||
1220 | // Improve the reconstructed tracks if required | |
1221 | if (AliMUONReconstructor::GetRecoParam()->ImproveTracks()) ImproveTrack(track); | |
1222 | ||
1223 | // Fill AliMUONTrack data members | |
1224 | FinalizeTrack(track); | |
1225 | ||
1226 | return kTRUE; | |
1227 | ||
b0e4c598 | 1228 | } |
ea94c18b | 1229 |