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 "DataFormats/L1THGCal/interface/HGCalCluster.h"
0012 
0013 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0014 #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
0015 
0016 #include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h"
0017 
0018 #include <memory>
0019 #include <utility>
0020 
0021 class HGCalBackendLayer2Producer : public edm::stream::EDProducer<> {
0022 public:
0023   HGCalBackendLayer2Producer(const edm::ParameterSet&);
0024   ~HGCalBackendLayer2Producer() override {}
0025 
0026   void beginRun(const edm::Run&, const edm::EventSetup&) override;
0027   void produce(edm::Event&, const edm::EventSetup&) override;
0028 
0029 private:
0030   // inputs
0031   edm::EDGetToken input_clusters_;
0032   edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;
0033   edm::ESGetToken<HGCalTriggerGeometryBase, CaloGeometryRecord> triggerGeomToken_;
0034 
0035   std::unique_ptr<HGCalBackendLayer2ProcessorBase> backendProcess_;
0036 };
0037 
0038 DEFINE_FWK_MODULE(HGCalBackendLayer2Producer);
0039 
0040 HGCalBackendLayer2Producer::HGCalBackendLayer2Producer(const edm::ParameterSet& conf)
0041     : input_clusters_(consumes<l1t::HGCalClusterBxCollection>(conf.getParameter<edm::InputTag>("InputCluster"))),
0042       triggerGeomToken_(esConsumes<HGCalTriggerGeometryBase, CaloGeometryRecord, edm::Transition::BeginRun>()) {
0043   //setup Backend parameters
0044   const edm::ParameterSet& beParamConfig = conf.getParameterSet("ProcessorParameters");
0045   const std::string& beProcessorName = beParamConfig.getParameter<std::string>("ProcessorName");
0046   backendProcess_ = std::unique_ptr<HGCalBackendLayer2ProcessorBase>{
0047       HGCalBackendLayer2Factory::get()->create(beProcessorName, beParamConfig)};
0048 
0049   produces<l1t::HGCalMulticlusterBxCollection>(backendProcess_->name());
0050   produces<l1t::HGCalClusterBxCollection>(backendProcess_->name() + "Unclustered");
0051 }
0052 
0053 void HGCalBackendLayer2Producer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) {
0054   triggerGeometry_ = es.getHandle(triggerGeomToken_);
0055   backendProcess_->setGeometry(triggerGeometry_.product());
0056 }
0057 
0058 void HGCalBackendLayer2Producer::produce(edm::Event& e, const edm::EventSetup& es) {
0059   // Output collections
0060   std::pair<l1t::HGCalMulticlusterBxCollection, l1t::HGCalClusterBxCollection> be_output;
0061 
0062   // Input collections
0063   edm::Handle<l1t::HGCalClusterBxCollection> trigCluster2DBxColl;
0064 
0065   e.getByToken(input_clusters_, trigCluster2DBxColl);
0066 
0067   backendProcess_->run(trigCluster2DBxColl, be_output);
0068 
0069   e.put(std::make_unique<l1t::HGCalMulticlusterBxCollection>(std::move(be_output.first)), backendProcess_->name());
0070   e.put(std::make_unique<l1t::HGCalClusterBxCollection>(std::move(be_output.second)),
0071         backendProcess_->name() + "Unclustered");
0072 }