]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/TPCLib/AliHLTTPCConfMapper.cxx
Qmax for merged clusters fixed
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCConfMapper.cxx
index de6860df10774941c8721e9a95ecaec06249fea6..5d56c20651c701cd7a9681b6a95ad7630da7c960 100644 (file)
@@ -1,18 +1,30 @@
 // @(#) $Id$
 // Original: AliHLTConfMapper.cxx,v 1.26 2005/06/14 10:55:21 cvetan Exp $
 
-/** \class AliHLTTPCConfMapper
-<pre>
-//_____________________________________________________________
-// AliHLTTPCConfMapper
-//
-// Conformal mapping base class
-//
-// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
-// Copyright &copy ALICE HLT Group
-</pre>
+//**************************************************************************
+//* This file is property of and copyright by the ALICE HLT Project        * 
+//* ALICE Experiment at CERN, All rights reserved.                         *
+//*                                                                        *
+//* Primary Authors: Anders Vestbo, maintained by
+//*                  Matthias Richter <Matthias.Richter@ift.uib.no>        *
+//*                  for The ALICE HLT Project.                            *
+//*                                                                        *
+//* Permission to use, copy, modify and distribute this software and its   *
+//* documentation strictly for non-commercial purposes is hereby granted   *
+//* without fee, provided that the above copyright notice appears in all   *
+//* copies and that both the copyright notice and this permission notice   *
+//* appear in the supporting documentation. The authors make no claims     *
+//* about the suitability of this software for any purpose. It is          *
+//* provided "as is" without express or implied warranty.                  *
+//**************************************************************************
+
+/** @file   AliHLTTPCConfMapper.cxx
+    @author Anders Vestbo, Matthias Richter
+    @date   Conformal mapping base class.
+    @brief  
 */
 
+#include <cassert>
 #include <sys/time.h>
  
 #include "AliHLTTPCRootTypes.h"
@@ -37,7 +49,7 @@ AliHLTTPCConfMapper::AliHLTTPCConfMapper()
   fNTracks(0),
   fVertex(NULL),
   fVertexFinder(kFALSE),
-  fHit(NULL),
+  fHit(),
   fTrack(NULL),
   fMaxDca(0.0), // no clue whether this is reasonable, but at least better than without initialization
   fVolume(NULL),
@@ -58,25 +70,34 @@ AliHLTTPCConfMapper::AliHLTTPCConfMapper()
   fEtaMax(0),
   fRowMin(0),
   fRowMax(0),
-  fVertexConstraint(kTRUE)
+  fVertexConstraint(kTRUE),
+  fGoodDist(0.0),
+  fMaxPhi(0.0),
+  fMaxEta(0.0),
+  fMainVertexTracks(0),
+  fClustersUnused(0),
+  fClusterCutZ(-1)
 {
   //Default constructor
-  fParamSet[0]=0;
-  fParamSet[1]=0;
+  memset(fParamSet, 0, sizeof(fParamSet));
+  memset(fTrackletLength, 0, sizeof(fTrackletLength));
+  memset(fRowScopeTracklet, 0, sizeof(fRowScopeTracklet));
+  memset(fRowScopeTrack, 0, sizeof(fRowScopeTrack));
+  memset(fMinPoints, 0, sizeof(fMinPoints));
+  
+  memset(fMaxAngleTracklet, 0, sizeof(fMaxAngleTracklet));
+  memset(fMaxDist, 0, sizeof(fMaxDist));
+  memset(fHitChi2Cut, 0, sizeof(fHitChi2Cut));
+  memset(fGoodHitChi2, 0, sizeof(fGoodHitChi2));
+  memset(fTrackChi2Cut, 0, sizeof(fTrackChi2Cut));
 }
 
 AliHLTTPCConfMapper::~AliHLTTPCConfMapper()
 {
   // Destructor.
-  if(fVolume) {
-    delete [] fVolume;
-  }
   if(fRow) {
     delete [] fRow;
   }
-  if(fHit) {
-    delete [] fHit;
-  }
   if(fTrack) {
     delete fTrack;
   }
@@ -94,32 +115,21 @@ void AliHLTTPCConfMapper::InitVolumes()
   fNumEtaSegmentPlusOne = fNumEtaSegment+1;
   fNumPhiEtaSegmentPlusOne = fNumPhiSegmentPlusOne*fNumEtaSegmentPlusOne;
   fBounds = fNumRowSegmentPlusOne * fNumPhiSegmentPlusOne * fNumEtaSegmentPlusOne;
+
+  Reset();
   
-  //Allocate volumes:
+  fTrack = new AliHLTTPCTrackArray("AliHLTTPCConfMapTrack",10);
+}
+
+void AliHLTTPCConfMapper::Reset()
+{
   if(fVolume) delete [] fVolume;
+  fVolume=NULL;
   if(fRow) delete [] fRow;
+  fRow=NULL;
   
-  LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
-    "Allocating "<<fBounds*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fVolume"<<ENDLOG;
-  LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
-    "Allocating "<<fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fRow"<<ENDLOG;
-  
-  fVolume = new AliHLTTPCConfMapContainer[fBounds];
-  fRow = new AliHLTTPCConfMapContainer[fNumRowSegmentPlusOne];
-  
-  memset(fVolume,0,fBounds*sizeof(AliHLTTPCConfMapContainer));
-  memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer));
-  
-  Int_t maxnumoftracks = 2000;
-  Int_t maxnumofhits = 120000;
-  
-  if(fHit)
-    delete [] fHit;
-  if(fTrack)
-    delete fTrack;
-    
-  fHit = new AliHLTTPCConfMapPoint[maxnumofhits];
-  fTrack = new AliHLTTPCTrackArray("AliHLTTPCConfMapTrack",maxnumoftracks);
+  fClustersUnused=0;
+  fHit.clear();
 }
 
 void AliHLTTPCConfMapper::InitSector(Int_t sector,Int_t *rowrange,Float_t *etarange)
