+ // Get the seeds in sorted sequence
+ AliESDtrack *seed = event->GetTrack(index[iSeed]);
+ fHBackfit->Fill(0); // All seeds
+
+ // Check the seed status
+ ULong_t status = seed->GetStatus();
+ if ((status & AliESDtrack::kTPCout) == 0) {
+ fHBackfit->Fill(1); // TPC outer edge reached
+ continue;
+ }
+ if ((status & AliESDtrack::kTRDout) != 0) {
+ fHBackfit->Fill(2); // TRD outer edge reached (does this happen ?)
+ continue;
+ }
+
+ // Do the back prolongation
+ Int_t lbl = seed->GetLabel();
+ AliTRDtrack *track = new AliTRDtrack(*seed);
+ track->SetSeedLabel(lbl);
+ seed->UpdateTrackParams(track,AliESDtrack::kTRDbackup); // Make backup
+ fNseeds++;
+ Float_t p4 = track->GetC();
+ Int_t expectedClr = FollowBackProlongation(*track);
+ fHBackfit->Fill(3); // Back prolongation done
+ fHX->Fill(track->GetX());
+
+ if ((TMath::Abs(track->GetC() - p4) / TMath::Abs(p4) < 0.2) ||
+ (track->Pt() > 0.8)) {
+
+ fHBackfit->Fill(4);
+
+ //
+ // Make backup for back propagation
+ //
+
+ Int_t foundClr = track->GetNumberOfClusters();
+ if (foundClr >= foundMin) {
+ track->CookdEdx();
+ track->CookdEdxTimBin(seed->GetID()); // A.Bercuci 25.07.07
+ CookLabel(track,1 - fgkLabelFraction);
+ if (track->GetBackupTrack()) UseClusters(track->GetBackupTrack());
+
+
+ // Sign only gold tracks
+ if (track->GetChi2() / track->GetNumberOfClusters() < 4) {
+ if ((seed->GetKinkIndex(0) == 0) &&
+ (track->Pt() < 1.5)) {
+ UseClusters(track);
+ }
+ }
+ Bool_t isGold = kFALSE;
+
+ // Full gold track
+ if (track->GetChi2() / track->GetNumberOfClusters() < 5) {
+ //seed->UpdateTrackParams(track, AliESDtrack::kTRDbackup);
+ if (track->GetBackupTrack()) {
+ seed->UpdateTrackParams(track->GetBackupTrack(),AliESDtrack::kTRDbackup);
+ }
+ isGold = kTRUE;
+ //fHBackfit->Fill()
+ }
+
+ // Almost gold track
+ if ((!isGold) && (track->GetNCross() == 0) &&
+ (track->GetChi2() / track->GetNumberOfClusters() < 7)) {
+ //seed->UpdateTrackParams(track, AliESDtrack::kTRDbackup);
+ if (track->GetBackupTrack()) {
+ seed->UpdateTrackParams(track->GetBackupTrack(),AliESDtrack::kTRDbackup);
+ }
+ isGold = kTRUE;
+ }
+
+ if ((!isGold) && (track->GetBackupTrack())) {
+ if ((track->GetBackupTrack()->GetNumberOfClusters() > foundMin) && ((track->GetBackupTrack()->GetChi2()/(track->GetBackupTrack()->GetNumberOfClusters()+1)) < 7)) {
+ seed->UpdateTrackParams(track->GetBackupTrack(),AliESDtrack::kTRDbackup);
+ isGold = kTRUE;
+ }
+ }
+
+ if ((track->StatusForTOF() > 0) && (track->GetNCross() == 0) && (Float_t(track->GetNumberOfClusters()) / Float_t(track->GetNExpected()) > 0.4)) {
+ //seed->UpdateTrackParams(track->GetBackupTrack(), AliESDtrack::kTRDbackup);
+ }
+ }
+ }
+ /**/
+
+ /**/
+ // Debug part of tracking
+ TTreeSRedirector &cstream = *fDebugStreamer;
+ Int_t eventNrInFile = event->GetEventNumberInFile(); // This is most likely NOT the event number you'd like to use. It has nothing to do with the 'real' event number.
+ if (fReconstructor->GetStreamLevel(AliTRDReconstructor::kTracker) > 0) {
+ if (track->GetBackupTrack()) {
+ cstream << "Tracks"
+ << "EventNrInFile=" << eventNrInFile
+ << "ESD.=" << seed
+ << "trd.=" << track
+ << "trdback.=" << track->GetBackupTrack()
+ << "\n";
+ }
+ else {
+ cstream << "Tracks"
+ << "EventNrInFile=" << eventNrInFile
+ << "ESD.=" << seed
+ << "trd.=" << track
+ << "trdback.=" << track
+ << "\n";
+ }
+ }
+ /**/
+
+ // Propagation to the TOF (I.Belikov)
+ if (track->GetStop() == kFALSE) {
+ fHBackfit->Fill(5);
+
+ Double_t xtof = 371.0;
+ Double_t xTOF0 = 370.0;
+
+ Double_t c2 = track->GetSnp() + track->GetC() * (xtof - track->GetX());
+ if (TMath::Abs(c2) >= 0.99) {
+ fHBackfit->Fill(6);
+ delete track;
+ continue;
+ }
+
+ PropagateToX(*track,xTOF0,fgkMaxStep);
+
+ // Energy losses taken to the account - check one more time
+ c2 = track->GetSnp() + track->GetC() * (xtof - track->GetX());
+ if (TMath::Abs(c2) >= 0.99) {
+ fHBackfit->Fill(7);
+ delete track;
+ continue;
+ }
+
+ //if (!PropagateToX(*track,xTOF0,fgkMaxStep)) {
+ // fHBackfit->Fill(7);
+ //delete track;
+ // continue;
+ //}
+
+ Double_t ymax = xtof * TMath::Tan(0.5 * AliTRDgeometry::GetAlpha());
+ Double_t y;
+ track->GetYAt(xtof,GetBz(),y);
+ if (y > ymax) {
+ if (!track->Rotate( AliTRDgeometry::GetAlpha())) {
+ fHBackfit->Fill(8);
+ delete track;
+ continue;
+ }
+ }
+ else if (y < -ymax) {
+ if (!track->Rotate(-AliTRDgeometry::GetAlpha())) {
+ fHBackfit->Fill(9);
+ delete track;
+ continue;
+ }
+ }
+
+ if (track->PropagateTo(xtof)) {
+ seed->UpdateTrackParams(track,AliESDtrack::kTRDout);
+ fHBackfit->Fill(10);
+
+ seed->SetNumberOfTRDslices(AliTRDCalPID::kNSlicesLQ);
+ for (Int_t i = 0; i < AliTRDtrack::kNplane; i++) {
+ for (Int_t j = 0; j < AliTRDCalPID::kNSlicesLQ; j++) {
+ seed->SetTRDslice(track->GetPIDsignals(i,j),i,j);
+ }
+ seed->SetTRDTimBin(track->GetPIDTimBin(i),i);
+ }
+ //seed->SetTRDtrack(new AliTRDtrack(*track));
+ if (track->GetNumberOfClusters() > foundMin) {
+ fHBackfit->Fill(11);
+ found++;
+ }
+ }
+ }
+ else {
+ fHBackfit->Fill(12);
+
+ if ((track->GetNumberOfClusters() > 15) &&
+ (track->GetNumberOfClusters() > 0.5*expectedClr)) {
+ seed->UpdateTrackParams(track,AliESDtrack::kTRDout);
+ fHBackfit->Fill(13);
+
+ //seed->SetStatus(AliESDtrack::kTRDStop);
+
+ seed->SetNumberOfTRDslices(AliTRDCalPID::kNSlicesLQ);
+ for (Int_t i = 0; i < AliTRDtrack::kNplane; i++) {
+ for (Int_t j = 0; j <AliTRDCalPID::kNSlicesLQ; j++) {
+ seed->SetTRDslice(track->GetPIDsignals(i,j),i,j);
+ }
+ seed->SetTRDTimBin(track->GetPIDTimBin(i),i);
+ }
+ //seed->SetTRDtrack(new AliTRDtrack(*track));
+ found++;
+ }
+ }
+
+ seed->SetTRDQuality(track->StatusForTOF());
+ seed->SetTRDBudget(track->GetBudget(0));
+
+ fHBackfit->Fill(14);
+ delete track;