]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDseedV1.cxx
More Coverity stuff ..
[u/mrichter/AliRoot.git] / TRD / AliTRDseedV1.cxx
index eac63403ae8a39fa74ac33d3b05c58d2f9a1fe31..3061dcd826838582246031483ba42f7c66ff596b 100644 (file)
@@ -416,38 +416,29 @@ void AliTRDseedV1::CookdEdx(Int_t nslices)
   memset(fdEdx, 0, kNslices*sizeof(Float_t));
   const Double_t kDriftLength = (.5 * AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick());
 
-  for(int ic=0; ic<kNtb; ic++){
-    AliTRDcluster *c(NULL); Float_t qt(0.);
-    if(fClusters[ic]){
-      c = fClusters[ic];
-      qt += TMath::Abs(c->GetQ());
-    }
-    if(fClusters[ic+kNtb]){
-      c = fClusters[ic+kNtb];
-      qt += TMath::Abs(c->GetQ());
-    }
-    if(!c) continue; // no cluster found
-    Float_t dx(fX0 - c->GetX());
-    
+  AliTRDcluster *c(NULL);
+  for(int ic=0; ic<AliTRDtrackerV1::GetNTimeBins(); ic++){
+    if(!(c = fClusters[ic]) && !(c = fClusters[ic+kNtb])) continue;
+    Float_t dx = TMath::Abs(fX0 - c->GetX());
+
     // Filter clusters for dE/dx calculation
-    
+
     // 1.consider calibration effects for slice determination
-    Int_t slice(0);
-    if(dx<0.) slice = 0; // amplification region ?!
-    else if(dx<kDriftLength) slice = Int_t(dx * nslices / kDriftLength); // TODO should be replaced by c->IsInChamber()
-    else slice = nslices-1;
+    Int_t slice;
+    if(dx<kDriftLength){ // TODO should be replaced by c->IsInChamber()
+      slice = Int_t(dx * nslices / kDriftLength);
+    } else slice = c->GetX() < fX0 ? nslices-1 : 0;
+
 
     // 2. take sharing into account
     Float_t w = /*c->IsShared() ? .5 :*/ 1.;
-    
+
     // 3. take into account large clusters TODO
     //w *= c->GetNPads() > 3 ? .8 : 1.;
-    
-    fdEdx[slice]   += w * qt;
-  } // End of loop over clusters
 
-  // normalization to track inclination
-  for(Int_t is(0); is<nslices; is++) fdEdx[is] /= TMath::Sqrt(1. + fYfit[1]*fYfit[1] + fZref[1]*fZref[1]);
+    //CHECK !!!
+    fdEdx[slice]   += w * GetdQdl(ic); //fdQdl[ic];
+  } // End of loop over clusters
 }
 
 //_____________________________________________________________________________
@@ -506,6 +497,47 @@ Float_t AliTRDseedV1::GetCharge(Bool_t useOutliers)
   return qt;
 }
 
+//____________________________________________________________________
+Bool_t AliTRDseedV1::GetEstimatedCrossPoint(Float_t &x, Float_t &z) const
+{
+// Algorithm to estimate cross point in the x-z plane for pad row cross tracklets.
+// Returns true in case of success.
+  if(!IsRowCross()) return kFALSE;
+
+  x=0.; z=0.;
+  AliTRDcluster *c(NULL);
+  // Find radial range for first row
+  Float_t x1[] = {0., 1.e3};
+  for(int ic=0; ic<kNtb; ic++){
+    if(!(c=fClusters[ic])) continue;
+    if(!c->IsInChamber()) continue;
+    if(c->GetX() <= x1[1]) x1[1] = c->GetX();
+    if(c->GetX() >= x1[0]) x1[0] = c->GetX();
+    z=c->GetZ();
+  }
+  if((x1[0] - x1[1])<1.e-5) return kFALSE;
+
+  // Find radial range for second row
+  Bool_t kZ(kFALSE);
+  Float_t x2[] = {0., 1.e3};
+  for(int ic=kNtb; ic<kNclusters; ic++){
+    if(!(c=fClusters[ic])) continue;
+    if(!c->IsInChamber()) continue;
+    if(c->GetX() <= x2[1]) x2[1] = c->GetX();
+    if(c->GetX() >= x2[0]) x2[0] = c->GetX();
+    if(!kZ){
+      z+=c->GetZ();
+      z*=0.5;
+      kZ=kTRUE;
+    }
+  }
+  if((x2[0] - x2[1])<1.e-5) return kFALSE;
+
+  // Find intersection of the 2 radial regions
+  x = 0.5*((x1[0]+x1[1] > x2[0]+x2[1]) ? (x1[1]+x2[0]) : (x1[0]+x2[1]));
+  return kTRUE;
+}
+
 //____________________________________________________________________
 Float_t AliTRDseedV1::GetdQdl(Int_t ic, Float_t *dl) const
 {