6 #include "UCTLayer1.hh"
10 #include "UCTRegion.hh"
11 #include "UCTTower.hh"
13 #include "UCTGeometry.hh"
14 #include "UCTLogging.hh"
16 using namespace l1tcalo;
18 UCTLayer1::UCTLayer1(
int fwv) : uctSummary(0),
fwVersion(fwv) {
20 crates.reserve(
g.getNCrates());
21 for (uint32_t crate = 0; crate <
g.getNCrates(); crate++) {
22 crates.push_back(
new UCTCrate(crate,
fwVersion));
26 UCTLayer1::~UCTLayer1() {
27 for (uint32_t
i = 0;
i < crates.size();
i++) {
28 if (crates[
i] !=
nullptr)
33 bool UCTLayer1::clearEvent() {
34 for (uint32_t
i = 0;
i < crates.size();
i++) {
35 if (crates[
i] !=
nullptr)
36 crates[
i]->clearEvent();
41 const UCTRegion* UCTLayer1::getRegion(
int regionEtaIndex, uint32_t regionPhiIndex)
const {
42 if (regionEtaIndex == 0 || (uint32_t)
std::abs(regionEtaIndex) > NRegionsInCard ||
43 regionPhiIndex >= MaxUCTRegionsPhi) {
48 UCTRegionIndex
r = UCTRegionIndex(regionEtaIndex, regionPhiIndex);
49 UCTTowerIndex
t =
g.getUCTTowerIndex(
r);
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;
59 const UCTCrate* crate = crates[crt];
60 const UCTCard* card = crate->getCard(
t);
61 const UCTRegion*
region = card->getRegion(
r);
65 const UCTTower* UCTLayer1::getTower(
int caloEta,
int caloPhi)
const {
67 LOG_ERROR <<
"UCT::getTower - Negative caloPhi is unacceptable -- bailing" << std::endl;
71 UCTTowerIndex twr = UCTTowerIndex(caloEta, caloPhi);
72 const UCTRegionIndex rgn =
g.getUCTRegionIndex(twr);
73 const UCTRegion*
region = getRegion(rgn);
78 bool UCTLayer1::setECALData(UCTTowerIndex
t,
bool ecalFG, uint32_t ecalET) {
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;
88 UCTCrate* crate = crates[crt];
89 return crate->setECALData(
t, ecalFG, ecalET);
92 bool UCTLayer1::setHCALData(UCTTowerIndex
t, uint32_t hcalFB, uint32_t hcalET) {
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;
102 UCTCrate* crate = crates[crt];
103 return crate->setHCALData(
t, hcalFB, hcalET);
108 for (uint32_t
i = 0;
i < crates.size();
i++) {
109 if (crates[
i] !=
nullptr) {
110 crates[
i]->process();
111 uctSummary += crates[
i]->et();
119 os <<
"UCTLayer1: Summary " <<
l.uctSummary << std::endl;