@@ -171,18 +181,55 @@ void AliHLTTPCConfMapper::InitSector(Int_t sector,Int_t *rowrange,Float_t *etara
 }
 
 Bool_t AliHLTTPCConfMapper::ReadHits(UInt_t count, AliHLTTPCSpacePointData* hits )
+{
+  //read hits with ReadHitsChecked  
+  return ReadHitsChecked(count,hits,0);
+}
+
+Bool_t AliHLTTPCConfMapper::ReadHitsChecked(UInt_t count, AliHLTTPCSpacePointData* hits, unsigned int sizeInByte )
 {
   //read hits
-  Int_t nhit=(Int_t)count; 
-  for (Int_t i=0;i<nhit;i++)
-    {  
-      fHit[i+fClustersUnused].Reset();
-      fHit[i+fClustersUnused].ReadHits(&(hits[i]));
-    }
-  fClustersUnused += nhit;
+  if(fClusterCutZ == -1){
+    if (fHit.size()<fClustersUnused+count) fHit.resize(fClustersUnused+count);
+    assert(fHit.size()>=fClustersUnused+count);
+    for (Int_t i=0;(UInt_t)i<count;i++)
+      {        
+       AliHLTTPCSpacePointData *hit = &hits[i];
+       if (sizeInByte>0 && ((AliHLTUInt8_t*)hit)+sizeof(AliHLTTPCSpacePointData)>((AliHLTUInt8_t*)hits)+sizeInByte) {
+         LOG(AliHLTTPCLog::kWarning,"AliHLTTPCConfMapper::ReadHits","")<<"Wrong size of data (" << sizeInByte << " byte), skipping array of AliHLTTPCSpacePointData" <<ENDLOG;;
+         break;
+       }
+       fHit[i+fClustersUnused].Reset();
+       fHit[i+fClustersUnused].Read(hits[i]);
+      }
+    fClustersUnused += count;
+  }
+  else{
+    //Skipping clusters with high Z. 
+    UInt_t skipped=0;
+    
+    if (fHit.size()<fClustersUnused+count) fHit.resize(fClustersUnused+count);
+    assert(fHit.size()>=fClustersUnused+count);
+    for (Int_t i=0;(UInt_t)i<count;i++)
+      {  
+       AliHLTTPCSpacePointData *hit = &hits[i];
+       if (sizeInByte>0 && ((AliHLTUInt8_t*)hit)+sizeof(AliHLTTPCSpacePointData)>((AliHLTUInt8_t*)hits)+sizeInByte) {
+         LOG(AliHLTTPCLog::kWarning,"AliHLTTPCConfMapper::ReadHits","")<<"Wrong size of data (" << sizeInByte << " byte), skipping array of AliHLTTPCSpacePointData" <<ENDLOG;;
+         break;
+       }
+       if(hits[i].fZ > fClusterCutZ || hits[i].fZ < -1*fClusterCutZ){
+         ++skipped;
+         continue;
+       }
+       fHit[i+fClustersUnused-skipped].Reset();
+       fHit[i+fClustersUnused-skipped].Read(hits[i]);
+      }
+    fClustersUnused += count - skipped;
+    fHit.resize(fClustersUnused);
+  }
 
   LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::ReadHits","#hits")
-    <<AliHLTTPCLog::kDec<<"hit_counter: "<<nhit<<" count: "<<count<<ENDLOG;
+    <<AliHLTTPCLog::kDec<<"#hits: "<<count<<" total: "<<fClustersUnused<<ENDLOG;
   
   return true;
 }
@@ -195,7 +242,19 @@ void AliHLTTPCConfMapper::SetPointers()
   if(fClustersUnused < fMinPoints[fVertexConstraint])
     return;
   
-  //Reset detector volumes
+  //Allocate detector volumes
+  if (fVolume==NULL) {
+    LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
+      "Allocating "<<fBounds*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fVolume"<<ENDLOG;
+    fVolume = new AliHLTTPCConfMapContainer[fBounds];
+  }
+
+  if (fRow==NULL) {
+    LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::InitVolumes","Memory")<<AliHLTTPCLog::kDec<<
+      "Allocating "<<fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer)<<" Bytes to fRow"<<ENDLOG;
+    fRow = new AliHLTTPCConfMapContainer[fNumRowSegmentPlusOne];
+  }
+  
   memset(fVolume,0,fBounds*sizeof(AliHLTTPCConfMapContainer));
   memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliHLTTPCConfMapContainer));
   
