CMS 3D CMS Logo

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 
15 
16 template <class INP_TYPE, class OUT_TYPE>
18 public:
21 
23 
24 protected:
25  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
26 
29  OUT_TYPE const defaultValue_;
30 };
31 
32 template <class INP_TYPE, class OUT_TYPE>
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>
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>
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:89281
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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
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