CMS 3D CMS Logo

HGCalTowerMap2DImpl.cc
Go to the documentation of this file.
1 
9 
11 
12 
13 
15  nEtaBins_(conf.getParameter<int>("nEtaBins")),
16  nPhiBins_(conf.getParameter<int>("nPhiBins")),
17  etaBins_(conf.getParameter<std::vector<double> >("etaBins")),
18  phiBins_(conf.getParameter<std::vector<double> >("phiBins")),
19  useLayerWeights_(conf.getParameter<bool>("useLayerWeights")),
20  layerWeights_(conf.getParameter< std::vector<double> >("layerWeights"))
21 {
22  edm::LogInfo("HGCalTowerMap2DImpl") << "Number of eta bins for the tower maps: " << nEtaBins_<<endl;
23  edm::LogInfo("HGCalTowerMap2DImpl") << "Number of phi bins for the tower maps: " << nPhiBins_<<endl;
24 
25  if(!etaBins_.empty() && int(etaBins_.size())!=nEtaBins_+1){
26  throw edm::Exception(edm::errors::Configuration, "Configuration")
27  << "HGCalTowerMap2DImpl nEtaBins for the tower map not consistent with etaBins size"<<endl;
28  }
29  if(!phiBins_.empty() && int(phiBins_.size())!=nPhiBins_+1){
30  throw edm::Exception(edm::errors::Configuration, "Configuration")
31  << "HGCalTowerMap2DImpl nPhiBins for the tower map not consistent with phiBins size"<<endl;
32  }
33 
34 
35  std::vector<l1t::HGCalTowerMap> towerMaps = newTowerMaps();
36  edm::LogInfo("HGCalTowerMap2DImpl") << "Eta bins for the tower maps: {";
37  for(auto eta : towerMaps[0].etaBins()) edm::LogInfo("HGCalTowerMap2DImpl") << eta << ",";
38  edm::LogInfo("HGCalTowerMap2DImpl") << "}" <<endl;
39  edm::LogInfo("HGCalTowerMap2DImpl") << "Phi bins for the tower maps: {";
40  for(auto phi : towerMaps[0].phiBins()) edm::LogInfo("HGCalTowerMap2DImpl") << phi << ",";
41  edm::LogInfo("HGCalTowerMap2DImpl") << "}" <<endl;
42 
43 }
44 
45 
46 std::vector<l1t::HGCalTowerMap> HGCalTowerMap2DImpl::newTowerMaps(){
47 
48  //If no custom binning specified, assume uniform one
50  if(etaBins_.empty() || phiBins_.empty()){
52  map = mapTmp;
53  }
54  else{
56  map = mapTmp;
57  }
58 
59  std::vector<l1t::HGCalTowerMap> towerMaps(max(triggerTools_.lastLayerBH(),unsigned(1)),map); //Always create at least 1 towerMap
60  for(unsigned layer=0; layer<triggerTools_.lastLayerBH(); layer++) towerMaps[layer].setLayer(layer+1);
61  return towerMaps;
62 
63 }
64 
65 
66 
67 
68 void HGCalTowerMap2DImpl::buildTowerMap2D(const std::vector<edm::Ptr<l1t::HGCalTriggerCell>> & triggerCellsPtrs,
70  ){
71 
72  std::vector<l1t::HGCalTowerMap> towerMapsTmp = newTowerMaps();
73 
74  for(const auto& tc : triggerCellsPtrs){
75 
76  unsigned layer = triggerTools_.layerWithOffset(tc->detId());
77  int iEta = towerMapsTmp[layer-1].iEta(tc->eta());
78  int iPhi = towerMapsTmp[layer-1].iPhi(tc->phi());
79 
80  double calibPt = tc->pt();
81  if(useLayerWeights_) calibPt = layerWeights_[layer]*(tc->mipPt());
83  tc->eta(),
84  tc->phi(),
85  0. );
86 
87  double etEm = layer<=triggerTools_.lastLayerEE() ? calibPt : 0;
88  double etHad = layer>triggerTools_.lastLayerEE() ? calibPt : 0;
89 
90  l1t::HGCalTower tower;
91  tower.setP4(p4);
92  tower.setEtEm(etEm);
93  tower.setEtHad(etHad);
94  tower.setHwEta(iEta);
95  tower.setHwPhi(iPhi);
96 
97  towerMapsTmp[layer-1].addTower(iEta,iPhi,tower);
98 
99  }
100 
101  /* store towerMaps in the persistent collection */
102  towerMaps.resize(0, triggerTools_.lastLayerBH());
103  int i=0;
104  for(auto towerMap : towerMapsTmp){
105  towerMaps.set( 0, i, towerMap);
106  i++;
107  }
108 
109 
110 }
111 
112 
113 
void setEtEm(double et)
Definition: HGCalTower.cc:31
unsigned lastLayerEE() const
std::vector< double > layerWeights_
std::vector< l1t::HGCalTowerMap > newTowerMaps()
HGCalTriggerTools triggerTools_
unsigned layerWithOffset(const DetId &) const
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
double p4[4]
Definition: TauolaWrapper.h:92
void buildTowerMap2D(const std::vector< edm::Ptr< l1t::HGCalTriggerCell >> &triggerCellsPtrs, l1t::HGCalTowerMapBxCollection &towermaps)
unsigned lastLayerBH() const
void set(int bx, unsigned i, const T &object)
void setHwPhi(int phi)
Definition: L1Candidate.h:43
void resize(int bx, unsigned size)
std::vector< double > etaBins_
void setHwEta(int eta)
Definition: L1Candidate.h:42
HGCalTowerMap2DImpl(const edm::ParameterSet &conf)
void setEtHad(double et)
Definition: HGCalTower.cc:36
std::vector< double > phiBins_
void setP4(const LorentzVector &p4) final
set 4-momentum