]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/src/AliL3ConfMapper.cxx
fix reporting of writing speed when interrupted by signal.
[u/mrichter/AliRoot.git] / HLT / src / AliL3ConfMapper.cxx
index 0f369d33736ecd8b8bedc82858d52f93436ad189..aa68550f2d5101b0b613b79ff02cba08060762fe 100644 (file)
@@ -1,24 +1,29 @@
-//$Id$
+// @(#) $Id$
 
 // Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
-//*-- Copyright &copy ASV 
+//*-- Copyright &copy ALICE HLT Group
  
 #include "AliL3StandardIncludes.h"
 #include <sys/time.h>
 
-#include "AliL3ConfMapper.h"
 #include "AliL3Logging.h" 
 #include "AliL3Vertex.h"
 #include "AliL3ConfMapTrack.h"
 #include "AliL3ConfMapPoint.h"
 #include "AliL3TrackArray.h"
 #include "AliL3Transform.h"
+#include "AliL3ConfMapper.h"
 
+/** \class AliL3ConfMapper
+<pre>
 //_____________________________________________________________
 // AliL3ConfMapper
 //
 // Conformal mapping base class
 //
+</pre>
+*/
+
 ClassImp(AliL3ConfMapper)
 
 Double_t AliL3ConfMapper::pi=3.14159265358979323846;
@@ -34,9 +39,9 @@ AliL3ConfMapper::AliL3ConfMapper()
   fVolume = NULL;
   fRow = NULL;
   fBench = (Bool_t)true;
-  fParamSet = (Bool_t)false;
   fVertexConstraint = (Bool_t)true;
-  
+  fParamSet[0]=0;
+  fParamSet[1]=0;
 }
 
 
@@ -87,8 +92,8 @@ void AliL3ConfMapper::InitVolumes()
   memset(fVolume,0,fBounds*sizeof(AliL3ConfMapContainer));
   memset(fRow,0,fNumRowSegmentPlusOne*sizeof(AliL3ConfMapContainer));
   
-  Int_t max_num_of_tracks = 1000;
-  Int_t max_num_of_hits = 80000;
+  Int_t max_num_of_tracks = 2000;
+  Int_t max_num_of_hits = 120000;
   
   if(fHit)
     delete [] fHit;
@@ -100,7 +105,7 @@ void AliL3ConfMapper::InitVolumes()
 }
 
 void AliL3ConfMapper::InitSector(Int_t sector,Int_t *rowrange,Float_t *etarange)
