49 using namespace ::helper;
50 size_t f = selection.find_first_not_of(
' ');
51 size_t n = selection.size();
54 for(; (c = selection[
f]) !=
' ' && f < n; ++
f) {
57 if(command[0] ==
'+') {
59 if(command[0] ==
'+') {
68 if(command[command.size() - 1] ==
'+') {
69 command.erase(command.size() - 1);
70 if(command[command.size()-1] ==
'+') {
71 command.erase(command.size() - 1);
79 if(command ==
"keep") code.
keepOrDrop_ = SelectCode::kKeep;
80 else if(command ==
"drop") code.
keepOrDrop_ = SelectCode::kDrop;
83 <<
"invalid selection command: " << command <<
"\n" << endl;
86 if(selection[f] !=
' ')
break;
88 cut =
string(selection, f);
90 cut =
string(cut, 0, cut.find_first_of(
' '));
91 code.
all_ = cut ==
"*";
97 selection_(cfg.getParameter<vector<
string> >(
"select")) {
98 using namespace ::helper;
99 produces<GenParticleCollection>();
115 std::vector<size_t> & allIndices ) {
118 size_t cachedIndex =
index;
123 if (
find( allIndices.begin(), allIndices.end(),
index ) == allIndices.end() ) {
124 allIndices.push_back( index );
125 if ( cachedIndex != index ) {
134 std::vector<size_t> & allIndices ) {
137 size_t cachedIndex =
index;
142 if (
find( allIndices.begin(), allIndices.end(),
index ) == allIndices.end() ) {
143 allIndices.push_back( index );
144 if ( cachedIndex != index ) {
162 <<
"selections \"keep *\" and \"drop *\" can be used only as first options. Here used in position # "
165 case ::helper::SelectCode::kDrop :
167 case ::helper::SelectCode::kKeep :
178 using namespace ::helper;
181 const size_t n = src->size();
185 const pair<StringCutObjectSelector<GenParticle>, SelectCode> &
sel =
select_[
j];
186 SelectCode code = sel.second;
188 for(
size_t i = 0;
i <
n; ++
i) {
191 int keepOrDrop =
keep;
192 switch(code.keepOrDrop_) {
193 case SelectCode::kKeep:
194 keepOrDrop =
keep;
break;
195 case SelectCode::kDrop:
199 std::vector<size_t> allIndicesDa;
200 std::vector<size_t> allIndicesMo;
201 switch(code.daughtersDepth_) {
202 case SelectCode::kAll :
204 case SelectCode::kFirst :
209 switch(code.mothersDepth_) {
210 case SelectCode::kAll :
212 case SelectCode::kFirst :
222 for(
size_t i = 0;
i <
n; ++
i) {
231 out->reserve(counter);
242 vector<size_t> daIndxs;
244 vector<size_t> moIndxs;
256 j != daughters.
end(); ++
j) {
258 if (
find(daIndxs.begin(), daIndxs.end(), dau.
key()) == daIndxs.end() ) {
260 daIndxs.push_back( dau.
key() );
280 j != mothers.
end(); ++
j) {
282 if (
find(moIndxs.begin(), moIndxs.end(), mom.
key()) == moIndxs.end() ) {
284 moIndxs.push_back( mom.
key() );
std::vector< std::pair< StringCutObjectSelector< reco::GenParticle >, helper::SelectCode > > select_
void flagDaughters(const reco::GenParticle &, int)
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
std::vector< int > flags_
void addMotherRefs(std::vector< size_t > &, reco::GenParticle &, reco::GenParticleRefProd, const reco::GenParticleRefVector &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
void flagMothers(const reco::GenParticle &, int)
std::string replace(const std::string &) const
void recursiveFlagMothers(size_t, const reco::GenParticleCollection &, int, std::vector< size_t > &)
const daughters & daughterRefVector() const
references to daughtes
GenParticlePruner(const edm::ParameterSet &)
const_iterator end() const
Termination of iteration.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
void recursiveFlagDaughters(size_t, const reco::GenParticleCollection &, int, std::vector< size_t > &)
const_iterator begin() const
Initialize an iterator over the RefVector.
void addDaughter(const typename daughters::value_type &)
add a daughter via a reference
std::vector< size_t > indices_
const mothers & motherRefVector() const
references to mothers
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
FlagDepth daughtersDepth_
void parse(const std::string &selection, helper::SelectCode &code, std::string &cut) const
void addMother(const typename mothers::value_type &)
add a daughter via a reference
RefProd< PROD > getRefBeforePut()
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
key_type key() const
Accessor for product key.
edm::EDGetTokenT< reco::GenParticleCollection > srcToken_
static std::atomic< unsigned int > counter
size_type size() const
Size of the RefVector.
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< std::string > selection_
void addDaughterRefs(std::vector< size_t > &, reco::GenParticle &, reco::GenParticleRefProd, const reco::GenParticleRefVector &) const