]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDseedV1.cxx
fix bugs introduced by last modifications (Markus)
[u/mrichter/AliRoot.git] / TRD / AliTRDseedV1.cxx
index 476a55ecd2afb7ad403819bd42bebc5102dd5ddc..5cf7c66789c9f9797da4d7b5ae6513f80010b24f 100644 (file)
@@ -55,7 +55,7 @@ ClassImp(AliTRDseedV1)
 
 //____________________________________________________________________
 AliTRDseedV1::AliTRDseedV1(Int_t det) 
-  :TObject()
+  :AliTRDtrackletBase()
   ,fReconstructor(0x0)
   ,fClusterIter(0x0)
   ,fExB(0.)
@@ -65,9 +65,7 @@ AliTRDseedV1::AliTRDseedV1(Int_t det)
   ,fDiffL(0.)
   ,fDiffT(0.)
   ,fClusterIdx(0)
-//   ,fUsable(0)
-  ,fN2(0)
-  ,fNUsed(0)
+  ,fN(0)
   ,fDet(det)
   ,fTilt(0.)
   ,fPadLength(0.)
@@ -85,13 +83,13 @@ AliTRDseedV1::AliTRDseedV1(Int_t det)
   //
   // Constructor
   //
-  for(Int_t ic=kNTimeBins; ic--;) fIndexes[ic] = -1;
-  memset(fClusters, 0, kNTimeBins*sizeof(AliTRDcluster*));
+  for(Int_t ic=kNclusters; ic--;) fIndexes[ic] = -1;
+  memset(fClusters, 0, kNclusters*sizeof(AliTRDcluster*));
   fYref[0] = 0.; fYref[1] = 0.; 
   fZref[0] = 0.; fZref[1] = 0.; 
   fYfit[0] = 0.; fYfit[1] = 0.; 
   fZfit[0] = 0.; fZfit[1] = 0.; 
-  memset(fdEdx, 0, kNSlices*sizeof(Float_t)); 
+  memset(fdEdx, 0, kNslices*sizeof(Float_t)); 
   for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) fProb[ispec]  = -1.;
   fLabels[0]=-1; fLabels[1]=-1; // most freq MC labels
   fLabels[2]=0;  // number of different labels for tracklet
@@ -104,7 +102,7 @@ AliTRDseedV1::AliTRDseedV1(Int_t det)
 
 //____________________________________________________________________
 AliTRDseedV1::AliTRDseedV1(const AliTRDseedV1 &ref)
-  :TObject((TObject&)ref)
+  :AliTRDtrackletBase((AliTRDtrackletBase&)ref)
   ,fReconstructor(0x0)
   ,fClusterIter(0x0)
   ,fExB(0.)
@@ -114,9 +112,7 @@ AliTRDseedV1::AliTRDseedV1(const AliTRDseedV1 &ref)
   ,fDiffL(0.)
   ,fDiffT(0.)
   ,fClusterIdx(0)
-//   ,fUsable(0)
-  ,fN2(0)
-  ,fNUsed(0)
+  ,fN(0)
   ,fDet(-1)
   ,fTilt(0.)
   ,fPadLength(0.)
