1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONTrackReconstructorK
21 /// MUON track reconstructor using the kalman method
23 /// This class contains as data:
24 /// - the parameters for the track reconstruction
26 /// It contains as methods, among others:
27 /// - MakeTracks to build the tracks
29 //-----------------------------------------------------------------------------
31 #include "AliMUONTrackReconstructorK.h"
33 #include "AliMUONConstants.h"
34 #include "AliMUONVCluster.h"
35 #include "AliMUONVClusterServer.h"
36 #include "AliMUONVClusterStore.h"
37 #include "AliMUONTrack.h"
38 #include "AliMUONTrackParam.h"
39 #include "AliMUONTrackExtrap.h"
40 #include "AliMUONRecoParam.h"
42 #include "AliMpArea.h"
46 #include <Riostream.h>
51 ClassImp(AliMUONTrackReconstructorK) // Class implementation in ROOT context
54 //__________________________________________________________________________
55 AliMUONTrackReconstructorK::AliMUONTrackReconstructorK(const AliMUONRecoParam* recoParam, AliMUONVClusterServer* clusterServer)
56 : AliMUONVTrackReconstructor(recoParam, clusterServer)
61 //__________________________________________________________________________
62 AliMUONTrackReconstructorK::~AliMUONTrackReconstructorK()
67 //__________________________________________________________________________
68 Bool_t AliMUONTrackReconstructorK::MakeTrackCandidates(AliMUONVClusterStore& clusterStore)
70 /// To make track candidates (assuming linear propagation if AliMUONRecoParam::MakeTrackCandidatesFast() return kTRUE):
71 /// Start with segments station(1..) 4 or 5 then follow track in station 5 or 4.
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().
75 TClonesArray *segments;
76 AliMUONObjectPair *segment;
81 AliDebug(1,"Enter MakeTrackCandidates");
83 // Unless we're doing combined tracking, we'll clusterize all stations at once
84 Int_t firstChamber(0);
87 if (GetRecoParam()->CombineClusterTrackReco()) {
88 // ... Here's the exception : ask the clustering to reconstruct
89 // clusters *only* in station 4 and 5 for combined tracking
93 for (Int_t i = firstChamber; i <= lastChamber; ++i )
95 if (fClusterServer && GetRecoParam()->UseChamber(i)) fClusterServer->Clusterize(i, clusterStore, AliMpArea(), GetRecoParam());
98 // Loop over stations(1..) 5 and 4 and make track candidates
99 for (Int_t istat=4; istat>=3; istat--) {
101 // Make segments in the station
102 segments = MakeSegmentsBetweenChambers(clusterStore, 2*istat, 2*istat+1);
104 // Loop over segments
105 for (Int_t iSegment=0; iSegment<segments->GetEntriesFast(); iSegment++) {
106 AliDebug(1,Form("Making primary candidate(1..) %d",++iCandidate));
107 segment = (AliMUONObjectPair*) segments->UncheckedAt(iSegment);
109 // Transform segments to tracks and put them at the end of fRecTracksPtr
110 track = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(segment,GetRecoParam()->GetBendingVertexDispersion());
113 // Look for compatible cluster(s) in the other station
114 if (GetRecoParam()->MakeTrackCandidatesFast()) clusterFound = FollowLinearTrackInStation(*track, clusterStore, 7-istat);
115 else clusterFound = FollowTrackInStation(*track, clusterStore, 7-istat);
117 // Remove track if no cluster found on a requested station
118 // or abort tracking if there are too many candidates
119 if (GetRecoParam()->RequestStation(7-istat)) {
121 fRecTracksPtr->Remove(track);
123 } else if (fNRecTracks > GetRecoParam()->GetMaxTrackCandidates()) {
124 AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks));
129 if ((fNRecTracks + segments->GetEntriesFast() - iSegment - 1) > GetRecoParam()->GetMaxTrackCandidates()) {
130 AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks + segments->GetEntriesFast() - iSegment - 1));
138 // delete the array of segments
142 // Keep all different tracks if required
143 if (GetRecoParam()->TrackAllTracks()) RemoveIdenticalTracks();
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);
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()))) {
155 fRecTracksPtr->Remove(track);
161 // Keep only the best tracks if required
162 if (!GetRecoParam()->TrackAllTracks()) RemoveDoubleTracks();
163 else fRecTracksPtr->Compress();
165 AliDebug(1,Form("Number of good candidates = %d",fNRecTracks));
171 //__________________________________________________________________________
172 Bool_t AliMUONTrackReconstructorK::MakeMoreTrackCandidates(AliMUONVClusterStore& clusterStore)
174 /// To make extra track candidates assuming linear propagation:
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.
177 /// Good candidates are made of at least three clusters if both stations are requested (two otherwise).
178 /// Keep only best candidates or all of them according to the flag fgkTrackAllTracks.
180 TClonesArray *segments;
181 AliMUONObjectPair *segment;
183 Int_t iCandidate = 0, iCurrentTrack, nCurrentTracks;
184 Int_t initialNRecTracks = fNRecTracks;
187 AliDebug(1,"Enter MakeMoreTrackCandidates");
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++) {
193 // Make segments between ch1 and ch2
194 segments = MakeSegmentsBetweenChambers(clusterStore, ich1, ich2);
196 /// Remove segments already attached to a track
197 RemoveUsedSegments(*segments);
199 // Loop over segments
200 for (Int_t iSegment=0; iSegment<segments->GetEntriesFast(); iSegment++) {
201 AliDebug(1,Form("Making primary candidate(1..) %d",++iCandidate));
202 segment = (AliMUONObjectPair*) segments->UncheckedAt(iSegment);
204 // Transform segments to tracks and put them at the end of fRecTracksPtr
205 iCurrentTrack = fRecTracksPtr->GetLast()+1;
206 track = new ((*fRecTracksPtr)[iCurrentTrack]) AliMUONTrack(segment,GetRecoParam()->GetBendingVertexDispersion());
209 // Look for compatible cluster(s) in the second chamber of station 5
210 clusterFound = FollowLinearTrackInChamber(*track, clusterStore, 17-ich2);
212 // skip the original track in case it has been removed
213 if (GetRecoParam()->TrackAllTracks() && clusterFound) iCurrentTrack++;
215 // loop over every new tracks
216 nCurrentTracks = fRecTracksPtr->GetLast()+1;
217 while (iCurrentTrack < nCurrentTracks) {
218 track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iCurrentTrack);
220 // Look for compatible cluster(s) in the second chamber of station 4
221 FollowLinearTrackInChamber(*track, clusterStore, 13-ich1);
226 // abort tracking if there are too many candidates
227 if ((fNRecTracks + segments->GetEntriesFast() - iSegment - 1) > GetRecoParam()->GetMaxTrackCandidates()) {
228 AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks + segments->GetEntriesFast() - iSegment - 1));
235 // delete the array of segments
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++) {
243 track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iRecTrack);
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()))) {
250 fRecTracksPtr->Remove(track);
256 // Keep only the best tracks if required
257 if (!GetRecoParam()->TrackAllTracks()) RemoveDoubleTracks();
258 else fRecTracksPtr->Compress();
260 AliDebug(1,Form("Number of good candidates = %d",fNRecTracks));
266 //__________________________________________________________________________
267 Bool_t AliMUONTrackReconstructorK::RetraceTrack(AliMUONTrack &trackCandidate, Bool_t resetSeed)
269 /// Re-run the kalman filter from the most downstream cluster to the most uptream one
270 /// Return kFALSE in case of failure (i.e. extrapolation problem)
271 AliDebug(1,"Enter RetraceTrack");
273 AliMUONTrackParam* lastTrackParam = (AliMUONTrackParam*) trackCandidate.GetTrackParamAtCluster()->Last();
275 // Reset the "seed" (= track parameters and their covariances at last cluster) if required
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();
284 // parameters at last but one cluster
285 AliMUONTrackParam* previousTrackParam = (AliMUONTrackParam*) trackCandidate.GetTrackParamAtCluster()->Before(lastTrackParam);
286 AliMUONVCluster* cluster1 = previousTrackParam->GetClusterPtr();
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();
292 Double_t x1 = cluster1->GetX();
293 Double_t y1 = cluster1->GetY();
294 Double_t z1 = cluster1->GetZ();
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();
304 Double_t inverseBendingMomentum = 1. / AliMUONTrackExtrap::GetBendingMomentumFromImpactParam(bendingImpact);
305 lastTrackParam->SetInverseBendingMomentum(inverseBendingMomentum);
307 // => Reset track parameter covariances at last cluster (as if the other clusters did not exist)
308 TMatrixD lastParamCov(5,5);
311 lastParamCov(0,0) = cluster2->GetErrX2();
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;
316 lastParamCov(2,2) = cluster2->GetErrY2();
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;
320 // Inverse bending momentum (vertex resolution + bending slope resolution + 10% error on dipole parameters+field)
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;
332 lastTrackParam->SetCovariances(lastParamCov);
334 // Reset the track chi2
335 lastTrackParam->SetTrackChi2(0.);
340 return RetracePartialTrack(trackCandidate, lastTrackParam);
344 //__________________________________________________________________________
345 Bool_t AliMUONTrackReconstructorK::RetracePartialTrack(AliMUONTrack &trackCandidate, const AliMUONTrackParam* startingTrackParam)
347 /// Re-run the kalman filter from the cluster attached to startingTrackParam to the most uptream cluster
348 /// Return kFALSE in case of failure (i.e. extrapolation problem)
349 AliDebug(1,"Enter RetracePartialTrack");
351 // Printout for debuging
352 if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
353 cout << "RetracePartialTrack: track chi2 before re-tracking: " << trackCandidate.GetGlobalChi2() << endl;
356 // Reset the track chi2
357 trackCandidate.SetGlobalChi2(startingTrackParam->GetTrackChi2());
359 // loop over attached clusters until the first one and recompute track parameters and covariances using kalman filter
360 Bool_t extrapStatus = kTRUE;
361 Int_t expectedChamber = startingTrackParam->GetClusterPtr()->GetChamberId() - 1;
362 Int_t currentChamber;
363 Double_t addChi2TrackAtCluster;
364 AliMUONTrackParam* trackParamAtCluster = (AliMUONTrackParam*) trackCandidate.GetTrackParamAtCluster()->Before(startingTrackParam);
365 while (trackParamAtCluster) {
367 // reset track parameters and their covariances
368 trackParamAtCluster->SetParameters(startingTrackParam->GetParameters());
369 trackParamAtCluster->SetZ(startingTrackParam->GetZ());
370 trackParamAtCluster->SetCovariances(startingTrackParam->GetCovariances());
373 AliMUONTrackExtrap::AddMCSEffect(trackParamAtCluster,AliMUONConstants::ChamberThicknessInX0(expectedChamber+1),-1.);
375 // reset propagator for smoother
376 if (GetRecoParam()->UseSmoother()) trackParamAtCluster->ResetPropagator();
378 // add MCS in missing chambers if any
379 currentChamber = trackParamAtCluster->GetClusterPtr()->GetChamberId();
380 while (currentChamber < expectedChamber) {
381 // extrapolation to the missing chamber (update the propagator)
382 if (!AliMUONTrackExtrap::ExtrapToZCov(trackParamAtCluster, AliMUONConstants::DefaultChamberZ(expectedChamber),
383 GetRecoParam()->UseSmoother())) extrapStatus = kFALSE;
385 AliMUONTrackExtrap::AddMCSEffect(trackParamAtCluster,AliMUONConstants::ChamberThicknessInX0(expectedChamber),-1.);
389 // extrapolation to the plane of the cluster attached to the current trackParamAtCluster (update the propagator)
390 if (!AliMUONTrackExtrap::ExtrapToZCov(trackParamAtCluster, trackParamAtCluster->GetClusterPtr()->GetZ(),
391 GetRecoParam()->UseSmoother())) extrapStatus = kFALSE;
393 if (GetRecoParam()->UseSmoother()) {
394 // save extrapolated parameters for smoother
395 trackParamAtCluster->SetExtrapParameters(trackParamAtCluster->GetParameters());
397 // save extrapolated covariance matrix for smoother
398 trackParamAtCluster->SetExtrapCovariances(trackParamAtCluster->GetCovariances());
401 // Compute new track parameters using kalman filter
402 addChi2TrackAtCluster = RunKalmanFilter(*trackParamAtCluster);
404 // Update the track chi2
405 trackCandidate.SetGlobalChi2(trackCandidate.GetGlobalChi2() + addChi2TrackAtCluster);
406 trackParamAtCluster->SetTrackChi2(trackCandidate.GetGlobalChi2());
409 expectedChamber = currentChamber - 1;
410 startingTrackParam = trackParamAtCluster;
411 trackParamAtCluster = (AliMUONTrackParam*) (trackCandidate.GetTrackParamAtCluster()->Before(startingTrackParam));
414 // Printout for debuging
415 if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
416 cout << "RetracePartialTrack: track chi2 after re-tracking: " << trackCandidate.GetGlobalChi2() << endl;
419 // set global chi2 to max value in case of problem during track extrapolation
420 if (!extrapStatus) trackCandidate.SetGlobalChi2(2.*AliMUONTrack::MaxChi2());
425 //__________________________________________________________________________
426 Bool_t AliMUONTrackReconstructorK::FollowTracks(AliMUONVClusterStore& clusterStore)
428 /// Follow tracks in stations(1..) 3, 2 and 1
429 AliDebug(1,"Enter FollowTracks");
432 Int_t currentNRecTracks;
434 for (Int_t station = 2; station >= 0; station--) {
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;
441 for (Int_t iRecTrack = 0; iRecTrack <currentNRecTracks; iRecTrack++) {
442 AliDebug(1,Form("FollowTracks: track candidate(1..) %d", iRecTrack+1));
444 track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iRecTrack);
446 // Look for compatible cluster(s) in station(0..) "station"
447 if (!FollowTrackInStation(*track, clusterStore, station)) {
449 // Try to recover track if required
450 if (GetRecoParam()->RecoverTracks()) {
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
454 if (!GetRecoParam()->RequestStation(station)) {
455 track = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(*track);
460 if (!RecoverTrack(*track, clusterStore, station)) {
461 // remove track if no cluster found
462 fRecTracksPtr->Remove(track);
466 } else if (GetRecoParam()->RequestStation(station)) {
467 // remove track if no cluster found
468 fRecTracksPtr->Remove(track);
474 // abort tracking if there are too many candidates
475 if (GetRecoParam()->RequestStation(station)) {
476 if (fNRecTracks > GetRecoParam()->GetMaxTrackCandidates()) {
477 AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks));
481 if ((fNRecTracks + currentNRecTracks - iRecTrack - 1) > GetRecoParam()->GetMaxTrackCandidates()) {
482 AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks + currentNRecTracks - iRecTrack - 1));
489 fRecTracksPtr->Compress(); // this is essential before checking tracks
491 // Keep only the best tracks if required
492 if (!GetRecoParam()->TrackAllTracks()) RemoveDoubleTracks();
500 //__________________________________________________________________________
501 Bool_t AliMUONTrackReconstructorK::FollowTrackInChamber(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextChamber)
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));
512 Double_t chi2OfCluster;
513 Double_t maxChi2OfCluster = 2. * GetRecoParam()->GetSigmaCutForTracking() *
514 GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2
515 Double_t addChi2TrackAtCluster;
516 Double_t bestAddChi2TrackAtCluster = AliMUONTrack::MaxChi2();
517 Bool_t foundOneCluster = kFALSE;
518 AliMUONTrack *newTrack = 0x0;
519 AliMUONVCluster *cluster;
520 AliMUONTrackParam extrapTrackParamAtCh;
521 AliMUONTrackParam extrapTrackParamAtCluster;
522 AliMUONTrackParam bestTrackParamAtCluster;
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();
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();
536 Int_t currentChamber = extrapTrackParamAtCh.GetClusterPtr()->GetChamberId();
537 AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(currentChamber),-1.);
539 // reset propagator for smoother
540 if (GetRecoParam()->UseSmoother()) extrapTrackParamAtCh.ResetPropagator();
542 // Add MCS in the missing chamber(s) if any
543 while (currentChamber > nextChamber + 1) {
544 // extrapolation to the missing chamber
546 if (!AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(currentChamber),
547 GetRecoParam()->UseSmoother())) return kFALSE;
549 AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(currentChamber),-1.);
552 //Extrapolate trackCandidate to chamber
553 if (!AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(nextChamber),
554 GetRecoParam()->UseSmoother())) return kFALSE;
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();
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;
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
570 if (GetRecoParam()->CombineClusterTrackReco()) {
571 if (nextChamber < 6) AskForNewClustersInChamber(extrapTrackParamAtCh, clusterStore, nextChamber);
574 // Create iterators to loop over clusters in both chambers
575 TIter next(clusterStore.CreateChamberIterator(nextChamber,nextChamber));
577 // look for candidates in chamber
578 while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) ) {
580 // try to add the current cluster fast
581 if (!TryOneClusterFast(extrapTrackParamAtCh, cluster)) continue;
583 // try to add the current cluster accuratly
584 chi2OfCluster = TryOneCluster(extrapTrackParamAtCh, cluster, extrapTrackParamAtCluster,
585 GetRecoParam()->UseSmoother());
587 // if good chi2 then consider to add cluster
588 if (chi2OfCluster < maxChi2OfCluster) {
590 if (GetRecoParam()->UseSmoother()) {
591 // save extrapolated parameters for smoother
592 extrapTrackParamAtCluster.SetExtrapParameters(extrapTrackParamAtCluster.GetParameters());
594 // save extrapolated covariance matrix for smoother
595 extrapTrackParamAtCluster.SetExtrapCovariances(extrapTrackParamAtCluster.GetCovariances());
598 // Compute new track parameters including new cluster using kalman filter
599 addChi2TrackAtCluster = RunKalmanFilter(extrapTrackParamAtCluster);
601 // skip track out of limits
602 if (!IsAcceptable(extrapTrackParamAtCluster)) continue;
604 // remember a cluster was found
605 foundOneCluster = kTRUE;
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;
614 if (GetRecoParam()->TrackAllTracks()) {
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);
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();
626 } else if (addChi2TrackAtCluster < bestAddChi2TrackAtCluster) {
627 // keep track of the best cluster
628 bestAddChi2TrackAtCluster = addChi2TrackAtCluster;
629 bestTrackParamAtCluster = extrapTrackParamAtCluster;
636 // fill out the best track if required else clean up the fRecTracksPtr array
637 if (!GetRecoParam()->TrackAllTracks()) {
638 if (foundOneCluster) {
639 UpdateTrack(trackCandidate,bestTrackParamAtCluster,bestAddChi2TrackAtCluster);
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();
647 } else return kFALSE;
649 } else if (foundOneCluster) {
651 // remove obsolete track
652 fRecTracksPtr->Remove(&trackCandidate);
655 } else return kFALSE;
661 //__________________________________________________________________________
662 Bool_t AliMUONTrackReconstructorK::FollowTrackInStation(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextStation)
664 /// Follow trackCandidate in station(0..) nextStation and search for compatible cluster(s)
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.
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)
671 AliDebug(1,Form("Enter FollowTrackInStation(1..) %d", nextStation+1));
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
677 if (nextStation==4) {
678 ch1 = 2*nextStation+1;
682 ch2 = 2*nextStation+1;
685 Double_t chi2OfCluster;
686 Double_t maxChi2OfCluster = 2. * GetRecoParam()->GetSigmaCutForTracking() *
687 GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2
688 Double_t addChi2TrackAtCluster1;
689 Double_t addChi2TrackAtCluster2;
690 Double_t bestAddChi2TrackAtCluster1 = AliMUONTrack::MaxChi2();
691 Double_t bestAddChi2TrackAtCluster2 = AliMUONTrack::MaxChi2();
692 Bool_t foundOneCluster = kFALSE;
693 Bool_t foundTwoClusters = kFALSE;
694 AliMUONTrack *newTrack = 0x0;
695 AliMUONVCluster *clusterCh1, *clusterCh2;
696 AliMUONTrackParam extrapTrackParam;
697 AliMUONTrackParam extrapTrackParamAtCh;
698 AliMUONTrackParam extrapTrackParamAtCluster1;
699 AliMUONTrackParam extrapTrackParamAtCluster2;
700 AliMUONTrackParam bestTrackParamAtCluster1;
701 AliMUONTrackParam bestTrackParamAtCluster2;
703 // Get track parameters according to the propagation direction
704 if (nextStation==4) extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->Last();
705 else extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First();
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();
715 Int_t currentChamber = extrapTrackParamAtCh.GetClusterPtr()->GetChamberId();
716 AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(currentChamber),-1.);
718 // reset propagator for smoother
719 if (GetRecoParam()->UseSmoother()) extrapTrackParamAtCh.ResetPropagator();
721 // Add MCS in the missing chamber(s) if any
722 while (ch1 < ch2 && currentChamber > ch2 + 1) {
723 // extrapolation to the missing chamber
725 if (!AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(currentChamber),
726 GetRecoParam()->UseSmoother())) return kFALSE;
728 AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(currentChamber),-1.);
731 //Extrapolate trackCandidate to chamber "ch2"
732 if (!AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch2),
733 GetRecoParam()->UseSmoother())) return kFALSE;
735 // Printout for debuging
736 if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) {
737 cout<<endl<<"Track parameters and covariances at first cluster extrapolated to z = "<<AliMUONConstants::DefaultChamberZ(ch2)<<":"<<endl;
738 extrapTrackParamAtCh.GetParameters().Print();
739 extrapTrackParamAtCh.GetCovariances().Print();
742 // Printout for debuging
743 if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
744 cout << "FollowTrackInStation: look for clusters in chamber(1..): " << ch2+1 << endl;
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
749 if (GetRecoParam()->CombineClusterTrackReco()) {
750 if (nextStation < 3) AskForNewClustersInStation(extrapTrackParamAtCh, clusterStore, nextStation);
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;
758 // Create iterators to loop over clusters in both chambers
759 TIter nextInCh1(clusterStore.CreateChamberIterator(ch1,ch1));
760 TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2));
762 // look for candidates in chamber 2
763 while ( ( clusterCh2 = static_cast<AliMUONVCluster*>(nextInCh2()) ) ) {
765 // try to add the current cluster fast
766 if (!TryOneClusterFast(extrapTrackParamAtCh, clusterCh2)) continue;
768 // try to add the current cluster accuratly
769 chi2OfCluster = TryOneCluster(extrapTrackParamAtCh, clusterCh2, extrapTrackParamAtCluster2,
770 GetRecoParam()->UseSmoother());
772 // if good chi2 then try to attach a cluster in the other chamber too
773 if (chi2OfCluster < maxChi2OfCluster) {
775 if (GetRecoParam()->UseSmoother()) {
776 // save extrapolated parameters for smoother
777 extrapTrackParamAtCluster2.SetExtrapParameters(extrapTrackParamAtCluster2.GetParameters());
779 // save extrapolated covariance matrix for smoother
780 extrapTrackParamAtCluster2.SetExtrapCovariances(extrapTrackParamAtCluster2.GetCovariances());
783 // Compute new track parameters including "clusterCh2" using kalman filter
784 addChi2TrackAtCluster2 = RunKalmanFilter(extrapTrackParamAtCluster2);
786 // skip track out of limits
787 if (!IsAcceptable(extrapTrackParamAtCluster2)) continue;
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;
794 cout << " look for second clusters in chamber(1..): " << ch1+1 << " ..." << endl;
797 // copy new track parameters for next step
798 extrapTrackParam = extrapTrackParamAtCluster2;
801 AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParam,AliMUONConstants::ChamberThicknessInX0(ch2),-1.);
803 // reset propagator for smoother
804 if (GetRecoParam()->UseSmoother()) extrapTrackParam.ResetPropagator();
806 //Extrapolate track parameters to chamber "ch1"
807 Bool_t normalExtrap = AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParam, AliMUONConstants::DefaultChamberZ(ch1),
808 GetRecoParam()->UseSmoother());
810 // reset cluster iterator of chamber 1
814 // look for second candidates in chamber 1
815 Bool_t foundSecondCluster = kFALSE;
816 if (normalExtrap) while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) {
819 // try to add the current cluster fast
820 if (!TryOneClusterFast(extrapTrackParam, clusterCh1)) continue;
822 // try to add the current cluster accuratly
823 chi2OfCluster = TryOneCluster(extrapTrackParam, clusterCh1, extrapTrackParamAtCluster1,
824 GetRecoParam()->UseSmoother());
826 // if good chi2 then consider to add the 2 clusters to the "trackCandidate"
827 if (chi2OfCluster < maxChi2OfCluster) {
829 if (GetRecoParam()->UseSmoother()) {
830 // save extrapolated parameters for smoother
831 extrapTrackParamAtCluster1.SetExtrapParameters(extrapTrackParamAtCluster1.GetParameters());
833 // save extrapolated covariance matrix for smoother
834 extrapTrackParamAtCluster1.SetExtrapCovariances(extrapTrackParamAtCluster1.GetCovariances());
837 // Compute new track parameters including "clusterCh1" using kalman filter
838 addChi2TrackAtCluster1 = RunKalmanFilter(extrapTrackParamAtCluster1);
840 // skip track out of limits
841 if (!IsAcceptable(extrapTrackParamAtCluster1)) continue;
843 // remember a second cluster was found
844 foundSecondCluster = kTRUE;
845 foundTwoClusters = kTRUE;
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;
854 if (GetRecoParam()->TrackAllTracks()) {
855 // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new clusters
856 newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
857 UpdateTrack(*newTrack,extrapTrackParamAtCluster1,extrapTrackParamAtCluster2,addChi2TrackAtCluster1,addChi2TrackAtCluster2);
860 // Tag clusterCh1 as used
861 clusterCh1Used[iCluster1] = kTRUE;
863 // Printout for debuging
864 if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
865 cout << "FollowTrackInStation: added two clusters in station(1..): " << nextStation+1 << endl;
866 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
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;
881 // if no clusterCh1 found then consider to add clusterCh2 only
882 if (!foundSecondCluster) {
884 // remember a cluster was found
885 foundOneCluster = kTRUE;
887 if (GetRecoParam()->TrackAllTracks()) {
888 // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster
889 newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
890 UpdateTrack(*newTrack,extrapTrackParamAtCluster2,addChi2TrackAtCluster2);
893 // Printout for debuging
894 if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
895 cout << "FollowTrackInStation: added one cluster in chamber(1..): " << ch2+1 << endl;
896 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
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;
911 // look for candidates in chamber 1 not already attached to a track
912 // if we want to keep all possible tracks or if no good couple of clusters has been found
913 if (GetRecoParam()->TrackAllTracks() || !foundTwoClusters) {
915 // add MCS effect for next step
916 AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(ch2),-1.);
918 //Extrapolate trackCandidate to chamber "ch1"
919 Bool_t normalExtrap = AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch1),
920 GetRecoParam()->UseSmoother());
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();
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;
934 // reset cluster iterator of chamber 1
938 // look for second candidates in chamber 1
939 if (normalExtrap) while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) {
942 if (clusterCh1Used[iCluster1]) continue; // Skip clusters already used
944 // try to add the current cluster fast
945 if (!TryOneClusterFast(extrapTrackParamAtCh, clusterCh1)) continue;
947 // try to add the current cluster accuratly
948 chi2OfCluster = TryOneCluster(extrapTrackParamAtCh, clusterCh1, extrapTrackParamAtCluster1,
949 GetRecoParam()->UseSmoother());
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) {
955 if (GetRecoParam()->UseSmoother()) {
956 // save extrapolated parameters for smoother
957 extrapTrackParamAtCluster1.SetExtrapParameters(extrapTrackParamAtCluster1.GetParameters());
959 // save extrapolated covariance matrix for smoother
960 extrapTrackParamAtCluster1.SetExtrapCovariances(extrapTrackParamAtCluster1.GetCovariances());
963 // Compute new track parameters including "clusterCh1" using kalman filter
964 addChi2TrackAtCluster1 = RunKalmanFilter(extrapTrackParamAtCluster1);
966 // skip track out of limits
967 if (!IsAcceptable(extrapTrackParamAtCluster1)) continue;
969 // remember a cluster was found
970 foundOneCluster = kTRUE;
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;
979 if (GetRecoParam()->TrackAllTracks()) {
980 // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster
981 newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
982 UpdateTrack(*newTrack,extrapTrackParamAtCluster1,addChi2TrackAtCluster1);
985 // Printout for debuging
986 if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
987 cout << "FollowTrackInStation: added one cluster in chamber(1..): " << ch1+1 << endl;
988 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
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;
1003 // fill out the best track if required else clean up the fRecTracksPtr array
1004 if (!GetRecoParam()->TrackAllTracks()) {
1005 if (foundTwoClusters) {
1006 UpdateTrack(trackCandidate,bestTrackParamAtCluster1,bestTrackParamAtCluster2,bestAddChi2TrackAtCluster1,bestAddChi2TrackAtCluster2);
1008 // Printout for debuging
1009 if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
1010 cout << "FollowTrackInStation: added the two best clusters in station(1..): " << nextStation+1 << endl;
1011 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
1014 } else if (foundOneCluster) {
1015 UpdateTrack(trackCandidate,bestTrackParamAtCluster1,bestAddChi2TrackAtCluster1);
1017 // Printout for debuging
1018 if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
1019 cout << "FollowTrackInStation: added the best cluster in chamber(1..): " << bestTrackParamAtCluster1.GetClusterPtr()->GetChamberId()+1 << endl;
1020 if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
1024 delete [] clusterCh1Used;
1028 } else if (foundOneCluster || foundTwoClusters) {
1030 // remove obsolete track
1031 fRecTracksPtr->Remove(&trackCandidate);
1035 delete [] clusterCh1Used;
1039 delete [] clusterCh1Used;
1044 //__________________________________________________________________________
1045 Double_t AliMUONTrackReconstructorK::RunKalmanFilter(AliMUONTrackParam &trackParamAtCluster)
1047 /// Compute new track parameters and their covariances including new cluster using kalman filter
1048 /// return the additional track chi2
1049 AliDebug(1,"Enter RunKalmanFilter");
1051 // Get actual track parameters (p)
1052 TMatrixD param(trackParamAtCluster.GetParameters());
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();
1061 // Compute the actual parameter weight (W)
1062 TMatrixD paramWeight(trackParamAtCluster.GetCovariances());
1063 if (paramWeight.Determinant() != 0) {
1064 paramWeight.Invert();
1066 AliWarning(" Determinant = 0");
1067 return 2.*AliMUONTrack::MaxChi2();
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();
1076 // Compute the new parameters covariance matrix ( (W+U)^-1 )
1077 TMatrixD newParamCov(paramWeight,TMatrixD::kPlus,clusterWeight);
1078 if (newParamCov.Determinant() != 0) {
1079 newParamCov.Invert();
1081 AliWarning(" Determinant = 0");
1082 return 2.*AliMUONTrack::MaxChi2();
1085 // Save the new parameters covariance matrix
1086 trackParamAtCluster.SetCovariances(newParamCov);
1088 // Compute the new parameters (p' = ((W+U)^-1)U(m-p) + p)
1089 TMatrixD tmp(clusterParam,TMatrixD::kMinus,param);
1090 TMatrixD tmp2(clusterWeight,TMatrixD::kMult,tmp); // U(m-p)
1091 TMatrixD newParam(newParamCov,TMatrixD::kMult,tmp2); // ((W+U)^-1)U(m-p)
1092 newParam += param; // ((W+U)^-1)U(m-p) + p
1094 // Save the new parameters
1095 trackParamAtCluster.SetParameters(newParam);
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'
1103 tmp -= clusterParam; // (p'-m)
1104 TMatrixD tmp4(clusterWeight,TMatrixD::kMult,tmp); // U(p'-m)
1105 addChi2Track += TMatrixD(tmp,TMatrixD::kTransposeMult,tmp4); // ((p'-p)^-1)W(p'-p) + ((p'-m)^-1)U(p'-m)
1107 return addChi2Track(0,0);
1111 //__________________________________________________________________________
1112 void AliMUONTrackReconstructorK::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtCluster, Double_t addChi2)
1114 /// Add 1 cluster to the track candidate
1115 /// Update chi2 of the track
1117 // Flag cluster as being (not) removable
1118 if (GetRecoParam()->RequestStation(trackParamAtCluster.GetClusterPtr()->GetChamberId()/2))
1119 trackParamAtCluster.SetRemovable(kFALSE);
1120 else trackParamAtCluster.SetRemovable(kTRUE);
1121 trackParamAtCluster.SetLocalChi2(0.); // --> Local chi2 not used
1123 // Update the track chi2 into trackParamAtCluster
1124 trackParamAtCluster.SetTrackChi2(track.GetGlobalChi2() + addChi2);
1126 // Update the chi2 of the new track
1127 track.SetGlobalChi2(trackParamAtCluster.GetTrackChi2());
1129 // Update array of TrackParamAtCluster
1130 track.AddTrackParamAtCluster(trackParamAtCluster,*(trackParamAtCluster.GetClusterPtr()));
1134 //__________________________________________________________________________
1135 void AliMUONTrackReconstructorK::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtCluster1, AliMUONTrackParam &trackParamAtCluster2,
1136 Double_t addChi2AtCluster1, Double_t addChi2AtCluster2)
1138 /// Add 2 clusters to the track candidate (order is important)
1139 /// Update track and local chi2
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);
1149 // Flag first cluster as being removable
1150 trackParamAtCluster1.SetRemovable(kTRUE);
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);
1162 // Flag second cluster as being removable
1163 trackParamAtCluster2.SetRemovable(kTRUE);
1165 // Update the track chi2 into trackParamAtCluster2
1166 trackParamAtCluster2.SetTrackChi2(track.GetGlobalChi2() + addChi2AtCluster2);
1168 // Update the track chi2 into trackParamAtCluster1
1169 trackParamAtCluster1.SetTrackChi2(trackParamAtCluster2.GetTrackChi2() + addChi2AtCluster1);
1171 // Update the chi2 of the new track
1172 track.SetGlobalChi2(trackParamAtCluster1.GetTrackChi2());
1174 // Update array of trackParamAtCluster
1175 track.AddTrackParamAtCluster(trackParamAtCluster1,*cluster1);
1176 track.AddTrackParamAtCluster(trackParamAtCluster2,*cluster2);
1180 //__________________________________________________________________________
1181 Bool_t AliMUONTrackReconstructorK::RecoverTrack(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextStation)
1183 /// Try to recover the track candidate in the next station
1184 /// by removing the worst of the two clusters attached in the current station
1185 /// Return kTRUE if recovering succeeds
1186 AliDebug(1,"Enter RecoverTrack");
1188 // Do not try to recover track until we have attached cluster(s) on station(1..) 3
1189 if (nextStation > 1) return kFALSE;
1191 Int_t worstClusterNumber = -1;
1192 Double_t localChi2, worstLocalChi2 = -1.;
1194 // Look for the cluster to remove
1195 for (Int_t clusterNumber = 0; clusterNumber < 2; clusterNumber++) {
1196 AliMUONTrackParam *trackParamAtCluster = (AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(clusterNumber);
1198 // check if current cluster is in the previous station
1199 if (trackParamAtCluster->GetClusterPtr()->GetChamberId()/2 != nextStation+1) break;
1201 // check if current cluster is removable
1202 if (!trackParamAtCluster->IsRemovable()) return kFALSE;
1204 // reset the current cluster as being not removable if it is on a required station
1205 if (GetRecoParam()->RequestStation(nextStation+1)) trackParamAtCluster->SetRemovable(kFALSE);
1207 // Pick up cluster with the worst chi2
1208 localChi2 = trackParamAtCluster->GetLocalChi2();
1209 if (localChi2 > worstLocalChi2) {
1210 worstLocalChi2 = localChi2;
1211 worstClusterNumber = clusterNumber;
1215 // check if worst cluster found
1216 if (worstClusterNumber < 0) return kFALSE;
1218 // Remove the worst cluster
1219 trackCandidate.RemoveTrackParamAtCluster((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(worstClusterNumber));
1221 // Re-calculate track parameters at the (new) first cluster
1222 if (!RetracePartialTrack(trackCandidate,(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(1))) return kFALSE;
1224 // skip track out of limits
1225 if (!IsAcceptable(*((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First()))) return kFALSE;
1227 // Look for new cluster(s) in next station
1228 return FollowTrackInStation(trackCandidate, clusterStore, nextStation);
1232 //__________________________________________________________________________
1233 Bool_t AliMUONTrackReconstructorK::RunSmoother(AliMUONTrack &track)
1235 /// Compute new track parameters and their covariances using smoother
1236 AliDebug(1,"Enter UseSmoother");
1238 AliMUONTrackParam *previousTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->First();
1240 // Smoothed parameters and covariances at first cluster = filtered parameters and covariances
1241 previousTrackParam->SetSmoothParameters(previousTrackParam->GetParameters());
1242 previousTrackParam->SetSmoothCovariances(previousTrackParam->GetCovariances());
1244 AliMUONTrackParam *currentTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(previousTrackParam);
1246 // Save local chi2 at first cluster = last additional chi2 provided by Kalman
1247 previousTrackParam->SetLocalChi2(previousTrackParam->GetTrackChi2() - currentTrackParam->GetTrackChi2());
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());
1257 while (currentTrackParam) {
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)
1268 // Compute smoother gain: A(k) = C(kk) * F(k)^t * (C(k+1 k))^-1
1269 TMatrixD extrapWeight(extrapCovariances);
1270 if (extrapWeight.Determinant() != 0) {
1271 extrapWeight.Invert(); // (C(k+1 k))^-1
1273 AliWarning(" Determinant = 0");
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
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))
1284 // Save smoothed parameters
1285 currentTrackParam->SetSmoothParameters(smoothParameters);
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
1293 // Save smoothed covariances
1294 currentTrackParam->SetSmoothCovariances(smoothCovariances);
1296 // Compute smoothed residual: r(k n) = cluster - X(k n)
1297 AliMUONVCluster* cluster = currentTrackParam->GetClusterPtr();
1298 TMatrixD smoothResidual(2,1);
1299 smoothResidual.Zero();
1300 smoothResidual(0,0) = cluster->GetX() - smoothParameters(0,0);
1301 smoothResidual(1,0) = cluster->GetY() - smoothParameters(2,0);
1303 // Compute weight of smoothed residual: W(k n) = (clusterCov - C(k n))^-1
1304 TMatrixD smoothResidualWeight(2,2);
1305 smoothResidualWeight(0,0) = cluster->GetErrX2() - smoothCovariances(0,0);
1306 smoothResidualWeight(0,1) = - smoothCovariances(0,2);
1307 smoothResidualWeight(1,0) = - smoothCovariances(2,0);
1308 smoothResidualWeight(1,1) = cluster->GetErrY2() - smoothCovariances(2,2);
1309 if (smoothResidualWeight.Determinant() != 0) {
1310 smoothResidualWeight.Invert();
1312 AliWarning(" Determinant = 0");
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)
1321 currentTrackParam->SetLocalChi2(localChi2(0,0));
1323 previousTrackParam = currentTrackParam;
1324 currentTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(previousTrackParam);
1331 //__________________________________________________________________________
1332 Bool_t AliMUONTrackReconstructorK::ComplementTracks(const AliMUONVClusterStore& clusterStore)
1334 /// Complete tracks by adding missing clusters (if there is an overlap between
1335 /// two detection elements, the track may have two clusters in the same chamber).
1336 /// Recompute track parameters and covariances at each clusters.
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.
1339 AliDebug(1,"Enter ComplementTracks");
1341 Int_t chamberId, detElemId;
1342 Double_t chi2OfCluster, addChi2TrackAtCluster, bestAddChi2TrackAtCluster;
1343 Double_t maxChi2OfCluster = 2. * GetRecoParam()->GetSigmaCutForTracking() *
1344 GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2
1345 Bool_t foundOneCluster, trackModified, hasChanged = kFALSE;
1346 AliMUONVCluster *cluster;
1347 AliMUONTrackParam *trackParam, *previousTrackParam, *nextTrackParam, trackParamAtCluster, bestTrackParamAtCluster;
1348 AliMUONTrack *nextTrack;
1350 AliMUONTrack *track = (AliMUONTrack*) fRecTracksPtr->First();
1352 trackModified = kFALSE;
1354 trackParam = (AliMUONTrackParam*)track->GetTrackParamAtCluster()->First();
1355 previousTrackParam = trackParam;
1356 while (trackParam) {
1357 foundOneCluster = kFALSE;
1358 bestAddChi2TrackAtCluster = AliMUONTrack::MaxChi2();
1359 chamberId = trackParam->GetClusterPtr()->GetChamberId();
1360 detElemId = trackParam->GetClusterPtr()->GetDetElemId();
1362 // prepare nextTrackParam before adding new cluster because of the sorting
1363 nextTrackParam = (AliMUONTrackParam*)track->GetTrackParamAtCluster()->After(trackParam);
1365 // Create iterators to loop over clusters in current chamber
1366 TIter nextInCh(clusterStore.CreateChamberIterator(chamberId,chamberId));
1368 // look for one second candidate in the same chamber
1369 while ( ( cluster = static_cast<AliMUONVCluster*>(nextInCh()) ) ) {
1371 // look for a cluster in another detection element
1372 if (cluster->GetDetElemId() == detElemId) continue;
1374 // try to add the current cluster fast
1375 if (!TryOneClusterFast(*trackParam, cluster)) continue;
1377 // try to add the current cluster accurately
1378 // never use track parameters at last cluster because the covariance matrix is meaningless
1379 if (nextTrackParam) chi2OfCluster = TryOneCluster(*trackParam, cluster, trackParamAtCluster);
1380 else chi2OfCluster = TryOneCluster(*previousTrackParam, cluster, trackParamAtCluster);
1382 // if good chi2 then consider to add this cluster to the track
1383 if (chi2OfCluster < maxChi2OfCluster) {
1385 // Compute local track parameters including current cluster using kalman filter
1386 addChi2TrackAtCluster = RunKalmanFilter(trackParamAtCluster);
1388 // keep track of the best cluster
1389 if (addChi2TrackAtCluster < bestAddChi2TrackAtCluster) {
1390 bestAddChi2TrackAtCluster = addChi2TrackAtCluster;
1391 bestTrackParamAtCluster = trackParamAtCluster;
1392 foundOneCluster = kTRUE;
1399 // add new cluster if any
1400 if (foundOneCluster) {
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();
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();
1413 trackParam->SetRemovable(kTRUE);
1414 bestTrackParamAtCluster.SetRemovable(kTRUE);
1415 track->AddTrackParamAtCluster(bestTrackParamAtCluster,*(bestTrackParamAtCluster.GetClusterPtr()));
1416 trackModified = kTRUE;
1420 previousTrackParam = trackParam;
1421 trackParam = nextTrackParam;
1424 // prepare next track
1425 nextTrack = (AliMUONTrack*) fRecTracksPtr->After(track);
1427 // re-compute track parameters using kalman filter if needed
1428 if (trackModified && !RetraceTrack(*track,kTRUE)) {
1429 AliWarning("track modified but problem occur during refitting --> remove track");
1430 fRecTracksPtr->Remove(track);
1441 //__________________________________________________________________________
1442 void AliMUONTrackReconstructorK::ImproveTrack(AliMUONTrack &track)
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()
1446 /// Recompute track parameters and covariances at the remaining clusters
1447 /// and if something goes wrong (i.e. extrapolation failed...) set track chi2 to max value
1448 AliDebug(1,"Enter ImproveTrack");
1450 Double_t localChi2, worstLocalChi2;
1451 AliMUONTrackParam *trackParamAtCluster, *worstTrackParamAtCluster, *nextTrackParam, *next2nextTrackParam;
1452 Int_t nextChamber, next2nextChamber;
1454 Double_t sigmaCut2 = GetRecoParam()->GetSigmaCutForImprovement() *
1455 GetRecoParam()->GetSigmaCutForImprovement();
1457 while (!track.IsImproved()) {
1459 // identify removable clusters
1460 track.TagRemovableClusters(GetRecoParam()->RequestedStationMask());
1462 // Run smoother if required
1464 if (GetRecoParam()->UseSmoother()) smoothed = RunSmoother(track);
1466 // Use standard procedure to compute local chi2 if smoother not required or not working
1469 // Update track parameters and covariances
1470 if (!track.UpdateCovTrackParamAtCluster()) {
1471 AliWarning("unable to update track parameters and covariances --> stop improvement");
1472 // restore the kalman parameters
1473 RetraceTrack(track,kTRUE);
1477 // Compute local chi2 of each clusters
1478 track.ComputeLocalChi2(kTRUE);
1481 // Look for the cluster to remove
1482 worstTrackParamAtCluster = 0x0;
1483 worstLocalChi2 = -1.;
1484 trackParamAtCluster = (AliMUONTrackParam*)track.GetTrackParamAtCluster()->First();
1485 while (trackParamAtCluster) {
1487 // save parameters into smooth parameters in case of smoother did not work properly
1488 if (GetRecoParam()->UseSmoother() && !smoothed) {
1489 trackParamAtCluster->SetSmoothParameters(trackParamAtCluster->GetParameters());
1490 trackParamAtCluster->SetSmoothCovariances(trackParamAtCluster->GetCovariances());
1493 // Pick up cluster with the worst chi2
1494 localChi2 = trackParamAtCluster->GetLocalChi2();
1495 if (localChi2 > worstLocalChi2) {
1496 worstLocalChi2 = localChi2;
1497 worstTrackParamAtCluster = trackParamAtCluster;
1500 trackParamAtCluster = (AliMUONTrackParam*)track.GetTrackParamAtCluster()->After(trackParamAtCluster);
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);
1509 // if the worst cluster is not removable then stop improvement
1510 if (!worstTrackParamAtCluster->IsRemovable()) {
1511 // restore the kalman parameters in case they have been lost
1512 if (!smoothed) RetraceTrack(track,kTRUE);
1516 // get track parameters at cluster next to the one to be removed
1517 nextTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(worstTrackParamAtCluster);
1519 // Remove the worst cluster
1520 track.RemoveTrackParamAtCluster(worstTrackParamAtCluster);
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)
1525 // - or if the removed cluster was used to compute the tracking seed
1526 Bool_t normalExtrap;
1527 if (smoothed && nextTrackParam) {
1529 nextChamber = nextTrackParam->GetClusterPtr()->GetChamberId();
1530 next2nextTrackParam = nextTrackParam;
1533 next2nextChamber = next2nextTrackParam->GetClusterPtr()->GetChamberId();
1534 next2nextTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(next2nextTrackParam);
1536 } while (next2nextTrackParam && (next2nextChamber == nextChamber));
1538 if (next2nextChamber == nextChamber) normalExtrap = RetraceTrack(track,kTRUE);
1539 else normalExtrap = RetracePartialTrack(track,nextTrackParam);
1541 } else normalExtrap = RetraceTrack(track,kTRUE);
1543 // stop in case of extrapolation problem
1544 if (!normalExtrap) {
1545 AliWarning("track partially improved but problem occur during refitting --> stop improvement");
1549 // Printout for debuging
1550 if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructorK") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
1551 cout << "ImproveTracks: track " << fRecTracksPtr->IndexOf(&track)+1 << " improved " << endl;
1558 //__________________________________________________________________________
1559 Bool_t AliMUONTrackReconstructorK::FinalizeTrack(AliMUONTrack &track)
1561 /// Update track parameters and covariances at each attached cluster
1562 /// using smoother if required, if not already done
1563 /// return kFALSE if the track cannot be extrapolated uo to the last chamber
1565 AliMUONTrackParam *trackParamAtCluster;
1566 Bool_t smoothed = kFALSE;
1568 // update track parameters (using smoother if required) if not already done
1569 if (track.IsImproved()) smoothed = GetRecoParam()->UseSmoother();
1571 if (GetRecoParam()->UseSmoother()) smoothed = RunSmoother(track);
1573 if (track.UpdateCovTrackParamAtCluster()) track.ComputeLocalChi2(kTRUE);
1575 AliWarning("finalization failed due to extrapolation problem");
1581 // copy smoothed parameters and covariances if any
1584 trackParamAtCluster = (AliMUONTrackParam*) (track.GetTrackParamAtCluster()->First());
1585 while (trackParamAtCluster) {
1587 trackParamAtCluster->SetParameters(trackParamAtCluster->GetSmoothParameters());
1588 trackParamAtCluster->SetCovariances(trackParamAtCluster->GetSmoothCovariances());
1590 trackParamAtCluster = (AliMUONTrackParam*) (track.GetTrackParamAtCluster()->After(trackParamAtCluster));
1599 //__________________________________________________________________________
1600 Bool_t AliMUONTrackReconstructorK::RefitTrack(AliMUONTrack &track, Bool_t enableImprovement)
1602 /// re-fit the given track
1603 AliDebug(1,"Enter RefitTrack");
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");
1611 // re-compute track parameters and covariances using Kalman filter
1612 if (!RetraceTrack(track,kTRUE)) {
1613 AliWarning("bad track refitting due to extrapolation failure");
1617 // Improve the reconstructed tracks if required
1618 track.SetImproved(kFALSE);
1619 if (enableImprovement && GetRecoParam()->ImproveTracks()) ImproveTrack(track);
1621 // Fill AliMUONTrack data members
1622 if (track.GetGlobalChi2() < AliMUONTrack::MaxChi2()) return FinalizeTrack(track);
1624 AliWarning("track not finalized due to extrapolation failure");