@@ -204,9 +263,9 @@ void AliHLTTPCConfMapper::SetPointers()
 
   Int_t volumeIndex;
   Int_t localcounter=0;
+  assert((int)fHit.size()>=fClustersUnused);
   for(Int_t j=0; j<fClustersUnused; j++)
     {
-      //AliHLTTPCConfMapPoint *thisHit = (AliHLTTPCConfMapPoint*)fHit->At(j);
       AliHLTTPCConfMapPoint *thisHit = &(fHit[j]);
 
       thisHit->Setup(fVertex);
@@ -253,15 +312,20 @@ void AliHLTTPCConfMapper::SetPointers()
        fRow[(localrow-fRowMin)].last = (void *)thisHit;
     }
   
+  //If a cluster has an Eta outside the Eta or Phi range set in the Tracker, it will go in to
+  //the if here. This has been seen for high Eta clusters most likely from signal from the gating grid.
+  //These clusters are read in, but not used in the Tracking. 
+#ifdef PACKAGE_STRING
   if(fClustersUnused>0 && localcounter==0)
-    LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::SetPointers","Parameters")
+    LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::SetPointers","Parameters")
       <<AliHLTTPCLog::kDec<<"No points passed to track finder, hits out of range: "
       <<fEtaHitsOutOfRange+fPhiHitsOutOfRange<<ENDLOG;
 
   Int_t hits_accepted=fClustersUnused-(fEtaHitsOutOfRange+fPhiHitsOutOfRange);
-  LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::SetPointers","Setup")
+  LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::SetPointers","Setup")
     <<"Setup finished, hits out of range: "<<fEtaHitsOutOfRange+fPhiHitsOutOfRange
     <<" hits accepted "<<hits_accepted<<ENDLOG;
+#endif //PACKAGE_STRING
 }
 
 void AliHLTTPCConfMapper::MainVertexTrackingA()
@@ -282,7 +346,7 @@ void AliHLTTPCConfMapper::MainVertexTrackingA()
   SetVertexConstraint(true);
   cpuTime = CpuTime() - initCpuTime;
   if(fBench)
-    LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTrackingA","Timing")
+    LOG(AliHLTTPCLog::kBenchmark,"AliHLTTPCConfMapper::MainVertexTrackingA","Timing")
       <<AliHLTTPCLog::kDec<<"Setup finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
   
 }
@@ -304,7 +368,7 @@ void AliHLTTPCConfMapper::MainVertexTrackingB()
  
   cpuTime = CpuTime() - initCpuTime;
   if(fBench)
-    LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTrackingB","Timing")
+    LOG(AliHLTTPCLog::kBenchmark,"AliHLTTPCConfMapper::MainVertexTrackingB","Timing")
       <<AliHLTTPCLog::kDec<<"Main Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
 }
 
@@ -330,7 +394,7 @@ void AliHLTTPCConfMapper::MainVertexTracking()
 
   cpuTime = CpuTime() - initCpuTime;
   if(fBench)
-    LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::MainVertexTracking","Timing")<<AliHLTTPCLog::kDec<<
+    LOG(AliHLTTPCLog::kBenchmark,"AliHLTTPCConfMapper::MainVertexTracking","Timing")<<AliHLTTPCLog::kDec<<
       "Tracking finished in "<<cpuTime*1000<<" ms"<<ENDLOG;
   
   return;
@@ -672,6 +736,7 @@ AliHLTTPCConfMapPoint *AliHLTTPCConfMapper::GetNextNeighbor(AliHLTTPCConfMapPoin
                    "VolumeIndex error "<<volumeIndex<<ENDLOG;
                }
              
+             assert(fVolume!=NULL);
              for(hit = (AliHLTTPCConfMapPoint*)fVolume[volumeIndex].first;
                  hit!=0; hit = hit->GetNextVolumeHit())
                {
@@ -825,9 +890,9 @@ Double_t AliHLTTPCConfMapper::TrackletAngle(AliHLTTPCConfMapTrack *track,Int_t n
   if(n<3)
     return 0;
   
-  Double_t x1[2];
-  Double_t x2[2];
-  Double_t x3[2];
+  Double_t x1[2]={0,0};
+  Double_t x2[2]={0,0};
+  Double_t x3[2]={0,0};
   Double_t angle1,angle2;
   Int_t counter=0;
   for(track->StartLoop(); track->LoopDone(); track->GetNextHit())
@@ -890,12 +955,12 @@ Int_t AliHLTTPCConfMapper::FillTracks()
   Int_t numoftracks = fNTracks;
   if(fNTracks == 0)
     {
-      LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
+      LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
        "No tracks found!!"<<ENDLOG;
       return 0;
     }
 
-  LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
+  LOG(AliHLTTPCLog::kInformational,"AliHLTTPCConfMapper::FillTracks","fNTracks")<<AliHLTTPCLog::kDec<<
     "Number of found tracks: "<<fNTracks<<ENDLOG;
   
   //  fTrack->Sort();