CMS 3D CMS Logo

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  selectorInit_(this->consumesCollector()),
42  selector_(cfg, this->consumesCollector()),
43  sizeSelector_(reco::modules::make<SizeSelector>(cfg)),
44  postProcessor_(cfg, this->consumesCollector()) {
45  const std::string filter("filter");
46  std::vector<std::string> bools = cfg.template getParameterNamesForType<bool>();
47  bool found = std::find(bools.begin(), bools.end(), filter) != bools.end();
48  if (found)
49  filter_ = cfg.template getParameter<bool>(filter);
50  postProcessor_.init(*this);
51  }
53  ~ObjectSelectorBase() override {}
54 
55 private:
57  bool filter(edm::Event& evt, const edm::EventSetup& es) override {
58  selectorInit_.init(selector_, evt, es);
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_;
77  SizeSelector sizeSelector_;
79  PostProcessor postProcessor_;
80 };
81 
82 #endif
~ObjectSelectorBase() override
destructor
bool filter(edm::Event &evt, const edm::EventSetup &es) override
process one event
Init selectorInit_
Object collection selector.
S make(const edm::ParameterSet &cfg)
def Base(process)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:536
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
static const TGPicture * filtered(bool iBackgroundIsBlack)
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
ObjectSelectorBase(const edm::ParameterSet &cfg)
constructor
ROOT::VecOps::RVec< bool > bools
Definition: Resolutions.cc:5
Functor that operates on <T>
Definition: Selector.h:22
edm::EDGetTokenT< typename Selector::collection > srcToken_
source collection label
PostProcessor postProcessor_
post processor
fixed size matrix
HLT enums.
SizeSelector sizeSelector_
selected object collection size selector
static std::string const source
Definition: EdmProvDump.cc:49