]> 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 113e918ccbc383649b0734734ad746ad8c728819..324a27f4b4a1b0ce8156f70c7ed9e6efb876e978 100644 (file)
@@ -28,6 +28,7 @@
 #include "AliTPCCalPad.h"
 #include "AliTPCCalROC.h"
 #include "AliTPCcalibDB.h"
+#include "AliTPCParam.h"
 
 
 
@@ -528,6 +529,15 @@ 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){
@@ -572,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);
@@ -691,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]++;
@@ -1034,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, AliTPCCalPad * gainMap){
+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
@@ -1046,14 +1063,20 @@ 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++){
@@ -1088,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++;
   }
 
@@ -1168,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()));
+}