17 LogDebug(
"L1T") <<
"Board ID = " << block.
amc().getBoardID();
21 auto ctp7_phi = block.
amc().getBoardID();
22 const uint32_t* ptr = block.
payload().data();
29 makeECalTPGs(ctp7_phi, ctp7Data, res->getEcalDigis());
30 makeHCalTPGs(ctp7_phi, ctp7Data, res->getHcalDigis());
31 makeHFTPGs(ctp7_phi, ctp7Data, res->getHcalDigis());
32 makeRegions(ctp7_phi, ctp7Data, res->getRegions());
33 }
else if (N_BX == 5) {
36 makeECalTPGs5BX(ctp7_phi, ctp7Data5BX, res->getEcalDigis(), 2);
37 makeHCalTPGs5BX(ctp7_phi, ctp7Data5BX, res->getHcalDigis(), 2);
38 makeHFTPGs5BX(ctp7_phi, ctp7Data5BX, res->getHcalDigis(), 2);
39 makeRegions5BX(ctp7_phi, ctp7Data5BX, res->getRegions(), 2);
40 for (
int i = 0;
i < 5;
i++) {
41 makeECalTPGs5BX(ctp7_phi, ctp7Data5BX, res->getEcalDigisBx(
i),
i);
44 LogError(
"CaloLayer1Unpacker") <<
"Number of BXs to unpack is not 1 or 5, stop here !!! " << N_BX << std::endl;
51 void CaloLayer1Unpacker::makeECalTPGs(uint32_t lPhi,
55 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
56 int cPhi = -1 + lPhi * 4 + iPhi;
62 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeECalTPGs" << std::endl;
65 for (
int cEta = -28; cEta <= 28; cEta++) {
67 bool negativeEta =
false;
70 uint32_t iEta =
abs(cEta);
78 uint32_t towerDatum = ctp7Data.
getET(cType, negativeEta, iEta, iPhi);
79 if (ctp7Data.
getFB(cType, negativeEta, iEta, iPhi) != 0)
83 if (ctp7Data.
isLinkMasked(cType, negativeEta, iEta, iPhi))
87 ctp7Data.
isLinkDown(cType, negativeEta, iEta, iPhi))
90 int zSide = cEta / ((int)iEta);
104 void CaloLayer1Unpacker::makeHCalTPGs(uint32_t lPhi,
108 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
109 int cPhi = -1 + lPhi * 4 + iPhi;
114 else if (cPhi < -1) {
115 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeHCalTPGs" << std::endl;
118 for (
int cEta = -28; cEta <= 28; cEta++) {
120 bool negativeEta =
false;
123 uint32_t iEta =
abs(cEta);
131 uint32_t towerDatum = ctp7Data.
getET(cType, negativeEta, iEta, iPhi);
132 if (ctp7Data.
getFB(cType, negativeEta, iEta, iPhi) != 0)
133 towerDatum |= 0x0100;
135 towerDatum |= 0x0200;
137 towerDatum |= 0x0400;
138 if (ctp7Data.
isLinkDown(cType, negativeEta, iEta, iPhi))
139 towerDatum |= 0x0800;
141 towerDatum |= 0x2000;
142 if (ctp7Data.
isLinkMasked(cType, negativeEta, iEta, iPhi))
143 towerDatum |= 0x4000;
146 ctp7Data.
isLinkDown(cType, negativeEta, iEta, iPhi))
147 towerDatum |= 0x8000;
161 for (uint32_t side = 0; side <= 1; side++) {
162 bool negativeEta =
false;
165 for (uint32_t iEta = 30; iEta <= 40; iEta++) {
166 for (uint32_t iPhi = 0; iPhi < 2; iPhi++) {
167 if (iPhi == 1 && iEta == 40)
169 int cPhi = 1 + lPhi * 4 + iPhi * 2;
172 cPhi = (cPhi + 69) % 72 + 1;
184 uint32_t towerDatum = ctp7Data.
getET(cType, negativeEta, iEta, iPhi);
185 towerDatum |= ctp7Data.
getFB(cType, negativeEta, iEta, iPhi) << 8;
187 towerDatum |= 0x0400;
189 towerDatum |= 0x0800;
190 if (ctp7Data.
isLinkDown(cType, negativeEta, iEta, iPhi))
191 towerDatum |= 0x1000;
193 towerDatum |= 0x2000;
194 if (ctp7Data.
isLinkMasked(cType, negativeEta, iEta, iPhi))
195 towerDatum |= 0x4000;
198 ctp7Data.
isLinkDown(cType, negativeEta, iEta, iPhi))
199 towerDatum |= 0x8000;
213 for (uint32_t side = 0; side <= 1; side++) {
214 bool negativeEta =
false;
219 uint32_t lEta = 10 -
region;
222 regions->push_back(
L1CaloRegion((uint16_t)regionData, (
unsigned)lEta, (
unsigned)lPhi, (int16_t)0));
232 void CaloLayer1Unpacker::makeECalTPGs5BX(uint32_t lPhi,
237 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
238 int cPhi = -1 + lPhi * 4 + iPhi;
243 else if (cPhi < -1) {
244 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeECalTPGs5BX" << std::endl;
247 for (
int cEta = -28; cEta <= 28; cEta++) {
249 bool negativeEta =
false;
252 uint32_t iEta =
abs(cEta);
260 uint32_t towerDatum = ctp7Data5BX.
getET(cType, negativeEta, iEta, iPhi, BX_n);
261 if (ctp7Data5BX.
getFB(cType, negativeEta, iEta, iPhi, BX_n) != 0)
262 towerDatum |= 0x0100;
263 if (ctp7Data5BX.
isTowerMasked(cType, negativeEta, iEta, iPhi, BX_n))
264 towerDatum |= 0x2000;
265 if (ctp7Data5BX.
isLinkMasked(cType, negativeEta, iEta, iPhi, BX_n))
266 towerDatum |= 0x4000;
268 ctp7Data5BX.
isLinkInError(cType, negativeEta, iEta, iPhi, BX_n) ||
269 ctp7Data5BX.
isLinkDown(cType, negativeEta, iEta, iPhi, BX_n))
270 towerDatum |= 0x8000;
272 int zSide = cEta / ((int)iEta);
286 void CaloLayer1Unpacker::makeHCalTPGs5BX(uint32_t lPhi,
291 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
292 int cPhi = -1 + lPhi * 4 + iPhi;
297 else if (cPhi < -1) {
298 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeHCalTPGs5BX" << std::endl;
301 for (
int cEta = -28; cEta <= 28; cEta++) {
303 bool negativeEta =
false;
306 uint32_t iEta =
abs(cEta);
314 uint32_t towerDatum = ctp7Data5BX.
getET(cType, negativeEta, iEta, iPhi, BX_n);
315 if (ctp7Data5BX.
getFB(cType, negativeEta, iEta, iPhi, BX_n) != 0)
316 towerDatum |= 0x0100;
318 towerDatum |= 0x0200;
319 if (ctp7Data5BX.
isLinkInError(cType, negativeEta, iEta, iPhi, BX_n))
320 towerDatum |= 0x0400;
321 if (ctp7Data5BX.
isLinkDown(cType, negativeEta, iEta, iPhi, BX_n))
322 towerDatum |= 0x0800;
323 if (ctp7Data5BX.
isTowerMasked(cType, negativeEta, iEta, iPhi, BX_n))
324 towerDatum |= 0x2000;
325 if (ctp7Data5BX.
isLinkMasked(cType, negativeEta, iEta, iPhi, BX_n))
326 towerDatum |= 0x4000;
328 ctp7Data5BX.
isLinkInError(cType, negativeEta, iEta, iPhi, BX_n) ||
329 ctp7Data5BX.
isLinkDown(cType, negativeEta, iEta, iPhi, BX_n))
330 towerDatum |= 0x8000;
342 void CaloLayer1Unpacker::makeHFTPGs5BX(uint32_t lPhi,
347 for (uint32_t side = 0; side <= 1; side++) {
348 bool negativeEta =
false;
351 for (uint32_t iEta = 30; iEta <= 40; iEta++) {
352 for (uint32_t iPhi = 0; iPhi < 2; iPhi++) {
353 if (iPhi == 1 && iEta == 40)
355 int cPhi = 1 + lPhi * 4 + iPhi * 2;
358 cPhi = (cPhi + 69) % 72 + 1;
370 uint32_t towerDatum = ctp7Data5BX.
getET(cType, negativeEta, iEta, iPhi, BX_n);
371 towerDatum |= ctp7Data5BX.
getFB(cType, negativeEta, iEta, iPhi, BX_n) << 8;
373 towerDatum |= 0x0400;
374 if (ctp7Data5BX.
isLinkInError(cType, negativeEta, iEta, iPhi, BX_n))
375 towerDatum |= 0x0800;
376 if (ctp7Data5BX.
isLinkDown(cType, negativeEta, iEta, iPhi, BX_n))
377 towerDatum |= 0x1000;
378 if (ctp7Data5BX.
isTowerMasked(cType, negativeEta, iEta, iPhi, BX_n))
379 towerDatum |= 0x2000;
380 if (ctp7Data5BX.
isLinkMasked(cType, negativeEta, iEta, iPhi, BX_n))
381 towerDatum |= 0x4000;
383 ctp7Data5BX.
isLinkInError(cType, negativeEta, iEta, iPhi, BX_n) ||
384 ctp7Data5BX.
isLinkDown(cType, negativeEta, iEta, iPhi, BX_n))
385 towerDatum |= 0x8000;
398 void CaloLayer1Unpacker::makeRegions5BX(uint32_t lPhi,
402 for (uint32_t side = 0; side <= 1; side++) {
403 bool negativeEta =
false;
408 uint32_t lEta = 10 -
region;
411 regions->push_back(
L1CaloRegion((uint16_t)regionData, (
unsigned)lEta, (
unsigned)lPhi, (int16_t)0));
uint32_t getFB(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t BX_n)
void setSample(int i, const HcalTriggerPrimitiveSample &sam)
uint32_t getFB(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
const std::vector< uint32_t > & payload() const
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
uint16_t *__restrict__ id
bool isLinkMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
BlockHeader header() const
void push_back(T const &t)
Log< level::Error, false > LogError
bool isLinkDown(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
bool isLinkInError(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t BX_n)
uint32_t getRegionSummary(bool negativeEta, uint32_t region, uint32_t BX_n)
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
bool isLinkInError(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
bool isTowerMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
Abs< T >::type abs(const T &t)
uint32_t getET(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t BX_n)
bool isLinkDown(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t BX_n)
uint32_t getET(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
#define DEFINE_L1T_UNPACKER(type)
A calorimeter trigger region (sum of 4x4 trigger towers)
bool isLinkMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t BX_n)
std::vector< L1CaloRegion > L1CaloRegionCollection
void amc(const amc::Header &h)
bool isTowerMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t BX_n)
uint32_t getRegionSummary(bool negativeEta, uint32_t region)
bool isLinkMisaligned(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t BX_n)
bool isLinkMisaligned(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)