Index: modules/DenseTrackFilter.cc
===================================================================
--- modules/DenseTrackFilter.cc	(revision 748ce0768b71857e7ae4a99de48fae37cd8ae427)
+++ modules/DenseTrackFilter.cc	(revision 60e1de658834b2e839df047a6102381cf52db758)
@@ -204,5 +204,5 @@
       // switch to next tower
       towerEtaPhi = hitEtaPhi;
-     
+
       // saving track with highest pT that hit the tower
       FillTrack();
@@ -213,5 +213,5 @@
     }
     // check for track hits
-    
+
     if(flags & 1)
     {
@@ -220,20 +220,18 @@
       momentum = track->Momentum;
 
-      if (momentum.Pt() > ptmax) 
+      if(momentum.Pt() > ptmax)
       {
-	ptmax = momentum.Pt();
+        ptmax = momentum.Pt();
         fBestTrack = track;
       }
       continue;
     }
-  
-  }
-  
+
+  }
+
   // here fill last tower
   FillTrack();
-  
-}
-
-
+
+}
 
 //------------------------------------------------------------------------------
@@ -241,41 +239,24 @@
 void DenseTrackFilter::FillTrack()
 {
-  
-  Candidate *candidate, *track, *mother, *trackRef, *bestTrackRef;
+
+  Candidate *candidate, *track;
   Double_t pt, eta, phi;
-  Bool_t matched;
-  
+  Int_t numberOfCandidates;
+
+  numberOfCandidates = fBestTrack->GetCandidates()->GetEntriesFast();
+
   // saving track with highest pT that hit the tower
-  if(fTowerTrackHits > 0)
-  {
-     bestTrackRef = static_cast<Candidate*>(fBestTrack->GetCandidates()->At(0));
-
-     // find corresponding track in properly propagated tracks
-     fItTrackInputArray->Reset();
-     matched = kFALSE;
-     int ntrack = 0;
-     while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
-     {
-       ntrack++;
-       trackRef = static_cast<Candidate*>(track->GetCandidates()->At(0));
-
-       if (trackRef->GetUniqueID() == bestTrackRef->GetUniqueID())
-       {
-	 mother = track;
-	 candidate = static_cast<Candidate*>(track->Clone());
-	 pt = candidate->Momentum.Pt();
-	 eta = candidate->Momentum.Eta();
-	 phi = candidate->Momentum.Phi();
-	 eta = gRandom->Gaus(eta, fEtaPhiRes);
-	 phi = gRandom->Gaus(phi, fEtaPhiRes);
-	 candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt*TMath::CosH(eta));
-	 candidate->AddCandidate(mother);
-	 fTrackOutputArray->Add(candidate);
-	 matched = kTRUE;
-       }
-       if (matched) break;
-     }
-  } 
-
-
-}
+  if(fTowerTrackHits > 0 && numberOfCandidates > 1)
+  {
+    track = static_cast<Candidate*>(fBestTrack->GetCandidates()->At(numberOfCandidates - 2));
+    candidate = static_cast<Candidate*>(track->Clone());
+    pt = candidate->Momentum.Pt();
+    eta = candidate->Momentum.Eta();
+    phi = candidate->Momentum.Phi();
+    eta = gRandom->Gaus(eta, fEtaPhiRes);
+    phi = gRandom->Gaus(phi, fEtaPhiRes);
+    candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt*TMath::CosH(eta));
+    candidate->AddCandidate(track);
+    fTrackOutputArray->Add(candidate);
+  }
+}
Index: modules/ParticlePropagator.cc
===================================================================
--- modules/ParticlePropagator.cc	(revision 748ce0768b71857e7ae4a99de48fae37cd8ae427)
+++ modules/ParticlePropagator.cc	(revision 60e1de658834b2e839df047a6102381cf52db758)
@@ -124,6 +124,6 @@
 void ParticlePropagator::Process()
 {
-  Candidate *candidate, *mother;
-  TLorentzVector candidatePosition, candidateMomentum, beamSpotPosition;
+  Candidate *candidate, *mother, *particle;
+  TLorentzVector particlePosition, particleMomentum, beamSpotPosition;
   Double_t px, py, pz, pt, pt2, e, q;
   Double_t x, y, z, t, r, phi;
@@ -151,9 +151,18 @@
   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
   {
-    candidatePosition = candidate->Position;
-    candidateMomentum = candidate->Momentum;
-    x = candidatePosition.X()*1.0E-3;
-    y = candidatePosition.Y()*1.0E-3;
-    z = candidatePosition.Z()*1.0E-3;
+    if(candidate->GetCandidates()->GetEntriesFast() == 0)
+    {
+      particle = candidate;
+    }
+    else
+    {
+      particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
+    }
+
+    particlePosition = particle->Position;
+    particleMomentum = particle->Momentum;
+    x = particlePosition.X()*1.0E-3;
+    y = particlePosition.Y()*1.0E-3;
+    z = particlePosition.Z()*1.0E-3;
 
     bsx = beamSpotPosition.X()*1.0E-3;
@@ -161,5 +170,5 @@
     bsz = beamSpotPosition.Z()*1.0E-3;
 
-    q = candidate->Charge;
+    q = particle->Charge;
 
     // check that particle position is inside the cylinder
@@ -169,10 +178,10 @@
     }
 
-    px = candidateMomentum.Px();
-    py = candidateMomentum.Py();
-    pz = candidateMomentum.Pz();
-    pt = candidateMomentum.Pt();
-    pt2 = candidateMomentum.Perp2();
-    e = candidateMomentum.E();
+    px = particleMomentum.Px();
+    py = particleMomentum.Py();
+    pz = particleMomentum.Pz();
+    pt = particleMomentum.Pt();
+    pt2 = particleMomentum.Perp2();
+    e = particleMomentum.E();
 
     if(pt2 < 1.0E-9)
@@ -186,9 +195,9 @@
       candidate = static_cast<Candidate*>(candidate->Clone());
 
-      candidate->InitialPosition = candidatePosition;
-      candidate->Position = candidatePosition;
+      candidate->InitialPosition = particlePosition;
+      candidate->Position = particlePosition;
       candidate->L = 0.0;
 
-      candidate->Momentum = candidateMomentum;
+      candidate->Momentum = particleMomentum;
       candidate->AddCandidate(mother);
 
@@ -230,9 +239,9 @@
       candidate = static_cast<Candidate*>(candidate->Clone());
 
-      candidate->InitialPosition = candidatePosition;
-      candidate->Position.SetXYZT(x_t*1.0E3, y_t*1.0E3, z_t*1.0E3, candidatePosition.T() + t*e*1.0E3);
+      candidate->InitialPosition = particlePosition;
+      candidate->Position.SetXYZT(x_t*1.0E3, y_t*1.0E3, z_t*1.0E3, particlePosition.T() + t*e*1.0E3);
       candidate->L = l*1.0E3;
 
-      candidate->Momentum = candidateMomentum;
+      candidate->Momentum = particleMomentum;
       candidate->AddCandidate(mother);
 
@@ -295,8 +304,8 @@
       px = TMath::Sign(1.0, r) * pt * (-y_c / r_c);
       py = TMath::Sign(1.0, r) * pt * (x_c / r_c);
-      etap = candidateMomentum.Eta();
+      etap = particleMomentum.Eta();
       phip = TMath::ATan2(py, px);
 
-      candidateMomentum.SetPtEtaPhiE(pt, etap, phip, candidateMomentum.E());
+      particleMomentum.SetPtEtaPhiE(pt, etap, phip, particleMomentum.E());
 
       // calculate additional track parameters (correct for beamspot position)
@@ -304,6 +313,6 @@
       d0        = ((x - bsx) * py - (y - bsy) * px) / pt;
       dz        = z - ((x - bsx) * px + (y - bsy) * py) / pt * (pz / pt);
-      p         = candidateMomentum.P();
-      ctgTheta  = 1.0 / TMath::Tan (candidateMomentum.Theta());
+      p         = particleMomentum.P();
+      ctgTheta  = 1.0 / TMath::Tan (particleMomentum.Theta());
 
 
@@ -363,18 +372,18 @@
 
         // store these variables before cloning
-        candidate->D0 = d0*1.0E3;
-        candidate->DZ = dz*1.0E3;
-        candidate->P  = p;
-        candidate->PT = pt;
-        candidate->CtgTheta = ctgTheta;
-        candidate->Phi = phip;
+        particle->D0 = d0*1.0E3;
+        particle->DZ = dz*1.0E3;
+        particle->P  = p;
+        particle->PT = pt;
+        particle->CtgTheta = ctgTheta;
+        particle->Phi = phip;
 
         mother = candidate;
         candidate = static_cast<Candidate*>(candidate->Clone());
 
-        candidate->InitialPosition = candidatePosition;
-        candidate->Position.SetXYZT(x_t*1.0E3, y_t*1.0E3, z_t*1.0E3, candidatePosition.T() + t*c_light*1.0E3);
-
-        candidate->Momentum = candidateMomentum;
+        candidate->InitialPosition = particlePosition;
+        candidate->Position.SetXYZT(x_t*1.0E3, y_t*1.0E3, z_t*1.0E3, particlePosition.T() + t*c_light*1.0E3);
+
+        candidate->Momentum = particleMomentum;
 
         candidate->L = l*1.0E3;
