Index: modules/DenseTrackFilter.cc
===================================================================
--- modules/DenseTrackFilter.cc	(revision e999d62eae6804f9175b97704fb24be9c1958b17)
+++ modules/DenseTrackFilter.cc	(revision 4170544648e42c82513e559c4dc5dd14656e410a)
@@ -111,7 +111,7 @@
 
   // Eta x Phi smearing to be applied
-  fEtaPhiRes = GetDouble("EtaPhiRes", 0.005);
-
-  fTrackInputArray = ImportArray(GetString("TrackInputArray", "TrackMerger/tracks"));
+  fEtaPhiRes = GetDouble("EtaPhiRes", 0.003);
+
+  fTrackInputArray = ImportArray(GetString("TrackInputArray", "TrackMergerProp/tracks"));
   fItTrackInputArray = fTrackInputArray->MakeIterator();
 
@@ -139,12 +139,10 @@
 void DenseTrackFilter::Process()
 {
-  Candidate *candidate, *track, *bestTrack, *mother, *trackRef, *bestTrackRef;
+  Candidate *track;
   TLorentzVector position, momentum;
   Short_t etaBin, phiBin, flags;
-  Int_t number, towerTrackHits;
+  Int_t number;
   Long64_t towerHit, towerEtaPhi, hitEtaPhi;
-
-  Double_t pt, ptmax, eta, phi;
-  Bool_t matched;
+  Double_t ptmax;
 
   vector< Double_t >::iterator itEtaBin;
@@ -191,8 +189,7 @@
   // loop over all hits
   towerEtaPhi = 0;
-  bestTrack = 0;
-  fTower = 0;
+  fBestTrack = 0;
   ptmax = 0.0;
-  towerTrackHits = 0;
+  fTowerTrackHits = 0;
 
   for(itTowerHits = fTowerHits.begin(); itTowerHits != fTowerHits.end(); ++itTowerHits)
@@ -202,47 +199,16 @@
     number = (towerHit) & 0x0000000000FFFFFFLL;
     hitEtaPhi = towerHit >> 32;
+
     if(towerEtaPhi != hitEtaPhi)
     {
       // switch to next tower
       towerEtaPhi = hitEtaPhi;
-      
+     
       // saving track with highest pT that hit the tower
-      if(towerTrackHits > 0)
-      {
-         bestTrackRef = static_cast<Candidate*>(bestTrack->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;
-	 }
-         
-         // find track 
-      }
+      FillTrack();
 
       ptmax = 0.0;
-      towerTrackHits = 0;
-      bestTrack = 0;
+      fTowerTrackHits = 0;
+      fBestTrack = 0;
     }
     // check for track hits
@@ -250,5 +216,5 @@
     if(flags & 1)
     {
-      ++towerTrackHits;
+      ++fTowerTrackHits;
       track = static_cast<Candidate*>(fDenseChargedInputArray->At(number));
       momentum = track->Momentum;
@@ -256,10 +222,60 @@
       if (momentum.Pt() > ptmax) 
       {
-        ptmax = momentum.Pt();
-        bestTrack = track;
+	ptmax = momentum.Pt();
+        fBestTrack = track;
       }
       continue;
     }
-  }
-  
-}
+  
+  }
+  
+  // here fill last tower
+  FillTrack();
+  
+}
+
+
+
+//------------------------------------------------------------------------------
+
+void DenseTrackFilter::FillTrack()
+{
+  
+  Candidate *candidate, *track, *mother, *trackRef, *bestTrackRef;
+  Double_t pt, eta, phi;
+  Bool_t matched;
+  
+  // 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;
+     }
+  } 
+
+
+}
Index: modules/DenseTrackFilter.h
===================================================================
--- modules/DenseTrackFilter.h	(revision e999d62eae6804f9175b97704fb24be9c1958b17)
+++ modules/DenseTrackFilter.h	(revision 4170544648e42c82513e559c4dc5dd14656e410a)
@@ -53,5 +53,7 @@
   typedef std::map< Double_t, std::set< Double_t > > TBinMap; //!
 
-  Candidate *fTower;
+  Candidate *fBestTrack;
+
+  Int_t fTowerTrackHits;
 
   Double_t fEtaPhiRes;
@@ -73,5 +75,6 @@
   const TObjArray *fDenseChargedInputArray;
   TIterator *fItDenseChargedInputArray;
-
+  
+  void FillTrack();
   ClassDef(DenseTrackFilter, 1)
 };
