CMS 3D CMS Logo

ObjectPairCollectionSelector.h
Go to the documentation of this file.
1 #ifndef RecoAlgos_ObjectPairCollectionSelector_h
2 #define RecoAlgos_ObjectPairCollectionSelector_h
3 
21 #include <vector>
22 
23 namespace edm { class Event; }
24 
25 template<typename InputCollection, typename Selector,
26  typename StoreContainer = std::vector<const typename InputCollection::value_type *>,
29 public:
31 
32 private:
33  typedef const typename InputCollection::value_type * reference;
34  typedef StoreContainer container;
35  typedef typename container::const_iterator const_iterator;
36 
37 public:
39  select_(reco::modules::make<Selector>(cfg)) { }
40  const_iterator begin() const { return selected_.begin(); }
41  const_iterator end() const { return selected_.end(); }
43  unsigned int s = c->size();
44  std::vector<bool> v(s, false);
45  for(unsigned int i = 0; i < s; ++i)
46  for(unsigned int j = i + 1; j < s; ++j) {
47  if(select_((*c)[i], (*c)[j]))
48  v[i] = v[j] = true;
49  }
50  selected_.clear();
51  for(unsigned int i = 0; i < s; ++i)
52  if (v[i])
53  addRef_(selected_, c, i);
54  }
55 
56 private:
58  StoreContainer selected_;
59  RefAdder addRef_;
60 };
61 
62 #endif
63 
S make(const edm::ParameterSet &cfg)
const InputCollection::value_type * reference
Functor that operates on <T>
Definition: Selector.h:23
fixed size matrix
HLT enums.
void select(const edm::Handle< InputCollection > &c, const edm::Event &, const edm::EventSetup &)
ObjectPairCollectionSelector(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
container::const_iterator const_iterator