]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/tracking-ca/AliHLTTPCCAMerger.cxx
- Method to calculate the track length is added to the AliHLTGlobalBarrelTrack
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAMerger.cxx
index 5bc57e55bfdcb7f292d948a6b087eb355ea65d94..1ecbb25137d51f8a79369400fc68db64089fa180 100644 (file)
@@ -17,7 +17,7 @@
 //                                                                          *
 //***************************************************************************
 
-
+#include <stdio.h>
 #include "AliHLTTPCCASliceTrack.h"
 #include "AliHLTTPCCATracker.h"
 #include "AliHLTTPCCATrackParam.h"
@@ -220,7 +220,9 @@ void AliHLTTPCCAMerger::UnpackSlices()
     for ( int itr = 0; itr < slice.NTracks(); itr++ ) {
 
       const AliHLTTPCCASliceTrack &sTrack = slice.Track( itr );
-      AliHLTTPCCATrackParam t0 = sTrack.Param();
+      AliHLTTPCCATrackParam t0;
+         t0.InitParam();
+         t0.SetParam(sTrack.Param());
       int nCluNew = 0;
 
       for ( int iTrClu = 0; iTrClu < sTrack.NClusters(); iTrClu++ ) {
@@ -233,7 +235,7 @@ void AliHLTTPCCAMerger::UnpackSlices()
         clu.SetISlice( iSlice );
         clu.SetIRow( slice.ClusterRow( ic ) );
         clu.SetId( slice.ClusterId( ic ) );
-        clu.SetPackedAmp( slice.ClusterPackedAmp( ic ) );
+        clu.SetPackedAmp( 0 );
         float2 yz = slice.ClusterUnpackedYZ( ic );
         clu.SetX( slice.ClusterUnpackedX( ic ) );
         clu.SetY( yz.x );
@@ -257,7 +259,9 @@ void AliHLTTPCCAMerger::UnpackSlices()
       int nHits = nCluNew;
       for ( int i = 0; i < nHits; i++ ) hits[i] = nClustersCurrent + i;
 
-      AliHLTTPCCATrackParam startPoint = sTrack.Param();
+      AliHLTTPCCATrackParam startPoint;
+         startPoint.InitParam();
+         startPoint.SetParam(sTrack.Param());
       AliHLTTPCCATrackParam endPoint = startPoint;
       float startAlpha = fSliceParam.Alpha( iSlice );
       float endAlpha = startAlpha;
@@ -298,7 +302,7 @@ void AliHLTTPCCAMerger::UnpackSlices()
 
 bool AliHLTTPCCAMerger::FitTrack( AliHLTTPCCATrackParam &T, float &Alpha,
                                   AliHLTTPCCATrackParam t0, float Alpha0,
-                                  int hits[], int &NTrackHits, bool dir,
+                                  int hits[], int &NTrackHits, bool dir, bool final,
                                   AliHLTTPCCAClusterInfo *infoArray )
 {
   // Fit the track
@@ -362,6 +366,11 @@ bool AliHLTTPCCAMerger::FitTrack( AliHLTTPCCATrackParam &T, float &Alpha,
     float err2Y = h.Err2Y();
     float err2Z = h.Err2Z();
     if ( doErrors ) fSliceParam.GetClusterErrors2( h.IRow(), h.Z(), l.SinPhi(), l.CosPhi(), l.DzDs(), err2Y, err2Z );
+    if( !final ){
+      err2Y*= fSliceParam.ClusterError2CorrectionY();
+      err2Z*= fSliceParam.ClusterError2CorrectionZ();
+    }
+
     if ( !t.Filter( h.Y(), h.Z(), err2Y, err2Z ) ) continue;
 
     first = 0;
@@ -369,17 +378,9 @@ bool AliHLTTPCCAMerger::FitTrack( AliHLTTPCCATrackParam &T, float &Alpha,
     hitsNew[nHitsNew++] = hits[jhit];
   }
 
-  if ( CAMath::Abs( t.QPt() ) < 1.e-8 ) t.SetQPt( 1.e-8 );
-
-  bool ok = 1;
+  if ( CAMath::Abs( t.QPt() ) < 1.e-4 ) t.SetQPt( 1.e-4 );
 
-  const float *c = t.Cov();
-  for ( int i = 0; i < 15; i++ ) ok = ok && finite( c[i] );
-  for ( int i = 0; i < 5; i++ ) ok = ok && finite( t.Par()[i] );
-  ok = ok && ( t.GetX() > 50 );
-
-  if ( c[0] <= 0 || c[2] <= 0 || c[5] <= 0 || c[9] <= 0 || c[14] <= 0 ) ok = 0;
-  if ( c[0] > 5. || c[2] > 5. || c[5] > 2. || c[9] > 2 || c[14] > 2. ) ok = 0;
+  bool ok = t.CheckNumericalQuality();
 
   if ( CAMath::Abs( t.SinPhi() ) > .99 ) ok = 0;
   else if ( l.CosPhi() >= 0 ) t.SetSignCosPhi( 1 );
@@ -412,7 +413,7 @@ float AliHLTTPCCAMerger::GetChi2( float x1, float y1, float a00, float a10, floa
 
   float mS[3] = { mSi[2], -mSi[1], mSi[0] };
 
-  return TMath::Abs( ( ( mS[0]*d[0] + mS[1]*d[1] )*d[0]
+  return AliHLTTPCCAMath::Abs( ( ( mS[0]*d[0] + mS[1]*d[1] )*d[0]
                        + ( mS[1]*d[0] + mS[2]*d[1] )*d[1] ) / s / 2 );
 
 }
@@ -468,6 +469,7 @@ void AliHLTTPCCAMerger::MakeBorderTracks( int iSlice, int iBorder, AliHLTTPCCABo
     if ( do0 ) {
       AliHLTTPCCABorderTrack &b = B[nB];
       b.SetX( t0.GetX() );
+      
       if ( t0.TransportToX( x0, fSliceParam.GetBz( t0 ), maxSin ) ) {
         b.SetOK( 1 );
         b.SetTrackID( itr );
@@ -480,6 +482,7 @@ void AliHLTTPCCAMerger::MakeBorderTracks( int iSlice, int iBorder, AliHLTTPCCABo
     if ( do1 ) {
       AliHLTTPCCABorderTrack &b = B[nB];
       b.SetX( t1.GetX() );
+      
       if ( t1.TransportToX( x0, fSliceParam.GetBz( t1 ), maxSin ) ) {
         b.SetOK( 1 );
         b.SetTrackID( itr );
@@ -496,12 +499,14 @@ void AliHLTTPCCAMerger::MakeBorderTracks( int iSlice, int iBorder, AliHLTTPCCABo
 
 
 
-void AliHLTTPCCAMerger::SplitBorderTracks( int iSlice1, AliHLTTPCCABorderTrack B1[], int N1,
+void AliHLTTPCCAMerger::MergeBorderTracks( int iSlice1, AliHLTTPCCABorderTrack B1[], int N1,
     int iSlice2, AliHLTTPCCABorderTrack B2[], int N2
                                          )
 {
-  //* split two sets of tracks
+  //* merge two sets of tracks
 
+  //std::cout<<" Merge slices "<<iSlice1<<"+"<<iSlice2<<": tracks "<<N1<<"+"<<N2<<std::endl;
+  
   float factor2ys = 1.;//1.5;//SG!!!
   float factor2zt = 1.;//1.5;//SG!!!
   float factor2k = 2.0;//2.2;
@@ -537,18 +542,21 @@ void AliHLTTPCCAMerger::SplitBorderTracks( int iSlice1, AliHLTTPCCABorderTrack B
       float c = t2.SignCosPhi() * t1.SignCosPhi() >= 0 ? 1 : -1;
       float dk = t2.QPt() - c * t1.QPt();
       float s2k = t2.Err2QPt() + t1.Err2QPt();
-
+      //std::cout<<" check 1.. "<<dk/sqrt(factor2k)<<std::endl;
       if ( dk*dk > factor2k*s2k ) continue;
 
 
       float chi2ys = GetChi2( t1.Y(), c * t1.SinPhi(), t1.Cov()[0], c * t1.Cov()[3], t1.Cov()[5],
                               t2.Y(),  t2.SinPhi(), t2.Cov()[0],  t2.Cov()[3], t2.Cov()[5] );
 
+      //std::cout<<" check 2.. "<<sqrt(chi2ys/factor2ys)<<std::endl;
       if ( chi2ys > factor2ys ) continue;
+      
 
       float chi2zt = GetChi2( t1.Z(), c * t1.DzDs(), t1.Cov()[2], c * t1.Cov()[7], t1.Cov()[9],
                               t2.Z(),  t2.DzDs(), t2.Cov()[2],  t2.Cov()[7], t2.Cov()[9] );
 
+      //std::cout<<" check 3.. "<<sqrt(chi2zt/factor2zt)<<std::endl;
       if ( chi2zt > factor2zt ) continue;
 
       lBest2 = b2.NClusters();
@@ -557,6 +565,7 @@ void AliHLTTPCCAMerger::SplitBorderTracks( int iSlice1, AliHLTTPCCABorderTrack B
 
     if ( iBest2 < 0 ) continue;
 
+    //std::cout<<"Neighbour found for "<<i1<<": "<<iBest2<<std::endl;
     AliHLTTPCCASliceTrackInfo &newTrack1 = fTrackInfos[fSliceTrackInfoStart[iSlice1] + b1.TrackID() ];
     AliHLTTPCCASliceTrackInfo &newTrack2 = fTrackInfos[fSliceTrackInfoStart[iSlice2] + iBest2 ];
 
@@ -578,6 +587,7 @@ void AliHLTTPCCAMerger::SplitBorderTracks( int iSlice1, AliHLTTPCCABorderTrack B
     }
     newTrack1.SetNextNeighbour( iBest2 );
     newTrack2.SetPrevNeighbour( b1.TrackID() );
+    //std::cout<<"Neighbourhood is set"<<std::endl;
   }
 
 }
@@ -625,7 +635,7 @@ void AliHLTTPCCAMerger::Merging()
 
       int nBord = 0;
       MakeBorderTracks( iSlice, 4, bord.Data(), nBord );
-      SplitBorderTracks( iSlice, bord.Data(), nBord, iSlice, bord.Data(), nBord );
+      MergeBorderTracks( iSlice, bord.Data(), nBord, iSlice, bord.Data(), nBord );
 
       int nTr = 0, nH = 0;
       int sliceFirstClusterRef = 0;
@@ -696,8 +706,8 @@ void AliHLTTPCCAMerger::Merging()
     MakeBorderTracks( iSlice, 2, bCurr0, nCurr0 );
     MakeBorderTracks( jSlice, 3, bNext0, nNext0 );
 
-    SplitBorderTracks( iSlice, bCurr0, nCurr0, jSlice, bNext0, nNext0 );
-    SplitBorderTracks( iSlice, bCurr, nCurr, jSlice, bNext, nNext );
+    MergeBorderTracks( iSlice, bCurr0, nCurr0, jSlice, bNext0, nNext0 );
+    MergeBorderTracks( iSlice, bCurr, nCurr, jSlice, bNext, nNext );
   }
 
   if ( bCurr0 ) delete[] bCurr0;
@@ -723,7 +733,7 @@ void AliHLTTPCCAMerger::Merging()
 
       if ( track.Used() ) continue;
       if ( track.PrevNeighbour() >= 0 ) continue;
-
+      //std::cout<<"Merged track candidate, nhits "<<track.NClusters()<<std::endl;
       AliHLTTPCCATrackParam startPoint = track.InnerParam(), endPoint = track.OuterParam();
       float startAlpha = track.InnerAlpha(), endAlpha = track.OuterAlpha();
 
@@ -797,42 +807,41 @@ void AliHLTTPCCAMerger::Merging()
       // need best t0!!!SG
 
       endPoint = startPoint;
-      if ( !FitTrack( endPoint, endAlpha, startPoint, startAlpha, hits + firstHit, nHits, 0 ) ) continue;
-      if ( !FitTrack( startPoint, startAlpha, endPoint, endAlpha, hits + firstHit, nHits, 1 ) ) continue;
 
+      if ( !FitTrack( endPoint, endAlpha, startPoint, startAlpha, hits + firstHit, nHits, 0,1 ) ) continue;
+      if ( !FitTrack( startPoint, startAlpha, endPoint, endAlpha, hits + firstHit, nHits, 1,1 ) ) continue;
       if ( nHits < 30 ) continue;    //SG!!!
 
-      AliHLTTPCCATrackParam &p = startPoint;
-
-      {
+      AliHLTTPCCATrackParam p = startPoint;
+      
+      if(0){
         double xTPC = 83.65; //SG!!!
-        double dAlpha = 0.00609235;
-        AliHLTTPCCATrackParam::AliHLTTPCCATrackFitParam fitPar;
-        p.CalculateFitParameters( fitPar );
-
-        if ( p.TransportToXWithMaterial( xTPC, fitPar, fSliceParam.GetBz( p ) ) ) {
+        double dAlpha = 0.349066;
+       double ymax = 2.* xTPC * CAMath::Tan( dAlpha / 2. );
+        
+        double dRot = 0;
+        if ( p.TransportToXWithMaterial( xTPC, fSliceParam.GetBz( p ) ) ) {
           double y = p.GetY();
-          double ymax = xTPC * CAMath::Tan( dAlpha / 2. );
-          if ( y > ymax ) {
-            if ( p.Rotate( dAlpha ) ) { startAlpha += dAlpha;  p.TransportToXWithMaterial( xTPC, fitPar, fSliceParam.GetBz( p ) ); }
-          } else if ( y < -ymax ) {
-            if ( p.Rotate( -dAlpha ) ) {  startAlpha -= dAlpha; p.TransportToXWithMaterial( xTPC, fitPar, fSliceParam.GetBz( p ) );}
+          if ( y > ymax ) {         
+            if ( p.Rotate( dAlpha ) ){
+              dRot = dAlpha;
+              p.TransportToXWithMaterial( xTPC, fSliceParam.GetBz( p ) );
+            }
+          } else if( y< -ymax ){
+            if ( p.Rotate( -dAlpha ) ){
+              dRot = -dAlpha;
+              p.TransportToXWithMaterial( xTPC, fSliceParam.GetBz( p ) );
+            }
           }
         }
+        
+        if ( -ymax <= p.GetY() && p.GetY() <= ymax && p.CheckNumericalQuality() ){
+          startPoint = p;
+          startAlpha+=dRot;
+        }     
       }
 
-      {
-        bool ok = 1;
-
-        const float *c = p.Cov();
-        for ( int i = 0; i < 15; i++ ) ok = ok && finite( c[i] );
-        for ( int i = 0; i < 5; i++ ) ok = ok && finite( p.Par()[i] );
-        ok = ok && ( p.GetX() > 50 );
-
-        if ( c[0] <= 0 || c[2] <= 0 || c[5] <= 0 || c[9] <= 0 || c[14] <= 0 ) ok = 0;
-        if ( c[0] > 5. || c[2] > 5. || c[5] > 2. || c[9] > 2 || c[14] > 2 ) ok = 0;
-        if ( !ok ) continue;
-      }
+      if ( !startPoint.CheckNumericalQuality() ) continue;
 
       AliHLTTPCCAMergedTrack &mergedTrack = outTracks[nOutTracks];
       mergedTrack.SetNClusters( nHits );
@@ -854,6 +863,9 @@ void AliHLTTPCCAMerger::Merging()
   }
 
   fOutput->SetNTracks( nOutTracks );
+  #ifdef HLTCA_STANDALONE
+  printf("Tracks Output: %d\n", nOutTracks);
+  #endif
   fOutput->SetNTrackClusters( nOutTrackClusters );
   fOutput->SetPointers();