File indexing completed on 2023-03-17 10:50:23
0001 #include "DataFormats/L1THGCal/interface/HGCalTowerMap.h"
0002 #include "FWCore/Utilities/interface/EDMException.h"
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0005
0006 using namespace l1t;
0007
0008 HGCalTowerMap::HGCalTowerMap(const std::vector<HGCalTowerCoord>& tower_ids, const int layer = 0) : layer_(layer) {
0009 for (auto tower_id : tower_ids) {
0010 towerMap_[tower_id.rawId] = l1t::HGCalTower(0., 0., tower_id.eta, tower_id.phi, tower_id.rawId);
0011 }
0012 }
0013
0014 const HGCalTowerMap& HGCalTowerMap::operator+=(const HGCalTowerMap& map) {
0015 if (nTowers() != map.nTowers()) {
0016 throw edm::Exception(edm::errors::StdException, "StdException")
0017 << "HGCalTowerMap: Trying to add HGCalTowerMaps with different bins: " << nTowers() << " and " << map.nTowers()
0018 << endl;
0019 }
0020
0021 for (const auto& tower : map.towers()) {
0022 auto this_tower = towerMap_.find(tower.first);
0023 if (this_tower == towerMap_.end()) {
0024 throw edm::Exception(edm::errors::StdException, "StdException")
0025 << "HGCalTowerMap: Trying to add HGCalTowerMaps but could not find bin: " << tower.first << endl;
0026 } else {
0027 this_tower->second += tower.second;
0028 }
0029 }
0030 return *this;
0031 }
0032
0033 bool HGCalTowerMap::addEt(short bin_id, float etEm, float etHad) {
0034 auto this_tower = towerMap_.find(bin_id);
0035 if (this_tower == towerMap_.end())
0036 return false;
0037 this_tower->second.addEtEm(etEm);
0038 this_tower->second.addEtHad(etHad);
0039
0040 return true;
0041 }