Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:40

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 
0008 #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
0009 #include "DataFormats/L1THGCal/interface/HGCalTriggerSums.h"
0010 #include "DataFormats/HGCDigi/interface/HGCDigiCollections.h"
0011 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0012 #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
0013 
0014 #include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h"
0015 
0016 #include "DataFormats/L1THGCal/interface/HGCalCluster.h"
0017 
0018 #include <memory>
0019 
0020 class HGCalBackendLayer1Producer : public edm::stream::EDProducer<> {
0021 public:
0022   HGCalBackendLayer1Producer(const edm::ParameterSet&);
0023   ~HGCalBackendLayer1Producer() 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<HGCalBackendLayer1ProcessorBase> backendProcess_;
0035 };
0036 
0037 DEFINE_FWK_MODULE(HGCalBackendLayer1Producer);
0038 
0039 HGCalBackendLayer1Producer::HGCalBackendLayer1Producer(const edm::ParameterSet& conf)
0040     : input_cell_(consumes<l1t::HGCalTriggerCellBxCollection>(conf.getParameter<edm::InputTag>("InputTriggerCells"))),
0041       triggerGeomToken_(esConsumes<HGCalTriggerGeometryBase, CaloGeometryRecord, edm::Transition::BeginRun>()) {
0042   //setup Backend parameters
0043   const edm::ParameterSet& beParamConfig = conf.getParameterSet("ProcessorParameters");
0044   const std::string& beProcessorName = beParamConfig.getParameter<std::string>("ProcessorName");
0045   backendProcess_ = std::unique_ptr<HGCalBackendLayer1ProcessorBase>{
0046       HGCalBackendLayer1Factory::get()->create(beProcessorName, beParamConfig)};
0047 
0048   produces<l1t::HGCalClusterBxCollection>(backendProcess_->name());
0049 }
0050 
0051 void HGCalBackendLayer1Producer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) {
0052   triggerGeometry_ = es.getHandle(triggerGeomToken_);
0053   backendProcess_->setGeometry(triggerGeometry_.product());
0054 }
0055 
0056 void HGCalBackendLayer1Producer::produce(edm::Event& e, const edm::EventSetup& es) {
0057   // Output collections
0058   auto be_cluster_output = std::make_unique<l1t::HGCalClusterBxCollection>();
0059 
0060   // Input collections
0061   edm::Handle<l1t::HGCalTriggerCellBxCollection> trigCellBxColl;
0062 
0063   e.getByToken(input_cell_, trigCellBxColl);
0064   backendProcess_->run(trigCellBxColl, *be_cluster_output);
0065   e.put(std::move(be_cluster_output), backendProcess_->name());
0066 }