10 #include "UCTRegion.hh" 12 #include "UCTGeometry.hh" 13 #include "UCTLogging.hh" 15 #include "UCTTower.hh" 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 &&
47 phiPattern != badPattern10 &&
48 phiPattern != badPattern11 && phiPattern != badPattern13 &&
50 etaPattern != badPattern9 && phiPattern != badPattern9){
58 uint32_t etSum = et[0] + et[1] + et[2] + et[3];
61 (et[1] >> 1) + et[1] +
62 (et[2] >> 1) + (et[2] << 1) +
63 (et[3] << 2) - (et[3] >> 1) ;
64 uint32_t iAve = 0xDEADBEEF;
65 if( iEtSum <= etSum) iAve = 0;
66 else if(iEtSum <= (etSum << 1)) iAve = 1;
67 else if(iEtSum <= (etSum + (etSum << 1))) iAve = 2;
72 UCTRegion::UCTRegion(uint32_t crt, uint32_t crd,
bool ne, uint32_t rgn,
int fwv) :
80 uint32_t
nEta = g.getNEta(region);
81 uint32_t
nPhi = g.getNPhi(region);
83 for(uint32_t iEta = 0; iEta <
nEta; iEta++) {
84 for(uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
85 towers.push_back(
new UCTTower(crate, card,
ne, region, iEta, iPhi,
fwVersion));
90 UCTRegion::~UCTRegion() {
91 for(uint32_t
i = 0;
i < towers.size();
i++) {
92 if(towers[
i] !=
nullptr)
delete towers[
i];
96 const UCTTower* UCTRegion::getTower(uint32_t caloEta, uint32_t caloPhi)
const {
98 uint32_t
nPhi = g.getNPhi(region);
99 uint32_t iEta = g.getiEta(caloEta);
100 uint32_t iPhi = g.getiPhi(caloPhi);
101 UCTTower* tower = towers[iEta*nPhi+iPhi];
109 uint32_t
nEta = g.getNEta(region);
110 uint32_t
nPhi = g.getNPhi(region);
113 uint32_t regionET = 0;
114 uint32_t regionEcalET = 0;
115 for(uint32_t twr = 0; twr < towers.size(); twr++) {
117 LOG_ERROR <<
"Tower level processing failed. Bailing out :(" << std::endl;
120 regionET += towers[twr]->et();
122 regionEcalET += towers[twr]->getEcalET();
124 if(regionET > RegionETMask) {
127 regionET = RegionETMask;
129 regionSummary = (RegionETMask & regionET);
130 if(regionEcalET > RegionETMask) regionEcalET = RegionETMask;
134 if(region < NRegionsInCard) {
138 uint32_t activityLevel = ((uint32_t) ((
float) regionET) *
activityFraction);
139 uint32_t nActiveTowers = 0;
140 uint32_t activeTowerET = 0;
141 for(uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
142 for(uint32_t iEta = 0; iEta <
nEta; iEta++) {
143 uint32_t towerET = towers[iEta*nPhi+iPhi]->et();
144 if(towerET > activityLevel) {
145 activeTower[iEta][iPhi] =
true;
147 activeTowerET += towers[iEta*nPhi+iPhi]->et();
150 activeTower[iEta][iPhi] =
false;
153 if(activeTowerET > RegionETMask) activeTowerET = RegionETMask;
155 uint32_t sumETIEta[4] = {0, 0, 0, 0};
156 for(uint32_t iEta = 0; iEta <
nEta; iEta++) {
157 for(uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
158 uint32_t towerET = towers[iEta*nPhi+iPhi]->et();
159 sumETIEta[iEta] += towerET;
163 uint32_t sumETIPhi[4] = {0, 0, 0, 0};
164 for(uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
165 for(uint32_t iEta = 0; iEta <
nEta; iEta++) {
166 uint32_t towerET = towers[iEta*nPhi+iPhi]->et();
167 sumETIPhi[iPhi] += towerET;
171 uint32_t hitTowerLocation = hitIEta * nPhi + hitIPhi;
173 bitset<4> activeTowerEtaPattern = 0;
174 for(uint32_t iEta = 0; iEta <
nEta; iEta++) {
175 bool activeStrip =
false;
176 for(uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
177 if(activeTower[iEta][iPhi]) activeStrip =
true;
179 if(activeStrip) activeTowerEtaPattern |= (0x1 << iEta);
181 bitset<4> activeTowerPhiPattern = 0;
182 for(uint32_t iPhi = 0; iPhi <
nPhi; iPhi++) {
183 bool activeStrip =
false;
184 for(uint32_t iEta = 0; iEta <
nEta; iEta++) {
185 if(activeTower[iEta][iPhi]) activeStrip =
true;
187 if(activeStrip) activeTowerPhiPattern |= (0x1 << iPhi);
190 bool veto =
vetoBit(activeTowerEtaPattern, activeTowerPhiPattern);
195 if((regionET - regionEcalET) > maxMiscActivityLevelForEG) egVeto =
true;
196 if((regionET - activeTowerET) > maxMiscActivityLevelForTau) tauVeto =
true;
198 if(egVeto) regionSummary |= RegionEGVeto;
199 if(tauVeto) regionSummary |= RegionTauVeto;
201 regionSummary |= (hitTowerLocation << LocationShift);
205 if(negativeEta) regionSummary |= NegEtaBit;
206 regionSummary |= (region << RegionNoShift);
207 regionSummary |= (card << CardNoShift);
208 regionSummary |= (crate << CrateNoShift);
216 bool UCTRegion::clearEvent() {
218 for(uint32_t
i = 0;
i < towers.size();
i++) {
219 if(!towers[
i]->clearEvent())
return false;
224 bool UCTRegion::setECALData(UCTTowerIndex
t,
bool ecalFG, uint32_t ecalET) {
226 uint32_t
nPhi = g.getNPhi(region);
227 uint32_t absCaloEta =
abs(
t.first);
228 uint32_t absCaloPhi =
abs(
t.second);
229 uint32_t iEta = g.getiEta(absCaloEta);
230 uint32_t iPhi = g.getiPhi(absCaloPhi);
231 UCTTower* tower = towers[iEta*nPhi+iPhi];
232 return tower->setECALData(ecalFG, ecalET);
235 bool UCTRegion::setHCALData(UCTTowerIndex
t, uint32_t hcalFB, uint32_t hcalET) {
237 uint32_t
nPhi = g.getNPhi(region);
238 uint32_t absCaloEta =
abs(
t.first);
239 uint32_t absCaloPhi =
abs(
t.second);
240 uint32_t iEta = g.getiEta(absCaloEta);
241 uint32_t iPhiStart = g.getiPhi(absCaloPhi);
242 if(absCaloEta > 29 && absCaloEta < 40) {
245 for(uint32_t iPhi = iPhiStart; iPhi < iPhiStart + 2; iPhi++) {
246 UCTTower* tower = towers[iEta*nPhi + iPhi];
248 if(!tower->setHFData(hcalFB, hcalET))
return false;
251 else if(absCaloEta == 40 || absCaloEta == 41) {
254 for(uint32_t iPhi = 0; iPhi < 4; iPhi++) {
255 UCTTower* tower = towers[iEta * nPhi + iPhi];
257 if(!tower->setHFData(hcalFB, hcalET))
return false;
261 uint32_t iPhi = g.getiPhi(absCaloPhi);
262 UCTTower* tower = towers[iEta*nPhi+iPhi];
263 return tower->setHCALData(hcalFB, hcalET);
270 os <<
"UCTRegion Summary for negative eta " << r.region
271 <<
" HitTower (eta, phi) = (" <<
std::dec << r.hitCaloEta() <<
", " << r.hitCaloPhi() <<
")" 272 <<
" summary = "<< std::hex << r.regionSummary << std::endl;
274 os <<
"UCTRegion Summary for positive eta " << r.region
275 <<
" HitTower (eta, phi) = (" <<
std::dec << r.hitCaloEta() <<
", " << r.hitCaloPhi() <<
")" 276 <<
" summary = "<< std::hex << r.regionSummary << std::endl;
bool vetoBit(bitset< 4 > etaPattern, bitset< 4 > phiPattern)
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)
std::ostream & operator<<(std::ostream &os, const UCTRegion &r)
const float activityFraction
et
define resolution functions of each parameter
uint32_t getHitTowerLocation(uint32_t *et)