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 
20 #include <vector>
21 
22 namespace edm { class Event; }
23 
24 template<typename InputCollection, typename Selector,
25  typename StoreContainer = std::vector<const typename InputCollection::value_type *>,
28 public:
29  typedef InputCollection collection;
30 
31 private:
32  typedef const typename InputCollection::value_type * reference;
33  typedef StoreContainer container;
34  typedef typename container::const_iterator const_iterator;
35 
36 public:
38  select_(reco::modules::make<Selector>(cfg)) { }
39  const_iterator begin() const { return selected_.begin(); }
40  const_iterator end() const { return selected_.end(); }
42  unsigned int s = c->size();
43  std::vector<bool> v(s, false);
44  for(unsigned int i = 0; i < s; ++i)
45  for(unsigned int j = i + 1; j < s; ++j) {
46  if(select_((*c)[i], (*c)[j]))
47  v[i] = v[j] = true;
48  }
49  selected_.clear();
50  for(unsigned int i = 0; i < s; ++i)
51  if (v[i])
52  addRef_(selected_, c, i);
53  }
54 
55 private:
57  StoreContainer selected_;
58  RefAdder addRef_;
59 };
60 
61 #endif
62 
int i
Definition: DBlmapReader.cc:9
tuple cfg
Definition: looper.py:237
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:24
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