]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCseed.cxx
Updated flags for low flux case (A. Dainese)
[u/mrichter/AliRoot.git] / TPC / AliTPCseed.cxx
index df1f9f2b1ef25162589f9e52af088d9f0d9cad37..324a27f4b4a1b0ce8156f70c7ed9e6efb876e978 100644 (file)
 #include "AliTPCseed.h"
 #include "AliTPCReconstructor.h"
 #include "AliTPCClusterParam.h"
+#include "AliTPCCalPad.h"
+#include "AliTPCCalROC.h"
+#include "AliTPCcalibDB.h"
+#include "AliTPCParam.h"
+
+
 
 ClassImp(AliTPCseed)
 
@@ -34,13 +40,16 @@ AliTPCseed::AliTPCseed():
   AliTPCtrack(),
   fEsd(0x0),
   fClusterOwner(kFALSE),
-  fPoints(0x0),
-  fEPoints(0x0),
   fRow(0),
   fSector(-1),
   fRelativeSector(-1),
   fCurrentSigmaY2(1e10),
   fCurrentSigmaZ2(1e10),
+  fCMeanSigmaY2p30(-1.),   //! current mean sigma Y2 - mean30%
+  fCMeanSigmaZ2p30(-1.),   //! current mean sigma Z2 - mean30%
+  fCMeanSigmaY2p30R(-1.),   //! current mean sigma Y2 - mean2%
+  fCMeanSigmaZ2p30R(-1.),   //! current mean sigma Z2 - mean2%
+  //
   fErrorY2(1e10),
   fErrorZ2(1e10),
   fCurrentCluster(0x0),
@@ -80,13 +89,15 @@ AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
   AliTPCtrack(s),
   fEsd(0x0),
   fClusterOwner(clusterOwner),
-  fPoints(0x0),
-  fEPoints(0x0),
   fRow(0),
   fSector(-1),
   fRelativeSector(-1),
-  fCurrentSigmaY2(1e10),
-  fCurrentSigmaZ2(1e10),
+  fCurrentSigmaY2(-1),
+  fCurrentSigmaZ2(-1),
+  fCMeanSigmaY2p30(-1.),   //! current mean sigma Y2 - mean30%
+  fCMeanSigmaZ2p30(-1.),   //! current mean sigma Z2 - mean30%
+  fCMeanSigmaY2p30R(-1.),   //! current mean sigma Y2 - mean2%
+  fCMeanSigmaZ2p30R(-1.),   //! current mean sigma Z2 - mean2%
   fErrorY2(1e10),
   fErrorZ2(1e10),
   fCurrentCluster(0x0),
@@ -133,13 +144,15 @@ AliTPCseed::AliTPCseed(const AliTPCtrack &t):
   AliTPCtrack(t),
   fEsd(0x0),
   fClusterOwner(kFALSE),
-  fPoints(0x0),
-  fEPoints(0x0),
   fRow(0),
   fSector(-1),
   fRelativeSector(-1),
-  fCurrentSigmaY2(1e10),
-  fCurrentSigmaZ2(1e10),
+  fCurrentSigmaY2(-1),
+  fCurrentSigmaZ2(-1),
+  fCMeanSigmaY2p30(-1.),   //! current mean sigma Y2 - mean30%
+  fCMeanSigmaZ2p30(-1.),   //! current mean sigma Z2 - mean30%
+  fCMeanSigmaY2p30R(-1.),   //! current mean sigma Y2 - mean2%
+  fCMeanSigmaZ2p30R(-1.),   //! current mean sigma Z2 - mean2%
   fErrorY2(1e10),
   fErrorZ2(1e10),
   fCurrentCluster(0x0),
@@ -191,13 +204,15 @@ AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
   AliTPCtrack(xr, alpha, xx, cc, index),
   fEsd(0x0),
   fClusterOwner(kFALSE),
-  fPoints(0x0),
-  fEPoints(0x0),
   fRow(0),
   fSector(-1),
   fRelativeSector(-1),
-  fCurrentSigmaY2(1e10),
-  fCurrentSigmaZ2(1e10),
+  fCurrentSigmaY2(-1),
+  fCurrentSigmaZ2(-1),
+  fCMeanSigmaY2p30(-1.),   //! current mean sigma Y2 - mean30%
+  fCMeanSigmaZ2p30(-1.),   //! current mean sigma Z2 - mean30%
+  fCMeanSigmaY2p30R(-1.),   //! current mean sigma Y2 - mean2%
+  fCMeanSigmaZ2p30R(-1.),   //! current mean sigma Z2 - mean2%
   fErrorY2(1e10),
   fErrorZ2(1e10),
   fCurrentCluster(0x0),
