CMS 3D CMS Logo

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

#include <HGCalTowerMap.h>

Public Member Functions

void addTower (int iEta, int iPhi, const l1t::HGCalTower &tower)
 
const vector< double > & etaBins () const
 
 HGCalTowerMap ()
 
 HGCalTowerMap (int nEtaBins, int nPhiBins)
 
 HGCalTowerMap (const std::vector< double > &etaBins, const std::vector< double > &phiBins)
 
int iEta (const double eta) const
 
int iPhi (const double phi) const
 
int layer () const
 
int nEtaBins () const
 
int nPhiBins () const
 
HGCalTowerMapoperator+= (const HGCalTowerMap &map)
 
const vector< double > & phiBins () const
 
void setLayer (const unsigned layer)
 
const l1t::HGCalTowertower (int iEta, int iPhi) const
 
 ~HGCalTowerMap ()
 

Private Member Functions

int bin_id (int iEta, int iPhi) const
 

Private Attributes

vector< double > etaBins_
 
unsigned layer_
 
int nEtaBins_
 
int nPhiBins_
 
vector< double > phiBins_
 
std::unordered_map< int, l1t::HGCalTowertowerMap_
 

Static Private Attributes

static double kEtaMax_ = 3.
 
static double kEtaMaxLoose_ = 3.085
 
static double kEtaMin_ = 1.479
 
static double kEtaMinLoose_ = 1.401
 
static double kPhiMax_ = +M_PI
 
static double kPhiMin_ = -M_PI
 

Detailed Description

Definition at line 14 of file HGCalTowerMap.h.

Constructor & Destructor Documentation

l1t::HGCalTowerMap::HGCalTowerMap ( )
inline

Definition at line 18 of file HGCalTowerMap.h.

References etaBins(), nEtaBins(), nPhiBins(), phiBins(), and ~HGCalTowerMap().

HGCalTowerMap::HGCalTowerMap ( int  nEtaBins,
int  nPhiBins 
)

Definition at line 16 of file HGCalTowerMap.cc.

References stringResolutionProvider_cfi::bin, bin_id(), etaBins_, mps_fire::i, iEta(), iPhi(), kEtaMax_, kEtaMin_, kPhiMax_, kPhiMin_, nEtaBins(), nEtaBins_, nPhiBins(), nPhiBins_, phiBins_, l1t::L1Candidate::setHwEta(), l1t::L1Candidate::setHwPhi(), tower(), and towerMap_.

17 {
18 
21 
22  double eta_step = (kEtaMax_ - kEtaMin_)/nEtaBins_;
23  for(int i=0; i<nEtaBins_; i++) etaBins_.emplace_back( kEtaMin_ + eta_step*i );
24  etaBins_.emplace_back( kEtaMax_ );
25 
26  double phi_step = (kPhiMax_ - kPhiMin_)/nPhiBins_;
27  for(int i=0; i<nPhiBins_; i++) phiBins_.emplace_back( kPhiMin_ + phi_step*i );
28  phiBins_.emplace_back( kPhiMax_ );
29 
30 
31  for(int iEta=-nEtaBins_; iEta<=nEtaBins_; iEta++){
32  if(iEta==0) continue;
33  for(int iPhi=0; iPhi<nPhiBins_; iPhi++){
35  tower.setHwEta(iEta);
36  tower.setHwPhi(iPhi);
37  int bin = bin_id(iEta,iPhi);
38  towerMap_[bin] = tower;
39  }
40  }
41 
42 
43 }
int iPhi(const double phi) const
vector< double > phiBins_
Definition: HGCalTowerMap.h:54
static double kEtaMin_
Definition: HGCalTowerMap.h:44
int nEtaBins() const
Definition: HGCalTowerMap.h:29
std::unordered_map< int, l1t::HGCalTower > towerMap_
Definition: HGCalTowerMap.h:55
static double kEtaMax_
Definition: HGCalTowerMap.h:45
int bin_id(int iEta, int iPhi) const
int iEta(const double eta) const
static double kPhiMax_
Definition: HGCalTowerMap.h:49
static double kPhiMin_
Definition: HGCalTowerMap.h:48
const l1t::HGCalTower & tower(int iEta, int iPhi) const
Definition: HGCalTowerMap.h:33
int nPhiBins() const
Definition: HGCalTowerMap.h:30
bin
set the eta bin as selection string.
void setHwPhi(int phi)
Definition: L1Candidate.h:43
vector< double > etaBins_
Definition: HGCalTowerMap.h:53
void setHwEta(int eta)
Definition: L1Candidate.h:42
HGCalTowerMap::HGCalTowerMap ( const std::vector< double > &  etaBins,
const std::vector< double > &  phiBins 
)

