CMS 3D CMS Logo

ClassifierMerger.cc
Go to the documentation of this file.
3 
8 
9 #include <vector>
10 #include <memory>
11 
12 namespace {
13  class ClassifierMerger final : public edm::global::EDProducer<> {
14  public:
15  explicit ClassifierMerger(const edm::ParameterSet& conf) {
16  for (auto const& it : conf.getParameter<std::vector<std::string>>("inputClassifiers")) {
17  srcMVAs.push_back(consumes<MVACollection>(edm::InputTag(it, "MVAValues")));
18  srcQuals.push_back(consumes<QualityMaskCollection>(edm::InputTag(it, "QualityMasks")));
19  }
20 
21  produces<MVACollection>("MVAValues");
22  produces<QualityMaskCollection>("QualityMasks");
23  }
24 
25  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
27  desc.add<std::vector<std::string>>("inputClassifiers", std::vector<std::string>());
28  descriptions.add("ClassifierMerger", desc);
29  }
30 
31  private:
32  using MVACollection = std::vector<float>;
33  using QualityMaskCollection = std::vector<unsigned char>;
34 
35  void produce(edm::StreamID, edm::Event& evt, const edm::EventSetup&) const override {
36  // get Master
38  evt.getByToken(srcMVAs[0], hmva);
39  auto size = (*hmva).size();
40 
42  evt.getByToken(srcQuals[0], hqual);
43 
44  // products
45  auto mvas = std::make_unique<MVACollection>(*hmva);
46  auto quals = std::make_unique<QualityMaskCollection>(*hqual);
47 
48  for (auto i = 1U; i < srcQuals.size(); ++i) {
49  evt.getByToken(srcQuals[i], hqual);
50  auto const& iq = *hqual;
51  assert(iq.size() == size);
52  for (auto j = 0U; j != size; ++j)
53  (*quals)[j] |= iq[j];
54  }
55 
56  evt.put(std::move(mvas), "MVAValues");
57  evt.put(std::move(quals), "QualityMasks");
58  }
59 
60  std::vector<edm::EDGetTokenT<MVACollection>> srcMVAs;
61  std::vector<edm::EDGetTokenT<QualityMaskCollection>> srcQuals;
62  };
63 } // namespace
64 
67 
68 DEFINE_FWK_MODULE(ClassifierMerger);
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
cms::cuda::assert
assert(be >=bs)
edm::global::EDProducerBase::produce
virtual void produce(StreamID, Event &, EventSetup const &) const =0
edm::global::EDProducerBase::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: EDProducerBase.cc:255
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
ParameterSetDescription.h
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
ModuleDef.h
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
edm::EventSetup
Definition: EventSetup.h:57
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
Frameworkfwd.h
ParameterSet.h
EDProducer.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443