139 keepOrDropAll_(
drop),
140 selection_(iConfig.getParameter<
vector<
string>>(
"select")) {
141 produces<TrackingParticleCollection>();
159 std::vector<size_t> &allIndices) {
162 size_t cachedIndex =
index;
167 if (
find(allIndices.begin(), allIndices.end(),
index) == allIndices.end()) {
168 allIndices.push_back(
index);
169 if (cachedIndex !=
index) {
180 std::vector<size_t> &allIndices) {
183 size_t cachedIndex =
index;
188 if (
find(allIndices.begin(), allIndices.end(),
index) == allIndices.end()) {
189 allIndices.push_back(
index);
190 if (cachedIndex !=
index) {
199 vector<size_t> &daNewIndxs,
203 if (
find(daIndxs.begin(), daIndxs.end(), dau.
key()) == daIndxs.end()) {
204 daIndxs.push_back(dau.
key());
207 daNewIndxs.push_back(
idx);
218 vector<size_t> &moNewIndxs,
222 if (
find(moIndxs.begin(), moIndxs.end(), mom.
key()) == moIndxs.end()) {
223 moIndxs.push_back(mom.
key());
226 moNewIndxs.push_back(
idx);
243 ::helper::SelectCode code;
248 <<
"selections \"keep *\" and \"drop *\" can be used only as first options. Here used in position # " 251 switch (code.keepOrDrop_) {
252 case ::helper::SelectCode::kDrop:
255 case ::helper::SelectCode::kKeep:
271 const size_t n = gps.size();
275 const pair<StringCutObjectSelector<GenParticle>, SelectCode> &
sel =
select_[
j];
276 SelectCode code =
sel.second;
278 for (
size_t i = 0;
i <
n; ++
i) {
281 int keepOrDrop =
keep;
282 switch (code.keepOrDrop_) {
283 case SelectCode::kKeep:
286 case SelectCode::kDrop:
290 std::vector<size_t> allIndicesDa;
291 std::vector<size_t> allIndicesMo;
292 switch (code.daughtersDepth_) {
293 case SelectCode::kAll:
296 case SelectCode::kFirst:
301 switch (code.mothersDepth_) {
302 case SelectCode::kAll:
305 case SelectCode::kFirst:
314 auto out = std::make_unique<TrackingParticleCollection>();
317 for (
auto &&
tp : tps) {
318 auto &associatedGenParticles =
tp.genParticles();
321 for (
auto &&assocGen : associatedGenParticles) {
327 out->emplace_back(
tp);
337 desc.add<vector<string>>(
"select");
339 descriptions.
add(
"tpSelectorByGenDefault",
desc);
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
bool empty() const
Is the RefVector empty.
void produce(edm::Event &, const edm::EventSetup &) override
void flagDaughters(const reco::GenParticle &, int)
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
#define DEFINE_FWK_MODULE(type)
std::string pdgEntryReplace(const std::string &, HepPDT::ParticleDataTable const &)
void flagMothers(const reco::GenParticle &, int)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< int > flags_
void recursiveFlagMothers(size_t, const reco::GenParticleCollection &, int, std::vector< size_t > &)
key_type key() const
Accessor for product key.
void recursiveFlagDaughters(size_t, const reco::GenParticleCollection &, int, std::vector< size_t > &)
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > tableToken_
FlagDepth daughtersDepth_
void parse(const std::string &selection, helper::SelectCode &code, std::string &cut) const
bool getData(T &iHolder) const
void getDaughterKeys(std::vector< size_t > &, std::vector< size_t > &, const reco::GenParticleRefVector &) const
TrackingParticleSelectorByGen(const edm::ParameterSet &)
std::vector< std::pair< StringCutObjectSelector< reco::GenParticle >, helper::SelectCode > > select_
const_iterator end() const
Termination of iteration.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool isSelected(const std::vector< L1HPSPFTauQualityCut > &qualityCuts, const l1t::PFCandidate &pfCand, float_t primaryVertexZ)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< reco::GenParticleCollection > gpToken_
std::vector< TrackingParticle > TrackingParticleCollection
const_iterator begin() const
Initialize an iterator over the RefVector.
std::vector< std::string > selection_
void getMotherKeys(std::vector< size_t > &, std::vector< size_t > &, const reco::GenParticleRefVector &) const