X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDseedV1.cxx;h=fc6a763a4cbd1c43241cb9b6f6b3c2c439714d09;hb=fe4ee353cf0b8bf619d0fb19c2cc42e367eab468;hp=c3c32de2c3b23f4c758a3a650370efb2ddaf92cf;hpb=0662e01cd5a502d751d96487ca35a9bd8b61f6f4;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDseedV1.cxx b/TRD/AliTRDseedV1.cxx index c3c32de2c3b..fc6a763a4cb 100644 --- a/TRD/AliTRDseedV1.cxx +++ b/TRD/AliTRDseedV1.cxx @@ -36,8 +36,6 @@ //////////////////////////////////////////////////////////////////////////// #include "TMath.h" -#include "TLinearFitter.h" -#include "TClonesArray.h" // tmp #include #include "AliLog.h" @@ -53,7 +51,6 @@ #include "AliTRDchamberTimeBin.h" #include "AliTRDtrackingChamber.h" #include "AliTRDtrackerV1.h" -#include "AliTRDReconstructor.h" #include "AliTRDrecoParam.h" #include "AliTRDCommonParam.h" @@ -66,8 +63,8 @@ ClassImp(AliTRDseedV1) //____________________________________________________________________ AliTRDseedV1::AliTRDseedV1(Int_t det) :AliTRDtrackletBase() - ,fReconstructor(0x0) - ,fClusterIter(0x0) + ,fkReconstructor(NULL) + ,fClusterIter(NULL) ,fExB(0.) ,fVD(0.) ,fT0(0.) @@ -75,6 +72,7 @@ AliTRDseedV1::AliTRDseedV1(Int_t det) ,fDiffL(0.) ,fDiffT(0.) ,fClusterIdx(0) + ,fErrorMsg(0) ,fN(0) ,fDet(det) ,fPt(0.) @@ -85,13 +83,12 @@ AliTRDseedV1::AliTRDseedV1(Int_t det) ,fZ(0.) ,fS2Y(0.) ,fS2Z(0.) - ,fC(0.) ,fChi2(0.) { // // Constructor // - for(Int_t ic=kNclusters; ic--;) fIndexes[ic] = -1; + memset(fIndexes,0xFF,kNclusters*sizeof(fIndexes[0])); memset(fClusters, 0, kNclusters*sizeof(AliTRDcluster*)); memset(fPad, 0, 3*sizeof(Float_t)); fYref[0] = 0.; fYref[1] = 0.; @@ -102,7 +99,9 @@ AliTRDseedV1::AliTRDseedV1(Int_t det) for(int ispec=0; ispecGetProlongation(fX0, y, z)) return kFALSE; - UpDate(track); + Update(track); return kTRUE; } //_____________________________________________________________________________ -void AliTRDseedV1::Reset() +void AliTRDseedV1::Reset(Option_t *opt) { - // - // Reset seed - // +// +// Reset seed. If option opt="c" is given only cluster arrays are cleared. +// + for(Int_t ic=kNclusters; ic--;) fIndexes[ic] = -1; + memset(fClusters, 0, kNclusters*sizeof(AliTRDcluster*)); + fN=0; SetBit(kRowCross, kFALSE); + if(strcmp(opt, "c")==0) return; + fExB=0.;fVD=0.;fT0=0.;fS2PRF=0.; fDiffL=0.;fDiffT=0.; fClusterIdx=0; - fN=0; + fErrorMsg = 0; fDet=-1; 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.; - for(Int_t ic=kNclusters; ic--;) fIndexes[ic] = -1; - memset(fClusters, 0, kNclusters*sizeof(AliTRDcluster*)); memset(fPad, 0, 3*sizeof(Float_t)); fYref[0] = 0.; fYref[1] = 0.; fZref[0] = 0.; fZref[1] = 0.; @@ -279,23 +283,23 @@ void AliTRDseedV1::Reset() for(int ispec=0; ispecGetSnp(); Double_t fTgl = trk->GetTgl(); fPt = trk->Pt(); - fYref[1] = fSnp/TMath::Sqrt(1. - fSnp*fSnp); - fZref[1] = fTgl; + Double_t norm =1./TMath::Sqrt((1.-fSnp)*(1.+fSnp)); + fYref[1] = fSnp*norm; + fZref[1] = fTgl*norm; SetCovRef(trk->GetCovariance()); Double_t dx = trk->GetX() - fX0; @@ -345,7 +349,7 @@ void AliTRDseedV1::UseClusters() if((*c)->IsShared() || (*c)->IsUsed()){ if((*c)->IsShared()) SetNShared(GetNShared()-1); else SetNUsed(GetNUsed()-1); - (*c) = 0x0; + (*c) = NULL; fIndexes[ic] = -1; SetN(GetN()-1); continue; @@ -384,13 +388,10 @@ 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)); - const Double_t kDriftLength = (.5 * AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick()); - AliTRDcluster *c = 0x0; + AliTRDcluster *c(NULL); for(int ic=0; icGetX()); @@ -412,16 +413,7 @@ void AliTRDseedV1::CookdEdx(Int_t nslices) //CHECK !!! fdEdx[slice] += w * GetdQdl(ic); //fdQdl[ic]; - nclusters[slice]++; } // End of loop over clusters - - //if(fReconstructor->GetPIDMethod() == AliTRDReconstructor::kLQPID){ - if(nslices == AliTRDpidUtil::kLQslices){ - // calculate mean charge per slice (only LQ PID) - for(int is=0; is +//End_Html +// In the picture the energy loss measured on the tracklet as a function of drift time [left] and respectively +// drift length [right] for different particle species is displayed. // Author : Alex Bercuci // Float_t dq = 0.; - if(fClusters[ic]) dq += TMath::Abs(fClusters[ic]->GetQ()); - if(fClusters[ic+kNtb]) dq += TMath::Abs(fClusters[ic+kNtb]->GetQ()); - if(dq<1.e-3 || fdX < 1.e-3) return 0.; + // check whether both clusters are inside the chamber + Bool_t hasClusterInChamber = kFALSE; + if(fClusters[ic] && fClusters[ic]->IsInChamber()){ + hasClusterInChamber = kTRUE; + dq += TMath::Abs(fClusters[ic]->GetQ()); + }else if(fClusters[ic+kNtb] && fClusters[ic+kNtb]->IsInChamber()){ + hasClusterInChamber = kTRUE; + dq += TMath::Abs(fClusters[ic+kNtb]->GetQ()); + } + if(!hasClusterInChamber) return 0.; + if(dq<1.e-3) return 0.; + + Double_t dx = fdX; + if(ic-1>=0 && ic+1IsInChamber()) x2 = fClusters[ic-1]->GetX(); + else if(fClusters[ic-1+kNtb] && fClusters[ic-1+kNtb]->IsInChamber()) x2 = fClusters[ic-1+kNtb]->GetX(); + else if(fClusters[ic] && fClusters[ic]->IsInChamber()) x2 = fClusters[ic]->GetX()+fdX; + else x2 = fClusters[ic+kNtb]->GetX()+fdX; + // try to estimate lower radial position (find the cluster which is inside the chamber) + if(fClusters[ic+1] && fClusters[ic+1]->IsInChamber()) x1 = fClusters[ic+1]->GetX(); + else if(fClusters[ic+1+kNtb] && fClusters[ic+1+kNtb]->IsInChamber()) x1 = fClusters[ic+1+kNtb]->GetX(); + else if(fClusters[ic] && fClusters[ic]->IsInChamber()) x1 = fClusters[ic]->GetX()-fdX; + else x1 = fClusters[ic+kNtb]->GetX()-fdX; + + dx = .5*(x2 - x1); + } + dx *= TMath::Sqrt(1. + fYfit[1]*fYfit[1] + fZref[1]*fZref[1]); + if(dl) (*dl) = dx; + if(dx>1.e-9) return dq/dx; + else return 0.; +} - return dq/fdX/TMath::Sqrt(1. + fYfit[1]*fYfit[1] + fZref[1]*fZref[1]); +//____________________________________________________________ +Float_t AliTRDseedV1::GetMomentum(Float_t *err) const +{ +// Returns momentum of the track after update with the current tracklet as: +// BEGIN_LATEX +// p=#frac{1}{1/p_{t}} #sqrt{1+tgl^{2}} +// END_LATEX +// and optionally the momentum error (if err is not null). +// The estimated variance of the momentum is given by: +// BEGIN_LATEX +// #sigma_{p}^{2} = (#frac{dp}{dp_{t}})^{2} #sigma_{p_{t}}^{2}+(#frac{dp}{dtgl})^{2} #sigma_{tgl}^{2}+2#frac{dp}{dp_{t}}#frac{dp}{dtgl} cov(tgl,1/p_{t}) +// END_LATEX +// which can be simplified to +// BEGIN_LATEX +// #sigma_{p}^{2} = p^{2}p_{t}^{4}tgl^{2}#sigma_{tgl}^{2}-2p^{2}p_{t}^{3}tgl cov(tgl,1/p_{t})+p^{2}p_{t}^{2}#sigma_{1/p_{t}}^{2} +// END_LATEX +// + + Double_t p = fPt*TMath::Sqrt(1.+fZref[1]*fZref[1]); + Double_t p2 = p*p; + Double_t tgl2 = fZref[1]*fZref[1]; + Double_t pt2 = fPt*fPt; + if(err){ + Double_t s2 = + p2*tgl2*pt2*pt2*fRefCov[4] + -2.*p2*fZref[1]*fPt*pt2*fRefCov[5] + +p2*pt2*fRefCov[6]; + (*err) = TMath::Sqrt(s2); + } + 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; icGetPIDObject(fReconstructor->GetPIDMethod()); + const AliTRDCalPID *pd = calibration->GetPIDObject(fkReconstructor->GetPIDMethod()); if (!pd) { AliError("No access to AliTRDCalPID object"); return kFALSE; } - //AliInfo(Form("Method[%d] : %s", fReconstructor->GetRecoParam() ->GetPIDMethod(), pd->IsA()->GetName())); // calculate tracklet length TO DO - Float_t length = (AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick()); - /// TMath::Sqrt((1.0 - fSnp[iPlane]*fSnp[iPlane]) / (1.0 + fTgl[iPlane]*fTgl[iPlane])); + Float_t length = (AliTRDgeometry::AmThick() + AliTRDgeometry::DrThick())/ TMath::Sqrt((1.0 - GetSnp()*GetSnp()) / (1.0 + GetTgl()*GetTgl())); //calculate dE/dx - CookdEdx(fReconstructor->GetNdEdxSlices()); - - // Sets the a priori probabilities - for(int ispec=0; ispecGetProbability(ispec, GetMomentum(), &fdEdx[0], length, GetPlane()); - } + 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; ispecGetProbability(ispec, GetMomentum(), &fdEdx[0], length, kPIDNN?GetPlane():fkReconstructor->GetRecoParam()->GetPIDLQslices()); + return kTRUE; } @@ -598,9 +676,9 @@ void AliTRDseedV1::GetCovAt(Double_t x, Double_t *cov) const //GetPadLength()*GetPadLength()/12.; // insert systematic uncertainties - if(fReconstructor){ + if(fkReconstructor){ Double_t sys[15]; memset(sys, 0, 15*sizeof(Double_t)); - fReconstructor->GetRecoParam()->GetSysCovMatrix(sys); + fkReconstructor->GetRecoParam()->GetSysCovMatrix(sys); sy2 += sys[0]; sz2 += sys[1]; } @@ -615,7 +693,7 @@ void AliTRDseedV1::GetCovAt(Double_t x, Double_t *cov) const } //____________________________________________________________ -Double_t AliTRDseedV1::GetCovSqrt(Double_t *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. @@ -634,38 +712,46 @@ Double_t AliTRDseedV1::GetCovSqrt(Double_t *c, Double_t *d) // Author A.Bercuci // Date Mar 19 2009 - Double_t L[2], // eigenvalues - V[3]; // eigenvectors + const Double_t kZero(1.e-20); + Double_t l[2], // eigenvalues + v[3]; // eigenvectors // the secular equation and its solution : // (c[0]-L)(c[2]-L)-c[1]^2 = 0 // L^2 - L*Tr(c)+DET(c) = 0 // 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.; - 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.; - + Double_t tr = c[0]+c[2], // trace + det = c[0]*c[2]-c[1]*c[1]; // determinant + if(TMath::Abs(det)c[2]?-1.:1.)); + l[1] = .5*(tr + dd*(c[0]>c[2]?1.:-1.)); + if(l[0] // Date Mar 19 2009 - Double_t Det = c[0]*c[2] - c[1]*c[1]; - if(TMath::Abs(Det)<1.e-20) return 0.; - Double_t InvDet = 1./Det; - d[0] = c[2]*InvDet; - d[1] =-c[1]*InvDet; - d[2] = c[0]*InvDet; - return Det; + Double_t det = c[0]*c[2] - c[1]*c[1]; + if(TMath::Abs(det)<1.e-20) return 0.; + Double_t invDet = 1./det; + d[0] = c[2]*invDet; + d[1] =-c[1]*invDet; + d[2] = c[0]*invDet; + return det; } //____________________________________________________________________ UShort_t AliTRDseedV1::GetVolumeId() const { - Int_t ic=0; - while(icGetVolumeId() : 0; + for(Int_t ic(0);icGetVolumeId(); + } + return 0; } @@ -737,12 +824,15 @@ void AliTRDseedV1::Calibrate() } } - fT0 = t0Det->GetValue(fDet) + t0ROC->GetValue(col,row); + fT0 = (t0Det->GetValue(fDet) + t0ROC->GetValue(col,row)) / AliTRDCommonParam::Instance()->GetSamplingFrequency(); fVD = vdDet->GetValue(fDet) * vdROC->GetValue(col, row); fS2PRF = calib->GetPRFWidth(fDet, col, row); fS2PRF *= fS2PRF; 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); } @@ -771,63 +861,98 @@ void AliTRDseedV1::SetPadPlane(AliTRDpadPlane *p) //____________________________________________________________________ -Bool_t AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber, Bool_t tilt) +Bool_t AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *const chamber, Bool_t tilt) { - // - // Projective algorithm to attach clusters to seeding tracklets - // - // Parameters - // - // Output - // - // Detailed description - // 1. Collapse x coordinate for the full detector plane - // 2. truncated mean on y (r-phi) direction - // 3. purge clusters - // 4. truncated mean on z direction - // 5. purge clusters - // 6. fit tracklet - // - Bool_t kPRINT = kFALSE; - if(!fReconstructor->GetRecoParam() ){ - AliError("Seed can not be used without a valid RecoParam."); +// +// Projective algorithm to attach clusters to seeding tracklets. The following steps are performed : +// 1. Collapse x coordinate for the full detector plane +// 2. truncated mean on y (r-phi) direction +// 3. purge clusters +// 4. truncated mean on z direction +// 5. purge clusters +// +// Parameters +// - chamber : pointer to tracking chamber container used to search the tracklet +// - tilt : switch for tilt correction during road building [default true] +// Output +// - true : if tracklet found successfully. Failure can happend because of the following: +// - +// Detailed description +// +// We start up by defining the track direction in the xy plane and roads. The roads are calculated based +// on tracking information (variance in the r-phi direction) and estimated variance of the standard +// clusters (see AliTRDcluster::SetSigmaY2()) corrected for tilt (see GetCovAt()). From this the road is +// BEGIN_LATEX +// r_{y} = 3*#sqrt{12*(#sigma^{2}_{Trk}(y) + #frac{#sigma^{2}_{cl}(y) + tg^{2}(#alpha_{L})#sigma^{2}_{cl}(z)}{1+tg^{2}(#alpha_{L})})} +// r_{z} = 1.5*L_{pad} +// END_LATEX +// +// Author : Alexandru Bercuci +// Debug : level >3 + + 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 = 4; - Int_t kClmin = Int_t(fReconstructor->GetRecoParam() ->GetFindableClusters()*AliTRDtrackerV1::GetNTimeBins()); - - Double_t syRef = TMath::Sqrt(fRefCov[0]); + Int_t t0 = 14; + Int_t kClmin = Int_t(recoParam->GetFindableClusters()*AliTRDtrackerV1::GetNTimeBins()); + + 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.; - //fReconstructor->GetRecoParam() ->GetRoad1y(); - Double_t kroadz = GetPadLength() * 1.5 + 1.; - if(kPRINT) printf("AttachClusters() sy[%f] road[%f]\n", syRef, kroady); + 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); + if(fkReconstructor->IsHLT()) cp.SetRPhiMethod(AliTRDcluster::kCOG); + if(!IsCalibrated()) Calibrate(); + + AliDebug(4, ""); + AliDebug(4, Form("syKalman[%f] rY[%f] rZ[%f]", syRef, kroady, kroadz)); // working variables const Int_t kNrows = 16; - AliTRDcluster *clst[kNrows][kNclusters]; - Double_t cond[4], dx, dy, yt, zt, - yres[kNrows][kNclusters]; - Int_t idxs[kNrows][kNclusters], ncl[kNrows], ncls = 0; + const Int_t kNcls = 3*kNclusters; // buffer size + AliTRDcluster *clst[kNrows][kNcls]; + Bool_t blst[kNrows][kNcls]; + Double_t cond[4], dx, dy, yt, zt, yres[kNrows][kNcls]; + Int_t idxs[kNrows][kNcls], ncl[kNrows], ncls = 0; memset(ncl, 0, kNrows*sizeof(Int_t)); - memset(clst, 0, kNrows*kNclusters*sizeof(AliTRDcluster*)); + memset(yres, 0, kNrows*kNcls*sizeof(Double_t)); + memset(blst, 0, kNrows*kNcls*sizeof(Bool_t)); //this is 8 times faster to memset than "memset(clst, 0, kNrows*kNcls*sizeof(AliTRDcluster*))" // Do cluster projection - AliTRDcluster *c = 0x0; - AliTRDchamberTimeBin *layer = 0x0; + AliTRDcluster *c = NULL; + AliTRDchamberTimeBin *layer = NULL; Bool_t kBUFFER = kFALSE; - for (Int_t it = 0; it < AliTRDtrackerV1::GetNTimeBins(); it++) { + for (Int_t it = 0; it < kNtb; it++) { if(!(layer = chamber->GetTB(it))) continue; if(!Int_t(*layer)) continue; - + // get track projection at layers position dx = fX0 - layer->GetX(); yt = fYref[0] - fYref[1] * dx; zt = fZref[0] - fZref[1] * dx; - if(kPRINT) printf("\t%2d dx[%f] yt[%f] zt[%f]\n", it, dx, yt, zt); + // get standard cluster error corrected for tilt + cp.SetLocalTimeBin(it); + cp.SetSigmaY2(0.02, fDiffT, fExB, dx, -1./*zt*/, fYref[1]); + s2yCl = (cp.GetSigmaY2() + sysCov[0] + t2*s2zCl)/(1.+t2); + // get estimated road + kroady = 3.*TMath::Sqrt(12.*(s2yTrk + s2yCl)); + + AliDebug(5, Form(" %2d x[%f] yt[%f] zt[%f]", it, dx, yt, zt)); + + AliDebug(5, Form(" syTrk[um]=%6.2f syCl[um]=%6.2f syClTlt[um]=%6.2f Ry[mm]=%f", 1.e4*TMath::Sqrt(s2yTrk), 1.e4*TMath::Sqrt(cp.GetSigmaY2()), 1.e4*TMath::Sqrt(s2yCl), 1.e1*kroady)); - // select clusters on a 5 sigmaKalman level + // select clusters cond[0] = yt; cond[2] = kroady; cond[1] = zt; cond[3] = kroadz; Int_t n=0, idx[6]; @@ -842,120 +967,199 @@ Bool_t AliTRDseedV1::AttachClusters(AliTRDtrackingChamber *chamber, Bool_t tilt) continue; }*/ Int_t r = c->GetPadRow(); - if(kPRINT) printf("\t\t%d dy[%f] yc[%f] r[%d]\n", ic, TMath::Abs(dy), c->GetY(), r); + AliDebug(5, Form(" -> dy[%f] yc[%f] r[%d]", TMath::Abs(dy), c->GetY(), r)); clst[r][ncl[r]] = c; + blst[r][ncl[r]] = kTRUE; idxs[r][ncl[r]] = idx[ic]; yres[r][ncl[r]] = dy; ncl[r]++; ncls++; - if(ncl[r] >= kNclusters) { - AliWarning(Form("Cluster candidates reached limit %d. Some may be lost.", kNclusters)); + if(ncl[r] >= kNcls) { + AliWarning(Form("Cluster candidates row[%d] reached buffer limit[%d]. Some may be lost.", r, kNcls)); kBUFFER = kTRUE; break; } } if(kBUFFER) break; } - if(kPRINT) printf("Found %d clusters\n", ncls); - if(ncls0 && lr-ir != 1){ - if(kPRINT) printf("W - gap in rows attached !!\n"); + if(lr>0 && ir-lr != 1){ + AliDebug(2, "Rows attached not continuous. Turn on selection."); + kRowSelection=kTRUE; } - if(kPRINT) printf("\tir[%d] lr[%d] n[%d]\n", ir, lr, ncl[ir]); + + AliDebug(5, Form(" r[%d] n[%d]", ir, ncl[ir])); // Evaluate truncated mean on the y direction - if(ncl[ir] > 3) AliMathBase::EvaluateUni(ncl[ir], yres[ir], mean, syDis, Int_t(ncl[ir]*.8)); - else { - mean = 0.; syDis = 0.; - } + if(ncl[ir] < 4) continue; + AliMathBase::EvaluateUni(ncl[ir], yres[ir], mean[nr], syDis[nr], Int_t(ncl[ir]*.8)); // TODO check mean and sigma agains cluster resolution !! - if(kPRINT) printf("\tr[%2d] m[%f %5.3fsigma] s[%f]\n", ir, mean, TMath::Abs(mean/syRef), syDis); - // select clusters on a 3 sigmaDistr level + AliDebug(4, Form(" m_%d[%+5.3f (%5.3fs)] s[%f]", nr, mean[nr], TMath::Abs(mean[nr]/syDis[nr]), syDis[nr])); + // remove outliers based on a 3 sigmaDistr level Bool_t kFOUND = kFALSE; for(Int_t ic = ncl[ir]; ic--;){ - if(yres[ir][ic] - mean > 3. * syDis){ - clst[ir][ic] = 0x0; continue; + if(yres[ir][ic] - mean[nr] > 3. * syDis[nr]){ + blst[ir][ic] = kFALSE; continue; } - nrow[nr]++; kFOUND = kTRUE; + nrow[nr]++; rowId[nr]=ir; kFOUND = kTRUE; + } + if(kFOUND){ + vdy[nr].Use(nrow[nr], yres[ir]); + nr++; } - // exit loop - if(kFOUND) nr++; lr = ir; if(nr>=3) break; } - if(kPRINT) printf("lr[%d] nr[%d] nrow[0]=%d nrow[1]=%d nrow[2]=%d\n", lr, nr, nrow[0], nrow[1], nrow[2]); - - // classify cluster rows - Int_t row = -1; - switch(nr){ - case 1: - row = lr; - break; - case 2: - SetBit(kRowCross, kTRUE); // mark pad row crossing - if(nrow[0] > nrow[1]){ row = lr+1; lr = -1;} - else{ - row = lr; lr = 1; - nrow[2] = nrow[1]; - nrow[1] = nrow[0]; - nrow[0] = nrow[2]; + if(recoParam->GetStreamLevel(AliTRDrecoParam::kTracker) > 3 && fkReconstructor->IsDebugStreaming()){ + TTreeSRedirector &cstreamer = *fkReconstructor->GetDebugStream(AliTRDrecoParam::kTracker); + UChar_t stat(0); + if(IsKink()) SETBIT(stat, 1); + if(IsStandAlone()) SETBIT(stat, 2); + cstreamer << "AttachClusters" + << "stat=" << stat + << "det=" << fDet + << "pt=" << fPt + << "s2y=" << s2yTrk + << "r0=" << rowId[0] + << "dy0=" << &vdy[0] + << "m0=" << mean[0] + << "s0=" << syDis[0] + << "r1=" << rowId[1] + << "dy1=" << &vdy[1] + << "m1=" << mean[1] + << "s1=" << syDis[1] + << "r2=" << rowId[2] + << "dy2=" << &vdy[2] + << "m2=" << mean[2] + << "s2=" << syDis[2] + << "\n"; + } + + + // analyze gap in rows attached + if(kRowSelection){ + SetErrorMsg(kAttachRowGap); + Int_t rowRemove(-1); + if(nr==2){ // select based on minimum distance to track projection + if(TMath::Abs(mean[0])nrow[0]) AliDebug(2, Form("Conflicting mean[%f < %f] but ncl[%d < %d].", TMath::Abs(mean[0]), TMath::Abs(mean[1]), nrow[0], nrow[1])); + }else{ + if(nrow[1] %f] but ncl[%d > %d].", TMath::Abs(mean[0]), TMath::Abs(mean[1]), nrow[0], nrow[1])); + Swap(nrow[0],nrow[1]); Swap(rowId[0],rowId[1]); + Swap(mean[0],mean[1]); Swap(syDis[0],syDis[1]); + } + rowRemove=1; nr=1; + } else if(nr==3){ // select based on 2 consecutive rows + if(rowId[1]==rowId[0]+1 && rowId[1]!=rowId[2]-1){ + nr=2;rowRemove=2; + } else if(rowId[1]!=rowId[0]+1 && rowId[1]==rowId[2]-1){ + Swap(nrow[0],nrow[2]); Swap(rowId[0],rowId[2]); + Swap(mean[0],mean[2]); Swap(syDis[0],syDis[2]); + nr=2; rowRemove=2; + } } - break; - case 3: + if(rowRemove>0){nrow[rowRemove]=0; rowId[rowRemove]=-1;} + } + AliDebug(4, Form(" Ncl[%d[%d] + %d[%d] + %d[%d]]", nrow[0], rowId[0], nrow[1], rowId[1], nrow[2], rowId[2])); + + if(nr==3){ + SetBit(kRowCross, kTRUE); // mark pad row crossing + SetErrorMsg(kAttachRow); + const Float_t am[]={TMath::Abs(mean[0]), TMath::Abs(mean[1]), TMath::Abs(mean[2])}; + AliDebug(4, Form("complex row configuration\n" + " r[%d] n[%d] m[%6.3f] s[%6.3f]\n" + " r[%d] n[%d] m[%6.3f] s[%6.3f]\n" + " r[%d] n[%d] m[%6.3f] s[%6.3f]\n" + , rowId[0], nrow[0], am[0], syDis[0] + , rowId[1], nrow[1], am[1], syDis[1] + , rowId[2], nrow[2], am[2], syDis[2])); + Int_t id[]={0,1,2}; TMath::Sort(3, am, id, kFALSE); + // backup + Int_t rnn[3]; memcpy(rnn, nrow, 3*sizeof(Int_t)); + Int_t rid[3]; memcpy(rid, rowId, 3*sizeof(Int_t)); + Double_t rm[3]; memcpy(rm, mean, 3*sizeof(Double_t)); + Double_t rs[3]; memcpy(rs, syDis, 3*sizeof(Double_t)); + nrow[0]=rnn[id[0]]; rowId[0]=rid[id[0]]; mean[0]=rm[id[0]]; syDis[0]=rs[id[0]]; + nrow[1]=rnn[id[1]]; rowId[1]=rid[id[1]]; mean[1]=rm[id[1]]; syDis[1]=rs[id[1]]; + nrow[2]=0; rowId[2]=-1; mean[2] = 1.e3; syDis[2] = 1.e3; + AliDebug(4, Form("solved configuration\n" + " r[%d] n[%d] m[%+6.3f] s[%6.3f]\n" + " r[%d] n[%d] m[%+6.3f] s[%6.3f]\n" + " r[%d] n[%d] m[%+6.3f] s[%6.3f]\n" + , rowId[0], nrow[0], mean[0], syDis[0] + , rowId[1], nrow[1], mean[1], syDis[1] + , rowId[2], nrow[2], mean[2], syDis[2])); + nr=2; + } else if(nr==2) { SetBit(kRowCross, kTRUE); // mark pad row crossing - break; + if(nrow[1] > nrow[0]){ // swap row order + Swap(nrow[0],nrow[1]); Swap(rowId[0],rowId[1]); + Swap(mean[0],mean[1]); Swap(syDis[0],syDis[1]); + } } - if(kPRINT) printf("\trow[%d] n[%d]\n\n", row, nrow[0]); - if(row<0) return kFALSE; // Select and store clusters // We should consider here : // 1. How far is the chamber boundary // 2. How big is the mean - Int_t n = 0; + Int_t n(0); Float_t dyc[kNclusters]; memset(dyc,0,kNclusters*sizeof(Float_t)); 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); + Int_t jr(rowId[ir]); + AliDebug(4, Form(" Attaching Ncl[%d]=%d ...", jr, ncl[jr])); for (Int_t ic = 0; ic < ncl[jr]; ic++) { - if(!(c = clst[jr][ic])) continue; - Int_t it = c->GetPadTime(); + if(!blst[jr][ic])continue; + c = clst[jr][ic]; + Int_t it(c->GetPadTime()); + Int_t idx(it+kNtb*ir); + if(fClusters[idx]){ + AliDebug(4, Form("Many cluster candidates on row[%2d] tb[%2d].", jr, it)); + // TODO should save also the information on where the multiplicity happened and its size + SetErrorMsg(kAttachMultipleCl); + // TODO should also compare with mean and sigma for this row + if(yres[jr][ic] > dyc[idx]) continue; + } + // TODO proper indexing of clusters !! - fIndexes[it+kNtb*ir] = chamber->GetTB(it)->GetGlobalIndex(idxs[jr][ic]); - fClusters[it+kNtb*ir] = c; - - //printf("\tid[%2d] it[%d] idx[%d]\n", ic, it, fIndexes[it]); - + fIndexes[idx] = chamber->GetTB(it)->GetGlobalIndex(idxs[jr][ic]); + fClusters[idx] = c; + dyc[idx] = yres[jr][ic]; n++; } - } + } + SetN(n); // number of minimum numbers of clusters expected for the tracklet - if (n < kClmin){ - //AliWarning(Form("Not enough clusters to fit the tracklet %d [%d].", n, kClmin)); + if (GetN() < kClmin){ + AliDebug(1, Form("NOT ENOUGH CLUSTERS %d ATTACHED TO THE TRACKLET [min %d] FROM FOUND %d.", GetN(), kClmin, n)); + SetErrorMsg(kAttachClAttach); return kFALSE; } - SetN(n); // Load calibration parameters for this tracklet Calibrate(); // calculate dx for time bins in the drift region (calibration aware) - Int_t irp = 0; Float_t x[2] = {0.,0.}; Int_t tb[2]={0,0}; - for (Int_t it = t0; it < AliTRDtrackerV1::GetNTimeBins(); it++) { + Float_t x[2] = {0.,0.}; Int_t tb[2]={0,0}; + for (Int_t it = t0, irp=0; irp<2 && it < AliTRDtrackerV1::GetNTimeBins(); it++) { if(!fClusters[it]) continue; x[irp] = fClusters[it]->GetX(); - tb[irp] = it; + tb[irp] = fClusters[it]->GetLocalTimeBin(); irp++; - if(irp==2) break; } Int_t dtb = tb[1] - tb[0]; fdX = dtb ? (x[0] - x[1]) / dtb : 0.15; - return kTRUE; } @@ -973,12 +1177,12 @@ void AliTRDseedV1::Bootstrap(const AliTRDReconstructor *rec) // // A.Bercuci Oct 30th 2008 // - fReconstructor = rec; + fkReconstructor = rec; AliTRDgeometry g; 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; @@ -999,39 +1203,106 @@ void AliTRDseedV1::Bootstrap(const AliTRDReconstructor *rec) //____________________________________________________________________ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Bool_t zcorr) { - // - // Linear fit of the tracklet - // - // Parameters : - // - // Output : - // True if successful - // - // Detailed description - // 2. Check if tracklet crosses pad row boundary - // 1. Calculate residuals in the y (r-phi) direction - // 3. Do a Least Square Fit to the data - // +// +// Linear fit of the clusters attached to the tracklet +// +// Parameters : +// - tilt : switch for tilt pad correction of cluster y position based on +// the z, dzdx info from outside [default false]. +// - zcorr : switch for using z information to correct for anisochronity +// and a finner error parameterization estimation [default false] +// Output : +// True if successful +// +// Detailed description +// +// Fit in the xy plane +// +// The fit is performed to estimate the y position of the tracklet and the track +// angle in the bending plane. The clusters are represented in the chamber coordinate +// system (with respect to the anode wire - see AliTRDtrackerV1::FollowBackProlongation() +// on how this is set). The x and y position of the cluster and also their variances +// are known from clusterizer level (see AliTRDcluster::GetXloc(), AliTRDcluster::GetYloc(), +// AliTRDcluster::GetSX() and AliTRDcluster::GetSY()). +// If gaussian approximation is used to calculate y coordinate of the cluster the position +// is recalculated taking into account the track angle. The general formula to calculate the +// error of cluster position in the gaussian approximation taking into account diffusion and track +// inclination is given for TRD by: +// BEGIN_LATEX +// #sigma^{2}_{y} = #sigma^{2}_{PRF} + #frac{x#delta_{t}^{2}}{(1+tg(#alpha_{L}))^{2}} + #frac{x^{2}tg^{2}(#phi-#alpha_{L})tg^{2}(#alpha_{L})}{12} +// END_LATEX +// +// Since errors are calculated only in the y directions, radial errors (x direction) are mapped to y +// by projection i.e. +// BEGIN_LATEX +// #sigma_{x|y} = tg(#phi) #sigma_{x} +// END_LATEX +// and also by the lorentz angle correction +// +// Fit in the xz plane +// +// The "fit" is performed to estimate the radial position (x direction) where pad row cross happens. +// If no pad row crossing the z position is taken from geometry and radial position is taken from the xy +// fit (see below). +// +// There are two methods to estimate the radial position of the pad row cross: +// 1. leading cluster radial position : Here the lower part of the tracklet is considered and the last +// cluster registered (at radial x0) on this segment is chosen to mark the pad row crossing. The error +// of the z estimate is given by : +// BEGIN_LATEX +// #sigma_{z} = tg(#theta) #Delta x_{x_{0}}/12 +// END_LATEX +// The systematic errors for this estimation are generated by the following sources: +// - no charge sharing between pad rows is considered (sharp cross) +// - missing cluster at row cross (noise peak-up, under-threshold signal etc.). +// +// 2. charge fit over the crossing point : Here the full energy deposit along the tracklet is considered +// to estimate the position of the crossing by a fit in the qx plane. The errors in the q directions are +// parameterized as s_q = q^2. The systematic errors for this estimation are generated by the following sources: +// - no general model for the qx dependence +// - physical fluctuations of the charge deposit +// - gain calibration dependence +// +// Estimation of the radial position of the tracklet +// +// For pad row cross the radial position is taken from the xz fit (see above). Otherwise it is taken as the +// interpolation point of the tracklet i.e. the point where the error in y of the fit is minimum. The error +// in the y direction of the tracklet is (see AliTRDseedV1::GetCovAt()): +// BEGIN_LATEX +// #sigma_{y} = #sigma^{2}_{y_{0}} + 2xcov(y_{0}, dy/dx) + #sigma^{2}_{dy/dx} +// END_LATEX +// and thus the radial position is: +// BEGIN_LATEX +// x = - cov(y_{0}, dy/dx)/#sigma^{2}_{dy/dx} +// END_LATEX +// +// Estimation of tracklet position error +// +// The error in y direction is the error of the linear fit at the radial position of the tracklet while in the z +// direction is given by the cluster error or pad row cross error. In case of no pad row cross this is given by: +// BEGIN_LATEX +// #sigma_{y} = #sigma^{2}_{y_{0}} - 2cov^{2}(y_{0}, dy/dx)/#sigma^{2}_{dy/dx} + #sigma^{2}_{dy/dx} +// #sigma_{z} = Pad_{length}/12 +// END_LATEX +// For pad row cross the full error is calculated at the radial position of the crossing (see above) and the error +// in z by the width of the crossing region - being a matter of parameterization. +// BEGIN_LATEX +// #sigma_{z} = tg(#theta) #Delta x_{x_{0}}/12 +// END_LATEX +// In case of no tilt correction (default in the barrel tracking) the tilt is taken into account by the rotation of +// the covariance matrix. See AliTRDseedV1::GetCovAt() for details. +// +// Author +// A.Bercuci + if(!fkReconstructor){ + AliError("The tracklet needs the reconstruction setup. Please initialize by SetReconstructor()."); + return kFALSE; + } if(!IsCalibrated()) Calibrate(); const Int_t kClmin = 8; - - // cluster error parametrization parameters - // 1. sy total charge - const Float_t sq0inv = 0.019962; // [1/q0] - const Float_t sqb = 1.0281564; //[cm] - // 2. sy for the PRF - const Float_t scy[AliTRDgeometry::kNlayer][4] = { - {2.827e-02, 9.600e-04, 4.296e-01, 2.271e-02}, - {2.952e-02,-2.198e-04, 4.146e-01, 2.339e-02}, - {3.090e-02, 1.514e-03, 4.020e-01, 2.402e-02}, - {3.260e-02,-2.037e-03, 3.946e-01, 2.509e-02}, - {3.439e-02,-3.601e-04, 3.883e-01, 2.623e-02}, - {3.510e-02, 2.066e-03, 3.651e-01, 2.588e-02}, - }; - // get track direction Double_t y0 = fYref[0]; Double_t dydx = fYref[1]; @@ -1039,22 +1310,16 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Bool_t zcorr) Double_t dzdx = fZref[1]; Double_t yt, zt; - // 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; + AliTRDtrackerV1::AliTRDLeastSquare fitterY; + AliTRDtrackerV1::AliTRDLeastSquare fitterZ; - //AliTRDtrackerV1::AliTRDLeastSquare fitterZ; - TLinearFitter fitterY(1, "pol1"); - TLinearFitter fitterZ(1, "pol1"); - // book cluster information Double_t qc[kNclusters], xc[kNclusters], yc[kNclusters], zc[kNclusters], sy[kNclusters]; - Int_t ily = AliTRDgeometry::GetLayer(fDet); Int_t n = 0; - AliTRDcluster *c=0x0, **jc = &fClusters[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; icGetNPads()>4) w = .5; if(c->GetNPads()>5) w = .2; - Int_t tb = c->GetLocalTimeBin(); + // cluster charge qc[n] = TMath::Abs(c->GetQ()); + // pad row of leading + // Radial cluster position //Int_t jc = TMath::Max(fN-3, 0); //xc[fN] = c->GetXloc(fT0, fVD, &qc[jc], &xc[jc]/*, z0 - c->GetX()*dzdx*/); xc[n] = fX0 - c->GetX(); - //Double_t s2 = fS2PRF + fDiffL*fDiffL*xc[n]/(1.+2.*exb2)+tgg*xc[n]*xc[n]*exb2/12.; - //yc[fN] = c->GetYloc(s2, GetPadWidth(), xc[fN], fExB); - yc[n] = c->GetY()-AliTRDcluster::GetYcorr(ily, c->GetCenter()); - zc[n] = c->GetZ(); - - // extrapolated y value for the track + // extrapolated track to cluster position yt = y0 - xc[n]*dydx; - // extrapolated z value for the track zt = z0 - xc[n]*dzdx; - // tilt correction - if(tilt) yc[n] -= GetTilt()*(zc[n] - zt); - - // ELABORATE CLUSTER ERROR - // basic y error (|| to track). - sy[n] = AliTRDcluster::GetSY(tb, zcorr?zt:-1.); - //printf("cluster[%d]\n\tsy[0] = %5.3e [um]\n", fN, sy[fN]*1.e4); - // y error due to total charge - sy[n] += sqb*(1./qc[n] - sq0inv); - //printf("\tsy[1] = %5.3e [um]\n", sy[fN]*1.e4); - // y error due to PRF - sy[n] += scy[ily][0]*TMath::Gaus(c->GetCenter(), scy[ily][1], scy[ily][2]) - scy[ily][3]; - //printf("\tsy[2] = %5.3e [um]\n", sy[fN]*1.e4); - - sy[n] *= sy[n]; - - // ADD ERROR ON x - // error of drift length parallel to the track - Double_t sx = AliTRDcluster::GetSX(tb, zcorr?zt:-1.); // [cm] - //printf("\tsx[0] = %5.3e [um]\n", sx*1.e4); - sx *= sx; // square sx - - // add error from ExB - sy[n] += fExB*fExB*sx; - //printf("\tsy[3] = %5.3e [um^2]\n", sy[fN]*1.e8); - - // global radial error due to misalignment/miscalibration - Double_t sx0 = 0.; sx0 *= sx0; - // add sx contribution to sy due to track angle - sy[n] += tgg*(sx+sx0); - // TODO we should add tilt pad correction here - //printf("\tsy[4] = %5.3e [um^2]\n", sy[fN]*1.e8); - c->SetSigmaY2(sy[n]); - - sy[n] = TMath::Sqrt(sy[n]); + + // 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] = 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)); + + 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]); - fitterZ.AddPoint(&xc[n], qc[n], 1.); + 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(); - fYfit[0] = fitterY.GetParameter(0); - fYfit[1] = -fitterY.GetParameter(1); + if(!fitterY.Eval()){ + SetErrorMsg(kFitFailed); + return kFALSE; + } + fYfit[0] = fitterY.GetFunctionParameter(0); + fYfit[1] = -fitterY.GetFunctionParameter(1); // store covariance - Double_t *p = fitterY.GetCovarianceMatrix(); - fCov[0] = p[0]; // variance of y0 - fCov[1] = p[1]; // covariance of y0, dydx - fCov[2] = p[3]; // variance of dydx + Double_t p[3]; + fitterY.GetCovarianceMatrix(p); + fCov[0] = p[1]; // variance of y0 + fCov[1] = p[2]; // covariance of y0, 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; + } - // fit XZ + // collect second row clusters + Int_t m(0); if(IsRowCross()){ +/* // THE LEADING CLUSTER METHOD + Float_t xMin = fX0; + Int_t ic=n=kNclusters-1; jc = &fClusters[ic]; + AliTRDcluster *c0 =0x0, **kc = &fClusters[kNtb-1]; + for(; ic>kNtb; ic--, --jc, --kc){ + if((c0 = (*kc)) && c0->IsInChamber() && (xMin>c0->GetX())) xMin = c0->GetX(); + if(!(c = (*jc))) continue; + if(!c->IsInChamber()) continue; + zc[kNclusters-1] = c->GetZ(); + fX = fX0 - c->GetX(); + } + fZfit[0] = .5*(zc[0]+zc[kNclusters-1]); fZfit[1] = 0.; + // Error parameterization + fS2Z = fdX*fZref[1]; + fS2Z *= fS2Z; fS2Z *= 0.2887; // 1/sqrt(12)*/ + + // THE FIT X-Q PLANE METHOD Int_t ic=n=kNclusters-1; jc = &fClusters[ic]; for(; ic>kNtb; ic--, --jc){ if(!(c = (*jc))) continue; @@ -1146,22 +1417,33 @@ Bool_t AliTRDseedV1::Fit(Bool_t tilt, Bool_t zcorr) 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--; + n--;m++; } - // fit XZ + } + // fit XZ + if(m && IsRowCross()){ fitterZ.Eval(); - if(fitterZ.GetParameter(1)!=0.){ - fX = -fitterZ.GetParameter(0)/fitterZ.GetParameter(1); + if(fitterZ.GetFunctionParameter(1)!=0.){ + fX = -fitterZ.GetFunctionParameter(0)/fitterZ.GetFunctionParameter(1); fX=(fX<0.)?0.:fX; Float_t dl = .5*AliTRDgeometry::CamHght()+AliTRDgeometry::CdrHght(); fX=(fX> dl)?dl:fX; - fX+=.055; // TODO to be understood + fX-=.055; // TODO to be understood } fZfit[0] = .5*(zc[0]+zc[kNclusters-1]); fZfit[1] = 0.; - fS2Z = 0.02+1.55*fZref[1]; fS2Z *= fS2Z; + // temporary external error parameterization + fS2Z = 0.05+0.4*TMath::Abs(fZref[1]); fS2Z *= fS2Z; + // TODO correct formula + //fS2Z = sigma_x*TMath::Abs(fZref[1]); } else { + if(IsRowCross() && !m){ + AliDebug(1, "Tracklet crossed row but no clusters found in neighbor row."); + } fZfit[0] = zc[0]; fZfit[1] = 0.; fS2Z = GetPadLength()*GetPadLength()/12.; } @@ -1432,13 +1714,17 @@ void AliTRDseedV1::Print(Option_t *o) const 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(" | x[cm] | y[cm] | z[cm] | dydx | dzdx |"); 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[2]), fZref[0]-fX*fYref[1], TMath::Sqrt(fRefCov[2]), fYref[1], fZref[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])); if(strcmp(o, "a")!=0) return; @@ -1516,3 +1802,4 @@ Bool_t AliTRDseedV1::IsEqual(const TObject *o) const } return kTRUE; } +