42 constexpr std::array<ubit16, 2> inds(
ubit16 channel) {
48 std::array<ubit16, 2>
id = inds(channel);
49 return *(
p +
id[0]) & j <<
id[1] ? 1 : 0;
53Matrix::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) :
64 cout <<
"=============================================" << endl
65 <<
"Constructor of Matrix called with parameters:" << endl
66 << subsys <<
" " << proj <<
" " << sect <<
" " << lowhig <<
" " <<
add[0] <<
add[1] << endl
67 <<
"=============================================" << endl;
127 if (
m_matrixDebug & 1 << df) { cout <<
"Distructor of Matrix executed " << endl; }
137 for (i = 0; i < 2; i++) {
140 rpcpntnext = rpcpnt->
next;
172 auto zero = [](
auto& arr) { memset( arr, 0,
sizeof(arr) ); };
227 for (j = 0; j <
s_nchan[0]; j++) {
264 for (i = 0; i < 2; i++) {
265 for (j = 0; j < 2; j++) {
280 for (i = 0; i < 2; i++) {
281 for (j = 0; j < 2; j++) {
311 cout <<
"====================================================================" << endl
312 <<
"Matrix::setDefaultConfiguration: "
313 <<
"Default settings have been loaded." << std::endl
314 <<
"===================================================================" << endl;
324 cout <<
"=================================" << std::endl
325 <<
"Matrix::dispDefaultConfiguration:" << std::endl
326 <<
"=================================" << std::endl;
327 cout <<
"--------------------------------" << std::endl <<
"+ Coincidence Windows: " << std::endl;
329 cout <<
" + Threshold address:" << i << std::endl;
330 for (j = 0; j <
s_nchan[0]; j++) {
331 cout <<
" -Channel address:" << j <<
" Window 63-32 " << std::hex <<
m_trigRoad[i][j][1] <<
" Window 31-00 "
332 <<
m_trigRoad[i][j][0] << std::dec << std::endl;
338 cout <<
"--------------------------------" << std::endl
339 <<
"+ Majority addresses: " << std::endl
340 <<
"--------------------------------" << std::endl;
341 for (i = 0; i <
s_nthres; i++) { cout <<
" - threshold address " << i <<
" value " <<
m_majorities[i] << std::endl; }
346 cout <<
"--------------------------------" << std::endl
347 <<
"+ Threshold address low-to-high: " <<
m_lowtohigh << std::endl
348 <<
"+ Threshold address low-to-readout: " <<
m_toreadout << std::endl
349 <<
"+ Threshold address for overlap: " <<
m_overlapthres << std::endl;
353 cout <<
"--------------------------------" << std::endl
354 <<
"+ Local coincidence setting: " << std::endl
356 <<
" -Coincidence Plane: " <<
m_localDirec[1] << std::endl;
360 cout <<
"--------------------------------" << std::endl
361 <<
"+ Overlap mask setting: " << std::endl
363 <<
" -`left ' address " <<
m_matOverlap[1] << std::endl;
367 cout <<
"-----------------------------------------------" << std::endl
368 <<
"+ Channel pulse-width, delay and deadtime : " << std::endl;
369 for (i = 0; i < 2; i++) {
371 cout <<
" +Pivot Plane " << std::endl;
373 cout <<
" +Coincidence Plane " << std::endl;
375 for (j = 0; j < 2; j++) {
376 cout <<
" +Layer " << j << std::endl;
378 cout <<
" -group " << k <<
" pulsewidth " <<
m_pulseWidth[i][j][k] << std::endl;
381 cout <<
" -group " << k <<
" delay " <<
m_channDelay[i][j][k] << std::endl;
384 cout <<
" -group " << k <<
" deadtime " <<
m_channDeadT[i][j][k] << std::endl;
391 cout <<
"-----------------------------------------------" << std::endl <<
"+ Map of the masked-to-0 channels : " << std::endl;
392 for (i = 0; i < 2; i++) {
394 cout <<
" +Pivot Plane " << std::endl;
396 cout <<
" +Coincidence Plane " << std::endl;
398 for (j = 0; j < 2; j++) {
399 cout <<
" +Layer " << j << std::endl;
400 for (k = 0; k <
s_nchan[1]; k++) {
401 if (
m_channMask0[i][j][k]) { cout <<
" -channel " << k << std::endl; }
408 cout <<
"-----------------------------------------------" << std::endl <<
"+ Trigger Dead Time " << std::endl;
410 cout <<
" -group " << k <<
" Trigger DeadTime " <<
m_trigDeadTime[k] << std::endl;
415 cout <<
"-----------------------------------------------" << std::endl
416 <<
"+ Simulation parameters to align with the hardware (not used in CM)" << std::endl;
421 <<
" BunchPhase = 0 : to be used for standard ATLAS LVL1 simulation" << std::endl
422 <<
" BunchPhase = -1 : to be used to compare with the hardware; " << std::endl
423 <<
" this value fixed with VHDL comparison 1-7 august 2004." << std::endl
425 <<
" BunchOffset = 0 : to test with hardware; use this setting with setBCzero(0)." << std::endl;
429 cout <<
"======================================" << std::endl
430 <<
"Matrix::dispDefaultConfiguration: Done" << std::endl
431 <<
"======================================" << std::endl;
440 if (
m_matrixDebug & 1 << df) { cout <<
"Matrix:putData: putting data on Matrix" << endl; }
443 if (time < 0.0) BCID--;
466 if (stripaddress >= 0 && stripaddress <
s_nchan[sidemat]) {
470 rpcpntnew->
layer = layer;
472 rpcpntnew->
time = time;
473 rpcpntnew->
BC = BCID;
474 rpcpntnew->
DLL = DLLID;
478 rpcpntnew->
delay = 0;
487 throw std::out_of_range(
"Matrix::putData failure: channel addressed is " + std::to_string(stripaddress) +
" for matrix side " +
488 std::to_string(sidemat));
500 if (
m_matrixDebug & 1 << df) { cout <<
" method putPatt called; p is " << p << endl; }
527 for (i = 0; i <
s_nchan[0]; i++) {
529 if (p->m_k_pattern[j] & k) {
537 if (
m_matrixDebug & 1 << df) { cout <<
" copy_pivot; input matrix address " << p << endl; }
556 for (
ubit16 iside = 0; iside < 2; iside++) {
557 for (
ubit16 ilayer = 0; ilayer < 2; ilayer++) {
570 if (iside == 0 && igroup > 3) {
571 throw std::out_of_range(
572 "Matrix::setDeadTime: problems with side and group addresses: "
574 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" group=" + std::to_string(igroup));
577 throw std::out_of_range(
578 "Matrix::setDeadTime: problems in adressing pulseWidth: "
580 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" group=" + std::to_string(igroup));
585 if (iside > 1 || ilayer > 1) {
586 throw std::out_of_range(
587 "Matrix::setDelay: problems with side and layer addresses: "
589 std::to_string(iside) +
" layer=" + std::to_string(ilayer));
598 if (iside == 0 && igroup > 3) {
599 throw std::out_of_range(
600 "Matrix::setDelay: problems with side and group addresses:"
602 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" group=" + std::to_string(igroup));
605 throw std::out_of_range(
606 "Matrix::setDelay: problems in adressing pulseWidth:"
608 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" group=" + std::to_string(igroup));
613 for (
ubit16 iside = 0; iside < 2; iside++) {
614 for (
ubit16 ilayer = 0; ilayer < 2; ilayer++) {
628 if (iside == 0 && igroup > 3) {
629 throw std::out_of_range(
630 "Matrix::setDelay: problems with side and group addresses:"
632 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" group=" + std::to_string(igroup));
635 throw std::out_of_range(
636 "Matrix::setDelay: problems in adressing pulseWidth:"
638 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" group=" + std::to_string(igroup));
643 if (iside > 1 || ilayer > 1 || ichannel > (
s_nchan[iside] - 1)) {
644 throw std::out_of_range(
645 "Matrix::setMask0: problems with side/layer/channel addresses: "
647 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" channel=" + std::to_string(ichannel));
654 if (ithreshold > 2 || iside > 1 || imajority > 1 || ichannel > (
s_nchan[iside] - 1)) {
655 throw std::out_of_range(
656 "Matrix::setMask1: problems with side/layer/channel addresses: "
658 std::to_string(ithreshold) +
" side=" + std::to_string(iside) +
" majority=" + std::to_string(imajority) +
659 " channel=" + std::to_string(ichannel));
666 for (
int ichannel = 0; ichannel <
s_nchan[iside]; ichannel++) {
setMask1(ithreshold, iside, imajority, ichannel); }
670 for (
int imajority = 0; imajority < 2; imajority++) {
setMask1(ithreshold, iside, imajority); }
674 if (iside > 1 || ilayer > 1 || ichannel > (
s_nchan[iside] - 1)) {
675 throw std::out_of_range(
676 "Matrix::setMaskReadout: problems with side/layer/channel addresses: "
678 std::to_string(iside) +
" layer=" + std::to_string(ilayer) +
" channel=" + std::to_string(ichannel));
685 for (
ubit16 i = ichannel; i < (ichannel + nchannels - 1); i++) {
setMaskReadOut(iside, ilayer, ichannel, i); }
713 for (i = 0; i < 2; i++) {
716 for (j = 0; j < 2; j++) {
717 for (jg = 0; jg < addGroupMax; jg++) {
729 for (j = 0; j <
s_nchan[0]; j++) {
741 throw std::out_of_range(
"Matrix::setLocalDirection : add=" + std::to_string(
add) +
" not valid");
748 if (content < 0 || content >> 2) {
749 throw std::out_of_range(
"Matrix::setKReadout : threshold address = " + std::to_string(content) +
" not valid");
756 if (content >= 0 && content <
s_nthres) {
767 throw std::out_of_range(
"Matrix::setTrigDeadTime : igroup= " + std::to_string(igroup) +
" not valid");
777 throw std::out_of_range(
"Matrix::setMajority : add=" + std::to_string(
add) +
" not valid");
785 throw std::out_of_range(
"Matrix::setRoad : addThres= " + std::to_string(addThres) +
" addChn= " + std::to_string(addChn) +
786 " add64= " + std::to_string(add64) +
" not valid");
788 m_trigRoad[addThres][addChn][add64] = content;
794 throw std::out_of_range(
"Matrix::setRoad : addThres= " + std::to_string(addThres) +
" addChn= " + std::to_string(addChn));
799 throw std::runtime_error(
"Matrix::setRoad; outflag from char2int is positive: " + std::to_string(outflag));
807 throw std::out_of_range(
"Matrix::setMatOverlap : add= " + std::to_string(
add) +
" not valid");
815 throw std::out_of_range(
"Matrix::setDiagonal : add= " + std::to_string(
add) +
" not valid");
824 throw std::out_of_range(
"Matrix::getMatOverlap : add= " + std::to_string(
add) +
" not valid");
834 throw std::out_of_range(
"Matrix::getRoad : addThres= " + std::to_string(addThres) +
" addChn= " + std::to_string(addChn) +
835 " add64= " + std::to_string(add64) +
" not valid");
845 throw std::out_of_range(
"Matrix::getMajority : add= " + std::to_string(
add) +
" not valid");
861 cout <<
"====================" << endl
863 <<
"| Matrix::execute |" << endl
864 <<
"| --------------- |" << endl
866 <<
"====================" << endl;
900 cout <<
"--------------------------" << endl <<
"| Matrix::storeDeadtime |" << endl <<
"--------------------------" << endl;
902 for (
ubit16 i = 0; i < 2; i++) {
906 rpchit = rpchit->
next;
915 cout <<
"--------------------" << endl <<
"| Matrix::masking |" << endl <<
"--------------------" << endl;
917 for (
ubit16 i = 0; i < 2; i++) {
921 rpchit = rpchit->
next;
930 cout <<
"--------------------" << endl <<
"| Matrix::delay |" << endl <<
"--------------------" << endl;
932 for (
ubit16 i = 0; i < 2; i++) {
936 rpchit = rpchit->
next;
947 cout <<
"--------------------" << endl <<
"| Matrix::load |" << endl <<
"--------------------" << endl;
950 for (
ubit16 i = 0; i < 2; i++) {
954 cout <<
" Layer= " << rpcpnt->
layer <<
" stripadd= " << rpcpnt->
stripadd <<
" time= " << rpcpnt->
time
955 <<
" mask= " << rpcpnt->
masked <<
" BC= " << rpcpnt->
BC <<
" DLL= " << rpcpnt->
DLL <<
" delay= " << rpcpnt->
delay
963 if (
m_matrixDebug & 1 << df) { cout <<
" abs_time= " << abs_time <<
" timeadd= " << timeadd << endl; }
968 if (timeadd >= 0 && timeadd < m_nclock && !rpcpnt->masked) {
970 cout <<
" setting input with side " << i <<
" " << rpcpnt->
layer <<
" " << timeadd <<
" 0"
971 <<
" for channel " << rpcpnt->
stripadd <<
" timeadd " << timeadd << endl;
976 rpcpnt = rpcpnt->
next;
986 for (
ubit16 i = 0; i < 2; i++) {
987 for (
ubit16 j = 0; j < 2; j++) {
989 for (
ubit16 l = 0; l < 2; l++) {
1000 cout <<
"-------------------------" << endl <<
"| matrix: preprocessing |" << endl <<
"-------------------------" << endl;
1024 ubit16 thres, chan, nconf, conf[4][2];
1025 for (i = 0; i < 4; i++) {
1026 for (j = 0; j < 2; j++) { conf[i][j] = 0; }
1030 cout <<
"--------------------" << endl <<
"| matrix: coincide |" << endl <<
"--------------------" << endl;
1039 cout <<
" Matrix::coincidence; lowhigh= " <<
m_lowhigh << endl
1040 <<
" Matrix::coincidence; majority array ="
1045 for (thres = 0; thres <
s_nthres; thres++) {
1048 nconf =
config(thres, &conf[0][0]);
1058 for (l = 0; l < nconf; l++) {
1059 for (j = 0; j <
s_nchan[0]; j++) {
1074 if (bitstatus(&
m_mjori[thres][0][conf[l][0]][i][0], j) &&
1078 cout <<
"coincidence!!!"
1079 <<
" clock=" << i <<
" xchan=" << j << endl;
1084 if (BCaddress >= 0 && BCaddress <
m_Nbunch)
1106 for (chan = 0; chan <
s_nchan[0]; chan++) {
1107 for (thres = 0; thres <
s_nthres; thres++) {
1108 for (i =
m_nclock - 1; i > 0; i--) {
1109 previousTime = bitstatus(&
m_trigg[thres][i - 1], chan);
1117 for (chan = 0; chan <
s_nchan[0]; chan++) {
1118 for (thres = 0; thres <
s_nthres; thres++) {
1119 for (i =
m_nclock - 1; i > 0; i--) {
1120 if (bitstatus(&
m_trigg[thres][i], chan)) {
1133 for (thres = 0; thres <
s_nthres; thres++) {
1139 if (BCaddress >= 0 && BCaddress <
m_Nbunch) {
1153 for (m = 0; m < 2; m++) {
1156 if (BCaddress >= 0 && BCaddress <
m_Nbunch) {
1168 for (m = 0; m < 2; m++) {
1176 for (m = 0; m < 2; m++) {
1185 cout <<
"---------------------" << endl <<
"| Matrix::mask_to_1 |" << endl <<
"---------------------" << endl;
1190 for (i = 0; i < 2; i++) {
1191 for (j = 0; j < 2; j++) {
1192 for (l = 0; l <
s_nchan[i]; l++) {
1209 for (i = 0; i < 2; i++) {
1210 for (j = 0; j < 2; j++) {
1211 for (k = 0; k <
s_nchan[i]; k++) {
1215 for (l = 0; l < (
m_nclock - 1); l++) {
1216 ((!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;
1248 cout <<
"-----------------------" << endl <<
"| Matrix::pulse_width |" << endl <<
"-----------------------" << endl;
1251 for (i = 0; i < 2; i++) {
1252 for (j = 0; j < 2; j++) {
1253 for (l = 0; l <
s_nchan[i]; l++) {
1254 for (k =
m_nclock - 1; k >= 0; k--) {
1255 if (bitstatus(&
m_input[i][j][k][0], l)) {
1286 cout <<
"-------------------" << endl <<
"| Matrix::majori |" << endl <<
"-------------------" << endl;
1295 for (i = 0; i < 2; i++) {
1297 for (k = 0; k < 2; k++) {
1299 buffi[k] =
m_prepr[n][i][1][j][k];
1302 shift(&buffi[0], &buffo[0], i);
1303 for (k = 0; k < 2; k++) {
1312 for (l = 0; l <
s_nchan[i]; l++) {
1313 if (bitstatus(&
m_mjori[n][i][1][j][0], l)) {
1329 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k); }
1332 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k) << 1; }
1333 *(buffo + 1) = (*(buffi + 0) & 0x80000000) ? (*(buffo + 1) | 0x1) : (*(buffo + 1) | 0);
1336 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k) | (*(buffi + k) << 1); }
1337 *(buffo + 1) = (*(buffi + 0) & 0x80000000) ? (*(buffo + 1) | 0x1) : (*(buffo + 1) | 0);
1340 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k) >> 1; }
1341 *(buffo + 0) = (*(buffi + 1) & 0x1) ? (*(buffo + 0) | 0x80000000) : (*(buffo + 0) | 0);
1344 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k) | (*(buffi + k) >> 1); }
1345 *(buffo + 0) = (*(buffi + 1) & 0x1) ? (*(buffo + 0) | 0x80000000) : (*(buffo + 0) | 0);
1348 for (k = 0; k < 2; k++) { *(buffo + k) = (*(buffi + k) >> 1) | (*(buffi + k) << 1); }
1349 *(buffo + 0) = (*(buffi + 1) & 0x1) ? (*(buffo + 0) | 0x80000000) : (*(buffo + 0) | 0);
1350 *(buffo + 1) = (*(buffi + 0) & 0x80000000) ? (*(buffo + 1) | 0x1) : (*(buffo + 1) | 0);
1353 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k) | (*(buffi + k) >> 1) | (*(buffi + k) << 1); }
1354 *(buffo + 0) = (*(buffi + 1) & 0x1) ? (*(buffo + 0) | 0x80000000) : (*(buffo + 0) | 0);
1355 *(buffo + 1) = (*(buffi + 0) & 0x80000000) ? (*(buffo + 1) | 0x1) : (*(buffo + 1) | 0);
1358 cout <<
" Matrix::shift -- m_localDirec[" << i <<
"]=" <<
m_localDirec[i] <<
" not expected; m_localDirec forced to be 1 "
1360 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k); }
1366 if (!i) *(buffo + 1) = 0;
1376 ubit16 nup, first, i, j, k, l;
1379 cout <<
"------------------------" << endl <<
"| matrix: declustering |" << endl <<
"------------------------" << endl;
1384 for (i = 0; i < 2; i++) {
1385 for (j = 0; j < 2; j++) {
1388 for (l = 0; l <
s_nchan[i]; l++) {
1389 if (bitstatus(&
m_input[i][j][k][0], l)) {
1391 if (nup == 1) first = l;
1393 if (!bitstatus(&
m_input[i][j][k][0], l) || (l == (
s_nchan[i] - 1))) {
1395 reduce(i, j, k, 0, nup, first);
1421 cout <<
" --------------------" << endl
1422 <<
" | Matrix::reduce |" << endl
1423 <<
" --------------------" << endl
1424 <<
" nup= " << nup <<
" first " << first << endl;
1434 }
else if (nup == 3) {
1437 }
else if (nup == 4) {
1440 }
else if (nup > 4) {
1444 if (
m_matrixDebug & 1 << df) { cout <<
" j= " << j <<
" ncop= " << ncop << endl; }
1448 for (na = 0; na <
s_nthres; na++) {
1449 for (i = j; i < j + ncop; i++) {
1488 for (k = 0; k <
s_nchan[0]; k++) {
1504 const ubit16 maxchan = 100;
1505 const ubit16 maxtimes = 1000;
1507 ubit16 IJ[maxtimes][4] = {{0}};
1508 ubit16 channels[maxtimes][4][maxchan] = {{{0}}};
1509 float times[maxtimes] = {0};
1511 const float timeOffsetHit = 114.675;
1516 strcpy(plane[0],
"I0");
1517 strcpy(plane[1],
"I1");
1518 strcpy(plane[2],
"J0");
1519 strcpy(plane[3],
"J1");
1521 cout <<
"-------------------------------" << endl
1522 <<
"| Matrix::makeTestPattern |" << endl
1523 <<
"-------------------------------" << endl;
1531 for (i = 0; i < 2; i++) {
1535 rpcpnt = rpcpnt->
next;
1539 while (!completed) {
1541 timemin = 999999999.;
1542 for (i = 0; i < 2; i++) {
1545 if (rpcpnt->
time < timemin && !rpcpnt->
mark) {
1546 timemin = rpcpnt->
time;
1549 rpcpnt = rpcpnt->
next;
1553 if (ntimes < maxtimes) ntimes += 1;
1554 times[ntimes - 1] = timemin;
1555 for (i = 0; i < 2; i++) {
1558 if (rpcpnt->
time == timemin) {
1560 if (IJ[ntimes - 1][rpcpnt->
layer + 2 * i] < maxchan) { IJ[ntimes - 1][rpcpnt->
layer + 2 * i] += 1; }
1561 channels[ntimes - 1][rpcpnt->
layer + 2 * i][IJ[ntimes - 1][rpcpnt->
layer + 2 * i] - 1] = rpcpnt->
stripadd;
1563 rpcpnt = rpcpnt->
next;
1573 vhdlinput.open(
"k-trigger.output", ios::app);
1575 cout <<
" File for vhdl analysis not opened. " << endl <<
" ==================================" << endl << endl;
1578 cout <<
" File for vhdl analysis correctly opened" << endl << endl;
1583 vhdlinput <<
" LINES " << (ntimes + ktimes) << std::endl;
1585 for (l = 0; l < ntimes; l++) {
1586 vhdlinput <<
" TIME " << times[l] + timeOffsetHit <<
" ";
1587 for (i = 0; i < 4; i++) {
1588 vhdlinput << plane[i][0] << plane[i][1] <<
" " << IJ[l][i] <<
" ";
1589 for (j = 0; j < IJ[l][i]; j++) { vhdlinput << channels[l][i][IJ[l][i] - 1 - j] <<
" "; }
1591 vhdlinput << std::endl;
1599 const float timeOffsetKPa = 168.125;
1600 const float timeOffsetThr = 210.500;
1603 ubit16 chanHistory[32] = {0};
1604 const ubit16 maxchan = 100;
1613 for (i = 0; i <
m_nclock; i++) { nchannels[i][0][0] = 0; }
1618 for (l = 0; l <
s_nchan[0]; l++) {
1620 if (!chanHistory[l]) {
1622 if (ntimes < maxtimes) ntimes += 1;
1623 times[ntimes - 1] = time;
1625 if (nchannels[ntimes - 1][0][0] < maxchan) nchannels[ntimes - 1][0][0] += 1;
1626 channels[ntimes - 1][0][0][nchannels[ntimes - 1][0][0] - 1] = l;
1637 ubit16 nthresPass, thresPass[8], overlPass[8], BCidentifier[8];
1643 BCidentifier[nthresPass] = i;
1651 ofstream out_k_trigger;
1652 out_k_trigger.open(
"k-trigger.output", ios::app);
1656 for (i = 0; i < ntimes; i++) {
1657 out_k_trigger <<
" TIME " << times[i] + timeOffsetKPa <<
" K ";
1658 out_k_trigger << nchannels[i][0][0] <<
" ";
1659 for (l = 0; l < nchannels[i][0][0]; l++) { out_k_trigger << channels[i][0][0][l] <<
" "; }
1660 out_k_trigger << endl;
1664 for (i = 0; i < nthresPass; i++) {
1665 out_k_trigger <<
" TIME " << BCidentifier[i] * 25. + timeOffsetThr;
1666 out_k_trigger <<
" THR " << thresPass[i] << endl;
1668 out_k_trigger <<
" TIME " << BCidentifier[i] * 25. + timeOffsetThr;
1669 out_k_trigger <<
" OVL " << overlPass[i] << std::endl;
1674 out_k_trigger.close();
1718 default:
throw std::runtime_error(
"Matrix::config: the majority " + std::to_string(
m_majorities[i]) +
" is unforeseen");
1734 default:
throw std::runtime_error(
"Matrix::config: the majority " + std::to_string(
m_majorities[i]) +
" is unforeseen");
1737 default:
throw std::runtime_error(
"Matrix::config: lowhighpt " + std::to_string(
m_lowhigh) +
" is unforeseen");
1768 std::array<ubit16, 2> i = inds(channel);
1769 if (!(channel < 0)) {
1770 *(p + i[0]) = *(p + i[0]) | j << i[1];
1772 throw std::out_of_range(
"Matrix::set_to_1: channel is negative; channel=" + std::to_string(channel));
1778 std::array<ubit16, 2> i = inds(channel);
1779 if (!(channel < 0)) {
1780 *(p + i[0]) = *(p + i[0]) & ~(j << i[1]);
1782 throw std::out_of_range(
"Matrix::set_to_1: channel is negative; channel=" + std::to_string(channel));
1789 cout <<
"-----------------------" << endl
1790 <<
"| Matrix::wind |" << endl
1791 <<
"-----------------------" << endl
1792 <<
" Matrix Roads " << endl;
1794 for (j = 0; j <
s_nchan[0]; j++) {
1795 cout <<
" thres. " << i <<
" channel "
1799 <<
" Road0 " << hex << (
m_trigRoad[i][j][0]) << dec <<
" Road1 " << hex << (
m_trigRoad[i][j][1]) << dec << endl;
1802 cout <<
" majorities: " << endl;
1803 for (i = 0; i < 3; i++) { cout <<
m_majorities[i] <<
" " << endl; }
1805 <<
" number of overlapping ' low' channels: " <<
m_matOverlap[0] << endl
1806 <<
" number of overlapping 'high' channels: " <<
m_matOverlap[1] << endl;
1807 for (i = 0; i <
s_nchan[0]; i++) { cout <<
" channel " << i <<
" in coincidence with " <<
m_diagonal[i] << endl; }
1816 cout <<
"=======================" << endl <<
"|| Matrix Display ||" << endl <<
"=======================" << endl << endl;
1819 cout << endl <<
" All raw data " << endl;
1820 for (i = 0; i < 2; i++) {
1821 cout <<
" Matrix Side is " << i << endl;
1824 cout <<
" Layer= " << rpcpnt->
layer <<
" stripadd= " << rpcpnt->
stripadd <<
" time= " << rpcpnt->
time
1825 <<
" mask= " << rpcpnt->
masked <<
" BC= " << rpcpnt->
BC <<
" DLL= " << rpcpnt->
DLL <<
" delay= " << rpcpnt->
delay << endl;
1826 rpcpnt = rpcpnt->
next;
1831 cout <<
" Display Matrix Input " << endl;
1837 cout <<
" Display Matrix Preprocessing " << endl;
1842 cout <<
" Display Matrix Majority " << endl;
1847 cout <<
" Display Trigger " << endl;
1859 cout <<
" Matrix Attributes: " << endl
1870 for (i = 0; i < 2; i++) {
1871 cout <<
" CMA Side (0=side-x; 1=side-y) " << i << endl;
1872 for (j = 0; j < 2; j++) {
1875 cout <<
" Layer " << j << endl;
1879 cout <<
" Layer " << j << endl;
1882 default: cout <<
" Matrix::disp_CMAreg id value " <<
id <<
" not foreseen " << endl;
1891 cout <<
" Threshold address " << i << endl;
1892 for (j = 0; j < 2; j++) {
1893 cout <<
" CMA Side (0=side-x; 1=side-y) " << j << endl;
1894 for (k = 0; k < 2; k++) {
1895 cout <<
" Majority type (0=1/2; 1=2/2) " << k << endl;
1903 cout <<
" Trigger Threshold address " << i << endl;
1906 cout <<
" ReadOut Buffer " << endl;
1909 default: cout <<
" Matrix::disp_CMAreg id value " <<
id <<
" not foreseen " << endl;
1913 cout <<
" " << endl;
1921 std::ostringstream strdisp;
1925 for (j = 0; j <
s_nchan[side]; j += 2) { strdisp <<
" " << j % 10; }
1926 strdisp <<
" " << endl;
1928 strdisp <<
" " << j % 10 <<
" ";
1929 for (k = 0; k < n; k++) {
1932 strdisp <<
" " << endl;
1936 cout << strdisp.str() << endl;
1945 std::ostringstream strdisp;
1948 for (j = 0; j <
s_nchan[0]; j += 2) { strdisp <<
" " << j % 10; }
1949 strdisp <<
" " << endl;
1951 strdisp <<
" " << j % 10 <<
" ";
1953 strdisp <<
" " << endl;
1956 cout << strdisp.str() << endl;
1978 std::ostringstream strdisp;
1981 <<
" =========================" << endl
1983 <<
" = Matrix::dispWind =" << endl
1984 <<
" = Threshold address " << thres <<
" =" << endl
1986 <<
" =========================" << endl
1993 strdisp <<
" " << j <<
" ";
1995 strdisp << j <<
" ";
1998 if ((
m_trigRoad[thres][k][ad1]) & (1 << ad2)) {
2004 strdisp <<
" " << endl;
2006 strdisp <<
" " << endl;
2007 strdisp <<
" 00000000001111111111222222222233" << endl <<
" 01234567890123456789012345678901" << endl;
2009 cout << strdisp.str() << endl;
2018 if (stringLength > 16) {
2021 for (
ubit16 i = 0; i < stringLength; i++) {
2023 if (*(
str + stringLength - 1 - i) ==
'0')
2024 the32[i / 8] = the32[i / 8] + 0;
2025 else if (*(
str + stringLength - 1 - i) ==
'1')
2026 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 1;
2027 else if (*(
str + stringLength - 1 - i) ==
'2')
2028 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 2;
2029 else if (*(
str + stringLength - 1 - i) ==
'3')
2030 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 3;
2031 else if (*(
str + stringLength - 1 - i) ==
'4')
2032 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 4;
2033 else if (*(
str + stringLength - 1 - i) ==
'5')
2034 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 5;
2035 else if (*(
str + stringLength - 1 - i) ==
'6')
2036 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 6;
2037 else if (*(
str + stringLength - 1 - i) ==
'7')
2038 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 7;
2039 else if (*(
str + stringLength - 1 - i) ==
'8')
2040 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 8;
2041 else if (*(
str + stringLength - 1 - i) ==
'9')
2042 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 9;
2043 else if (*(
str + stringLength - 1 - i) ==
'a' || *(
str + stringLength - 1 - i) ==
'A')
2044 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 10;
2045 else if (*(
str + stringLength - 1 - i) ==
'b' || *(
str + stringLength - 1 - i) ==
'B')
2046 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 11;
2047 else if (*(
str + stringLength - 1 - i) ==
'c' || *(
str + stringLength - 1 - i) ==
'C')
2048 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 12;
2049 else if (*(
str + stringLength - 1 - i) ==
'd' || *(
str + stringLength - 1 - i) ==
'D')
2050 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 13;
2051 else if (*(
str + stringLength - 1 - i) ==
'e' || *(
str + stringLength - 1 - i) ==
'E')
2052 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 14;
2053 else if (*(
str + stringLength - 1 - i) ==
'f' || *(
str + stringLength - 1 - i) ==
'F')
2054 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 15;
2074 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
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 dispBinary(const CMAword *p, std::ostringstream &strdisp) const
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)
int run(int argc, char *argv[])