Index: modules/ModulesLinkDef.h
===================================================================
--- modules/ModulesLinkDef.h	(revision 6c565ccdf8ede767e2a9de0d557bff060cfc1070)
+++ modules/ModulesLinkDef.h	(revision c41c262e7bf915328267ce0ade51a90bde8ae513)
@@ -37,4 +37,8 @@
 #include "modules/ExampleModule.h"
 
+#ifdef HAS_PYTHIA8
+#include "modules/PileUpMergerPythia8.h"
+#endif
+
 #ifdef __CINT__
 
@@ -68,3 +72,7 @@
 #pragma link C++ class ExampleModule+;
 
+#ifdef HAS_PYTHIA8
+#pragma link C++ class PileUpMergerPythia8+;
 #endif
+
+#endif
Index: modules/PileUpMergerPythia8.cc
===================================================================
--- modules/PileUpMergerPythia8.cc	(revision c41c262e7bf915328267ce0ade51a90bde8ae513)
+++ modules/PileUpMergerPythia8.cc	(revision c41c262e7bf915328267ce0ade51a90bde8ae513)
@@ -0,0 +1,158 @@
+/** \class PileUpMergerPythia8
+ *
+ *  Merges particles from pile-up sample into event
+ *
+ *
+ *  $Date$
+ *  $Revision$
+ *
+ *
+ *  \author P. Selvaggi - UCL, Louvain-la-Neuve
+ *
+ */
+
+#include "modules/PileUpMergerPythia8.h"
+
+#include "classes/DelphesClasses.h"
+#include "classes/DelphesFactory.h"
+#include "classes/DelphesFormula.h"
+#include "classes/DelphesPileUpReader.h"
+
+#include "ExRootAnalysis/ExRootResult.h"
+#include "ExRootAnalysis/ExRootFilter.h"
+#include "ExRootAnalysis/ExRootClassifier.h"
+
+#include "Pythia.h"
+
+#include "TMath.h"
+#include "TString.h"
+#include "TFormula.h"
+#include "TRandom3.h"
+#include "TObjArray.h"
+#include "TDatabasePDG.h"
+#include "TLorentzVector.h"
+
+#include <algorithm>
+#include <stdexcept>
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+//------------------------------------------------------------------------------
+
+PileUpMergerPythia8::PileUpMergerPythia8() :
+  fPythia(0), fItInputArray(0)
+{
+}
+
+//------------------------------------------------------------------------------
+
+PileUpMergerPythia8::~PileUpMergerPythia8()
+{
+}
+
+//------------------------------------------------------------------------------
+
+void PileUpMergerPythia8::Init()
+{
+  const char *fileName;
+
+  fMeanPileUp  = GetDouble("MeanPileUp", 10);
+  fZVertexSpread = GetDouble("ZVertexSpread", 0.05)*1.0E3;
+
+  fCMEnergy = GetDouble("CMEnergy", 14000.0);
+  fPTMin = GetDouble("PTMin", 0.5);
+
+  fRandomSeed = GetInt("RandomSeed", 1);
+  fBeamAID = GetInt("BeamAID", 2212);
+  fBeamBID = GetInt("BeamBID", 2212);
+
+  // Pythia8 pile-up initialization
+  fPythia = new Pythia8::Pythia();
+  fPythia->readString("SoftQCD:minBias = on");
+  fPythia->init(fBeamAID, fBeamBID, fCMEnergy);
+  fPythia->rndm.init(fRandomSeed);
+
+  // import input array
+  fInputArray = ImportArray(GetString("InputArray", "Delphes/stableParticles"));
+  fItInputArray = fInputArray->MakeIterator();
+
+  // create output arrays
+  fOutputArray = ExportArray(GetString("OutputArray", "stableParticles"));
+}
+
+//------------------------------------------------------------------------------
+
+void PileUpMergerPythia8::Finish()
+{
+  if(fPythia) delete fPythia;
+}
+
+//------------------------------------------------------------------------------
+
+void PileUpMergerPythia8::Process()
+{
+  TDatabasePDG *pdg = TDatabasePDG::Instance();
+  TParticlePDG *pdgParticle;
+  Int_t pid;
+  Float_t x, y, z, t;
+  Float_t px, py, pz, e;
+  Double_t dz, dphi;
+  Int_t poisson, event, i;
+  Long64_t allEntries, entry;
+  Candidate *candidate;
+  DelphesFactory *factory;
+
+  fItInputArray->Reset();
+  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
+  {
+    fOutputArray->Add(candidate);
+  }
+
+  factory = GetFactory();
+
+  poisson = gRandom->Poisson(fMeanPileUp);
+
+  for(event = 0; event < poisson; ++event)
+  {
+    while(!fPythia->next());
+
+    dz = gRandom->Gaus(0.0, fZVertexSpread);
+    dphi = gRandom->Uniform(-TMath::Pi(), TMath::Pi());
+
+    for(i = 0; i < fPythia->event.size(); ++i)
+    {
+      Pythia8::Particle &particle = pythia->event[i];
+
+      if(particle.status() != 1 || !particle.isVisible() || particle.pT() <= fPTMin) continue;
+
+      pid = particle.id();
+      px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.e();
+      x = particle.xProd(); y = particle.yProd(); z = particle.zProd(); t = particle.tProd();
+
+      candidate = factory->NewCandidate();
+
+      candidate->PID = pid;
+
+      candidate->Status = 1;
+
+      pdgParticle = pdg->GetParticle(pid);
+      candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
+      candidate->Mass = pdgParticle ? pdgParticle->Mass() : -999.9;
+
+      candidate->IsPU = 1;
+
+      candidate->Momentum.SetPxPyPzE(px, py, pz, e);
+      candidate->Momentum.RotateZ(dphi);
+
+      candidate->Position.SetXYZT(x, y, z + dz, t);
+      candidate->Position.RotateZ(dphi);
+
+      fOutputArray->Add(candidate);
+    }
+  }
+}
+
+//------------------------------------------------------------------------------
+
Index: modules/PileUpMergerPythia8.h
===================================================================
--- modules/PileUpMergerPythia8.h	(revision c41c262e7bf915328267ce0ade51a90bde8ae513)
+++ modules/PileUpMergerPythia8.h	(revision c41c262e7bf915328267ce0ade51a90bde8ae513)
@@ -0,0 +1,59 @@
+#ifndef PileUpMergerPythia8_h
+#define PileUpMergerPythia8_h
+
+/** \class PileUpMergerPythia8
+ *
+ *  Merges particles from pile-up sample into event
+ *
+ *
+ *  $Date$
+ *  $Revision$
+ *
+ *
+ *  \author M. Selvaggi - UCL, Louvain-la-Neuve
+ *
+ */
+
+#include "classes/DelphesModule.h"
+
+class TObjArray;
+
+namespace Pythia8
+{
+ class Pythia;
+};
+
+class PileUpMergerPythia8: public DelphesModule
+{
+public:
+
+  PileUpMergerPythia8();
+  ~PileUpMergerPythia8();
+
+  void Init();
+  void Process();
+  void Finish();
+
+private:
+
+  Double_t fMeanPileUp;
+  Double_t fZVertexSpread;
+  Double_t fCMEnergy;
+  Double_t fPTMin;
+
+  Int_t fRandomSeed;
+  Int_t fBeamAID;
+  Int_t fBeamBID;
+
+  Pythia8::Pythia *fPythia; //!
+
+  TIterator *fItInputArray; //!
+
+  const TObjArray *fInputArray; //!
+
+  TObjArray *fOutputArray; //!
+
+  ClassDef(PileUpMergerPythia8, 1)
+};
+
+#endif
