X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDtrackV1.cxx;h=7f072e68d37acba48a6d178ecbcb70fd3bdaeb7c;hb=383a295ac7dc9752055fe92388ad6e102a41dc69;hp=243c389954d9890e1afdcff1119c19be1dbad118;hpb=c04438f1cbe0db4cd438cf9fbab5618e06bbb594;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDtrackV1.cxx b/TRD/AliTRDtrackV1.cxx index 243c389954d..7f072e68d37 100644 --- a/TRD/AliTRDtrackV1.cxx +++ b/TRD/AliTRDtrackV1.cxx @@ -15,6 +15,7 @@ /* $Id$ */ +#include "AliLog.h" #include "AliESDtrack.h" #include "AliTracker.h" @@ -39,9 +40,12 @@ ClassImp(AliTRDtrackV1) //_______________________________________________________________ AliTRDtrackV1::AliTRDtrackV1() : AliKalmanTrack() - ,fPIDquality(0) + ,fStatus(0) ,fDE(0.) - ,fBackupTrack(0x0) + ,fkReconstructor(NULL) + ,fBackupTrack(NULL) + ,fTrackLow(NULL) + ,fTrackHigh(NULL) { // // Default constructor @@ -55,15 +59,18 @@ AliTRDtrackV1::AliTRDtrackV1() : AliKalmanTrack() for(int ip=0; ipGetN(); } } @@ -194,16 +214,16 @@ AliTRDtrackV1::~AliTRDtrackV1() { //AliInfo(""); //printf("I-AliTRDtrackV1::~AliTRDtrackV1() : Owner[%s]\n", TestBit(kOwner)?"YES":"NO"); - if(fBackupTrack) { - delete fBackupTrack; - } - fBackupTrack = 0x0; - if(TestBit(kOwner)){ - for(Int_t ip=0; ipGetClusters(ic))) continue; for (Int_t k = 0; k < 3; k++) { label = c->GetLabel(k); @@ -251,7 +272,6 @@ Bool_t AliTRDtrackV1::CookLabel(Float_t wrong) max = s[i][1]; label = s[i][0]; } - if ((1. - Float_t(max)/GetNumberOfClusters()) > wrong) label = -label; SetLabel(label); @@ -262,40 +282,28 @@ Bool_t AliTRDtrackV1::CookLabel(Float_t wrong) //_______________________________________________________________ Bool_t AliTRDtrackV1::CookPID() { - // - // Cook the PID information - // +// +// Cook the PID information for the track by delegating the omonim function of the tracklets. +// Computes the number of tracklets used. The tracklet information are considered independent. +// For the moment no global track measurement of PID is performed as for example to estimate +// bremsstrahlung probability based on global chi2 of the track. +// +// The status bit AliESDtrack::kTRDpid is set during the call of AliTRDtrackV1::UpdateESDtrack().The PID performance of the +//TRD for tracks with 6 tacklets is displayed below. +//Begin_Html +// +//End_Html +// - // Reset the a priori probabilities + /*Reset the a priori probabilities*/ Double_t pid = 1. / AliPID::kSPECIES; - for(int ispec=0; ispecIsOK()) continue; - if(!(prob = fTracklet[ip]->GetProbability())) return kFALSE; - - Int_t nspec = 0; // quality check of tracklet dEdx - for(int ispec=0; ispecIsOK()) continue; + if(!(prob = fTracklet[ip]->GetProbability(kFALSE))) continue; + + Int_t nspec = 0; // quality check of tracklet dEdx + for(int ispec=0; ispecSetPID(); + nPID++; + } + return nPID; +} + +//___________________________________________________________ +UChar_t AliTRDtrackV1::SetNumberOfTrackletsPID(Bool_t recalc) +{ +// Retrieve number of tracklets used for PID calculation. // Recalculated PID at tracklet level by quering the PID DB. - Double_t r[3]; - GetXYZ(r); - return AliTracker::GetBz(r); + UChar_t fPIDquality = 0; + + // steer PID calculation @ tracklet level + Float_t *prob = NULL; + for(int ip=0; ipIsOK()) continue; + if(!(prob = fTracklet[ip]->GetProbability(recalc))) return 0; + + Int_t nspec = 0; // quality check of tracklet dEdx + for(int ispec=0; ispecGetN() <= id){ + n+=fTracklet[ip]->GetN(); + continue; + } + AliTRDcluster *c = NULL; + for(Int_t ic=AliTRDseedV1::kNclusters; ic--;){ + if(!(c = fTracklet[ip]->GetClusters(ic))) continue; + + if(nGetN() < id){ + if(n+fTracklet[ip]->GetN() <= id){ n+=fTracklet[ip]->GetN(); continue; } - for(Int_t ic=34; ic>=0; ic--){ - if(!fTracklet[ip]->GetClusters(ic)) continue; - n++; - if(nGetClusters(ic))) continue; + + if(nGetIndexes(ic); } } @@ -347,19 +417,91 @@ Int_t AliTRDtrackV1::GetClusterIndex(Int_t id) const } //_______________________________________________________________ -Double_t AliTRDtrackV1::GetPredictedChi2(const AliTRDseedV1 *trklt) const +Double_t AliTRDtrackV1::GetPredictedChi2(const AliTRDseedV1 *trklt, Double_t *cov) const { - // - // Get the predicted chi2 - // +// Compute chi2 between tracklet and track. The value is calculated at the radial position of the track +// equal to the reference radial position of the tracklet (see AliTRDseedV1) +// +// The chi2 estimator is computed according to the following formula +// BEGIN_LATEX +// #chi^{2}=(X_{trklt}-X_{track})(C_{trklt}+C_{track})^{-1}(X_{trklt}-X_{track})^{T} +// END_LATEX +// where X=(y z), the position of the track/tracklet in the yz plane +// + + Double_t p[2] = { trklt->GetY(), trklt->GetZ()}; + trklt->GetCovAt(trklt->GetX(), cov); + return AliExternalTrackParam::GetPredictedChi2(p, cov); +} + +//_______________________________________________________________ +Int_t AliTRDtrackV1::GetSector() const +{ + return Int_t(GetAlpha()/AliTRDgeometry::GetAlpha() + (GetAlpha()>0. ? 0 : AliTRDgeometry::kNsector)); +} + +//_______________________________________________________________ +Bool_t AliTRDtrackV1::IsEqual(const TObject *o) const +{ + // Checks whether two tracks are equal + if (!o) return kFALSE; + const AliTRDtrackV1 *inTrack = dynamic_cast(o); + if (!inTrack) return kFALSE; - Double_t x = trklt->GetX0(); - Double_t p[2] = { trklt->GetYat(x) - , trklt->GetZat(x) }; - Double_t cov[3]; - trklt->GetCovAt(x, cov); + //if ( fPIDquality != inTrack->GetPIDquality() ) return kFALSE; - return AliExternalTrackParam::GetPredictedChi2(p, cov); + for(Int_t i = 0; i < AliPID::kSPECIES; i++){ + if ( fPID[i] != inTrack->GetPID(i) ) return kFALSE; + } + + for (Int_t i = 0; i < 3; i++){ + if ( fBudget[i] != inTrack->GetBudget(i) ) return kFALSE; + } + if ( fDE != inTrack->GetEdep() ) return kFALSE; + if ( fFakeRatio != inTrack->GetFakeRatio() ) return kFALSE; + if ( fChi2 != inTrack->GetChi2() ) return kFALSE; + if ( fMass != inTrack->GetMass() ) return kFALSE; + if ( fLab != inTrack->GetLabel() ) return kFALSE; + if ( fN != inTrack->GetNumberOfClusters() ) return kFALSE; + if ( AliKalmanTrack::GetIntegratedLength() != inTrack->GetIntegratedLength() ) return kFALSE; + + if ( GetX() != inTrack->GetX() ) return kFALSE; + if ( GetAlpha() != inTrack->GetAlpha() ) return kFALSE; + const Double_t *inP = inTrack->GetParameter(); + const Double_t *curP = GetParameter(); + for (Int_t i = 0; i < 5; i++){ + if ( curP[i] != inP[i]) return kFALSE; + } + const Double_t *inC = inTrack->GetCovariance(); + const Double_t *curC = GetCovariance(); + for (Int_t i = 0; i < 15; i++){ + if ( curC[i] != inC[i]) return kFALSE; + } + + for (Int_t iTracklet = 0; iTracklet < kNplane; iTracklet++){ + AliTRDseedV1 *curTracklet = fTracklet[iTracklet]; + AliTRDseedV1 *inTracklet = inTrack->GetTracklet(iTracklet); + if (curTracklet && inTracklet){ + if (! curTracklet->IsEqual(inTracklet) ) { + curTracklet->Print(); + inTracklet->Print(); + return kFALSE; + } + } else { + // if one tracklet exists, and corresponding + // in other track doesn't - return kFALSE + if(inTracklet || curTracklet) return kFALSE; + } + } + + return kTRUE; +} + +//_______________________________________________________________ +Bool_t AliTRDtrackV1::IsElectron() const +{ + if(GetPID(0) > fkReconstructor->GetRecoParam()->GetPIDThreshold(GetP())) return kTRUE; + return kFALSE; } @@ -383,12 +525,12 @@ Int_t AliTRDtrackV1::GetProlongation(Double_t xk, Double_t &y, Double_t &z) { // // Find a prolongation at given x - // Return 0 if it does not exist + // Return -1 if it does not exist // Double_t bz = GetBz(); - if (!AliExternalTrackParam::GetYAt(xk,bz,y)) return 0; - if (!AliExternalTrackParam::GetZAt(xk,bz,z)) return 0; + if (!AliExternalTrackParam::GetYAt(xk,bz,y)) return -1; + if (!AliExternalTrackParam::GetZAt(xk,bz,z)) return -1; return 1; @@ -405,45 +547,35 @@ Bool_t AliTRDtrackV1::PropagateTo(Double_t xk, Double_t xx0, Double_t xrho) // "xrho" - thickness*density [g/cm^2] // - if (xk == GetX()) { - return kTRUE; - } - - Double_t oldX = GetX(); - Double_t oldY = GetY(); - Double_t oldZ = GetZ(); - - Double_t bz = GetBz(); - - if (!AliExternalTrackParam::PropagateTo(xk,bz)) { - return kFALSE; - } + if (xk == GetX()) return kTRUE; - Double_t x = GetX(); - Double_t y = GetY(); - Double_t z = GetZ(); - - if (oldX < xk) { + Double_t xyz0[3] = {GetX(), GetY(), GetZ()}, // track position BEFORE propagation + b[3]; // magnetic field + GetBxByBz(b); + if(!AliExternalTrackParam::PropagateToBxByBz(xk,b)) return kFALSE; + + // local track position AFTER propagation + Double_t xyz1[3] = {GetX(), GetY(), GetZ()}; + if(xyz0[0] < xk) { xrho = -xrho; if (IsStartedTimeIntegral()) { - Double_t l2 = TMath::Sqrt((x-oldX)*(x-oldX) - + (y-oldY)*(y-oldY) - + (z-oldZ)*(z-oldZ)); - Double_t crv = AliExternalTrackParam::GetC(bz); + Double_t l2 = TMath::Sqrt((xyz1[0]-xyz0[0])*(xyz1[0]-xyz0[0]) + + (xyz1[1]-xyz0[1])*(xyz1[1]-xyz0[1]) + + (xyz1[2]-xyz0[2])*(xyz1[2]-xyz0[2])); + Double_t crv = AliExternalTrackParam::GetC(b[3]); if (TMath::Abs(l2*crv) > 0.0001) { // Make correction for curvature if neccesary - l2 = 0.5 * TMath::Sqrt((x-oldX)*(x-oldX) - + (y-oldY)*(y-oldY)); + l2 = 0.5 * TMath::Sqrt((xyz1[0]-xyz0[0])*(xyz1[0]-xyz0[0]) + + (xyz1[1]-xyz0[1])*(xyz1[1]-xyz0[1])); l2 = 2.0 * TMath::ASin(l2 * crv) / crv; - l2 = TMath::Sqrt(l2*l2 + (z-oldZ)*(z-oldZ)); + l2 = TMath::Sqrt(l2*l2 + (xyz1[2]-xyz0[2])*(xyz1[2]-xyz0[2])); } AddTimeStep(l2); } } - if (!AliExternalTrackParam::CorrectForMeanMaterial(xx0,xrho,GetMass())) { - return kFALSE; - } + if (!AliExternalTrackParam::CorrectForMeanMaterial(xx0, xrho, GetMass())) return kFALSE; + { @@ -505,12 +637,12 @@ Int_t AliTRDtrackV1::PropagateToR(Double_t r,Double_t step) Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]); Rotate(alpha,kTRUE); GetXYZ(xyz0); - GetProlongation(x,y,z); + if(GetProlongation(x,y,z)<0) return -1; xyz1[0] = x * TMath::Cos(alpha) + y * TMath::Sin(alpha); xyz1[1] = x * TMath::Sin(alpha) - y * TMath::Cos(alpha); xyz1[2] = z; Double_t param[7]; - AliTracker::MeanMaterialBudget(xyz0,xyz1,param); + if(AliTracker::MeanMaterialBudget(xyz0,xyz1,param)<=0.) return -1; if (param[1] <= 0) { param[1] = 100000000; } @@ -522,12 +654,12 @@ Int_t AliTRDtrackV1::PropagateToR(Double_t r,Double_t step) Double_t alpha = TMath::ATan2(xyz0[1],xyz0[0]); Rotate(alpha,kTRUE); GetXYZ(xyz0); - GetProlongation(r,y,z); + if(GetProlongation(r,y,z)<0) return -1; xyz1[0] = r * TMath::Cos(alpha) + y * TMath::Sin(alpha); xyz1[1] = r * TMath::Sin(alpha) - y * TMath::Cos(alpha); xyz1[2] = z; Double_t param[7]; - AliTracker::MeanMaterialBudget(xyz0,xyz1,param); + if(AliTracker::MeanMaterialBudget(xyz0,xyz1,param) <= 0.) return -1; if (param[1] <= 0) { param[1] = 100000000; @@ -538,6 +670,39 @@ Int_t AliTRDtrackV1::PropagateToR(Double_t r,Double_t step) } +//_____________________________________________________________________________ +void AliTRDtrackV1::Print(Option_t *o) const +{ + // Print track status + AliInfo(Form("PID [%4.1f %4.1f %4.1f %4.1f %4.1f]", 1.E2*fPID[0], 1.E2*fPID[1], 1.E2*fPID[2], 1.E2*fPID[3], 1.E2*fPID[4])); + AliInfo(Form("Material[%5.2f %5.2f %5.2f]", fBudget[0], fBudget[1], fBudget[2])); + + AliInfo(Form("x[%7.2f] t[%7.4f] alpha[%f] mass[%f]", GetX(), GetIntegratedLength(), GetAlpha(), fMass)); + AliInfo(Form("Ntr[%1d] NtrPID[%1d] Ncl[%3d] lab[%3d]", GetNumberOfTracklets(), GetNumberOfTrackletsPID(), fN, fLab)); + + printf("|X| = ("); + const Double_t *curP = GetParameter(); + for (Int_t i = 0; i < 5; i++) printf("%7.2f ", curP[i]); + printf(")\n"); + + printf("|V| = \n"); + const Double_t *curC = GetCovariance(); + for (Int_t i = 0, j=4, k=0; i<15; i++, k++){ + printf("%7.2f ", curC[i]); + if(k==j){ + printf("\n"); + k=-1; j--; + } + } + if(strcmp(o, "a")!=0) return; + + for(Int_t ip=0; ipPrint(o); + } +} + + //_____________________________________________________________________________ Bool_t AliTRDtrackV1::Rotate(Double_t alpha, Bool_t absolute) { @@ -583,47 +748,52 @@ void AliTRDtrackV1::SetOwner() } //_______________________________________________________________ -void AliTRDtrackV1::SetTracklet(AliTRDseedV1 *trklt, Int_t index) +void AliTRDtrackV1::SetTracklet(AliTRDseedV1 *const trklt, Int_t index) { // // Set the tracklets // Int_t plane = trklt->GetPlane(); - if(fTrackletIndex[plane]==0xffff && fTracklet[plane]){ - delete fTracklet[plane]; - } + fTracklet[plane] = trklt; fTrackletIndex[plane] = index; } //_______________________________________________________________ -Bool_t AliTRDtrackV1::Update(AliTRDseedV1 *trklt, Double_t chisq) +void AliTRDtrackV1::SetTrackLow() +{ + const AliExternalTrackParam *op = dynamic_cast(this); + fTrackLow = fTrackLow ? new(fTrackLow) AliExternalTrackParam(*op) : new AliExternalTrackParam(*op); +} + +//_______________________________________________________________ +void AliTRDtrackV1::SetTrackHigh(const AliExternalTrackParam *op) +{ + if(!op) op = dynamic_cast(this); + fTrackHigh = fTrackHigh ? new(fTrackHigh) AliExternalTrackParam(*op) : new AliExternalTrackParam(*op); +} + +//_______________________________________________________________ +void AliTRDtrackV1::UnsetTracklet(Int_t plane) +{ + if(plane<0 && plane >= kNplane) return; + fTrackletIndex[plane] = 0xffff; + fTracklet[plane] = NULL; +} + + +//_______________________________________________________________ +Bool_t AliTRDtrackV1::Update(Double_t *p, Double_t *cov, Double_t chi2) { // - // Update track and tracklet parameters + // Update track // - - Double_t x = trklt->GetX0(); - Double_t p[2] = { trklt->GetYat(x) - , trklt->GetZat(x) }; - Double_t cov[3]; - trklt->GetCovAt(x, cov); - + AliDebug(2, Form("Point:\n p=[%6.2f %6.2f]\n V=[%6.2f %6.2f]\n [%6.2f %6.2f]", p[0], p[1], cov[0], cov[1], cov[1], cov[2])); if(!AliExternalTrackParam::Update(p, cov)) return kFALSE; - - AliTRDcluster *c = 0x0; - Int_t ic = 0; while(!(c = trklt->GetClusters(ic))) ic++; - AliTracker::FillResiduals(this, p, cov, c->GetVolumeId()); - - + // Register info to track SetNumberOfClusters(); - SetChi2(GetChi2() + chisq); - - // update tracklet - trklt->SetMomentum(GetP()); - trklt->SetSnp(GetSnp()); - trklt->SetTgl(GetTgl()); + SetChi2(GetChi2() + chi2); return kTRUE; } @@ -634,17 +804,25 @@ void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track) // Update the TRD PID information in the ESD track // - track->SetNumberOfTRDslices(kNslice); - + Int_t nslices = fkReconstructor->GetRecoParam()->IsEightSlices() ? (Int_t)AliTRDpidUtil::kNNslices : (Int_t)AliTRDpidUtil::kLQslices; + // number of tracklets used for PID calculation + UChar_t nPID = GetNumberOfTrackletsPID(); + // number of tracklets attached to the track + UChar_t nTrk = GetNumberOfTracklets(); + // pack the two numbers together and store them in the ESD + track->SetTRDntracklets(nPID | (nTrk<<3)); + // allocate space to store raw PID signals dEdx & momentum + track->SetNumberOfTRDslices((nslices+2)*AliTRDgeometry::kNlayer); + // store raw signals + Float_t p, sp; Double_t spd; for (Int_t ip = 0; ip < kNplane; ip++) { if(fTrackletIndex[ip] == 0xffff) continue; - fTracklet[ip]->CookdEdx(kNslice); - Float_t *dedx = fTracklet[ip]->GetdEdx(); - for (Int_t js = 0; js < kNslice; js++) track->SetTRDslice(dedx[js], ip, js); + if(!fTracklet[ip]->HasPID()) continue; + const Float_t *dedx = fTracklet[ip]->GetdEdx(); + for (Int_t js = 0; js < nslices; js++, dedx++) track->SetTRDslice(*dedx, ip, js); + p = fTracklet[ip]->GetMomentum(&sp); spd = sp; + track->SetTRDmomentum(p, ip, &spd); } - - // copy PID to ESD - if(!fPIDquality) return; + // store PID probabilities track->SetTRDpid(fPID); - track->SetTRDpidQuality(fPIDquality); }