CMS 3D CMS Logo

HGCalTowerMap.cc
Go to the documentation of this file.
5 
6 using namespace l1t;
7 
8 HGCalTowerMap::HGCalTowerMap(const std::vector<HGCalTowerCoord>& tower_ids,
9  const int layer=0) : layer_(layer) {
10  for(auto tower_id: tower_ids) {
11  towerMap_[tower_id.rawId] = l1t::HGCalTower(0., 0., tower_id.eta, tower_id.phi, tower_id.rawId);
12  }
13 }
14 
15 
16 
18  if (nTowers() != map.nTowers()) {
19  throw edm::Exception(edm::errors::StdException, "StdException")
20  << "HGCalTowerMap: Trying to add HGCalTowerMaps with different bins: " << nTowers() << " and " << map.nTowers() <<endl;
21  }
22 
23  for(auto tower: map.towers()) {
24  auto this_tower = towerMap_.find(tower.first);
25  if(this_tower == towerMap_.end()) {
26  throw edm::Exception(edm::errors::StdException, "StdException")
27  << "HGCalTowerMap: Trying to add HGCalTowerMaps but could not find bin: " << tower.first <<endl;
28  } else {
29  this_tower->second+=tower.second;
30  }
31 
32  }
33  return *this;
34 }
35 
36 
37 bool HGCalTowerMap::addEt(short bin_id, float etEm, float etHad) {
38  auto this_tower = towerMap_.find(bin_id);
39  if(this_tower == towerMap_.end()) return false;
40  this_tower->second.addEtEm(etEm);
41  this_tower->second.addEtHad(etHad);
42 
43  return true;
44 }
static const char layer_[]
const std::unordered_map< unsigned short, l1t::HGCalTower > & towers() const
Definition: HGCalTowerMap.h:30
bool addEt(short bin_id, float etEm, float etHad)
delete x;
Definition: CaloConfig.h:22
const HGCalTowerMap & operator+=(const HGCalTowerMap &map)
std::unordered_map< unsigned short, l1t::HGCalTower > towerMap_
Definition: HGCalTowerMap.h:35
unsigned nTowers() const
Definition: HGCalTowerMap.h:29