Definition at line 46 of file HGCalTowerMap.cc.

References stringResolutionProvider_cfi::bin, bin_id(), etaBins(), etaBins_, iEta(), iPhi(), nEtaBins_, nPhiBins_, phiBins(), phiBins_, l1t::L1Candidate::setHwEta(), l1t::L1Candidate::setHwPhi(), tower(), and towerMap_.

47 {
48 
49  nEtaBins_ = etaBins.size()-1;
50  nPhiBins_ = phiBins.size()-1;
51  etaBins_ = etaBins;
52  phiBins_ = phiBins;
53 
54  for(int iEta=-nEtaBins_; iEta<=nEtaBins_; iEta++){
55  if(iEta==0) continue;
56  for(int iPhi=0; iPhi<nPhiBins_; iPhi++){
58  tower.setHwEta(iEta);
59  tower.setHwPhi(iPhi);
60  int bin = bin_id(iEta,iPhi);
61  towerMap_[bin] = tower;
62  }
63  }
64 
65 }
int iPhi(const double phi) const
vector< double > phiBins_
Definition: HGCalTowerMap.h:54
const vector< double > & etaBins() const
Definition: HGCalTowerMap.h:31
std::unordered_map< int, l1t::HGCalTower > towerMap_
Definition: HGCalTowerMap.h:55
int bin_id(int iEta, int iPhi) const
int iEta(const double eta) const
const l1t::HGCalTower & tower(int iEta, int iPhi) const
Definition: HGCalTowerMap.h:33
bin
set the eta bin as selection string.
void setHwPhi(int phi)
Definition: L1Candidate.h:43
vector< double > etaBins_
Definition: HGCalTowerMap.h:53
void setHwEta(int eta)
Definition: L1Candidate.h:42
const vector< double > & phiBins() const
Definition: HGCalTowerMap.h:32
HGCalTowerMap::~HGCalTowerMap ( )

Definition at line 68 of file HGCalTowerMap.cc.

Referenced by HGCalTowerMap().

69 {
70 
71 }

Member Function Documentation

void l1t::HGCalTowerMap::addTower ( int  iEta,
int  iPhi,
const l1t::HGCalTower tower 
)
inline

Definition at line 40 of file HGCalTowerMap.h.

References bin_id(), tower(), and towerMap_.

40 { towerMap_[bin_id(iEta,iPhi)] += tower; }
int iPhi(const double phi) const
std::unordered_map< int, l1t::HGCalTower > towerMap_
Definition: HGCalTowerMap.h:55
int bin_id(int iEta, int iPhi) const
int iEta(const double eta) const
const l1t::HGCalTower & tower(int iEta, int iPhi) const
Definition: HGCalTowerMap.h:33
int HGCalTowerMap::bin_id ( int  iEta,
int  iPhi 
) const
private

Definition at line 138 of file HGCalTowerMap.cc.

References Exception, iPhi(), nEtaBins_, nPhiBins_, and edm::errors::StdException.

Referenced by addTower(), HGCalTowerMap(), operator+=(), and tower().

138  {
139 
140  if(iEta==0 || iEta>nEtaBins_ || iEta<-nEtaBins_){
141  throw edm::Exception(edm::errors::StdException, "StdException")
142  << "HGCalTowerMap: Trying to access a bin out of eta range"<<endl;
143  }
144 
145  if(iPhi<0 || iPhi>=nPhiBins_){
146  throw edm::Exception(edm::errors::StdException, "StdException")
147  << "HGCalTowerMap: Trying to access a bin out of phi range"<<endl;
148  }
149 
150  return iEta*nPhiBins_ + iPhi;
151 
152 }
int iPhi(const double phi) const
int iEta(const double eta) const
const vector<double>& l1t::HGCalTowerMap::etaBins ( ) const
inline

Definition at line 31 of file HGCalTowerMap.h.

References etaBins_.

Referenced by HGCalTowerMap(), and operator+=().

