32unsigned setbits(
unsigned x,
int msb,
int lsb,
unsigned y) {
34 mask = (~0u << (msb + 1)) | ~(~0u << lsb);
35 return (
x & mask) | (
y << lsb);
46ostream &
dfpa(ostream &stream,
int indent,
int whitesp,
int ntimes) {
47 int iind = 0, iwhit = 0, itime = 0;
48 for (iind = 0; iind <= indent - 1; iind++) stream <<
" ";
49 for (itime = 0; itime <= ntimes - 1; itime++) {
50 for (iwhit = 0; iwhit <= whitesp - 1; iwhit++) stream <<
" ";
51 stream <<
"b o r o o p m n s";
54 for (iind = 0; iind <= indent - 1; iind++) stream <<
" ";
55 for (itime = 0; itime <= ntimes - 1; itime++) {
56 for (iwhit = 0; iwhit <= whitesp - 1; iwhit++) stream <<
" ";
57 stream <<
"c p s e f t t t g";
67 stream << o.
bcid <<
" ";
70 stream << o.
opl <<
" ";
72 stream << o.
oveta <<
" ";
73 stream << o.
ovphi <<
" ";
74 stream << o.
pt <<
" ";
75 stream << o.
roi <<
" ";
76 stream << o.
ntrig <<
" ";
83ostream &
ofsla(ostream &stream,
int indent,
int whitesp,
int ntimes) {
84 int iind = 0, iwhit = 0, itime = 0;
85 for (iind = 0; iind <= indent - 1; iind++) stream <<
" ";
86 for (itime = 0; itime <= ntimes - 1; itime++) {
87 for (iwhit = 0; iwhit <= whitesp - 1; iwhit++) stream <<
" ";
88 stream <<
"ss bnnppoorproorprn";
91 for (iind = 0; iind <= indent - 1; iind++) stream <<
" ";
92 for (itime = 0; itime <= ntimes - 1; itime++) {
93 for (iwhit = 0; iwhit <= whitesp - 1; iwhit++) stream <<
" ";
94 stream <<
"gg cttttefsdiefsdit";
97 for (iind = 0; iind <= indent - 1; iind++) stream <<
" ";
98 for (itime = 0; itime <= ntimes - 1; itime++) {
99 for (iwhit = 0; iwhit <= whitesp - 1; iwhit++) stream <<
" ";
100 stream <<
"21 21212222211111 ";
109 stream.setf(std::ios::dec, std::ios::basefield);
142 for (j = 0; j <= 7; j++) {
143 stream <<
"pad[" << j <<
"] : ";
144 stream << o.
pad[j] << std::endl;
146 stream.setf(ios::hex, ios::basefield);
147 stream <<
"tile : " << o.
tile << std::endl;
148 stream <<
"sl out : " << o.
out;
149 stream.setf(ios::hex, ios::basefield);
179 for (j = 0; j <= 7; j++) {
181 for (k = 0; k <= 2; k++) {
196 if (bunchID < m_nBunMax && bunchID >= 0) {
200 throw std::out_of_range(
"SectorLogic::outputToMuCTPI: bunchID out of range: " + std::to_string(bunchID));
224 for (bcid = 0; bcid <=
m_nBunMax - 1; bcid++) {
225 cout <<
"LowPtFilter_in BCID is " <<
m_LowPtFilter_in[bcid].out.bcid << std::endl
234 <<
"SortHighest_in BCID is " <<
m_SortHighest_in[bcid].out.bcid << std::endl
248 for (i = 0; i <= 7; i++) {
249 for (j = 0; j <= 5; j++) {
m_SetTCCheck[i][j] = SetTCCheck_in[i][j]; }
258 for (i = 0; i <= 7; i++) {
259 for (j = 0; j <= 2; j++) {
m_SetOPLCheck[i][j] = SetOPLCheck_in[i][j]; }
268 for (ipad = 0; ipad <= 7; ipad++) {
m_InFromPad[bx][ipad] = from_pad[ipad]; }
322 fmtout = fmtout | ((slroi1 & 0x1f) << 1);
323 fmtout = fmtout | ((0 & 0x03) << 6);
326 fmtout = fmtout | ((slroi2 & 0x1f) << 10);
327 fmtout = fmtout | ((0 & 0x03) << 15);
334 fmtout = fmtout | ((bc & 0x07) << 27);
345 for (ibx = 0; ibx <=
m_nBunMax - 1; ibx++) {
363 for (i1 = 0; i1 <= 7; i1++) {
367 if (0 < Pt_reg1 && Pt_reg1 <= 3) {
387 for (j1 = 0; j1 <= 7; j1++) {
391 if (0 < Pt_reg2 && Pt_reg2 <= 6) {
396 if (0 < Pt_reg2 && Pt_reg2 <= 3) {
401 if (
getbits(EnableTCCheck, j1 * 4 + Pt_reg2, j1 * 4 + Pt_reg2) == 1) {
402 int TileCalCheck = 0;
421 for (k1 = 0; k1 <= 7; k1++) {
424 std::cout <<
"pad # " << k1 <<
" bcid # " << ibx <<
" has eta overlap flag on but no triggered track" << std::endl;
430 for (kk = 0; kk <= 1; kk++) {
432 for (k3 = kk; k3 <= 6 - kk; k3 = k3 + 2) {
449 std::cout <<
"pads " << k3 <<
" and " << k3 + 1 <<
" have eta overlap flags on with wrong RoIs"
467 for (l1 = 0; l1 <= 7; l1++) {
503 for (m1 = 0; m1 <= 7; m1++) {
533 for (m1 = 0; m1 <= 7; m1++) {
545 stream <<
"@@@@@@@@@@ event and sector logic identification @@@@@@@@@@\n\n";
547 stream <<
"run = " << o.
m_run << std::endl;
548 stream <<
"event = " << o.
m_event << std::endl;
549 stream <<
"debug = " << o.
m_debug << std::endl;
550 stream <<
"subsys = " << o.
m_subsys << std::endl;
551 stream <<
"sect = " << o.
m_sect << std::endl;
556 stream <<
"@@@@@@@@@@ sector logic configuration parameters @@@@@@@@@@\n\n";
559 stream.setf(ios::hex, ios::basefield);
560 stream <<
"EnableTCCheckLow : ";
564 stream <<
"EnableTCCheckHigh : ";
570 for (jj = 0; jj <= 7; jj++) {
571 stream <<
"SetTCCheck pad[";
574 for (kk = 5; kk >= 0; kk--) {
584 stream <<
"EnableOPLCheck : ";
588 for (jj = 0; jj <= 7; jj++) {
589 stream <<
"SetOPLCheck pad[";
592 for (kk = 2; kk >= 0; kk--) {
622 stream <<
"@@@@@@@@@@ sector logic input registers @@@@@@@@@@\n\n";
625 stream.setf(std::ios::dec, std::ios::basefield);
626 dfpa(stream, 8, 8, nBunMax);
628 for (ipad = 0; ipad <= 7; ipad++) {
629 stream <<
"pad[" << ipad <<
"] :";
630 for (ibx = 0; ibx <= nBunMax - 1; ibx++) {
638 stream.setf(std::ios::hex, std::ios::basefield);
640 for (ibx = 0; ibx <= nBunMax - 1; ibx++) {
648 stream << std::endl << std::endl;
651 stream <<
"@@@@@@@@@@ sector logic internal registers @@@@@@@@@@\n\n";
654 for (ireg = 0; ireg <= 4; ireg++) {
656 stream <<
"internal registers # " << ireg + 1 <<
" (input)" << std::endl;
658 stream.setf(std::ios::dec, std::ios::basefield);
659 dfpa(stream, 8, 8, nBunMax);
660 for (ipad = 0; ipad <= 7; ipad++) {
661 stream <<
"pad[" << ipad <<
"] :";
662 for (ibx = 0; ibx <= nBunMax - 1; ibx++) {
664 stream << (intreginp[ireg] + ibx)->pad[ipad];
669 stream.setf(ios::hex, ios::basefield);
671 for (ibx = 0; ibx <= nBunMax - 1; ibx++) {
675 stream << (intreginp[ireg] + ibx)->tile;
681 stream.setf(std::ios::dec, std::ios::basefield);
682 stream <<
"sl out :";
683 for (ibx = 0; ibx <= nBunMax - 1; ibx++) {
685 stream << (intreginp[ireg] + ibx)->out;
691 stream <<
"internal registers # " << ireg + 1 <<
" (output)" << std::endl;
693 stream.setf(std::ios::dec, std::ios::basefield);
694 dfpa(stream, 8, 8, nBunMax);
695 for (ipad = 0; ipad <= 7; ipad++) {
696 stream <<
"pad[" << ipad <<
"] :";
697 for (ibx = 0; ibx <= nBunMax - 1; ibx++) {
699 stream << (intregoutp[ireg] + ibx)->pad[ipad];
704 stream.setf(std::ios::hex, std::ios::basefield);
706 for (ibx = 0; ibx <= nBunMax - 1; ibx++) {
710 stream << (intregoutp[ireg] + ibx)->tile;
716 stream.setf(std::ios::dec, std::ios::basefield);
717 stream <<
"sl out :";
718 for (ibx = 0; ibx <= nBunMax - 1; ibx++) {
720 stream << (intregoutp[ireg] + ibx)->out;
722 stream << std::endl << std::endl;
726 stream.setf(std::ios::dec, std::ios::basefield);
727 stream <<
"@@@@@@@@@@ sector logic output register @@@@@@@@@@\n\n";
728 ofsla(stream, 8, 5, nBunMax);
730 for (ibx = 0; ibx <= nBunMax - 1; ibx++) {
unsigned short int ubit16
ostream & ofsla(ostream &stream, int indent, int whitesp, int ntimes)
CMAword getbits(CMAword x, int msb, int lsb)
ostream & dfpa(ostream &stream, int indent, int whitesp, int ntimes)
unsigned setbits(unsigned x, int msb, int lsb, unsigned y)
BaseObject(ObjectType, const std::string &)
std::array< DataFromPad, 8 > pad
InternalRegister()=default
OutputFromSectorLogic out
OutputFromSectorLogic()=default
std::array< InternalRegister, 8 > m_LowPtFilter_out
std::array< InternalRegister, 8 > m_Sort2ndHighest_out
SectorLogic(int run, int event, CMAword debug, ubit16 subsys, ubit16 sect, bool oldSimulation, uint NOBXS, uint BCZERO)
CMAword m_EnableTCCheckHigh
std::array< OutputFromSectorLogic, 8 > m_OutFromSectorLogic
std::array< InternalRegister, 8 > m_SortHighest_in
std::array< InternalRegister, 8 > m_SolveEtaOverlap_out
std::array< InternalRegister, 8 > m_TileCalConfirm_in
std::array< InternalRegister, 8 > m_LowPtFilter_in
std::array< CMAword, 8 > m_InFromTileCal
std::array< InternalRegister, 8 > m_SortHighest_out
ubit16 numberOfBunches() const
std::array< InternalRegister, 8 > m_Sort2ndHighest_in
void dbginput(ubit16 bx, DataFromPad from_pad[8], CMAword from_tile_cal)
OutputFromSectorLogic dbgoutput(ubit16 bx)
CMAword outputToMuCTPI(int deltaBC=0)
CMAword m_EnableTCCheckLow
CMAword m_SetTCCheck[8][6]
void LoadOPLCheck(CMAword EnableOPLCheck_in, ubit16 SetOPLCheck_in[8][3])
std::array< InternalRegister, 8 > m_SolveEtaOverlap_in
void LoadTCCheck(CMAword EnableTCCheckLow_in, CMAword EnableTCCheckHigh_in, CMAword SetTCCheck_in[8][6])
std::array< InternalRegister, 8 > m_TileCalConfirm_out
ubit16 m_SetOPLCheck[8][3]
DataFromPad m_InFromPad[8][8]
void load(ubit16 padAdd, ubit16 BX, ubit16 RoIAdd, ubit16 pT, ubit16 OPL, ubit16 overlapPhi, ubit16 overlapEta, ubit16 RoiAmbiguity, ubit16 BCIDcounter)
ostream & operator<<(ostream &s, const SG::VarHandleKey &m)
int run(int argc, char *argv[])