////////////////////////////////////////////////////////////////////////////
#include "TMath.h"
-#include "TLinearFitter.h"
-#include "TClonesArray.h" // tmp
#include <TTreeStream.h>
#include "AliLog.h"
ClassImp(AliTRDseedV1)
-TLinearFitter *AliTRDseedV1::fgFitterY = NULL;
-TLinearFitter *AliTRDseedV1::fgFitterZ = NULL;
-
//____________________________________________________________________
AliTRDseedV1::AliTRDseedV1(Int_t det)
:AliTRDtrackletBase()
,fZ(0.)
,fS2Y(0.)
,fS2Z(0.)
- ,fC(0.)
,fChi2(0.)
{
//
fLabels[0]=-1; fLabels[1]=-1; // most freq MC labels
fLabels[2]=0; // number of different labels for tracklet
memset(fRefCov, 0, 7*sizeof(Double_t));
+ // stand alone curvature
+ fC[0] = 0.; fC[1] = 0.;
// covariance matrix [diagonal]
// default sy = 200um and sz = 2.3 cm
fCov[0] = 4.e-4; fCov[1] = 0.; fCov[2] = 5.3;
,fZ(0.)
,fS2Y(0.)
,fS2Z(0.)
- ,fC(0.)
,fChi2(0.)
{
//
target.fZ = fZ;
target.fS2Y = fS2Y;
target.fS2Z = fS2Z;
- target.fC = fC;
target.fChi2 = fChi2;
memcpy(target.fIndexes, fIndexes, kNclusters*sizeof(Int_t));
memcpy(target.fProb, fProb, AliPID::kSPECIES*sizeof(Float_t));
memcpy(target.fLabels, fLabels, 3*sizeof(Int_t));
memcpy(target.fRefCov, fRefCov, 7*sizeof(Double_t));
+ target.fC[0] = fC[0]; target.fC[1] = fC[1];
memcpy(target.fCov, fCov, 3*sizeof(Double_t));
TObject::Copy(ref);
fPt=0.;
fdX=0.;fX0=0.; fX=0.; fY=0.; fZ=0.;
fS2Y=0.; fS2Z=0.;
- fC=0.; fChi2 = 0.;
+ fC[0]=0.; fC[1]=0.;
+ fChi2 = 0.;
memset(fPad, 0, 3*sizeof(Float_t));
fYref[0] = 0.; fYref[1] = 0.;
Double_t fSnp = trk->GetSnp();
Double_t fTgl = trk->GetTgl();
fPt = trk->Pt();
- Double_t norm =1./TMath::Sqrt(1. - fSnp*fSnp);
+ Double_t norm =1./TMath::Sqrt((1.-fSnp)*(1.+fSnp));
fYref[1] = fSnp*norm;
fZref[1] = fTgl*norm;
SetCovRef(trk->GetCovariance());
// 3. cluster size
//
- 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());
- AliTRDcluster *c = NULL;
+ AliTRDcluster *c(NULL);
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());
//CHECK !!!
fdEdx[slice] += w * GetdQdl(ic); //fdQdl[ic];
- nclusters[slice]++;
} // End of loop over clusters
-
- //if(fkReconstructor->GetPIDMethod() == AliTRDReconstructor::kLQPID){
- if(nslices == AliTRDpidUtil::kLQslices){
- // calculate mean charge per slice (only LQ PID)
- for(int is=0; is<nslices; is++){
- if(nclusters[is]) fdEdx[is] /= nclusters[is];
- }
- }
}
//_____________________________________________________________________________
}
dx *= TMath::Sqrt(1. + fYfit[1]*fYfit[1] + fZref[1]*fZref[1]);
if(dl) (*dl) = dx;
- return dq/dx;
+ if(dx>1.e-9) return dq/dx;
+ else return 0.;
}
//____________________________________________________________
return p;
}
+//____________________________________________________________________
+Float_t AliTRDseedV1::GetOccupancyTB() const
+{
+// Returns procentage of TB occupied by clusters
+
+ Int_t n(0);
+ AliTRDcluster *c(NULL);
+ for(int ic=0; ic<AliTRDtrackerV1::GetNTimeBins(); ic++){
+ if(!(c = fClusters[ic]) && !(c = fClusters[ic+kNtb])) continue;
+ n++;
+ }
+
+ return Float_t(n)/AliTRDtrackerV1::GetNTimeBins();
+}
//____________________________________________________________________
Float_t* AliTRDseedV1::GetProbability(Bool_t force)
Float_t length = (AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick())/ TMath::Sqrt((1.0 - GetSnp()*GetSnp()) / (1.0 + GetTgl()*GetTgl()));
//calculate dE/dx
- CookdEdx(fkReconstructor->GetNdEdxSlices());
- AliDebug(4, Form("PID p[%f] dEdx[%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f] l[%f]", GetMomentum(), fdEdx[0], fdEdx[1], fdEdx[2], fdEdx[3], fdEdx[4], fdEdx[5], fdEdx[6], fdEdx[7], length));
+ CookdEdx(AliTRDCalPID::kNSlicesNN);
+ AliDebug(4, Form("p=%6.4f[GeV/c] dEdx{%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f} l=%4.2f[cm]", GetMomentum(), fdEdx[0], fdEdx[1], fdEdx[2], fdEdx[3], fdEdx[4], fdEdx[5], fdEdx[6], fdEdx[7], length));
// Sets the a priori probabilities
+ Bool_t kPIDNN(fkReconstructor->GetPIDMethod()==AliTRDpidUtil::kNN);
for(int ispec=0; ispec<AliPID::kSPECIES; ispec++)
- fProb[ispec] = pd->GetProbability(ispec, GetMomentum(), &fdEdx[0], length, GetPlane());
+ fProb[ispec] = pd->GetProbability(ispec, GetMomentum(), &fdEdx[0], length, kPIDNN?GetPlane():fkReconstructor->GetRecoParam()->GetPIDLQslices());
return kTRUE;
}
}
//____________________________________________________________
-Double_t AliTRDseedV1::GetCovSqrt(const Double_t * const c, Double_t *d)
+Int_t AliTRDseedV1::GetCovSqrt(const Double_t * const c, Double_t *d)
{
// Helper function to calculate the square root of the covariance matrix.
// The input matrix is stored in the vector c and the result in the vector d.
// Author A.Bercuci <A.Bercuci@gsi.de>
// Date Mar 19 2009
+ const Double_t kZero(1.e-20);
Double_t l[2], // eigenvalues
v[3]; // eigenvectors
// the secular equation and its solution :
// L12 = [Tr(c) +- sqrt(Tr(c)^2-4*DET(c))]/2
Double_t tr = c[0]+c[2], // trace
det = c[0]*c[2]-c[1]*c[1]; // determinant
- if(TMath::Abs(det)<1.e-20) return -1.;
+ if(TMath::Abs(det)<kZero) return 1;
Double_t dd = TMath::Sqrt(tr*tr - 4*det);
- l[0] = .5*(tr + dd);
- l[1] = .5*(tr - dd);
- if(l[0]<0. || l[1]<0.) return -1.;
-
+ l[0] = .5*(tr + dd*(c[0]>c[2]?-1.:1.));
+ l[1] = .5*(tr + dd*(c[0]>c[2]?1.:-1.));
+ if(l[0]<kZero || l[1]<kZero) return 2;
// the sym V matrix
// | v00 v10|
// | v10 v11|
- Double_t tmp = (l[0]-c[0])/c[1];
- v[0] = TMath::Sqrt(1./(tmp*tmp+1));
- v[1] = tmp*v[0];
- v[2] = v[1]*c[1]/(l[1]-c[2]);
+ Double_t den = (l[0]-c[0])*(l[0]-c[0])+c[1]*c[1];
+ if(den<kZero){ // almost diagonal
+ v[0] = TMath::Sign(0., c[1]);
+ v[1] = TMath::Sign(1., (l[0]-c[0]));
+ v[2] = TMath::Sign(0., c[1]*(l[0]-c[0])*(l[1]-c[2]));
+ } else {
+ Double_t tmp = 1./TMath::Sqrt(den);
+ v[0] = c[1]* tmp;
+ v[1] = (l[0]-c[0])*tmp;
+ if(TMath::Abs(l[1]-c[2])<kZero) v[2] = TMath::Sign(v[0]*(l[0]-c[0])/kZero, (l[1]-c[2]));
+ else v[2] = v[0]*(l[0]-c[0])/(l[1]-c[2]);
+ }
// the VD^{1/2}V is:
l[0] = TMath::Sqrt(l[0]); l[1] = TMath::Sqrt(l[1]);
d[0] = v[0]*v[0]*l[0]+v[1]*v[1]*l[1];
d[1] = v[0]*v[1]*l[0]+v[1]*v[2]*l[1];
d[2] = v[1]*v[1]*l[0]+v[2]*v[2]*l[1];
- return 1.;
+ return 0;
}
//____________________________________________________________
//____________________________________________________________________
UShort_t AliTRDseedV1::GetVolumeId() const
{
- Int_t ic=0;
- while(ic<kNclusters && !fClusters[ic]) ic++;
- return fClusters[ic] ? fClusters[ic]->GetVolumeId() : 0;
+ for(Int_t ic(0);ic<kNclusters; ic++){
+ if(fClusters[ic]) return fClusters[ic]->GetVolumeId();
+ }
+ return 0;
}
-//____________________________________________________________________
-TLinearFitter* AliTRDseedV1::GetFitterY()
-{
- if(!fgFitterY) fgFitterY = new TLinearFitter(1, "pol1");
- fgFitterY->ClearPoints();
- return fgFitterY;
-}
-
-//____________________________________________________________________
-TLinearFitter* AliTRDseedV1::GetFitterZ()
-{
- if(!fgFitterZ) fgFitterZ = new TLinearFitter(1, "pol1");
- fgFitterZ->ClearPoints();
- return fgFitterZ;
-}
//____________________________________________________________________
void AliTRDseedV1::Calibrate()
fExB = AliTRDCommonParam::Instance()->GetOmegaTau(fVD);
AliTRDCommonParam::Instance()->GetDiffCoeff(fDiffL,
fDiffT, fVD);
+ AliDebug(4, Form("Calibration params for Det[%3d] Col[%3d] Row[%2d]\n t0[%f] vd[%f] s2PRF[%f] ExB[%f] Dl[%f] Dt[%f]", fDet, col, row, fT0, fVD, fS2PRF, fExB, fDiffL, fDiffT));
+
+
SetBit(kCalib, kTRUE);
}
// Author : Alexandru Bercuci <A.Bercuci@gsi.de>
// Debug : level >3
- if(!fkReconstructor->GetRecoParam() ){
+ const AliTRDrecoParam* const recoParam = fkReconstructor->GetRecoParam(); //the dynamic cast in GetRecoParam is slow, so caching the pointer to it
+
+ if(!recoParam){
AliError("Tracklets can not be used without a valid RecoParam.");
return kFALSE;
}
// Initialize reco params for this tracklet
// 1. first time bin in the drift region
Int_t t0 = 14;
- Int_t kClmin = Int_t(fkReconstructor->GetRecoParam() ->GetFindableClusters()*AliTRDtrackerV1::GetNTimeBins());
+ Int_t kClmin = Int_t(recoParam->GetFindableClusters()*AliTRDtrackerV1::GetNTimeBins());
- Double_t sysCov[5]; fkReconstructor->GetRecoParam()->GetSysCovMatrix(sysCov);
+ Double_t sysCov[5]; recoParam->GetSysCovMatrix(sysCov);
Double_t s2yTrk= fRefCov[0],
s2yCl = 0.,
s2zCl = GetPadLength()*GetPadLength()/12.,
syRef = TMath::Sqrt(s2yTrk),
t2 = GetTilt()*GetTilt();
//define roads
- Double_t kroady = 1., //fkReconstructor->GetRecoParam() ->GetRoad1y();
- kroadz = GetPadLength() * fkReconstructor->GetRecoParam()->GetRoadzMultiplicator() + 1.;
+ Double_t kroady = 1., //recoParam->GetRoad1y();
+ kroadz = GetPadLength() * recoParam->GetRoadzMultiplicator() + 1.;
// define probing cluster (the perfect cluster) and default calibration
Short_t sig[] = {0, 0, 10, 30, 10, 0,0};
AliTRDcluster cp(fDet, 6, 75, 0, sig, 0);
}
lr = ir; if(nr>=3) break;
}
- if(fkReconstructor->GetRecoParam()->GetStreamLevel(AliTRDrecoParam::kTracker) > 3 && fkReconstructor->IsDebugStreaming()){
+ if(recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 3 && fkReconstructor->IsDebugStreaming()){
TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker);
UChar_t stat(0);
if(IsKink()) SETBIT(stat, 1);
AliTRDpadPlane *pp = g.GetPadPlane(fDet);
fPad[0] = pp->GetLengthIPad();
fPad[1] = pp->GetWidthIPad();
- fPad[3] = TMath::Tan(TMath::DegToRad()*pp->GetTiltingAngle());
+ fPad[2] = TMath::Tan(TMath::DegToRad()*pp->GetTiltingAngle());
//fSnp = fYref[1]/TMath::Sqrt(1+fYref[1]*fYref[1]);
//fTgl = fZref[1];
Int_t n = 0, nshare = 0, nused = 0;
// Author
// A.Bercuci <A.Bercuci@gsi.de>
+ if(!fkReconstructor){
+ AliError("The tracklet needs the reconstruction setup. Please initialize by SetReconstructor().");
+ return kFALSE;
+ }
if(!IsCalibrated()) Calibrate();
const Int_t kClmin = 8;
Int_t n = 0;
AliTRDcluster *c=NULL, **jc = &fClusters[0];
+ const AliTRDrecoParam* const recoParam = fkReconstructor->GetRecoParam(); //the dynamic cast in GetRecoParam is slow, so caching the pointer to it
for (Int_t ic=0; ic<kNtb; ic++, ++jc) {
xc[ic] = -1.;
yc[ic] = 999.;
// Recalculate cluster error based on tracking information
c->SetSigmaY2(fS2PRF, fDiffT, fExB, xc[n], zcorr?zt:-1., dydx);
+ c->SetSigmaZ2(fPad[0]*fPad[0]/12.); // for HLT
sy[n] = TMath::Sqrt(c->GetSigmaY2());
- yc[n] = fkReconstructor->GetRecoParam()->UseGAUS() ?
+ yc[n] = recoParam->UseGAUS() ?
c->GetYloc(y0, sy[n], GetPadWidth()): c->GetY();
zc[n] = c->GetZ();
//optional tilt correction
if(tilt) yc[n] -= (GetTilt()*(zc[n] - zt));
- fitterY.AddPoint(&xc[n], yc[n], TMath::Sqrt(sy[n]));
+ AliDebug(5, Form(" tb[%2d] dx[%6.3f] y[%6.2f+-%6.3f]", c->GetLocalTimeBin(), xc[n], yc[n], sy[n]));
+ fitterY.AddPoint(&xc[n], yc[n], sy[n]);
if(IsRowCross()) fitterZ.AddPoint(&xc[n], qc[n], 1.);
n++;
}
// to few clusters
- if (n < kClmin) return kFALSE;
+ if (n < kClmin){
+ SetErrorMsg(kFitFailed);
+ return kFALSE;
+ }
// fit XY
- fitterY.Eval();
+ if(!fitterY.Eval()){
+ SetErrorMsg(kFitFailed);
+ return kFALSE;
+ }
fYfit[0] = fitterY.GetFunctionParameter(0);
fYfit[1] = -fitterY.GetFunctionParameter(1);
// store covariance
Double_t p[3];
fitterY.GetCovarianceMatrix(p);
- fCov[0] = p[0]; // variance of y0
+ fCov[0] = p[1]; // variance of y0
fCov[1] = p[2]; // covariance of y0, dydx
- fCov[2] = p[1]; // variance of dydx
+ fCov[2] = p[0]; // variance of dydx
// the ref radial position is set at the minimum of
// the y variance of the tracklet
fX = -fCov[1]/fCov[2];
+ Float_t xs=fX+.5*AliTRDgeometry::CamHght();
+ if(xs < 0. || xs > AliTRDgeometry::CamHght()+AliTRDgeometry::CdrHght()){
+ AliDebug(1, Form("Ref radial position ouside chamber x[%5.2f].", fX));
+ SetErrorMsg(kFitOutside);
+ return kFALSE;
+ }
// collect second row clusters
Int_t m(0);
qc[n] = TMath::Abs(c->GetQ());
xc[n] = fX0 - c->GetX();
zc[n] = c->GetZ();
+ // Recalculate cluster error based on tracking information
+ c->SetSigmaY2(fS2PRF, fDiffT, fExB, xc[n], zcorr?(z0 - xc[n]*dzdx):-1., dydx);
+ c->SetSigmaZ2(fPad[0]*fPad[0]/12.); // for HLT
fitterZ.AddPoint(&xc[n], -qc[n], 1.);
n--;m++;
}
AliInfo(Form("Det[%3d] X0[%7.2f] Pad{L[%5.2f] W[%5.2f] Tilt[%+6.2f]}", fDet, fX0, GetPadLength(), GetPadWidth(), GetTilt()));
AliInfo(Form("N[%2d] Nused[%2d] Nshared[%2d] [%d]", GetN(), GetNUsed(), GetNShared(), fN));
AliInfo(Form("FLAGS : RC[%c] Kink[%c] SA[%c]", IsRowCross()?'y':'n', IsKink()?'y':'n', IsStandAlone()?'y':'n'));
+ AliInfo(Form("CALIB PARAMS : T0[%5.2f] Vd[%5.2f] s2PRF[%5.2f] ExB[%5.2f] Dl[%5.2f] Dt[%5.2f]", fT0, fVD, fS2PRF, fExB, fDiffL, fDiffT));
Double_t cov[3], x=GetX();
GetCovAt(x, cov);
AliInfo(Form("Fit | %7.2f | %7.2f+-%7.2f | %7.2f+-%7.2f| %5.2f | ----- |", x, GetY(), TMath::Sqrt(cov[0]), GetZ(), TMath::Sqrt(cov[2]), fYfit[1]));
AliInfo(Form("Ref | %7.2f | %7.2f+-%7.2f | %7.2f+-%7.2f| %5.2f | %5.2f |", x, fYref[0]-fX*fYref[1], TMath::Sqrt(fRefCov[0]), fZref[0]-fX*fYref[1], TMath::Sqrt(fRefCov[2]), fYref[1], fZref[1]))
AliInfo(Form("P / Pt [GeV/c] = %f / %f", GetMomentum(), fPt));
+ if(IsStandAlone()) AliInfo(Form("C Rieman / Vertex [1/cm] = %f / %f", fC[0], fC[1]));
AliInfo(Form("dEdx [a.u.] = %f / %f / %f / %f / %f/ %f / %f / %f", fdEdx[0], fdEdx[1], fdEdx[2], fdEdx[3], fdEdx[4], fdEdx[5], fdEdx[6], fdEdx[7]));
AliInfo(Form("PID = %5.3f / %5.3f / %5.3f / %5.3f / %5.3f", fProb[0], fProb[1], fProb[2], fProb[3], fProb[4]));