Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-08 22:26:31

0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/Framework/interface/stream/EDProducer.h"
0003 
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006 #include "FWCore/Utilities/interface/ESGetToken.h"
0007 #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
0008 #include "DataFormats/L1THGCal/interface/HGCalTriggerSums.h"
0009 #include "DataFormats/L1THGCal/interface/HGCalConcentratorData.h"
0010 #include "DataFormats/HGCDigi/interface/HGCDigiCollections.h"
0011 
0012 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0013 #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
0014 
0015 #include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h"
0016 
0017 #include <memory>
0018 #include <utility>
0019 
0020 class HGCalConcentratorProducer : public edm::stream::EDProducer<> {
0021 public:
0022   HGCalConcentratorProducer(const edm::ParameterSet&);
0023   ~HGCalConcentratorProducer() override {}
0024 
0025   void beginRun(const edm::Run&, const edm::EventSetup&) override;
0026   void produce(edm::Event&, const edm::EventSetup&) override;
0027 
0028 private:
0029   // inputs
0030   edm::EDGetToken input_cell_, input_sums_;
0031   edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;
0032   edm::ESGetToken<HGCalTriggerGeometryBase, CaloGeometryRecord> triggerGeomToken_;
0033 
0034   std::unique_ptr<HGCalConcentratorProcessorBase> concentratorProcess_;
0035 };
0036 
0037 DEFINE_FWK_MODULE(HGCalConcentratorProducer);
0038 
0039 HGCalConcentratorProducer::HGCalConcentratorProducer(const edm::ParameterSet& conf)
0040     : input_cell_(consumes<l1t::HGCalTriggerCellBxCollection>(conf.getParameter<edm::InputTag>("InputTriggerCells"))),
0041       input_sums_(consumes<l1t::HGCalTriggerSumsBxCollection>(conf.getParameter<edm::InputTag>("InputTriggerSums"))),
0042       triggerGeomToken_(esConsumes<HGCalTriggerGeometryBase, CaloGeometryRecord, edm::Transition::BeginRun>()) {
0043   //setup Concentrator parameters
0044   const edm::ParameterSet& concParamConfig = conf.getParameterSet("ProcessorParameters");
0045   const std::string& concProcessorName = concParamConfig.getParameter<std::string>("ProcessorName");
0046   concentratorProcess_ = std::unique_ptr<HGCalConcentratorProcessorBase>{
0047       HGCalConcentratorFactory::get()->create(concProcessorName, concParamConfig)};
0048 
0049   produces<l1t::HGCalTriggerCellBxCollection>(concentratorProcess_->name());
0050   produces<l1t::HGCalTriggerSumsBxCollection>(concentratorProcess_->name());
0051   produces<l1t::HGCalConcentratorDataBxCollection>(concentratorProcess_->name());
0052 }
0053 
0054 void HGCalConcentratorProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) {
0055   triggerGeometry_ = es.getHandle(triggerGeomToken_);
0056   concentratorProcess_->setGeometry(triggerGeometry_.product());
0057 }
0058 
0059 void HGCalConcentratorProducer::produce(edm::Event& e, const edm::EventSetup& es) {
0060   // Output collections
0061   std::tuple<l1t::HGCalTriggerCellBxCollection, l1t::HGCalTriggerSumsBxCollection, l1t::HGCalConcentratorDataBxCollection>
0062       cc_output;
0063 
0064   // Input collections
0065   edm::Handle<l1t::HGCalTriggerCellBxCollection> trigCellBxColl;
0066 
0067   e.getByToken(input_cell_, trigCellBxColl);
0068   concentratorProcess_->run(trigCellBxColl, cc_output);
0069   // Put in the event
0070   e.put(std::make_unique<l1t::HGCalTriggerCellBxCollection>(std::move(std::get<0>(cc_output))),
0071         concentratorProcess_->name());
0072   e.put(std::make_unique<l1t::HGCalTriggerSumsBxCollection>(std::move(std::get<1>(cc_output))),
0073         concentratorProcess_->name());
0074   e.put(std::make_unique<l1t::HGCalConcentratorDataBxCollection>(std::move(std::get<2>(cc_output))),
0075         concentratorProcess_->name());
0076 }