10 #include "UCTRegion.hh"
12 #include "UCTGeometry.hh"
13 #include "UCTLogging.hh"
15 #include "UCTTower.hh"
17 using namespace l1tcalo;
29 bool vetoBit(bitset<4> etaPattern, bitset<4> phiPattern) {
30 bitset<4> badPattern5(
string(
"0101"));
31 bitset<4> badPattern7(
string(
"0111"));
32 bitset<4> badPattern9(
string(
"1001"));
33 bitset<4> badPattern10(
string(
"1010"));
34 bitset<4> badPattern11(
string(
"1011"));
35 bitset<4> badPattern13(
string(
"1101"));
36 bitset<4> badPattern14(
string(
"1110"));
37 bitset<4> badPattern15(
string(
"1111"));
41 if (etaPattern != badPattern5 && etaPattern != badPattern7 && etaPattern != badPattern10 &&
42 etaPattern != badPattern11 && etaPattern != badPattern13 && etaPattern != badPattern14 &&
43 etaPattern != badPattern15 && phiPattern != badPattern5 &&
45 phiPattern != badPattern10 && phiPattern != badPattern11 && phiPattern != badPattern13 &&
47 etaPattern != badPattern9 && phiPattern != badPattern9) {
54 uint32_t etSum =
et[0] +
et[1] +
et[2] +
et[3];
55 uint32_t iEtSum = (
et[0] >> 1) +
56 (
et[1] >> 1) +
et[1] +
57 (
et[2] >> 1) + (
et[2] << 1) +
58 (
et[3] << 2) - (
et[3] >> 1);
59 uint32_t iAve = 0xDEADBEEF;
62 else if (iEtSum <= (etSum << 1))
64 else if (iEtSum <= (etSum + (etSum << 1)))
71 UCTRegion::UCTRegion(uint32_t crt, uint32_t crd,
bool ne, uint32_t rgn,
int fwv)
72 : crate(crt), card(crd),
region(rgn), negativeEta(ne), regionSummary(0),
fwVersion(fwv) {
78 for (uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
84 UCTRegion::~UCTRegion() {
85 for (uint32_t
i = 0;
i <
towers.size();
i++) {
91 const UCTTower* UCTRegion::getTower(uint32_t caloEta, uint32_t caloPhi)
const {
94 uint32_t
iEta =
g.getiEta(caloEta);
95 uint32_t iPhi =
g.getiPhi(caloPhi);
107 uint32_t regionET = 0;
108 uint32_t regionEcalET = 0;
109 for (uint32_t twr = 0; twr <
towers.size(); twr++) {
111 LOG_ERROR <<
"Tower level processing failed. Bailing out :(" << std::endl;
114 regionET +=
towers[twr]->et();
116 regionEcalET +=
towers[twr]->getEcalET();
118 if (regionET > RegionETMask) {
121 regionET = RegionETMask;
123 regionSummary = (RegionETMask & regionET);
124 if (regionEcalET > RegionETMask)
125 regionEcalET = RegionETMask;
129 if (
region < NRegionsInCard) {
134 uint32_t nActiveTowers = 0;
135 uint32_t activeTowerET = 0;
136 for (uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
139 if (towerET > activityLevel) {
140 activeTower[
iEta][iPhi] =
true;
144 activeTower[
iEta][iPhi] =
false;
147 if (activeTowerET > RegionETMask)
148 activeTowerET = RegionETMask;
150 uint32_t sumETIEta[4] = {0, 0, 0, 0};
152 for (uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
154 sumETIEta[
iEta] += towerET;
158 uint32_t sumETIPhi[4] = {0, 0, 0, 0};
159 for (uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
162 sumETIPhi[iPhi] += towerET;
166 uint32_t hitTowerLocation = hitIEta *
nPhi + hitIPhi;
168 bitset<4> activeTowerEtaPattern = 0;
170 bool activeStrip =
false;
171 for (uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
172 if (activeTower[
iEta][iPhi])
176 activeTowerEtaPattern |= (0x1 <<
iEta);
178 bitset<4> activeTowerPhiPattern = 0;
179 for (uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
180 bool activeStrip =
false;
182 if (activeTower[
iEta][iPhi])
186 activeTowerPhiPattern |= (0x1 << iPhi);
189 bool veto =
vetoBit(activeTowerEtaPattern, activeTowerPhiPattern);
194 if ((regionET - regionEcalET) > maxMiscActivityLevelForEG)
196 if ((regionET - activeTowerET) > maxMiscActivityLevelForTau)
200 regionSummary |= RegionEGVeto;
202 regionSummary |= RegionTauVeto;
204 regionSummary |= (hitTowerLocation << LocationShift);
209 regionSummary |= NegEtaBit;
210 regionSummary |= (
region << RegionNoShift);
211 regionSummary |= (card << CardNoShift);
212 regionSummary |= (crate << CrateNoShift);
218 bool UCTRegion::clearEvent() {
220 for (uint32_t
i = 0;
i <
towers.size();
i++) {
227 bool UCTRegion::setECALData(UCTTowerIndex
t,
bool ecalFG, uint32_t ecalET) {
230 uint32_t absCaloEta =
abs(
t.first);
231 uint32_t absCaloPhi =
abs(
t.second);
232 uint32_t
iEta =
g.getiEta(absCaloEta);
233 uint32_t iPhi =
g.getiPhi(absCaloPhi);
235 return tower->setECALData(ecalFG, ecalET);
238 bool UCTRegion::setHCALData(UCTTowerIndex
t, uint32_t hcalFB, uint32_t hcalET) {
241 uint32_t absCaloEta =
abs(
t.first);
242 uint32_t absCaloPhi =
abs(
t.second);
243 uint32_t
iEta =
g.getiEta(absCaloEta);
244 uint32_t iPhiStart =
g.getiPhi(absCaloPhi);
245 if (absCaloEta > 29 && absCaloEta < 40) {
248 for (uint32_t iPhi = iPhiStart; iPhi < iPhiStart + 2; iPhi++) {
251 if (!
tower->setHFData(hcalFB, hcalET))
254 }
else if (absCaloEta == 40 || absCaloEta == 41) {
257 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
260 if (!
tower->setHFData(hcalFB, hcalET))
264 uint32_t iPhi =
g.getiPhi(absCaloPhi);
266 return tower->setHCALData(hcalFB, hcalET);
271 bool UCTRegion::setRegionSummary(uint16_t regionData) {
273 regionSummary = regionData;
279 os <<
"UCTRegion Summary for negative eta " <<
r.region <<
" HitTower (eta, phi) = (" <<
std::dec <<
r.hitCaloEta()
280 <<
", " <<
r.hitCaloPhi() <<
")"
281 <<
" summary = " << std::hex <<
r.regionSummary << std::endl;
283 os <<
"UCTRegion Summary for positive eta " <<
r.region <<
" HitTower (eta, phi) = (" <<
std::dec <<
r.hitCaloEta()
284 <<
", " <<
r.hitCaloPhi() <<
")"
285 <<
" summary = " << std::hex <<
r.regionSummary << std::endl;