Index: readers/DelphesCMSFWLite.cpp
===================================================================
--- readers/DelphesCMSFWLite.cpp	(revision 386f52621d00c86f5c6dc56835431d949fd62363)
+++ readers/DelphesCMSFWLite.cpp	(revision a7c900258fb2558bc70666736fb0903f48c12c3d)
@@ -99,6 +99,7 @@
     handleParticle.getByLabel(event, "genParticles");
   }
-  else if (!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()))
-  {
+  else if (!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && !((handleParticle.getBranchNameFor(event,"prunedGenParticles")).empty()))
+  {
+    handleParticle.getByLabel(event, "prunedGenParticles");
     handlePackedParticle.getByLabel(event, "packedGenParticles");
   }
@@ -159,114 +160,113 @@
 
   pdg = TDatabasePDG::Instance();
-  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);
-      }
+
+  for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
+  {
+    const reco::GenParticle &particle = *itParticle;
+    if( !isMiniAOD || particle.status() != 1 ) vectorCandidate.push_back(&*itParticle);
+  }
+
+  for(itParticle = handleParticle->begin(); itParticle != handleParticle->end(); ++itParticle)
+  {
+    const reco::GenParticle &particle = *itParticle;
+
+    pid = particle.pdgId();
+    status = particle.status();
+    if( isMiniAOD && particle.status() == 1 ) continue;
+    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)
+    {
+      // Prevent duplicated particle.
+      if ( !isMiniAOD ) stableParticleOutputArray->Add(candidate);
+    }
+    else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
+    {
+      partonOutputArray->Add(candidate);
+    }
+  }
+  if ( !isMiniAOD) return ;
+  // For MiniAOD sample,
+  // Only status==1 particles are saved to packedGenParticles.
+  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);
     }
   }
