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) {
31 bitset<4> badPattern5(
string(
"0101"));
32 bitset<4> badPattern7(
string(
"0111"));
33 bitset<4> badPattern9(
string(
"1001"));
34 bitset<4> badPattern10(
string(
"1010"));
35 bitset<4> badPattern11(
string(
"1011"));
36 bitset<4> badPattern13(
string(
"1101"));
37 bitset<4> badPattern14(
string(
"1110"));
38 bitset<4> badPattern15(
string(
"1111"));
42 if(etaPattern != badPattern5 && etaPattern != badPattern7 &&
43 etaPattern != badPattern10 && etaPattern != badPattern11 &&
44 etaPattern != badPattern13 && etaPattern != badPattern14 &&
45 etaPattern != badPattern15 && phiPattern != badPattern5 &&
46 phiPattern != badPattern7 && phiPattern != badPattern10 &&
47 phiPattern != badPattern11 && phiPattern != badPattern13 &&
48 phiPattern != badPattern14 && phiPattern != badPattern15 &&
49 etaPattern != badPattern9 && phiPattern != badPattern9){
57 uint32_t etSum = et[0] + et[1] + et[2] + et[3];
60 (et[1] >> 1) + et[1] +
61 (et[2] >> 1) + (et[2] << 1) +
62 (et[3] << 2) - (et[3] >> 1) ;
63 uint32_t iAve = 0xDEADBEEF;
64 if( iEtSum <= etSum) iAve = 0;
65 else if(iEtSum <= (etSum << 1)) iAve = 1;
66 else if(iEtSum <= (etSum + (etSum << 1))) iAve = 2;
71 UCTRegion::UCTRegion(uint32_t crt, uint32_t crd,
bool ne, uint32_t rgn) :
81 for(uint32_t iEta = 0; iEta <
nEta; iEta++) {
82 for(uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
83 towers.push_back(
new UCTTower(crate, card, ne,
region, iEta, iPhi));
88 UCTRegion::~UCTRegion() {
89 for(uint32_t
i = 0;
i <
towers.size();
i++) {
94 const UCTTower* UCTRegion::getTower(uint32_t caloEta, uint32_t caloPhi)
const {
96 uint32_t nPhi = g.getNPhi(
region);
97 uint32_t iEta = g.getiEta(caloEta);
98 uint32_t iPhi = g.getiPhi(caloPhi);
99 UCTTower* tower =
towers[iEta*nPhi+iPhi];
107 uint32_t nEta = g.getNEta(
region);
108 uint32_t nPhi = g.getNPhi(
region);
111 uint32_t regionET = 0;
112 uint32_t regionEcalET = 0;
113 for(uint32_t twr = 0; twr <
towers.size(); twr++) {
115 LOG_ERROR <<
"Tower level processing failed. Bailing out :(" << std::endl;
118 regionET +=
towers[twr]->et();
120 regionEcalET +=
towers[twr]->getEcalET();
122 if(regionET > RegionETMask) {
123 LOG_ERROR <<
"L1TCaloLayer1::UCTRegion::Pegging RegionET" << std::endl;
124 regionET = RegionETMask;
126 regionSummary = (RegionETMask & regionET);
127 if(regionEcalET > RegionETMask) regionEcalET = RegionETMask;
131 if(
region < NRegionsInCard) {
135 uint32_t activityLevel = ((uint32_t) ((
float) regionET) *
activityFraction);
136 uint32_t nActiveTowers = 0;
137 uint32_t activeTowerET = 0;
138 for(uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
139 for(uint32_t iEta = 0; iEta <
nEta; iEta++) {
140 uint32_t towerET =
towers[iEta*nPhi+iPhi]->et();
141 if(towerET > activityLevel) {
142 activeTower[iEta][iPhi] =
true;
144 activeTowerET +=
towers[iEta*nPhi+iPhi]->et();
147 activeTower[iEta][iPhi] =
false;
150 if(activeTowerET > RegionETMask) activeTowerET = RegionETMask;
152 uint32_t sumETIEta[4] = {0, 0, 0, 0};
153 for(uint32_t iEta = 0; iEta <
nEta; iEta++) {
154 for(uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
155 uint32_t towerET =
towers[iEta*nPhi+iPhi]->et();
156 sumETIEta[iEta] += towerET;
160 uint32_t sumETIPhi[4] = {0, 0, 0, 0};
161 for(uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
162 for(uint32_t iEta = 0; iEta <
nEta; iEta++) {
163 uint32_t towerET =
towers[iEta*nPhi+iPhi]->et();
164 sumETIPhi[iPhi] += towerET;
168 uint32_t hitTowerLocation = hitIEta * nPhi + hitIPhi;
170 bitset<4> activeTowerEtaPattern = 0;
171 for(uint32_t iEta = 0; iEta <
nEta; iEta++) {
172 bool activeStrip =
false;
173 for(uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
174 if(activeTower[iEta][iPhi]) activeStrip =
true;
176 if(activeStrip) activeTowerEtaPattern |= (0x1 << iEta);
178 bitset<4> activeTowerPhiPattern = 0;
179 for(uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
180 bool activeStrip =
false;
181 for(uint32_t iEta = 0; iEta <
nEta; iEta++) {
182 if(activeTower[iEta][iPhi]) activeStrip =
true;
184 if(activeStrip) activeTowerPhiPattern |= (0x1 << iPhi);
187 bool veto =
vetoBit(activeTowerEtaPattern, activeTowerPhiPattern);
192 if((regionET - regionEcalET) > maxMiscActivityLevelForEG) egVeto =
true;
193 if((regionET - activeTowerET) > maxMiscActivityLevelForTau) tauVeto =
true;
195 if(egVeto) regionSummary |= RegionEGVeto;
196 if(tauVeto) regionSummary |= RegionTauVeto;
198 regionSummary |= (hitTowerLocation << LocationShift);
202 if(negativeEta) regionSummary |= NegEtaBit;
203 regionSummary |= (
region << RegionNoShift);
204 regionSummary |= (card << CardNoShift);
205 regionSummary |= (crate << CrateNoShift);
213 bool UCTRegion::clearEvent() {
215 for(uint32_t
i = 0;
i <
towers.size();
i++) {
216 if(!
towers[
i]->clearEvent())
return false;
221 bool UCTRegion::setECALData(UCTTowerIndex
t,
bool ecalFG, uint32_t ecalET) {
223 uint32_t nPhi = g.getNPhi(
region);
224 uint32_t absCaloEta =
abs(t.first);
225 uint32_t absCaloPhi =
abs(t.second);
226 uint32_t iEta = g.getiEta(absCaloEta);
227 uint32_t iPhi = g.getiPhi(absCaloPhi);
228 UCTTower* tower =
towers[iEta*nPhi+iPhi];
229 return tower->setECALData(ecalFG, ecalET);
232 bool UCTRegion::setHCALData(UCTTowerIndex t, uint32_t hcalFB, uint32_t hcalET) {
234 uint32_t nPhi = g.getNPhi(
region);
235 uint32_t absCaloEta =
abs(t.first);
236 uint32_t absCaloPhi =
abs(t.second);
237 uint32_t iEta = g.getiEta(absCaloEta);
238 uint32_t iPhiStart = g.getiPhi(absCaloPhi);
239 if(absCaloEta > 29 && absCaloEta < 40) {
242 for(uint32_t iPhi = iPhiStart; iPhi < iPhiStart + 2; iPhi++) {
243 UCTTower* tower =
towers[iEta*nPhi + iPhi];
245 if(!tower->setHFData(hcalFB, hcalET))
return false;
248 else if(absCaloEta == 40 || absCaloEta == 41) {
251 for(uint32_t iPhi = 0; iPhi < 4; iPhi++) {
252 UCTTower* tower =
towers[iEta * nPhi + iPhi];
254 if(!tower->setHFData(hcalFB, hcalET))
return false;
258 uint32_t iPhi = g.getiPhi(absCaloPhi);
259 UCTTower* tower =
towers[iEta*nPhi+iPhi];
260 return tower->setHCALData(hcalFB, hcalET);
267 os <<
"UCTRegion Summary for negative eta " << r.region
268 <<
" HitTower (eta, phi) = (" <<
std::dec << r.hitCaloEta() <<
", " << r.hitCaloPhi() <<
")"
269 <<
" summary = "<< std::hex << r.regionSummary << std::endl;
271 os <<
"UCTRegion Summary for positive eta " << r.region
272 <<
" HitTower (eta, phi) = (" <<
std::dec << r.hitCaloEta() <<
", " << r.hitCaloPhi() <<
")"
273 <<
" summary = "<< std::hex << r.regionSummary << std::endl;
bool vetoBit(bitset< 4 > etaPattern, bitset< 4 > phiPattern)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
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
const float miscActivityFraction
const float ecalActivityFraction
Abs< T >::type abs(const T &t)
const float activityFraction
uint32_t getHitTowerLocation(uint32_t *et)