CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
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>
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
tuple cfg
Definition: looper.py:293
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
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)
tuple InputCollection
take no action (default)
const std::complex< double > I
Definition: I.h:8
Functor that operates on &lt;T&gt;
Definition: Selector.h:24
AssociatedVariableCollectionSelectorEventSetupInit< AssociatedVariableCollectionSelector< I, V, S, O, C, R > > type
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
def template
Definition: svgfig.py:520
void select(const edm::Handle< InputCollection > &c, const edm::Event &evt, const edm::EventSetup &)