CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
UCTLayer1.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <cstdlib>
4 #include <cstdint>
5 
6 #include "UCTLayer1.hh"
7 
8 #include "UCTCrate.hh"
9 #include "UCTCard.hh"
10 #include "UCTRegion.hh"
11 #include "UCTTower.hh"
12 
13 #include "UCTGeometry.hh"
14 #include "UCTLogging.hh"
15 
16 using namespace l1tcalo;
17 
18 UCTLayer1::UCTLayer1(int fwv) : uctSummary(0), fwVersion(fwv) {
19  UCTGeometry g;
20  crates.reserve(g.getNCrates());
21  for (uint32_t crate = 0; crate < g.getNCrates(); crate++) {
22  crates.push_back(new UCTCrate(crate, fwVersion));
23  }
24 }
25 
26 UCTLayer1::~UCTLayer1() {
27  for (uint32_t i = 0; i < crates.size(); i++) {
28  if (crates[i] != nullptr)
29  delete crates[i];
30  }
31 }
32 
33 bool UCTLayer1::clearEvent() {
34  for (uint32_t i = 0; i < crates.size(); i++) {
35  if (crates[i] != nullptr)
36  crates[i]->clearEvent();
37  }
38  return true;
39 }
40 
41 const UCTRegion* UCTLayer1::getRegion(int regionEtaIndex, uint32_t regionPhiIndex) const {
42  if (regionEtaIndex == 0 || (uint32_t)std::abs(regionEtaIndex) > (NRegionsInCard + NHFRegionsInCard) ||
43  regionPhiIndex >= MaxUCTRegionsPhi) {
44  return nullptr;
45  }
46  // Get (0,0) tower region information
47  UCTGeometry g;
48  UCTRegionIndex r = UCTRegionIndex(regionEtaIndex, regionPhiIndex);
49  UCTTowerIndex t = g.getUCTTowerIndex(r);
50  uint32_t absCaloEta = std::abs(t.first);
51  uint32_t absCaloPhi = std::abs(t.second);
52  uint32_t crt = g.getCrate(absCaloEta, absCaloPhi);
53  if (crt >= crates.size()) {
54  LOG_ERROR << "UCTLayer1::getRegion - Crate number is wrong - " << std::hex << crt << std::dec << " (rEta,rPhi)=("
55  << regionEtaIndex << "," << regionPhiIndex << ")"
56  << " (eta,phi)=(" << absCaloEta << "," << absCaloPhi << ")" << std::endl;
57  exit(1);
58  }
59  const UCTCrate* crate = crates[crt];
60  const UCTCard* card = crate->getCard(t);
61  const UCTRegion* region = card->getRegion(r);
62  return region;
63 }
64 
65 const UCTTower* UCTLayer1::getTower(int caloEta, int caloPhi) const {
66  if (caloPhi < 0) {
67  LOG_ERROR << "UCT::getTower - Negative caloPhi is unacceptable -- bailing" << std::endl;
68  exit(1);
69  }
70  UCTGeometry g;
71  UCTTowerIndex twr = UCTTowerIndex(caloEta, caloPhi);
72  const UCTRegionIndex rgn = g.getUCTRegionIndex(twr);
73  const UCTRegion* region = getRegion(rgn);
74  const UCTTower* tower = region->getTower(twr);
75  return tower;
76 }
77 
78 bool UCTLayer1::setECALData(UCTTowerIndex t, bool ecalFG, uint32_t ecalET) {
79  uint32_t absCaloEta = std::abs(t.first);
80  uint32_t absCaloPhi = std::abs(t.second);
81  UCTGeometry g;
82  uint32_t crt = g.getCrate(absCaloEta, absCaloPhi);
83  if (crt >= crates.size()) {
84  LOG_ERROR << "UCTLayer1::setECALData - Crate number is wrong - " << std::hex << crt << std::dec << " (eta,phi)=("
85  << absCaloEta << "," << absCaloPhi << ")" << std::endl;
86  exit(1);
87  }
88  UCTCrate* crate = crates[crt];
89  return crate->setECALData(t, ecalFG, ecalET);
90 }
91 
92 bool UCTLayer1::setHCALData(UCTTowerIndex t, uint32_t hcalFB, uint32_t hcalET) {
93  uint32_t absCaloEta = std::abs(t.first);
94  uint32_t absCaloPhi = std::abs(t.second);
95  UCTGeometry g;
96  uint32_t crt = g.getCrate(absCaloEta, absCaloPhi);
97  if (crt >= crates.size()) {
98  LOG_ERROR << "UCTLayer1::setHCALData - Crate number is wrong - " << std::hex << crt << std::dec << " (eta,phi)=("
99  << absCaloEta << "," << absCaloPhi << ")" << std::endl;
100  exit(1);
101  }
102  UCTCrate* crate = crates[crt];
103  return crate->setHCALData(t, hcalFB, hcalET);
104 }
105 
106 bool UCTLayer1::process() {
107  uctSummary = 0;
108  for (uint32_t i = 0; i < crates.size(); i++) {
109  if (crates[i] != nullptr) {
110  crates[i]->process();
111  uctSummary += crates[i]->et();
112  }
113  }
114 
115  return true;
116 }
117 
118 std::ostream& operator<<(std::ostream& os, const UCTLayer1& l) {
119  os << "UCTLayer1: Summary " << l.uctSummary << std::endl;
120  return os;
121 }
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
tuple process
Definition: LaserDQM_cfg.py:3
#define LOG_ERROR
Definition: CSCDQM_Logger.h:40