Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:35:59

0001 // system include files
0002 #include <memory>
0003 
0004 // user include files
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/stream/EDProducer.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 
0009 #include "FWCore/Utilities/interface/ESInputTag.h"
0010 #include "FWCore/Utilities/interface/Transition.h"
0011 
0012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0013 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0014 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0015 
0016 #include "DataFormats/NanoAOD/interface/FlatTable.h"
0017 #include "DataFormats/HcalDigi/interface/HcalUMNioDigi.h"
0018 
0019 class HcalUMNioTableProducer : public edm::stream::EDProducer<> {
0020 private:
0021   edm::EDGetTokenT<HcalUMNioDigi> tokenUMNio_;
0022   edm::InputTag tagUMNio_;
0023 
0024 public:
0025   explicit HcalUMNioTableProducer(const edm::ParameterSet& iConfig)
0026       : tagUMNio_(iConfig.getUntrackedParameter<edm::InputTag>("tagUMNio", edm::InputTag("hcalDigis"))) {
0027     tokenUMNio_ = consumes<HcalUMNioDigi>(tagUMNio_);
0028 
0029     produces<nanoaod::FlatTable>("uMNioTable");
0030   }
0031 
0032   ~HcalUMNioTableProducer() override {}
0033 
0034   /*
0035     static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0036         edm::ParameterSetDescription desc;
0037         desc.add<edm::InputTag>("tagUMNio")->setComment("Input uMNio digi collection");
0038         descriptions.add("HcalUMNioTable", desc);
0039     }
0040     */
0041 
0042 private:
0043   void produce(edm::Event&, edm::EventSetup const&) override;
0044 };
0045 
0046 void HcalUMNioTableProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0047   edm::Handle<HcalUMNioDigi> uMNioDigi;
0048   iEvent.getByToken(tokenUMNio_, uMNioDigi);
0049   uint8_t eventType = uMNioDigi->eventType();
0050 
0051   auto uMNioNanoTable = std::make_unique<nanoaod::FlatTable>(1, "uMNio", true);
0052   uMNioNanoTable->addColumnValue<uint8_t>("EventType", eventType, "EventType");
0053   for (int iWord = 0; iWord < uMNioDigi->numberUserWords(); ++iWord) {
0054     uint32_t thisWord = uMNioDigi->valueUserWord(iWord);
0055     uMNioNanoTable->addColumnValue<uint32_t>(
0056         "UserWord" + std::to_string(iWord), thisWord, "UserWord" + std::to_string(iWord));
0057   }
0058   iEvent.put(std::move(uMNioNanoTable), "uMNioTable");
0059 }
0060 
0061 #include "FWCore/Framework/interface/MakerMacros.h"
0062 //define this as a plug-in
0063 DEFINE_FWK_MODULE(HcalUMNioTableProducer);