X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDtrackV1.cxx;h=156ca2621a24c018b326791d01307207fd027a47;hb=f8066e767d19b1b742acc16b730682b1bdf390b1;hp=3ca9927f933109b1398f337d86786f9fd8e7232a;hpb=e79f8eb0f6173e1f14c2a80bdb9e2be4f2d13b82;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDtrackV1.cxx b/TRD/AliTRDtrackV1.cxx index 3ca9927f933..156ca2621a2 100644 --- a/TRD/AliTRDtrackV1.cxx +++ b/TRD/AliTRDtrackV1.cxx @@ -1,3 +1,4 @@ + /************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * @@ -15,6 +16,8 @@ /* $Id$ */ +#include "TVectorT.h" +#include "AliLog.h" #include "AliESDtrack.h" #include "AliTracker.h" @@ -22,7 +25,9 @@ #include "AliTRDcluster.h" #include "AliTRDcalibDB.h" #include "AliTRDReconstructor.h" +#include "AliTRDPIDResponse.h" #include "AliTRDrecoParam.h" +#include "AliTRDdEdxUtils.h" ClassImp(AliTRDtrackV1) @@ -39,39 +44,55 @@ ClassImp(AliTRDtrackV1) //_______________________________________________________________ AliTRDtrackV1::AliTRDtrackV1() : AliKalmanTrack() - ,fPIDquality(0) + ,fStatus(0) + ,fESDid(0) ,fDE(0.) - ,fBackupTrack(0x0) + ,fTruncatedMean(0) + ,fkReconstructor(NULL) + ,fBackupTrack(NULL) + ,fTrackLow(NULL) + ,fTrackHigh(NULL) { // // Default constructor // + //printf("AliTRDtrackV1::AliTRDtrackV1()\n"); + for(int i =0; i<3; i++) fBudget[i] = 0.; Float_t pid = 1./AliPID::kSPECIES; 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++) { - label = c->GetLabel(k); - labelAdded = kFALSE; - Int_t j = 0; - if (label >= 0) { - while ((!labelAdded) && (j < kMAXCLUSTERSPERTRACK)) { - if ((s[j][0] == label) || - (s[j][1] == 0)) { - s[j][0] = label; - s[j][1]++; - labelAdded = kTRUE; - } - j++; - } + for (Int_t k(0); k < 3; k++) { + if ((label = c->GetLabel(k)) < 0) continue; + Int_t j(0); + while(j < kMAXCLUSTERSPERTRACK){ + if(s[0][j]!=label && s[1][j]!=0){j++; continue;} + if(!s[1][j]) nlabels++; + s[0][j] = label; s[1][j]++; + break; } } } } - - Int_t max = 0; - label = -123456789; - for (Int_t i = 0; i < kMAXCLUSTERSPERTRACK; i++) { - if (s[i][1] <= max) continue; - max = s[i][1]; - label = s[i][0]; + //printf(" Found %4d labels\n", nlabels); + Float_t prob(1.); + if(!nlabels){ + AliError(Form("No MC labels found for track %d.", fESDid)); + return 0; + } else if(nlabels==1) { + label = s[0][0]; + if(labs && freq){labs[0]=label; freq[0]=1.;} + } else { + Int_t idx[kMAXCLUSTERSPERTRACK]; + TMath::Sort(nlabels, s[1], idx); + label = s[0][idx[0]]; prob = s[1][idx[0]]/Float_t(ncl); + if(labs && freq){ + for (Int_t i(0); i wrong) label = -label; - - SetLabel(label); - - return kTRUE; + SetLabel((1.-prob > wrong)?-label:label); + return nlabels; } //_______________________________________________________________ Bool_t AliTRDtrackV1::CookPID() { - // - // Cook the PID information - // - - // Reset the a priori probabilities - Double_t pid = 1. / AliPID::kSPECIES; - for(int ispec=0; ispec +//End_Html +// + const AliTRDPIDResponse *pidResponse = AliTRDcalibDB::Instance()->GetPIDResponse(fkReconstructor->GetRecoParam()->GetPIDmethod()); + if(!pidResponse){ + AliError("PID Response not available"); + return kFALSE; } - fPIDquality = 0; - - // steer PID calculation @ tracklet level - Double_t *prob = 0x0; - for(int ip=0; ipIsOK()) continue; - if(!(prob = fTracklet[ip]->GetProbability())) return kFALSE; - - Int_t nspec = 0; // quality check of tracklet dEdx - for(int ispec=0; ispecGetNumberOfSlices(); + 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]->SetPID(); + if(pidResponse->GetPIDmethod() == AliTRDPIDResponse::kLQ1D){ + dEdx[iseed] = fTracklet[iseed]->GetdQdl(); + } else { + fTracklet[iseed]->CookdEdx(nslices); + const Float_t *trackletdEdx = fTracklet[iseed]->GetdEdx(); + for(Int_t islice = 0; islice < nslices; islice++){ + dEdx[iseed*nslices + islice] = trackletdEdx[islice]; + } } - if(!nspec) continue; - - fPIDquality++; } - - // no tracklet found for PID calculations - if(!fPIDquality) return kTRUE; - - // slot for PID calculation @ track level - - - // normalize probabilities - Double_t probTotal = 0.0; - for (Int_t is = 0; is < AliPID::kSPECIES; is++) probTotal += fPID[is]; - - - if (probTotal <= 0.0) { - AliWarning("The total probability over all species <= 0. This may be caused by some error in the reference data."); - return kFALSE; + pidResponse->GetResponse(nslices, dEdx, trackletP, fPID); + + static Int_t nprint = 0; + if(!nprint){ + AliTRDdEdxUtils::PrintControl(); + nprint++; } - - for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) fPID[iSpecies] /= probTotal; - + + //do truncated mean + AliTRDdEdxUtils::SetObjPHQ(AliTRDcalibDB::Instance()->GetPHQ()); + const Double_t mag = AliTRDdEdxUtils::IsExBOn() ? GetBz() : -1; + const Double_t charge = AliTRDdEdxUtils::IsExBOn() ? Charge() : -1; + fTruncatedMean = CookTruncatedMean(0, mag, charge, kTRUE); + return kTRUE; } -//_____________________________________________________________________________ -Double_t AliTRDtrackV1::GetBz() const +//___________________________________________________________ +UChar_t AliTRDtrackV1::GetNumberOfTrackletsPID() const { - // - // Returns Bz component of the magnetic field (kG) - // +// Retrieve number of tracklets used for PID calculation. - if (AliTracker::UniformField()) return AliTracker::GetBz(); + UChar_t nPID = 0; + for(int ip=0; ipIsOK()) continue; + + nPID++; + } + return nPID; +} - Double_t r[3]; - GetXYZ(r); - return AliTracker::GetBz(r); +//_______________________________________________________________ +AliTRDcluster* AliTRDtrackV1::GetCluster(Int_t id) +{ + // Get the cluster at a certain position in the track + Int_t n = 0; + for(Int_t ip=0; ipGetN() <= 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); } } @@ -341,48 +461,149 @@ 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); + 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]; + 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; } //_____________________________________________________________________________ -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]->GetTBoccupancy()/AliTRDseedV1::kNtb; + 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 - // 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; @@ -399,51 +620,41 @@ 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 (TMath::Abs(xk - GetX()) x1[%6.2f] dx[%6.2f] rho[%f]\n", xyz0[0], xyz1[0], xyz0[0]-xk, xrho/TMath::Abs(xyz0[0]-xk)); + 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[2]); 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, fMass)) return kFALSE; - if (!AliExternalTrackParam::CorrectForMeanMaterial(xx0,xrho,GetMass())) { - return kFALSE; - } { // Energy losses Double_t p2 = (1.0 + GetTgl()*GetTgl()) / (GetSigned1Pt()*GetSigned1Pt()); - Double_t beta2 = p2 / (p2 + GetMass()*GetMass()); + Double_t beta2 = p2 / (p2 + fMass*fMass); if ((beta2 < 1.0e-10) || ((5940.0 * beta2/(1.0 - beta2 + 1.0e-10) - beta2) < 0.0)) { return kFALSE; @@ -466,7 +677,7 @@ Bool_t AliTRDtrackV1::PropagateTo(Double_t xk, Double_t xx0, Double_t xrho) /* // Suspicious ! I.B. Double_t sigmade = 0.07 * TMath::Sqrt(TMath::Abs(dE)); // Energy loss fluctuation - Double_t sigmac2 = sigmade*sigmade*fC*fC*(p2+GetMass()*GetMass())/(p2*p2); + Double_t sigmac2 = sigmade*sigmade*fC*fC*(p2+fMass*fMass)/(p2*p2); fCcc += sigmac2; fCee += fX*fX * sigmac2; */ @@ -499,12 +710,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; } @@ -516,12 +727,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; @@ -532,6 +743,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) { @@ -554,7 +798,7 @@ void AliTRDtrackV1::SetNumberOfClusters() Int_t ncls = 0; for(int ip=0; ipGetN(); + if(fTracklet[ip] && fTrackletIndex[ip] >= 0) ncls += fTracklet[ip]->GetN(); } AliKalmanTrack::SetNumberOfClusters(ncls); } @@ -567,58 +811,69 @@ void AliTRDtrackV1::SetOwner() // Toggle ownership of tracklets // - if(TestBit(1)) return; + 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(); } - SetBit(1); + SetBit(kOwner); } //_______________________________________________________________ -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::SetTrackIn() { - // - // Update track and tracklet parameters - // - - Double_t x = trklt->GetX0(); - Double_t p[2] = { trklt->GetYat(x) - , trklt->GetZat(x) }; - Double_t cov[3]; - trklt->GetCovAt(x, cov); - - 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()); - return kTRUE; +// Save location of birth for the TRD track +// If the pointer is not valid allocate memory +// + const AliExternalTrackParam *op = dynamic_cast(this); + + //printf("SetTrackIn() : fTrackLow[%p]\n", (void*)fTrackLow); + if(fTrackLow){ + fTrackLow->~AliExternalTrackParam(); + new(fTrackLow) AliExternalTrackParam(*op); + } else fTrackLow = new 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); + if(fTrackHigh){ + fTrackHigh->~AliExternalTrackParam(); + new(fTrackHigh) AliExternalTrackParam(*op); + } else fTrackHigh = new AliExternalTrackParam(*op); +} + +//_______________________________________________________________ +void AliTRDtrackV1::UnsetTracklet(Int_t plane) +{ + if(plane<0) return; + fTrackletIndex[plane] = -1; + fTracklet[plane] = NULL; +} + + +//_______________________________________________________________ +void AliTRDtrackV1::UpdateChi2(Float_t chi2) +{ +// Update chi2/track with one tracklet contribution + SetChi2(GetChi2() + chi2); } //_______________________________________________________________ @@ -628,16 +883,75 @@ void AliTRDtrackV1::UpdateESDtrack(AliESDtrack *track) // Update the TRD PID information in the ESD track // - track->SetNumberOfTRDslices(kNslice); - +// 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 + 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((AliTRDPIDResponse::kNslicesNN+3)*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(fTrackletIndex[ip]<0 || !fTracklet[ip]) continue; + if(!fTracklet[ip]->HasPID()) continue; + fTracklet[ip]->CookdEdx(AliTRDPIDResponse::kNslicesNN); + const Float_t *dedx = fTracklet[ip]->GetdEdx(); + for (Int_t js = 0; js < AliTRDPIDResponse::kNslicesNN; js++, dedx++){ + track->SetTRDslice(*dedx, ip, js+1); + } + p = fTracklet[ip]->GetMomentum(&sp); + spd = sp; track->SetTRDmomentum(p, ip, &spd); + // store global quality per tracklet instead of momentum error + // 26.09.11 A.Bercuci + // first implementation store no. of time bins filled in tracklet (5bits see "y" bits) and + // no. of double clusters in case of pad row cross (4bits see "x" bits) + // bit map for tracklet quality xxxxyyyyy + // 27.10.11 A.Bercuci + // add chamber status bit "z" bit + // bit map for tracklet quality zxxxxyyyyy + // 12.11.11 A.Bercuci + // fit tracklet quality into the field fTRDTimeBin [Char_t] + // bit map for tracklet quality zxxyyyyy + // The information should be retrieved by the following functions of AliESDtrack for each TRD layer + // GetTRDtrkltOccupancy(layer) -> no of TB filled in tracklet + // GetTRDtrkltClCross(layer) -> no of TB filled in crossing pad rows + // IsTRDtrkltChmbGood(layer) -> status of the chamber from which the tracklet is found + Int_t nCross(fTracklet[ip]->IsRowCross()?fTracklet[ip]->GetTBcross():0); if(nCross>3) nCross = 3; + Char_t trackletQ = Char_t(fTracklet[ip]->GetTBoccupancy() | (nCross<<5) | (fTracklet[ip]->IsChmbGood()<<7)); + track->SetTRDTimBin(trackletQ, ip); + track->SetTRDslice(fTracklet[ip]->GetdQdl(), ip, 0); // Set Summed dEdx into the first slice } - - // copy PID to ESD + // store PID probabilities track->SetTRDpid(fPID); - track->SetTRDpidQuality(fPIDquality); + + //store truncated mean + track->SetTRDsignal(fTruncatedMean); +} + +//_______________________________________________________________ +Double_t AliTRDtrackV1::CookTruncatedMean(const Bool_t kinvq, const Double_t mag, const Int_t charge, const Int_t kcalib, TVectorD *Qs, TVectorD *Xs, Int_t timeBin0, Int_t timeBin1, Int_t tstep) const +{ + // + //Origin: Xianguo Lu , Marian Ivanov + // + + TVectorD arrayQ(200), arrayX(200); + Int_t ncls = AliTRDdEdxUtils::GetArrayClusterQ(kinvq, &arrayQ, &arrayX, this, timeBin0, timeBin1, tstep); + + const TObjArray *cobj = kcalib ? AliTRDdEdxUtils::GetObjPHQ(kinvq, mag, charge) : NULL; + + const Double_t tmean = AliTRDdEdxUtils::ToyCook(kinvq, ncls, &arrayQ, &arrayX, cobj); + + const Int_t nch = AliTRDdEdxUtils::UpdateArrayX(ncls, &arrayX); + + if(Qs && Xs){ + (*Qs)=arrayQ; + (*Xs)=arrayX; + } + + return AliTRDdEdxUtils::GetSignal(nch, ncls, tmean); } +