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 
16 
17 namespace edm {
18 
19 namespace details {
20 
21  // which type should be used in edm::ParameterSet::getParameter<_> to read a parameter compatible with T ?
22 
23  // most types can use themselves
24  template <typename C>
26  typedef C type;
27  };
28 
29  // "float" is not allowed, as it conflicts with "double"
30  template <>
32  typedef double type;
33  };
34 
35 } // namespace details;
36 
37 template <typename T, typename C>
39 public:
41 
42 private:
43  typedef T candidate_type;
44  typedef C selection_type;
46 
47  void produce(edm::Event & event, edm::EventSetup const & setup);
48 
51 
53 };
54 
55 } // namespace edm;
56 
57 //------------------------------------------------------------------------------
58 
59 #include <vector>
60 #include <memory>
61 
66 
67 //------------------------------------------------------------------------------
68 
69 namespace edm {
70 
71 template <typename T, typename C>
73  token_electrons(consumes<edm::View<candidate_type> >(config.getParameter<edm::InputTag>("input"))),
74  token_selection(consumes<edm::ValueMap<selection_type> >(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.getByToken(token_electrons, h_electrons);
91  edm::View<candidate_type> const & electrons = * h_electrons;
92 
93  // read the selection map from the Event
95  event.getByToken(token_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:21
int i
Definition: DBlmapReader.cc:9
GenericSelectorByValueMap(edm::ParameterSet const &config)
RefToBase< value_type > refAt(size_type i) const
edm::EDGetTokenT< edm::ValueMap< selection_type > > token_selection
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
edm::EDGetTokenT< edm::View< candidate_type > > token_electrons
void produce(edm::Event &event, edm::EventSetup const &setup)
long double T
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
def template
Definition: svgfig.py:520