CMS 3D CMS Logo

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) override;
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  // register the product
77  produces<edm::RefToBaseVector<candidate_type>>();
78  }
79 
80  //------------------------------------------------------------------------------
81 
82  template <typename T, typename C>
84  auto candidates = std::make_unique<edm::RefToBaseVector<candidate_type>>();
85 
86  // read the collection of GsfElectrons from the Event
88  event.getByToken(token_electrons, h_electrons);
89  edm::View<candidate_type> const& electrons = *h_electrons;
90 
91  // read the selection map from the Event
93  event.getByToken(token_selection, h_selection);
94  edm::ValueMap<selection_type> const& selectionMap = *h_selection;
95 
96  for (unsigned int i = 0; i < electrons.size(); ++i) {
98  if (selectionMap[ptr] > m_cut)
99  candidates->push_back(ptr);
100  }
101 
102  // put the product in the event
103  event.put(std::move(candidates));
104  }
105 
106 } // namespace edm
107 
108 #endif // GenericSelectorByValueMap_h
Handle.h
mps_fire.i
i
Definition: mps_fire.py:355
edm::GenericSelectorByValueMap::produce
void produce(edm::Event &event, edm::EventSetup const &setup) override
Definition: GenericSelectorByValueMap.h:83
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
EDProducer.h
edm::GenericSelectorByValueMap::m_cut
cut_type m_cut
Definition: GenericSelectorByValueMap.h:52
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::details::CompatibleConfigurationType< float >::type
double type
Definition: GenericSelectorByValueMap.h:32
edm::GenericSelectorByValueMap::candidate_type
T candidate_type
Definition: GenericSelectorByValueMap.h:43
edm::GenericSelectorByValueMap::token_electrons
edm::EDGetTokenT< edm::View< candidate_type > > token_electrons
Definition: GenericSelectorByValueMap.h:49
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
config
Definition: config.py:1
PtrVector.h
RefToBaseVector.h
details
Definition: helper.h:56
edm::details::CompatibleConfigurationType::type
C type
Definition: GenericSelectorByValueMap.h:26
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
Ptr.h
edm::GenericSelectorByValueMap::selection_type
C selection_type
Definition: GenericSelectorByValueMap.h:44
edm::GenericSelectorByValueMap::cut_type
details::template CompatibleConfigurationType< selection_type >::type cut_type
Definition: GenericSelectorByValueMap.h:45
edm::GenericSelectorByValueMap::token_selection
edm::EDGetTokenT< edm::ValueMap< selection_type > > token_selection
Definition: GenericSelectorByValueMap.h:50
edm::EventSetup
Definition: EventSetup.h:57
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
edm::GenericSelectorByValueMap
Definition: GenericSelectorByValueMap.h:38
InputTag.h
ValueMap.h
edm::GenericSelectorByValueMap::GenericSelectorByValueMap
GenericSelectorByValueMap(edm::ParameterSet const &config)
Definition: GenericSelectorByValueMap.h:72
type
type
Definition: HCALResponse.h:21
eostools.move
def move(src, dest)
Definition: eostools.py:511
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
gen::C
C
Definition: PomwigHadronizer.cc:76
edm::details::CompatibleConfigurationType
Definition: GenericSelectorByValueMap.h:25
Frameworkfwd.h
T
long double T
Definition: Basic3DVectorLD.h:48
HLT_2018_cff.candidates
candidates
Definition: HLT_2018_cff.py:53513
edm::ValueMap
Definition: ValueMap.h:107
EventSetup.h
edm::EDProducer
Definition: EDProducer.h:36
edm::RefToBase
Definition: AssociativeIterator.h:54
View.h
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15