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/HGCalTower.h"
0010 
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 <memory>
0017 
0018 class HGCalTowerProducer : public edm::stream::EDProducer<> {
0019 public:
0020   HGCalTowerProducer(const edm::ParameterSet&);
0021   ~HGCalTowerProducer() override {}
0022 
0023   void beginRun(const edm::Run&, const edm::EventSetup&) override;
0024   void produce(edm::Event&, const edm::EventSetup&) override;
0025 
0026 private:
0027   // inputs
0028   edm::EDGetToken input_towers_map_;
0029   edm::EDGetToken input_trigger_cells_;
0030   edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;
0031   edm::ESGetToken<HGCalTriggerGeometryBase, CaloGeometryRecord> triggerGeomToken_;
0032   std::unique_ptr<HGCalTowerProcessorBase> towersProcess_;
0033 };
0034 
0035 DEFINE_FWK_MODULE(HGCalTowerProducer);
0036 
0037 HGCalTowerProducer::HGCalTowerProducer(const edm::ParameterSet& conf)
0038     : input_towers_map_(consumes<l1t::HGCalTowerMapBxCollection>(conf.getParameter<edm::InputTag>("InputTowerMaps"))),
0039       input_trigger_cells_(
0040           consumes<l1t::HGCalClusterBxCollection>(conf.getParameter<edm::InputTag>("InputTriggerCells"))),
0041       triggerGeomToken_(esConsumes<HGCalTriggerGeometryBase, CaloGeometryRecord, edm::Transition::BeginRun>()) {
0042   //setup TowerMap parameters
0043   const edm::ParameterSet& towerParamConfig = conf.getParameterSet("ProcessorParameters");
0044   const std::string& towerProcessorName = towerParamConfig.getParameter<std::string>("ProcessorName");
0045   towersProcess_ = HGCalTowerFactory::get()->create(towerProcessorName, towerParamConfig);
0046 
0047   produces<l1t::HGCalTowerBxCollection>(towersProcess_->name());
0048 }
0049 
0050 void HGCalTowerProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) {
0051   triggerGeometry_ = es.getHandle(triggerGeomToken_);
0052   towersProcess_->setGeometry(triggerGeometry_.product());
0053 }
0054 
0055 void HGCalTowerProducer::produce(edm::Event& e, const edm::EventSetup& es) {
0056   // Output collections
0057   auto towers_output = std::make_unique<l1t::HGCalTowerBxCollection>();
0058 
0059   // Input collections
0060   std::pair<edm::Handle<l1t::HGCalTowerMapBxCollection>, edm::Handle<l1t::HGCalClusterBxCollection> > inputsColl;
0061   auto& towersMapBxColl = inputsColl.first;
0062   auto& clustersBxColl = inputsColl.second;
0063 
0064   e.getByToken(input_towers_map_, towersMapBxColl);
0065   e.getByToken(input_trigger_cells_, clustersBxColl);
0066 
0067   towersProcess_->run(inputsColl, *towers_output);
0068 
0069   e.put(std::move(towers_output), towersProcess_->name());
0070 }