#include "TClonesArray.h"
#include "AliTPCseed.h"
#include "AliTPCReconstructor.h"
+#include "AliTPCClusterParam.h"
+#include "AliTPCCalPad.h"
+#include "AliTPCCalROC.h"
+#include "AliTPCcalibDB.h"
+#include "AliTPCParam.h"
+
+
ClassImp(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),
fNCDEDX[i] = 0;
}
for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
- for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
- for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
+ // for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
+ //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
+ fClusterMap.ResetAllBits(kFALSE);
+ fSharedMap.ResetAllBits(kFALSE);
+
}
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),
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),
fNCDEDX[i] = 0;
}
for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
- for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
- for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
+
+ //for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
+ //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
+ fClusterMap.ResetAllBits(kFALSE);
+ fSharedMap.ResetAllBits(kFALSE);
+
}
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),
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++){
delete fClusterPointer[icluster];
}
}
- for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
- for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
+
}
//_________________________________________________
AliTPCseed & AliTPCseed::operator=(const AliTPCseed ¶m)
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;
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)
for (Int_t i=first;i<last; i++){
Int_t index = GetClusterIndex2(i);
if (index!=-1) foundable++;
+ if (index&0x8000) continue;
if (fClusterPointer[i]) {
found++;
}
//_____________________________________________________________________________
-Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t /*index*/)
+Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
{
//-----------------------------------------------------------------
// This function associates a cluster with this track.
//-----------------------------------------------------------------
- Double_t p[2]={c->GetY(), c->GetZ()};
- Double_t cov[3]={fErrorY2, 0., fErrorZ2};
+ Int_t n=GetNumberOfClusters();
+ 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 (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
+ 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;
+ }
- Int_t n=GetNumberOfClusters();
- // fIndex[n]=index;
- SetNumberOfClusters(n+1);
- SetChi2(GetChi2()+chisq);
+ SetClusterIndex(n,idx); // restore the current cluster index
return kTRUE;
}
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};
//
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);
}
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]++;
{
return fSharedMap[ibit];
}
+
+
+
+
+
+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
+ // low - up specify trunc mean range - default form 0-0.7
+ // type - 1 - max charge or 0- total charge in cluster
+ // //2- max no corr 3- total+ correction
+ // i1-i2 - the pad-row range used for calculation
+ //
+ // 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 =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;
+ if (irow>62) ipad=1;
+ if (irow>127) ipad=2;
+ if (type<=1){
+ //
+ AliTPCTrackerPoint * point = GetTrackPoint(irow);
+ Float_t ty = TMath::Abs(point->GetAngleY());
+ Float_t tz = TMath::Abs(point->GetAngleZ());
+
+ Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
+ 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 (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++;
+ }
+
+ if (type>3) return ncl;
+ TMath::Sort(ncl,amp, indexes, kFALSE);
+
+ if (ncl<10) return 0;
+
+ Float_t suma=0;
+ Float_t sumn=0;
+ Int_t icl0=TMath::Nint(ncl*low);
+ Int_t icl1=TMath::Nint(ncl*up);
+ for (Int_t icl=icl0; icl<icl1;icl++){
+ suma+=amp[indexes[icl]];
+ sumn++;
+ }
+ return suma/sumn;
+
+}
+
+Double_t AliTPCseed::BetheMass(Double_t mass){
+ //
+ // return bethe-bloch
+ //
+ Float_t bg= P()/mass;
+ const Double_t kp1=0.76176e-1;
+ const Double_t kp2=10.632;
+ const Double_t kp3=0.13279e-4;
+ const Double_t kp4=1.8631;
+ const Double_t kp5=1.9479;
+
+ Double_t dbg = (Double_t) bg;
+
+ Double_t beta = dbg/TMath::Sqrt(1.+dbg*dbg);
+
+ Double_t aa = TMath::Power(beta,kp4);
+ Double_t bb = TMath::Power(1./dbg,kp5);
+
+ bb=TMath::Log(kp3+bb);
+
+ return ((Float_t)((kp2-aa-bb)*kp1/aa));
+}
+
+
+Float_t AliTPCseed::CookShape(Int_t type){
+ //
+ //
+ //
+ //-----------------------------------------------------------------
+ // This funtion calculates dE/dX within the "low" and "up" cuts.
+ //-----------------------------------------------------------------
+ Float_t means=0;
+ Float_t meanc=0;
+ for (Int_t i =0; i<160;i++) {
+ AliTPCTrackerPoint * point = GetTrackPoint(i);
+ if (point==0) continue;
+
+ AliTPCclusterMI * cl = fClusterPointer[i];
+ if (cl==0) continue;
+
+ Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
+ Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
+ Float_t rsigma = (rsigmay+rsigmaz)*0.5;
+ if (type==0) means+=rsigma;
+ if (type==1) means+=rsigmay;
+ if (type==2) means+=rsigmaz;
+ meanc++;
+ }
+ 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()));
+}