CMS 3D CMS Logo

UCTLayer1.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 #include <stdlib.h>
4 #include <stdint.h>
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] != 0) delete crates[i];
29  }
30 }
31 
32 bool UCTLayer1::clearEvent() {
33  for(uint32_t i = 0; i < crates.size(); i++) {
34  if(crates[i] != 0) crates[i]->clearEvent();
35  }
36  return true;
37 }
38 
39 const UCTRegion* UCTLayer1::getRegion(int regionEtaIndex, uint32_t regionPhiIndex) const {
40  if(regionEtaIndex == 0 || (uint32_t) std::abs(regionEtaIndex) > NRegionsInCard || regionPhiIndex >= MaxUCTRegionsPhi) {
41  return 0;
42  }
43  // Get (0,0) tower region information
44  UCTGeometry g;
45  UCTRegionIndex r = UCTRegionIndex(regionEtaIndex, regionPhiIndex);
46  UCTTowerIndex t = g.getUCTTowerIndex(r);
47  uint32_t absCaloEta = std::abs(t.first);
48  uint32_t absCaloPhi = std::abs(t.second);
49  uint32_t crt = g.getCrate(absCaloEta, absCaloPhi);
50  if(crt >= crates.size()) {
51  LOG_ERROR << "UCTLayer1::getRegion - Crate number is wrong - " << std::hex << crt
52  << std::dec
53  << " (rEta,rPhi)=(" << regionEtaIndex << ","<< regionPhiIndex << ")"
54  << " (eta,phi)=(" << absCaloEta << ","<< absCaloPhi << ")" << std::endl;
55  exit(1);
56  }
57  const UCTCrate* crate = crates[crt];
58  const UCTCard* card = crate->getCard(t);
59  const UCTRegion* region = card->getRegion(r);
60  return region;
61 }
62 
63 const UCTTower* UCTLayer1::getTower(int caloEta, int caloPhi) const {
64  if(caloPhi < 0) {
65  LOG_ERROR << "UCT::getTower - Negative caloPhi is unacceptable -- bailing" << std::endl;
66  exit(1);
67  }
68  UCTGeometry g;
69  UCTTowerIndex twr = UCTTowerIndex(caloEta, caloPhi);
70  const UCTRegionIndex rgn = g.getUCTRegionIndex(twr);
71  const UCTRegion* region = getRegion(rgn);
72  const UCTTower* tower = region->getTower(twr);
73  return tower;
74 }
75 
76 bool UCTLayer1::setECALData(UCTTowerIndex t, bool ecalFG, uint32_t ecalET) {
77  uint32_t absCaloEta = std::abs(t.first);
78  uint32_t absCaloPhi = std::abs(t.second);
79  UCTGeometry g;
80  uint32_t crt = g.getCrate(absCaloEta, absCaloPhi);
81  if(crt >= crates.size()) {
82  LOG_ERROR << "UCTLayer1::setECALData - Crate number is wrong - " << std::hex << crt << std::dec
83  << " (eta,phi)=(" << absCaloEta << ","<< absCaloPhi << ")" << std::endl;
84  exit(1);
85  }
86  UCTCrate* crate = crates[crt];
87  return crate->setECALData(t, ecalFG, ecalET);
88 }
89 
90 bool UCTLayer1::setHCALData(UCTTowerIndex t, uint32_t hcalFB, uint32_t hcalET) {
91  uint32_t absCaloEta = std::abs(t.first);
92  uint32_t absCaloPhi = std::abs(t.second);
93  UCTGeometry g;
94  uint32_t crt = g.getCrate(absCaloEta, absCaloPhi);
95  if(crt >= crates.size()) {
96  LOG_ERROR << "UCTLayer1::setHCALData - Crate number is wrong - " << std::hex << crt << std::dec
97  << " (eta,phi)=(" << absCaloEta << ","<< absCaloPhi << ")" << std::endl;
98  exit(1);
99  }
100  UCTCrate* crate = crates[crt];
101  return crate->setHCALData(t, hcalFB, hcalET);
102 }
103 
104 bool UCTLayer1::process() {
105  uctSummary = 0;
106  for(uint32_t i = 0; i < crates.size(); i++) {
107  if(crates[i] != 0) {
108  crates[i]->process();
109  uctSummary += crates[i]->et();
110  }
111  }
112 
113  return true;
114 }
115 
116 std::ostream& operator<<(std::ostream& os, const UCTLayer1& l) {
117  os << "UCTLayer1: Summary " << l.uctSummary << std::endl;
118  return os;
119 }
120 
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
std::ostream & operator<<(std::ostream &os, const UCTLayer1 &l)
Definition: UCTLayer1.cc:116
#define LOG_ERROR
Definition: CSCDQM_Logger.h:41