Index: readers/DelphesCMSFWLite.cpp
===================================================================
--- readers/DelphesCMSFWLite.cpp	(revision 06a83b3d8a3b27169b8510861b936f1e717eec98)
+++ readers/DelphesCMSFWLite.cpp	(revision 386f52621d00c86f5c6dc56835431d949fd62363)
@@ -53,4 +53,5 @@
 #include "DataFormats/FWLite/interface/Handle.h"
 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
+#include "DataFormats/PatCandidates/interface/PackedGenParticle.h"
 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
 #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
@@ -63,7 +64,7 @@
 
 void ConvertInput(fwlite::Event &event, Long64_t eventCounter,
-  ExRootTreeBranch *branchEvent, ExRootTreeBranch *branchRwgt,
-  DelphesFactory *factory, TObjArray *allParticleOutputArray,
-  TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray, Bool_t firstEvent)
+    ExRootTreeBranch *branchEvent, ExRootTreeBranch *branchRwgt,
+    DelphesFactory *factory, TObjArray *allParticleOutputArray,
+    TObjArray *stableParticleOutputArray, TObjArray *partonOutputArray, Bool_t firstEvent)
 {
 
@@ -71,6 +72,8 @@
   fwlite::Handle< LHEEventProduct > handleLHEEvent;
   fwlite::Handle< vector< reco::GenParticle > > handleParticle;
+  fwlite::Handle< vector< pat::PackedGenParticle > > handlePackedParticle;
 
   vector< reco::GenParticle >::const_iterator itParticle;
+  vector< pat::PackedGenParticle >::const_iterator itPackedParticle;
 
   vector< const reco::Candidate * > vectorCandidate;
@@ -96,7 +99,7 @@
     handleParticle.getByLabel(event, "genParticles");
   }
-  else if (!((handleParticle.getBranchNameFor(event, "prunedGenParticles")).empty()))
-  {
-    handleParticle.getByLabel(event, "prunedGenParticles");
+  else if (!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()))
+  {
+    handlePackedParticle.getByLabel(event, "packedGenParticles");
   }
   else
@@ -107,4 +110,5 @@
 
   Bool_t foundLHE = !((handleLHEEvent.getBranchNameFor(event, "source")).empty()) || !((handleLHEEvent.getBranchNameFor(event, "externalLHEProducer")).empty());
