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 HGCalTowerMapProducer : public edm::stream::EDProducer<> {
0019 public:
0020   HGCalTowerMapProducer(const edm::ParameterSet&);
0021   ~HGCalTowerMapProducer() 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_sums_;
0029   edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;
0030   edm::ESGetToken<HGCalTriggerGeometryBase, CaloGeometryRecord> triggerGeomToken_;
0031   std::unique_ptr<HGCalTowerMapProcessorBase> towersMapProcess_;
0032 };
0033 
0034 DEFINE_FWK_MODULE(HGCalTowerMapProducer);
0035 
0036 HGCalTowerMapProducer::HGCalTowerMapProducer(const edm::ParameterSet& conf)
0037     : input_sums_(consumes<l1t::HGCalTriggerSumsBxCollection>(conf.getParameter<edm::InputTag>("InputTriggerSums"))),
0038       triggerGeomToken_(esConsumes<HGCalTriggerGeometryBase, CaloGeometryRecord, edm::Transition::BeginRun>()) {
0039   //setup TowerMap parameters
0040   const edm::ParameterSet& towerMapParamConfig = conf.getParameterSet("ProcessorParameters");
0041   const std::string& towerMapProcessorName = towerMapParamConfig.getParameter<std::string>("ProcessorName");
0042   towersMapProcess_ = std::unique_ptr<HGCalTowerMapProcessorBase>{
0043       HGCalTowerMapFactory::get()->create(towerMapProcessorName, towerMapParamConfig)};
0044 
0045   produces<l1t::HGCalTowerMapBxCollection>(towersMapProcess_->name());
0046 }
0047 
0048 void HGCalTowerMapProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) {
0049   triggerGeometry_ = es.getHandle(triggerGeomToken_);
0050   towersMapProcess_->setGeometry(triggerGeometry_.product());
0051 }
0052 
0053 void HGCalTowerMapProducer::produce(edm::Event& e, const edm::EventSetup& es) {
0054   // Output collections
0055   auto towersMap_output = std::make_unique<l1t::HGCalTowerMapBxCollection>();
0056 
0057   // Input collections
0058   edm::Handle<l1t::HGCalTriggerSumsBxCollection> trigSumBxColl;
0059 
0060   e.getByToken(input_sums_, trigSumBxColl);
0061 
0062   towersMapProcess_->run(trigSumBxColl, *towersMap_output);
0063 
0064   e.put(std::move(towersMap_output), towersMapProcess_->name());
0065 }