Index: modules/ModulesLinkDef.h
===================================================================
--- modules/ModulesLinkDef.h	(revision 952bbbc7286306d2ddf56ea40238864f152dbd7a)
+++ modules/ModulesLinkDef.h	(revision 5862d1fa07d0f47f91791bc8ab5ef06774495194)
@@ -76,4 +76,5 @@
 #include "modules/DecayFilter.h"
 #include "modules/ParticleDensity.h"
+#include "modules/TruthVertexFinder.h"
 #include "modules/ExampleModule.h"
 
@@ -134,4 +135,5 @@
 #pragma link C++ class DecayFilter+;
 #pragma link C++ class ParticleDensity+;
+#pragma link C++ class TruthVertexFinder+;
 #pragma link C++ class ExampleModule+;
 
Index: modules/TruthVertexFinder.cc
===================================================================
--- modules/TruthVertexFinder.cc	(revision 5862d1fa07d0f47f91791bc8ab5ef06774495194)
+++ modules/TruthVertexFinder.cc	(revision 5862d1fa07d0f47f91791bc8ab5ef06774495194)
@@ -0,0 +1,157 @@
+/*
+ *  Delphes: a framework for fast simulation of a generic collider experiment
+ *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** \class TruthVertexFinder
+ *
+ *  Merges particles from pile-up sample into event
+ *
+ *  \author M. Selvaggi - UCL, Louvain-la-Neuve
+ *
+ */
+
+#include "modules/TruthVertexFinder.h"
+
+#include "classes/DelphesClasses.h"
+#include "classes/DelphesFactory.h"
+#include "classes/DelphesPileUpReader.h"
+#include "classes/DelphesTF2.h"
+
+#include "ExRootAnalysis/ExRootClassifier.h"
+#include "ExRootAnalysis/ExRootFilter.h"
+#include "ExRootAnalysis/ExRootResult.h"
+
+#include "TDatabasePDG.h"
+#include "TFormula.h"
+#include "TLorentzVector.h"
+#include "TMath.h"
+#include "TObjArray.h"
+#include "TRandom3.h"
+#include "TString.h"
+
+#include <algorithm>
+#include <iostream>
+#include <sstream>
+#include <stdexcept>
+
+using namespace std;
+
+//------------------------------------------------------------------------------
+
+TruthVertexFinder::TruthVertexFinder() :
+fItInputArray(0), fItOutputArray(0)
+{
+}
+
+//------------------------------------------------------------------------------
+
+TruthVertexFinder::~TruthVertexFinder()
+{
+}
+
+//------------------------------------------------------------------------------
+
+void TruthVertexFinder::Init()
+{
+
+  fResolution = GetDouble("Resolution", 1E-06); // resolution in meters
+  // import input array
+  fInputArray = ImportArray(GetString("InputArray", "Delphes/stableParticles"));
+  fItInputArray = fInputArray->MakeIterator();
+
+  // create output arrays
+  fVertexOutputArray = ExportArray(GetString("VertexOutputArray", "vertices"));
+  //fItOutputArray = fVertexOutputArray->MakeIterator();
+}
+
+//------------------------------------------------------------------------------
+
+void TruthVertexFinder::Finish()
+{
+  if(fItInputArray) delete fItInputArray;
+  if(fItOutputArray) delete fItOutputArray;
+}
+
+//------------------------------------------------------------------------------
+
+void TruthVertexFinder::Process()
+{
+  Int_t nvtx = -1;
+  Float_t pt;
+  Candidate *candidate, *vertex;
+  DelphesFactory *factory;
+
+
+  fItInputArray->Reset();
+
+  factory = GetFactory();
+  vertex = factory->NewCandidate();
+
+  TLorentzVector vertexPosition(0., 0., 0., 0.);
+
+  nvtx=0;
+  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
+  {
+
+     const TLorentzVector &candidatePosition = candidate->Position;
+     const TLorentzVector &candidateMomentum = candidate->Momentum;
+
+     pt = candidateMomentum.Pt();
+     // check whether vertex already included, if so add particle
+     Bool_t old_vertex=false;
+     fItOutputArray = fVertexOutputArray->MakeIterator();
+     fItOutputArray->Reset();
+     while((vertex = static_cast<Candidate *>(fItOutputArray->Next())))
+     {
+        const TLorentzVector &vertexPosition = vertex->Position;
+        // check whether spatial difference is < 1 um, in that case assume it is the same vertex
+        if ( TMath::Abs((candidatePosition.P() - vertexPosition.P())) < fResolution*1.E3)
+        {
+           old_vertex=true;
+           vertex->AddCandidate(candidate);
+           if (TMath::Abs(candidate->Charge) > 0)
+           {
+              vertex->ClusterNDF += 1;
+              vertex->GenSumPT2 += pt*pt;
+           }
+        }
+     }
+
+     // else fill new vertex
+     if (!old_vertex)
+     {
+        vertex = factory->NewCandidate();
+        vertex->Position = candidatePosition;
+        vertex->ClusterIndex = nvtx;
+
+        if (TMath::Abs(candidate->Charge) > 0)
+        {
+           vertex->ClusterNDF = 1;
+           vertex->GenSumPT2 = pt*pt;
+        }
+        else
+        {
+           vertex->ClusterNDF = 0;
+           vertex->GenSumPT2 = 0.;
+        }
+        fVertexOutputArray->Add(vertex);
+        nvtx++;
+      }
+   }
+}
+
+//------------------------------------------------------------------------------
Index: modules/TruthVertexFinder.h
===================================================================
--- modules/TruthVertexFinder.h	(revision 5862d1fa07d0f47f91791bc8ab5ef06774495194)
+++ modules/TruthVertexFinder.h	(revision 5862d1fa07d0f47f91791bc8ab5ef06774495194)
@@ -0,0 +1,57 @@
+/*
+ *  Delphes: a framework for fast simulation of a generic collider experiment
+ *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef TruthVertexFinder_h
+#define TruthVertexFinder_h
+
+/** \class TruthVertexFinder
+ *
+ *  Produces list of MC truth vertices
+ *
+ *  \author M. Selvaggi - CERN
+ *
+ */
+
+#include "classes/DelphesModule.h"
+
+class TObjArray;
+
+class TruthVertexFinder: public DelphesModule
+{
+public:
+  TruthVertexFinder();
+  ~TruthVertexFinder();
+
+  void Init();
+  void Process();
+  void Finish();
+
+private:
+
+  Double_t fResolution; //!
+
+  TIterator *fItInputArray; //!
+  TIterator *fItOutputArray; //!
+
+  const TObjArray *fInputArray; //!
+
+  TObjArray *fVertexOutputArray; //!
+  ClassDef(TruthVertexFinder, 1)
+};
+
+#endif
