87 using namespace ::helper;
88 size_t f = selection.find_first_not_of(
' ');
89 size_t n = selection.size();
92 for (; (c = selection[
f]) !=
' ' && f < n; ++
f) {
95 if (command[0] ==
'+') {
97 if (command[0] ==
'+') {
106 if (command[command.size() - 1] ==
'+') {
107 command.erase(command.size() - 1);
108 if (command[command.size() - 1] ==
'+') {
109 command.erase(command.size() - 1);
117 if (command ==
"keep")
119 else if (command ==
"drop")
125 if (selection[f] !=
' ')
128 cut =
string(selection, f);
130 cut =
string(cut, 0, cut.find_first_of(
' '));
131 code.
all_ = cut ==
"*";
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:
270 using namespace ::helper;
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
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const edm::EventSetup & c
void produce(edm::Event &, const edm::EventSetup &) override
void flagDaughters(const reco::GenParticle &, int)
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
#define DEFINE_FWK_MODULE(type)
void parse(const std::string &selection, helper::SelectCode &code, std::string &cut) const
std::string pdgEntryReplace(const std::string &, HepPDT::ParticleDataTable const &)
void getMotherKeys(std::vector< size_t > &, std::vector< size_t > &, const reco::GenParticleRefVector &) const
void flagMothers(const reco::GenParticle &, int)
const daughters & daughterRefVector() const
references to daughtes
key_type key() const
Accessor for product key.
const_iterator end() const
Termination of iteration.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool empty() const
Is the RefVector empty.
std::vector< int > flags_
void recursiveFlagMothers(size_t, const reco::GenParticleCollection &, int, std::vector< size_t > &)
const_iterator begin() const
Initialize an iterator over the RefVector.
void recursiveFlagDaughters(size_t, const reco::GenParticleCollection &, int, std::vector< size_t > &)
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > tableToken_
bool getData(T &iHolder) const
const mothers & motherRefVector() const
references to mothers
void getDaughterKeys(std::vector< size_t > &, std::vector< size_t > &, const reco::GenParticleRefVector &) const
bool get(ProductID const &oid, Handle< PROD > &result) const
FlagDepth daughtersDepth_
TrackingParticleSelectorByGen(const edm::ParameterSet &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< std::pair< StringCutObjectSelector< reco::GenParticle >, helper::SelectCode > > select_
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
std::vector< std::string > selection_