16 LogDebug(
"L1T") <<
"Block size = " <<
block.header().getSize();
21 auto ctp7_phi =
block.amc().getBoardID();
22 const uint32_t* ptr =
block.payload().data();
24 int N_BX = (
block.header().getFlags() >> 16) & 0xf;
27 int HCALFB = (
block.header().getFlags() >> 15) & 0x1;
32 makeECalTPGs(ctp7_phi, ctp7Data,
res->getEcalDigis());
33 makeHCalTPGs(ctp7_phi, ctp7Data,
res->getHcalDigis());
34 makeHFTPGs(ctp7_phi, ctp7Data,
res->getHcalDigis());
35 makeRegions(ctp7_phi, ctp7Data,
res->getRegions());
39 makeECalTPGs_HCALFB(ctp7_phi, ctp7Data_HCALFB,
res->getEcalDigis());
40 makeHCalTPGs_HCALFB(ctp7_phi, ctp7Data_HCALFB,
res->getHcalDigis());
41 makeHFTPGs_HCALFB(ctp7_phi, ctp7Data_HCALFB,
res->getHcalDigis());
42 makeRegions_HCALFB(ctp7_phi, ctp7Data_HCALFB,
res->getRegions());
44 }
else if (
N_BX == 5) {
48 makeECalTPGs5BX(ctp7_phi, ctp7Data5BX,
res->getEcalDigis(), 2);
49 makeHCalTPGs5BX(ctp7_phi, ctp7Data5BX,
res->getHcalDigis(), 2);
50 makeHFTPGs5BX(ctp7_phi, ctp7Data5BX,
res->getHcalDigis(), 2);
51 makeRegions5BX(ctp7_phi, ctp7Data5BX,
res->getRegions(), 2);
52 for (
int i = 0;
i < 5;
i++) {
53 makeECalTPGs5BX(ctp7_phi, ctp7Data5BX,
res->getEcalDigisBx(
i),
i);
59 makeECalTPGs5BX_HCALFB(ctp7_phi, ctp7Data5BX_HCALFB,
res->getEcalDigis(), 2);
60 makeHCalTPGs5BX_HCALFB(ctp7_phi, ctp7Data5BX_HCALFB,
res->getHcalDigis(), 2);
61 makeHFTPGs5BX_HCALFB(ctp7_phi, ctp7Data5BX_HCALFB,
res->getHcalDigis(), 2);
62 makeRegions5BX_HCALFB(ctp7_phi, ctp7Data5BX_HCALFB,
res->getRegions(), 2);
63 for (
int i = 0;
i < 5;
i++) {
64 makeECalTPGs5BX_HCALFB(ctp7_phi, ctp7Data5BX_HCALFB,
res->getEcalDigisBx(
i),
i);
68 LogError(
"CaloLayer1Unpacker") <<
"Number of BXs to unpack is not 1 or 5, stop here !!! " <<
N_BX << std::endl;
75 void CaloLayer1Unpacker::makeECalTPGs(uint32_t lPhi,
79 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
80 int cPhi = -1 + lPhi * 4 + iPhi;
86 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeECalTPGs" << std::endl;
89 for (
int cEta = -28; cEta <= 28; cEta++) {
91 bool negativeEta =
false;
102 uint32_t towerDatum = ctp7Data.
getET(cType, negativeEta,
iEta, iPhi);
103 if (ctp7Data.
getFB(cType, negativeEta,
iEta, iPhi) != 0)
104 towerDatum |= 0x0100;
106 towerDatum |= 0x2000;
108 towerDatum |= 0x4000;
112 towerDatum |= 0x8000;
114 int zSide = cEta / ((
int)
iEta);
128 void CaloLayer1Unpacker::makeHCalTPGs(uint32_t lPhi,
132 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
133 int cPhi = -1 + lPhi * 4 + iPhi;
138 else if (cPhi < -1) {
139 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeHCalTPGs" << std::endl;
142 for (
int cEta = -28; cEta <= 28; cEta++) {
144 bool negativeEta =
false;
155 uint32_t towerDatum = ctp7Data.
getET(cType, negativeEta,
iEta, iPhi);
156 if (ctp7Data.
getFB(cType, negativeEta,
iEta, iPhi) != 0)
157 towerDatum |= 0x0100;
159 towerDatum |= 0x0200;
161 towerDatum |= 0x0400;
163 towerDatum |= 0x0800;
165 towerDatum |= 0x2000;
167 towerDatum |= 0x4000;
171 towerDatum |= 0x8000;
185 for (uint32_t side = 0; side <= 1; side++) {
186 bool negativeEta =
false;
190 for (uint32_t iPhi = 0; iPhi < 2; iPhi++) {
191 if (iPhi == 1 &&
iEta == 40)
193 int cPhi = 1 + lPhi * 4 + iPhi * 2;
196 cPhi = (cPhi + 69) % 72 + 1;
208 uint32_t towerDatum = ctp7Data.
getET(cType, negativeEta,
iEta, iPhi);
209 towerDatum |= ctp7Data.
getFB(cType, negativeEta,
iEta, iPhi) << 8;
211 towerDatum |= 0x0400;
213 towerDatum |= 0x0800;
215 towerDatum |= 0x1000;
217 towerDatum |= 0x2000;
219 towerDatum |= 0x4000;
223 towerDatum |= 0x8000;
237 for (uint32_t side = 0; side <= 1; side++) {
238 bool negativeEta =
false;
243 uint32_t lEta = 10 -
region;
246 regions->push_back(
L1CaloRegion((uint16_t)regionData, (
unsigned)lEta, (
unsigned)lPhi, (int16_t)0));
252 void CaloLayer1Unpacker::makeECalTPGs_HCALFB(uint32_t lPhi,
256 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
257 int cPhi = -1 + lPhi * 4 + iPhi;
262 else if (cPhi < -1) {
263 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeECalTPGs_HCALFB" << std::endl;
266 for (
int cEta = -28; cEta <= 28; cEta++) {
268 bool negativeEta =
false;
279 uint32_t towerDatum = ctp7Data_HCALFB.
getET(cType, negativeEta,
iEta, iPhi);
280 if (ctp7Data_HCALFB.
getFB(cType, negativeEta,
iEta, iPhi) != 0)
281 towerDatum |= 0x0100;
283 towerDatum |= 0x2000;
285 towerDatum |= 0x4000;
289 towerDatum |= 0x8000;
291 int zSide = cEta / ((
int)
iEta);
305 void CaloLayer1Unpacker::makeHCalTPGs_HCALFB(uint32_t lPhi,
309 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
310 int cPhi = -1 + lPhi * 4 + iPhi;
315 else if (cPhi < -1) {
316 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeHCalTPGs_HCALFB" << std::endl;
319 for (
int cEta = -28; cEta <= 28; cEta++) {
321 bool negativeEta =
false;
332 uint32_t towerDatum = ctp7Data_HCALFB.
getET(cType, negativeEta,
iEta, iPhi);
333 uint32_t fb = ctp7Data_HCALFB.
getFB(cType, negativeEta,
iEta, iPhi);
334 towerDatum |= ((fb & 0x1) << 8);
335 uint32_t towerDatum2 = ((fb & 0x3E) >> 1);
337 towerDatum |= 0x0200;
339 towerDatum |= 0x0400;
341 towerDatum |= 0x0800;
343 towerDatum |= 0x2000;
345 towerDatum |= 0x4000;
349 towerDatum |= 0x8000;
363 void CaloLayer1Unpacker::makeHFTPGs_HCALFB(uint32_t lPhi,
367 for (uint32_t side = 0; side <= 1; side++) {
368 bool negativeEta =
false;
372 for (uint32_t iPhi = 0; iPhi < 2; iPhi++) {
373 if (iPhi == 1 &&
iEta == 40)
375 int cPhi = 1 + lPhi * 4 + iPhi * 2;
378 cPhi = (cPhi + 69) % 72 + 1;
390 uint32_t towerDatum = ctp7Data_HCALFB.
getET(cType, negativeEta,
iEta, iPhi);
391 towerDatum |= ctp7Data_HCALFB.
getFB(cType, negativeEta,
iEta, iPhi) << 8;
393 towerDatum |= 0x0400;
395 towerDatum |= 0x0800;
397 towerDatum |= 0x1000;
399 towerDatum |= 0x2000;
401 towerDatum |= 0x4000;
405 towerDatum |= 0x8000;
418 void CaloLayer1Unpacker::makeRegions_HCALFB(uint32_t lPhi,
421 for (uint32_t side = 0; side <= 1; side++) {
422 bool negativeEta =
false;
427 uint32_t lEta = 10 -
region;
430 regions->push_back(
L1CaloRegion((uint16_t)regionData, (
unsigned)lEta, (
unsigned)lPhi, (int16_t)0));
440 void CaloLayer1Unpacker::makeECalTPGs5BX(uint32_t lPhi,
445 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
446 int cPhi = -1 + lPhi * 4 + iPhi;
451 else if (cPhi < -1) {
452 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeECalTPGs5BX" << std::endl;
455 for (
int cEta = -28; cEta <= 28; cEta++) {
457 bool negativeEta =
false;
468 uint32_t towerDatum = ctp7Data5BX.
getET(cType, negativeEta,
iEta, iPhi, BX_n);
469 if (ctp7Data5BX.
getFB(cType, negativeEta,
iEta, iPhi, BX_n) != 0)
470 towerDatum |= 0x0100;
472 towerDatum |= 0x2000;
474 towerDatum |= 0x4000;
478 towerDatum |= 0x8000;
480 int zSide = cEta / ((
int)
iEta);
494 void CaloLayer1Unpacker::makeHCalTPGs5BX(uint32_t lPhi,
499 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
500 int cPhi = -1 + lPhi * 4 + iPhi;
505 else if (cPhi < -1) {
506 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeHCalTPGs5BX" << std::endl;
509 for (
int cEta = -28; cEta <= 28; cEta++) {
511 bool negativeEta =
false;
522 uint32_t towerDatum = ctp7Data5BX.
getET(cType, negativeEta,
iEta, iPhi, BX_n);
523 if (ctp7Data5BX.
getFB(cType, negativeEta,
iEta, iPhi, BX_n) != 0)
524 towerDatum |= 0x0100;
526 towerDatum |= 0x0200;
528 towerDatum |= 0x0400;
530 towerDatum |= 0x0800;
532 towerDatum |= 0x2000;
534 towerDatum |= 0x4000;
538 towerDatum |= 0x8000;
550 void CaloLayer1Unpacker::makeHFTPGs5BX(uint32_t lPhi,
555 for (uint32_t side = 0; side <= 1; side++) {
556 bool negativeEta =
false;
560 for (uint32_t iPhi = 0; iPhi < 2; iPhi++) {
561 if (iPhi == 1 &&
iEta == 40)
563 int cPhi = 1 + lPhi * 4 + iPhi * 2;
566 cPhi = (cPhi + 69) % 72 + 1;
578 uint32_t towerDatum = ctp7Data5BX.
getET(cType, negativeEta,
iEta, iPhi, BX_n);
579 towerDatum |= ctp7Data5BX.
getFB(cType, negativeEta,
iEta, iPhi, BX_n) << 8;
581 towerDatum |= 0x0400;
583 towerDatum |= 0x0800;
585 towerDatum |= 0x1000;
587 towerDatum |= 0x2000;
589 towerDatum |= 0x4000;
593 towerDatum |= 0x8000;
606 void CaloLayer1Unpacker::makeRegions5BX(uint32_t lPhi,
610 for (uint32_t side = 0; side <= 1; side++) {
611 bool negativeEta =
false;
616 uint32_t lEta = 10 -
region;
619 regions->push_back(
L1CaloRegion((uint16_t)regionData, (
unsigned)lEta, (
unsigned)lPhi, (int16_t)0));
625 void CaloLayer1Unpacker::makeECalTPGs5BX_HCALFB(uint32_t lPhi,
630 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
631 int cPhi = -1 + lPhi * 4 + iPhi;
636 else if (cPhi < -1) {
637 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeECalTPGs5BX_HCALFB" << std::endl;
640 for (
int cEta = -28; cEta <= 28; cEta++) {
642 bool negativeEta =
false;
653 uint32_t towerDatum = ctp7Data5BX_HCALFB.
getET(cType, negativeEta,
iEta, iPhi, BX_n);
654 if (ctp7Data5BX_HCALFB.
getFB(cType, negativeEta,
iEta, iPhi, BX_n) != 0)
655 towerDatum |= 0x0100;
657 towerDatum |= 0x2000;
659 towerDatum |= 0x4000;
662 ctp7Data5BX_HCALFB.
isLinkDown(cType, negativeEta,
iEta, iPhi, BX_n))
663 towerDatum |= 0x8000;
665 int zSide = cEta / ((
int)
iEta);
679 void CaloLayer1Unpacker::makeHCalTPGs5BX_HCALFB(uint32_t lPhi,
684 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
685 int cPhi = -1 + lPhi * 4 + iPhi;
690 else if (cPhi < -1) {
691 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeHCalTPGs5BX_HCALFB" << std::endl;
694 for (
int cEta = -28; cEta <= 28; cEta++) {
696 bool negativeEta =
false;
707 uint32_t towerDatum = ctp7Data5BX_HCALFB.
getET(cType, negativeEta,
iEta, iPhi, BX_n);
708 uint32_t fb = ctp7Data5BX_HCALFB.
getFB(cType, negativeEta,
iEta, iPhi, BX_n);
709 towerDatum |= ((fb & 0x1) << 8);
710 uint32_t towerDatum2 = ((fb & 0x3E) >> 1);
712 towerDatum |= 0x0200;
714 towerDatum |= 0x0400;
715 if (ctp7Data5BX_HCALFB.
isLinkDown(cType, negativeEta,
iEta, iPhi, BX_n))
716 towerDatum |= 0x0800;
718 towerDatum |= 0x2000;
720 towerDatum |= 0x4000;
723 ctp7Data5BX_HCALFB.
isLinkDown(cType, negativeEta,
iEta, iPhi, BX_n))
724 towerDatum |= 0x8000;
738 void CaloLayer1Unpacker::makeHFTPGs5BX_HCALFB(uint32_t lPhi,
743 for (uint32_t side = 0; side <= 1; side++) {
744 bool negativeEta =
false;
748 for (uint32_t iPhi = 0; iPhi < 2; iPhi++) {
749 if (iPhi == 1 &&
iEta == 40)
751 int cPhi = 1 + lPhi * 4 + iPhi * 2;
754 cPhi = (cPhi + 69) % 72 + 1;
766 uint32_t towerDatum = ctp7Data5BX_HCALFB.
getET(cType, negativeEta,
iEta, iPhi, BX_n);
767 towerDatum |= ctp7Data5BX_HCALFB.
getFB(cType, negativeEta,
iEta, iPhi, BX_n) << 8;
769 towerDatum |= 0x0400;
771 towerDatum |= 0x0800;
772 if (ctp7Data5BX_HCALFB.
isLinkDown(cType, negativeEta,
iEta, iPhi, BX_n))
773 towerDatum |= 0x1000;
775 towerDatum |= 0x2000;
777 towerDatum |= 0x4000;
780 ctp7Data5BX_HCALFB.
isLinkDown(cType, negativeEta,
iEta, iPhi, BX_n))
781 towerDatum |= 0x8000;
794 void CaloLayer1Unpacker::makeRegions5BX_HCALFB(uint32_t lPhi,
798 for (uint32_t side = 0; side <= 1; side++) {
799 bool negativeEta =
false;
804 uint32_t lEta = 10 -
region;
807 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)
uint32_t getFB(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t BX_n)
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
uint32_t getRegionSummary(bool negativeEta, uint32_t region)
bool isLinkMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
bool isTowerMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t BX_n)
void push_back(T const &t)
uint32_t getRegionSummary(bool negativeEta, uint32_t region, uint32_t BX_n)
Log< level::Error, false > LogError
bool isLinkDown(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
bool isTowerMasked(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)
bool isLinkInError(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
bool isLinkMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t BX_n)
bool isLinkInError(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
bool isTowerMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
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)
Abs< T >::type abs(const T &t)
bool isLinkMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
uint32_t getET(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
bool isLinkMisaligned(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, uint32_t BX_n)
bool isLinkDown(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)
uint32_t getFB(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi)
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 isLinkInError(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t BX_n)
bool isLinkMasked(CaloType cType, bool negativeEta, uint32_t cEta, uint32_t iPhi, uint32_t BX_n)
std::vector< L1CaloRegion > L1CaloRegionCollection
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)