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 #include "FWCore/Utilities/interface/ESGetToken.h"
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 HGCalVFEProducer : public edm::stream::EDProducer<> {
0019 public:
0020   HGCalVFEProducer(const edm::ParameterSet&);
0021   ~HGCalVFEProducer() 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 inputee_, inputfh_, inputbh_;
0029   edm::ESHandle<HGCalTriggerGeometryBase> triggerGeometry_;
0030   edm::ESGetToken<HGCalTriggerGeometryBase, CaloGeometryRecord> triggerGeomToken_;
0031   std::unique_ptr<HGCalVFEProcessorBase> vfeProcess_;
0032 };
0033 
0034 DEFINE_FWK_MODULE(HGCalVFEProducer);
0035 
0036 HGCalVFEProducer::HGCalVFEProducer(const edm::ParameterSet& conf)
0037     : inputee_(consumes<HGCalDigiCollection>(conf.getParameter<edm::InputTag>("eeDigis"))),
0038       inputfh_(consumes<HGCalDigiCollection>(conf.getParameter<edm::InputTag>("fhDigis"))),
0039       inputbh_(consumes<HGCalDigiCollection>(conf.getParameter<edm::InputTag>("bhDigis"))),
0040       triggerGeomToken_(esConsumes<HGCalTriggerGeometryBase, CaloGeometryRecord, edm::Transition::BeginRun>()) {
0041   // setup VFE parameters
0042   const edm::ParameterSet& vfeParamConfig = conf.getParameterSet("ProcessorParameters");
0043   const std::string& vfeProcessorName = vfeParamConfig.getParameter<std::string>("ProcessorName");
0044   vfeProcess_ = std::unique_ptr<HGCalVFEProcessorBase>{
0045       HGCalVFEProcessorBaseFactory::get()->create(vfeProcessorName, vfeParamConfig)};
0046 
0047   produces<l1t::HGCalTriggerCellBxCollection>(vfeProcess_->name());
0048 }
0049 
0050 void HGCalVFEProducer::beginRun(const edm::Run& /*run*/, const edm::EventSetup& es) {
0051   triggerGeometry_ = es.getHandle(triggerGeomToken_);
0052   vfeProcess_->setGeometry(triggerGeometry_.product());
0053 }
0054 
0055 void HGCalVFEProducer::produce(edm::Event& e, const edm::EventSetup& es) {
0056   // Output collection
0057   auto vfe_trigcell_output = std::make_unique<l1t::HGCalTriggerCellBxCollection>();
0058 
0059   // Input collections
0060   edm::Handle<HGCalDigiCollection> ee_digis_h;
0061   edm::Handle<HGCalDigiCollection> fh_digis_h;
0062   edm::Handle<HGCalDigiCollection> bh_digis_h;
0063 
0064   e.getByToken(inputee_, ee_digis_h);
0065   e.getByToken(inputfh_, fh_digis_h);
0066   e.getByToken(inputbh_, bh_digis_h);
0067 
0068   // Processing DigiCollections and putting the results into the HGCalTriggerCellBxCollectio
0069   if (ee_digis_h.isValid()) {
0070     const HGCalDigiCollection& ee_digis = *ee_digis_h;
0071     vfeProcess_->run(ee_digis, *vfe_trigcell_output);
0072   }
0073 
0074   if (fh_digis_h.isValid()) {
0075     const HGCalDigiCollection& fh_digis = *fh_digis_h;
0076     vfeProcess_->run(fh_digis, *vfe_trigcell_output);
0077   }
0078 
0079   if (bh_digis_h.isValid()) {
0080     const HGCalDigiCollection& bh_digis = *bh_digis_h;
0081     vfeProcess_->run(bh_digis, *vfe_trigcell_output);
0082   }
0083 
0084   // Put in the event
0085   e.put(std::move(vfe_trigcell_output), vfeProcess_->name());
0086 }