1 #ifndef PhysicsTools_PatAlgos_plugins_PATCleaner_h
2 #define PhysicsTools_PatAlgos_plugins_PATCleaner_h
35 #include <boost/ptr_container/ptr_vector.hpp>
39 template<
class PATObjType>
63 template <
class PATObjType>
65 src_(iConfig.getParameter<edm::InputTag>(
"src")),
66 srcToken_(consumes<edm::
View<PATObjType> >(src_)),
67 preselectionCut_(iConfig.getParameter<std::
string>(
"preselection")),
68 finalCut_(iConfig.getParameter<std::
string>(
"finalCut"))
75 for (std::vector<std::string>::const_iterator itn = overlapNames.begin(); itn != overlapNames.end(); ++itn) {
79 if (cfg.
empty())
continue;
83 if (algorithm ==
"byDeltaR") {
85 }
else if (algorithm ==
"bySuperClusterSeed") {
88 throw cms::Exception(
"Configuration") <<
"PATCleaner for " <<
src_ <<
": unsupported algorithm '" << algorithm <<
"'\n";
93 produces<std::vector<PATObjType> >();
96 template <
class PATObjType>
105 std::auto_ptr< std::vector<PATObjType> >
output(
new std::vector<PATObjType>());
108 for (boost::ptr_vector<OverlapTest>::iterator itov = overlapTests_.begin(), edov = overlapTests_.end(); itov != edov; ++itov) {
109 itov->readInput(iEvent,iSetup);
114 if (!preselectionCut_(*it))
continue;
118 output->push_back(*it);
119 PATObjType &
obj = output->back();
122 bool badForOverlap =
false;
123 for (boost::ptr_vector<OverlapTest>::iterator itov = overlapTests_.begin(), edov = overlapTests_.end(); itov != edov; ++itov) {
125 bool hasOverlap = itov->fillOverlapsForItem(obj, overlaps);
126 if (hasOverlap && itov->requireNoOverlaps()) {
127 badForOverlap =
true;
130 obj.setOverlaps(itov->name(),
overlaps);
132 if (badForOverlap) { output->pop_back();
continue; }
135 if (!finalCut_(obj)) output->pop_back();
T getParameter(std::string const &) const
boost::ptr_vector< OverlapTest > overlapTests_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
PAT Cleaner module for PAT Objects.
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< edm::View< PATObjType > > srcToken_
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Selector preselectionCut_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
pat::helper::OverlapTest OverlapTest
PATCleaner(const edm::ParameterSet &iConfig)
StringCutObjectSelector< PATObjType > Selector