]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/global/AliHLTGlobalTrackMatcher.h
patch
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalTrackMatcher.h
index 14ca8165041ff5ef1fd1f5590547ccfa310005ad..5d5e3918f27deb5304eadaf319ea16604028984a 100644 (file)
@@ -15,6 +15,7 @@
 */
 
 
+
 #include "AliHLTLogging.h"
 #include "AliESDtrack.h"
 #include "TObjArray.h"
@@ -67,11 +68,10 @@ private:
 
 
 template <class T>
-Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*>  &phosClustersVector, 
-                                      vector<T*> &emcalClustersVector,  Double_t bz ) 
-{
+Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*>  &phosClustersVector, vector<T*> &emcalClustersVector,  Double_t bz ) {
   //See above for documentation
 
+
   Int_t nTracks = trackArray->GetEntriesFast();
   Int_t nPhosClusters = phosClustersVector.size();
   Int_t nEmcalClusters = emcalClustersVector.size(); 
@@ -86,6 +86,7 @@ Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*>  &phos
     return 0;
   }
 
+
   Float_t bestMatchPhos[nPhosClusters];   
   for(int ic = 0; ic < nPhosClusters; ic++) {
     bestMatchPhos[ic] = 999999;
@@ -100,82 +101,77 @@ Int_t AliHLTGlobalTrackMatcher::Match( TObjArray * trackArray, vector<T*>  &phos
   for (int it = 0; it < nTracks; it++ ) {
     AliExternalTrackParam * track = static_cast<AliExternalTrackParam*>(trackArray->At(it));
 
-    if ( IsTrackCloseToDetector(track, bz, fPhosMaxX, kFALSE, fPhosMaxZ, fPhosRadius ) ) 
-      {
-       MatchTrackToClusters( track, phosClustersVector, nPhosClusters, bestMatchPhos, bz);
-      } 
-    else 
-      if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) 
-       {
-         MatchTrackToClusters( track, emcalClustersVector, nEmcalClusters, bestMatchEmcal, bz);
-       } 
+    if ( IsTrackCloseToDetector(track, bz, fPhosMaxX, kFALSE, fPhosMaxZ, fPhosRadius ) ) {
+      MatchTrackToClusters( track, phosClustersVector, nPhosClusters, bestMatchPhos, bz);
+
+    } else if ( IsTrackCloseToDetector(track, bz, fEmcalMaxX, kTRUE, fEmcalMaxZ, fEmcalRadius ) ) {
+      MatchTrackToClusters( track, emcalClustersVector, nEmcalClusters, bestMatchEmcal, bz);
+    } 
+
   }   
+    
   return 0;
 } 
 
 
+
 template <class T>
 Int_t AliHLTGlobalTrackMatcher::MatchTrackToClusters( AliExternalTrackParam * track, vector<T*>  &clustersVector, Int_t nClusters, Float_t * bestMatch, Double_t bz) {
   
   //See header file for documentation
   Int_t iResult = 0;
   Float_t clusterPosition[3];
   Double_t trackPosition[3];
   
-  for(int ic = 0; ic < nClusters; ic++) 
-    {
-      T * cluster = clustersVector.at(ic);
-      //Get cluster global coordinates
-      cluster->GetPosition(clusterPosition);
-      Double_t rCluster = TMath::Sqrt(clusterPosition[0]*clusterPosition[0] 
-                                     + clusterPosition[1]*clusterPosition[1]);      
-      //Rotate tracking system to the angle of the cluster
-      TVector3 cVec(clusterPosition);
-      
-      if (! (track->Rotate(cVec.Phi())) ) 
-       {
-         continue;
-       }
+  for(int ic = 0; ic < nClusters; ic++) {
     
-      if(! (track->GetXYZAt(rCluster, bz, trackPosition)) ) 
-       {
-         continue;
-       }
+    T * cluster = clustersVector.at(ic);
     
-    //Get residual in z= 0 plane (squared)
-      Double_t dxy = 0;
-      for(int i = 0; i < 2; i++) 
-       {
-         Double_t dd = trackPosition[i] - clusterPosition[i];
-         dxy += dd*dd;
-       }
-
-      //Get z residual (squared)
-      Double_t dd = trackPosition[2] - clusterPosition[2];
-      Double_t dz = dd*dd;
-      Double_t match = dz + dxy;
+    //Get cluster global coordinates
+    cluster->GetPosition(clusterPosition);
+
+    Double_t rCluster = TMath::Sqrt(clusterPosition[0]*clusterPosition[0] + clusterPosition[1]*clusterPosition[1]);      
+
+    //Rotate tracking system to the angle of the cluster
+    TVector3 cVec(clusterPosition);
+    if (! (track->Rotate(cVec.Phi())) ) {
+      continue;
+    }
+   
+    if(! (track->GetXYZAt(rCluster, bz, trackPosition)) ) {
+      continue;
+    }
+
+    //Calculate track - cluster residuals
+    Double_t match = 0;
+    for(int i = 0; i < 3; i++) {
+      Double_t dd = trackPosition[i] - clusterPosition[i];
+      match += dd*dd;
+    }
+
+    if( match > fMatchDistance  )  {     
+      continue;
+    }
+
+    if (match < bestMatch[ic]) {
       
-      if( match > fMatchDistance  )  
-       {     
-         continue;
-       }
-      if (match < bestMatch[ic]) 
-       {
-         bestMatch[ic] = match;
-         cluster->SetEmcCpvDistance(TMath::Sqrt(match));
-         cluster->SetTrackDistance(TMath::Sqrt(dxy), TMath::Sqrt(dz));
-       }
-    
-      //Add track to cluster's array of matching tracks
-      Int_t nTracksMatched = cluster->GetNTracksMatched();
-      iResult = AddTrackToCluster(track->GetID(), cluster->GetTracksMatched(), 
-                                 match < bestMatch[ic], nTracksMatched);
+      bestMatch[ic] = match;
+      cluster->SetEmcCpvDistance(TMath::Sqrt(match));
+      
+      Double_t dx = trackPosition[0] - clusterPosition[0];
+      Double_t dy = trackPosition[1] - clusterPosition[1];
+      Double_t dz = trackPosition[2] - clusterPosition[2];
+      cluster->SetTrackDistance( ((dx > 0) ? 1 : -1 )*TMath::Sqrt(dx*dx + dy*dy), dz);
     }
+    
+    //Add track to cluster's array of matching tracks
+    Int_t nTracksMatched = cluster->GetNTracksMatched();
+    iResult = AddTrackToCluster(track->GetID(), cluster->GetTracksMatched(), match < bestMatch[ic], nTracksMatched);
+  }
   
   return iResult;
 }
 
-
 #endif
-
-