Index: modules/CMakeLists.txt
===================================================================
--- modules/CMakeLists.txt	(revision f08ddc6503c00edb79fe7475e2e4861275520bef)
+++ modules/CMakeLists.txt	(revision f0fd18a3edd611423e3c194102dc411219d37c70)
@@ -19,8 +19,6 @@
 add_library(modules OBJECT ${sources} FastJetDict.cxx ModulesDict.cxx)
 
-# install public headers
-install(FILES Delphes.h
-        DESTINATION include/modules
-)
+# install headers
+install(FILES ${headers} DESTINATION include/modules)
 
 # install pcms if they are created
Index: modules/RunPUPPI.cc
===================================================================
--- modules/RunPUPPI.cc	(revision f08ddc6503c00edb79fe7475e2e4861275520bef)
+++ modules/RunPUPPI.cc	(revision f0fd18a3edd611423e3c194102dc411219d37c70)
@@ -166,5 +166,4 @@
   Candidate *pv = static_cast<Candidate*>(fPVItInputArray->Next());
   if (pv) PVZ = pv->Position.Z();
-
   // Fill input particles for puppi
   std::vector<RecoObj> puppiInputVector;
@@ -179,6 +178,5 @@
       curRecoObj.phi = momentum.Phi();
       curRecoObj.m   = momentum.M();  
-      particle = static_cast<Candidate*>(candidate->GetCandidates()->Last());
-      //if(fApplyNoLep && TMath::Abs(candidate->PID) == 11) continue; //Dumb cut to minimize the nolepton on electron
+      particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));//if(fApplyNoLep && TMath::Abs(candidate->PID) == 11) continue; //Dumb cut to minimize the nolepton on electron
       //if(fApplyNoLep && TMath::Abs(candidate->PID) == 13) continue;
       if (candidate->IsRecoPU and candidate->Charge !=0) { // if it comes fromPU vertexes after the resolution smearing and the dZ matching within resolution
@@ -192,5 +190,5 @@
         curRecoObj.dZ = particle->Position.Z()-PVZ;
       } 
-      else if(!candidate->IsRecoPU and candidate->Charge !=0) {
+      else if(!candidate->IsRecoPU && candidate->Charge !=0) {
 	curRecoObj.id    = 1;  // charge from LV
         curRecoObj.vtxId = 1; // from PV
@@ -219,6 +217,5 @@
       curRecoObj.m   = momentum.M();
       curRecoObj.charge = 0;
-      particle = static_cast<Candidate*>(candidate->GetCandidates()->Last());
-
+      particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
       if(candidate->Charge == 0){
 	curRecoObj.id    = 0; // neutrals have id==0
Index: modules/TrackPileUpSubtractor.cc
===================================================================
--- modules/TrackPileUpSubtractor.cc	(revision f08ddc6503c00edb79fe7475e2e4861275520bef)
+++ modules/TrackPileUpSubtractor.cc	(revision f0fd18a3edd611423e3c194102dc411219d37c70)
@@ -53,6 +53,8 @@
 //------------------------------------------------------------------------------
 
-TrackPileUpSubtractor::TrackPileUpSubtractor()
+TrackPileUpSubtractor::TrackPileUpSubtractor() :
+fFormula(0) 
 {
+  fFormula = new DelphesFormula;
 }
 
@@ -61,4 +63,5 @@
 TrackPileUpSubtractor::~TrackPileUpSubtractor()
 {
+  if(fFormula) delete fFormula;
 }
 
@@ -72,5 +75,6 @@
   fItVertexInputArray = fVertexInputArray->MakeIterator();
 
-  fZVertexResolution  = GetDouble("ZVertexResolution", 0.005)*1.0E3;
+  // read resolution formula in m
+  fFormula->Compile(GetString("ZVertexResolution", "0.001"));
 
   fPTMin = GetDouble("PTMin", 0.);
@@ -119,4 +123,5 @@
   TObjArray *array;
   Double_t z, zvtx=0;
+  Double_t pt, eta, phi, e;
 
 
@@ -144,4 +149,11 @@
     {
       particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
+      const TLorentzVector &candidateMomentum = particle->Momentum;
+
+      eta = candidateMomentum.Eta();
+      pt = candidateMomentum.Pt();
+      phi = candidateMomentum.Phi();
+      e = candidateMomentum.E();
+      
       z = particle->Position.Z();
 
@@ -149,5 +161,5 @@
       // assume perfect pile-up subtraction for tracks outside fZVertexResolution
 
-      if(candidate->IsPU && TMath::Abs(z-zvtx) > fZVertexResolution)
+      if(candidate->Charge !=0 && TMath::Abs(z-zvtx) > fFormula->Eval(pt, eta, phi, e)* 1.0e3)
       {
         candidate->IsRecoPU = 1;
@@ -161,4 +173,2 @@
   }
 }
-
-//------------------------------------------------------------------------------
Index: modules/TrackPileUpSubtractor.h
===================================================================
--- modules/TrackPileUpSubtractor.h	(revision f08ddc6503c00edb79fe7475e2e4861275520bef)
+++ modules/TrackPileUpSubtractor.h	(revision f0fd18a3edd611423e3c194102dc411219d37c70)
@@ -34,4 +34,5 @@
 class TIterator;
 class TObjArray;
+class DelphesFormula;
 
 class TrackPileUpSubtractor: public DelphesModule
@@ -48,5 +49,5 @@
 private:
 
-  Double_t fZVertexResolution;
+  DelphesFormula *fFormula; //!
 
   Double_t fPTMin;
