]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDseedV1.cxx
- Replace the TClonesArray of AliMUONTrackParam by a TObjArray in
[u/mrichter/AliRoot.git] / TRD / AliTRDseedV1.cxx
index 918ed71321696ff136485d4640a47367fc837048..3061dcd826838582246031483ba42f7c66ff596b 100644 (file)
 
 #include "AliLog.h"
 #include "AliMathBase.h"
+#include "AliRieman.h"
 #include "AliCDBManager.h"
-#include "AliTracker.h"
 
+#include "AliTRDReconstructor.h"
 #include "AliTRDpadPlane.h"
 #include "AliTRDcluster.h"
 #include "AliTRDseedV1.h"
@@ -58,6 +59,8 @@
 #include "Cal/AliTRDCalROC.h"
 #include "Cal/AliTRDCalDet.h"
 
+class AliTracker;
+
 ClassImp(AliTRDseedV1)
 
 //____________________________________________________________________
@@ -228,6 +231,28 @@ void AliTRDseedV1::Copy(TObject &ref) const
 }
 
 
+//____________________________________________________________
+void AliTRDseedV1::Init(const AliRieman *rieman)
+{
+// Initialize this tracklet using the riemann fit information
+
+
+  fZref[0] = rieman->GetZat(fX0);
+  fZref[1] = rieman->GetDZat(fX0);
+  fYref[0] = rieman->GetYat(fX0);
+  fYref[1] = rieman->GetDYat(fX0);
+  if(fkReconstructor && fkReconstructor->IsHLT()){
+    fRefCov[0] = 1;
+    fRefCov[2] = 10;
+  }else{
+    fRefCov[0] = rieman->GetErrY(fX0);
+    fRefCov[2] = rieman->GetErrZ(fX0);
+  }
+  fC[0]    = rieman->GetC(); 
+  fChi2    = rieman->GetChi2();
+}
+
+
 //____________________________________________________________
 Bool_t AliTRDseedV1::Init(AliTRDtrackV1 *track)
 {
@@ -395,22 +420,22 @@ void AliTRDseedV1::CookdEdx(Int_t nslices)
   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;
-    if(dx<kDriftLength){ // TODO should be replaced by c->IsInChamber() 
+    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.;
-    
+
     //CHECK !!!
     fdEdx[slice]   += w * GetdQdl(ic); //fdQdl[ic];
   } // End of loop over clusters
@@ -444,6 +469,8 @@ void AliTRDseedV1::CookLabels()
 //____________________________________________________________
 Float_t AliTRDseedV1::GetAnodeWireOffset(Float_t zt)
 {
+// Find position inside the amplification cell for reading drift velocity map
+
   Float_t d = fPad[3] - zt;
   if(d<0.){
     AliError(Form("Fail AnodeWireOffset calculation z0[%+7.2f] zt[%+7.2f] d[%+7.2f].", fPad[3], zt, d));
@@ -455,6 +482,62 @@ Float_t AliTRDseedV1::GetAnodeWireOffset(Float_t zt)
 }
 
 
+//____________________________________________________________________
+Float_t AliTRDseedV1::GetCharge(Bool_t useOutliers)
+{
+// Computes total charge attached to tracklet. If "useOutliers" is set clusters 
+// which are not in chamber are also used (default false)
+
+  AliTRDcluster *c(NULL); Float_t qt(0.);
+  for(int ic=0; ic<kNclusters; ic++){
+    if(!(c=fClusters[ic])) continue;
+    if(c->IsInChamber() && !useOutliers) continue;
+    qt += TMath::Abs(c->GetQ());
+  }
+  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
 {
@@ -484,7 +567,8 @@ Float_t AliTRDseedV1::GetdQdl(Int_t ic, Float_t *dl) const
   if(fClusters[ic] && fClusters[ic]->IsInChamber()){
     hasClusterInChamber = kTRUE;
     dq += TMath::Abs(fClusters[ic]->GetQ());
-  }else if(fClusters[ic+kNtb] && fClusters[ic+kNtb]->IsInChamber()){
+  }
+  if(fClusters[ic+kNtb] && fClusters[ic+kNtb]->IsInChamber()){
     hasClusterInChamber = kTRUE;
     dq += TMath::Abs(fClusters[ic+kNtb]->GetQ());
   }
@@ -791,6 +875,8 @@ Double_t AliTRDseedV1::GetCovInv(const Double_t * const c, Double_t *d)
 //____________________________________________________________________
 UShort_t AliTRDseedV1::GetVolumeId() const
 {
+// Returns geometry volume id by delegation 
+
   for(Int_t ic(0);ic<kNclusters; ic++){
     if(fClusters[ic]) return fClusters[ic]->GetVolumeId();
   }
@@ -868,7 +954,7 @@ void AliTRDseedV1::SetOwner()
 }
 
 //____________________________________________________________
-void AliTRDseedV1::SetPadPlane(AliTRDpadPlane *p)
+void AliTRDseedV1::SetPadPlane(AliTRDpadPlane * const p)
 {
 // Shortcut method to initialize pad geometry.
   fPad[0] = p->GetLengthIPad();
@@ -1318,7 +1404,7 @@ Bool_t AliTRDseedV1::Fit(UChar_t opt)
   }
   if(!IsCalibrated()) Calibrate();
   if(opt>2){
-    AliWarning(Form("Option [%d] outside range [0, 2]. Using default"));
+    AliWarning(Form("Option [%d] outside range [0, 2]. Using default",opt));
     opt=0;
   }
 
@@ -1405,12 +1491,13 @@ Bool_t AliTRDseedV1::Fit(UChar_t opt)
 
   // to few clusters
   if (n < kClmin){ 
+    AliDebug(1, Form("Not enough clusters to fit. Clusters: Attached[%d] Fit[%d].", GetN(), n));
     SetErrorMsg(kFitCl);
     return kFALSE; 
   }
-
   // fit XY
   if(!fitterY.Eval()){
+    AliDebug(1, "Fit Y failed.");
     SetErrorMsg(kFitFailedY);
     return kFALSE;
   }
@@ -1453,7 +1540,7 @@ Bool_t AliTRDseedV1::Fit(UChar_t opt)
   // fit QZ
   if(opt!=1 && IsRowCross()){
     if(!fitterZ.Eval()) SetErrorMsg(kFitFailedZ);
-    if(!HasError(kFitFailedZ) && fitterZ.GetFunctionParameter(1)!=0.){ 
+    if(!HasError(kFitFailedZ) && TMath::Abs(fitterZ.GetFunctionParameter(1))>1.e-10){ 
       // TODO - one has to recalculate xy fit based on
       // better knowledge of z position
 //       Double_t x = -fitterZ.GetFunctionParameter(0)/fitterZ.GetFunctionParameter(1);
@@ -1773,9 +1860,9 @@ Bool_t AliTRDseedV1::IsEqual(const TObject *o) const
     if ( fZref[i] != inTracklet->fZref[i] ) return kFALSE;
   }
   
-  if ( fS2Y != inTracklet->fS2Y ) return kFALSE;
-  if ( GetTilt() != inTracklet->GetTilt() ) return kFALSE;
-  if ( GetPadLength() != inTracklet->GetPadLength() ) return kFALSE;
+  if ( TMath::Abs(fS2Y - inTracklet->fS2Y)>1.e-10 ) return kFALSE;
+  if ( TMath::Abs(GetTilt() - inTracklet->GetTilt())>1.e-10 ) return kFALSE;
+  if ( TMath::Abs(GetPadLength() - inTracklet->GetPadLength())>1.e-10 ) return kFALSE;
   
   for (Int_t i = 0; i < kNclusters; i++){
 //     if ( fX[i] != inTracklet->GetX(i) ) return kFALSE;
@@ -1798,14 +1885,14 @@ Bool_t AliTRDseedV1::IsEqual(const TObject *o) const
   //if ( fFreq != inTracklet->GetFreq() ) return kFALSE;
   //if ( fNChange != inTracklet->GetNChange() ) return kFALSE;
    
-  if ( fC != inTracklet->fC ) return kFALSE;
+  if ( TMath::Abs(fC[0] - inTracklet->fC[0])>1.e-10 ) return kFALSE;
   //if ( fCC != inTracklet->GetCC() ) return kFALSE;
-  if ( fChi2 != inTracklet->fChi2 ) return kFALSE;
+  if ( TMath::Abs(fChi2 - inTracklet->fChi2)>1.e-10 ) return kFALSE;
   //  if ( fChi2Z != inTracklet->GetChi2Z() ) return kFALSE;
 
   if ( fDet != inTracklet->fDet ) return kFALSE;
-  if ( fPt != inTracklet->fPt ) return kFALSE;
-  if ( fdX != inTracklet->fdX ) return kFALSE;
+  if ( TMath::Abs(fPt - inTracklet->fPt)>1.e-10 ) return kFALSE;
+  if ( TMath::Abs(fdX - inTracklet->fdX)>1.e-10 ) return kFALSE;
   
   for (Int_t iCluster = 0; iCluster < kNclusters; iCluster++){
     AliTRDcluster *curCluster = fClusters[iCluster];