10 #include "UCTLogging.hh"
12 using namespace l1tcalo;
15 if(
region >= NRegionsInCard) {
16 return processHFTower();
18 if(ecalET > etInputMax) ecalET = etInputMax;
19 if(hcalET > etInputMax) hcalET = etInputMax;
20 uint32_t calibratedECALET = ecalET;
21 uint32_t logECALET = (uint32_t) log2((
double) ecalET);
22 if(logECALET > erMaxV) logECALET = erMaxV;
24 uint32_t etaAddress =
region * NEtaInRegion + iEta;
25 uint32_t fbAddress = 0;
26 if(ecalFG) fbAddress = 1;
27 uint32_t
value = (*ecalLUT)[etaAddress][fbAddress][ecalET];
28 calibratedECALET = value & etInputMax;
29 logECALET = (value & 0x7000) >> 12;
31 uint32_t calibratedHCALET = hcalET;
32 uint32_t logHCALET = (uint32_t) log2((
double) hcalET);
33 if(logHCALET > erMaxV) logHCALET = erMaxV;
35 uint32_t etaAddress =
region * NEtaInRegion + iEta;
36 uint32_t fbAddress = 0;
37 if((hcalFB & 0x1) != 0) fbAddress = 1;
38 uint32_t
value = (*hcalLUT)[etaAddress][fbAddress][hcalET];
39 calibratedHCALET = value & etInputMax;
40 logHCALET = (value & 0x7000) >> 12;
42 towerData = calibratedECALET + calibratedHCALET;
43 if(towerData > etMask) towerData = etMask;
45 if(calibratedECALET == 0 || calibratedHCALET == 0) {
47 towerData |= zeroFlagMask;
48 if(calibratedHCALET == 0 && calibratedECALET != 0)
49 towerData |= eohrFlagMask;
51 else if(calibratedECALET == calibratedHCALET) {
53 towerData |= eohrFlagMask;
55 else if(calibratedECALET > calibratedHCALET) {
56 er = logECALET - logHCALET;
57 if(er > erMaxV) er = erMaxV;
58 towerData |= eohrFlagMask;
61 er = logHCALET - logECALET;
62 if(er > erMaxV) er = erMaxV;
64 towerData |= (er << erShift);
69 if((hcalFB & 0x1) != 0) towerData |= hcalFlagMask;
70 if(ecalFG) towerData |= ecalFlagMask;
72 towerData |= (calibratedECALET << ecalShift);
73 towerData |= (calibratedHCALET << hcalShift);
78 bool UCTTower::processHFTower() {
79 uint32_t calibratedET = hcalET;
81 const std::vector< uint32_t >
a = hfLUT->at((
region - NRegionsInCard) * NHFEtaInRegion + iEta);
82 calibratedET = a[hcalET] & 0xFF;
84 uint32_t absCaloEta =
abs(caloEta());
85 if(absCaloEta > 29 && absCaloEta < 40) {
89 else if(absCaloEta == 40 || absCaloEta == 41) {
93 towerData = calibratedET | zeroFlagMask;
94 if((hcalFB & 0x1) == 0x1) towerData |= ecalFlagMask;
95 if((hcalFB & 0x2) == 0x2) towerData |= hcalFlagMask;
99 bool UCTTower::setECALData(
bool eFG, uint32_t eET) {
102 if(eET > etInputMax) {
103 LOG_ERROR <<
"UCTTower::setData - ecalET too high " << eET <<
"; Pegged to etInputMax" << std::endl;
109 bool UCTTower::setHCALData(uint32_t hFB, uint32_t hET) {
112 if(hET > etInputMax) {
113 LOG_ERROR <<
"UCTTower::setData - hcalET too high " << hET <<
"; Pegged to etInputMax" << std::endl;
117 LOG_ERROR <<
"UCTTower::setData - too many hcalFeatureBits " << std::hex << hFB
118 <<
"; Used only bottom 6 bits" << std::endl;
124 bool UCTTower::setHFData(uint32_t fbIn, uint32_t etIn) {
129 if(etIn > etInputMax) {
130 LOG_ERROR <<
"UCTTower::setData - HF ET too high " << etIn <<
"; Pegged to etInputMax" << std::endl;
134 LOG_ERROR <<
"UCTTower::setData - too many HF FeatureBits " << std::hex << fbIn
135 <<
"; Used only bottom 2 bits" << std::endl;
141 const uint16_t UCTTower::location()
const {
143 if(negativeEta) l = 0x8000;
152 UCTTower::UCTTower(uint16_t location) {
153 if((location & 0x8000) != 0) negativeEta =
true;
154 crate = (location & 0x1800) >> 11;
155 card = (location & 0x0700) >> 8;
156 region = (location & 0x00F0) >> 4;
157 iEta = (location & 0x000C) >> 2;
158 iPhi = (location & 0x0003);
162 const uint64_t UCTTower::extendedData()
const {
172 os <<
"Side Crt Crd Rgn iEta iPhi cEta cPhi eET eFG hET hFB Summary" << std::endl;
176 if(t.negativeEta) side =
"-eta ";
178 << std::showbase << std::internal << std::setfill(
'0') << std::setw(4) << std::hex
180 << std::showbase << std::internal << std::setfill(
'0') << std::setw(4) << std::hex
182 << std::showbase << std::internal << std::setfill(
'0') << std::setw(4) << std::hex
184 << std::showbase << std::internal << std::setfill(
'0') << std::setw(4) << std::hex
186 << std::showbase << std::internal << std::setfill(
'0') << std::setw(4) << std::hex
188 << std::setw(4) << std::setfill(
' ') <<
std::dec
189 << g.getCaloEtaIndex(t.negativeEta, t.region, t.iEta) <<
" "
190 << std::setw(4) << std::setfill(
' ') <<
std::dec
191 << g.getCaloPhiIndex(t.crate, t.card, t.region, t.iPhi) <<
" "
192 << std::showbase << std::internal << std::setfill(
'0') << std::setw(4) << std::hex
194 << std::showbase << std::internal << std::setfill(
'0') << std::setw(4) << std::hex
196 << std::showbase << std::internal << std::setfill(
'0') << std::setw(4) << std::hex
198 << std::showbase << std::internal << std::setfill(
'0') << std::setw(4) << std::hex
200 << std::showbase << std::internal << std::setfill(
'0') << std::setw(10) << std::hex
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
Abs< T >::type abs(const T &t)
unsigned long long uint64_t