]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTrackReconstructor.cxx
Fixing Doxygen warnings
[u/mrichter/AliRoot.git] / MUON / AliMUONTrackReconstructor.cxx
index f903ed748b7c77d82eba81c198309e2f4240399c..1c3936f5f855c65a7a6c9ca7aaa841c267569ec1 100644 (file)
@@ -35,6 +35,7 @@
 #include "AliMUONTrack.h"
 #include "AliMUONTrackParam.h"
 #include "AliMUONTrackExtrap.h"
+#include "AliMUONRecoParam.h"
 
 #include "AliMpArea.h"
 
@@ -66,7 +67,7 @@ AliMUONTrackReconstructor::~AliMUONTrackReconstructor()
 } 
 
   //__________________________________________________________________________
-void AliMUONTrackReconstructor::MakeTrackCandidates(AliMUONVClusterStore& clusterStore)
+Bool_t AliMUONTrackReconstructor::MakeTrackCandidates(AliMUONVClusterStore& clusterStore)
 {
   /// To make track candidates (assuming linear propagation if the flag fgkMakeTrackCandidatesFast is set to kTRUE):
   /// Start with segments station(1..) 4 or 5 then follow track in station 5 or 4.
@@ -115,10 +116,23 @@ void AliMUONTrackReconstructor::MakeTrackCandidates(AliMUONVClusterStore& cluste
        clusterFound = FollowLinearTrackInStation(*track, clusterStore, 7-istat);
       else clusterFound = FollowTrackInStation(*track, clusterStore, 7-istat);
       
-      // Remove track if no cluster found
-      if (!clusterFound && GetRecoParam()->RequestStation(7-istat)) {
-        fRecTracksPtr->Remove(track);
-       fNRecTracks--;
+      // Remove track if no cluster found on a requested station
+      // or abort tracking if there are too many candidates
+      if (GetRecoParam()->RequestStation(7-istat)) {
+       if (!clusterFound) {
+         fRecTracksPtr->Remove(track);
+         fNRecTracks--;
+       } else if (fNRecTracks > GetRecoParam()->GetMaxTrackCandidates()) {
+         AliError(Form("Too many track candidates (%d tracks). Abort tracking.", fNRecTracks));
+         delete segments;
+         return kFALSE;
+       }
+      } else {
+       if ((fNRecTracks + segments->GetEntriesFast() - iseg - 1) > GetRecoParam()->GetMaxTrackCandidates()) {
+         AliError(Form("Too many track candidates (%d tracks). Abort tracking.", fNRecTracks + segments->GetEntriesFast() - iseg - 1));
+         delete segments;
+         return kFALSE;
+       }
       }
       
     }
@@ -127,18 +141,18 @@ void AliMUONTrackReconstructor::MakeTrackCandidates(AliMUONVClusterStore& cluste
     delete segments;
   }
   
-  fRecTracksPtr->Compress(); // this is essential before checking tracks
-  
   // Keep all different tracks or only the best ones as required
   if (GetRecoParam()->TrackAllTracks()) RemoveIdenticalTracks();
   else RemoveDoubleTracks();
   
   AliDebug(1,Form("Number of good candidates = %d",fNRecTracks));
   
+  return kTRUE;
+  
 }
 
   //__________________________________________________________________________
-void AliMUONTrackReconstructor::MakeMoreTrackCandidates(AliMUONVClusterStore& clusterStore)
+Bool_t AliMUONTrackReconstructor::MakeMoreTrackCandidates(AliMUONVClusterStore& clusterStore)
 {
   /// To make extra track candidates (assuming linear propagation if the flag fgkMakeTrackCandidatesFast is set to kTRUE):
   /// clustering is supposed to be already done
@@ -147,6 +161,7 @@ void AliMUONTrackReconstructor::MakeMoreTrackCandidates(AliMUONVClusterStore& cl
   /// Keep only best candidates or all of them according to the flag fgkTrackAllTracks.
   
   TClonesArray *segments;
+  AliMUONObjectPair *segment;
   AliMUONTrack *track;
   Int_t iCandidate = 0, iCurrentTrack, nCurrentTracks;
   Bool_t clusterFound;
@@ -160,20 +175,22 @@ void AliMUONTrackReconstructor::MakeMoreTrackCandidates(AliMUONVClusterStore& cl
       // Make segments in the station
       segments = MakeSegmentsBetweenChambers(clusterStore, ich1, ich2);
       
+      /// Remove segments already attached to a track
+      RemoveUsedSegments(*segments);
+      
       // Loop over segments
-      for (Int_t iseg=0; iseg<segments->GetEntriesFast(); iseg++) 
+      for (Int_t iSegment=0; iSegment<segments->GetEntriesFast(); iSegment++)
       {
        AliDebug(1,Form("Making primary candidate(1..) %d",++iCandidate));
+       segment = (AliMUONObjectPair*) segments->UncheckedAt(iSegment);
        
        // Transform segments to tracks and put them at the end of fRecTracksPtr
        iCurrentTrack = fRecTracksPtr->GetLast()+1;
-       track = new ((*fRecTracksPtr)[iCurrentTrack]) AliMUONTrack((AliMUONObjectPair*)((*segments)[iseg]),GetRecoParam()->GetBendingVertexDispersion());
+       track = new ((*fRecTracksPtr)[iCurrentTrack]) AliMUONTrack(segment,GetRecoParam()->GetBendingVertexDispersion());
        fNRecTracks++;
        
        // Look for compatible cluster(s) in the second chamber of station 5
-       if (GetRecoParam()->MakeTrackCandidatesFast())
-         clusterFound = FollowLinearTrackInChamber(*track, clusterStore, 17-ich2);
-       else clusterFound = FollowTrackInChamber(*track, clusterStore, 17-ich2);
+       clusterFound = FollowLinearTrackInChamber(*track, clusterStore, 17-ich2);
        
        // skip the original track in case it has been removed
        if (GetRecoParam()->TrackAllTracks() && clusterFound) iCurrentTrack++;
@@ -184,13 +201,18 @@ void AliMUONTrackReconstructor::MakeMoreTrackCandidates(AliMUONVClusterStore& cl
          track = (AliMUONTrack*) fRecTracksPtr->UncheckedAt(iCurrentTrack);
          
          // Look for compatible cluster(s) in the second chamber of station 4
-         if (GetRecoParam()->MakeTrackCandidatesFast())
-           FollowLinearTrackInChamber(*track, clusterStore, 13-ich1);
-         else FollowTrackInChamber(*track, clusterStore, 13-ich1);
+         FollowLinearTrackInChamber(*track, clusterStore, 13-ich1);
          
          iCurrentTrack++;
        }
        
+       // abort tracking if there are too many candidates
+       if ((fNRecTracks + segments->GetEntriesFast() - iSegment - 1) > GetRecoParam()->GetMaxTrackCandidates()) {
+         AliError(Form("Too many track candidates (%d tracks). Abort tracking.", fNRecTracks + segments->GetEntriesFast() - iSegment - 1));
+         delete segments;
+         return kFALSE;
+       }
+       
       }
       
       // delete the array of segments
@@ -198,18 +220,18 @@ void AliMUONTrackReconstructor::MakeMoreTrackCandidates(AliMUONVClusterStore& cl
     }
   }
   
-  fRecTracksPtr->Compress(); // this is essential before checking tracks
-  
-  // Keep all different tracks or only the best ones as required
-  if (GetRecoParam()->TrackAllTracks()) RemoveIdenticalTracks();
-  else RemoveDoubleTracks();
+  // Keep only the best tracks if required
+  if (!GetRecoParam()->TrackAllTracks()) RemoveDoubleTracks();
+  else fRecTracksPtr->Compress();
   
   AliDebug(1,Form("Number of good candidates = %d",fNRecTracks));
   
+  return kTRUE;
+  
 }
 
   //__________________________________________________________________________
-void AliMUONTrackReconstructor::FollowTracks(AliMUONVClusterStore& clusterStore)
+Bool_t AliMUONTrackReconstructor::FollowTracks(AliMUONVClusterStore& clusterStore)
 {
   /// Follow tracks in stations(1..) 3, 2 and 1
   AliDebug(1,"Enter FollowTracks");
@@ -241,15 +263,18 @@ void AliMUONTrackReconstructor::FollowTracks(AliMUONVClusterStore& clusterStore)
        Fit(*track, kFALSE, kTRUE, kTRUE);
       else Fit(*track, kFALSE, kFALSE, kTRUE);
       
-      // remove track with absolute bending momentum out of limits
-      // or if the normalized chi2 is too high
-      Double_t bendingMomentum = TMath::Abs(1. / ((AliMUONTrackParam*)track->GetTrackParamAtCluster()->First())->GetInverseBendingMomentum());
-      if (bendingMomentum < GetRecoParam()->GetMinBendingMomentum() ||
-         bendingMomentum > GetRecoParam()->GetMaxBendingMomentum() ||
-         track->GetNormalizedChi2() > sigmaCut2) {
+      // remove tracks out of limits
+      if (!IsAcceptable(*((AliMUONTrackParam*)track->GetTrackParamAtCluster()->First()))) {
+       fRecTracksPtr->Remove(track);
+       fNRecTracks--;
+       continue;
+      }
+      
+      // remove track if the normalized chi2 is too high
+      if (track->GetNormalizedChi2() > sigmaCut2) {
        fRecTracksPtr->Remove(track);
-       fNRecTracks--;
-       continue;
+       fNRecTracks--;
+       continue;
       }
       
       // save parameters from fit into smoothed parameters to complete track afterward
@@ -329,6 +354,12 @@ void AliMUONTrackReconstructor::FollowTracks(AliMUONVClusterStore& clusterStore)
        
       }
       
+      // abort tracking if there are too many candidates
+      if (fNRecTracks > GetRecoParam()->GetMaxTrackCandidates()) {
+       AliError(Form("Too many track candidates (%d tracks). Abort tracking.", fNRecTracks));
+       return kFALSE;
+      }
+      
     }
     
     // Compress fRecTracksPtr for the next step
@@ -402,6 +433,8 @@ void AliMUONTrackReconstructor::FollowTracks(AliMUONVClusterStore& clusterStore)
   
   fRecTracksPtr->Compress();
   
+  return kTRUE;
+  
 }
 
   //__________________________________________________________________________
@@ -916,6 +949,7 @@ Double_t AliMUONTrackReconstructor::TryTwoClusters(const AliMUONTrackParam &trac
     jacob(1,2) = 1.; // dy1/dy
     // first derivative at the second cluster:
     TMatrixD dParam(5,1);
+    Double_t direction[5] = {-1.,-1.,1.,1.,-1.};
     for (Int_t i=0; i<5; i++) {
       // Skip jacobian calculation for parameters with no associated error
       if (kParamCov(i,i) == 0.) continue;
@@ -923,7 +957,7 @@ Double_t AliMUONTrackReconstructor::TryTwoClusters(const AliMUONTrackParam &trac
       for (Int_t j=0; j<5; j++) {
         if (j==i) {
           dParam(j,0) = TMath::Sqrt(kParamCov(i,i));
-         if (j == 4) dParam(j,0) *= TMath::Sign(1.,-paramAtCluster1Save(4,0)); // variation always in the same direction
+         dParam(j,0) *= TMath::Sign(1.,direction[j]*paramAtCluster1Save(j,0)); // variation always in the same direction
         } else dParam(j,0) = 0.;
       }
       
@@ -1078,6 +1112,9 @@ Bool_t AliMUONTrackReconstructor::RecoverTrack(AliMUONTrack &trackCandidate, Ali
   // Calculate the track parameter covariance matrix
   Fit(trackCandidate, kFALSE, kFALSE, kTRUE);
   
+  // skip track out of limits
+  if (!IsAcceptable(*((AliMUONTrackParam*)trackCandidate.GetTrackParamAtCluster()->First()))) return kFALSE;
+  
   // Look for new cluster(s) in next station
   return FollowTrackInStation(trackCandidate,clusterStore,nextStation);
   
@@ -1248,18 +1285,19 @@ void TrackChi2(Int_t & /*nParam*/, Double_t * /*gradient*/, Double_t &chi2, Doub
 }
 
   //__________________________________________________________________________
-void AliMUONTrackReconstructor::ComplementTracks(const AliMUONVClusterStore& clusterStore)
+Bool_t AliMUONTrackReconstructor::ComplementTracks(const AliMUONVClusterStore& clusterStore)
 {
   /// Complete tracks by adding missing clusters (if there is an overlap between
-  /// two detection elements, the track may have two clusters in the same chamber)
-  /// Re-fit track parameters and covariances
+  /// two detection elements, the track may have two clusters in the same chamber).
+  /// Re-fit track parameters and covariances.
+  /// Return kTRUE if one or more tracks have been complemented.
   AliDebug(1,"Enter ComplementTracks");
   
   Int_t chamberId, detElemId;
   Double_t chi2OfCluster, bestChi2OfCluster;
   Double_t sigmaCut2 = GetRecoParam()->GetSigmaCutForTracking() *
                        GetRecoParam()->GetSigmaCutForTracking();
-  Bool_t foundOneCluster, trackModified;
+  Bool_t foundOneCluster, trackModified, hasChanged = kFALSE;
   AliMUONVCluster* cluster;
   AliMUONTrackParam *trackParam, *nextTrackParam, copyOfTrackParam, trackParamAtCluster, bestTrackParamAtCluster;
   
@@ -1322,6 +1360,7 @@ void AliMUONTrackReconstructor::ComplementTracks(const AliMUONVClusterStore& clu
        bestTrackParamAtCluster.SetRemovable(kTRUE);
        track->AddTrackParamAtCluster(bestTrackParamAtCluster,*(bestTrackParamAtCluster.GetClusterPtr()));
        trackModified = kTRUE;
+       hasChanged = kTRUE;
       }
       
       trackParam = nextTrackParam;
@@ -1333,6 +1372,8 @@ void AliMUONTrackReconstructor::ComplementTracks(const AliMUONVClusterStore& clu
     track = (AliMUONTrack*) fRecTracksPtr->After(track);
   }
   
+  return hasChanged;
+  
 }
 
   //__________________________________________________________________________