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 amc_slot =
block.amc().getAMCNumber();
26 int N_BX = (
block.header().getFlags() >> 16) & 0xf;
28 int HCALFB = (
block.header().getFlags() >> 15) & 0x1;
30 if (not(amc_slot == 7)) {
34 makeECalTPGs(ctp7_phi, ctp7Data,
res->getEcalDigis());
35 makeHCalTPGs(ctp7_phi, ctp7Data,
res->getHcalDigis());
36 makeHFTPGs(ctp7_phi, ctp7Data,
res->getHcalDigis());
37 makeRegions(ctp7_phi, ctp7Data,
res->getRegions());
38 }
else if (HCALFB == 1) {
40 makeECalTPGs_HCALFB(ctp7_phi, ctp7Data_HCALFB,
res->getEcalDigis());
41 makeHCalTPGs_HCALFB(ctp7_phi, ctp7Data_HCALFB,
res->getHcalDigis());
42 makeHFTPGs_HCALFB(ctp7_phi, ctp7Data_HCALFB,
res->getHcalDigis());
43 makeRegions_HCALFB(ctp7_phi, ctp7Data_HCALFB,
res->getRegions());
45 }
else if (
N_BX == 5) {
49 makeECalTPGs5BX(ctp7_phi, ctp7Data5BX,
res->getEcalDigis(), 2);
50 makeHCalTPGs5BX(ctp7_phi, ctp7Data5BX,
res->getHcalDigis(), 2);
51 makeHFTPGs5BX(ctp7_phi, ctp7Data5BX,
res->getHcalDigis(), 2);
52 makeRegions5BX(ctp7_phi, ctp7Data5BX,
res->getRegions(), 2);
53 for (
int i = 0;
i < 5;
i++) {
54 makeECalTPGs5BX(ctp7_phi, ctp7Data5BX,
res->getEcalDigisBx(
i),
i);
56 }
else if (HCALFB == 1) {
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 80 void CaloLayer1Unpacker::makeECalTPGs(uint32_t lPhi,
84 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
85 int cPhi = -1 + lPhi * 4 + iPhi;
91 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeECalTPGs" << std::endl;
94 for (
int cEta = -28; cEta <= 28; cEta++) {
96 bool negativeEta =
false;
107 uint32_t towerDatum = ctp7Data.
getET(cType, negativeEta,
iEta, iPhi);
108 if (ctp7Data.
getFB(cType, negativeEta,
iEta, iPhi) != 0)
109 towerDatum |= 0x0100;
111 towerDatum |= 0x2000;
113 towerDatum |= 0x4000;
117 towerDatum |= 0x8000;
119 int zSide = cEta / ((
int)
iEta);
133 void CaloLayer1Unpacker::makeHCalTPGs(uint32_t lPhi,
137 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
138 int cPhi = -1 + lPhi * 4 + iPhi;
143 else if (cPhi < -1) {
144 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeHCalTPGs" << std::endl;
147 for (
int cEta = -28; cEta <= 28; cEta++) {
149 bool negativeEta =
false;
160 uint32_t towerDatum = ctp7Data.
getET(cType, negativeEta,
iEta, iPhi);
161 if (ctp7Data.
getFB(cType, negativeEta,
iEta, iPhi) != 0)
162 towerDatum |= 0x0100;
164 towerDatum |= 0x0200;
166 towerDatum |= 0x0400;
168 towerDatum |= 0x0800;
170 towerDatum |= 0x2000;
172 towerDatum |= 0x4000;
176 towerDatum |= 0x8000;
190 for (uint32_t side = 0; side <= 1; side++) {
191 bool negativeEta =
false;
195 for (uint32_t iPhi = 0; iPhi < 2; iPhi++) {
196 if (iPhi == 1 &&
iEta == 40)
198 int cPhi = 1 + lPhi * 4 + iPhi * 2;
201 cPhi = (cPhi + 69) % 72 + 1;
213 uint32_t towerDatum = ctp7Data.
getET(cType, negativeEta,
iEta, iPhi);
214 towerDatum |= ctp7Data.
getFB(cType, negativeEta,
iEta, iPhi) << 8;
216 towerDatum |= 0x0400;
218 towerDatum |= 0x0800;
220 towerDatum |= 0x1000;
222 towerDatum |= 0x2000;
224 towerDatum |= 0x4000;
228 towerDatum |= 0x8000;
242 for (uint32_t side = 0; side <= 1; side++) {
243 bool negativeEta =
false;
248 uint32_t lEta = 10 -
region;
251 regions->push_back(
L1CaloRegion((uint16_t)regionData, (
unsigned)lEta, (
unsigned)lPhi, (int16_t)0));
257 void CaloLayer1Unpacker::makeECalTPGs_HCALFB(uint32_t lPhi,
261 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
262 int cPhi = -1 + lPhi * 4 + iPhi;
267 else if (cPhi < -1) {
268 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeECalTPGs_HCALFB" << std::endl;
271 for (
int cEta = -28; cEta <= 28; cEta++) {
273 bool negativeEta =
false;
284 uint32_t towerDatum = ctp7Data_HCALFB.
getET(cType, negativeEta,
iEta, iPhi);
285 if (ctp7Data_HCALFB.
getFB(cType, negativeEta,
iEta, iPhi) != 0)
286 towerDatum |= 0x0100;
288 towerDatum |= 0x2000;
290 towerDatum |= 0x4000;
294 towerDatum |= 0x8000;
296 int zSide = cEta / ((
int)
iEta);
310 void CaloLayer1Unpacker::makeHCalTPGs_HCALFB(uint32_t lPhi,
314 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
315 int cPhi = -1 + lPhi * 4 + iPhi;
320 else if (cPhi < -1) {
321 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeHCalTPGs_HCALFB" << std::endl;
324 for (
int cEta = -28; cEta <= 28; cEta++) {
326 bool negativeEta =
false;
337 uint32_t towerDatum = ctp7Data_HCALFB.
getET(cType, negativeEta,
iEta, iPhi);
338 uint32_t fb = ctp7Data_HCALFB.
getFB(cType, negativeEta,
iEta, iPhi);
339 towerDatum |= ((fb & 0x1) << 8);
340 uint32_t towerDatum2 = ((fb & 0x3E) >> 1);
342 towerDatum |= 0x0200;
344 towerDatum |= 0x0400;
346 towerDatum |= 0x0800;
348 towerDatum |= 0x2000;
350 towerDatum |= 0x4000;
354 towerDatum |= 0x8000;
368 void CaloLayer1Unpacker::makeHFTPGs_HCALFB(uint32_t lPhi,
372 for (uint32_t side = 0; side <= 1; side++) {
373 bool negativeEta =
false;
377 for (uint32_t iPhi = 0; iPhi < 2; iPhi++) {
378 if (iPhi == 1 &&
iEta == 40)
380 int cPhi = 1 + lPhi * 4 + iPhi * 2;
383 cPhi = (cPhi + 69) % 72 + 1;
395 uint32_t towerDatum = ctp7Data_HCALFB.
getET(cType, negativeEta,
iEta, iPhi);
396 towerDatum |= ctp7Data_HCALFB.
getFB(cType, negativeEta,
iEta, iPhi) << 8;
398 towerDatum |= 0x0400;
400 towerDatum |= 0x0800;
402 towerDatum |= 0x1000;
404 towerDatum |= 0x2000;
406 towerDatum |= 0x4000;
410 towerDatum |= 0x8000;
423 void CaloLayer1Unpacker::makeRegions_HCALFB(uint32_t lPhi,
426 for (uint32_t side = 0; side <= 1; side++) {
427 bool negativeEta =
false;
432 uint32_t lEta = 10 -
region;
435 regions->push_back(
L1CaloRegion((uint16_t)regionData, (
unsigned)lEta, (
unsigned)lPhi, (int16_t)0));
445 void CaloLayer1Unpacker::makeECalTPGs5BX(uint32_t lPhi,
450 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
451 int cPhi = -1 + lPhi * 4 + iPhi;
456 else if (cPhi < -1) {
457 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeECalTPGs5BX" << std::endl;
460 for (
int cEta = -28; cEta <= 28; cEta++) {
462 bool negativeEta =
false;
473 uint32_t towerDatum = ctp7Data5BX.
getET(cType, negativeEta,
iEta, iPhi, BX_n);
474 if (ctp7Data5BX.
getFB(cType, negativeEta,
iEta, iPhi, BX_n) != 0)
475 towerDatum |= 0x0100;
477 towerDatum |= 0x2000;
479 towerDatum |= 0x4000;
483 towerDatum |= 0x8000;
485 int zSide = cEta / ((
int)
iEta);
499 void CaloLayer1Unpacker::makeHCalTPGs5BX(uint32_t lPhi,
504 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
505 int cPhi = -1 + lPhi * 4 + iPhi;
510 else if (cPhi < -1) {
511 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeHCalTPGs5BX" << std::endl;
514 for (
int cEta = -28; cEta <= 28; cEta++) {
516 bool negativeEta =
false;
527 uint32_t towerDatum = ctp7Data5BX.
getET(cType, negativeEta,
iEta, iPhi, BX_n);
528 if (ctp7Data5BX.
getFB(cType, negativeEta,
iEta, iPhi, BX_n) != 0)
529 towerDatum |= 0x0100;
531 towerDatum |= 0x0200;
533 towerDatum |= 0x0400;
535 towerDatum |= 0x0800;
537 towerDatum |= 0x2000;
539 towerDatum |= 0x4000;
543 towerDatum |= 0x8000;
555 void CaloLayer1Unpacker::makeHFTPGs5BX(uint32_t lPhi,
560 for (uint32_t side = 0; side <= 1; side++) {
561 bool negativeEta =
false;
565 for (uint32_t iPhi = 0; iPhi < 2; iPhi++) {
566 if (iPhi == 1 &&
iEta == 40)
568 int cPhi = 1 + lPhi * 4 + iPhi * 2;
571 cPhi = (cPhi + 69) % 72 + 1;
583 uint32_t towerDatum = ctp7Data5BX.
getET(cType, negativeEta,
iEta, iPhi, BX_n);
584 towerDatum |= ctp7Data5BX.
getFB(cType, negativeEta,
iEta, iPhi, BX_n) << 8;
586 towerDatum |= 0x0400;
588 towerDatum |= 0x0800;
590 towerDatum |= 0x1000;
592 towerDatum |= 0x2000;
594 towerDatum |= 0x4000;
598 towerDatum |= 0x8000;
611 void CaloLayer1Unpacker::makeRegions5BX(uint32_t lPhi,
615 for (uint32_t side = 0; side <= 1; side++) {
616 bool negativeEta =
false;
621 uint32_t lEta = 10 -
region;
624 regions->push_back(
L1CaloRegion((uint16_t)regionData, (
unsigned)lEta, (
unsigned)lPhi, (int16_t)0));
630 void CaloLayer1Unpacker::makeECalTPGs5BX_HCALFB(uint32_t lPhi,
635 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
636 int cPhi = -1 + lPhi * 4 + iPhi;
641 else if (cPhi < -1) {
642 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeECalTPGs5BX_HCALFB" << std::endl;
645 for (
int cEta = -28; cEta <= 28; cEta++) {
647 bool negativeEta =
false;
658 uint32_t towerDatum = ctp7Data5BX_HCALFB.
getET(cType, negativeEta,
iEta, iPhi, BX_n);
659 if (ctp7Data5BX_HCALFB.
getFB(cType, negativeEta,
iEta, iPhi, BX_n) != 0)
660 towerDatum |= 0x0100;
662 towerDatum |= 0x2000;
664 towerDatum |= 0x4000;
667 ctp7Data5BX_HCALFB.
isLinkDown(cType, negativeEta,
iEta, iPhi, BX_n))
668 towerDatum |= 0x8000;
670 int zSide = cEta / ((
int)
iEta);
684 void CaloLayer1Unpacker::makeHCalTPGs5BX_HCALFB(uint32_t lPhi,
689 for (uint32_t iPhi = 0; iPhi < 4; iPhi++) {
690 int cPhi = -1 + lPhi * 4 + iPhi;
695 else if (cPhi < -1) {
696 LogError(
"CaloLayer1Unpacker") <<
"Major error in makeHCalTPGs5BX_HCALFB" << std::endl;
699 for (
int cEta = -28; cEta <= 28; cEta++) {
701 bool negativeEta =
false;
712 uint32_t towerDatum = ctp7Data5BX_HCALFB.
getET(cType, negativeEta,
iEta, iPhi, BX_n);
713 uint32_t fb = ctp7Data5BX_HCALFB.
getFB(cType, negativeEta,
iEta, iPhi, BX_n);
714 towerDatum |= ((fb & 0x1) << 8);
715 uint32_t towerDatum2 = ((fb & 0x3E) >> 1);
717 towerDatum |= 0x0200;
719 towerDatum |= 0x0400;
720 if (ctp7Data5BX_HCALFB.
isLinkDown(cType, negativeEta,
iEta, iPhi, BX_n))
721 towerDatum |= 0x0800;
723 towerDatum |= 0x2000;
725 towerDatum |= 0x4000;
728 ctp7Data5BX_HCALFB.
isLinkDown(cType, negativeEta,
iEta, iPhi, BX_n))
729 towerDatum |= 0x8000;
743 void CaloLayer1Unpacker::makeHFTPGs5BX_HCALFB(uint32_t lPhi,
748 for (uint32_t side = 0; side <= 1; side++) {
749 bool negativeEta =
false;
753 for (uint32_t iPhi = 0; iPhi < 2; iPhi++) {
754 if (iPhi == 1 &&
iEta == 40)
756 int cPhi = 1 + lPhi * 4 + iPhi * 2;
759 cPhi = (cPhi + 69) % 72 + 1;
771 uint32_t towerDatum = ctp7Data5BX_HCALFB.
getET(cType, negativeEta,
iEta, iPhi, BX_n);
772 towerDatum |= ctp7Data5BX_HCALFB.
getFB(cType, negativeEta,
iEta, iPhi, BX_n) << 8;
774 towerDatum |= 0x0400;
776 towerDatum |= 0x0800;
777 if (ctp7Data5BX_HCALFB.
isLinkDown(cType, negativeEta,
iEta, iPhi, BX_n))
778 towerDatum |= 0x1000;
780 towerDatum |= 0x2000;
782 towerDatum |= 0x4000;
785 ctp7Data5BX_HCALFB.
isLinkDown(cType, negativeEta,
iEta, iPhi, BX_n))
786 towerDatum |= 0x8000;
799 void CaloLayer1Unpacker::makeRegions5BX_HCALFB(uint32_t lPhi,
803 for (uint32_t side = 0; side <= 1; side++) {
804 bool negativeEta =
false;
809 uint32_t lEta = 10 -
region;
812 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)
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)
std::pair< unsigned int, unsigned int > unpack(cond::Time_t since)
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)