3 #include "MergedGenParticleProducer.hh" 11 #include "HepPDT/ParticleID.hh" 14 input_pruned_ = consumes<edm::View<reco::GenParticle>>(
config.getParameter<
edm::InputTag>(
"inputPruned"));
15 input_packed_ = consumes<edm::View<pat::PackedGenParticle>>(
config.getParameter<
edm::InputTag>(
"inputPacked"));
17 produces<reco::GenParticleCollection>();
26 event.getByToken(input_pruned_, pruned_handle);
29 event.getByToken(input_packed_, packed_handle);
33 std::map<pat::PackedGenParticle const*, reco::GenParticle const*> st1_dup_map;
37 std::map<reco::Candidate const*, std::size_t> pruned_idx_map;
39 unsigned int nLeptonsFromPrunedPhoton = 0;
41 for (
unsigned int i = 0,
idx = 0;
i < pruned_handle->size(); ++
i) {
43 pruned_idx_map[&
src] =
idx;
47 if (isLeptonFromPrunedPhoton(
src)) {
48 ++nLeptonsFromPrunedPhoton;
52 if (
src.status() != 1)
61 unsigned found_matches = 0;
62 for (
unsigned j = 0;
j < packed_handle->size(); ++
j) {
64 if (pks.pdgId() != pk.
pdgId()
or pks.p4() != pk.
p4())
67 st1_dup_map[&pk] = &
src;
69 if (found_matches > 1) {
70 edm::LogWarning(
"MergedGenParticleProducer") <<
"Found multiple packed matches for: " <<
i <<
"\t" <<
src.pdgId()
71 <<
"\t" <<
src.pt() <<
"\t" <<
src.y() <<
"\n";
72 }
else if (found_matches == 0 &&
std::abs(
src.y()) < 6.0) {
74 <<
"unmatched status 1: " <<
i <<
"\t" <<
src.pdgId() <<
"\t" <<
src.pt() <<
"\t" <<
src.y() <<
"\n";
80 unsigned int nPhotonsFromPrunedHadron = 0;
81 for (
unsigned int j = 0;
j < packed_handle->size(); ++
j) {
83 if (isPhotonFromPrunedHadron(pk))
84 ++nPhotonsFromPrunedHadron;
88 const unsigned int n = pruned_handle->size() + (packed_handle->size() - st1_dup_map.size()) +
89 nPhotonsFromPrunedHadron + nLeptonsFromPrunedPhoton;
90 auto cands = std::make_unique<reco::GenParticleCollection>(
n);
94 for (
unsigned i = 0;
i < pruned_handle->size(); ++
i) {
102 if (isLeptonFromPrunedPhoton(old_cand)) {
132 for (
unsigned i = 0;
i < packed_handle->size(); ++
i) {
134 if (st1_dup_map.count(&pk))
140 if (isPhotonFromPrunedHadron(pk)) {
180 if (not(motherid.isHadron() and pk.
mother(0)->
status() == 2))
186 bool MergedGenParticleProducer::isLeptonFromPrunedPhoton(
const reco::GenParticle& pk)
const {
bool fromHardProcess() const
const Point & vertex() const override
vertex position
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
bool isDirectHadronDecayProduct() const
const Candidate * mother(size_type=0) const override
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...
int charge() const override
electric charge
virtual int status() const =0
status word
size_t numberOfDaughters() const override
number of daughters
const Point & vertex() const override
vertex position (overwritten by PF...)
size_t numberOfMothers() const override
number of mothers
const LorentzVector & p4() const final
four-momentum Lorentz vector
void setVertex(const Point &vertex) override
set vertex
void addDaughter(const typename daughters::value_type &)
add a daughter via a reference
int pdgId() const final
PDG identifier.
void resetDaughters(const edm::ProductID &id)
set daughters product ID
const LorentzVector & p4() const override
four-momentum Lorentz vecto r
size_t numberOfMothers() const override
number of mothers
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Abs< T >::type abs(const T &t)
int pdgId() const override
PDG identifier.
virtual const Point & vertex() const =0
vertex position
#define DEFINE_FWK_MODULE(type)
void addMother(const typename mothers::value_type &)
add a daughter via a reference
virtual int pdgId() const =0
PDG identifier.
const GenStatusFlags & statusFlags() const
const reco::Candidate * mother(size_type) const override
return mother at a given position (throws an exception)
Log< level::Warning, false > LogWarning
void resetMothers(const edm::ProductID &id)
set mother product ID
void setP4(const LorentzVector &p4) final
set 4-momentum
bool isDirectTauDecayProduct() const
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector
const reco::GenStatusFlags & statusFlags() const