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