31 { return etaBins_; }
vector< double > etaBins_
Definition: HGCalTowerMap.h:53
int HGCalTowerMap::iEta ( const double  eta) const

Definition at line 74 of file HGCalTowerMap.cc.

References PVValHelper::eta, etaBins_, mps_fire::i, kEtaMax_, kEtaMaxLoose_, kEtaMin_, kEtaMinLoose_, and nEtaBins_.

Referenced by HGCalTowerMap(), operator+=(), and tower().

75 {
76 
77  double absEta = fabs(eta);
78  int signEta = eta>0 ? 1 : -1;
79 
80  if(absEta<kEtaMin_){
81  absEta = kEtaMin_;
82  if(absEta<kEtaMinLoose_) edm::LogWarning("HGCalTowerMap") << "WARNING: trying to access towers below min eta range of tower maps eta="<<eta;
83  return signEta;
84  }
85  else if(absEta>kEtaMax_){
86  absEta = kEtaMax_;
87  if(absEta>kEtaMaxLoose_) edm::LogWarning("HGCalTowerMap") << "WARNING: trying to access towers above max eta range of tower maps eta="<<eta;
88  return signEta*nEtaBins_;
89  }
90 
91  for(int i = 0; i<nEtaBins_; i++){
92  if(absEta>=etaBins_[i] && absEta<etaBins_[i+1]){
93  return signEta*(i+1);
94  }
95  }
96 
97  return 0;
98 
99 }
static double kEtaMin_
Definition: HGCalTowerMap.h:44
static double kEtaMax_
Definition: HGCalTowerMap.h:45
static double kEtaMinLoose_
Definition: HGCalTowerMap.h:46
vector< double > etaBins_
Definition: HGCalTowerMap.h:53
static double kEtaMaxLoose_
Definition: HGCalTowerMap.h:47
int HGCalTowerMap::iPhi ( const double  phi) const

Definition at line 102 of file HGCalTowerMap.cc.

References mps_fire::i, normalizedPhi(), nPhiBins_, and phiBins_.

Referenced by bin_id(), HGCalTowerMap(), operator+=(), and tower().

103 {
104 
105  double phi_norm = normalizedPhi(phi);
106 
107  for(int i = 0; i<nPhiBins_; i++){
108  if(phi_norm>=phiBins_[i] && phi_norm<phiBins_[i+1]){
109  return i;
110  }
111  }
112 
113  return -1;
114 
115 }
vector< double > phiBins_
Definition: HGCalTowerMap.h:54
T normalizedPhi(T phi)
Definition: normalizedPhi.h:9
int l1t::HGCalTowerMap::layer ( ) const
inline
int l1t::HGCalTowerMap::nEtaBins ( ) const
inline

Definition at line 29 of file HGCalTowerMap.h.

References nEtaBins_.

Referenced by HGCalTowerMap3DImpl::buildTowerMap3D(), and HGCalTowerMap().

29 { return nEtaBins_; }
int l1t::HGCalTowerMap::nPhiBins ( ) const
inline

Definition at line 30 of file HGCalTowerMap.h.

References nPhiBins_.

Referenced by HGCalTowerMap3DImpl::buildTowerMap3D(), and HGCalTowerMap().

30 { return nPhiBins_; }
HGCalTowerMap & HGCalTowerMap::operator+= ( const HGCalTowerMap map)

Definition at line 118 of file HGCalTowerMap.cc.

References bin_id(), etaBins(), etaBins_, Exception, iEta(), iPhi(), nEtaBins_, nPhiBins_, phiBins(), phiBins_, edm::errors::StdException, tower(), and towerMap_.

Referenced by layer().

