CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ObjectSelectorBase.h
Go to the documentation of this file.
1 #ifndef RecoAlgos_ObjectSelectorBase_h
2 #define RecoAlgos_ObjectSelectorBase_h
3 
20 #include <utility>
21 #include <vector>
22 #include <memory>
23 #include <algorithm>
24 
25 template <typename Selector,
26  typename OutputCollection,
27  typename SizeSelector,
28  typename PostProcessor,
29  typename StoreManager,
30  typename Base,
31  typename Init>
32 class ObjectSelectorBase : public Base {
33 public:
35  // ObjectSelectorBase()=default;
37  : Base(cfg),
38  srcToken_(
39  this->template consumes<typename Selector::collection>(cfg.template getParameter<edm::InputTag>("src"))),
40  filter_(false),
41  selector_(cfg, this->consumesCollector()),
42  sizeSelector_(reco::modules::make<SizeSelector>(cfg)),
43  postProcessor_(cfg, this->consumesCollector()) {
44  const std::string filter("filter");
45  std::vector<std::string> bools = cfg.template getParameterNamesForType<bool>();
46  bool found = std::find(bools.begin(), bools.end(), filter) != bools.end();
47  if (found)
48  filter_ = cfg.template getParameter<bool>(filter);
49  postProcessor_.init(*this);
50  }
52  ~ObjectSelectorBase() override {}
53 
54 private:
56  bool filter(edm::Event& evt, const edm::EventSetup& es) override {
57  Init::init(selector_, evt, es);
58  using namespace std;
61  StoreManager manager(source);
62  selector_.select(source, evt, es);
63  manager.cloneAndStore(selector_.begin(), selector_.end(), evt);
64  bool result = (!filter_ || sizeSelector_(manager.size()));
66  postProcessor_.process(filtered, evt);
67  return result;
68  }
72  bool filter_;
76  SizeSelector sizeSelector_;
78  PostProcessor postProcessor_;
79 };
80 
81 #endif
~ObjectSelectorBase() override
destructor
bool filter(edm::Event &evt, const edm::EventSetup &es) override
process one event
tuple cfg
Definition: looper.py:296
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
int init
Definition: HydjetWrapper.h:64
S make(const edm::ParameterSet &cfg)
bool filter_
filter event
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
tuple result
Definition: mps_fire.py:311
Selector selector_
Object collection selector.
static const TGPicture * filtered(bool iBackgroundIsBlack)
ObjectSelectorBase(const edm::ParameterSet &cfg)
constructor
Functor that operates on &lt;T&gt;
Definition: Selector.h:22
edm::EDGetTokenT< typename Selector::collection > srcToken_
source collection label
PostProcessor postProcessor_
post processor
SizeSelector sizeSelector_
selected object collection size selector
static std::string const source
Definition: EdmProvDump.cc:46
def template
Definition: svgfig.py:521