X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDtrackV1.cxx;h=e7560118430dead11e12e66efb87db7e7c6c1864;hb=63671ce777860e7a35b2be0807379235b674177c;hp=8e988a10b38201efb2c4b125cb9819dd392c8bfb;hpb=2a3191bbd3d1634d2cc5c1b9b7b80ec4d0705774;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDtrackV1.cxx b/TRD/AliTRDtrackV1.cxx index 8e988a10b38..e7560118430 100644 --- a/TRD/AliTRDtrackV1.cxx +++ b/TRD/AliTRDtrackV1.cxx @@ -23,6 +23,7 @@ #include "AliTRDcluster.h" #include "AliTRDcalibDB.h" #include "AliTRDReconstructor.h" +#include "AliTRDPIDResponse.h" #include "AliTRDrecoParam.h" ClassImp(AliTRDtrackV1) @@ -41,11 +42,12 @@ ClassImp(AliTRDtrackV1) //_______________________________________________________________ AliTRDtrackV1::AliTRDtrackV1() : AliKalmanTrack() ,fStatus(0) + ,fESDid(0) ,fDE(0.) - ,fReconstructor(0x0) - ,fBackupTrack(0x0) - ,fTrackLow(0x0) - ,fTrackHigh(0x0) + ,fkReconstructor(NULL) + ,fBackupTrack(NULL) + ,fTrackLow(NULL) + ,fTrackHigh(NULL) { // // Default constructor @@ -58,19 +60,20 @@ AliTRDtrackV1::AliTRDtrackV1() : AliKalmanTrack() for(int is =0; isGetN(); } - } + } AliKalmanTrack::SetNumberOfClusters(ncls); for(int i =0; i<3; i++) fBudget[i] = 0.; Float_t pid = 1./AliPID::kSPECIES; for(int is =0; isGetClusters(ic))) continue; for (Int_t k = 0; k < 3; k++) { @@ -290,29 +347,31 @@ Bool_t AliTRDtrackV1::CookPID() // //End_Html // - - /*Reset the a priori probabilities*/ - Double_t pid = 1. / AliPID::kSPECIES; - for(int ispec=0; ispecGetPIDResponse(fkReconstructor->GetRecoParam()->GetPIDmethod()); + if(!pidResponse){ + AliError("PID Response not available"); return kFALSE; } - - for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) fPID[iSpecies] /= probTotal; - + Int_t nslices = pidResponse->GetNumberOfSlices(); + Double_t dEdx[kNplane * (Int_t)AliTRDPIDResponse::kNslicesNN]; + Float_t trackletP[kNplane]; + memset(dEdx, 0, sizeof(Double_t) * kNplane * (Int_t)AliTRDPIDResponse::kNslicesNN); + memset(trackletP, 0, sizeof(Float_t)*kNplane); + for(Int_t iseed = 0; iseed < kNplane; iseed++){ + if(!fTracklet[iseed]) continue; + trackletP[iseed] = fTracklet[iseed]->GetMomentum(); + fTracklet[iseed]->CookdEdx(nslices); + fTracklet[iseed]->SetPID(); + if(pidResponse->GetPIDmethod() == AliTRDPIDResponse::kLQ1D){ + dEdx[iseed] = fTracklet[iseed]->GetdQdl(); + } else { + const Float_t *trackletdEdx = fTracklet[iseed]->GetdEdx(); + for(Int_t islice = 0; islice < nslices; islice++){ + dEdx[iseed*nslices + islice] = trackletdEdx[islice]; + } + } + } + pidResponse->GetResponse(nslices, dEdx, trackletP, fPID); return kTRUE; } @@ -322,55 +381,19 @@ UChar_t AliTRDtrackV1::GetNumberOfTrackletsPID() const // Retrieve number of tracklets used for PID calculation. UChar_t nPID = 0; - Float_t *prob = 0x0; for(int ip=0; ipIsOK()) 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. - - UChar_t fPIDquality = 0; - - // steer PID calculation @ tracklet level - Float_t *prob = 0x0; - 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(); continue; } - AliTRDcluster *c = 0x0; + AliTRDcluster *c = NULL; for(Int_t ic=AliTRDseedV1::kNclusters; ic--;){ if(!(c = fTracklet[ip]->GetClusters(ic))) continue; @@ -386,12 +409,13 @@ AliTRDcluster* AliTRDtrackV1::GetCluster(Int_t id) return c; } } - return 0x0; + return NULL; } //_______________________________________________________________ Int_t AliTRDtrackV1::GetClusterIndex(Int_t id) const { + // Get the cluster index at a certain position in the track Int_t n = 0; for(Int_t ip=0; ipGetN(); continue; } - AliTRDcluster *c = 0x0; for(Int_t ic=AliTRDseedV1::kNclusters; ic--;){ - if(!(c = fTracklet[ip]->GetClusters(ic))) continue; - + if(!(fTracklet[ip]->GetClusters(ic))) continue; if(nGetIndexes(ic); } @@ -437,39 +459,30 @@ Int_t AliTRDtrackV1::GetSector() const //_______________________________________________________________ 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; //if ( fPIDquality != inTrack->GetPIDquality() ) return kFALSE; - 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; - } + if(memcmp(fPID, inTrack->fPID, AliPID::kSPECIES*sizeof(Double32_t))) return kFALSE; + if(memcmp(fBudget, inTrack->fBudget, 3*sizeof(Double32_t))) return kFALSE; + if(memcmp(&fDE, &inTrack->fDE, sizeof(Double32_t))) return kFALSE; + if(memcmp(&fFakeRatio, &inTrack->fFakeRatio, sizeof(Double32_t))) return kFALSE; + if(memcmp(&fChi2, &inTrack->fChi2, sizeof(Double32_t))) return kFALSE; + if(memcmp(&fMass, &inTrack->fMass, sizeof(Double32_t))) return kFALSE; + if( fLab != inTrack->fLab ) return kFALSE; + if( fN != inTrack->fN ) return kFALSE; + Double32_t l(0.), in(0.); + l = GetIntegratedLength(); in = inTrack->GetIntegratedLength(); + if(memcmp(&l, &in, sizeof(Double32_t))) return kFALSE; + l=GetX(); in=inTrack->GetX(); + if(memcmp(&l, &in, sizeof(Double32_t))) return kFALSE; + l = GetAlpha(); in = inTrack->GetAlpha(); + if(memcmp(&l, &in, sizeof(Double32_t))) return kFALSE; + if(memcmp(GetParameter(), inTrack->GetParameter(), 5*sizeof(Double32_t))) return kFALSE; + if(memcmp(GetCovariance(), inTrack->GetCovariance(), 15*sizeof(Double32_t))) return kFALSE; for (Int_t iTracklet = 0; iTracklet < kNplane; iTracklet++){ AliTRDseedV1 *curTracklet = fTracklet[iTracklet]; @@ -493,28 +506,67 @@ Bool_t AliTRDtrackV1::IsEqual(const TObject *o) const //_______________________________________________________________ Bool_t AliTRDtrackV1::IsElectron() const { - if(GetPID(0) > fReconstructor->GetRecoParam()->GetPIDThreshold(GetP())) return kTRUE; + if(GetPID(0) > fkReconstructor->GetRecoParam()->GetPIDThreshold(GetP())) return kTRUE; return kFALSE; } //_____________________________________________________________________________ -void AliTRDtrackV1::MakeBackupTrack() +Int_t AliTRDtrackV1::MakeBackupTrack() { - // - // Creates a backup track - // +// +// Creates a backup track +// TO DO update quality check of the track. +// + + Float_t occupancy(0.); Int_t n(0), ncls(0); + for(Int_t il(AliTRDgeometry::kNlayer); il--;){ + if(!fTracklet[il]) continue; + n++; + occupancy+=fTracklet[il]->GetOccupancyTB(); + ncls += fTracklet[il]->GetN(); + } + if(!n) return -1; + occupancy/=n; + + //Float_t ratio1 = Float_t(t.GetNumberOfClusters()+1) / Float_t(t.GetNExpected()+1); + + Int_t failedCutId(0); + if(GetChi2()/n > 5.0) failedCutId=1; + if(occupancy < 0.7) failedCutId=2; + //if(ratio1 > 0.6) && + //if(ratio0+ratio1 > 1.5) && + if(GetNCross() != 0) failedCutId=3; + if(TMath::Abs(GetSnp()) > 0.85) failedCutId=4; + if(ncls < 20) failedCutId=5; + + if(failedCutId){ + AliDebug(2, Form("\n" + "chi2/tracklet < 5.0 [%c] %5.2f\n" + "occupancy > 0.7 [%c] %4.2f\n" + "NCross == 0 [%c] %d\n" + "Abs(snp) < 0.85 [%c] %4.2f\n" + "NClusters > 20 [%c] %d" + ,(GetChi2()/n<5.0)?'y':'n', GetChi2()/n + ,(occupancy>0.7)?'y':'n', occupancy + ,(GetNCross()==0)?'y':'n', GetNCross() + ,(TMath::Abs(GetSnp())<0.85)?'y':'n', TMath::Abs(GetSnp()) + ,(ncls>20)?'y':'n', ncls + )); + return failedCutId; + } if(fBackupTrack) { fBackupTrack->~AliTRDtrackV1(); new(fBackupTrack) AliTRDtrackV1((AliTRDtrackV1&)(*this)); - return; + return 0; } fBackupTrack = new AliTRDtrackV1((AliTRDtrackV1&)(*this)); + return 0; } //_____________________________________________________________________________ -Int_t AliTRDtrackV1::GetProlongation(Double_t xk, Double_t &y, Double_t &z) +Int_t AliTRDtrackV1::GetProlongation(Double_t xk, Double_t &y, Double_t &z) const { // // Find a prolongation at given x @@ -540,37 +592,28 @@ 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; - } - - Double_t x = GetX(); - Double_t y = GetY(); - Double_t z = GetZ(); + if (TMath::Abs(xk - GetX()) 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); } @@ -675,13 +718,13 @@ 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)); - if(strcmp(o, "a")!=0) return; printf("|X| = ("); const Double_t *curP = GetParameter(); for (Int_t i = 0; i < 5; i++) printf("%7.2f ", curP[i]); @@ -696,6 +739,7 @@ void AliTRDtrackV1::Print(Option_t *o) const k=-1; j--; } } + if(strcmp(o, "a")!=0) return; for(Int_t ip=0; ipGetN(); + if(fTracklet[ip] && fTrackletIndex[ip] >= 0) ncls += fTracklet[ip]->GetN(); } AliKalmanTrack::SetNumberOfClusters(ncls); } @@ -741,7 +785,7 @@ void AliTRDtrackV1::SetOwner() if(TestBit(kOwner)) return; for (Int_t ip = 0; ip < kNplane; ip++) { - if(fTrackletIndex[ip] == 0xffff) continue; + if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue; fTracklet[ip] = new AliTRDseedV1(*fTracklet[ip]); fTracklet[ip]->SetOwner(); } @@ -749,7 +793,7 @@ void AliTRDtrackV1::SetOwner() } //_______________________________________________________________ -void AliTRDtrackV1::SetTracklet(AliTRDseedV1 *trklt, Int_t index) +void AliTRDtrackV1::SetTracklet(AliTRDseedV1 *const trklt, Int_t index) { // // Set the tracklets @@ -761,40 +805,47 @@ void AliTRDtrackV1::SetTracklet(AliTRDseedV1 *trklt, Int_t index) } //_______________________________________________________________ -void AliTRDtrackV1::SetTrackLow() +void AliTRDtrackV1::SetTrackIn() { +// Save location of birth for the TRD track +// If the pointer is not valid allocate memory +// const AliExternalTrackParam *op = dynamic_cast(this); - fTrackLow = fTrackLow ? new(fTrackLow) AliExternalTrackParam(*op) : new AliExternalTrackParam(*op); + + //printf("SetTrackIn() : fTrackLow[%p]\n", (void*)fTrackLow); + if(fTrackLow){ + fTrackLow->~AliExternalTrackParam(); + new(fTrackLow) AliExternalTrackParam(*op); + } else fTrackLow = new AliExternalTrackParam(*op); } //_______________________________________________________________ -void AliTRDtrackV1::SetTrackHigh(const AliExternalTrackParam *op) +void AliTRDtrackV1::SetTrackOut(const AliExternalTrackParam *op) { +// Save location of death for the TRD track +// If the pointer is not valid allocate memory +// if(!op) op = dynamic_cast(this); - fTrackHigh = fTrackHigh ? new(fTrackHigh) AliExternalTrackParam(*op) : new AliExternalTrackParam(*op); + if(fTrackHigh){ + fTrackHigh->~AliExternalTrackParam(); + new(fTrackHigh) AliExternalTrackParam(*op); + } else fTrackHigh = new AliExternalTrackParam(*op); } //_______________________________________________________________ void AliTRDtrackV1::UnsetTracklet(Int_t plane) { - if(plane<0 && plane >= kNplane) return; - fTrackletIndex[plane] = 0xffff; - fTracklet[plane] = 0x0; + if(plane<0) return; + fTrackletIndex[plane] = -1; + fTracklet[plane] = NULL; } //_______________________________________________________________ -Bool_t AliTRDtrackV1::Update(Double_t *p, Double_t *cov, Double_t chi2) +void AliTRDtrackV1::UpdateChi2(Float_t chi2) { - // - // Update track - // - if(!AliExternalTrackParam::Update(p, cov)) return kFALSE; - - // Register info to track - SetNumberOfClusters(); +// Update chi2/track with one tracklet contribution SetChi2(GetChi2() + chi2); - return kTRUE; } //_______________________________________________________________ @@ -804,7 +855,7 @@ void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track) // Update the TRD PID information in the ESD track // - Int_t nslices = fReconstructor->IsEightSlices() ? (Int_t)AliTRDpidUtil::kNNslices : (Int_t)AliTRDpidUtil::kLQslices; + Int_t nslices = AliTRDcalibDB::Instance()->GetPIDResponse(fkReconstructor->GetRecoParam()->GetPIDmethod())->GetNumberOfSlices(); // number of tracklets used for PID calculation UChar_t nPID = GetNumberOfTrackletsPID(); // number of tracklets attached to the track @@ -816,12 +867,16 @@ void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track) // store raw signals Float_t p, sp; Double_t spd; for (Int_t ip = 0; ip < kNplane; ip++) { - if(fTrackletIndex[ip] == 0xffff) continue; + if(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue; if(!fTracklet[ip]->HasPID()) continue; - 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; + const Float_t *dedx = fTracklet[ip]->GetdEdx(); + for (Int_t js = 0; js < nslices; js++, dedx++) track->SetTRDslice(*dedx, ip, js+1); + p = fTracklet[ip]->GetMomentum(&sp); + // 04.01.11 A.Bercuci + // store global dQdl per tracklet instead of momentum error + spd = sp; track->SetTRDmomentum(p, ip, &spd); + track->SetTRDslice(fTracklet[ip]->GetdQdl(), ip, 0); // Set Summed dEdx into the first slice } // store PID probabilities track->SetTRDpid(fPID);