@@ -233,10 +248,6 @@ AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
 AliTPCseed::~AliTPCseed(){
   //
   // destructor
-  if (fPoints) delete  fPoints;
-  fPoints =0;
-  if (fEPoints) delete  fEPoints;
-  fEPoints = 0;
   fNoCluster =0;
   if (fClusterOwner){
     for (Int_t icluster=0; icluster<160; icluster++){
@@ -258,8 +269,6 @@ AliTPCseed & AliTPCseed::operator=(const AliTPCseed &param)
     fClusterOwner = param.fClusterOwner;
     // leave out fPoint, they are also not copied in the copy ctor...
     // but deleted in the dtor... strange...
-    // fPoints =
-    // fEPoints =
     fRow            = param.fRow;
     fSector         = param.fSector;
     fRelativeSector = param.fRelativeSector;
@@ -301,30 +310,6 @@ AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
   return &fTrackPoints[i];
 }
 
-void AliTPCseed::RebuildSeed()
-{
-  //
-  // rebuild seed to be ready for storing
-  AliTPCclusterMI cldummy;
-  cldummy.SetQ(0);
-  AliTPCTrackPoint pdummy;
-  pdummy.GetTPoint().SetShared(10);
-  for (Int_t i=0;i<160;i++){
-    AliTPCclusterMI * cl0 = fClusterPointer[i];
-    AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);     
-    if (cl0){
-      trpoint->GetTPoint() = *(GetTrackPoint(i));
-      trpoint->GetCPoint() = *cl0;
-      trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
-    }
-    else{
-      *trpoint = pdummy;
-      trpoint->GetCPoint()= cldummy;
-    }
-    
-  }
-
-}
 
 
 Double_t AliTPCseed::GetDensityFirst(Int_t n)
@@ -544,7 +529,31 @@ Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
   Int_t idx=GetClusterIndex(n);    // save the current cluster index
 
   AliCluster cl(*c);  cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
+  Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
+  if (TMath::Abs(dx)>0){
+    Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
+    Float_t dy = dx*ty;
+    Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
+    cl.SetY(c->GetY()-dy);  
+    cl.SetZ(c->GetZ()-dz);  
+  }
+
   if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
+  
+  if (fCMeanSigmaY2p30<0){
+    fCMeanSigmaY2p30= c->GetSigmaY2();   //! current mean sigma Y2 - mean30%
+    fCMeanSigmaZ2p30= c->GetSigmaZ2();   //! current mean sigma Z2 - mean30%    
+    fCMeanSigmaY2p30R = 1;   //! current mean sigma Y2 - mean5%
+    fCMeanSigmaZ2p30R = 1;   //! current mean sigma Z2 - mean5%
+  }
+  //
+  fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();   
+  fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();  
+  if (fCurrentSigmaY2>0){
+    fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R  +0.3*c->GetSigmaY2()/fCurrentSigmaY2;  
+    fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R  +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;   
+  }
+
 
   SetClusterIndex(n,idx);          // restore the current cluster index
   return kTRUE;
@@ -563,7 +572,6 @@ Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_
   Float_t weight[200];
   Int_t index[200];
   //Int_t nc = 0;
-  //  TClonesArray & arr = *fPoints; 
   Float_t meanlog = 100.;
   
   Float_t mean[4]  = {0,0,0,0};
@@ -574,11 +582,17 @@ Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_
   //
   fNShared =0;
 
+  Float_t gainGG = 1;
+  if (AliTPCcalibDB::Instance()->GetParameters()){
+    gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.;  //relative gas gain
+  }
+
+
   for (Int_t of =0; of<4; of++){    
     for (Int_t i=of+i1;i<i2;i+=4)
       {
-       Int_t index = fIndex[i];
-       if (index<0||index&0x8000) continue;
+       Int_t clindex = fIndex[i];
+       if (clindex<0||clindex&0x8000) continue;
 
        //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
        AliTPCTrackerPoint * point = GetTrackPoint(i);
@@ -693,6 +707,7 @@ Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_
        }
        if (rsigma>1.5) ampc/=1.3;  // if big backround
        amp[nc[of]]        = ampc;
+       amp[nc[of]]       /=gainGG;
        angular[nc[of]]    = TMath::Sqrt(1.+angley*angley+anglez*anglez);
        weight[nc[of]]     = w;
        nc[of]++;
@@ -1036,7 +1051,7 @@ Bool_t AliTPCseed::GetSharedMapBit(int ibit)
 
 
 
-Float_t  AliTPCseed::CookdEdxNorm(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2){
+Float_t  AliTPCseed::CookdEdxNorm(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, AliTPCCalPad * gainMap, Bool_t posNorm, Bool_t padNorm){
  
   //
   // calculates dedx using the cluster
@@ -1048,20 +1063,39 @@ Float_t  AliTPCseed::CookdEdxNorm(Double_t low, Double_t up, Int_t type, Int_t i
   // normalization parametrization taken from AliTPCClusterParam
   //
   AliTPCClusterParam * parcl = AliTPCClusterParam::Instance();
+  if (!parcl) parcl = AliTPCcalibDB::Instance()->GetClusterParam();
   if (!parcl) return 0;
   Float_t amp[160];
   Int_t   indexes[160];
   Int_t   ncl=0;
   //
   //
+  Float_t gainGG = 1;
+  if (AliTPCcalibDB::Instance()->GetParameters()){
+    gainGG= 20000./AliTPCcalibDB::Instance()->GetParameters()->GetGasGain();  //relative gas gain
+  }
+
   const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
-  const Float_t kedgey =4.;
+  const Float_t kedgey =3.;
+  //
   //
   for (Int_t irow=i1; irow<i2; irow++){
     AliTPCclusterMI* cluster = GetClusterPointer(irow);
     if (!cluster) continue;
     if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
     Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
+    if (!gainMap) gainMap =  AliTPCcalibDB::Instance()->GetDedxGainFactor();
+    if (gainMap) {      
+      Float_t factor = 1;      
+      AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
+      if (irow < 63) { // IROC
+       factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()))*1.55;
+      } else {         // OROC
+       factor = roc->GetValue(irow - 63, TMath::Nint(cluster->GetPad()));
+      }
+      if (factor>0.5) charge/=factor;
+    }
+    
     //do normalization
     Float_t corr=1;
     Int_t  ipad= 0;
@@ -1077,15 +1111,32 @@ Float_t  AliTPCseed::CookdEdxNorm(Double_t low, Double_t up, Int_t type, Int_t i
       corr  = parcl->Qnorm(ipad,type,dr,ty,tz);
     }
     amp[ncl]=charge/corr;
-    
+    amp[ncl]/=gainGG;
+    if (posNorm){
+      //
+      //
+      //
+      corr = parcl->QnormPos(ipad,type, cluster->GetPad(),cluster->GetTimeBin(), cluster->GetZ(),
+                            cluster->GetSigmaY2(),cluster->GetSigmaZ2(),cluster->GetMax(),cluster->GetQ());
+      amp[ncl]/=corr;
+    }
+
+
     amp[ncl] *= 2.0;     // put mean value to channel 50
-    if (ipad==0) {
-      amp[ncl] /= 0.65; // this we will take form OCDB
-    } else
-      if (ipad==2){
-       amp[ncl] /=1.57;
-      }else{
-      }      
+    if (padNorm){
+      corr=1;
+      if (type==0 && parcl->fQpadTnorm) corr = (*parcl->fQpadTnorm)[ipad];
+      if (type==1 && parcl->fQpadTnorm) corr = (*parcl->fQpadMnorm)[ipad];
+      amp[ncl]/=corr;
+    }
+
+    // if (ipad==0) {
+//       amp[ncl] /= 0.65; // this we will take form OCDB
+//     } else
+//       if (ipad==2){
+//     amp[ncl] /=1.57;
+//       }else{
+//       }      
     ncl++;
   }
 
@@ -1157,3 +1208,185 @@ Float_t  AliTPCseed::CookShape(Int_t type){
   Float_t mean = (meanc>0)? means/meanc:0;
   return mean;
 }
+
+
+
+Int_t  AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
+  //
+  // Refit the track
+  // return value - number of used clusters
+  // 
+  //
+  const Int_t kMinNcl =10;
+  AliTPCseed *track=new AliTPCseed(*seed);
+  Int_t sector=-1;
+  // reset covariance
+  //
+  Double_t covar[15];
+  for (Int_t i=0;i<15;i++) covar[i]=0;
+  covar[0]=10.*10.;
+  covar[2]=10.*10.;
+  covar[5]=10.*10./(64.*64.);
+  covar[9]=10.*10./(64.*64.);
+  covar[14]=1*1;
+  //
+
+  Float_t xmin=1000, xmax=-10000;
+  Int_t imin=158, imax=0;
+  for (Int_t i=0;i<160;i++) {
+    AliTPCclusterMI *c=track->GetClusterPointer(i);
+    if (!c) continue;
+    if (sector<0) sector = c->GetDetector();
+    if (c->GetX()<xmin) xmin=c->GetX();
+    if (c->GetX()>xmax) xmax=c->GetX();
+    if (i<imin) imin=i;
+    if (i>imax) imax=i;
+  }
+  if(imax-imin<kMinNcl) {
+    delete track;
+    return 0 ;
+  }
+  // Not succes to rotate
+  if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
+    delete track;
+    return 0;
+  }
+  //
+  //
+  // fit from inner to outer row
+  //
+  AliExternalTrackParam paramIn;
+  AliExternalTrackParam paramOut;
+  Bool_t isOK=kTRUE;
+  Int_t ncl=0;
+  //
+  //
+  //
+  for (Int_t i=imin; i<=imax; i++){
+    AliTPCclusterMI *c=track->GetClusterPointer(i);
+    if (!c) continue;
+    //    if (RejectCluster(c,track)) continue;
+    sector = (c->GetDetector()%18);
+    if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
+      //continue;
+    }
+    Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
+    Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
+    if (!track->PropagateTo(r[0])) {
+      isOK=kFALSE;
+    }
+    if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
+  }
+  if (!isOK) { delete track; return 0;}
+  track->AddCovariance(covar);
+  //
+  //
+  //
+  for (Int_t i=imax; i>=imin; i--){
+    AliTPCclusterMI *c=track->GetClusterPointer(i);
+    if (!c) continue;
+    //if (RejectCluster(c,track)) continue;
+    sector = (c->GetDetector()%18);
+    if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
+      //continue;
+    }
+    Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
+    Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
+    if (!track->PropagateTo(r[0])) {
+      isOK=kFALSE;
+    }
+    if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
+  }
+  //if (!isOK) { delete track; return 0;}
+  paramIn = *track;
+  track->AddCovariance(covar);
+  //
+  //
+  for (Int_t i=imin; i<=imax; i++){
+    AliTPCclusterMI *c=track->GetClusterPointer(i);
+    if (!c) continue;
+    sector = (c->GetDetector()%18);
+    if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
+      //continue;
+    }
+    ncl++;
+    //if (RejectCluster(c,track)) continue;
+    Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
+    Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
+    if (!track->PropagateTo(r[0])) {
+      isOK=kFALSE;
+    }
+    if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
+  }
+  //if (!isOK) { delete track; return 0;}
+  paramOut=*track;
+  //
+  //
+  //
+  if (parin) (*parin)=paramIn;
+  if (parout) (*parout)=paramOut;
+  return ncl;
+}
+
+
+
+Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
+  //
+  //
+  //
+  return kFALSE;
+}
+
+
+
+
+
+
+void  AliTPCseed::GetError(AliTPCclusterMI* cluster, AliExternalTrackParam * param, 
+                                 Double_t& erry, Double_t &errz)
+{
+  //
+  // Get cluster error at given position
+  //
+  AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
+  Double_t tany,tanz;  
+  Double_t snp1=param->GetSnp();
+  tany=snp1/TMath::Sqrt(1.-snp1*snp1);
+  //
+  Double_t tgl1=param->GetTgl();
+  tanz=tgl1/TMath::Sqrt(1.-snp1*snp1);
+  //
+  Int_t padSize = 0;                          // short pads
+  if (cluster->GetDetector() >= 36) {
+    padSize = 1;                              // medium pads 
+    if (cluster->GetRow() > 63) padSize = 2; // long pads
+  }
+
+  erry  = clusterParam->GetError0Par( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany) );
+  errz  = clusterParam->GetError0Par( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) );
+}
+
+
+void  AliTPCseed::GetShape(AliTPCclusterMI* cluster, AliExternalTrackParam * param, 
+                                 Double_t& rmsy, Double_t &rmsz)
+{
+  //
+  // Get cluster error at given position
+  //
+  AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
+  Double_t tany,tanz;  
+  Double_t snp1=param->GetSnp();
+  tany=snp1/TMath::Sqrt(1.-snp1*snp1);
+  //
+  Double_t tgl1=param->GetTgl();
+  tanz=tgl1/TMath::Sqrt(1.-snp1*snp1);
+  //
+  Int_t padSize = 0;                          // short pads
+  if (cluster->GetDetector() >= 36) {
+    padSize = 1;                              // medium pads 
+    if (cluster->GetRow() > 63) padSize = 2; // long pads
+  }
+
+  rmsy  = clusterParam->GetRMSQ( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany), TMath::Abs(cluster->GetMax()) );
+  rmsz  = clusterParam->GetRMSQ( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) ,TMath::Abs(cluster->GetMax()));
+}