CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
l1t::HGCalTowerMap Class Reference

#include <HGCalTowerMap.h>

Public Member Functions

bool addEt (const std::unordered_map< unsigned short, float > &towerIDandShares, float etEm, float etHad)
 
 HGCalTowerMap ()
 
 HGCalTowerMap (const std::vector< l1t::HGCalTowerCoord > &tower_ids, const int layer)
 
int layer () const
 
unsigned nTowers () const
 
const HGCalTowerMapoperator+= (const HGCalTowerMap &map)
 
const std::unordered_map< unsigned short, l1t::HGCalTower > & towers () const
 

Private Attributes

unsigned layer_
 
std::unordered_map< unsigned short, l1t::HGCalTowertowerMap_
 

Detailed Description

Definition at line 15 of file HGCalTowerMap.h.

Constructor & Destructor Documentation

◆ HGCalTowerMap() [1/2]

l1t::HGCalTowerMap::HGCalTowerMap ( )
inline

Definition at line 17 of file HGCalTowerMap.h.

17 : layer_(0) {}

◆ HGCalTowerMap() [2/2]

HGCalTowerMap::HGCalTowerMap ( const std::vector< l1t::HGCalTowerCoord > &  tower_ids,
const int  layer = 0 
)

Definition at line 8 of file HGCalTowerMap.cc.

References towerMap_.

8  : layer_(layer) {
9  for (auto tower_id : tower_ids) {
10  towerMap_[tower_id.rawId] = l1t::HGCalTower(0., 0., tower_id.eta, tower_id.phi, tower_id.rawId);
11  }
12 }
int layer() const
Definition: HGCalTowerMap.h:21
std::unordered_map< unsigned short, l1t::HGCalTower > towerMap_
Definition: HGCalTowerMap.h:31

Member Function Documentation

◆ addEt()

bool HGCalTowerMap::addEt ( const std::unordered_map< unsigned short, float > &  towerIDandShares,
float  etEm,
float  etHad 
)

Definition at line 33 of file HGCalTowerMap.cc.

References towerMap_.

33  {
34  for (const auto& towerIDandShare : towerIDandShares) {
35  auto this_tower = towerMap_.find(towerIDandShare.first);
36  if (this_tower == towerMap_.end())
37  return false;
38  this_tower->second.addEtEm(etEm * towerIDandShare.second);
39  this_tower->second.addEtHad(etHad * towerIDandShare.second);
40  }
41  return true;
42 }
std::unordered_map< unsigned short, l1t::HGCalTower > towerMap_
Definition: HGCalTowerMap.h:31

◆ layer()

int l1t::HGCalTowerMap::layer ( ) const
inline

◆ nTowers()

unsigned l1t::HGCalTowerMap::nTowers ( ) const
inline

Definition at line 27 of file HGCalTowerMap.h.

References towerMap_.

Referenced by operator+=().

27 { return towerMap_.size(); }
std::unordered_map< unsigned short, l1t::HGCalTower > towerMap_
Definition: HGCalTowerMap.h:31

◆ operator+=()

const HGCalTowerMap & HGCalTowerMap::operator+= ( const HGCalTowerMap map)

Definition at line 14 of file HGCalTowerMap.cc.

References Exception, genParticles_cff::map, nTowers(), edm::errors::StdException, l1tHGCalTowerProducer_cfi::tower, and towerMap_.

14  {
15  if (nTowers() != map.nTowers()) {
16  throw edm::Exception(edm::errors::StdException, "StdException")
17  << "HGCalTowerMap: Trying to add HGCalTowerMaps with different bins: " << nTowers() << " and " << map.nTowers()
18  << endl;
19  }
20 
21  for (const auto& tower : map.towers()) {
22  auto this_tower = towerMap_.find(tower.first);
23  if (this_tower == towerMap_.end()) {
24  throw edm::Exception(edm::errors::StdException, "StdException")
25  << "HGCalTowerMap: Trying to add HGCalTowerMaps but could not find bin: " << tower.first << endl;
26  } else {
27  this_tower->second += tower.second;
28  }
29  }
30  return *this;
31 }
unsigned nTowers() const
Definition: HGCalTowerMap.h:27
std::unordered_map< unsigned short, l1t::HGCalTower > towerMap_
Definition: HGCalTowerMap.h:31

◆ towers()

const std::unordered_map<unsigned short, l1t::HGCalTower>& l1t::HGCalTowerMap::towers ( ) const
inline

Definition at line 28 of file HGCalTowerMap.h.

References towerMap_.

Referenced by HGCalTowerMap3DImpl::buildTowerMap3D().

28 { return towerMap_; }
std::unordered_map< unsigned short, l1t::HGCalTower > towerMap_
Definition: HGCalTowerMap.h:31

Member Data Documentation

◆ layer_

unsigned l1t::HGCalTowerMap::layer_
private

Definition at line 32 of file HGCalTowerMap.h.

Referenced by layer().

◆ towerMap_

std::unordered_map<unsigned short, l1t::HGCalTower> l1t::HGCalTowerMap::towerMap_
private

Definition at line 31 of file HGCalTowerMap.h.

Referenced by addEt(), HGCalTowerMap(), nTowers(), operator+=(), and towers().