@@ -167,7 +163,7 @@ AliTRDseedV1::~AliTRDseedV1()
   //printf("I-AliTRDseedV1::~AliTRDseedV1() : Owner[%s]\n", IsOwner()?"YES":"NO");
 
   if(IsOwner()) {
-    for(int itb=0; itb<kNTimeBins; itb++){
+    for(int itb=0; itb<kNclusters; itb++){
       if(!fClusters[itb]) continue; 
       //AliInfo(Form("deleting c %p @ %d", fClusters[itb], itb));
       delete fClusters[itb];
@@ -195,9 +191,7 @@ void AliTRDseedV1::Copy(TObject &ref) const
   target.fDiffL         = fDiffL;
   target.fDiffT         = fDiffT;
   target.fClusterIdx    = 0;
-//   target.fUsable        = fUsable;
-  target.fN2            = fN2;
-  target.fNUsed         = fNUsed;
+  target.fN             = fN;
   target.fDet           = fDet;
   target.fTilt          = fTilt;
   target.fPadLength     = fPadLength;
@@ -212,13 +206,13 @@ void AliTRDseedV1::Copy(TObject &ref) const
   target.fC             = fC;
   target.fChi2          = fChi2;
   
-  memcpy(target.fIndexes, fIndexes, kNTimeBins*sizeof(Int_t));
-  memcpy(target.fClusters, fClusters, kNTimeBins*sizeof(AliTRDcluster*));
+  memcpy(target.fIndexes, fIndexes, kNclusters*sizeof(Int_t));
+  memcpy(target.fClusters, fClusters, kNclusters*sizeof(AliTRDcluster*));
   target.fYref[0] = fYref[0]; target.fYref[1] = fYref[1]; 
   target.fZref[0] = fZref[0]; target.fZref[1] = fZref[1]; 
   target.fYfit[0] = fYfit[0]; target.fYfit[1] = fYfit[1]; 
   target.fZfit[0] = fZfit[0]; target.fZfit[1] = fZfit[1]; 
-  memcpy(target.fdEdx, fdEdx, kNSlices*sizeof(Float_t)); 
+  memcpy(target.fdEdx, fdEdx, kNslices*sizeof(Float_t)); 
   memcpy(target.fProb, fProb, AliPID::kSPECIES*sizeof(Float_t)); 
   memcpy(target.fLabels, fLabels, 3*sizeof(Int_t)); 
   memcpy(target.fRefCov, fRefCov, 3*sizeof(Double_t)); 
@@ -260,21 +254,21 @@ void AliTRDseedV1::Reset()
   //
   fExB=0.;fVD=0.;fT0=0.;fS2PRF=0.;
   fDiffL=0.;fDiffT=0.;
-  fClusterIdx=0;//fUsable=0;
-  fN2=0; fNUsed=0;
+  fClusterIdx=0;
+  fN=0;
   fDet=-1;fTilt=0.;fPadLength=0.;
   fMom=0.;
   fdX=0.;fX0=0.; fX=0.; fY=0.; fZ=0.;
   fS2Y=0.; fS2Z=0.;
   fC=0.; fChi2 = 0.;
 
-  for(Int_t ic=kNTimeBins; ic--;) fIndexes[ic] = -1;
-  memset(fClusters, 0, kNTimeBins*sizeof(AliTRDcluster*));
+  for(Int_t ic=kNclusters; ic--;) fIndexes[ic] = -1;
+  memset(fClusters, 0, kNclusters*sizeof(AliTRDcluster*));
   fYref[0] = 0.; fYref[1] = 0.; 
   fZref[0] = 0.; fZref[1] = 0.; 
   fYfit[0] = 0.; fYfit[1] = 0.; 
   fZfit[0] = 0.; fZfit[1] = 0.; 
-  memset(fdEdx, 0, kNSlices*sizeof(Float_t)); 
+  memset(fdEdx, 0, kNslices*sizeof(Float_t)); 
   for(int ispec=0; ispec<AliPID::kSPECIES; ispec++) fProb[ispec]  = -1.;
   fLabels[0]=-1; fLabels[1]=-1; // most freq MC labels
   fLabels[2]=0;  // number of different labels for tracklet
@@ -309,12 +303,18 @@ void AliTRDseedV1::UpdateUsed()
   // Calculate number of used clusers in the tracklet
   //
 
-  fNUsed = 0;
-  for (Int_t i = kNTimeBins; i--; ) {
+  Int_t nused = 0, nshared = 0;
+  for (Int_t i = kNclusters; i--; ) {
     if (!fClusters[i]) continue;
-    if(fClusters[i]->IsUsed()) fNUsed++;
-    else if(fClusters[i]->IsShared() && IsStandAlone()) fNUsed++;
+    if(fClusters[i]->IsUsed()){ 
+      nused++;
+    } else if(fClusters[i]->IsShared()){
+      if(IsStandAlone()) nused++;
+      else nshared++;
+    }
   }
+  SetNUsed(nused);
+  SetNShared(nshared);
 }
 
 //_____________________________________________________________________________
@@ -332,20 +332,21 @@ void AliTRDseedV1::UseClusters()
   // - Clusters which are attached to a kink track become shared
   //
   AliTRDcluster **c = &fClusters[0];
-  for (Int_t ic=kNTimeBins; ic--; c++) {
+  for (Int_t ic=kNclusters; ic--; c++) {
     if(!(*c)) continue;
     if(IsStandAlone()){
       if((*c)->IsShared() || (*c)->IsUsed()){ 
-       (*c) = 0x0;
+        if((*c)->IsShared()) SetNShared(GetNShared()-1);
+        else SetNUsed(GetNUsed()-1);
+        (*c) = 0x0;
         fIndexes[ic] = -1;
-        fN2--;
-       continue;
+        SetN(GetN()-1);
+        continue;
       }
-    }
-    else{
+    } else {
       if((*c)->IsUsed() || IsKink()){
-       (*c)->SetShared();
-       continue;
+        (*c)->SetShared();
+        continue;
       }
     }
     (*c)->Use();
@@ -376,9 +377,9 @@ void AliTRDseedV1::CookdEdx(Int_t nslices)
 // 3. cluster size
 //
 
-  Int_t nclusters[kNSlices]; 
-  memset(nclusters, 0, kNSlices*sizeof(Int_t));
-  memset(fdEdx, 0, kNSlices*sizeof(Float_t));
+  Int_t nclusters[kNslices]; 
+  memset(nclusters, 0, kNslices*sizeof(Int_t));
+  memset(fdEdx, 0, kNslices*sizeof(Float_t));
 
   const Double_t kDriftLength = (.5 * AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick());
 
@@ -397,7 +398,7 @@ void AliTRDseedV1::CookdEdx(Int_t nslices)
 
 
     // 2. take sharing into account
-    Float_t w = c->IsShared() ? .5 : 1.;
+    Float_t w = /*c->IsShared() ? .5 :*/ 1.;
     
     // 3. take into account large clusters TODO
     //w *= c->GetNPads() > 3 ? .8 : 1.;
@@ -426,7 +427,7 @@ void AliTRDseedV1::CookLabels()
   Int_t labels[200];
   Int_t out[200];
   Int_t nlab = 0;
-  for (Int_t i = 0; i < kNTimeBins; i++) {
+  for (Int_t i = 0; i < kNclusters; i++) {
     if (!fClusters[i]) continue;
     for (Int_t ilab = 0; ilab < 3; ilab++) {
       if (fClusters[i]->GetLabel(ilab) >= 0) {
@@ -499,8 +500,16 @@ Float_t AliTRDseedV1::GetdQdl(Int_t ic) const
 }
 
 //____________________________________________________________________
-Float_t* AliTRDseedV1::GetProbability()
+Float_t* AliTRDseedV1::GetProbability(Bool_t force)
 {      
+  if(!force) return &fProb[0];
+  if(!CookPID()) return 0x0;
+  return &fProb[0];
+}
+
+//____________________________________________________________
+Bool_t AliTRDseedV1::CookPID()
+{
 // Fill probability array for tracklet from the DB.
 //
 // Parameters
@@ -515,19 +524,19 @@ Float_t* AliTRDseedV1::GetProbability()
   AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
   if (!calibration) {
     AliError("No access to calibration data");
-    return 0x0;
+    return kFALSE;
   }
 
   if (!fReconstructor) {
     AliError("Reconstructor not set.");
-    return 0x0;
+    return kFALSE;
   }
 
   // Retrieve the CDB container class with the parametric detector response
   const AliTRDCalPID *pd = calibration->GetPIDObject(fReconstructor->GetPIDMethod());
   if (!pd) {
     AliError("No access to AliTRDCalPID object");
-    return 0x0;
+    return kFALSE;
   }
   //AliInfo(Form("Method[%d] : %s", fReconstructor->GetRecoParam() ->GetPIDMethod(), pd->IsA()->GetName()));
 
@@ -543,7 +552,7 @@ Float_t* AliTRDseedV1::GetProbability()
     fProb[ispec] = pd->GetProbability(ispec, fMom, &fdEdx[0], length, GetPlane());     
   }
 
-  return &fProb[0];
+  return kTRUE;
 }
 
 //____________________________________________________________________
@@ -555,7 +564,7 @@ Float_t AliTRDseedV1::GetQuality(Bool_t kZcorr) const
 
   Float_t zcorr = kZcorr ? fTilt * (fZfit[0] - fZref[0]) : 0.;
   return 
-      .5 * TMath::Abs(18.0 - fN2)
+      .5 * TMath::Abs(18.0 - GetN())
     + 10.* TMath::Abs(fYfit[1] - fYref[1])
     + 5. * TMath::Abs(fYfit[0] - fYref[0] + zcorr)
     + 2. * TMath::Abs(fZfit[0] - fZref[0]) / fPadLength;
@@ -663,9 +672,9 @@ void AliTRDseedV1::Calibrate()
 
   Int_t col = 70, row = 7;
   AliTRDcluster **c = &fClusters[0];
-  if(fN2){ 
+  if(GetN()){ 
     Int_t ic = 0;
-    while (ic<kNTimeBins && !(*c)){ic++; c++;} 
+    while (ic<kNclusters && !(*c)){ic++; c++;} 
     if(*c){
       col = (*c)->GetPadCol();
       row = (*c)->GetPadRow();
@@ -687,7 +696,7 @@ void AliTRDseedV1::SetOwner()
   //AliInfo(Form("own [%s] fOwner[%s]", own?"YES":"NO", fOwner?"YES":"NO"));
   
   if(TestBit(kOwner)) return;
-  for(int ic=0; ic<kNTimeBins; ic++){
+  for(int ic=0; ic<kNclusters; ic++){
     if(!fClusters[ic]) continue;
     fClusters[ic] = new AliTRDcluster(*fClusters[ic]);
   }
@@ -860,12 +869,12 @@ Bool_t    AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber, Bool_t tilt)
 
   // working variables
   const Int_t kNrows = 16;
-  AliTRDcluster *clst[kNrows][kNTimeBins];
+  AliTRDcluster *clst[kNrows][kNclusters];
   Double_t cond[4], dx, dy, yt, zt,
-    yres[kNrows][kNTimeBins];
-  Int_t idxs[kNrows][kNTimeBins], ncl[kNrows], ncls = 0;
+    yres[kNrows][kNclusters];
+  Int_t idxs[kNrows][kNclusters], ncl[kNrows], ncls = 0;
   memset(ncl, 0, kNrows*sizeof(Int_t));
-  memset(clst, 0, kNrows*kNTimeBins*sizeof(AliTRDcluster*));
+  memset(clst, 0, kNrows*kNclusters*sizeof(AliTRDcluster*));
 
   // Do cluster projection
   AliTRDcluster *c = 0x0;
@@ -901,8 +910,8 @@ Bool_t      AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber, Bool_t tilt)
       yres[r][ncl[r]] = dy;
       ncl[r]++; ncls++;
 
-      if(ncl[r] >= kNTimeBins) {
-        AliWarning(Form("Cluster candidates reached limit %d. Some may be lost.", kNTimeBins));
+      if(ncl[r] >= kNclusters) {
+        AliWarning(Form("Cluster candidates reached limit %d. Some may be lost.", kNclusters));
         kBUFFER = kTRUE;
         break;
       }
@@ -970,7 +979,7 @@ Bool_t      AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber, Bool_t tilt)
   // We should consider here :
   //  1. How far is the chamber boundary
   //  2. How big is the mean
-  fN2 = 0;
+  Int_t n = 0;
   for (Int_t ir = 0; ir < nr; ir++) {
     Int_t jr = row + ir*lr; 
     if(kPRINT) printf("\tattach %d clusters for row %d\n", ncl[jr], jr);
@@ -983,16 +992,16 @@ Bool_t    AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber, Bool_t tilt)
   
       //printf("\tid[%2d] it[%d] idx[%d]\n", ic, it, fIndexes[it]);
   
-      fN2++;
+      n++;
     }
   }  
 
   // number of minimum numbers of clusters expected for the tracklet
-  if (fN2 < kClmin){
-    AliWarning(Form("Not enough clusters to fit the tracklet %d [%d].", fN2, kClmin));
-    fN2 = 0;
+  if (n < kClmin){
+    //AliWarning(Form("Not enough clusters to fit the tracklet %d [%d].", n, kClmin));
     return kFALSE;
   }
+  SetN(n);
 
   // Load calibration parameters for this tracklet  
   Calibrate();
@@ -1049,16 +1058,15 @@ void AliTRDseedV1::Bootstrap(const AliTRDReconstructor *rec)
   fPadLength = pp->GetLengthIPad();
   //fSnp = fYref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);
   //fTgl = fZref[1];
-  fN2 = 0;// fMPads = 0.;
+  Int_t n = 0, nshare = 0, nused = 0;
   AliTRDcluster **cit = &fClusters[0];
-  for(Int_t ic = kNTimeBins; ic--; cit++){
+  for(Int_t ic = kNclusters; ic--; cit++){
     if(!(*cit)) return;
-    fN2++;
-/*    fX[ic] = (*cit)->GetX() - fX0;
-    fY[ic] = (*cit)->GetY();
-    fZ[ic] = (*cit)->GetZ();*/
+    n++;
+    if((*cit)->IsShared()) nshare++;
+    if((*cit)->IsUsed()) nused++;
   }
-  //Update(); // 
+  SetN(n); SetNUsed(nused); SetNShared(nshare);
   Fit();
   CookLabels();
   GetProbability();
@@ -1127,7 +1135,6 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Int_t errors)
   Double_t dzdx = fZref[1];
   Double_t yt, zt;
 
-  const Int_t kNtb = AliTRDtrackerV1::GetNTimeBins();
   // calculation of tg^2(phi - a_L) and tg^2(a_L)
   Double_t tgg = (dydx-fExB)/(1.+dydx*fExB); tgg *= tgg;
   //Double_t exb2= fExB*fExB;
@@ -1138,7 +1145,7 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Int_t errors)
   //Double_t convert = 1./TMath::Sqrt(12.);
   
   // book cluster information
-  Double_t qc[kNTimeBins], xc[kNTimeBins], yc[kNTimeBins], zc[kNTimeBins], sy[kNTimeBins];
+  Double_t qc[kNclusters], xc[kNclusters], yc[kNclusters], zc[kNclusters], sy[kNclusters];
 
   Int_t ily = AliTRDgeometry::GetLayer(fDet);
   Int_t fN = 0;
@@ -1550,7 +1557,7 @@ void AliTRDseedV1::Print(Option_t *o) const
   //
 
   AliInfo(Form("Det[%3d] Tilt[%+6.2f] Pad[%5.2f]", fDet, fTilt, fPadLength));
-  AliInfo(Form("N[%2d] ", fN2));
+  AliInfo(Form("N[%2d] Nused[%2d] Nshared[%2d]", GetN(), GetNUsed(), GetNShared()));
   AliInfo(Form("x[%7.2f] y[%7.2f] z[%7.2f] dydx[%5.2f] dzdx[%5.2f]", fX0, fYfit[0], fZfit[0], fYfit[1], fZfit[1]));
   AliInfo(Form("Ref        y[%7.2f] z[%7.2f] dydx[%5.2f] dzdx[%5.2f]", fYref[0], fZref[0], fYref[1], fZref[1]))
 
@@ -1558,7 +1565,7 @@ void AliTRDseedV1::Print(Option_t *o) const
   if(strcmp(o, "a")!=0) return;
 
   AliTRDcluster* const* jc = &fClusters[0];
-  for(int ic=0; ic<kNTimeBins; ic++, jc++) {
+  for(int ic=0; ic<kNclusters; ic++, jc++) {
     if(!(*jc)) continue;
     (*jc)->Print(o);
   }
@@ -1584,7 +1591,7 @@ Bool_t AliTRDseedV1::IsEqual(const TObject *o) const
   if ( fTilt != inTracklet->fTilt ) return kFALSE;
   if ( fPadLength != inTracklet->fPadLength ) return kFALSE;
   
-  for (Int_t i = 0; i < kNTimeBins; i++){
+  for (Int_t i = 0; i < kNclusters; i++){
 //     if ( fX[i] != inTracklet->GetX(i) ) return kFALSE;
 //     if ( fY[i] != inTracklet->GetY(i) ) return kFALSE;
 //     if ( fZ[i] != inTracklet->GetZ(i) ) return kFALSE;
@@ -1600,8 +1607,8 @@ Bool_t AliTRDseedV1::IsEqual(const TObject *o) const
   
 /*  if ( fMeanz != inTracklet->GetMeanz() ) return kFALSE;
   if ( fZProb != inTracklet->GetZProb() ) return kFALSE;*/
-  if ( fN2 != inTracklet->fN2 ) return kFALSE;
-  if ( fNUsed != inTracklet->fNUsed ) return kFALSE;
+  if ( fN != inTracklet->fN ) return kFALSE;
+  //if ( fNUsed != inTracklet->fNUsed ) return kFALSE;
   //if ( fFreq != inTracklet->GetFreq() ) return kFALSE;
   //if ( fNChange != inTracklet->GetNChange() ) return kFALSE;
    
@@ -1614,7 +1621,7 @@ Bool_t AliTRDseedV1::IsEqual(const TObject *o) const
   if ( fMom != inTracklet->fMom ) return kFALSE;
   if ( fdX != inTracklet->fdX ) return kFALSE;
   
-  for (Int_t iCluster = 0; iCluster < kNTimeBins; iCluster++){
+  for (Int_t iCluster = 0; iCluster < kNclusters; iCluster++){
     AliTRDcluster *curCluster = fClusters[iCluster];
     AliTRDcluster *inCluster = inTracklet->fClusters[iCluster];
     if (curCluster && inCluster){