CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ObjectPairCollectionSelector.h
Go to the documentation of this file.
1 #ifndef RecoAlgos_ObjectPairCollectionSelector_h
2 #define RecoAlgos_ObjectPairCollectionSelector_h
3 
19 #include <vector>
20 
21 namespace edm { class Event; }
22 
23 template<typename InputCollection, typename Selector,
24  typename StoreContainer = std::vector<const typename InputCollection::value_type *>,
27 public:
29 
30 private:
31  typedef const typename InputCollection::value_type * reference;
32  typedef StoreContainer container;
33  typedef typename container::const_iterator const_iterator;
34 
35 public:
37  select_(reco::modules::make<Selector>(cfg)) { }
38  const_iterator begin() const { return selected_.begin(); }
39  const_iterator end() const { return selected_.end(); }
41  unsigned int s = c->size();
42  std::vector<bool> v(s, false);
43  for(unsigned int i = 0; i < s; ++i)
44  for(unsigned int j = i + 1; j < s; ++j) {
45  if(select_((*c)[i], (*c)[j]))
46  v[i] = v[j] = true;
47  }
48  selected_.clear();
49  for(unsigned int i = 0; i < s; ++i)
50  if (v[i])
51  addRef_(selected_, c, i);
52  }
53 
54 private:
56  StoreContainer selected_;
57  RefAdder addRef_;
58 };
59 
60 #endif
61 
int i
Definition: DBlmapReader.cc:9
std::vector< InputItem > InputCollection
Definition: JetRecoTypes.h:62
S make(const edm::ParameterSet &cfg)
const InputCollection::value_type * reference
int j
Definition: DBlmapReader.cc:9
Container::value_type value_type
Functor that operates on &lt;T&gt;
Definition: Selector.h:25
ObjectPairCollectionSelector(const edm::ParameterSet &cfg)
void select(const edm::Handle< InputCollection > &c, const edm::Event &, const edm::EventSetup &)
container::const_iterator const_iterator