CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenericSelectorByValueMap.h
Go to the documentation of this file.
1 #ifndef GenericSelectorByValueMap_h
2 #define GenericSelectorByValueMap_h
3 
14 
15 namespace edm {
16 
17 namespace details {
18 
19  // which type should be used in edm::ParameterSet::getParameter<_> to read a parameter compatible with T ?
20 
21  // most types can use themselves
22  template <typename C>
24  typedef C type;
25  };
26 
27  // "float" is not allowed, as it conflicts with "double"
28  template <>
30  typedef double type;
31  };
32 
33 } // namespace details;
34 
35 template <typename T, typename C>
37 public:
39 
40 private:
41  typedef T candidate_type;
42  typedef C selection_type;
44 
45  void produce(edm::Event & event, edm::EventSetup const & setup);
46 
49 
51 };
52 
53 } // namespace edm;
54 
55 //------------------------------------------------------------------------------
56 
57 #include <vector>
58 #include <memory>
59 
66 
67 //------------------------------------------------------------------------------
68 
69 namespace edm {
70 
71 template <typename T, typename C>
73  m_electrons(config.getParameter<edm::InputTag>("input")),
74  m_selection(config.getParameter<edm::InputTag>("selection")),
75  m_cut(config.getParameter<cut_type>("cut"))
76 {
77  // register the product
78  produces<edm::RefToBaseVector<candidate_type> >();
79 }
80 
81 //------------------------------------------------------------------------------
82 
83 template <typename T, typename C>
85 {
86  std::auto_ptr<edm::RefToBaseVector<candidate_type> > candidates(new edm::RefToBaseVector<candidate_type>());
87 
88  // read the collection of GsfElectrons from the Event
90  event.getByLabel(m_electrons, h_electrons);
91  edm::View<candidate_type> const & electrons = * h_electrons;
92 
93  // read the selection map from the Event
95  event.getByLabel(m_selection, h_selection);
96  edm::ValueMap<selection_type> const & selectionMap = * h_selection;
97 
98  for (unsigned int i = 0; i < electrons.size(); ++i) {
99  edm::RefToBase<candidate_type> ptr = electrons.refAt(i);
100  if (selectionMap[ptr] > m_cut)
101  candidates->push_back(ptr);
102  }
103 
104  // put the product in the event
105  event.put(candidates);
106 }
107 
108 } // namespace edm;
109 
110 #endif // GenericSelectorByValueMap_h
type
Definition: HCALResponse.h:22
int i
Definition: DBlmapReader.cc:9
GenericSelectorByValueMap(edm::ParameterSet const &config)
RefToBase< value_type > refAt(size_type i) const
details::template CompatibleConfigurationType< selection_type >::type cut_type
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
size_type size() const
tuple config
Definition: cmsDriver.py:17
void produce(edm::Event &event, edm::EventSetup const &setup)
def template
Definition: svgfig.py:520