45 constexpr std::array<ubit16, 2> inds(
ubit16 channel) {
51 std::array<ubit16, 2>
id = inds(channel);
52 return *(
p +
id[0]) & j <<
id[1] ? 1 : 0;
56Matrix::Matrix(
int run,
int event,
CMAword debug,
int subsys,
int proj,
int sect,
int padadd,
int lowhig,
int add[2],
int locadd,
int NOBXS,
int BCZERO) :
67 cout <<
"=============================================" << endl
68 <<
"Constructor of Matrix called with parameters:" << endl
69 << subsys <<
" " << proj <<
" " << sect <<
" " << lowhig <<
" " <<
add[0] <<
add[1] << endl
70 <<
"=============================================" << endl;
130 if (
m_matrixDebug & 1 << df) { cout <<
"Destructor of Matrix executed " << endl; }
140 for (i = 0; i < 2; i++) {
143 rpcpntnext = rpcpnt->
next;
175 auto zero = [](
auto& arr) { memset( arr, 0,
sizeof(arr) ); };
230 for (j = 0; j <
s_nchan[0]; j++) {
267 for (i = 0; i < 2; i++) {
268 for (j = 0; j < 2; j++) {
283 for (i = 0; i < 2; i++) {
284 for (j = 0; j < 2; j++) {
314 cout <<
"====================================================================" << endl
315 <<
"Matrix::setDefaultConfiguration: "
316 <<
"Default settings have been loaded." << std::endl
317 <<
"===================================================================" << endl;
327 cout <<
"=================================" << std::endl
328 <<
"Matrix::dispDefaultConfiguration:" << std::endl
329 <<
"=================================" << std::endl;
330 cout <<
"--------------------------------" << std::endl <<
"+ Coincidence Windows: " << std::endl;
332 cout <<
" + Threshold address:" << i << std::endl;
333 for (j = 0; j <
s_nchan[0]; j++) {
334 cout <<
" -Channel address:" << j <<
" Window 63-32 " << std::hex <<
m_trigRoad[i][j][1] <<
" Window 31-00 "
335 <<
m_trigRoad[i][j][0] << std::dec << std::endl;
341 cout <<
"--------------------------------" << std::endl
342 <<
"+ Majority addresses: " << std::endl
343 <<
"--------------------------------" << std::endl;
344 for (i = 0; i <
s_nthres; i++) { cout <<
" - threshold address " << i <<
" value " <<
m_majorities[i] << std::endl; }
349 cout <<
"--------------------------------" << std::endl
350 <<
"+ Threshold address low-to-high: " <<
m_lowtohigh << std::endl
351 <<
"+ Threshold address low-to-readout: " <<
m_toreadout << std::endl
352 <<
"+ Threshold address for overlap: " <<
m_overlapthres << std::endl;
356 cout <<
"--------------------------------" << std::endl
357 <<
"+ Local coincidence setting: " << std::endl
359 <<
" -Coincidence Plane: " <<
m_localDirec[1] << std::endl;
363 cout <<
"--------------------------------" << std::endl
364 <<
"+ Overlap mask setting: " << std::endl
366 <<
" -`left ' address " <<
m_matOverlap[1] << std::endl;
370 cout <<
"-----------------------------------------------" << std::endl
371 <<
"+ Channel pulse-width, delay and deadtime : " << std::endl;
372 for (i = 0; i < 2; i++) {
374 cout <<
" +Pivot Plane " << std::endl;
376 cout <<
" +Coincidence Plane " << std::endl;
378 for (j = 0; j < 2; j++) {
379 cout <<
" +Layer " << j << std::endl;
381 cout <<
" -group " << k <<
" pulsewidth " <<
m_pulseWidth[i][j][k] << std::endl;
384 cout <<
" -group " << k <<
" delay " <<
m_channDelay[i][j][k] << std::endl;
387 cout <<
" -group " << k <<
" deadtime " <<
m_channDeadT[i][j][k] << std::endl;
394 cout <<
"-----------------------------------------------" << std::endl <<
"+ Map of the masked-to-0 channels : " << std::endl;
395 for (i = 0; i < 2; i++) {
397 cout <<
" +Pivot Plane " << std::endl;
399 cout <<
" +Coincidence Plane " << std::endl;
401 for (j = 0; j < 2; j++) {
402 cout <<
" +Layer " << j << std::endl;
403 for (k = 0; k <
s_nchan[1]; k++) {
404 if (
m_channMask0[i][j][k]) { cout <<
" -channel " << k << std::endl; }
411 cout <<
"-----------------------------------------------" << std::endl <<
"+ Trigger Dead Time " << std::endl;
413 cout <<
" -group " << k <<
" Trigger DeadTime " <<
m_trigDeadTime[k] << std::endl;
418 cout <<
"-----------------------------------------------" << std::endl
419 <<
"+ Simulation parameters to align with the hardware (not used in CM)" << std::endl;
424 <<
" BunchPhase = 0 : to be used for standard ATLAS LVL1 simulation" << std::endl
425 <<
" BunchPhase = -1 : to be used to compare with the hardware; " << std::endl
426 <<
" this value fixed with VHDL comparison 1-7 august 2004." << std::endl
428 <<
" BunchOffset = 0 : to test with hardware; use this setting with setBCzero(0)." << std::endl;
432 cout <<
"======================================" << std::endl
433 <<
"Matrix::dispDefaultConfiguration: Done" << std::endl
434 <<
"======================================" << std::endl;
443 if (
m_matrixDebug & 1 << df) { cout <<
"Matrix:putData: putting data on Matrix" << endl; }
446 if (time < 0.0) BCID--;
469 if (stripaddress >= 0 && stripaddress <
s_nchan[sidemat]) {
473 rpcpntnew->
layer = layer;
475 rpcpntnew->
time = time;
476 rpcpntnew->
BC = BCID;
477 rpcpntnew->
DLL = DLLID;
481 rpcpntnew->
delay = 0;
490 throw std::out_of_range(
"Matrix::putData failure: channel addressed is " + std::to_string(stripaddress) +
" for matrix side " +
491 std::to_string(sidemat));
503 if (
m_matrixDebug & 1 << df) { cout <<
" method putPatt called; p is " << p << endl; }
530 for (i = 0; i <
s_nchan[0]; i++) {
532 if (p->m_k_pattern[j] & k) {
540 if (
m_matrixDebug & 1 << df) { cout <<
" copy_pivot; input matrix address " << p << endl; }
559 for (
ubit16 iside = 0; iside < 2; iside++) {
560 for (
ubit16 ilayer = 0; ilayer < 2; ilayer++) {
573 if (iside == 0 && igroup > 3) {
574 throw std::out_of_range(
575 "Matrix::setDeadTime: problems with side and group addresses: "
577 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" group=" + std::to_string(igroup));
580 throw std::out_of_range(
581 "Matrix::setDeadTime: problems in adressing pulseWidth: "
583 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" group=" + std::to_string(igroup));
588 if (iside > 1 || ilayer > 1) {
589 throw std::out_of_range(
590 "Matrix::setDelay: problems with side and layer addresses: "
592 std::to_string(iside) +
" layer=" + std::to_string(ilayer));
601 if (iside == 0 && igroup > 3) {
602 throw std::out_of_range(
603 "Matrix::setDelay: problems with side and group addresses:"
605 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" group=" + std::to_string(igroup));
608 throw std::out_of_range(
609 "Matrix::setDelay: problems in adressing pulseWidth:"
611 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" group=" + std::to_string(igroup));
616 for (
ubit16 iside = 0; iside < 2; iside++) {
617 for (
ubit16 ilayer = 0; ilayer < 2; ilayer++) {
631 if (iside == 0 && igroup > 3) {
632 throw std::out_of_range(
633 "Matrix::setDelay: problems with side and group addresses:"
635 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" group=" + std::to_string(igroup));
638 throw std::out_of_range(
639 "Matrix::setDelay: problems in adressing pulseWidth:"
641 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" group=" + std::to_string(igroup));
646 if (iside > 1 || ilayer > 1 || ichannel > (
s_nchan[iside] - 1)) {
647 throw std::out_of_range(
648 "Matrix::setMask0: problems with side/layer/channel addresses: "
650 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" channel=" + std::to_string(ichannel));
657 if (ithreshold > 2 || iside > 1 || imajority > 1 || ichannel > (
s_nchan[iside] - 1)) {
658 throw std::out_of_range(
659 "Matrix::setMask1: problems with side/layer/channel addresses: "
661 std::to_string(ithreshold) +
" side=" + std::to_string(iside) +
" majority=" + std::to_string(imajority) +
662 " channel=" + std::to_string(ichannel));
669 for (
int ichannel = 0; ichannel <
s_nchan[iside]; ichannel++) {
setMask1(ithreshold, iside, imajority, ichannel); }
673 for (
int imajority = 0; imajority < 2; imajority++) {
setMask1(ithreshold, iside, imajority); }
677 if (iside > 1 || ilayer > 1 || ichannel > (
s_nchan[iside] - 1)) {
678 throw std::out_of_range(
679 "Matrix::setMaskReadout: problems with side/layer/channel addresses: "
681 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" channel=" + std::to_string(ichannel));
688 for (
ubit16 i = ichannel; i < (ichannel + nchannels - 1); i++) {
setMaskReadOut(iside, ilayer, ichannel, i); }
716 for (i = 0; i < 2; i++) {
719 for (j = 0; j < 2; j++) {
720 for (jg = 0; jg < addGroupMax; jg++) {
732 for (j = 0; j <
s_nchan[0]; j++) {
744 throw std::out_of_range(
"Matrix::setLocalDirection : add=" + std::to_string(
add) +
" not valid");
751 if (content < 0 || content >> 2) {
752 throw std::out_of_range(
"Matrix::setKReadout : threshold address = " + std::to_string(content) +
" not valid");
759 if (content >= 0 && content <
s_nthres) {
770 throw std::out_of_range(
"Matrix::setTrigDeadTime : igroup= " + std::to_string(igroup) +
" not valid");
780 throw std::out_of_range(
"Matrix::setMajority : add=" + std::to_string(
add) +
" not valid");
788 throw std::out_of_range(
"Matrix::setRoad : addThres= " + std::to_string(addThres) +
" addChn= " + std::to_string(addChn) +
789 " add64= " + std::to_string(add64) +
" not valid");
791 m_trigRoad[addThres][addChn][add64] = content;
797 throw std::out_of_range(
"Matrix::setRoad : addThres= " + std::to_string(addThres) +
" addChn= " + std::to_string(addChn));
802 throw std::runtime_error(
"Matrix::setRoad; outflag from char2int is positive: " + std::to_string(outflag));
810 throw std::out_of_range(
"Matrix::setMatOverlap : add= " + std::to_string(
add) +
" not valid");
818 throw std::out_of_range(
"Matrix::setDiagonal : add= " + std::to_string(
add) +
" not valid");
827 throw std::out_of_range(
"Matrix::getMatOverlap : add= " + std::to_string(
add) +
" not valid");
837 throw std::out_of_range(
"Matrix::getRoad : addThres= " + std::to_string(addThres) +
" addChn= " + std::to_string(addChn) +
838 " add64= " + std::to_string(add64) +
" not valid");
848 throw std::out_of_range(
"Matrix::getMajority : add= " + std::to_string(
add) +
" not valid");
864 cout <<
"====================" << endl
866 <<
"| Matrix::execute |" << endl
867 <<
"| --------------- |" << endl
869 <<
"====================" << endl;
903 cout <<
"--------------------------" << endl <<
"| Matrix::storeDeadtime |" << endl <<
"--------------------------" << endl;
905 for (
ubit16 i = 0; i < 2; i++) {
909 rpchit = rpchit->
next;
918 cout <<
"--------------------" << endl <<
"| Matrix::masking |" << endl <<
"--------------------" << endl;
920 for (
ubit16 i = 0; i < 2; i++) {
924 rpchit = rpchit->
next;
933 cout <<
"--------------------" << endl <<
"| Matrix::delay |" << endl <<
"--------------------" << endl;
935 for (
ubit16 i = 0; i < 2; i++) {
939 rpchit = rpchit->
next;
950 cout <<
"--------------------" << endl <<
"| Matrix::load |" << endl <<
"--------------------" << endl;
953 for (
ubit16 i = 0; i < 2; i++) {
957 cout <<
" Layer= " << rpcpnt->
layer <<
" stripadd= " << rpcpnt->
stripadd <<
" time= " << rpcpnt->
time
958 <<
" mask= " << rpcpnt->
masked <<
" BC= " << rpcpnt->
BC <<
" DLL= " << rpcpnt->
DLL <<
" delay= " << rpcpnt->
delay
966 if (
m_matrixDebug & 1 << df) { cout <<
" abs_time= " << abs_time <<
" timeadd= " << timeadd << endl; }
971 if (timeadd >= 0 && timeadd < m_nclock && !rpcpnt->masked) {
973 cout <<
" setting input with side " << i <<
" " << rpcpnt->
layer <<
" " << timeadd <<
" 0"
974 <<
" for channel " << rpcpnt->
stripadd <<
" timeadd " << timeadd << endl;
979 rpcpnt = rpcpnt->
next;
989 for (
ubit16 i = 0; i < 2; i++) {
990 for (
ubit16 j = 0; j < 2; j++) {
992 for (
ubit16 l = 0; l < 2; l++) {
1003 cout <<
"-------------------------" << endl <<
"| matrix: preprocessing |" << endl <<
"-------------------------" << endl;
1027 ubit16 thres, chan, nconf, conf[4][2];
1028 for (i = 0; i < 4; i++) {
1029 for (j = 0; j < 2; j++) { conf[i][j] = 0; }
1033 cout <<
"--------------------" << endl <<
"| matrix: coincide |" << endl <<
"--------------------" << endl;
1042 cout <<
" Matrix::coincidence; lowhigh= " <<
m_lowhigh << endl
1043 <<
" Matrix::coincidence; majority array ="
1048 for (thres = 0; thres <
s_nthres; thres++) {
1051 nconf =
config(thres, &conf[0][0]);
1061 for (l = 0; l < nconf; l++) {
1062 for (j = 0; j <
s_nchan[0]; j++) {
1077 if (bitstatus(&
m_mjori[thres][0][conf[l][0]][i][0], j) &&
1081 cout <<
"coincidence!!!"
1082 <<
" clock=" << i <<
" xchan=" << j << endl;
1087 if (BCaddress >= 0 && BCaddress <
m_Nbunch)
1109 for (chan = 0; chan <
s_nchan[0]; chan++) {
1110 for (thres = 0; thres <
s_nthres; thres++) {
1111 for (i =
m_nclock - 1; i > 0; i--) {
1112 previousTime = bitstatus(&
m_trigg[thres][i - 1], chan);
1120 for (chan = 0; chan <
s_nchan[0]; chan++) {
1121 for (thres = 0; thres <
s_nthres; thres++) {
1122 for (i =
m_nclock - 1; i > 0; i--) {
1123 if (bitstatus(&
m_trigg[thres][i], chan)) {
1136 for (thres = 0; thres <
s_nthres; thres++) {
1142 if (BCaddress >= 0 && BCaddress <
m_Nbunch) {
1156 for (m = 0; m < 2; m++) {
1159 if (BCaddress >= 0 && BCaddress <
m_Nbunch) {
1171 for (m = 0; m < 2; m++) {
1179 for (m = 0; m < 2; m++) {
1188 cout <<
"---------------------" << endl <<
"| Matrix::mask_to_1 |" << endl <<
"---------------------" << endl;
1193 for (i = 0; i < 2; i++) {
1194 for (j = 0; j < 2; j++) {
1195 for (l = 0; l <
s_nchan[i]; l++) {
1212 for (i = 0; i < 2; i++) {
1213 for (j = 0; j < 2; j++) {
1214 for (k = 0; k <
s_nchan[i]; k++) {
1218 for (l = 0; l < (
m_nclock - 1); l++) {
1219 ((!bitstatus(&
m_input[i][j][l][0], k)) && bitstatus(&
m_input[i][j][l + 1][0], k)) ?
temp[l + 1] = 1 :
temp[l + 1] = 0;
1251 cout <<
"-----------------------" << endl <<
"| Matrix::pulse_width |" << endl <<
"-----------------------" << endl;
1254 for (i = 0; i < 2; i++) {
1255 for (j = 0; j < 2; j++) {
1256 for (l = 0; l <
s_nchan[i]; l++) {
1257 for (k =
m_nclock - 1; k >= 0; k--) {
1258 if (bitstatus(&
m_input[i][j][k][0], l)) {
1289 cout <<
"-------------------" << endl <<
"| Matrix::majori |" << endl <<
"-------------------" << endl;
1298 for (i = 0; i < 2; i++) {
1300 for (k = 0; k < 2; k++) {
1302 buffi[k] =
m_prepr[n][i][1][j][k];
1305 shift(&buffi[0], &buffo[0], i);
1306 for (k = 0; k < 2; k++) {
1315 for (l = 0; l <
s_nchan[i]; l++) {
1316 if (bitstatus(&
m_mjori[n][i][1][j][0], l)) {
1332 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k); }
1335 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k) << 1; }
1336 *(buffo + 1) = (*(buffi + 0) & 0x80000000) ? (*(buffo + 1) | 0x1) : (*(buffo + 1) | 0);
1339 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k) | (*(buffi + k) << 1); }
1340 *(buffo + 1) = (*(buffi + 0) & 0x80000000) ? (*(buffo + 1) | 0x1) : (*(buffo + 1) | 0);
1343 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k) >> 1; }
1344 *(buffo + 0) = (*(buffi + 1) & 0x1) ? (*(buffo + 0) | 0x80000000) : (*(buffo + 0) | 0);
1347 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k) | (*(buffi + k) >> 1); }
1348 *(buffo + 0) = (*(buffi + 1) & 0x1) ? (*(buffo + 0) | 0x80000000) : (*(buffo + 0) | 0);
1351 for (k = 0; k < 2; k++) { *(buffo + k) = (*(buffi + k) >> 1) | (*(buffi + k) << 1); }
1352 *(buffo + 0) = (*(buffi + 1) & 0x1) ? (*(buffo + 0) | 0x80000000) : (*(buffo + 0) | 0);
1353 *(buffo + 1) = (*(buffi + 0) & 0x80000000) ? (*(buffo + 1) | 0x1) : (*(buffo + 1) | 0);
1356 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k) | (*(buffi + k) >> 1) | (*(buffi + k) << 1); }
1357 *(buffo + 0) = (*(buffi + 1) & 0x1) ? (*(buffo + 0) | 0x80000000) : (*(buffo + 0) | 0);
1358 *(buffo + 1) = (*(buffi + 0) & 0x80000000) ? (*(buffo + 1) | 0x1) : (*(buffo + 1) | 0);
1361 cout <<
" Matrix::shift -- m_localDirec[" << i <<
"]=" <<
m_localDirec[i] <<
" not expected; m_localDirec forced to be 1 "
1363 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k); }
1369 if (!i) *(buffo + 1) = 0;
1379 ubit16 nup, first, i, j, k, l;
1382 cout <<
"------------------------" << endl <<
"| matrix: declustering |" << endl <<
"------------------------" << endl;
1387 for (i = 0; i < 2; i++) {
1388 for (j = 0; j < 2; j++) {
1391 for (l = 0; l <
s_nchan[i]; l++) {
1392 if (bitstatus(&
m_input[i][j][k][0], l)) {
1394 if (nup == 1) first = l;
1396 if (!bitstatus(&
m_input[i][j][k][0], l) || (l == (
s_nchan[i] - 1))) {
1398 reduce(i, j, k, 0, nup, first);
1424 cout <<
" --------------------" << endl
1425 <<
" | Matrix::reduce |" << endl
1426 <<
" --------------------" << endl
1427 <<
" nup= " << nup <<
" first " << first << endl;
1437 }
else if (nup == 3) {
1440 }
else if (nup == 4) {
1443 }
else if (nup > 4) {
1447 if (
m_matrixDebug & 1 << df) { cout <<
" j= " << j <<
" ncop= " << ncop << endl; }
1451 for (na = 0; na <
s_nthres; na++) {
1452 for (i = j; i < j + ncop; i++) {
1491 for (k = 0; k <
s_nchan[0]; k++) {
1507 const ubit16 maxchan = 100;
1508 const ubit16 maxtimes = 1000;
1510 ubit16 IJ[maxtimes][4]{};
1513 ubit16 channels[maxtimes][4][maxchan]{};
1514 float times[maxtimes]{};
1516 const float timeOffsetHit = 114.675;
1521 strcpy(plane[0],
"I0");
1522 strcpy(plane[1],
"I1");
1523 strcpy(plane[2],
"J0");
1524 strcpy(plane[3],
"J1");
1526 cout <<
"-------------------------------" << endl
1527 <<
"| Matrix::makeTestPattern |" << endl
1528 <<
"-------------------------------" << endl;
1536 for (i = 0; i < 2; i++) {
1540 rpcpnt = rpcpnt->
next;
1544 while (!completed) {
1546 timemin = 999999999.;
1547 for (i = 0; i < 2; i++) {
1550 if (rpcpnt->
time < timemin && !rpcpnt->
mark) {
1551 timemin = rpcpnt->
time;
1554 rpcpnt = rpcpnt->
next;
1558 if (ntimes < maxtimes) ntimes += 1;
1559 times[ntimes - 1] = timemin;
1560 for (i = 0; i < 2; i++) {
1563 if (rpcpnt->
time == timemin) {
1565 if (IJ[ntimes - 1][rpcpnt->
layer + 2 * i] < maxchan) { IJ[ntimes - 1][rpcpnt->
layer + 2 * i] += 1; }
1566 channels[ntimes - 1][rpcpnt->
layer + 2 * i][IJ[ntimes - 1][rpcpnt->
layer + 2 * i] - 1] = rpcpnt->
stripadd;
1568 rpcpnt = rpcpnt->
next;
1578 vhdlinput.open(
"k-trigger.output", ios::app);
1580 cout <<
" File for vhdl analysis not opened. " << endl <<
" ==================================" << endl << endl;
1583 cout <<
" File for vhdl analysis correctly opened" << endl << endl;
1588 vhdlinput <<
" LINES " << (ntimes + ktimes) << std::endl;
1590 for (l = 0; l < ntimes; l++) {
1591 vhdlinput <<
" TIME " << times[l] + timeOffsetHit <<
" ";
1592 for (i = 0; i < 4; i++) {
1593 vhdlinput << plane[i][0] << plane[i][1] <<
" " << IJ[l][i] <<
" ";
1594 for (j = 0; j < IJ[l][i]; j++) { vhdlinput << channels[l][i][IJ[l][i] - 1 - j] <<
" "; }
1596 vhdlinput << std::endl;
1604 const float timeOffsetKPa = 168.125;
1605 const float timeOffsetThr = 210.500;
1608 ubit16 chanHistory[32]{};
1609 const ubit16 maxchan = 100;
1620 for (i = 0; i <
m_nclock; i++) { nchannels[i][0][0] = 0; }
1625 for (l = 0; l <
s_nchan[0]; l++) {
1627 if (!chanHistory[l]) {
1629 if (ntimes < maxtimes) ntimes += 1;
1630 times[ntimes - 1] = time;
1632 if (nchannels[ntimes - 1][0][0] < maxchan) nchannels[ntimes - 1][0][0] += 1;
1633 channels[ntimes - 1][0][0][nchannels[ntimes - 1][0][0] - 1] = l;
1644 ubit16 nthresPass, thresPass[8], overlPass[8], BCidentifier[8];
1650 BCidentifier[nthresPass] = i;
1658 ofstream out_k_trigger;
1659 out_k_trigger.open(
"k-trigger.output", ios::app);
1663 for (i = 0; i < ntimes; i++) {
1664 out_k_trigger <<
" TIME " << times[i] + timeOffsetKPa <<
" K ";
1665 out_k_trigger << nchannels[i][0][0] <<
" ";
1666 for (l = 0; l < nchannels[i][0][0]; l++) { out_k_trigger << channels[i][0][0][l] <<
" "; }
1667 out_k_trigger << endl;
1671 for (i = 0; i < nthresPass; i++) {
1672 out_k_trigger <<
" TIME " << BCidentifier[i] * 25. + timeOffsetThr;
1673 out_k_trigger <<
" THR " << thresPass[i] << endl;
1675 out_k_trigger <<
" TIME " << BCidentifier[i] * 25. + timeOffsetThr;
1676 out_k_trigger <<
" OVL " << overlPass[i] << std::endl;
1681 out_k_trigger.close();
1725 default:
throw std::runtime_error(
"Matrix::config: the majority " + std::to_string(
m_majorities[i]) +
" is unforeseen");
1741 default:
throw std::runtime_error(
"Matrix::config: the majority " + std::to_string(
m_majorities[i]) +
" is unforeseen");
1744 default:
throw std::runtime_error(
"Matrix::config: lowhighpt " + std::to_string(
m_lowhigh) +
" is unforeseen");
1775 std::array<ubit16, 2> i = inds(channel);
1776 if (!(channel < 0)) {
1777 *(p + i[0]) = *(p + i[0]) | j << i[1];
1779 throw std::out_of_range(
"Matrix::set_to_1: channel is negative; channel=" + std::to_string(channel));
1785 std::array<ubit16, 2> i = inds(channel);
1786 if (!(channel < 0)) {
1787 *(p + i[0]) = *(p + i[0]) & ~(j << i[1]);
1789 throw std::out_of_range(
"Matrix::set_to_1: channel is negative; channel=" + std::to_string(channel));
1796 cout <<
"-----------------------" << endl
1797 <<
"| Matrix::wind |" << endl
1798 <<
"-----------------------" << endl
1799 <<
" Matrix Roads " << endl;
1801 for (j = 0; j <
s_nchan[0]; j++) {
1802 cout <<
" thres. " << i <<
" channel "
1806 <<
" Road0 " << hex << (
m_trigRoad[i][j][0]) << dec <<
" Road1 " << hex << (
m_trigRoad[i][j][1]) << dec << endl;
1809 cout <<
" majorities: " << endl;
1810 for (i = 0; i < 3; i++) { cout <<
m_majorities[i] <<
" " << endl; }
1812 <<
" number of overlapping ' low' channels: " <<
m_matOverlap[0] << endl
1813 <<
" number of overlapping 'high' channels: " <<
m_matOverlap[1] << endl;
1814 for (i = 0; i <
s_nchan[0]; i++) { cout <<
" channel " << i <<
" in coincidence with " <<
m_diagonal[i] << endl; }
1823 cout <<
"=======================" << endl <<
"|| Matrix Display ||" << endl <<
"=======================" << endl << endl;
1826 cout << endl <<
" All raw data " << endl;
1827 for (i = 0; i < 2; i++) {
1828 cout <<
" Matrix Side is " << i << endl;
1831 cout <<
" Layer= " << rpcpnt->
layer <<
" stripadd= " << rpcpnt->
stripadd <<
" time= " << rpcpnt->
time
1832 <<
" mask= " << rpcpnt->
masked <<
" BC= " << rpcpnt->
BC <<
" DLL= " << rpcpnt->
DLL <<
" delay= " << rpcpnt->
delay << endl;
1833 rpcpnt = rpcpnt->
next;
1838 cout <<
" Display Matrix Input " << endl;
1844 cout <<
" Display Matrix Preprocessing " << endl;
1849 cout <<
" Display Matrix Majority " << endl;
1854 cout <<
" Display Trigger " << endl;
1866 cout <<
" Matrix Attributes: " << endl
1877 for (i = 0; i < 2; i++) {
1878 cout <<
" CMA Side (0=side-x; 1=side-y) " << i << endl;
1879 for (j = 0; j < 2; j++) {
1882 cout <<
" Layer " << j << endl;
1886 cout <<
" Layer " << j << endl;
1897 cout <<
" Threshold address " << i << endl;
1898 for (j = 0; j < 2; j++) {
1899 cout <<
" CMA Side (0=side-x; 1=side-y) " << j << endl;
1900 for (k = 0; k < 2; k++) {
1901 cout <<
" Majority type (0=1/2; 1=2/2) " << k << endl;
1909 cout <<
" Trigger Threshold address " << i << endl;
1912 cout <<
" ReadOut Buffer " << endl;
1915 default: cout <<
" Matrix::disp_CMAreg id value " <<
id <<
" not foreseen " << endl;
1919 cout <<
" " << endl;
1927 std::ostringstream strdisp;
1931 for (j = 0; j <
s_nchan[side]; j += 2) { strdisp <<
" " << j % 10; }
1932 strdisp <<
" " << endl;
1934 strdisp <<
" " << j % 10 <<
" ";
1935 for (k = 0; k < n; k++) {
1938 strdisp <<
" " << endl;
1942 cout << strdisp.str() << endl;
1951 std::ostringstream strdisp;
1954 for (j = 0; j <
s_nchan[0]; j += 2) { strdisp <<
" " << j % 10; }
1955 strdisp <<
" " << endl;
1957 strdisp <<
" " << j % 10 <<
" ";
1959 strdisp <<
" " << endl;
1962 cout << strdisp.str() << endl;
1984 std::ostringstream strdisp;
1987 <<
" =========================" << endl
1989 <<
" = Matrix::dispWind =" << endl
1990 <<
" = Threshold address " << thres <<
" =" << endl
1992 <<
" =========================" << endl
1999 strdisp <<
" " << j <<
" ";
2001 strdisp << j <<
" ";
2004 if ((
m_trigRoad[thres][k][ad1]) & (1 << ad2)) {
2010 strdisp <<
" " << endl;
2012 strdisp <<
" " << endl;
2013 strdisp <<
" 00000000001111111111222222222233" << endl <<
" 01234567890123456789012345678901" << endl;
2015 cout << strdisp.str() << endl;
2024 if (stringLength > 16) {
2027 for (
ubit16 i = 0; i < stringLength; i++) {
2029 if (*(
str + stringLength - 1 - i) ==
'0')
2030 the32[i / 8] = the32[i / 8] + 0;
2031 else if (*(
str + stringLength - 1 - i) ==
'1')
2032 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 1;
2033 else if (*(
str + stringLength - 1 - i) ==
'2')
2034 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 2;
2035 else if (*(
str + stringLength - 1 - i) ==
'3')
2036 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 3;
2037 else if (*(
str + stringLength - 1 - i) ==
'4')
2038 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 4;
2039 else if (*(
str + stringLength - 1 - i) ==
'5')
2040 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 5;
2041 else if (*(
str + stringLength - 1 - i) ==
'6')
2042 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 6;
2043 else if (*(
str + stringLength - 1 - i) ==
'7')
2044 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 7;
2045 else if (*(
str + stringLength - 1 - i) ==
'8')
2046 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 8;
2047 else if (*(
str + stringLength - 1 - i) ==
'9')
2048 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 9;
2049 else if (*(
str + stringLength - 1 - i) ==
'a' || *(
str + stringLength - 1 - i) ==
'A')
2050 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 10;
2051 else if (*(
str + stringLength - 1 - i) ==
'b' || *(
str + stringLength - 1 - i) ==
'B')
2052 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 11;
2053 else if (*(
str + stringLength - 1 - i) ==
'c' || *(
str + stringLength - 1 - i) ==
'C')
2054 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 12;
2055 else if (*(
str + stringLength - 1 - i) ==
'd' || *(
str + stringLength - 1 - i) ==
'D')
2056 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 13;
2057 else if (*(
str + stringLength - 1 - i) ==
'e' || *(
str + stringLength - 1 - i) ==
'E')
2058 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 14;
2059 else if (*(
str + stringLength - 1 - i) ==
'f' || *(
str + stringLength - 1 - i) ==
'F')
2060 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 15;
2080 for (
ubit16 i = 1; i <= expo; i++) { output = output *
base; }
unsigned short int ubit16
BaseObject(ObjectType, const std::string &)
CMAword intPow(const ubit16 base, const ubit16 expo) const
Matrix(int run, int event, CMAword debug, int subsys, int proj, int sect, int padadd, int lowhig, int add[2], int locadd, int NOBXS, int BCZERO)
CMAword m_channReadOutMask[2][2][2]
CMAword m_triggerOverlapRO[64][2]
static const ubit16 s_nthres
static const float s_DLLtime
void disp_CMAreg(ubit16 id) const
void setRunEvent(int runNum, int eventNum)
void setDelay(ubit16 iside, ubit16 ilayer, ubit16 delay)
void set_to_1(CMAword *p, sbit16 channel) const
int getProjection() const
CMAword m_channMask1[3][2][2][2]
void show_attributes() const
void dispBinary(const CMAword *p, std::ostream &strdisp) const
ubit16 m_channDeadT[2][2][8]
void reduce(ubit16 ia, ubit16 ja, ubit16 ka, ubit16 la, ubit16 nup, ubit16 first)
static const sbit16 s_ROOffset
static const sbit16 s_timeGroupA
ubit16 char2int(const char *str, CMAword the32[2])
ubit16 config(ubit16 i, ubit16 *arr) const
void setOverlaThres(int overthres)
ubit16 getOutputThres(ubit16 bunch) const
void dispDefaultConfiguration() const
CMAword getMatOverlap(ubit16 add) const
void setMask1(ubit16 ithreshold, ubit16 iside, ubit16 imajority, ubit16 ichannel)
void set_to_0(CMAword *p, sbit16 channel) const
static const float s_BCtime
void makeTestPattern(ubit16 mode, ubit16 ktimes)
CMAword m_input[2][2][64][2]
CMAword m_k_pattern[8 *64]
void dispTrigger(const CMAword *p) const
CMAword rodat[2][2][64][2]
Note array lengths using hardcoded values rather than to depend on NOBXS as they were in the past (as...
void setTrigDeadTime(ubit16 deadt)
void putPatt(const Matrix *p)
static const ubit16 s_NDLLCYC
void setMaskReadOut(ubit16 iside, ubit16 ilayer, ubit16 ichannel)
void setKReadOut(int kToReadout)
void shift(CMAword *buffi, CMAword *buffo, ubit16 i) const
CMAword m_mjori[3][2][2][64][2]
CMAword m_prepr[3][2][2][64][2]
void setConfig(int *l, ubit16 *p1, int *k, CMAword *p2, int *q, CMAword *o, sbit32 *g)
ubit16 getOutputOverl(ubit16 bunch) const
static const sbit16 s_timeGroupB
void setMask0(ubit16 iside, ubit16 ilayer, ubit16 ichannel)
void setDefaultConfiguration()
int getMajority(ubit16 add) const
void dispRegister(const CMAword *p, ubit16 side) const
sbit16 getBunchPhase() const
ubit16 m_channDelay[2][2][4]
ubit16 m_channMask0[2][2][64]
CMAword m_triggerOverlap[8][2]
static const ubit16 s_nchan[2]
void putData(int sidemat, int layer, int stripaddress, float time)
CMAword getRoad(ubit16 addThres, ubit16 addChn, ubit16 add64) const
void setDeadTime(ubit16 deadt)
CMAword m_trigRoad[3][32][2]
void setMatOverlap(ubit16 add, CMAword content)
void setBCzero(ubit16 offset)
ubit16 m_pulseWidth[2][2][8]
void setLocalDirection(ubit16 add, int content)
void setPulseWidth(ubit16 length)
void setMajority(ubit16 add, int content)
void setRoad(ubit16 addThres, ubit16 addChn, ubit16 add64, CMAword content)
sbit16 getBunchOffset() const
static const sbit16 s_wordlen
void setDiagonal(ubit16 add, sbit32 content)
void zero(TH2 *h)
zero the contents of a 2d histogram
bool add(const std::string &hname, TKey *tobj)
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
int run(int argc, char *argv[])