CMS 3D CMS Logo

AssociatedVariableCollectionSelector.h
Go to the documentation of this file.
1 #ifndef CommonTools_UtilAlgos_AssociatedVariableCollectionSelector_h
2 #define CommonTools_UtilAlgos_AssociatedVariableCollectionSelector_h
3 /* \class AssociatedVariableCollectionSelector
4  *
5  * \author Luca Lista, INFN
6  *
7  * \version $Id: AssociatedVariableCollectionSelector.h,v 1.2 2010/02/20 20:55:13 wmtan Exp $
8  *
9  */
20 
21 namespace reco {
22  namespace modules {
24  }
25 }
26 
27 template<typename InputCollection, typename VarCollection, typename Selector,
32 public:
34  typedef StoreContainer container;
35  typedef Selector selector;
36  typedef typename container::const_iterator const_iterator;
38  varToken_(iC.consumes<VarCollection>(cfg.template getParameter<edm::InputTag>("var"))),
39  select_(reco::modules::make<Selector>(cfg, iC)) { }
40  const_iterator begin() const { return selected_.begin(); }
41  const_iterator end() const { return selected_.end(); }
42  void select(const edm::Handle<InputCollection>& c, const edm::Event& evt, const edm::EventSetup&) {
43  selected_.clear();
45  evt.getByToken(varToken_, var);
46  for(size_t idx = 0; idx < c->size(); ++idx) {
47  if (select_((*c)[idx], (*var)[edm::getRef(c,idx)]))
48  addRef_(selected_, c, idx);
49  }
50  }
51 private:
53  container selected_;
54  selector select_;
55  RefAdder addRef_;
57 };
58 
59 
61 
62 namespace reco {
63  namespace modules {
64  template<typename S>
65  struct AssociatedVariableCollectionSelectorEventSetupInit {
66  static void init(S & s, const edm::Event& evt, const edm::EventSetup& es) {
67  typedef typename EventSetupInit<typename S::selector>::type ESI;
68  ESI::init(s.select_, evt, es);
69  }
70  };
71 
72  template<typename I, typename V, typename S, typename O, typename C, typename R>
73  struct EventSetupInit<AssociatedVariableCollectionSelector<I, V, S, O, C, R> > {
75  };
76  }
77 }
78 
79 #endif
80 
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
Definition: getRef.h:28
type
Definition: HCALResponse.h:21
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
int init
Definition: HydjetWrapper.h:67
S make(const edm::ParameterSet &cfg)
static void init(S &s, const edm::Event &evt, const edm::EventSetup &es)
AssociatedVariableCollectionSelector(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
take no action (default)
const std::complex< double > I
Definition: I.h:8
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
Functor that operates on <T>
Definition: Selector.h:23
AssociatedVariableCollectionSelectorEventSetupInit< AssociatedVariableCollectionSelector< I, V, S, O, C, R > > type
fixed size matrix
HLT enums.
void select(const edm::Handle< InputCollection > &c, const edm::Event &evt, const edm::EventSetup &)