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.1 2009/03/03 13:07:25 llista Exp $
8  *
9  */
18 
19 namespace reco {
20  namespace modules {
22  }
23 }
24 
25 template<typename InputCollection, typename VarCollection, typename Selector,
30 public:
32  typedef StoreContainer container;
33  typedef Selector selector;
34  typedef typename container::const_iterator const_iterator;
36  var_(cfg.template getParameter<edm::InputTag>("var")),
37  select_(reco::modules::make<Selector>(cfg)) { }
38  const_iterator begin() const { return selected_.begin(); }
39  const_iterator end() const { return selected_.end(); }
40  void select(const edm::Handle<InputCollection>& c, const edm::Event& evt, const edm::EventSetup&) {
41  selected_.clear();
43  evt.getByLabel(var_, var);
44  for(size_t idx = 0; idx < c->size(); ++idx) {
45  if (select_((*c)[idx], (*var)[edm::getRef(c,idx)]))
46  addRef_(selected_, c, idx);
47  }
48  }
49 private:
53  RefAdder addRef_;
55 };
56 
57 
59 
60 namespace reco {
61  namespace modules {
62  template<typename S>
63  struct AssociatedVariableCollectionSelectorEventSetupInit {
64  static void init(S & s, const edm::Event& evt, const edm::EventSetup& es) {
65  typedef typename EventSetupInit<typename S::selector>::type ESI;
66  ESI::init(s.select_, evt, es);
67  }
68  };
69 
70  template<typename I, typename V, typename S, typename O, typename C, typename R>
73  };
74  }
75 }
76 
77 #endif
helper::MatcherGetRef< C >::ref_type getRef(const Handle< C > &c, size_t k)
Definition: getRef.h:28
type
Definition: HCALResponse.h:22
std::vector< ProtoJet > OutputCollection
Definition: JetRecoTypes.h:63
std::vector< InputItem > InputCollection
Definition: JetRecoTypes.h:62
int init
Definition: HydjetWrapper.h:63
S make(const edm::ParameterSet &cfg)
static void init(S &s, const edm::Event &evt, const edm::EventSetup &es)
AssociatedVariableCollectionSelector(const edm::ParameterSet &cfg)
take no action (default)
const std::complex< double > I
Definition: I.h:8
Functor that operates on &lt;T&gt;
Definition: Selector.h:25
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
AssociatedVariableCollectionSelectorEventSetupInit< AssociatedVariableCollectionSelector< I, V, S, O, C, R > > type
string s
Definition: asciidump.py:422
def template
Definition: svgfig.py:520
void select(const edm::Handle< InputCollection > &c, const edm::Event &evt, const edm::EventSetup &)