Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

94X backport: Fix GenParticles2HepMCConverter to run on herwig samples #21467

Merged
merged 3 commits into from
Dec 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ void GenParticles2HepMCConverter::produce(edm::Event& event, const edm::EventSet

// Prepare list of HepMC::GenParticles
std::map<const reco::Candidate*, HepMC::GenParticle*> genCandToHepMCMap;
HepMC::GenParticle* hepmc_parton1 = nullptr, * hepmc_parton2 = nullptr;
std::vector<HepMC::GenParticle*> hepmc_particles;
const reco::Candidate* parton1 = nullptr, * parton2 = nullptr;
for ( unsigned int i=0, n=genParticlesHandle->size(); i<n; ++i )
{
const reco::Candidate* p = &genParticlesHandle->at(i);
Expand All @@ -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->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;
}
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<const reco::Candidate*, HepMC::GenVertex*> ParticleToVertexMap;
ParticleToVertexMap particleToVertexMap;
particleToVertexMap[parton1] = vertex1;
particleToVertexMap[parton2] = vertex2;
for ( unsigned int i=2, n=genParticlesHandle->size(); i<n; ++i )
for ( unsigned int i=0, n=genParticlesHandle->size(); i<n; ++i )
{
const reco::Candidate* p = &genParticlesHandle->at(i);
if ( p == parton1 or p == parton2 ) continue;

// Connect mother-daughters for the other cases
for ( unsigned int j=0, nMothers=p->numberOfMothers(); j<nMothers; ++j )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down