From d8ed728e26cd37ccebbb1ec03f08f6c943505af1 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Fri, 17 Nov 2017 21:27:51 +0900 Subject: [PATCH 1/3] fix GenParticles2HepMCConverter to run on herwig sample --- .../plugins/GenParticles2HepMCConverter.cc | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/GeneratorInterface/RivetInterface/plugins/GenParticles2HepMCConverter.cc b/GeneratorInterface/RivetInterface/plugins/GenParticles2HepMCConverter.cc index 04d8d50b13d22..c7fe72ef4c849 100644 --- a/GeneratorInterface/RivetInterface/plugins/GenParticles2HepMCConverter.cc +++ b/GeneratorInterface/RivetInterface/plugins/GenParticles2HepMCConverter.cc @@ -93,7 +93,9 @@ void GenParticles2HepMCConverter::produce(edm::Event& event, const edm::EventSet // Prepare list of HepMC::GenParticles std::map genCandToHepMCMap; + HepMC::GenParticle* hepmc_parton1 = nullptr, * hepmc_parton2 = nullptr; std::vector hepmc_particles; + const reco::Candidate* parton1 = nullptr, * parton2 = nullptr; for ( unsigned int i=0, n=genParticlesHandle->size(); iat(i); @@ -109,27 +111,38 @@ void GenParticles2HepMCConverter::produce(edm::Event& event, const edm::EventSet hepmc_particles.push_back(hepmc_particle); genCandToHepMCMap[p] = hepmc_particle; + + // Find incident proton pair + if ( p->pdgId() == 2212 and std::abs(p->eta()) > 100 and std::abs(p->pz()) > 1000 ) { + if ( !parton1 and p->pz() > 0 ) { + parton1 = p; + hepmc_parton1 = hepmc_particle; + } + else if ( !parton2 and p->pz() < 0 ) { + parton2 = p; + hepmc_parton2 = hepmc_particle; + } + } } // Put incident beam particles : proton -> parton vertex - const reco::Candidate* parton1 = genParticlesHandle->at(0).daughter(0); - const reco::Candidate* parton2 = genParticlesHandle->at(1).daughter(0); HepMC::GenVertex* vertex1 = new HepMC::GenVertex(FourVector(parton1->vertex())); HepMC::GenVertex* vertex2 = new HepMC::GenVertex(FourVector(parton2->vertex())); hepmc_event->add_vertex(vertex1); hepmc_event->add_vertex(vertex2); - vertex1->add_particle_in(hepmc_particles[0]); - vertex2->add_particle_in(hepmc_particles[1]); - hepmc_event->set_beam_particles(hepmc_particles[0], hepmc_particles[1]); + vertex1->add_particle_in(hepmc_parton1); + vertex2->add_particle_in(hepmc_parton2); + hepmc_event->set_beam_particles(hepmc_parton1, hepmc_parton2); // Prepare vertex list typedef std::map ParticleToVertexMap; ParticleToVertexMap particleToVertexMap; particleToVertexMap[parton1] = vertex1; particleToVertexMap[parton2] = vertex2; - for ( unsigned int i=2, n=genParticlesHandle->size(); isize(); iat(i); + if ( p == parton1 or p == parton2 ) continue; // Connect mother-daughters for the other cases for ( unsigned int j=0, nMothers=p->numberOfMothers(); j Date: Mon, 27 Nov 2017 22:57:12 +0900 Subject: [PATCH 2/3] loosen incident parton selection to avoid crash in some samples (/GGToEE) --- .../RivetInterface/plugins/GenParticles2HepMCConverter.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GeneratorInterface/RivetInterface/plugins/GenParticles2HepMCConverter.cc b/GeneratorInterface/RivetInterface/plugins/GenParticles2HepMCConverter.cc index c7fe72ef4c849..66546c88649f4 100644 --- a/GeneratorInterface/RivetInterface/plugins/GenParticles2HepMCConverter.cc +++ b/GeneratorInterface/RivetInterface/plugins/GenParticles2HepMCConverter.cc @@ -113,7 +113,7 @@ void GenParticles2HepMCConverter::produce(edm::Event& event, const edm::EventSet genCandToHepMCMap[p] = hepmc_particle; // Find incident proton pair - if ( p->pdgId() == 2212 and std::abs(p->eta()) > 100 and std::abs(p->pz()) > 1000 ) { + if ( p->mother() == nullptr and std::abs(p->eta()) > 5 and std::abs(p->pz()) > 1000 ) { if ( !parton1 and p->pz() > 0 ) { parton1 = p; hepmc_parton1 = hepmc_particle; @@ -132,7 +132,7 @@ void GenParticles2HepMCConverter::produce(edm::Event& event, const edm::EventSet hepmc_event->add_vertex(vertex2); vertex1->add_particle_in(hepmc_parton1); vertex2->add_particle_in(hepmc_parton2); - hepmc_event->set_beam_particles(hepmc_parton1, hepmc_parton2); + //hepmc_event->set_beam_particles(hepmc_parton1, hepmc_parton2); // Prepare vertex list typedef std::map ParticleToVertexMap; From 297be5a7ba8da764f6ec9bd6ebfafefa7095d377 Mon Sep 17 00:00:00 2001 From: Junghwan John Goh Date: Mon, 27 Nov 2017 23:34:00 +0900 Subject: [PATCH 3/3] cherry-pick commit b49a38c @intrepid42 --- .../plugins/MergedGenParticleProducer.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/GeneratorInterface/RivetInterface/plugins/MergedGenParticleProducer.cc b/GeneratorInterface/RivetInterface/plugins/MergedGenParticleProducer.cc index 42cf610af0e19..aae42773e3fc9 100644 --- a/GeneratorInterface/RivetInterface/plugins/MergedGenParticleProducer.cc +++ b/GeneratorInterface/RivetInterface/plugins/MergedGenParticleProducer.cc @@ -133,13 +133,14 @@ void MergedGenParticleProducer::produce(edm::Event& event, const edm::EventSetup bool MergedGenParticleProducer::isPhotonFromPrunedHadron(const pat::PackedGenParticle& pk) const { - HepPDT::ParticleID motherid(pk.mother(0)->pdgId()); - return - ( pk.pdgId() == 22 // We care about photons for lepton dressing here - and pk.statusFlags().isDirectHadronDecayProduct() // Gen status flag seems correct - // Catch cases where miniaod mother is not compatible with the status flag - and not (motherid.isHadron() and pk.mother(0)->status() == 2) - ); + if (pk.pdgId() == 22 and pk.statusFlags().isDirectHadronDecayProduct()) { + // no mother + if (pk.numberOfMothers() == 0) return true; + // miniaod mother not compatible with the status flag + HepPDT::ParticleID motherid(pk.mother(0)->pdgId()); + if (not (motherid.isHadron() and pk.mother(0)->status() == 2)) return true; + } + return false; } #include "FWCore/Framework/interface/MakerMacros.h"