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  */
19 
20 namespace reco {
21  namespace modules {
23  }
24 }
25 
26 template<typename InputCollection, typename VarCollection, typename Selector,
31 public:
33  typedef StoreContainer container;
34  typedef Selector selector;
35  typedef typename container::const_iterator const_iterator;
37  varToken_(iC.consumes<VarCollection>(cfg.template getParameter<edm::InputTag>("var"))),
38  select_(reco::modules::make<Selector>(cfg, iC)) { }
39  const_iterator begin() const { return selected_.begin(); }
40  const_iterator end() const { return selected_.end(); }
41  void select(const edm::Handle<InputCollection>& c, const edm::Event& evt, const edm::EventSetup&) {
42  selected_.clear();
44  evt.getByToken(varToken_, var);
45  for(size_t idx = 0; idx < c->size(); ++idx) {
46  if (select_((*c)[idx], (*var)[edm::getRef(c,idx)]))
47  addRef_(selected_, c, idx);
48  }
49  }
50 private:
52  container selected_;
53  selector select_;
54  RefAdder addRef_;
56 };
57 
58 
60 
61 namespace reco {
62  namespace modules {
63  template<typename S>
64  struct AssociatedVariableCollectionSelectorEventSetupInit {
65  static void init(S & s, const edm::Event& evt, const edm::EventSetup& es) {
66  typedef typename EventSetupInit<typename S::selector>::type ESI;
67  ESI::init(s.select_, evt, es);
68  }
69  };
70 
71  template<typename I, typename V, typename S, typename O, typename C, typename R>
72  struct EventSetupInit<AssociatedVariableCollectionSelector<I, V, S, O, C, R> > {
74  };
75  }
76 }
77 
78 #endif
79 
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:460
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:520
Functor that operates on <T>
Definition: Selector.h:24
AssociatedVariableCollectionSelectorEventSetupInit< AssociatedVariableCollectionSelector< I, V, S, O, C, R > > type
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
fixed size matrix
HLT enums.
void select(const edm::Handle< InputCollection > &c, const edm::Event &evt, const edm::EventSetup &)