118  {
119 
120  if(etaBins_!=map.etaBins() || phiBins_!=map.phiBins()){
121  throw edm::Exception(edm::errors::StdException, "StdException")
122  << "HGCalTowerMap: Trying to add HGCalTowerMaps with different bins"<<endl;
123  }
124 
125  for(int iEta=-nEtaBins_; iEta<=nEtaBins_; iEta++){
126  if(iEta==0) continue;
127  for(int iPhi=0; iPhi<nPhiBins_; iPhi++){
128  towerMap_[bin_id(iEta,iPhi)] += map.tower(iEta,iPhi);
129  }
130  }
131 
132  return *this;
133 
134 }
int iPhi(const double phi) const
vector< double > phiBins_
Definition: HGCalTowerMap.h:54
const vector< double > & etaBins() const
Definition: HGCalTowerMap.h:31
std::unordered_map< int, l1t::HGCalTower > towerMap_
Definition: HGCalTowerMap.h:55
int bin_id(int iEta, int iPhi) const
int iEta(const double eta) const
const l1t::HGCalTower & tower(int iEta, int iPhi) const
Definition: HGCalTowerMap.h:33
vector< double > etaBins_
Definition: HGCalTowerMap.h:53
const vector< double > & phiBins() const
Definition: HGCalTowerMap.h:32
const vector<double>& l1t::HGCalTowerMap::phiBins ( ) const
inline

Definition at line 32 of file HGCalTowerMap.h.

References phiBins_.

Referenced by HGCalTowerMap(), and operator+=().

32 { return phiBins_; }
vector< double > phiBins_
Definition: HGCalTowerMap.h:54
void l1t::HGCalTowerMap::setLayer ( const unsigned  layer)
inline

Definition at line 26 of file HGCalTowerMap.h.

References layer(), and layer_.

26 { layer_ = layer; }
int layer() const
Definition: HGCalTowerMap.h:37
const l1t::HGCalTower& l1t::HGCalTowerMap::tower ( int  iEta,
int  iPhi 
) const
inline

Definition at line 33 of file HGCalTowerMap.h.

References bin_id(), PVValHelper::eta, iEta(), iPhi(), and towerMap_.

Referenced by addTower(), HGCalTowerMap3DImpl::buildTowerMap3D(), HGCalTowerMap(), and operator+=().

33 { return towerMap_.at(bin_id(iEta,iPhi)); }
int iPhi(const double phi) const
std::unordered_map< int, l1t::HGCalTower > towerMap_
Definition: HGCalTowerMap.h:55
int bin_id(int iEta, int iPhi) const
int iEta(const double eta) const

Member Data Documentation

vector<double> l1t::HGCalTowerMap::etaBins_
private

Definition at line 53 of file HGCalTowerMap.h.

Referenced by etaBins(), HGCalTowerMap(), iEta(), and operator+=().

double HGCalTowerMap::kEtaMax_ = 3.
staticprivate

Definition at line 45 of file HGCalTowerMap.h.

Referenced by HGCalTowerMap(), and iEta().

double HGCalTowerMap::kEtaMaxLoose_ = 3.085
staticprivate

Definition at line 47 of file HGCalTowerMap.h.

Referenced by iEta().

double HGCalTowerMap::kEtaMin_ = 1.479
staticprivate

Definition at line 44 of file HGCalTowerMap.h.

Referenced by HGCalTowerMap(), and iEta().

double HGCalTowerMap::kEtaMinLoose_ = 1.401
staticprivate

Definition at line 46 of file HGCalTowerMap.h.

Referenced by iEta().

double HGCalTowerMap::kPhiMax_ = +M_PI
staticprivate

Definition at line 49 of file HGCalTowerMap.h.

Referenced by HGCalTowerMap().

double HGCalTowerMap::kPhiMin_ = -M_PI
staticprivate

Definition at line 48 of file HGCalTowerMap.h.

Referenced by HGCalTowerMap().

unsigned l1t::HGCalTowerMap::layer_
private

Definition at line 56 of file HGCalTowerMap.h.

Referenced by layer(), and setLayer().

int l1t::HGCalTowerMap::nEtaBins_
private

Definition at line 51 of file HGCalTowerMap.h.

Referenced by bin_id(), HGCalTowerMap(), iEta(), nEtaBins(), and operator+=().

int l1t::HGCalTowerMap::nPhiBins_
private

Definition at line 52 of file HGCalTowerMap.h.

Referenced by bin_id(), HGCalTowerMap(), iPhi(), nPhiBins(), and operator+=().

vector<double> l1t::HGCalTowerMap::phiBins_
private

Definition at line 54 of file HGCalTowerMap.h.

Referenced by HGCalTowerMap(), iPhi(), operator+=(), and phiBins().

std::unordered_map<int,l1t::HGCalTower> l1t::HGCalTowerMap::towerMap_
private

Definition at line 55 of file HGCalTowerMap.h.

Referenced by addTower(), HGCalTowerMap(), operator+=(), and tower().