HLTrigger
JetMET
plugins
HLTMultiplicityValueProducerFromNestedCollection.h
Go to the documentation of this file.
1
#ifndef HLTrigger_JetMET_plugins_HLTMultiplicityValueProducerFromNestedCollection_h
2
#define HLTrigger_JetMET_plugins_HLTMultiplicityValueProducerFromNestedCollection_h
3
4
#include <memory>
5
6
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
7
#include "
FWCore/Framework/interface/global/EDProducer.h
"
8
#include "
FWCore/Framework/interface/Event.h
"
9
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
10
#include "
FWCore/ParameterSet/interface/ConfigurationDescriptions.h
"
11
#include "
FWCore/ParameterSet/interface/ParameterSetDescription.h
"
12
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
13
14
template
<
class
INP_TYPE,
class
OUT_TYPE>
15
class
HLTMultiplicityValueProducerFromNestedCollection
:
public
edm::global::EDProducer
<> {
16
public
:
17
explicit
HLTMultiplicityValueProducerFromNestedCollection
(
edm::ParameterSet
const
&);
18
~HLTMultiplicityValueProducerFromNestedCollection
()
override
{}
19
20
static
void
fillDescriptions
(
edm::ConfigurationDescriptions
&);
21
22
protected
:
23
void
produce
(
edm::StreamID
,
edm::Event
&,
edm::EventSetup
const
&)
const override
;
24
25
edm::EDGetTokenT<INP_TYPE>
const
src_token_
;
26
OUT_TYPE
const
defaultValue_
;
27
};
28
29
template
<
class
INP_TYPE,
class
OUT_TYPE>
30
HLTMultiplicityValueProducerFromNestedCollection<INP_TYPE, OUT_TYPE>::HLTMultiplicityValueProducerFromNestedCollection
(
31
edm::ParameterSet
const
& iConfig)
32
: src_token_(consumes<INP_TYPE>(iConfig.getParameter<
edm
::
InputTag
>(
"src"
))),
33
defaultValue_(iConfig.getParameter<OUT_TYPE>(
"defaultValue"
)) {
34
produces<OUT_TYPE>();
35
}
36
37
template
<
class
INP_TYPE,
class
OUT_TYPE>
38
void
HLTMultiplicityValueProducerFromNestedCollection<INP_TYPE, OUT_TYPE>::produce
(
39
edm::StreamID
,
edm::Event
&
iEvent
,
edm::EventSetup
const
& iSetup)
const
{
40
auto
const
& objHandle(
iEvent
.getHandle(src_token_));
41
42
if
(objHandle.isValid()) {
43
LogDebug
(
"Input"
) <<
"size of input collection: "
<< objHandle->size();
44
45
OUT_TYPE objMult(0);
46
for
(
auto
const
&
obj
: *objHandle) {
47
objMult +=
obj
.size();
48
}
49
50
LogDebug
(
"Output"
) <<
"size of output objects: "
<< objMult;
51
52
iEvent
.put(std::make_unique<OUT_TYPE>(objMult));
53
}
else
{
54
iEvent
.put(std::make_unique<OUT_TYPE>(defaultValue_));
55
}
56
}
57
58
template
<
class
INP_TYPE,
class
OUT_TYPE>
59
void
HLTMultiplicityValueProducerFromNestedCollection<INP_TYPE, OUT_TYPE>::fillDescriptions
(
60
edm::ConfigurationDescriptions
& descriptions) {
61
edm::ParameterSetDescription
desc
;
62
desc
.add<
edm::InputTag
>(
"src"
,
edm::InputTag
(
""
))->setComment(
"input collection"
);
63
desc
.add<OUT_TYPE>(
"defaultValue"
, 0)->setComment(
"default output value (used when input collection is unavailable)"
);
64
descriptions.
addWithDefaultLabel
(
desc
);
65
}
66
67
#endif // HLTrigger_JetMET_plugins_HLTMultiplicityValueProducerFromNestedCollection_h
ConfigurationDescriptions.h
edm::StreamID
Definition:
StreamID.h:30
HLTMultiplicityValueProducerFromNestedCollection::~HLTMultiplicityValueProducerFromNestedCollection
~HLTMultiplicityValueProducerFromNestedCollection() override
Definition:
HLTMultiplicityValueProducerFromNestedCollection.h:18
MessageLogger.h
HLTMultiplicityValueProducerFromNestedCollection::src_token_
const edm::EDGetTokenT< INP_TYPE > src_token_
Definition:
HLTMultiplicityValueProducerFromNestedCollection.h:25
edm::EDGetTokenT< INP_TYPE >
edm
HLT enums.
Definition:
AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition:
HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition:
ParameterSetDescription.h:52
HLTMultiplicityValueProducerFromNestedCollection
Definition:
HLTMultiplicityValueProducerFromNestedCollection.h:15
ParameterSetDescription.h
getGTfromDQMFile.obj
obj
Definition:
getGTfromDQMFile.py:32
edm::global::EDProducer
Definition:
EDProducer.h:32
edm::ConfigurationDescriptions
Definition:
ConfigurationDescriptions.h:28
HLTMultiplicityValueProducerFromNestedCollection::produce
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
Definition:
HLTMultiplicityValueProducerFromNestedCollection.h:38
LogDebug
#define LogDebug(id)
Definition:
MessageLogger.h:233
edm::ParameterSet
Definition:
ParameterSet.h:47
HLTMultiplicityValueProducerFromNestedCollection::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition:
HLTMultiplicityValueProducerFromNestedCollection.h:59
Event.h
HLTMultiplicityValueProducerFromNestedCollection::HLTMultiplicityValueProducerFromNestedCollection
HLTMultiplicityValueProducerFromNestedCollection(edm::ParameterSet const &)
Definition:
HLTMultiplicityValueProducerFromNestedCollection.h:30
iEvent
int iEvent
Definition:
GenABIO.cc:224
edm::EventSetup
Definition:
EventSetup.h:58
submitPVResolutionJobs.desc
string desc
Definition:
submitPVResolutionJobs.py:251
Frameworkfwd.h
HLTMultiplicityValueProducerFromNestedCollection::defaultValue_
const OUT_TYPE defaultValue_
Definition:
HLTMultiplicityValueProducerFromNestedCollection.h:26
ParameterSet.h
EDProducer.h
edm::Event
Definition:
Event.h:73
edm::InputTag
Definition:
InputTag.h:15
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition:
ConfigurationDescriptions.cc:87
Generated for CMSSW Reference Manual by
1.8.16