Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-08 22:26:31

0001 #include "L1Trigger/L1THGCal/interface/HGCalProcessorBase.h"
0002 
0003 #include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
0004 #include "DataFormats/L1THGCal/interface/HGCalTowerMap.h"
0005 #include "DataFormats/L1THGCal/interface/HGCalTower.h"
0006 
0007 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0008 #include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
0009 #include "L1Trigger/L1THGCal/interface/backend/HGCalTowerMap2DImpl.h"
0010 #include "L1Trigger/L1THGCal/interface/backend/HGCalTowerMap3DImpl.h"
0011 
0012 class HGCalTowerProcessor : public HGCalTowerProcessorBase {
0013 public:
0014   HGCalTowerProcessor(const edm::ParameterSet& conf) : HGCalTowerProcessorBase(conf) {
0015     includeTrigCells_ = conf.getParameter<bool>("includeTrigCells"),
0016     towermap2D_ = std::make_unique<HGCalTowerMap2DImpl>(conf.getParameterSet("towermap_parameters"));
0017     towermap3D_ = std::make_unique<HGCalTowerMap3DImpl>();
0018   }
0019 
0020   void setGeometry(const HGCalTriggerGeometryBase* const geom) override {
0021     HGCalTowerProcessorBase::setGeometry(geom);
0022     towermap2D_->setGeometry(geom);
0023   }
0024 
0025   void run(const std::pair<edm::Handle<l1t::HGCalTowerMapBxCollection>, edm::Handle<l1t::HGCalClusterBxCollection>>&
0026                collHandle,
0027            l1t::HGCalTowerBxCollection& collTowers) override {
0028     auto& towerMapCollHandle = collHandle.first;
0029     auto& unclTCsCollHandle = collHandle.second;
0030 
0031     /* create a persistent vector of pointers to the towerMaps */
0032     std::vector<edm::Ptr<l1t::HGCalTowerMap>> towerMapsPtrs;
0033     for (unsigned i = 0; i < towerMapCollHandle->size(); ++i) {
0034       towerMapsPtrs.emplace_back(towerMapCollHandle, i);
0035     }
0036 
0037     if (includeTrigCells_) {
0038       /* create additional TowerMaps from the unclustered TCs */
0039 
0040       // translate our HGCalClusters into HGCalTriggerCells
0041       std::vector<edm::Ptr<l1t::HGCalTriggerCell>> trigCellVec;
0042       for (unsigned i = 0; i < unclTCsCollHandle->size(); ++i) {
0043         edm::Ptr<l1t::HGCalCluster> ptr(unclTCsCollHandle, i);
0044         for (const auto& itTC : ptr->constituents()) {
0045           trigCellVec.push_back(itTC.second);
0046         }
0047       }
0048 
0049       // fill the TowerMaps with the HGCalTriggersCells
0050       l1t::HGCalTowerMapBxCollection towerMapsFromUnclTCs;
0051       towermap2D_->buildTowerMap2D(trigCellVec, towerMapsFromUnclTCs);
0052 
0053       /* merge the two sets of TowerMaps */
0054       unsigned int towerMapsPtrsSize = towerMapsPtrs.size();
0055       for (unsigned int i = 0; i < towerMapsFromUnclTCs.size(); ++i) {
0056         towerMapsPtrs.emplace_back(&(towerMapsFromUnclTCs[i]), i + towerMapsPtrsSize);
0057       }
0058 
0059       /* call to towerMap3D clustering */
0060       towermap3D_->buildTowerMap3D(towerMapsPtrs, collTowers);
0061     } else {
0062       /* call to towerMap3D clustering */
0063       towermap3D_->buildTowerMap3D(towerMapsPtrs, collTowers);
0064     }
0065   }
0066 
0067 private:
0068   bool includeTrigCells_;
0069 
0070   /* algorithms instances */
0071   std::unique_ptr<HGCalTowerMap2DImpl> towermap2D_;
0072   std::unique_ptr<HGCalTowerMap3DImpl> towermap3D_;
0073 };
0074 
0075 DEFINE_EDM_PLUGIN(HGCalTowerFactory, HGCalTowerProcessor, "HGCalTowerProcessor");