Index: modules/DenseTrackFilter.cc
===================================================================
--- modules/DenseTrackFilter.cc	(revision 5b51d33750bc7415d4ede53ce13067db637a5a11)
+++ modules/DenseTrackFilter.cc	(revision ec37bc3202fb17e911b9602b03a7044a2e62d42f)
@@ -54,5 +54,5 @@
 
 DenseTrackFilter::DenseTrackFilter() :
-  fItTrackInputArray(0),   fItDenseChargedInputArray(0)
+  fItTrackInputArray(0)
 {
 }
@@ -116,8 +116,8 @@
   fItTrackInputArray = fTrackInputArray->MakeIterator();
 
-  fDenseChargedInputArray = ImportArray(GetString("DenseChargedInputArray", "DenseMergeTracks/tracks"));
-  fItDenseChargedInputArray = fDenseChargedInputArray->MakeIterator();
-
   fTrackOutputArray = ExportArray(GetString("TrackOutputArray", "tracks"));
+  fChargedHadronOutputArray = ExportArray(GetString("ChargedHadronOutputArray", "chargedHadrons"));
+  fElectronOutputArray = ExportArray(GetString("ElectronOutputArray", "electrons"));
+  fMuonOutputArray = ExportArray(GetString("MuonOutputArray", "muons"));
 }
 
@@ -128,5 +128,4 @@
   vector< vector< Double_t >* >::iterator itPhiBin;
   if(fItTrackInputArray) delete fItTrackInputArray;
-  if(fItDenseChargedInputArray) delete fItDenseChargedInputArray;
   for(itPhiBin = fPhiBins.begin(); itPhiBin != fPhiBins.end(); ++itPhiBin)
   {
@@ -155,7 +154,7 @@
 
   // loop over all tracks
-  fItDenseChargedInputArray->Reset();
+  fItTrackInputArray->Reset();
   number = -1;
-  while((track = static_cast<Candidate*>(fItDenseChargedInputArray->Next())))
+  while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
   {
     const TLorentzVector &trackPosition = track->Position;
@@ -217,5 +216,5 @@
     {
       ++fTowerTrackHits;
-      track = static_cast<Candidate*>(fDenseChargedInputArray->At(number));
+      track = static_cast<Candidate*>(fTrackInputArray->At(number));
       momentum = track->Momentum;
 
@@ -244,19 +243,42 @@
   Int_t numberOfCandidates;
 
-  numberOfCandidates = fBestTrack->GetCandidates()->GetEntriesFast();
-
+  
+  cout<<fBestTrack<<endl;
+  
   // saving track with highest pT that hit the tower
-  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);
-  }
-}
+  if(fTowerTrackHits > 0) 
+  {
+    
+    numberOfCandidates = fBestTrack->GetCandidates()->GetEntriesFast();
+    if (numberOfCandidates < 2)
+       cout<<fBestTrack<<endl;
+
+    if (numberOfCandidates > 1)
+    {  
+
+      track = static_cast<Candidate*>(fBestTrack->GetCandidates()->At(numberOfCandidates - 1));
+      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);
+      switch(TMath::Abs(candidate->PID))
+      {
+        case 11:
+          fElectronOutputArray->Add(candidate);
+          break;
+        case 13:
+          fMuonOutputArray->Add(candidate);
+          break;
+        default:
+          fChargedHadronOutputArray->Add(candidate);
+      }
+ 
+    }
+  }
+
+}
Index: modules/DenseTrackFilter.h
===================================================================
--- modules/DenseTrackFilter.h	(revision 5b51d33750bc7415d4ede53ce13067db637a5a11)
+++ modules/DenseTrackFilter.h	(revision ec37bc3202fb17e911b9602b03a7044a2e62d42f)
@@ -69,11 +69,10 @@
 
   const TObjArray *fTrackInputArray; //!
-
   TObjArray *fTrackOutputArray; //!
 
+  TObjArray *fChargedHadronOutputArray; //!
+  TObjArray *fElectronOutputArray; //!
+  TObjArray *fMuonOutputArray; //!
 
-  const TObjArray *fDenseChargedInputArray;
-  TIterator *fItDenseChargedInputArray;
-  
   void FillTrack();
   ClassDef(DenseTrackFilter, 1)
