50 : inTag(params.getParameter<edm::
InputTag>(
"src")),
51 prunedInTag(params.exists(
"prunedGenParticles") ? params.getParameter<edm::
InputTag>(
"prunedGenParticles")
52 : edm::
InputTag(
"prunedGenParticles")),
53 partonicFinalState(params.getParameter<bool>(
"partonicFinalState")),
54 excludeResonances(params.getParameter<bool>(
"excludeResonances")),
55 tausAsJets(params.getParameter<bool>(
"tausAsJets")),
57 if (params.
exists(
"ignoreParticleIDs"))
65 <<
"Partonic final state not supported for MiniAOD. Falling back to the stable particle selection.";
69 produces<reco::CandidatePtrVector>();
89 pdgId = (pdgId > 0 ? pdgId : -pdgId) % 10000;
90 return (pdgId > 0 && pdgId < 6) || pdgId == 9 || (
tausAsJets && pdgId == 15) || pdgId == 21;
96 pdgId = (pdgId > 0 ? pdgId : -pdgId) % 10000;
97 return (pdgId > 100 && pdgId < 900) || (pdgId > 1000 && pdgId < 9000);
102 pdgId = (pdgId > 0 ? pdgId : -pdgId) % 10000;
103 return (pdgId > 21 && pdgId <= 42) || pdgId == 6 || pdgId == 7 || pdgId == 8;
107 pdgId = pdgId > 0 ? pdgId : -pdgId;
108 std::vector<unsigned int>::const_iterator pos =
114 pdgId = pdgId > 0 ? pdgId : -pdgId;
115 std::vector<unsigned int>::const_iterator pos =
121 InputGenJetsParticleSelector::ParticleVector::const_iterator pos =
std::lower_bound(p.begin(), p.end(), particle);
122 if (pos == p.end() || *pos != particle)
123 throw cms::Exception(
"CorruptedData") <<
"reco::GenEvent corrupted: Unlisted particles"
127 return pos - p.begin();
137 for (
unsigned int i = 0;
i <
npart; ++
i) {
155 for (
unsigned int i = 0;
i <
npart; ++
i) {
174 unsigned int idx =
partIdx(p, particle);
175 int id = particle->
pdgId();
191 for (
unsigned int i = 0;
i < nMo; ++
i) {
218 auto selected_ = std::make_unique<reco::CandidatePtrVector>();
227 iter != prunedGenParticles->end();
229 if (iter->status() !=
231 particles.push_back(&*iter);
238 std::map<const reco::Candidate *, size_t> particlePtrIdxMap;
241 particles.push_back(&*iter);
242 particlePtrIdxMap[&*iter] = (iter - genParticles->begin());
245 std::sort(particles.begin(), particles.end());
246 unsigned int size = particles.size();
251 for (
unsigned int i = 0;
i <
size;
i++) {
255 if (particle->
status() == 1)
268 for (
size_t idx = 0; idx <
size; ++idx) {
270 if (!selected[idx] || invalid[idx]) {
285 selected_->push_back(genParticles->ptrAt(particlePtrIdxMap[particle]));
bool hasPartonChildren(ParticleBitmap &invalid, const ParticleVector &p, const reco::Candidate *particle) const
static unsigned int partIdx(const InputGenJetsParticleSelector::ParticleVector &p, const reco::Candidate *particle)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
edm::EDGetTokenT< reco::CandidateView > input_genpartcoll_token_
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
static bool isHadron(int pdgId)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual double pt() const =0
transverse momentum
#define DEFINE_FWK_MODULE(type)
virtual int status() const =0
status word
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< unsigned int > excludeFromResonancePids
Log< level::Error, false > LogError
void produce(edm::StreamID, edm::Event &evt, const edm::EventSetup &evtSetup) const override
int testPartonChildren(ParticleBitmap &invalid, const ParticleVector &p, const reco::Candidate *particle) const
void setIgnoredParticles(const std::vector< unsigned int > &particleIDs)
virtual size_type numberOfDaughters() const =0
number of daughters
bool isParton(int pdgId) const
bool isExcludedFromResonance(int pdgId) const
edm::EDGetTokenT< reco::CandidateView > input_prunedgenpartcoll_token_
bool isIgnored(int pdgId) const
ResonanceState fromResonance(ParticleBitmap &invalid, const ParticleVector &p, const reco::Candidate *particle) const
std::vector< bool > ParticleBitmap
virtual int pdgId() const =0
PDG identifier.
static bool isResonance(int pdgId)
T getParameter(std::string const &) const
static void invalidateTree(InputGenJetsParticleSelector::ParticleBitmap &invalid, const InputGenJetsParticleSelector::ParticleVector &p, const reco::Candidate *particle)
InputGenJetsParticleSelector()
std::vector< unsigned int > ignoreParticleIDs
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
edm::InputTag prunedInTag
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
std::vector< const reco::Candidate * > ParticleVector
void setExcludeFromResonancePids(const std::vector< unsigned int > &particleIDs)
~InputGenJetsParticleSelector() override
tuple size
Write out results.