CMS 3D CMS Logo

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 
13 
14 template <class INP_TYPE, class OUT_TYPE>
16 public:
19 
21 
22 protected:
23  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
24 
26  OUT_TYPE const defaultValue_;
27 };
28 
29 template <class INP_TYPE, class OUT_TYPE>
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>
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>
60  edm::ConfigurationDescriptions& descriptions) {
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
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
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
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
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
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:57
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