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 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 
0008 #include "DataFormats/HGCDigi/interface/HGCDigiCollections.h"
0009 #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.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 HFNoseVFEProducer : public edm::stream::EDProducer<> {
0019 public:
0020   HFNoseVFEProducer(const edm::ParameterSet&);
0021   ~HFNoseVFEProducer() 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 inputnose_;
0029   edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;
0030   edm::ESGetToken<HGCalTriggerGeometryBase, CaloGeometryRecord> triggerGeomToken_;
0031 
0032   std::unique_ptr<HGCalVFEProcessorBase> vfeProcess_;
0033 };
0034 
0035 DEFINE_FWK_MODULE(HFNoseVFEProducer);
0036 
0037 HFNoseVFEProducer::HFNoseVFEProducer(const edm::ParameterSet& conf)
0038     : inputnose_(consumes<HGCalDigiCollection>(conf.getParameter<edm::InputTag>("noseDigis"))),
0039       triggerGeomToken_(esConsumes<HGCalTriggerGeometryBase, CaloGeometryRecord, edm::Transition::BeginRun>()) {
0040   // setup VFE parameters
0041   const edm::ParameterSet& vfeParamConfig = conf.getParameterSet("ProcessorParameters");
0042   const std::string& vfeProcessorName = vfeParamConfig.getParameter<std::string>("ProcessorName");
0043   vfeProcess_ = std::unique_ptr<HGCalVFEProcessorBase>{
0044       HGCalVFEProcessorBaseFactory::get()->create(vfeProcessorName, vfeParamConfig)};
0045 
0046   produces<l1t::HGCalTriggerCellBxCollection>(vfeProcess_->name());
0047 }
0048 
0049 void HFNoseVFEProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) {
0050   triggerGeometry_ = es.getHandle(triggerGeomToken_);
0051   vfeProcess_->setGeometry(triggerGeometry_.product());
0052 }
0053 
0054 void HFNoseVFEProducer::produce(edm::Event& e, const edm::EventSetup& es) {
0055   // Output collection
0056   auto vfe_trigcell_output = std::make_unique<l1t::HGCalTriggerCellBxCollection>();
0057 
0058   edm::Handle<HGCalDigiCollection> nose_digis_h;
0059   e.getByToken(inputnose_, nose_digis_h);
0060 
0061   if (nose_digis_h.isValid()) {
0062     const HGCalDigiCollection& nose_digis = *nose_digis_h;
0063     vfeProcess_->run(nose_digis, *vfe_trigcell_output);
0064   }
0065 
0066   // Put in the event
0067   e.put(std::move(vfe_trigcell_output), vfeProcess_->name());
0068 }