]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTrackReconstructor.cxx
Using common definition of gas mixture ArCO280. In the old defintion of ArCO2 (medium...
[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 "AliMUONHitForRec.h"
33 #include "AliMUONTrack.h"
34 #include "AliMUONTrackParam.h"
35 #include "AliMUONTrackExtrap.h"
36 #include "AliLog.h"
37
38 #include <TMinuit.h>
39 #include <Riostream.h>
40 #include <TMath.h>
41 #include <TMatrixD.h>
42
43 // Functions to be minimized with Minuit
44 void TrackChi2(Int_t &nParam, Double_t *gradient, Double_t &chi2, Double_t *param, Int_t flag);
45
46 /// \cond CLASSIMP
47 ClassImp(AliMUONTrackReconstructor) // Class implementation in ROOT context
48 /// \endcond
49
50 //************* Parameters for reconstruction
51 const Double_t AliMUONTrackReconstructor::fgkBendingVertexDispersion = 10.;
52 const Double_t AliMUONTrackReconstructor::fgkNonBendingVertexDispersion = 10.;
53
54
55   //__________________________________________________________________________
56 AliMUONTrackReconstructor::AliMUONTrackReconstructor()
57   : AliMUONVTrackReconstructor()
58 {
59   /// Constructor for class AliMUONTrackReconstructor
60   AliInfo("*** Original tracking ***");
61 }
62
63   //__________________________________________________________________________
64 AliMUONTrackReconstructor::~AliMUONTrackReconstructor()
65 {
66 /// Destructor
67
68
69   //__________________________________________________________________________
70 void AliMUONTrackReconstructor::MakeTrackCandidates()
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 hitForRec's.
75   /// Keep only best candidates or all of them according to the flag fgkTrackAllTracks.
76   TClonesArray *segments;
77   AliMUONTrack *track;
78   Int_t iCandidate = 0;
79   Bool_t hitFound;
80
81   AliDebug(1,"Enter MakeTrackCandidates");
82
83   // Loop over stations(1..) 5 and 4 and make track candidates
84   for (Int_t istat=4; istat>=3; istat--) {
85     
86     // Make segments in the station
87     segments = MakeSegmentsInStation(istat);
88     
89     // Loop over segments
90     for (Int_t iseg=0; iseg<segments->GetEntriesFast(); iseg++) 
91     {
92       AliDebug(1,Form("Making primary candidate(1..) %d",++iCandidate));
93       
94       // Transform segments to tracks and put them at the end of fRecTracksPtr
95       track = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack((AliMUONObjectPair*)((*segments)[iseg]));
96       fNRecTracks++;
97       
98       // Printout for debuging
99       if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2))
100       {
101         cout<<endl<<"Track parameter covariances at first hit with multiple Coulomb scattering effects:"<<endl;
102         ((AliMUONTrackParam*) track->GetTrackParamAtHit()->First())->GetCovariances().Print();
103       }
104       
105       // Look for compatible hitForRec(s) in the other station
106       if (fgkMakeTrackCandidatesFast) hitFound = FollowLinearTrackInStation(*track,7-istat);
107       else hitFound = FollowTrackInStation(*track,7-istat);
108       
109       // Remove track if no hit found
110       if (!hitFound) {
111         fRecTracksPtr->Remove(track);
112         fNRecTracks--;
113       }
114       
115     }
116     
117     // delete the array of segments
118     delete segments;
119   }
120   
121   fRecTracksPtr->Compress(); // this is essential before checking tracks
122   
123   // Keep all different tracks or only the best ones as required
124   if (fgkTrackAllTracks) RemoveIdenticalTracks();
125   else RemoveDoubleTracks();
126   
127   AliDebug(1,Form("Number of good candidates = %d",fNRecTracks));
128   
129 }
130
131   //__________________________________________________________________________
132 void AliMUONTrackReconstructor::FollowTracks()
133 {
134   /// Follow tracks in stations(1..) 3, 2 and 1
135   AliDebug(1,"Enter FollowTracks");
136   
137   AliMUONTrack *track, *nextTrack;
138   Int_t currentNRecTracks;
139   Bool_t hitFound;
140   
141   for (Int_t station = 2; station >= 0; station--) {
142     
143     // Save the actual number of reconstructed track in case of
144     // tracks are added or suppressed during the tracking procedure
145     // !! Do not compress fRecTracksPtr until the end of the loop over tracks !!
146     currentNRecTracks = fNRecTracks;
147     
148     for (Int_t iRecTrack = 0; iRecTrack <currentNRecTracks; iRecTrack++) {
149       AliDebug(1,Form("FollowTracks: track candidate(1..) %d", iRecTrack+1));
150       
151       track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iRecTrack);
152       
153       // Fit the track:
154       // Do not take into account the multiple scattering to speed up the fit
155       // Calculate the track parameter covariance matrix
156       // If "station" is station(1..) 3 then use the vertex to better constrain the fit
157       if (station==2) {
158         SetVertexForFit(*track);
159         track->SetFitWithVertex(kTRUE);
160       } else track->SetFitWithVertex(kFALSE);
161       Fit(*track, kFALSE, kTRUE);
162       
163       // Remove the track if the normalized chi2 is too high
164       if (track->GetNormalizedChi2() > fgkSigmaToCutForTracking * fgkSigmaToCutForTracking) {
165         fRecTracksPtr->Remove(track);
166         fNRecTracks--;
167         continue;
168       }
169       
170       // Printout for debuging
171       if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) {
172         cout<<endl<<"Track parameter covariances at first hit with multiple Coulomb scattering effects:"<<endl;
173         ((AliMUONTrackParam*) track->GetTrackParamAtHit()->First())->GetCovariances().Print();
174       }
175       
176       // Look for compatible hitForRec in station(0..) "station"
177       hitFound = FollowTrackInStation(*track,station);
178       
179       // Try to recover track if required
180       if (!hitFound && fgkRecoverTracks) hitFound = RecoverTrack(*track,station);
181       
182       // remove track if no hit found
183       if (!hitFound) {
184         fRecTracksPtr->Remove(track);
185         fNRecTracks--;
186       }
187       
188     }
189     
190     // Compress fRecTracksPtr for the next step
191     fRecTracksPtr->Compress();
192     
193     // Keep only the best tracks if required
194     if (!fgkTrackAllTracks) RemoveDoubleTracks();
195     
196   }
197   
198   // Last fit of track candidates with all station
199   // Take into account the multiple scattering and remove bad tracks
200   Int_t trackIndex = -1;
201   track = (AliMUONTrack*) fRecTracksPtr->First();
202   while (track) {
203     
204     trackIndex++;
205     nextTrack = (AliMUONTrack*) fRecTracksPtr->After(track); // prepare next track
206     
207     track->SetFitWithVertex(kFALSE); // just to be sure
208     Fit(*track, kTRUE, kTRUE);
209     
210     // Printout for debuging
211     if (AliLog::GetGlobalDebugLevel() >= 3) {
212       cout << "FollowTracks: track candidate(0..) " << trackIndex << " after final fit" << endl;
213       track->RecursiveDump();
214     } 
215     
216     // Remove the track if the normalized chi2 is too high
217     if (track->GetNormalizedChi2() > fgkSigmaToCutForTracking * fgkSigmaToCutForTracking) {
218       fRecTracksPtr->Remove(track);
219       fNRecTracks--;
220     }
221     
222     track = nextTrack;
223     
224   }
225   
226   fRecTracksPtr->Compress();
227   
228 }
229
230   //__________________________________________________________________________
231 Bool_t AliMUONTrackReconstructor::FollowTrackInStation(AliMUONTrack &trackCandidate, Int_t nextStation)
232 {
233   /// Follow trackCandidate in station(0..) nextStation and search for compatible HitForRec(s)
234   /// Keep all possibilities or only the best one(s) according to the flag fgkTrackAllTracks:
235   /// kTRUE:  duplicate "trackCandidate" if there are several possibilities and add the new tracks at the end of
236   ///         fRecTracksPtr to avoid conficts with other track candidates at this current stage of the tracking procedure.
237   ///         Remove the obsolete "trackCandidate" at the end.
238   /// kFALSE: add only the best hit(s) to the "trackCandidate". Try to add a couple of hits in priority.
239   AliDebug(1,Form("Enter FollowTrackInStation(1..) %d", nextStation+1));
240   
241   // Order the chamber according to the propagation direction (tracking starts with chamber 2):
242   // - nextStation == station(1...) 5 => forward propagation
243   // - nextStation < station(1...) 5 => backward propagation
244   Int_t ch1, ch2;
245   if (nextStation==4) {
246     ch1 = 2*nextStation+1;
247     ch2 = 2*nextStation;
248   } else {
249     ch1 = 2*nextStation;
250     ch2 = 2*nextStation+1;
251   }
252   
253   Double_t chi2WithOneHitForRec = 1.e10;
254   Double_t chi2WithTwoHitForRec = 1.e10;
255   Double_t maxChi2WithOneHitForRec = 2. * fgkSigmaToCutForTracking * fgkSigmaToCutForTracking; // 2 because 2 quantities in chi2
256   Double_t maxChi2WithTwoHitForRec = 4. * fgkSigmaToCutForTracking * fgkSigmaToCutForTracking; // 4 because 4 quantities in chi2
257   Double_t bestChi2WithOneHitForRec = maxChi2WithOneHitForRec;
258   Double_t bestChi2WithTwoHitForRec = maxChi2WithTwoHitForRec;
259   Bool_t foundOneHit = kFALSE;
260   Bool_t foundTwoHits = kFALSE;
261   AliMUONTrack *newTrack = 0x0;
262   AliMUONHitForRec *hitForRecCh1, *hitForRecCh2;
263   AliMUONTrackParam extrapTrackParam;
264   AliMUONTrackParam extrapTrackParamAtHit1;
265   AliMUONTrackParam extrapTrackParamAtHit2;
266   AliMUONTrackParam bestTrackParamAtHit1;
267   AliMUONTrackParam bestTrackParamAtHit2;
268   Bool_t *hitForRecCh1Used = new Bool_t[fNHitsForRecPerChamber[ch1]];
269   for (Int_t hit1 = 0; hit1 < fNHitsForRecPerChamber[ch1]; hit1++) hitForRecCh1Used[hit1] = kFALSE;
270   
271   // Get track parameters
272   AliMUONTrackParam extrapTrackParamAtCh(*(AliMUONTrackParam*)trackCandidate.GetTrackParamAtHit()->First());
273   
274   // Add MCS effect
275   AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.);
276   
277   // Add MCS in the missing chamber if any (only 1 chamber can be missing according to tracking criteria)
278   if (ch1 < ch2 && extrapTrackParamAtCh.GetHitForRecPtr()->GetChamberNumber() > ch2 + 1) {
279     // extrapolation to the missing chamber
280     AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch2 + 1));
281     // add MCS effect
282     AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.);
283   }
284   
285   //Extrapolate trackCandidate to chamber "ch2"
286   AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch2));
287   
288   // Printout for debuging
289   if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) {
290     cout<<endl<<"Track parameter covariances at first hit extrapolated to z = "<<AliMUONConstants::DefaultChamberZ(ch2)<<":"<<endl;
291     extrapTrackParamAtCh.GetCovariances().Print();
292   }
293   
294   // Printout for debuging
295   if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
296     cout << "FollowTrackInStation: look for hits in chamber(1..): " << ch2+1 << endl;
297   }
298   
299   // look for candidates in chamber 2 
300   for (Int_t hit2 = 0; hit2 < fNHitsForRecPerChamber[ch2]; hit2++) {
301     
302     hitForRecCh2 = (AliMUONHitForRec*) fHitsForRecPtr->UncheckedAt(fIndexOfFirstHitForRecPerChamber[ch2]+hit2);
303     
304     // try to add the current hit fast
305     if (!TryOneHitForRecFast(extrapTrackParamAtCh, hitForRecCh2)) continue;
306     
307     // try to add the current hit accuratly
308     chi2WithOneHitForRec = TryOneHitForRec(extrapTrackParamAtCh, hitForRecCh2, extrapTrackParamAtHit2);
309     
310     // if good chi2 then try to attach a hitForRec in the other chamber too
311     if (chi2WithOneHitForRec < maxChi2WithOneHitForRec) {
312       Bool_t foundSecondHit = kFALSE;
313       
314       // Printout for debuging
315       if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
316         cout << "FollowTrackInStation: found one hit in chamber(1..): " << ch2+1
317              << " (Chi2 = " << chi2WithOneHitForRec << ")" << endl;
318         cout << "                      look for second hits in chamber(1..): " << ch1+1 << " ..." << endl;
319       }
320       
321       // add MCS effect for next step
322       AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtHit2,AliMUONConstants::ChamberThicknessInX0(),1.);
323       
324       // copy new track parameters for next step
325       extrapTrackParam = extrapTrackParamAtHit2;
326       
327       //Extrapolate track parameters to chamber "ch1"
328       AliMUONTrackExtrap::ExtrapToZ(&extrapTrackParam, AliMUONConstants::DefaultChamberZ(ch1));
329       
330       for (Int_t hit1 = 0; hit1 < fNHitsForRecPerChamber[ch1]; hit1++) {
331         
332         hitForRecCh1 = (AliMUONHitForRec*) fHitsForRecPtr->UncheckedAt(fIndexOfFirstHitForRecPerChamber[ch1]+hit1);
333         
334         // try to add the current hit fast
335         if (!TryOneHitForRecFast(extrapTrackParam, hitForRecCh1)) continue;
336         
337         // try to add the current hit accuratly
338         chi2WithTwoHitForRec = TryTwoHitForRec(extrapTrackParamAtHit2, hitForRecCh1, extrapTrackParamAtHit1);
339         
340         // if good chi2 then create a new track by adding the 2 hitForRec to the "trackCandidate"
341         if (chi2WithTwoHitForRec < maxChi2WithTwoHitForRec) {
342           foundSecondHit = kTRUE;
343           foundTwoHits = kTRUE;
344           
345           // Printout for debuging
346           if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
347             cout << "FollowTrackInStation: found second hit in chamber(1..): " << ch1+1
348                  << " (Global Chi2 = " << chi2WithTwoHitForRec << ")" << endl;
349           }
350           
351           if (fgkTrackAllTracks) {
352             // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new hitForRec's
353             newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
354             UpdateTrack(*newTrack,extrapTrackParamAtHit1,extrapTrackParamAtHit2);
355             fNRecTracks++;
356             
357             // Tag hitForRecCh1 as used
358             hitForRecCh1Used[hit1] = kTRUE;
359             
360             // Printout for debuging
361             if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
362               cout << "FollowTrackInStation: added two hits in station(1..): " << nextStation+1 << endl;
363               if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
364             }
365             
366           } else if (chi2WithTwoHitForRec < bestChi2WithTwoHitForRec) {
367             // keep track of the best couple of hits
368             bestChi2WithTwoHitForRec = chi2WithTwoHitForRec;
369             bestTrackParamAtHit1 = extrapTrackParamAtHit1;
370             bestTrackParamAtHit2 = extrapTrackParamAtHit2;
371           }
372           
373         }
374         
375       }
376       
377       // if no hitForRecCh1 found then consider to add hitForRecCh2 only
378       if (!foundSecondHit) {
379         foundOneHit = kTRUE;
380         
381         if (fgkTrackAllTracks) {
382           // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new hitForRec's
383           newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
384           UpdateTrack(*newTrack,extrapTrackParamAtHit2);
385           fNRecTracks++;
386           
387           // Printout for debuging
388           if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
389             cout << "FollowTrackInStation: added one hit in chamber(1..): " << ch2+1 << endl;
390             if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
391           }
392           
393         } else if (!foundTwoHits && chi2WithOneHitForRec < bestChi2WithOneHitForRec) {
394           // keep track of the best single hitForRec except if a couple of hits has already been found
395           bestChi2WithOneHitForRec = chi2WithOneHitForRec;
396           bestTrackParamAtHit1 = extrapTrackParamAtHit2;
397         }
398         
399       }
400       
401     }
402     
403   }
404   
405   // look for candidates in chamber 1 not already attached to a track
406   // if we want to keep all possible tracks or if no good couple of hitForRec has been found
407   if (fgkTrackAllTracks || !foundTwoHits) {
408     
409     // Printout for debuging
410     if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
411       cout << "FollowTrackInStation: look for single hits in chamber(1..): " << ch1+1 << endl;
412     }
413     
414     // add MCS effect for next step
415     AliMUONTrackExtrap::AddMCSEffect(&extrapTrackParamAtCh,AliMUONConstants::ChamberThicknessInX0(),1.);
416     
417     //Extrapolate trackCandidate to chamber "ch1"
418     AliMUONTrackExtrap::ExtrapToZCov(&extrapTrackParamAtCh, AliMUONConstants::DefaultChamberZ(ch1));
419     
420     for (Int_t hit1 = 0; hit1 < fNHitsForRecPerChamber[ch1]; hit1++) {
421       
422       hitForRecCh1 = (AliMUONHitForRec*) fHitsForRecPtr->UncheckedAt(fIndexOfFirstHitForRecPerChamber[ch1]+hit1);
423       
424       if (hitForRecCh1Used[hit1]) continue; // Skip hitForRec already used
425       
426       // try to add the current hit fast
427       if (!TryOneHitForRecFast(extrapTrackParamAtCh, hitForRecCh1)) continue;
428       
429       // try to add the current hit accuratly
430       chi2WithOneHitForRec = TryOneHitForRec(extrapTrackParamAtCh, hitForRecCh1, extrapTrackParamAtHit1);
431     
432       // if good chi2 then consider to add hitForRecCh1
433       // We do not try to attach a hitForRec in the other chamber too since it has already been done above
434       if (chi2WithOneHitForRec < maxChi2WithOneHitForRec) {
435         foundOneHit = kTRUE;
436           
437         // Printout for debuging
438         if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
439           cout << "FollowTrackInStation: found one hit in chamber(1..): " << ch1+1
440                << " (Chi2 = " << chi2WithOneHitForRec << ")" << endl;
441         }
442         
443         if (fgkTrackAllTracks) {
444           // copy trackCandidate into a new track put at the end of fRecTracksPtr and add the new hitForRec's
445           newTrack = new ((*fRecTracksPtr)[fRecTracksPtr->GetLast()+1]) AliMUONTrack(trackCandidate);
446           UpdateTrack(*newTrack,extrapTrackParamAtHit1);
447           fNRecTracks++;
448           
449           // Printout for debuging
450           if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
451             cout << "FollowTrackInStation: added one hit in chamber(1..): " << ch1+1 << endl;
452             if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
453           }
454           
455         } else if (chi2WithOneHitForRec < bestChi2WithOneHitForRec) {
456           // keep track of the best single hitForRec except if a couple of hits has already been found
457           bestChi2WithOneHitForRec = chi2WithOneHitForRec;
458           bestTrackParamAtHit1 = extrapTrackParamAtHit1;
459         }
460         
461       }
462       
463     }
464     
465   }
466   
467   // fill out the best track if required else clean up the fRecTracksPtr array
468   if (!fgkTrackAllTracks) {
469     if (foundTwoHits) {
470       UpdateTrack(trackCandidate,bestTrackParamAtHit1,bestTrackParamAtHit2);
471       
472       // Printout for debuging
473       if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
474         cout << "FollowTrackInStation: added the two best hits in station(1..): " << nextStation+1 << endl;
475         if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
476       }
477       
478     } else if (foundOneHit) {
479       UpdateTrack(trackCandidate,bestTrackParamAtHit1);
480       
481       // Printout for debuging
482       if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
483         cout << "FollowTrackInStation: added the best hit in chamber(1..): " << bestTrackParamAtHit1.GetHitForRecPtr()->GetChamberNumber()+1 << endl;
484         if (AliLog::GetGlobalDebugLevel() >= 3) newTrack->RecursiveDump();
485       }
486       
487     } else {
488       delete [] hitForRecCh1Used;
489       return kFALSE;
490     }
491     
492   } else if (foundOneHit || foundTwoHits) {
493     
494     // remove obsolete track
495     fRecTracksPtr->Remove(&trackCandidate);
496     fNRecTracks--;
497     
498   } else {
499     delete [] hitForRecCh1Used;
500     return kFALSE;
501   }
502   
503   delete [] hitForRecCh1Used;
504   return kTRUE;
505   
506 }
507
508   //__________________________________________________________________________
509 Double_t AliMUONTrackReconstructor::TryTwoHitForRec(const AliMUONTrackParam &trackParamAtHit1, AliMUONHitForRec* hitForRec2,
510                                                     AliMUONTrackParam &trackParamAtHit2)
511 {
512 /// Test the compatibility between the track and the 2 hitForRec together (using trackParam's covariance matrix):
513 /// return the corresponding Chi2 accounting for covariances between the 2 hitForRec
514 /// return trackParamAtHit1 & 2
515   
516   // extrapolate track parameters at the z position of the second hit
517   trackParamAtHit2.SetParameters(trackParamAtHit1.GetParameters());
518   trackParamAtHit2.SetZ(trackParamAtHit1.GetZ());
519   AliMUONTrackExtrap::ExtrapToZ(&trackParamAtHit2, hitForRec2->GetZ());
520   
521   // set pointer to hit2 into trackParamAtHit2
522   trackParamAtHit2.SetHitForRecPtr(hitForRec2);
523   
524   // Set differences between track and the 2 hitForRec in the bending and non bending directions
525   AliMUONHitForRec* hitForRec1 = trackParamAtHit1.GetHitForRecPtr();
526   TMatrixD dPos(4,1);
527   dPos(0,0) = hitForRec1->GetNonBendingCoor() - trackParamAtHit1.GetNonBendingCoor();
528   dPos(1,0) = hitForRec1->GetBendingCoor() - trackParamAtHit1.GetBendingCoor();
529   dPos(2,0) = hitForRec2->GetNonBendingCoor() - trackParamAtHit2.GetNonBendingCoor();
530   dPos(3,0) = hitForRec2->GetBendingCoor() - trackParamAtHit2.GetBendingCoor();
531   
532   // Calculate the error matrix from the track parameter covariances at first hitForRec
533   TMatrixD error(4,4);
534   error.Zero();
535   if (trackParamAtHit1.CovariancesExist()) {
536     // Save track parameters at first hitForRec
537     AliMUONTrackParam trackParamAtHit1Save(trackParamAtHit1);
538     TMatrixD paramAtHit1Save(trackParamAtHit1Save.GetParameters());
539     Double_t z1 = trackParamAtHit1Save.GetZ();
540     
541     // Save track coordinates at second hitForRec
542     Double_t nonBendingCoor2         = trackParamAtHit2.GetNonBendingCoor();
543     Double_t bendingCoor2            = trackParamAtHit2.GetBendingCoor();
544     
545     // add MCS effect at first hitForRec
546     AliMUONTrackExtrap::AddMCSEffect(&trackParamAtHit1Save,AliMUONConstants::ChamberThicknessInX0(),1.);
547     
548     // Get the pointer to the parameter covariance matrix at first hitForRec
549     const TMatrixD& kParamCov = trackParamAtHit1Save.GetCovariances();
550     
551     // Calculate the jacobian related to the transformation between track parameters
552     // at first hitForRec and track coordinates at the 2 hitForRec z-position
553     TMatrixD jacob(4,5);
554     jacob.Zero();
555     // first derivative at the first hitForRec:
556     jacob(0,0) = 1.; // dx1/dx
557     jacob(1,2) = 1.; // dy1/dy
558     // first derivative at the second hitForRec:
559     TMatrixD dParam(5,1);
560     for (Int_t i=0; i<5; i++) {
561       // Skip jacobian calculation for parameters with no associated error
562       if (kParamCov(i,i) == 0.) continue;
563       // Small variation of parameter i only
564       for (Int_t j=0; j<5; j++) {
565         if (j==i) {
566           dParam(j,0) = TMath::Sqrt(kParamCov(i,i));
567           if (j == 4) dParam(j,0) *= TMath::Sign(1.,-paramAtHit1Save(4,0)); // variation always in the same direction
568         } else dParam(j,0) = 0.;
569       }
570       
571       // Set new track parameters at first hitForRec
572       trackParamAtHit1Save.SetParameters(paramAtHit1Save);
573       trackParamAtHit1Save.AddParameters(dParam);
574       trackParamAtHit1Save.SetZ(z1);
575       
576       // Extrapolate new track parameters to the z position of the second hitForRec
577       AliMUONTrackExtrap::ExtrapToZ(&trackParamAtHit1Save,hitForRec2->GetZ());
578       
579       // Calculate the jacobian
580       jacob(2,i) = (trackParamAtHit1Save.GetNonBendingCoor()  - nonBendingCoor2) / dParam(i,0); // dx2/dParami
581       jacob(3,i) = (trackParamAtHit1Save.GetBendingCoor()     - bendingCoor2   ) / dParam(i,0); // dy2/dParami
582     }
583     
584     // Calculate the error matrix
585     TMatrixD tmp(jacob,TMatrixD::kMult,kParamCov);
586     error = TMatrixD(tmp,TMatrixD::kMultTranspose,jacob);
587   }
588   
589   // Add hitForRec resolution to the error matrix
590   error(0,0) += hitForRec1->GetNonBendingReso2();
591   error(1,1) += hitForRec1->GetBendingReso2();
592   error(2,2) += hitForRec2->GetNonBendingReso2();
593   error(3,3) += hitForRec2->GetBendingReso2();
594   
595   // invert the error matrix for Chi2 calculation
596   if (error.Determinant() != 0) {
597     error.Invert();
598   } else {
599     AliWarning(" Determinant error=0");
600     return 1.e10;
601   }
602   
603   // Compute the Chi2 value
604   TMatrixD tmp2(dPos,TMatrixD::kTransposeMult,error);
605   TMatrixD result(tmp2,TMatrixD::kMult,dPos);
606   
607   return result(0,0);
608   
609 }
610
611   //__________________________________________________________________________
612 void AliMUONTrackReconstructor::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtHit)
613 {
614   /// Add 1 hit to the track candidate
615   /// Update chi2 of the track 
616   
617   // Compute local chi2
618   AliMUONHitForRec* hit = trackParamAtHit.GetHitForRecPtr();
619   Double_t deltaX = trackParamAtHit.GetNonBendingCoor() - hit->GetNonBendingCoor();
620   Double_t deltaY = trackParamAtHit.GetBendingCoor() - hit->GetBendingCoor();
621   Double_t localChi2 = deltaX*deltaX / hit->GetNonBendingReso2() +
622                        deltaY*deltaY / hit->GetBendingReso2();
623   
624   // Flag hit as being not removable
625   trackParamAtHit.SetRemovable(kFALSE);
626   trackParamAtHit.SetLocalChi2(0.); // --> Local chi2 not used
627   
628   // Update the chi2 of the new track
629   track.SetFitFMin(track.GetFitFMin() + localChi2);
630   
631   // Update TrackParamAtHit
632   track.AddTrackParamAtHit(&trackParamAtHit,trackParamAtHit.GetHitForRecPtr());
633   track.GetTrackParamAtHit()->Sort();
634   
635 }
636
637   //__________________________________________________________________________
638 void AliMUONTrackReconstructor::UpdateTrack(AliMUONTrack &track, AliMUONTrackParam &trackParamAtHit1, AliMUONTrackParam &trackParamAtHit2)
639 {
640   /// Add 2 hits to the track candidate
641   /// Update track and local chi2
642   
643   // Update local chi2 at first hit
644   AliMUONHitForRec* hit1 = trackParamAtHit1.GetHitForRecPtr();
645   Double_t deltaX = trackParamAtHit1.GetNonBendingCoor() - hit1->GetNonBendingCoor();
646   Double_t deltaY = trackParamAtHit1.GetBendingCoor() - hit1->GetBendingCoor();
647   Double_t localChi2AtHit1 = deltaX*deltaX / hit1->GetNonBendingReso2() +
648                              deltaY*deltaY / hit1->GetBendingReso2();
649   trackParamAtHit1.SetLocalChi2(localChi2AtHit1);
650   
651   // Flag first hit as being removable
652   trackParamAtHit1.SetRemovable(kTRUE);
653   
654   // Update local chi2 at second hit
655   AliMUONHitForRec* hit2 = trackParamAtHit2.GetHitForRecPtr();
656   deltaX = trackParamAtHit2.GetNonBendingCoor() - hit2->GetNonBendingCoor();
657   deltaY = trackParamAtHit2.GetBendingCoor() - hit2->GetBendingCoor();
658   Double_t localChi2AtHit2 = deltaX*deltaX / hit2->GetNonBendingReso2() +
659                              deltaY*deltaY / hit2->GetBendingReso2();
660   trackParamAtHit2.SetLocalChi2(localChi2AtHit2);
661   
662   // Flag first hit as being removable
663   trackParamAtHit2.SetRemovable(kTRUE);
664   
665   // Update the chi2 of the new track
666   track.SetFitFMin(track.GetFitFMin() + localChi2AtHit1 + localChi2AtHit2);
667   
668   // Update TrackParamAtHit
669   track.AddTrackParamAtHit(&trackParamAtHit1,trackParamAtHit1.GetHitForRecPtr());
670   track.AddTrackParamAtHit(&trackParamAtHit2,trackParamAtHit2.GetHitForRecPtr());
671   track.GetTrackParamAtHit()->Sort();
672   
673 }
674
675   //__________________________________________________________________________
676 Bool_t AliMUONTrackReconstructor::RecoverTrack(AliMUONTrack &trackCandidate, Int_t nextStation)
677 {
678   /// Try to recover the track candidate in the next station
679   /// by removing the worst of the two hits attached in the current station
680   /// Return kTRUE if recovering succeeds
681   AliDebug(1,"Enter RecoverTrack");
682   
683   // Do not try to recover track until we have attached hit(s) on station(1..) 3
684   if (nextStation > 1) return kFALSE;
685   
686   Int_t worstHitNumber = -1;
687   Double_t localChi2, worstLocalChi2 = 0.;
688   
689   // Look for the hit to remove
690   for (Int_t hitNumber = 0; hitNumber < 2; hitNumber++) {
691     AliMUONTrackParam *trackParamAtHit = (AliMUONTrackParam*)trackCandidate.GetTrackParamAtHit()->UncheckedAt(hitNumber);
692     
693     // check if current hit is removable
694     if (!trackParamAtHit->IsRemovable()) return kFALSE;
695     
696     // Pick up hit with the worst chi2
697     localChi2 = trackParamAtHit->GetLocalChi2();
698     if (localChi2 > worstLocalChi2) {
699       worstLocalChi2 = localChi2;
700       worstHitNumber = hitNumber;
701     }
702   }
703   
704   // Reset best hit as being NOT removable
705   ((AliMUONTrackParam*)trackCandidate.GetTrackParamAtHit()->UncheckedAt((worstHitNumber+1)%2))->SetRemovable(kFALSE);
706   
707   // Remove the worst hit
708   trackCandidate.RemoveTrackParamAtHit((AliMUONTrackParam*)trackCandidate.GetTrackParamAtHit()->UncheckedAt(worstHitNumber));
709   
710   // Re-fit the track:
711   // Do not take into account the multiple scattering to speed up the fit
712   // Calculate the track parameter covariance matrix
713   trackCandidate.SetFitWithVertex(kFALSE); // To be sure
714   Fit(trackCandidate, kFALSE, kTRUE);
715   
716   // Look for new hit(s) in next station
717   return FollowTrackInStation(trackCandidate,nextStation);
718   
719 }
720
721   //__________________________________________________________________________
722 void AliMUONTrackReconstructor::SetVertexForFit(AliMUONTrack &trackCandidate)
723 {
724   /// Add the vertex as a measured hit to constrain the fit of the "trackCandidate"
725   /// Compute the vertex resolution from natural vertex dispersion and
726   /// multiple scattering effets according to trackCandidate path in absorber
727   /// It is necessary to account for multiple scattering effects here instead of during the fit of
728   /// the "trackCandidate" to do not influence the result by changing track resolution at vertex
729   AliDebug(1,"Enter SetVertexForFit");
730   
731   Double_t nonBendingReso2 = fgkNonBendingVertexDispersion * fgkNonBendingVertexDispersion;
732   Double_t bendingReso2 = fgkBendingVertexDispersion * fgkBendingVertexDispersion;
733   // add multiple scattering effets
734   AliMUONTrackParam paramAtVertex(*((AliMUONTrackParam*)(trackCandidate.GetTrackParamAtHit()->First())));
735   paramAtVertex.DeleteCovariances(); // to be sure to account only for multiple scattering
736   AliMUONTrackExtrap::ExtrapToVertexUncorrected(&paramAtVertex,0.);
737   const TMatrixD& kParamCov = paramAtVertex.GetCovariances();
738   nonBendingReso2 += kParamCov(0,0);
739   bendingReso2 += kParamCov(2,2);
740   // Set the vertex
741   AliMUONHitForRec vertex; // Coordinates set to (0.,0.,0.) by default
742   vertex.SetNonBendingReso2(nonBendingReso2);
743   vertex.SetBendingReso2(bendingReso2);
744   trackCandidate.SetVertex(&vertex);
745 }
746
747   //__________________________________________________________________________
748 void AliMUONTrackReconstructor::Fit(AliMUONTrack &track, Bool_t includeMCS, Bool_t calcCov)
749 {
750   /// Fit the track "track" w/wo multiple Coulomb scattering according to "includeMCS".
751   
752   Double_t benC, errorParam, invBenP, nonBenC, x, y;
753   AliMUONTrackParam *trackParam;
754   Double_t arg[1], fedm, errdef, fitFMin;
755   Int_t npari, nparx;
756   Int_t status, covStatus;
757   
758   // Instantiate gMinuit if not already done
759   if (!gMinuit) gMinuit = new TMinuit(6);
760   // Clear MINUIT parameters
761   gMinuit->mncler();
762   // Give the fitted track to MINUIT
763   gMinuit->SetObjectFit(&track);
764   if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 2) || (AliLog::GetGlobalDebugLevel() >= 2)) {
765     // Define print level
766     arg[0] = 1;
767     gMinuit->mnexcm("SET PRI", arg, 1, status);
768     // Print covariance matrix
769     gMinuit->mnexcm("SHO COV", arg, 0, status);
770   } else {
771     arg[0] = -1;
772     gMinuit->mnexcm("SET PRI", arg, 1, status);
773   }
774   // No warnings
775   gMinuit->mnexcm("SET NOW", arg, 0, status);
776   // Define strategy
777   //arg[0] = 2;
778   //gMinuit->mnexcm("SET STR", arg, 1, status);
779   
780   // set flag w/wo multiple scattering according to "includeMCS"
781   track.SetFitWithMCS(includeMCS);
782   if (includeMCS) {
783     // compute hit weights only once
784     if (!track.ComputeHitWeights()) {
785       AliWarning("cannot take into account the multiple scattering effects");
786       track.SetFitWithMCS(kFALSE);
787     }
788   }
789   
790   // Set fitting function
791   gMinuit->SetFCN(TrackChi2);
792   
793   // Set fitted parameters (!! The order is very important for the covariance matrix !!)
794   trackParam = (AliMUONTrackParam*) (track.GetTrackParamAtHit()->First());
795   // could be tried with no limits for the search (min=max=0) ????
796   // mandatory limits in non Bending to avoid NaN values of parameters
797   gMinuit->mnparm(0, "X", trackParam->GetNonBendingCoor(), 0.03, -500.0, 500.0, status);
798   gMinuit->mnparm(1, "NonBenS", trackParam->GetNonBendingSlope(), 0.001, -0.5, 0.5, status);
799   // mandatory limits in Bending to avoid NaN values of parameters
800   gMinuit->mnparm(2, "Y", trackParam->GetBendingCoor(), 0.10, -500.0, 500.0, status);
801   gMinuit->mnparm(3, "BenS", trackParam->GetBendingSlope(), 0.001, -0.5, 0.5, status);
802   gMinuit->mnparm(4, "InvBenP", trackParam->GetInverseBendingMomentum(), 0.003, -0.4, 0.4, status);
803   
804   // minimization
805   gMinuit->mnexcm("MIGRAD", arg, 0, status);
806   
807   // Calculate the covariance matrix more accurately if required
808   if (calcCov) gMinuit->mnexcm("HESSE", arg, 0, status);
809    
810   // get results into "invBenP", "benC", "nonBenC" ("x", "y")
811   gMinuit->GetParameter(0, x, errorParam);
812   trackParam->SetNonBendingCoor(x);
813   gMinuit->GetParameter(1, nonBenC, errorParam);
814   trackParam->SetNonBendingSlope(nonBenC);
815   gMinuit->GetParameter(2, y, errorParam);
816   trackParam->SetBendingCoor(y);
817   gMinuit->GetParameter(3, benC, errorParam);
818   trackParam->SetBendingSlope(benC);
819   gMinuit->GetParameter(4, invBenP, errorParam);
820   trackParam->SetInverseBendingMomentum(invBenP);
821   
822   // global result of the fit
823   gMinuit->mnstat(fitFMin, fedm, errdef, npari, nparx, covStatus);
824   track.SetFitFMin(fitFMin);
825   
826   // Get the covariance matrix if required
827   if (calcCov) {
828     // Covariance matrix according to HESSE status
829     // If problem then keep only the diagonal terms (variances)
830     Double_t matrix[5][5];
831     gMinuit->mnemat(&matrix[0][0],5);
832     if (covStatus == 3) trackParam->SetCovariances(matrix);
833     else trackParam->SetVariances(matrix);
834   } else trackParam->DeleteCovariances();
835   
836 }
837
838   //__________________________________________________________________________
839 void TrackChi2(Int_t & /*nParam*/, Double_t * /*gradient*/, Double_t &chi2, Double_t *param, Int_t /*flag*/)
840 {
841   /// Return the "Chi2" to be minimized with Minuit for track fitting.
842   /// Assumes that the track hits are sorted according to increasing Z.
843   /// Track parameters at each TrackHit are updated accordingly.
844   /// Vertex is used according to the flag "trackBeingFitted->GetFitWithVertex()".
845   /// Multiple Coulomb scattering is taken into account according to the flag "trackBeingFitted->GetFitWithMCS()".
846   
847   AliMUONTrack *trackBeingFitted = (AliMUONTrack*) gMinuit->GetObjectFit();
848   AliMUONTrackParam* trackParamAtHit = (AliMUONTrackParam*) trackBeingFitted->GetTrackParamAtHit()->First();
849   Double_t dX, dY;
850   chi2 = 0.; // initialize chi2
851   
852   // update track parameters
853   trackParamAtHit->SetNonBendingCoor(param[0]);
854   trackParamAtHit->SetNonBendingSlope(param[1]);
855   trackParamAtHit->SetBendingCoor(param[2]);
856   trackParamAtHit->SetBendingSlope(param[3]);
857   trackParamAtHit->SetInverseBendingMomentum(param[4]);
858   trackBeingFitted->UpdateTrackParamAtHit();
859   
860   // Take the vertex into account in the fit if required
861   if (trackBeingFitted->GetFitWithVertex()) {
862     AliMUONTrackParam paramAtVertex(*trackParamAtHit);
863     AliMUONTrackExtrap::ExtrapToZ(&paramAtVertex, 0.);
864     AliMUONHitForRec *vertex = trackBeingFitted->GetVertex();
865     if (!vertex) {
866       cout<<"Error in TrackChi2: Want to use the vertex in tracking but it has not been created!!"<<endl;
867       exit(-1);
868     }
869     dX = vertex->GetNonBendingCoor() - paramAtVertex.GetNonBendingCoor();
870     dY = vertex->GetBendingCoor() - paramAtVertex.GetBendingCoor();
871     chi2 += dX * dX / vertex->GetNonBendingReso2() + dY * dY / vertex->GetBendingReso2();
872   }
873   
874   // compute chi2 w/wo multiple scattering
875   if (trackBeingFitted->GetFitWithMCS()) chi2 += trackBeingFitted->ComputeGlobalChi2(kTRUE);
876   else chi2 += trackBeingFitted->ComputeGlobalChi2(kFALSE);
877   
878 }
879
880   //__________________________________________________________________________
881 void AliMUONTrackReconstructor::ImproveTracks()
882 {
883   /// Improve tracks by removing clusters with local chi2 highter than the defined cut
884   /// Recompute track parameters and covariances at the remaining clusters
885   AliDebug(1,"Enter ImproveTracks");
886   
887   Double_t localChi2, worstLocalChi2;
888   Int_t worstChamber;
889   AliMUONTrackParam *trackParamAtHit, *worstTrackParamAtHit;
890   
891   // Remove double track to improve only "good" tracks
892   RemoveDoubleTracks();
893   
894   AliMUONTrack *track = (AliMUONTrack*) fRecTracksPtr->First();
895   while (track) {
896     
897     while (!track->IsImproved()) {
898       
899       // Update track parameters and covariances
900       track->UpdateCovTrackParamAtHit();
901       
902       // Compute local chi2 of each hits
903       track->ComputeLocalChi2(kTRUE);
904       
905       // Look for the hit to remove
906       worstTrackParamAtHit = 0;
907       worstLocalChi2 = 0.;
908       trackParamAtHit = (AliMUONTrackParam*) track->GetTrackParamAtHit()->First();
909       while (trackParamAtHit) {
910         
911         // Pick up hit with the worst chi2
912         localChi2 = trackParamAtHit->GetLocalChi2();
913         if (localChi2 > worstLocalChi2) {
914           worstLocalChi2 = localChi2;
915           worstTrackParamAtHit = trackParamAtHit;
916         }
917         
918       trackParamAtHit = (AliMUONTrackParam*) track->GetTrackParamAtHit()->After(trackParamAtHit);
919       }
920       
921       // Check if bad hit found
922       if (!worstTrackParamAtHit) {
923         track->SetImproved(kTRUE);
924         break;
925       }
926       
927       // check whether the worst hit is removable or not
928       if (!worstTrackParamAtHit->IsRemovable()) {
929         track->SetImproved(kTRUE);
930         break;
931       }
932       
933       // Check whether the worst chi2 is under requirement or not
934       if (worstLocalChi2 < 2. * fgkSigmaToCutForImprovement * fgkSigmaToCutForImprovement) { // 2 because 2 quantities in chi2
935         track->SetImproved(kTRUE);
936         break;
937       }
938       
939       // Reset the second hit in the same station as the bad one as being NOT removable
940       worstChamber = worstTrackParamAtHit->GetHitForRecPtr()->GetChamberNumber();
941       if (worstChamber%2 == 0) ((AliMUONTrackParam*)track->GetTrackParamAtHit()->After(worstTrackParamAtHit))->SetRemovable(kFALSE);
942       else ((AliMUONTrackParam*)track->GetTrackParamAtHit()->Before(worstTrackParamAtHit))->SetRemovable(kFALSE);
943       
944       // Remove the worst hit
945       track->RemoveTrackParamAtHit(worstTrackParamAtHit);
946       
947       // Re-fit the track:
948       // Take into account the multiple scattering
949       // Calculate the track parameter covariance matrix
950       track->SetFitWithVertex(kFALSE); // To be sure
951       Fit(*track, kTRUE, kTRUE);
952       
953       // Printout for debuging
954       if ((AliLog::GetDebugLevel("MUON","AliMUONTrackReconstructor") >= 1) || (AliLog::GetGlobalDebugLevel() >= 1)) {
955         cout << "ImproveTracks: track " << fRecTracksPtr->IndexOf(track)+1 << " improved " << endl;
956       }
957       
958     }
959     
960     track = (AliMUONTrack*) fRecTracksPtr->After(track);
961   }
962   
963 }
964
965   //__________________________________________________________________________
966 void AliMUONTrackReconstructor::Finalize()
967 {
968   /// Fill AliMUONTrack's fHitForRecAtHit array
969   /// Recompute track parameters and covariances at each attached cluster from those at the first one
970   AliMUONTrack *track;
971   AliMUONTrackParam *trackParamAtHit;
972   
973   track = (AliMUONTrack*) fRecTracksPtr->First();
974   while (track) {
975     
976     // update track parameters if not already done
977     if (!track->IsImproved()) track->UpdateCovTrackParamAtHit();
978     
979     trackParamAtHit = (AliMUONTrackParam*) (track->GetTrackParamAtHit()->First());
980     while (trackParamAtHit) {
981       
982       // update array of track hit
983       track->AddHitForRecAtHit(trackParamAtHit->GetHitForRecPtr());
984       
985       trackParamAtHit = (AliMUONTrackParam*) (track->GetTrackParamAtHit()->After(trackParamAtHit));
986     }
987     
988     track = (AliMUONTrack*) fRecTracksPtr->After(track);
989     
990   }
991     
992 }
993
994