Index: examples/Pythia8/configParticleGun.cmnd
===================================================================
--- examples/Pythia8/configParticleGun.cmnd	(revision 971db5b11629a3eccf9170867a31c12666f85a90)
+++ examples/Pythia8/configParticleGun.cmnd	(revision 971db5b11629a3eccf9170867a31c12666f85a90)
@@ -0,0 +1,21 @@
+ProcessLevel:all = off
+
+! 1) Settings used in the main program.
+
+Main:numberOfEvents = 1000         ! number of events to generate
+Main:timesAllowErrors = 3          ! how many aborts before run stops
+Main:spareFlag1 = on                ! true means particle gun
+Main:spareMode1 = 11               ! Id of the shooted particles
+
+! 2) Settings related to output in init(), next() and stat().
+
+Init:showChangedSettings = on      ! list changed settings
+Init:showChangedParticleData = off ! list changed particle data
+Next:numberCount = 100             ! print message every n events
+Next:numberShowInfo = 1            ! print event information n times
+Next:numberShowProcess = 1         ! print process record n times
+Next:numberShowEvent = 0           ! print event record n times
+
+! 3) Set the input LHE file
+
+! Beams:frameType = 4
Index: readers/DelphesPythia8.cpp
===================================================================
--- readers/DelphesPythia8.cpp	(revision fb98f404323f72540cdd64137d1cd269342600a8)
+++ readers/DelphesPythia8.cpp	(revision 971db5b11629a3eccf9170867a31c12666f85a90)
@@ -144,4 +144,46 @@
   interrupted = true;
 }
+
+
+// Single-particle gun. The particle must be a colour singlet.
+// Input: flavour, energy, direction (theta, phi).
+// If theta < 0 then random choice over solid angle.
+// Optional final argument to put particle at rest => E = m.
+// from pythia8 example 21
+
+void fillParticle(int id, double ee, double thetaIn, double phiIn,
+  Pythia8::Event& event, Pythia8::ParticleData& pdt, Pythia8::Rndm& rndm, bool atRest = false) {
+
+  // Reset event record to allow for new event.
+  event.reset();
+
+  // Select particle mass; where relevant according to Breit-Wigner.
+  double mm = pdt.mSel(id);
+  double pp = Pythia8::sqrtpos(ee*ee - mm*mm);
+
+  // Special case when particle is supposed to be at rest.
+  if (atRest) {
+    ee = mm;
+    pp = 0.;
+  }
+
+  // Angles as input or uniform in solid angle.
+  double cThe, sThe, phi;
+  if (thetaIn >= 0.) {
+    cThe = cos(thetaIn);
+    sThe = sin(thetaIn);
+    phi  = phiIn;
+  } else {
+    cThe = 2. * rndm.flat() - 1.;
+    sThe = Pythia8::sqrtpos(1. - cThe * cThe);
+    phi = 2. * M_PI * rndm.flat();
+  }
+
+  // Store the particle in the event record.
+  event.append( id, 1, 0, 0, pp * sThe * cos(phi), pp * sThe * sin(phi), pp * cThe, ee, mm);
+
+}
+
+
 
 //---------------------------------------------------------------------------
@@ -213,4 +255,6 @@
     // Initialize Pythia
     pythia = new Pythia8::Pythia;
+    //Pythia8::Event& event = pythia->event;
+    //Pythia8::ParticleData& pdt = pythia->particleData;
 
     if(pythia == NULL)
@@ -230,16 +274,20 @@
     timesAllowErrors = pythia->mode("Main:timesAllowErrors");
 
-    inputFile = fopen(pythia->word("Beams:LHEF").c_str(), "r");
-    if(inputFile)
-    {
-      reader = new DelphesLHEFReader;
-      reader->SetInputFile(inputFile);
-
-      branchEventLHEF = treeWriter->NewBranch("EventLHEF", LHEFEvent::Class());
-      branchWeightLHEF = treeWriter->NewBranch("WeightLHEF", LHEFWeight::Class());
-
-      allParticleOutputArrayLHEF = modularDelphes->ExportArray("allParticlesLHEF");
-      stableParticleOutputArrayLHEF = modularDelphes->ExportArray("stableParticlesLHEF");
-      partonOutputArrayLHEF = modularDelphes->ExportArray("partonsLHEF");
+    // Check if particle gun
+    if (!pythia->flag("Main:spareFlag1"))
+    {
+      inputFile = fopen(pythia->word("Beams:LHEF").c_str(), "r");
+      if(inputFile)
+      {
+        reader = new DelphesLHEFReader;
+        reader->SetInputFile(inputFile);
+
+        branchEventLHEF = treeWriter->NewBranch("EventLHEF", LHEFEvent::Class());
+        branchWeightLHEF = treeWriter->NewBranch("WeightLHEF", LHEFWeight::Class());
+
+        allParticleOutputArrayLHEF = modularDelphes->ExportArray("allParticlesLHEF");
+        stableParticleOutputArrayLHEF = modularDelphes->ExportArray("stableParticlesLHEF");
+        partonOutputArrayLHEF = modularDelphes->ExportArray("partonsLHEF");
+      }
     }
 
@@ -260,4 +308,9 @@
       while(reader && reader->ReadBlock(factory, allParticleOutputArrayLHEF,
         stableParticleOutputArrayLHEF, partonOutputArrayLHEF) && !reader->EventReady());
+
+      if (pythia->flag("Main:spareFlag1"))
+      {
+        fillParticle( pythia->mode("Main:spareMode1"), 30, -1., 0.,pythia->event, pythia->particleData, pythia->rndm, 0);
+      }
 
       if(!pythia->next())
