]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDchamberTimeBin.cxx
Small speedup for a very often used function
[u/mrichter/AliRoot.git] / TRD / AliTRDchamberTimeBin.cxx
index ccc024285bc2c4d29df635917ea5a91620abb348..2d9057bc99e0a8c13cecc856f5407fe40401d393 100644 (file)
@@ -107,10 +107,10 @@ AliTRDchamberTimeBin &AliTRDchamberTimeBin::operator=(const AliTRDchamberTimeBin
 //_____________________________________________________________________________
 void AliTRDchamberTimeBin::Clear(const Option_t *) 
 { 
-  for(AliTRDcluster **cit = &fClusters[0]; (*cit); cit++){
-    if(IsOwner()) delete (*cit);
-    (*cit) = NULL;
-  } 
+  if(IsOwner())
+    for(Int_t it = 0; it<kMaxClustersLayer; it++)
+      delete fClusters[it];
+  memset(fClusters,0,kMaxClustersLayer*sizeof(fClusters[0]));
   fN = 0; 
 }
 
@@ -246,7 +246,7 @@ void AliTRDchamberTimeBin::BuildIndices(Int_t iter)
   // Select clusters that belong to the Stack
   Int_t nClStack = 0;                                  // Internal counter
   for(Int_t i = 0; i < fN; i++){
-    if(fClusters[i]->IsUsed()){
+    if(fClusters[i]->IsUsed() || fClusters[i]->IsShared()){
       fClusters[i] = 0x0;
       fIndex[i] = 0xffff;
     } else nClStack++;
@@ -318,13 +318,14 @@ void AliTRDchamberTimeBin::BuildIndices(Int_t iter)
     
     // Debug Streaming
     if(fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) >= 3){
+      AliTRDcluster dcl(*cl);
       TTreeSRedirector &cstream = *fReconstructor->GetDebugStream(AliTRDReconstructor::kTracker);
       cstream << "BuildIndices"
       << "Plane="    << fPlane
       << "Stack="    << fStack
       << "Sector="   << fSector
       << "Iter="     << iter
-      << "C.="       << cl
+      << "C.="       << &dcl
       << "rowIndex=" << rowIndex
       << "\n";
     }
@@ -589,7 +590,10 @@ void AliTRDchamberTimeBin::GetClusters(Double_t *cond, Int_t *index, Int_t& ncl,
   PrintClusters();
   AliInfo(Form("zlo[%f] zhi[%f]", zvals[0], zvals[1]));
   AliInfo(Form("zlo[%d] zhi[%d]", zlo, zhi));*/
-  
+
+  Double_t ylo = cond[0] - cond[2],
+           yhi = cond[0] + cond[2];
+  //printf("CTB : ylo[%f] yhi[%f]\n", ylo, yhi);
   //Preordering in Direction z saves a lot of loops (boundary checked)
   for(UChar_t z = zlo; z <= zhi; z++){
     UInt_t upper = (z < fNRows-1) ? fPositions[z+1] : fN;
@@ -600,8 +604,8 @@ void AliTRDchamberTimeBin::GetClusters(Double_t *cond, Int_t *index, Int_t& ncl,
         return;        //Buffer filled
       }
       
-      if(fClusters[y]->GetY() > (cond[0] + cond[2])) break;                    // Abbortion conditions!!!
-      if(fClusters[y]->GetY() < (cond[0] - cond[2])) continue; // Too small
+      if(fClusters[y]->GetY() > yhi) break;                    // Abbortion conditions!!!
+      if(fClusters[y]->GetY() < ylo) continue; // Too small
       if(((Int_t)((fClusters[y]->GetZ())*1000) < (Int_t)(zvals[0]*1000)) || ((Int_t)((fClusters[y]->GetZ())*1000) > (Int_t)(zvals[1]*1000))){/*printf("exit z\n"); TODO*/ continue;}
       index[ncl] = y;
       ncl++;