-{
+{ //sector means slice here
   //Initialize tracker for tracking in a given sector.
   //Resets track and hit arrays.
   //Here it is also possible to specify a subsector, by defining
@@ -127,7 +132,6 @@ void AliL3ConfMapper::InitSector(Int_t sector,Int_t *rowrange,Float_t *etarange)
   else
     {
       fEtaMin = 0;
-      //fEtaMax = sector < 18 ? 1 : -1;
       fEtaMax = sector < 18 ? 0.9 : -0.9;
     }
   
@@ -148,8 +152,6 @@ void AliL3ConfMapper::InitSector(Int_t sector,Int_t *rowrange,Float_t *etarange)
   fTrack->Reset();
 }
 
-
-
 Bool_t AliL3ConfMapper::ReadHits(UInt_t count, AliL3SpacePointData* hits )
 {
   Int_t nhit=(Int_t)count; 
@@ -165,9 +167,13 @@ Bool_t AliL3ConfMapper::ReadHits(UInt_t count, AliL3SpacePointData* hits )
   return true;
 }
 
-
 void AliL3ConfMapper::SetPointers()
 {
+  //Check if there are not enough clusters to make a track in this sector
+  //Can happen in pp events.
+
+  if(fClustersUnused < fMinPoints[fVertexConstraint])
+    return;
   
   //Reset detector volumes
   memset(fVolume,0,fBounds*sizeof(AliL3ConfMapContainer));
@@ -180,7 +186,6 @@ void AliL3ConfMapper::SetPointers()
   Int_t local_counter=0;
   for(Int_t j=0; j<fClustersUnused; j++)
     {
-      
       //AliL3ConfMapPoint *thisHit = (AliL3ConfMapPoint*)fHit->At(j);
       AliL3ConfMapPoint *thisHit = &(fHit[j]);
 
@@ -196,6 +201,7 @@ void AliL3ConfMapper::SetPointers()
       
       if(thisHit->phiIndex<1 || thisHit->phiIndex>fNumPhiSegment)
        {
+         //cout << "Phiindex: " << thisHit->phiIndex << " " << thisHit->GetPhi() << endl;
          fPhiHitsOutOfRange++;
          continue;
        }
@@ -203,6 +209,7 @@ void AliL3ConfMapper::SetPointers()
       thisHit->etaIndex=(Int_t)((thisHit->GetEta()-fEtaMin)/etaSlice + 1);
       if(thisHit->etaIndex<1 || thisHit->etaIndex>fNumEtaSegment)
        {
+         //cout << "Etaindex: " << thisHit->etaIndex << " " << thisHit->GetEta() << endl;
          fEtaHitsOutOfRange++;
          continue;
        }
@@ -223,8 +230,6 @@ void AliL3ConfMapper::SetPointers()
       else
        ((AliL3ConfMapPoint *)(fRow[(localrow-fRowMin)].last))->nextRowHit = thisHit;
        fRow[(localrow-fRowMin)].last = (void *)thisHit;
-       
-       
     }
   
   if(fClustersUnused>0 && local_counter==0)
@@ -232,16 +237,17 @@ void AliL3ConfMapper::SetPointers()
       <<AliL3Log::kDec<<"No points passed to track finder, hits out of range: "
       <<fEtaHitsOutOfRange+fPhiHitsOutOfRange<<ENDLOG;
 
+  Int_t hits_accepted=fClustersUnused-(fEtaHitsOutOfRange+fPhiHitsOutOfRange);
   LOG(AliL3Log::kInformational,"AliL3ConfMapper::SetPointers","Setup")
     <<"Setup finished, hits out of range: "<<fEtaHitsOutOfRange+fPhiHitsOutOfRange
-    <<" hits accepted "<<fClustersUnused<<ENDLOG;
+    <<" hits accepted "<<hits_accepted<<ENDLOG;
 }
 
 void AliL3ConfMapper::MainVertexTracking_a()
 {
   //Tracking with vertex constraint.
 
-  if(!fParamSet)
+  if(!fParamSet[(Int_t)kTRUE])
     {
       LOG(AliL3Log::kError,"AliL3ConfMapper::MainVertexTracking","Parameters")<<AliL3Log::kDec<<
        "Tracking parameters not set!"<<ENDLOG;
@@ -250,6 +256,7 @@ void AliL3ConfMapper::MainVertexTracking_a()
 
   Double_t initCpuTime,cpuTime;
   initCpuTime = CpuTime();
+
   SetPointers();
   SetVertexConstraint(true);
   cpuTime = CpuTime() - initCpuTime;
@@ -263,7 +270,7 @@ void AliL3ConfMapper::MainVertexTracking_b()
 {
   //Tracking with vertex constraint.
 
-  if(!fParamSet)
+  if(!fParamSet[(Int_t)kTRUE])
     {
       LOG(AliL3Log::kError,"AliL3ConfMapper::MainVertexTracking","Parameters")<<AliL3Log::kDec<<
        "Tracking parameters not set!"<<ENDLOG;
@@ -284,7 +291,7 @@ void AliL3ConfMapper::MainVertexTracking()
 {
   //Tracking with vertex constraint.
 
-  if(!fParamSet)
+  if(!fParamSet[(Int_t)kTRUE])
     {
       LOG(AliL3Log::kError,"AliL3ConfMapper::MainVertexTracking","Parameters")<<AliL3Log::kDec<<
        "Tracking parameters not set!"<<ENDLOG;
@@ -313,7 +320,14 @@ void AliL3ConfMapper::NonVertexTracking()
   //in order to do tracking on the remaining clusters.
   //The conformal mapping is now done with respect to the first cluster
   //assosciated with this track.
-
+  
+  if(!fParamSet[(Int_t)kFALSE])
+    {
+      LOG(AliL3Log::kError,"AliL3ConfMapper::NonVertexTracking","Parameters")<<AliL3Log::kDec<<
+       "Tracking parameters not set!"<<ENDLOG;
+      return;
+    }
+  
   SetVertexConstraint(false);
   ClusterLoop();
   LOG(AliL3Log::kInformational,"AliL3ConfMapper::NonVertexTracking","ntracks")<<AliL3Log::kDec<<
@@ -337,6 +351,7 @@ void AliL3ConfMapper::MainVertexSettings(Int_t trackletlength, Int_t tracklength
   SetMinPoints(tracklength,(Bool_t)true);
   fMaxPhi=maxphi;
   fMaxEta=maxeta;
+  SetParamDone(kTRUE);
 }
 
 void AliL3ConfMapper::NonVertexSettings(Int_t trackletlength, Int_t tracklength,
@@ -346,10 +361,10 @@ void AliL3ConfMapper::NonVertexSettings(Int_t trackletlength, Int_t tracklength,
   SetRowScopeTracklet(rowscopetracklet, (Bool_t)false);
   SetRowScopeTrack(rowscopetrack, (Bool_t)false);
   SetMinPoints(tracklength,(Bool_t)false);
+  SetParamDone(kFALSE);
 }
 
-void AliL3ConfMapper::SetTrackCuts(Double_t hitChi2Cut, Double_t goodHitChi2, Double_t trackChi2Cut,Int_t maxdist,
-                                  Bool_t vertexconstraint)
+void AliL3ConfMapper::SetTrackCuts(Double_t hitChi2Cut, Double_t goodHitChi2, Double_t trackChi2Cut,Int_t maxdist,Bool_t vertexconstraint)
 {
   //Settings for tracks. The cuts are:
   //HitChi2Cut:     Maximum hit chi2
@@ -375,7 +390,12 @@ void AliL3ConfMapper::SetTrackletCuts(Double_t maxangle,Double_t goodDist, Bool_
 void AliL3ConfMapper::ClusterLoop()
 {
   //Loop over hits, starting at outermost padrow, and trying to build segments.
-
+  
+  //Check if there are not enough clusters to make a track in this sector
+  //Can happen in pp events.
+  if(fClustersUnused < fMinPoints[fVertexConstraint])
+    return;
+  
   Int_t row_segm,lastrow = fRowMin + fMinPoints[fVertexConstraint];
   AliL3ConfMapPoint *hit;
   
@@ -386,6 +406,7 @@ void AliL3ConfMapper::ClusterLoop()
     {
       if(fRow[(row_segm-fRowMin)].first && ((AliL3ConfMapPoint*)fRow[(row_segm-fRowMin)].first)->GetPadRow() < fRowMin + 1)
        break;
+
       for(hit = (AliL3ConfMapPoint*)fRow[(row_segm-fRowMin)].first; hit!=0; hit=hit->nextRowHit)
        {
          if(hit->GetUsage() == true)
@@ -583,8 +604,8 @@ AliL3ConfMapPoint *AliL3ConfMapper::GetNextNeighbor(AliL3ConfMapPoint *start_hit
     }
 
   //make a smart loop
-  Int_t loop_eta[9] = {0,0,0,-1,-1,-1,1,1,1};
-  Int_t loop_phi[9] = {0,-1,1,0,-1,1,0,-1,1};
+  Int_t loop_eta[25] = {0,0,0,-1,-1,-1,1,1,1, 0,0,-1,-1,1,1,-2,-2,-2,-2,-2,2,2,2,2,2};
+  Int_t loop_phi[25] = {0,-1,1,0,-1,1,0,-1,1, -2,2,-2,2,-2,2,-2,-1,0,1,2,-2,-1,0,1,2};
   
   if(min_row < fRowMin)
     min_row = fRowMin;
@@ -601,12 +622,15 @@ AliL3ConfMapPoint *AliL3ConfMapper::GetNextNeighbor(AliL3ConfMapPoint *start_hit
            {
              sub_phi_segm = start_hit->phiIndex + loop_phi[i];
              
-             if(sub_phi_segm<0)
+             if(sub_phi_segm < 0 || sub_phi_segm >= fNumPhiSegment)
+               continue;
+             /*
+               if(sub_phi_segm<0)
                sub_phi_segm += fNumPhiSegment;
-             
-             else if(sub_phi_segm >=fNumPhiSegment)
+               
+               else if(sub_phi_segm >=fNumPhiSegment)
                sub_phi_segm -= fNumPhiSegment;
-             
+             */
              //loop over sub eta segments
              
              sub_eta_segm = start_hit->etaIndex + loop_eta[i];
@@ -763,14 +787,50 @@ Bool_t AliL3ConfMapper::VerifyRange(const AliL3ConfMapPoint *hit1,const AliL3Con
 
 }
 
-Double_t AliL3ConfMapper::TrackletAngle(const AliL3ConfMapTrack *track,Int_t n) const
+Double_t AliL3ConfMapper::TrackletAngle(AliL3ConfMapTrack *track,Int_t n) const
 {
   // Returns the angle 'between' the last three points (started at point number n) on this track.
-
-  return 0;
-  /*
+  
+  if(n > track->GetNumberOfPoints())
+    n = track->GetNumberOfPoints();
+  
+  if(n<3)
+    return 0;
+  
   Double_t x1[2];
   Double_t x2[2];
+  Double_t x3[2];
+  Double_t angle1,angle2;
+  Int_t counter=0;
+  for(track->StartLoop(); track->LoopDone(); track->GetNextHit())
+    {
+      AliL3ConfMapPoint *p = (AliL3ConfMapPoint*)track->currentHit;
+      if( (n-1) == counter)
+       {
+         x1[0] = p->GetX();
+         x1[1] = p->GetY();
+       }
+      else if( (n-2) == counter)
+       {
+         x2[0] = p->GetX();
+         x2[1] = p->GetY();
+       }
+      else if( (n-3) == counter)
+       {
+         x3[0] = p->GetX();
+         x3[1] = p->GetY();
+       }
+      counter++;
+    }
+  
+  angle1 = atan2(x2[1]-x3[1],x2[0]-x3[0]);
+  angle2 = atan2(x1[1]-x2[1],x1[0]-x2[0]);
+  
+  return fabs(angle1-angle2);
+  
+  /*
+    Double_t x1[2];
+  Double_t x2[2];
   Double_t angle1,angle2;
   TObjArray *hits = track->GetHits();
   
@@ -815,6 +875,7 @@ Int_t AliL3ConfMapper::FillTracks()
     {
       AliL3ConfMapTrack *track = (AliL3ConfMapTrack*)fTrack->GetTrack(i);
       track->Fill(fVertex,fMaxDca);
+      
     }
   return 1;