+  Bool_t isMiniAOD = !((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && ((handleParticle.getBranchNameFor(event, "genParticles")).empty()) ;
 
   HepMCEvent *element;
@@ -146,5 +150,5 @@
     const vector< gen::WeightsInfo > &vectorWeightsInfo = handleLHEEvent->weights();
     vector< gen::WeightsInfo >::const_iterator itWeightsInfo;
-    
+
     for(itWeightsInfo = vectorWeightsInfo.begin(); itWeightsInfo != vectorWeightsInfo.end(); ++itWeightsInfo)
     {
@@ -155,57 +159,114 @@
 
   pdg = TDatabasePDG::Instance();
-
-  for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
-  {
-    vectorCandidate.push_back(&*itParticle);
-  }
-
-  for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
-  {
-    const reco::GenParticle &particle = *itParticle;
-
-    pid = particle.pdgId();
-    status = particle.status();
-    px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
-    x = particle.vx(); y = particle.vy(); z = particle.vz();
-
-    candidate = factory->NewCandidate();
-
-    candidate->PID = pid;
-    pdgCode = TMath::Abs(candidate->PID);
-
-    candidate->Status = status;
-
-    if(particle.mother())
-    {
-      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother());
-      if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate);
-    }
-
-    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
-    if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);
-
-    itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));
-    if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);
-
-    pdgParticle = pdg->GetParticle(pid);
-    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
-    candidate->Mass = mass;
-
-    candidate->Momentum.SetPxPyPzE(px, py, pz, e);
-
-    candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);
-
-    allParticleOutputArray->Add(candidate);
-
-    if(!pdgParticle) continue;
-
-    if(status == 1)
-    {
-      stableParticleOutputArray->Add(candidate);
-    }
-    else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
-    {
-      partonOutputArray->Add(candidate);
+  if( !isMiniAOD) {
+    for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
+    {
+      vectorCandidate.push_back(&*itParticle);
+    }
+
+    for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
+    {
+      const reco::GenParticle &particle = *itParticle;
+
+      pid = particle.pdgId();
+      status = particle.status();
+      px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
+      x = particle.vx(); y = particle.vy(); z = particle.vz();
+
+      candidate = factory->NewCandidate();
+
+      candidate->PID = pid;
+      pdgCode = TMath::Abs(candidate->PID);
+
+      candidate->Status = status;
+
+      if(particle.mother())
+      {
+        itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother());
+        if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate);
+      }
+
+      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
+      if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);
+
+      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));
+      if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);
+
+      pdgParticle = pdg->GetParticle(pid);
+      candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
+      candidate->Mass = mass;
+
+      candidate->Momentum.SetPxPyPzE(px, py, pz, e);
+
+      candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);
+
+      allParticleOutputArray->Add(candidate);
+
+      if(!pdgParticle) continue;
+
+      if(status == 1)
+      {
+        stableParticleOutputArray->Add(candidate);
+      }
+      else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
+      {
+        partonOutputArray->Add(candidate);
+      }
+    }
+  }
+  else {
+    for(itPackedParticle = handlePackedParticle->begin(); itPackedParticle != handlePackedParticle->end(); ++itPackedParticle)
+    {
+      vectorCandidate.push_back(&*itPackedParticle);
+    }
+
+    for(itPackedParticle = handlePackedParticle->begin(); itPackedParticle != handlePackedParticle->end(); ++itPackedParticle)
+    {
+      const pat::PackedGenParticle &particle = *itPackedParticle;
+  
+      pid = particle.pdgId();
+      status = particle.status();
+      px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
+      x = particle.vx(); y = particle.vy(); z = particle.vz();
+
+      candidate = factory->NewCandidate();
+
+      candidate->PID = pid;
+      pdgCode = TMath::Abs(candidate->PID);
+
+      candidate->Status = status;
+
+      if(particle.mother(0))
+      {
+        itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.mother(0));
+        if(itCandidate != vectorCandidate.end()) candidate->M1 = distance(vectorCandidate.begin(), itCandidate);
+      }
+
+      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(0));
+      if(itCandidate != vectorCandidate.end()) candidate->D1 = distance(vectorCandidate.begin(), itCandidate);
+
+      itCandidate = find(vectorCandidate.begin(), vectorCandidate.end(), particle.daughter(particle.numberOfDaughters() - 1));
+      if(itCandidate != vectorCandidate.end()) candidate->D2 = distance(vectorCandidate.begin(), itCandidate);
+
+      pdgParticle = pdg->GetParticle(pid);
+      candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
+      candidate->Mass = mass;
+
+      candidate->Momentum.SetPxPyPzE(px, py, pz, e);
+
+      candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);
+
+      allParticleOutputArray->Add(candidate);
+
+      if(!pdgParticle) continue;
+
+      if(status == 1)
+      {
+        stableParticleOutputArray->Add(candidate);
+      }
+      else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
+      {
+        partonOutputArray->Add(candidate);
+      }
     }
   }
@@ -258,5 +319,5 @@
 
   FWLiteEnabler::enable();
-  
+
   try
   {
@@ -317,7 +378,7 @@
       {
         ConvertInput(event, eventCounter, branchEvent, branchRwgt, factory,
-          allParticleOutputArray, stableParticleOutputArray, partonOutputArray, firstEvent);
+            allParticleOutputArray, stableParticleOutputArray, partonOutputArray, firstEvent);
         modularDelphes->ProcessTask();
-          
+
         firstEvent = kFALSE;
 
