]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTrackReconstructor.cxx
All:
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackReconstructor.cxx
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
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONTrackReconstructor
20 /// MUON track reconstructor using the original method
21 ///
22 /// This class contains as data:
23 /// - the parameters for the track reconstruction
24 ///
25 /// It contains as methods, among others:
26 /// - MakeTracks to build the tracks
27 //-----------------------------------------------------------------------------
28
29 #include "AliMUONTrackReconstructor.h"
30
31 #include "AliMUONConstants.h"
32 #include "AliMUONVCluster.h"
33 #include "AliMUONVClusterServer.h"
34 #include "AliMUONVClusterStore.h"
35 #include "AliMUONTrack.h"
36 #include "AliMUONTrackParam.h"
37 #include "AliMUONTrackExtrap.h"
38 #include "AliMUONRecoParam.h"
39
40 #include "AliMpArea.h"
41
42 #include "AliLog.h"
43
44 #include <TMinuit.h>
45 #include <Riostream.h>
46 #include <TMath.h>
47 #include <TMatrixD.h>
48
49 // Functions to be minimized with Minuit
50 void TrackChi2(Int_t &nParam, Double_t *gradient, Double_t &chi2, Double_t *param, Int_t flag);
51
52 /// \cond CLASSIMP
53 ClassImp(AliMUONTrackReconstructor) // Class implementation in ROOT context
54 /// \endcond
55
56   //__________________________________________________________________________
57 AliMUONTrackReconstructor::AliMUONTrackReconstructor(const AliMUONRecoParam* recoParam, AliMUONVClusterServer* clusterServer)
58   : AliMUONVTrackReconstructor(recoParam,clusterServer)
59 {
60   /// Constructor
61 }
62
63   //__________________________________________________________________________
64 AliMUONTrackReconstructor::~AliMUONTrackReconstructor()
65 {
66 /// Destructor
67
68
69   //__________________________________________________________________________
70 Bool_t AliMUONTrackReconstructor::MakeTrackCandidates(AliMUONVClusterStore& clusterStore)
71 {
72   /// To make track candidates (assuming linear propagation if the flag fgkMakeTrackCandidatesFast is set to kTRUE):
73   /// Start with segments station(1..) 4 or 5 then follow track in station 5 or 4.
74   /// Good candidates are made of at least three clusters.
75   /// Keep only best candidates or all of them according to the flag fgkTrackAllTracks.
76   
77   TClonesArray *segments;
78   AliMUONTrack *track;
79   Int_t iCandidate = 0;
80   Bool_t clusterFound;
81
82   AliDebug(1,"Enter MakeTrackCandidates");
83
84   // Unless we're doing combined tracking, we'll clusterize all stations at once
85   Int_t firstChamber(0);
86   Int_t lastChamber(9);
87   
88   if (GetRecoParam()->CombineClusterTrackReco()) {
89     // ... Here's the exception : ask the clustering to reconstruct
90     // clusters *only* in station 4 and 5 for combined tracking
91     firstChamber = 6;
92   }
93
94   for (Int_t i = firstChamber; i <= lastChamber; ++i ) 
95   {
96     if (fClusterServer && GetRecoParam()->UseChamber(i)) fClusterServer->Clusterize(i, clusterStore, AliMpArea(), GetRecoParam());
97   }
98   
99   // Loop over stations(1..) 5 and 4 and make track candidates
100   for (Int_t istat=4; istat>=3; istat--) {
101     
102     // Make segments in the station
103     segments = MakeSegmentsBetweenChambers(clusterStore, 2*istat, 2*istat+1);
104     
105     // Loop over segments
106     for (Int_t iseg=0; iseg<segments->GetEntriesFast(); iseg++) 
107     {
108       AliDebug(1,Form("Making primary candidate(1..) %d",++iCandidate));
109       
110       // Transform segments to tracks and put them at the end of fRecTracksPtr
111       track = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack((AliMUONObjectPair*)((*segments)[iseg]),GetRecoParam()->GetBendingVertexDispersion());
112       fNRecTracks++;
113       
114       // Look for compatible cluster(s) in the other station
115       if (GetRecoParam()->MakeTrackCandidatesFast())
116         clusterFound = FollowLinearTrackInStation(*track, clusterStore, 7-istat);
117       else clusterFound = FollowTrackInStation(*track, clusterStore, 7-istat);
118       
119       // Remove track if no cluster found on a requested station
120       // or abort tracking if there are too many candidates
121       if (!clusterFound && GetRecoParam()->RequestStation(7-istat)) {
122         fRecTracksPtr->Remove(track);
123         fNRecTracks--;
124       } else if (fNRecTracks > GetRecoParam()->GetMaxTrackCandidates()) {
125         AliError(Form("Too many track candidates (%d tracks). Abort tracking.", fNRecTracks));
126         delete segments;
127         return kFALSE;
128       }
129       
130     }
131     
132     // delete the array of segments
133     delete segments;
134   }
135   
136   // Keep all different tracks or only the best ones as required
137   if (GetRecoParam()->TrackAllTracks()) RemoveIdenticalTracks();
138   else RemoveDoubleTracks();
139   
140   AliDebug(1,Form("Number of good candidates = %d",fNRecTracks));
141   
142   return kTRUE;
143   
144 }
145
146   //__________________________________________________________________________
147 Bool_t AliMUONTrackReconstructor::MakeMoreTrackCandidates(AliMUONVClusterStore& clusterStore)
148 {
149   /// To make extra track candidates (assuming linear propagation if the flag fgkMakeTrackCandidatesFast is set to kTRUE):
150   /// clustering is supposed to be already done
151   /// Start with segments made of 1 cluster in each of the stations 4 and 5 then follow track in remaining chambers.
152   /// Good candidates are made of at least three clusters if both station are requested (two otherwise).
153   /// Keep only best candidates or all of them according to the flag fgkTrackAllTracks.
154   
155   TClonesArray *segments;
156   AliMUONObjectPair *segment;
157   AliMUONTrack *track;
158   Int_t iCandidate = 0, iCurrentTrack, nCurrentTracks;
159   Bool_t clusterFound;
160   
161   AliDebug(1,"Enter MakeMoreTrackCandidates");
162   
163   // Double loop over chambers in stations(1..) 4 and 5 to make track candidates
164   for (Int_t ich1 = 6; ich1 <= 7; ich1++) {
165     for (Int_t ich2 = 8; ich2 <= 9; ich2++) {
166       
167       // Make segments in the station
168       segments = MakeSegmentsBetweenChambers(clusterStore, ich1, ich2);
169       
170       /// Remove segments already attached to a track
171       RemoveUsedSegments(*segments);
172       
173       // Loop over segments
174       for (Int_t iSegment=0; iSegment<segments->GetEntriesFast(); iSegment++)
175       {
176         AliDebug(1,Form("Making primary candidate(1..) %d",++iCandidate));
177         segment = (AliMUONObjectPair*) segments->UncheckedAt(iSegment);
178         
179         // Transform segments to tracks and put them at the end of fRecTracksPtr
180         iCurrentTrack = fRecTracksPtr->GetLast()+1;
181         track = new ((*fRecTracksPtr)[iCurrentTrack]) AliMUONTrack(segment,GetRecoParam()->GetBendingVertexDispersion());
182         fNRecTracks++;
183         
184         // Look for compatible cluster(s) in the second chamber of station 5
185         clusterFound = FollowLinearTrackInChamber(*track, clusterStore, 17-ich2);
186         
187         // skip the original track in case it has been removed
188         if (GetRecoParam()->TrackAllTracks() && clusterFound) iCurrentTrack++;
189         
190         // loop over every new tracks
191         nCurrentTracks = fRecTracksPtr->GetLast()+1;
192         while (iCurrentTrack < nCurrentTracks) {
193           track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iCurrentTrack);
194           
195           // Look for compatible cluster(s) in the second chamber of station 4
196           FollowLinearTrackInChamber(*track, clusterStore, 13-ich1);
197           
198           iCurrentTrack++;
199         }
200         
201         // abort tracking if there are too many candidates
202         if (fNRecTracks > GetRecoParam()->GetMaxTrackCandidates()) {
203           AliError(Form("Too many track candidates (%d tracks). Abort tracking.", fNRecTracks));
204           delete segments;
205           return kFALSE;
206         }
207         
208       }
209       
210       // delete the array of segments
211       delete segments;
212     }
213   }
214   
215   // Keep only the best tracks if required
216   if (!GetRecoParam()->TrackAllTracks()) RemoveDoubleTracks();
217   else fRecTracksPtr->Compress();
218   
219   AliDebug(1,Form("Number of good candidates = %d",fNRecTracks));
220   
221   return kTRUE;
222   
223 }
224
225   //__________________________________________________________________________
226 Bool_t AliMUONTrackReconstructor::FollowTracks(AliMUONVClusterStore& clusterStore)
227 {
228   /// Follow tracks in stations(1..) 3, 2 and 1
229   AliDebug(1,"Enter FollowTracks");
230   
231   AliMUONTrack *track, *nextTrack;
232   AliMUONTrackParam *trackParam, *nextTrackParam;
233   Int_t currentNRecTracks;
234   
235   Double_t sigmaCut2 = GetRecoParam()->GetSigmaCutForTracking() *
236                        GetRecoParam()->GetSigmaCutForTracking();
237   
238   for (Int_t station = 2; station >= 0; station--) {
239     
240     // Save the actual number of reconstructed track in case of
241     // tracks are added or suppressed during the tracking procedure
242     // !! Do not compress fRecTracksPtr until the end of the loop over tracks !!
243     currentNRecTracks = fNRecTracks;
244     
245     for (Int_t iRecTrack = 0; iRecTrack <currentNRecTracks; iRecTrack++) {
246       AliDebug(1,Form("FollowTracks: track candidate(1..) %d", iRecTrack+1));
247       
248       track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iRecTrack);
249       
250       // Fit the track:
251       // Do not take into account the multiple scattering to speed up the fit
252       // Calculate the track parameter covariance matrix
253       // If there is no cluster out of station 4 or 5 then use the vertex to better constrain the fit
254       if (((AliMUONTrackParam*) track->GetTrackParamAtCluster()->First())->GetClusterPtr()->GetChamberId() > 5)
255         Fit(*track, kFALSE, kTRUE, kTRUE);
256       else Fit(*track, kFALSE, kFALSE, kTRUE);
257       
258       // remove track with absolute bending momentum out of limits
259       if (AliMUONTrackExtrap::IsFieldON()) {
260         Double_t bendingMomentum = TMath::Abs(1. / ((AliMUONTrackParam*)track->GetTrackParamAtCluster()->First())->GetInverseBendingMomentum());
261         if (bendingMomentum < GetRecoParam()->GetMinBendingMomentum() ||
262             bendingMomentum > GetRecoParam()->GetMaxBendingMomentum()) {
263           fRecTracksPtr->Remove(track);
264           fNRecTracks--;
265           continue;
266         }
267       }
268       
269       // remove track if the normalized chi2 is too high
270       if (track->GetNormalizedChi2() > sigmaCut2) {
271         fRecTracksPtr->Remove(track);
272         fNRecTracks--;
273         continue;
274       }
275       
276       // save parameters from fit into smoothed parameters to complete track afterward
277       if (GetRecoParam()->ComplementTracks()) {
278         
279         if (station==2) { // save track parameters on stations 4 and 5
280           
281           // extrapolate track parameters and covariances at each cluster
282           track->UpdateCovTrackParamAtCluster();
283           
284           // save them
285           trackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->First();
286           while (trackParam) {
287             trackParam->SetSmoothParameters(trackParam->GetParameters());
288             trackParam->SetSmoothCovariances(trackParam->GetCovariances());
289             trackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->After(trackParam);
290           }
291           
292         } else { // or save track parameters on last station only
293           
294           trackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->First();
295           if (trackParam->GetClusterPtr()->GetChamberId() < 2*(station+2)) {
296             
297             // save parameters from fit
298             trackParam->SetSmoothParameters(trackParam->GetParameters());
299             trackParam->SetSmoothCovariances(trackParam->GetCovariances());
300             
301             // save parameters extrapolated to the second chamber of the same station if it has been hit
302             nextTrackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->After(trackParam);
303             if (nextTrackParam->GetClusterPtr()->GetChamberId() < 2*(station+2)) {
304               
305               // reset parameters and covariances
306               nextTrackParam->SetParameters(trackParam->GetParameters());
307               nextTrackParam->SetZ(trackParam->GetZ());
308               nextTrackParam->SetCovariances(trackParam->GetCovariances());
309               
310               // extrapolate them to the z of the corresponding cluster
311               AliMUONTrackExtrap::ExtrapToZCov(nextTrackParam, nextTrackParam->GetClusterPtr()->GetZ());
312               
313               // save them
314               nextTrackParam->SetSmoothParameters(nextTrackParam->GetParameters());
315               nextTrackParam->SetSmoothCovariances(nextTrackParam->GetCovariances());
316               
317             }
318             
319           }
320           
321         }
322         
323       }
324       
325       // Look for compatible cluster(s) in station(0..) "station"
326       if (!FollowTrackInStation(*track, clusterStore, station)) {
327         
328         // Try to recover track if required
329         if (GetRecoParam()->RecoverTracks()) {
330           
331           // work on a copy of the track if this station is not required
332           // to keep the case where no cluster is reconstructed as a possible candidate
333           if (!GetRecoParam()->RequestStation(station)) {
334             track = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(*track);
335             fNRecTracks++;
336           }
337           
338           // try to recover
339           if (!RecoverTrack(*track, clusterStore, station)) {
340             // remove track if no cluster found
341             fRecTracksPtr->Remove(track);
342             fNRecTracks--;
343           }
344           
345         } else if (GetRecoParam()->RequestStation(station)) {
346           // remove track if no cluster found
347           fRecTracksPtr->Remove(track);
348           fNRecTracks--;
349         } 
350         
351       }
352       
353       // abort tracking if there are too many candidates
354       if (fNRecTracks > GetRecoParam()->GetMaxTrackCandidates()) {
355         AliError(Form("Too many track candidates (%d tracks). Abort tracking.", fNRecTracks));
356         return kFALSE;
357       }
358       
359     }
360     
361     // Compress fRecTracksPtr for the next step
362     fRecTracksPtr->Compress();
363     
364     // Keep only the best tracks if required
365     if (!GetRecoParam()->TrackAllTracks()) RemoveDoubleTracks();
366     
367   }
368   
369   // Last fit of track candidates with all stations
370   // Take into account the multiple scattering and remove bad tracks
371   Int_t trackIndex = -1;
372   track = (AliMUONTrack*) fRecTracksPtr->First();
373   while (track) {
374     
375     trackIndex++;
376     nextTrack = (AliMUONTrack*) fRecTracksPtr->After(track); // prepare next track
377     
378     Fit(*track, kTRUE, kFALSE, kTRUE);
379     
380     // Printout for debuging
381     if (AliLog::GetGlobalDebugLevel() >= 3) {
382       cout << "FollowTracks: track candidate(0..) " << trackIndex << " after final fit" << endl;
383       track->RecursiveDump();
384     } 
385     
386     // Remove the track if the normalized chi2 is too high
387     if (track->GetNormalizedChi2() > sigmaCut2) {
388       fRecTracksPtr->Remove(track);
389       fNRecTracks--;
390       track = nextTrack;
391       continue;
392     }
393     
394     // save parameters from fit into smoothed parameters to complete track afterward
395     if (GetRecoParam()->ComplementTracks()) {
396       
397       trackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->First();
398       if (trackParam->GetClusterPtr()->GetChamberId() < 2) {
399         
400         // save parameters from fit
401         trackParam->SetSmoothParameters(trackParam->GetParameters());
402         trackParam->SetSmoothCovariances(trackParam->GetCovariances());
403         
404         // save parameters extrapolated to the second chamber of the same station if it has been hit
405         nextTrackParam = (AliMUONTrackParam*) track->GetTrackParamAtCluster()->After(trackParam);
406         if (nextTrackParam->GetClusterPtr()->GetChamberId() < 2) {
407           
408           // reset parameters and covariances
409           nextTrackParam->SetParameters(trackParam->GetParameters());
410           nextTrackParam->SetZ(trackParam->GetZ());
411           nextTrackParam->SetCovariances(trackParam->GetCovariances());
412           
413           // extrapolate them to the z of the corresponding cluster
414           AliMUONTrackExtrap::ExtrapToZCov(nextTrackParam, nextTrackParam->GetClusterPtr()->GetZ());
415           
416           // save them
417           nextTrackParam->SetSmoothParameters(nextTrackParam->GetParameters());
418           nextTrackParam->SetSmoothCovariances(nextTrackParam->GetCovariances());
419           
420         }
421         
422       }
423       
424     }
425     
426     track = nextTrack;
427     
428   }
429   
430   fRecTracksPtr->Compress();
431   
432   return kTRUE;
433   
434 }
435
436   //__________________________________________________________________________
437 Bool_t AliMUONTrackReconstructor::FollowTrackInChamber(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextChamber)
438 {
439   /// Follow trackCandidate in chamber(0..) nextChamber and search for compatible cluster(s)
440   /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks:
441   /// kTRUE:  duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of
442   ///         fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure.
443   ///         Remove the obsolete "trackCandidate" at the end.
444   /// kFALSE: add only the best cluster(s) to the "trackCandidate". Try to add a couple of clusters in priority.
445   AliDebug(1,Form("Enter FollowTrackInChamber(1..) %d", nextChamber+1));
446   
447   Double_t chi2WithOneCluster = 1.e10;
448   Double_t maxChi2WithOneCluster = 2. * GetRecoParam()->GetSigmaCutForTracking() *
449                                         GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2
450   Double_t bestChi2WithOneCluster = maxChi2WithOneCluster;
451   Bool_t foundOneCluster = kFALSE;
452   AliMUONTrack *newTrack = 0x0;
453   AliMUONVCluster *cluster;
454   AliMUONTrackParam extrapTrackParam;
455   AliMUONTrackParam extrapTrackParamAtCh;
456   AliMUONTrackParam extrapTrackParamAtCluster;
457   AliMUONTrackParam bestTrackParamAtCluster;
458   
459   // Get track parameters according to the propagation direction
460   if (nextChamber > 7) extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->Last();
461   else extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First();
462   
463   // Printout for debuging
464   if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) {
465     cout<<endl<<"Track parameters and covariances at first cluster:"<<endl;
466     extrapTrackParamAtCh.GetParameters().Print();
467     extrapTrackParamAtCh.GetCovariances().Print();
468   }
469   
470   // Add MCS effect
471   AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.);
472   
473   // Add MCS in the missing chamber(s) if any
474   Int_t currentChamber = extrapTrackParamAtCh.GetClusterPtr()->GetChamberId();
475   while (currentChamber > nextChamber + 1) {
476     // extrapolation to the missing chamber
477     currentChamber--;
478     AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(currentChamber));
479     // add MCS effect
480     AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.);
481   }
482   
483   //Extrapolate trackCandidate to chamber
484   AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(nextChamber));
485   
486   // Printout for debuging
487   if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) {
488     cout<<endl<<"Track parameters and covariances at first cluster extrapolated to z = "<<AliMUONConstants::DefaultChamberZ(nextChamber)<<":"<<endl;
489     extrapTrackParamAtCh.GetParameters().Print();
490     extrapTrackParamAtCh.GetCovariances().Print();
491   }
492   
493   // Printout for debuging
494   if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
495     cout << "FollowTrackInStation: look for clusters in chamber(1..): " << nextChamber+1 << endl;
496   }
497   
498   // Ask the clustering to reconstruct new clusters around the track position in the current chamber
499   // except for station 4 and 5 that are already entirely clusterized
500   if (GetRecoParam()->CombineClusterTrackReco()) {
501     if (nextChamber < 6) AskForNewClustersInChamber(extrapTrackParamAtCh, clusterStore, nextChamber);
502   }
503   
504   // Create iterators to loop over clusters in both chambers
505   TIter next(clusterStore.CreateChamberIterator(nextChamber,nextChamber));
506   
507   // look for cluster in chamber
508   while ( ( cluster = static_cast<AliMUONVCluster*>(next()) ) ) {
509     
510     // try to add the current cluster fast
511     if (!TryOneClusterFast(extrapTrackParamAtCh, cluster)) continue;
512     
513     // try to add the current cluster accuratly
514     chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCh, cluster, extrapTrackParamAtCluster);
515     
516     // if good chi2 then consider to add cluster
517     if (chi2WithOneCluster < maxChi2WithOneCluster) {
518       foundOneCluster = kTRUE;
519       
520       // Printout for debuging
521       if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
522         cout << "FollowTrackInStation: found one cluster in chamber(1..): " << nextChamber+1
523         << " (Chi2 = " << chi2WithOneCluster << ")" << endl;
524         cluster->Print();
525       }
526       
527       if (GetRecoParam()->TrackAllTracks()) {
528         // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster
529         newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
530         UpdateTrack(*newTrack,extrapTrackParamAtCluster);
531         fNRecTracks++;
532         
533         // Printout for debuging
534         if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
535           cout << "FollowTrackInStation: added one cluster in chamber(1..): " << nextChamber+1 << endl;
536           if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
537         }
538         
539       } else if (chi2WithOneCluster < bestChi2WithOneCluster) {
540         // keep track of the best single cluster except if a couple of clusters has already been found
541         bestChi2WithOneCluster = chi2WithOneCluster;
542         bestTrackParamAtCluster = extrapTrackParamAtCluster;
543       }
544       
545     }
546     
547   }
548   
549   // fill out the best track if required else clean up the fRecTracksPtr array
550   if (!GetRecoParam()->TrackAllTracks()) {
551     if (foundOneCluster) {
552       UpdateTrack(trackCandidate,bestTrackParamAtCluster);
553       
554       // Printout for debuging
555       if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
556         cout << "FollowTrackInStation: added the best cluster in chamber(1..): " << bestTrackParamAtCluster.GetClusterPtr()->GetChamberId()+1 << endl;
557         if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
558       }
559       
560     } else return kFALSE;
561     
562   } else if (foundOneCluster) {
563     
564     // remove obsolete track
565     fRecTracksPtr->Remove(&trackCandidate);
566     fNRecTracks--;
567     
568   } else return kFALSE;
569   
570   return kTRUE;
571   
572 }
573
574   //__________________________________________________________________________
575 Bool_t AliMUONTrackReconstructor::FollowTrackInStation(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextStation)
576 {
577   /// Follow trackCandidate in station(0..) nextStation and search for compatible cluster(s)
578   /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks:
579   /// kTRUE:  duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of
580   ///         fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure.
581   ///         Remove the obsolete "trackCandidate" at the end.
582   /// kFALSE: add only the best cluster(s) to the "trackCandidate". Try to add a couple of clusters in priority.
583   AliDebug(1,Form("Enter FollowTrackInStation(1..) %d", nextStation+1));
584   
585   // Order the chamber according to the propagation direction (tracking starts with chamber 2):
586   // - nextStation == station(1...) 5 => forward propagation
587   // - nextStation < station(1...) 5 => backward propagation
588   Int_t ch1, ch2;
589   if (nextStation==4) {
590     ch1 = 2*nextStation+1;
591     ch2 = 2*nextStation;
592   } else {
593     ch1 = 2*nextStation;
594     ch2 = 2*nextStation+1;
595   }
596   
597   Double_t chi2WithOneCluster = 1.e10;
598   Double_t chi2WithTwoClusters = 1.e10;
599   Double_t maxChi2WithOneCluster = 2. * GetRecoParam()->GetSigmaCutForTracking() *
600                                         GetRecoParam()->GetSigmaCutForTracking(); // 2 because 2 quantities in chi2
601   Double_t maxChi2WithTwoClusters = 4. * GetRecoParam()->GetSigmaCutForTracking() *
602                                          GetRecoParam()->GetSigmaCutForTracking(); // 4 because 4 quantities in chi2
603   Double_t bestChi2WithOneCluster = maxChi2WithOneCluster;
604   Double_t bestChi2WithTwoClusters = maxChi2WithTwoClusters;
605   Bool_t foundOneCluster = kFALSE;
606   Bool_t foundTwoClusters = kFALSE;
607   AliMUONTrack *newTrack = 0x0;
608   AliMUONVCluster *clusterCh1, *clusterCh2;
609   AliMUONTrackParam extrapTrackParam;
610   AliMUONTrackParam extrapTrackParamAtCh;
611   AliMUONTrackParam extrapTrackParamAtCluster1;
612   AliMUONTrackParam extrapTrackParamAtCluster2;
613   AliMUONTrackParam bestTrackParamAtCluster1;
614   AliMUONTrackParam bestTrackParamAtCluster2;
615   
616   Int_t nClusters = clusterStore.GetSize();
617   Bool_t *clusterCh1Used = new Bool_t[nClusters];
618   for (Int_t i = 0; i < nClusters; i++) clusterCh1Used[i] = kFALSE;
619   Int_t iCluster1;
620   
621   // Get track parameters according to the propagation direction
622   if (nextStation==4) extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->Last();
623   else extrapTrackParamAtCh = *(AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First();
624   
625   // Printout for debuging
626   if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) {
627     cout<<endl<<"Track parameters and covariances at first cluster:"<<endl;
628     extrapTrackParamAtCh.GetParameters().Print();
629     extrapTrackParamAtCh.GetCovariances().Print();
630   }
631   
632   // Add MCS effect
633   AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.);
634   
635   // Add MCS in the missing chamber(s) if any
636   Int_t currentChamber = extrapTrackParamAtCh.GetClusterPtr()->GetChamberId();
637   while (ch1 < ch2 && currentChamber > ch2 + 1) {
638     // extrapolation to the missing chamber
639     currentChamber--;
640     AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(currentChamber));
641     // add MCS effect
642     AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.);
643   }
644   
645   //Extrapolate trackCandidate to chamber "ch2"
646   AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch2));
647   
648   // Printout for debuging
649   if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) {
650     cout<<endl<<"Track parameters and covariances at first cluster extrapolated to z = "<<AliMUONConstants::DefaultChamberZ(ch2)<<":"<<endl;
651     extrapTrackParamAtCh.GetParameters().Print();
652     extrapTrackParamAtCh.GetCovariances().Print();
653   }
654   
655   // Printout for debuging
656   if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
657     cout << "FollowTrackInStation: look for clusters in chamber(1..): " << ch2+1 << endl;
658   }
659   
660   // Ask the clustering to reconstruct new clusters around the track position in the current station
661   // except for station 4 and 5 that are already entirely clusterized
662   if (GetRecoParam()->CombineClusterTrackReco()) {
663     if (nextStation < 3) AskForNewClustersInStation(extrapTrackParamAtCh, clusterStore, nextStation);
664   }
665   
666   // Create iterators to loop over clusters in both chambers
667   TIter nextInCh1(clusterStore.CreateChamberIterator(ch1,ch1));
668   TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2));
669   
670   // look for candidates in chamber 2
671   while ( ( clusterCh2 = static_cast<AliMUONVCluster*>(nextInCh2()) ) ) {
672     
673     // try to add the current cluster fast
674     if (!TryOneClusterFast(extrapTrackParamAtCh, clusterCh2)) continue;
675     
676     // try to add the current cluster accuratly
677     chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCh, clusterCh2, extrapTrackParamAtCluster2);
678     
679     // if good chi2 then try to attach a cluster in the other chamber too
680     if (chi2WithOneCluster < maxChi2WithOneCluster) {
681       Bool_t foundSecondCluster = kFALSE;
682       
683       // Printout for debuging
684       if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
685         cout << "FollowTrackInStation: found one cluster in chamber(1..): " << ch2+1
686              << " (Chi2 = " << chi2WithOneCluster << ")" << endl;
687         clusterCh2->Print();
688         cout << "                      look for second clusters in chamber(1..): " << ch1+1 << " ..." << endl;
689       }
690       
691       // add MCS effect for next step
692       AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCluster2,AliMUONConstants::ChamberThicknessInX0(),1.);
693       
694       // copy new track parameters for next step
695       extrapTrackParam = extrapTrackParamAtCluster2;
696       
697       //Extrapolate track parameters to chamber "ch1"
698       AliMUONTrackExtrap::ExtrapToZ(&extrapTrackParam, AliMUONConstants::DefaultChamberZ(ch1));
699       
700       // reset cluster iterator of chamber 1
701       nextInCh1.Reset();
702       iCluster1 = -1;
703       
704       // look for second candidates in chamber 1
705       while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) {
706         iCluster1++;
707         
708         // try to add the current cluster fast
709         if (!TryOneClusterFast(extrapTrackParam, clusterCh1)) continue;
710         
711         // try to add the current cluster accuratly
712         chi2WithTwoClusters = TryTwoClusters(extrapTrackParamAtCluster2, clusterCh1, extrapTrackParamAtCluster1);
713         
714         // if good chi2 then create a new track by adding the 2 clusters to the "trackCandidate"
715         if (chi2WithTwoClusters < maxChi2WithTwoClusters) {
716           foundSecondCluster = kTRUE;
717           foundTwoClusters = kTRUE;
718           
719           // Printout for debuging
720           if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
721             cout << "FollowTrackInStation: found second cluster in chamber(1..): " << ch1+1
722                  << " (Global Chi2 = " << chi2WithTwoClusters << ")" << endl;
723             clusterCh1->Print();
724           }
725           
726           if (GetRecoParam()->TrackAllTracks()) {
727             // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new clusters
728             newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
729             UpdateTrack(*newTrack,extrapTrackParamAtCluster1,extrapTrackParamAtCluster2);
730             fNRecTracks++;
731             
732             // Tag clusterCh1 as used
733             clusterCh1Used[iCluster1] = kTRUE;
734             
735             // Printout for debuging
736             if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
737               cout << "FollowTrackInStation: added two clusters in station(1..): " << nextStation+1 << endl;
738               if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
739             }
740             
741           } else if (chi2WithTwoClusters < bestChi2WithTwoClusters) {
742             // keep track of the best couple of clusters
743             bestChi2WithTwoClusters = chi2WithTwoClusters;
744             bestTrackParamAtCluster1 = extrapTrackParamAtCluster1;
745             bestTrackParamAtCluster2 = extrapTrackParamAtCluster2;
746           }
747           
748         }
749         
750       }
751       
752       // if no clusterCh1 found then consider to add clusterCh2 only
753       if (!foundSecondCluster) {
754         foundOneCluster = kTRUE;
755         
756         if (GetRecoParam()->TrackAllTracks()) {
757           // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster
758           newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
759           UpdateTrack(*newTrack,extrapTrackParamAtCluster2);
760           fNRecTracks++;
761           
762           // Printout for debuging
763           if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
764             cout << "FollowTrackInStation: added one cluster in chamber(1..): " << ch2+1 << endl;
765             if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
766           }
767           
768         } else if (!foundTwoClusters && chi2WithOneCluster < bestChi2WithOneCluster) {
769           // keep track of the best single cluster except if a couple of clusters has already been found
770           bestChi2WithOneCluster = chi2WithOneCluster;
771           bestTrackParamAtCluster1 = extrapTrackParamAtCluster2;
772         }
773         
774       }
775       
776     }
777     
778   }
779   
780   // look for candidates in chamber 1 not already attached to a track
781   // if we want to keep all possible tracks or if no good couple of clusters has been found
782   if (GetRecoParam()->TrackAllTracks() || !foundTwoClusters) {
783     
784     // add MCS effect for next step
785     AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.);
786     
787     //Extrapolate trackCandidate to chamber "ch1"
788     AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch1));
789     
790     // Printout for debuging
791     if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) {
792       cout<<endl<<"Track parameters and covariances at first cluster extrapolated to z = "<<AliMUONConstants::DefaultChamberZ(ch1)<<":"<<endl;
793       extrapTrackParamAtCh.GetParameters().Print();
794       extrapTrackParamAtCh.GetCovariances().Print();
795     }
796     
797     // Printout for debuging
798     if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
799       cout << "FollowTrackInStation: look for single clusters in chamber(1..): " << ch1+1 << endl;
800     }
801     
802     // reset cluster iterator of chamber 1
803     nextInCh1.Reset();
804     iCluster1 = -1;
805     
806     // look for second candidates in chamber 1
807     while ( ( clusterCh1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) {
808       iCluster1++;
809       
810       if (clusterCh1Used[iCluster1]) continue; // Skip cluster already used
811       
812       // try to add the current cluster fast
813       if (!TryOneClusterFast(extrapTrackParamAtCh, clusterCh1)) continue;
814       
815       // try to add the current cluster accuratly
816       chi2WithOneCluster = TryOneCluster(extrapTrackParamAtCh, clusterCh1, extrapTrackParamAtCluster1);
817       
818       // if good chi2 then consider to add clusterCh1
819       // We do not try to attach a cluster in the other chamber too since it has already been done above
820       if (chi2WithOneCluster < maxChi2WithOneCluster) {
821         foundOneCluster = kTRUE;
822         
823         // Printout for debuging
824         if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
825           cout << "FollowTrackInStation: found one cluster in chamber(1..): " << ch1+1
826                << " (Chi2 = " << chi2WithOneCluster << ")" << endl;
827           clusterCh1->Print();
828         }
829         
830         if (GetRecoParam()->TrackAllTracks()) {
831           // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new cluster
832           newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
833           UpdateTrack(*newTrack,extrapTrackParamAtCluster1);
834           fNRecTracks++;
835           
836           // Printout for debuging
837           if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
838             cout << "FollowTrackInStation: added one cluster in chamber(1..): " << ch1+1 << endl;
839             if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
840           }
841           
842         } else if (chi2WithOneCluster < bestChi2WithOneCluster) {
843           // keep track of the best single cluster except if a couple of clusters has already been found
844           bestChi2WithOneCluster = chi2WithOneCluster;
845           bestTrackParamAtCluster1 = extrapTrackParamAtCluster1;
846         }
847         
848       }
849       
850     }
851     
852   }
853   
854   // fill out the best track if required else clean up the fRecTracksPtr array
855   if (!GetRecoParam()->TrackAllTracks()) {
856     if (foundTwoClusters) {
857       UpdateTrack(trackCandidate,bestTrackParamAtCluster1,bestTrackParamAtCluster2);
858       
859       // Printout for debuging
860       if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
861         cout << "FollowTrackInStation: added the two best clusters in station(1..): " << nextStation+1 << endl;
862         if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
863       }
864       
865     } else if (foundOneCluster) {
866       UpdateTrack(trackCandidate,bestTrackParamAtCluster1);
867       
868       // Printout for debuging
869       if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
870         cout << "FollowTrackInStation: added the best cluster in chamber(1..): " << bestTrackParamAtCluster1.GetClusterPtr()->GetChamberId()+1 << endl;
871         if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
872       }
873       
874     } else {
875       delete [] clusterCh1Used;
876       return kFALSE;
877     }
878     
879   } else if (foundOneCluster || foundTwoClusters) {
880     
881     // remove obsolete track
882     fRecTracksPtr->Remove(&trackCandidate);
883     fNRecTracks--;
884     
885   } else {
886     delete [] clusterCh1Used;
887     return kFALSE;
888   }
889   
890   delete [] clusterCh1Used;
891   return kTRUE;
892   
893 }
894
895   //__________________________________________________________________________
896 Double_t AliMUONTrackReconstructor::TryTwoClusters(const AliMUONTrackParam &trackParamAtCluster1, AliMUONVCluster* cluster2,
897                                                    AliMUONTrackParam &trackParamAtCluster2)
898 {
899 /// Test the compatibility between the track and the 2 clusters together (using trackParam's covariance matrix):
900 /// return the corresponding Chi2 accounting for covariances between the 2 clusters
901 /// return trackParamAtCluster1 & 2
902   
903   // extrapolate track parameters at the z position of the second cluster (no need to extrapolate the covariances)
904   trackParamAtCluster2.SetParameters(trackParamAtCluster1.GetParameters());
905   trackParamAtCluster2.SetZ(trackParamAtCluster1.GetZ());
906   AliMUONTrackExtrap::ExtrapToZ(&trackParamAtCluster2, cluster2->GetZ());
907   
908   // set pointer to cluster2 into trackParamAtCluster2
909   trackParamAtCluster2.SetClusterPtr(cluster2);
910   
911   // Set differences between track and the 2 clusters in the bending and non bending directions
912   AliMUONVCluster* cluster1 = trackParamAtCluster1.GetClusterPtr();
913   TMatrixD dPos(4,1);
914   dPos(0,0) = cluster1->GetX() - trackParamAtCluster1.GetNonBendingCoor();
915   dPos(1,0) = cluster1->GetY() - trackParamAtCluster1.GetBendingCoor();
916   dPos(2,0) = cluster2->GetX() - trackParamAtCluster2.GetNonBendingCoor();
917   dPos(3,0) = cluster2->GetY() - trackParamAtCluster2.GetBendingCoor();
918   
919   // Calculate the error matrix from the track parameter covariances at first cluster
920   TMatrixD error(4,4);
921   error.Zero();
922   if (trackParamAtCluster1.CovariancesExist()) {
923     // Save track parameters at first cluster
924     TMatrixD paramAtCluster1Save(trackParamAtCluster1.GetParameters());
925     
926     // Save track coordinates at second cluster
927     Double_t nonBendingCoor2 = trackParamAtCluster2.GetNonBendingCoor();
928     Double_t bendingCoor2    = trackParamAtCluster2.GetBendingCoor();
929     
930     // copy track parameters at first cluster for jacobian calculation
931     AliMUONTrackParam trackParam(trackParamAtCluster1);
932     
933     // add MCS effect to the covariance matrix at first cluster
934     AliMUONTrackExtrap::AddMCSEffect(&trackParam,AliMUONConstants::ChamberThicknessInX0(),1.);
935     
936     // Get the pointer to the parameter covariance matrix at first cluster
937     const TMatrixD& kParamCov = trackParam.GetCovariances();
938     
939     // Calculate the jacobian related to the transformation between track parameters
940     // at first cluster and track coordinates at the 2 cluster z-positions
941     TMatrixD jacob(4,5);
942     jacob.Zero();
943     // first derivative at the first cluster:
944     jacob(0,0) = 1.; // dx1/dx
945     jacob(1,2) = 1.; // dy1/dy
946     // first derivative at the second cluster:
947     TMatrixD dParam(5,1);
948     for (Int_t i=0; i<5; i++) {
949       // Skip jacobian calculation for parameters with no associated error
950       if (kParamCov(i,i) == 0.) continue;
951       // Small variation of parameter i only
952       for (Int_t j=0; j<5; j++) {
953         if (j==i) {
954           dParam(j,0) = TMath::Sqrt(kParamCov(i,i));
955           if (j == 4) dParam(j,0) *= TMath::Sign(1.,-paramAtCluster1Save(4,0)); // variation always in the same direction
956         } else dParam(j,0) = 0.;
957       }
958       
959       // Set new track parameters at first cluster
960       trackParam.SetParameters(paramAtCluster1Save);
961       trackParam.AddParameters(dParam);
962       trackParam.SetZ(cluster1->GetZ());
963       
964       // Extrapolate new track parameters to the z position of the second cluster
965       AliMUONTrackExtrap::ExtrapToZ(&trackParam,cluster2->GetZ());
966       
967       // Calculate the jacobian
968       jacob(2,i) = (trackParam.GetNonBendingCoor() - nonBendingCoor2) / dParam(i,0); // dx2/dParami
969       jacob(3,i) = (trackParam.GetBendingCoor()    - bendingCoor2   ) / dParam(i,0); // dy2/dParami
970     }
971     
972     // Calculate the error matrix
973     TMatrixD tmp(jacob,TMatrixD::kMult,kParamCov);
974     error = TMatrixD(tmp,TMatrixD::kMultTranspose,jacob);
975   }
976   
977   // Add cluster resolution to the error matrix
978   error(0,0) += cluster1->GetErrX2();
979   error(1,1) += cluster1->GetErrY2();
980   error(2,2) += cluster2->GetErrX2();
981   error(3,3) += cluster2->GetErrY2();
982   
983   // invert the error matrix for Chi2 calculation
984   if (error.Determinant() != 0) {
985     error.Invert();
986   } else {
987     AliWarning(" Determinant error=0");
988     return 1.e10;
989   }
990   
991   // Compute the Chi2 value
992   TMatrixD tmp2(dPos,TMatrixD::kTransposeMult,error);
993   TMatrixD result(tmp2,TMatrixD::kMult,dPos);
994   
995   return result(0,0);
996   
997 }
998
999   //__________________________________________________________________________
1000 void AliMUONTrackReconstructor::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtCluster)
1001 {
1002   /// Add 1 cluster to the track candidate
1003   /// Update chi2 of the track 
1004   
1005   // Compute local chi2
1006   AliMUONVCluster* cluster = trackParamAtCluster.GetClusterPtr();
1007   Double_t deltaX = trackParamAtCluster.GetNonBendingCoor() - cluster->GetX();
1008   Double_t deltaY = trackParamAtCluster.GetBendingCoor() - cluster->GetY();
1009   Double_t localChi2 = deltaX*deltaX / cluster->GetErrX2() +
1010                        deltaY*deltaY / cluster->GetErrY2();
1011   
1012   // Flag cluster as being not removable
1013   if (GetRecoParam()->RequestStation(cluster->GetChamberId()/2))
1014     trackParamAtCluster.SetRemovable(kFALSE);
1015   else trackParamAtCluster.SetRemovable(kTRUE);
1016   trackParamAtCluster.SetLocalChi2(0.); // --> Local chi2 not used
1017   
1018   // Update the chi2 of the new track
1019   track.SetGlobalChi2(track.GetGlobalChi2() + localChi2);
1020   
1021   // Update TrackParamAtCluster
1022   track.AddTrackParamAtCluster(trackParamAtCluster,*cluster);
1023   
1024 }
1025
1026   //__________________________________________________________________________
1027 void AliMUONTrackReconstructor::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtCluster1, AliMUONTrackParam &trackParamAtCluster2)
1028 {
1029   /// Add 2 clusters to the track candidate
1030   /// Update track and local chi2
1031   
1032   // Update local chi2 at first cluster
1033   AliMUONVCluster* cluster1 = trackParamAtCluster1.GetClusterPtr();
1034   Double_t deltaX = trackParamAtCluster1.GetNonBendingCoor() - cluster1->GetX();
1035   Double_t deltaY = trackParamAtCluster1.GetBendingCoor() - cluster1->GetY();
1036   Double_t localChi2AtCluster1 = deltaX*deltaX / cluster1->GetErrX2() +
1037                                  deltaY*deltaY / cluster1->GetErrY2();
1038   trackParamAtCluster1.SetLocalChi2(localChi2AtCluster1);
1039   
1040   // Flag first cluster as being removable
1041   trackParamAtCluster1.SetRemovable(kTRUE);
1042   
1043   // Update local chi2 at second cluster
1044   AliMUONVCluster* cluster2 = trackParamAtCluster2.GetClusterPtr();
1045   deltaX = trackParamAtCluster2.GetNonBendingCoor() - cluster2->GetX();
1046   deltaY = trackParamAtCluster2.GetBendingCoor() - cluster2->GetY();
1047   Double_t localChi2AtCluster2 = deltaX*deltaX / cluster2->GetErrX2() +
1048                                  deltaY*deltaY / cluster2->GetErrY2();
1049   trackParamAtCluster2.SetLocalChi2(localChi2AtCluster2);
1050   
1051   // Flag first cluster as being removable
1052   trackParamAtCluster2.SetRemovable(kTRUE);
1053   
1054   // Update the chi2 of the new track
1055   track.SetGlobalChi2(track.GetGlobalChi2() + localChi2AtCluster1 + localChi2AtCluster2);
1056   
1057   // Update TrackParamAtCluster
1058   track.AddTrackParamAtCluster(trackParamAtCluster1,*cluster1);
1059   track.AddTrackParamAtCluster(trackParamAtCluster2,*cluster2);
1060   
1061 }
1062
1063   //__________________________________________________________________________
1064 Bool_t AliMUONTrackReconstructor::RecoverTrack(AliMUONTrack &trackCandidate, AliMUONVClusterStore& clusterStore, Int_t nextStation)
1065 {
1066   /// Try to recover the track candidate in the next station
1067   /// by removing the worst of the two clusters attached in the current station
1068   /// Return kTRUE if recovering succeeds
1069   AliDebug(1,"Enter RecoverTrack");
1070   
1071   // Do not try to recover track until we have attached cluster(s) on station(1..) 3
1072   if (nextStation > 1) return kFALSE;
1073   
1074   Int_t worstClusterNumber = -1;
1075   Double_t localChi2, worstLocalChi2 = -1.;
1076   
1077   // Look for the cluster to remove
1078   for (Int_t clusterNumber = 0; clusterNumber < 2; clusterNumber++) {
1079     AliMUONTrackParam *trackParamAtCluster = (AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(clusterNumber);
1080     
1081     // check if current cluster is in the previous station
1082     if (trackParamAtCluster->GetClusterPtr()->GetChamberId()/2 != nextStation+1) break;
1083     
1084     // check if current cluster is removable
1085     if (!trackParamAtCluster->IsRemovable()) return kFALSE;
1086     
1087     // reset the current cluster as beig not removable if it is on a required station
1088     if (GetRecoParam()->RequestStation(nextStation+1)) trackParamAtCluster->SetRemovable(kFALSE);
1089     
1090     // Pick up cluster with the worst chi2
1091     localChi2 = trackParamAtCluster->GetLocalChi2();
1092     if (localChi2 > worstLocalChi2) {
1093       worstLocalChi2 = localChi2;
1094       worstClusterNumber = clusterNumber;
1095     }
1096     
1097   }
1098   
1099   // check if worst cluster found
1100   if (worstClusterNumber < 0) return kFALSE;
1101   
1102   // Remove the worst cluster
1103   trackCandidate.RemoveTrackParamAtCluster((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->UncheckedAt(worstClusterNumber));
1104   
1105   // Re-fit the track:
1106   // Do not take into account the multiple scattering to speed up the fit
1107   // Calculate the track parameter covariance matrix
1108   Fit(trackCandidate, kFALSE, kFALSE, kTRUE);
1109   
1110   // skip track with absolute bending momentum out of limits
1111   if (AliMUONTrackExtrap::IsFieldON()) {
1112     Double_t bendingMomentum = TMath::Abs(1. / ((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First())->GetInverseBendingMomentum());
1113     if (bendingMomentum < GetRecoParam()->GetMinBendingMomentum() ||
1114         bendingMomentum > GetRecoParam()->GetMaxBendingMomentum()) return kFALSE;
1115   }
1116   
1117   // Look for new cluster(s) in next station
1118   return FollowTrackInStation(trackCandidate,clusterStore,nextStation);
1119   
1120 }
1121
1122   //__________________________________________________________________________
1123 void AliMUONTrackReconstructor::SetVertexErrXY2ForFit(AliMUONTrack &trackCandidate)
1124 {
1125   /// Compute the vertex resolution square from natural vertex dispersion and
1126   /// multiple scattering effets according to trackCandidate path in absorber
1127   /// It is necessary to account for multiple scattering effects here instead of during the fit of
1128   /// the "trackCandidate" to do not influence the result by changing track resolution at vertex
1129   AliDebug(1,"Enter SetVertexForFit");
1130   
1131   Double_t nonBendingReso2 = GetRecoParam()->GetNonBendingVertexDispersion() *
1132                              GetRecoParam()->GetNonBendingVertexDispersion();
1133   Double_t bendingReso2 = GetRecoParam()->GetBendingVertexDispersion() *
1134                           GetRecoParam()->GetBendingVertexDispersion();
1135   
1136   // add multiple scattering effets
1137   AliMUONTrackParam paramAtVertex(*((AliMUONTrackParam*)(trackCandidate.GetTrackParamAtCluster()->First())));
1138   paramAtVertex.DeleteCovariances(); // to be sure to account only for multiple scattering
1139   AliMUONTrackExtrap::ExtrapToVertexUncorrected(&paramAtVertex,0.);
1140   const TMatrixD& kParamCov = paramAtVertex.GetCovariances();
1141   nonBendingReso2 += kParamCov(0,0);
1142   bendingReso2 += kParamCov(2,2);
1143   
1144   // Set the vertex resolution square
1145   trackCandidate.SetVertexErrXY2(nonBendingReso2,bendingReso2);
1146 }
1147
1148   //__________________________________________________________________________
1149 void AliMUONTrackReconstructor::Fit(AliMUONTrack &track, Bool_t includeMCS, Bool_t fitWithVertex, Bool_t calcCov)
1150 {
1151   /// Fit the track
1152   /// w/wo multiple Coulomb scattering according to "includeMCS".
1153   /// w/wo constraining the vertex according to "fitWithVertex".
1154   /// calculating or not the covariance matrix according to "calcCov".
1155   AliDebug(1,"Enter Fit");
1156   
1157   Double_t benC, errorParam, invBenP, nonBenC, x, y;
1158   AliMUONTrackParam *trackParam;
1159   Double_t arg[1], fedm, errdef, globalChi2;
1160   Int_t npari, nparx;
1161   Int_t status, covStatus;
1162   
1163   // Instantiate gMinuit if not already done
1164   if (!gMinuit) gMinuit = new TMinuit(6);
1165   // Clear MINUIT parameters
1166   gMinuit->mncler();
1167   // Give the fitted track to MINUIT
1168   gMinuit->SetObjectFit(&track);
1169   if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) {
1170     // Define print level
1171     arg[0] = 1;
1172     gMinuit->mnexcm("SET PRI", arg, 1, status);
1173     // Print covariance matrix
1174     gMinuit->mnexcm("SHO COV", arg, 0, status);
1175   } else {
1176     arg[0] = -1;
1177     gMinuit->mnexcm("SET PRI", arg, 1, status);
1178   }
1179   // No warnings
1180   gMinuit->mnexcm("SET NOW", arg, 0, status);
1181   // Define strategy
1182   //arg[0] = 2;
1183   //gMinuit->mnexcm("SET STR", arg, 1, status);
1184   
1185   // set flag w/wo multiple scattering according to "includeMCS"
1186   track.FitWithMCS(includeMCS);
1187   if (includeMCS) {
1188     // compute cluster weights only once
1189     if (!track.ComputeClusterWeights()) {
1190       AliWarning("cannot take into account the multiple scattering effects");
1191       track.FitWithMCS(kFALSE);
1192     }
1193   }
1194   
1195   track.FitWithVertex(fitWithVertex);
1196   if (fitWithVertex) SetVertexErrXY2ForFit(track);
1197   
1198   // Set fitting function
1199   gMinuit->SetFCN(TrackChi2);
1200   
1201   // Set fitted parameters (!! The order is very important for the covariance matrix !!)
1202   // Mandatory limits to avoid NaN values of parameters
1203   trackParam = (AliMUONTrackParam*) (track.GetTrackParamAtCluster()->First());
1204   Double_t maxIBM = 1. / GetRecoParam()->GetMinBendingMomentum();
1205   gMinuit->mnparm(0, "X", trackParam->GetNonBendingCoor(), 0.03, -500.0, 500.0, status);
1206   gMinuit->mnparm(1, "NonBenS", trackParam->GetNonBendingSlope(), 0.001, -1., 1., status);
1207   gMinuit->mnparm(2, "Y", trackParam->GetBendingCoor(), 0.10, -500.0, 500.0, status);
1208   gMinuit->mnparm(3, "BenS", trackParam->GetBendingSlope(), 0.001, -1.5, 1.5, status);
1209   gMinuit->mnparm(4, "InvBenP", trackParam->GetInverseBendingMomentum(), 0.003, -maxIBM, maxIBM, status);
1210   
1211   // minimization
1212   gMinuit->mnexcm("MIGRAD", arg, 0, status);
1213   
1214   // Calculate the covariance matrix more accurately if required
1215   if (calcCov) gMinuit->mnexcm("HESSE", arg, 0, status);
1216    
1217   // get results into "invBenP", "benC", "nonBenC" ("x", "y")
1218   gMinuit->GetParameter(0, x, errorParam);
1219   trackParam->SetNonBendingCoor(x);
1220   gMinuit->GetParameter(1, nonBenC, errorParam);
1221   trackParam->SetNonBendingSlope(nonBenC);
1222   gMinuit->GetParameter(2, y, errorParam);
1223   trackParam->SetBendingCoor(y);
1224   gMinuit->GetParameter(3, benC, errorParam);
1225   trackParam->SetBendingSlope(benC);
1226   gMinuit->GetParameter(4, invBenP, errorParam);
1227   trackParam->SetInverseBendingMomentum(invBenP);
1228   
1229   // global result of the fit
1230   gMinuit->mnstat(globalChi2, fedm, errdef, npari, nparx, covStatus);
1231   track.SetGlobalChi2(globalChi2);
1232   
1233   // Get the covariance matrix if required
1234   if (calcCov) {
1235     // Covariance matrix according to HESSE status
1236     // If problem then keep only the diagonal terms (variances)
1237     Double_t matrix[5][5];
1238     gMinuit->mnemat(&matrix[0][0],5);
1239     if (covStatus == 3) trackParam->SetCovariances(matrix);
1240     else trackParam->SetVariances(matrix);
1241   } else trackParam->DeleteCovariances();
1242   
1243 }
1244
1245   //__________________________________________________________________________
1246 void TrackChi2(Int_t & /*nParam*/, Double_t * /*gradient*/, Double_t &chi2, Double_t *param, Int_t /*flag*/)
1247 {
1248   /// Return the "Chi2" to be minimized with Minuit for track fitting.
1249   /// Assumes that the trackParamAtCluster are sorted according to increasing Z.
1250   /// Track parameters at each cluster are updated accordingly.
1251   /// Vertex is used according to the flag "trackBeingFitted->GetFitWithVertex()".
1252   /// Multiple Coulomb scattering is taken into account according to the flag "trackBeingFitted->GetFitWithMCS()".
1253   
1254   AliMUONTrack *trackBeingFitted = (AliMUONTrack*) gMinuit->GetObjectFit();
1255   AliMUONTrackParam* trackParamAtCluster = (AliMUONTrackParam*) trackBeingFitted->GetTrackParamAtCluster()->First();
1256   Double_t dX, dY;
1257   chi2 = 0.; // initialize chi2
1258   
1259   // update track parameters
1260   trackParamAtCluster->SetNonBendingCoor(param[0]);
1261   trackParamAtCluster->SetNonBendingSlope(param[1]);
1262   trackParamAtCluster->SetBendingCoor(param[2]);
1263   trackParamAtCluster->SetBendingSlope(param[3]);
1264   trackParamAtCluster->SetInverseBendingMomentum(param[4]);
1265   trackBeingFitted->UpdateTrackParamAtCluster();
1266   
1267   // Take the vertex into account in the fit if required
1268   if (trackBeingFitted->FitWithVertex()) {
1269     Double_t nonBendingReso2,bendingReso2;
1270     trackBeingFitted->GetVertexErrXY2(nonBendingReso2,bendingReso2);
1271     if (nonBendingReso2 == 0. || bendingReso2 == 0.) chi2 += 1.e10;
1272     else {
1273       AliMUONTrackParam paramAtVertex(*trackParamAtCluster);
1274       AliMUONTrackExtrap::ExtrapToZ(&paramAtVertex, 0.); // vextex position = (0,0,0)
1275       dX = paramAtVertex.GetNonBendingCoor();
1276       dY = paramAtVertex.GetBendingCoor();
1277       chi2 += dX * dX / nonBendingReso2 + dY * dY / bendingReso2;
1278     }
1279   }
1280   
1281   // compute chi2 w/wo multiple scattering
1282   chi2 += trackBeingFitted->ComputeGlobalChi2(trackBeingFitted->FitWithMCS());
1283   
1284 }
1285
1286   //__________________________________________________________________________
1287 Bool_t AliMUONTrackReconstructor::ComplementTracks(const AliMUONVClusterStore& clusterStore)
1288 {
1289   /// Complete tracks by adding missing clusters (if there is an overlap between
1290   /// two detection elements, the track may have two clusters in the same chamber).
1291   /// Re-fit track parameters and covariances.
1292   /// Return kTRUE if one or more tracks have been complemented.
1293   AliDebug(1,"Enter ComplementTracks");
1294   
1295   Int_t chamberId, detElemId;
1296   Double_t chi2OfCluster, bestChi2OfCluster;
1297   Double_t sigmaCut2 = GetRecoParam()->GetSigmaCutForTracking() *
1298                        GetRecoParam()->GetSigmaCutForTracking();
1299   Bool_t foundOneCluster, trackModified, hasChanged = kFALSE;
1300   AliMUONVCluster* cluster;
1301   AliMUONTrackParam *trackParam, *nextTrackParam, copyOfTrackParam, trackParamAtCluster, bestTrackParamAtCluster;
1302   
1303   AliMUONTrack *track = (AliMUONTrack*) fRecTracksPtr->First();
1304   while (track) {
1305     trackModified = kFALSE;
1306     
1307     trackParam = (AliMUONTrackParam*)track->GetTrackParamAtCluster()->First();
1308     while (trackParam) {
1309       foundOneCluster = kFALSE;
1310       bestChi2OfCluster = 2. * sigmaCut2; // 2 because 2 quantities in chi2
1311       chamberId = trackParam->GetClusterPtr()->GetChamberId();
1312       detElemId = trackParam->GetClusterPtr()->GetDetElemId();
1313       
1314       // prepare nextTrackParam before adding new cluster because of the sorting
1315       nextTrackParam = (AliMUONTrackParam*)track->GetTrackParamAtCluster()->After(trackParam);
1316       
1317       // recover track parameters from local fit and put them into a copy of trackParam
1318       copyOfTrackParam.SetZ(trackParam->GetZ());
1319       copyOfTrackParam.SetParameters(trackParam->GetSmoothParameters());
1320       copyOfTrackParam.SetCovariances(trackParam->GetSmoothCovariances());
1321       
1322       // Create iterators to loop over clusters in current chamber
1323       TIter nextInCh(clusterStore.CreateChamberIterator(chamberId,chamberId));
1324       
1325       // look for one second candidate in the same chamber
1326       while ( ( cluster = static_cast<AliMUONVCluster*>(nextInCh()) ) ) {
1327         
1328         // look for a cluster in another detection element
1329         if (cluster->GetDetElemId() == detElemId) continue;
1330         
1331         // try to add the current cluster fast
1332         if (!TryOneClusterFast(copyOfTrackParam, cluster)) continue;
1333         
1334         // try to add the current cluster accurately
1335         chi2OfCluster = TryOneCluster(copyOfTrackParam, cluster, trackParamAtCluster);
1336         
1337         // if better chi2 then prepare to add this cluster to the track
1338         if (chi2OfCluster < bestChi2OfCluster) {
1339           bestChi2OfCluster = chi2OfCluster;
1340           bestTrackParamAtCluster = trackParamAtCluster;
1341           foundOneCluster = kTRUE;
1342         }
1343         
1344       }
1345       
1346       // add new cluster if any
1347       if (foundOneCluster) {
1348         
1349         // Printout for debuging
1350         if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
1351           cout << "ComplementTracks: found one cluster in chamber(1..): " << chamberId+1 << endl;
1352           bestTrackParamAtCluster.GetClusterPtr()->Print();
1353           cout<<endl<<"Track parameters and covariances at cluster:"<<endl;
1354           bestTrackParamAtCluster.GetParameters().Print();
1355           bestTrackParamAtCluster.GetCovariances().Print();
1356         }
1357         
1358         trackParam->SetRemovable(kTRUE);
1359         bestTrackParamAtCluster.SetRemovable(kTRUE);
1360         track->AddTrackParamAtCluster(bestTrackParamAtCluster,*(bestTrackParamAtCluster.GetClusterPtr()));
1361         trackModified = kTRUE;
1362         hasChanged = kTRUE;
1363       }
1364       
1365       trackParam = nextTrackParam;
1366     }
1367     
1368     // re-fit track parameters if needed
1369     if (trackModified) Fit(*track, kTRUE, kFALSE, kTRUE);
1370     
1371     track = (AliMUONTrack*) fRecTracksPtr->After(track);
1372   }
1373   
1374   return hasChanged;
1375   
1376 }
1377
1378   //__________________________________________________________________________
1379 void AliMUONTrackReconstructor::ImproveTrack(AliMUONTrack &track)
1380 {
1381   /// Improve the given track by removing clusters with local chi2 highter than the defined cut
1382   /// Recompute track parameters and covariances at the remaining clusters
1383   AliDebug(1,"Enter ImproveTrack");
1384   
1385   Double_t localChi2, worstLocalChi2;
1386   AliMUONTrackParam *trackParamAtCluster, *worstTrackParamAtCluster;
1387   Double_t sigmaCut2 = GetRecoParam()->GetSigmaCutForImprovement() *
1388                        GetRecoParam()->GetSigmaCutForImprovement();
1389   
1390   while (!track.IsImproved()) {
1391     
1392     // identify removable clusters
1393     track.TagRemovableClusters(GetRecoParam()->RequestedStationMask());
1394     
1395     // Update track parameters and covariances
1396     track.UpdateCovTrackParamAtCluster();
1397     
1398     // Compute local chi2 of each clusters
1399     track.ComputeLocalChi2(kTRUE);
1400     
1401     // Look for the cluster to remove
1402     worstTrackParamAtCluster = NULL;
1403     worstLocalChi2 = 0.;
1404     trackParamAtCluster = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->First();
1405     while (trackParamAtCluster) {
1406       
1407       // Pick up cluster with the worst chi2
1408       localChi2 = trackParamAtCluster->GetLocalChi2();
1409       if (localChi2 > worstLocalChi2) {
1410         worstLocalChi2 = localChi2;
1411         worstTrackParamAtCluster = trackParamAtCluster;
1412       }
1413       
1414     trackParamAtCluster = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->After(trackParamAtCluster);
1415     }
1416     
1417     // Check if worst cluster found
1418     if (!worstTrackParamAtCluster) {
1419       AliWarning("Bad local chi2 values?");
1420       break;
1421     }
1422     
1423     // Check whether the worst chi2 is under requirement or not
1424     if (worstLocalChi2 < 2. * sigmaCut2) { // 2 because 2 quantities in chi2
1425       track.SetImproved(kTRUE);
1426       break;
1427     }
1428     
1429     // if the worst cluster is not removable then stop improvement
1430     if (!worstTrackParamAtCluster->IsRemovable()) break;
1431     
1432     // Remove the worst cluster
1433     track.RemoveTrackParamAtCluster(worstTrackParamAtCluster);
1434     
1435     // Re-fit the track:
1436     // Take into account the multiple scattering
1437     // Calculate the track parameter covariance matrix
1438     Fit(track, kTRUE, kFALSE, kTRUE);
1439     
1440     // Printout for debuging
1441     if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
1442       cout << "ImproveTracks: track " << fRecTracksPtr->IndexOf(&track)+1 << " improved " << endl;
1443     }
1444     
1445   }
1446   
1447 }
1448
1449   //__________________________________________________________________________
1450 void AliMUONTrackReconstructor::FinalizeTrack(AliMUONTrack &track)
1451 {
1452   /// Recompute track parameters and covariances at each attached cluster
1453   /// from those at the first one, if not already done
1454   AliDebug(1,"Enter FinalizeTrack");
1455   if (!track.IsImproved()) track.UpdateCovTrackParamAtCluster();
1456 }
1457
1458   //__________________________________________________________________________
1459 Bool_t AliMUONTrackReconstructor::RefitTrack(AliMUONTrack &track, Bool_t enableImprovement)
1460 {
1461   /// re-fit the given track
1462   
1463   // check validity of the track
1464   if (track.GetNClusters() < 3) {
1465     AliWarning("the track does not contain enough clusters --> unable to refit");
1466     return kFALSE;
1467   }
1468   
1469   // reset the seed (i.e. parameters at first cluster) before fitting
1470   AliMUONTrackParam* firstTrackParam = (AliMUONTrackParam*) track.GetTrackParamAtCluster()->First();
1471   if (firstTrackParam->GetInverseBendingMomentum() == 0.) {
1472     AliWarning("track parameters at first chamber are not initialized --> unable to refit");
1473     return kFALSE;
1474   }
1475   
1476   // compute track parameters at each cluster from parameters at the first one
1477   // necessary to compute multiple scattering effect during refitting
1478   track.UpdateTrackParamAtCluster();
1479   
1480   // Re-fit the track:
1481   // Take into account the multiple scattering
1482   // Calculate the track parameter covariance matrix
1483   Fit(track, kTRUE, kFALSE, kTRUE);
1484   
1485   // Improve the reconstructed tracks if required
1486   track.SetImproved(kFALSE);
1487   if (enableImprovement && GetRecoParam()->ImproveTracks()) ImproveTrack(track);
1488   
1489   // Fill AliMUONTrack data members
1490   FinalizeTrack(track);
1491   
1492   return kTRUE;
1493   
1494 }
1495