Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-18 08:23:36

0001 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0002 
0003 #include "L1Trigger/L1THGCal/interface/HGCalAlgoWrapperBase.h"
0004 #include "L1Trigger/L1THGCal/interface/backend/HGCalTowerMapImpl_SA.h"
0005 
0006 #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
0007 #include "DataFormats/L1THGCal/interface/HGCalTowerMap.h"
0008 #include "DataFormats/L1THGCal/interface/HGCalTower.h"
0009 
0010 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0011 #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
0012 #include "L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h"
0013 #include "L1Trigger/L1THGCal/interface/backend/HGCalTowerMap3DImpl.h"
0014 
0015 #include "L1Trigger/L1THGCal/interface/backend/HGCalTower_SA.h"
0016 #include "L1Trigger/L1THGCal/interface/backend/HGCalTowerMap_SA.h"
0017 #include "L1Trigger/L1THGCal/interface/backend/HGCalTowerMapsConfig_SA.h"
0018 
0019 class HGCalTowerMapsWrapper : public HGCalTowerMapsWrapperBase {
0020 public:
0021   HGCalTowerMapsWrapper(const edm::ParameterSet& conf);
0022   ~HGCalTowerMapsWrapper() override = default;
0023 
0024   void configure(const std::pair<const HGCalTriggerGeometryBase* const, const edm::ParameterSet&>& parameters) override;
0025 
0026   void process(const std::vector<edm::Ptr<l1t::HGCalTowerMap>>& inputs,
0027                l1t::HGCalTowerBxCollection& outputs) const override;
0028 
0029 private:
0030   void convertCMSSWInputs(const std::vector<edm::Ptr<l1t::HGCalTowerMap>>& inputTowerMaps,
0031                           std::vector<l1thgcfirmware::HGCalTowerMap>& towerMaps_SA) const;
0032   void convertAlgorithmOutputs(const std::vector<l1thgcfirmware::HGCalTower>& towerMaps_SA,
0033                                l1t::HGCalTowerBxCollection& outputTowerMaps) const;
0034 
0035   HGCalTowerMapImplSA theAlgo_;
0036 
0037   std::unique_ptr<l1thgcfirmware::TowerMapsAlgoConfig> theConfiguration_;
0038 };
0039 
0040 HGCalTowerMapsWrapper::HGCalTowerMapsWrapper(const edm::ParameterSet& conf) : HGCalTowerMapsWrapperBase(conf) {}
0041 
0042 void HGCalTowerMapsWrapper::convertCMSSWInputs(const std::vector<edm::Ptr<l1t::HGCalTowerMap>>& inputTowerMaps,
0043                                                std::vector<l1thgcfirmware::HGCalTowerMap>& towerMaps_SA) const {
0044   for (const auto& map : inputTowerMaps) {
0045     std::vector<l1thgcfirmware::HGCalTowerCoord> tower_ids;
0046     for (const auto& tower : map->towers()) {
0047       tower_ids.emplace_back(tower.first, tower.second.eta(), tower.second.phi());
0048     }
0049 
0050     l1thgcfirmware::HGCalTowerMap towerMapSA(tower_ids);
0051 
0052     for (const auto& tower : map->towers()) {
0053       towerMapSA.addEt(tower.first, tower.second.etEm(), tower.second.etHad());
0054     }
0055     towerMaps_SA.emplace_back(towerMapSA);
0056   }
0057 }
0058 
0059 void HGCalTowerMapsWrapper::convertAlgorithmOutputs(const std::vector<l1thgcfirmware::HGCalTower>& towers_SA,
0060                                                     l1t::HGCalTowerBxCollection& outputTowerMaps) const {
0061   for (const auto& towerSA : towers_SA) {
0062     outputTowerMaps.push_back(
0063         0, l1t::HGCalTower(towerSA.etEm(), towerSA.etHad(), towerSA.eta(), towerSA.phi(), towerSA.id()));
0064   }
0065 }
0066 
0067 void HGCalTowerMapsWrapper::process(const std::vector<edm::Ptr<l1t::HGCalTowerMap>>& inputs,
0068                                     l1t::HGCalTowerBxCollection& outputs) const {
0069   std::vector<l1thgcfirmware::HGCalTowerMap> inputs_SA;
0070   convertCMSSWInputs(inputs, inputs_SA);
0071 
0072   std::vector<l1thgcfirmware::HGCalTower> outputs_SA;
0073   theAlgo_.runAlgorithm(inputs_SA, outputs_SA);
0074 
0075   convertAlgorithmOutputs(outputs_SA, outputs);
0076 }
0077 
0078 void HGCalTowerMapsWrapper::configure(
0079     const std::pair<const HGCalTriggerGeometryBase* const, const edm::ParameterSet&>& parameters) {}
0080 
0081 DEFINE_EDM_PLUGIN(HGCalTowerMapsWrapperBaseFactory, HGCalTowerMapsWrapper, "HGCalTowerMapsWrapper");