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));
811 throw std::out_of_range(
"Matrix::setMatOverlap : add= " + std::to_string(
add) +
" not valid");
819 throw std::out_of_range(
"Matrix::setDiagonal : add= " + std::to_string(
add) +
" not valid");
828 throw std::out_of_range(
"Matrix::getMatOverlap : add= " + std::to_string(
add) +
" not valid");
838 throw std::out_of_range(
"Matrix::getRoad : addThres= " + std::to_string(addThres) +
" addChn= " + std::to_string(addChn) +
839 " add64= " + std::to_string(add64) +
" not valid");
849 throw std::out_of_range(
"Matrix::getMajority : add= " + std::to_string(
add) +
" not valid");
865 cout <<
"====================" << endl
867 <<
"| Matrix::execute |" << endl
868 <<
"| --------------- |" << endl
870 <<
"====================" << endl;
904 cout <<
"--------------------------" << endl <<
"| Matrix::storeDeadtime |" << endl <<
"--------------------------" << endl;
906 for (
ubit16 i = 0; i < 2; i++) {
910 rpchit = rpchit->
next;
919 cout <<
"--------------------" << endl <<
"| Matrix::masking |" << endl <<
"--------------------" << endl;
921 for (
ubit16 i = 0; i < 2; i++) {
925 rpchit = rpchit->
next;
934 cout <<
"--------------------" << endl <<
"| Matrix::delay |" << endl <<
"--------------------" << endl;
936 for (
ubit16 i = 0; i < 2; i++) {
940 rpchit = rpchit->
next;
951 cout <<
"--------------------" << endl <<
"| Matrix::load |" << endl <<
"--------------------" << endl;
954 for (
ubit16 i = 0; i < 2; i++) {
958 cout <<
" Layer= " << rpcpnt->
layer <<
" stripadd= " << rpcpnt->
stripadd <<
" time= " << rpcpnt->
time
959 <<
" mask= " << rpcpnt->
masked <<
" BC= " << rpcpnt->
BC <<
" DLL= " << rpcpnt->
DLL <<
" delay= " << rpcpnt->
delay
967 if (
m_matrixDebug & 1 << df) { cout <<
" abs_time= " << abs_time <<
" timeadd= " << timeadd << endl; }
972 if (timeadd >= 0 && timeadd < m_nclock && !rpcpnt->masked) {
974 cout <<
" setting input with side " << i <<
" " << rpcpnt->
layer <<
" " << timeadd <<
" 0"
975 <<
" for channel " << rpcpnt->
stripadd <<
" timeadd " << timeadd << endl;
980 rpcpnt = rpcpnt->
next;
990 for (
ubit16 i = 0; i < 2; i++) {
991 for (
ubit16 j = 0; j < 2; j++) {
993 for (
ubit16 l = 0; l < 2; l++) {
1004 cout <<
"-------------------------" << endl <<
"| matrix: preprocessing |" << endl <<
"-------------------------" << endl;
1028 ubit16 thres, chan, nconf, conf[4][2];
1029 for (i = 0; i < 4; i++) {
1030 for (j = 0; j < 2; j++) { conf[i][j] = 0; }
1034 cout <<
"--------------------" << endl <<
"| matrix: coincide |" << endl <<
"--------------------" << endl;
1043 cout <<
" Matrix::coincidence; lowhigh= " <<
m_lowhigh << endl
1044 <<
" Matrix::coincidence; majority array ="
1049 for (thres = 0; thres <
s_nthres; thres++) {
1052 nconf =
config(thres, &conf[0][0]);
1062 for (l = 0; l < nconf; l++) {
1063 for (j = 0; j <
s_nchan[0]; j++) {
1078 if (bitstatus(&
m_mjori[thres][0][conf[l][0]][i][0], j) &&
1082 cout <<
"coincidence!!!"
1083 <<
" clock=" << i <<
" xchan=" << j << endl;
1088 if (BCaddress >= 0 && BCaddress <
m_Nbunch)
1110 for (chan = 0; chan <
s_nchan[0]; chan++) {
1111 for (thres = 0; thres <
s_nthres; thres++) {
1112 for (i =
m_nclock - 1; i > 0; i--) {
1113 previousTime = bitstatus(&
m_trigg[thres][i - 1], chan);
1121 for (chan = 0; chan <
s_nchan[0]; chan++) {
1122 for (thres = 0; thres <
s_nthres; thres++) {
1123 for (i =
m_nclock - 1; i > 0; i--) {
1124 if (bitstatus(&
m_trigg[thres][i], chan)) {
1137 for (thres = 0; thres <
s_nthres; thres++) {
1143 if (BCaddress >= 0 && BCaddress <
m_Nbunch) {
1157 for (m = 0; m < 2; m++) {
1160 if (BCaddress >= 0 && BCaddress <
m_Nbunch) {
1172 for (m = 0; m < 2; m++) {
1180 for (m = 0; m < 2; m++) {
1189 cout <<
"---------------------" << endl <<
"| Matrix::mask_to_1 |" << endl <<
"---------------------" << endl;
1194 for (i = 0; i < 2; i++) {
1195 for (j = 0; j < 2; j++) {
1196 for (l = 0; l <
s_nchan[i]; l++) {
1213 for (i = 0; i < 2; i++) {
1214 for (j = 0; j < 2; j++) {
1215 for (k = 0; k <
s_nchan[i]; k++) {
1219 for (l = 0; l < (
m_nclock - 1); l++) {
1220 ((!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;
1252 cout <<
"-----------------------" << endl <<
"| Matrix::pulse_width |" << endl <<
"-----------------------" << endl;
1255 for (i = 0; i < 2; i++) {
1256 for (j = 0; j < 2; j++) {
1257 for (l = 0; l <
s_nchan[i]; l++) {
1258 for (k =
m_nclock - 1; k >= 0; k--) {
1259 if (bitstatus(&
m_input[i][j][k][0], l)) {
1290 cout <<
"-------------------" << endl <<
"| Matrix::majori |" << endl <<
"-------------------" << endl;
1299 for (i = 0; i < 2; i++) {
1301 for (k = 0; k < 2; k++) {
1303 buffi[k] =
m_prepr[n][i][1][j][k];
1306 shift(&buffi[0], &buffo[0], i);
1307 for (k = 0; k < 2; k++) {
1316 for (l = 0; l <
s_nchan[i]; l++) {
1317 if (bitstatus(&
m_mjori[n][i][1][j][0], l)) {
1333 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k); }
1336 for (k = 0; k < 2; k++) { *(buffo + 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) | (*(buffi + k) << 1); }
1341 *(buffo + 1) = (*(buffi + 0) & 0x80000000) ? (*(buffo + 1) | 0x1) : (*(buffo + 1) | 0);
1344 for (k = 0; k < 2; k++) { *(buffo + 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) | (*(buffi + k) >> 1); }
1349 *(buffo + 0) = (*(buffi + 1) & 0x1) ? (*(buffo + 0) | 0x80000000) : (*(buffo + 0) | 0);
1352 for (k = 0; k < 2; k++) { *(buffo + k) = (*(buffi + k) >> 1) | (*(buffi + k) << 1); }
1353 *(buffo + 0) = (*(buffi + 1) & 0x1) ? (*(buffo + 0) | 0x80000000) : (*(buffo + 0) | 0);
1354 *(buffo + 1) = (*(buffi + 0) & 0x80000000) ? (*(buffo + 1) | 0x1) : (*(buffo + 1) | 0);
1357 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k) | (*(buffi + k) >> 1) | (*(buffi + k) << 1); }
1358 *(buffo + 0) = (*(buffi + 1) & 0x1) ? (*(buffo + 0) | 0x80000000) : (*(buffo + 0) | 0);
1359 *(buffo + 1) = (*(buffi + 0) & 0x80000000) ? (*(buffo + 1) | 0x1) : (*(buffo + 1) | 0);
1362 cout <<
" Matrix::shift -- m_localDirec[" << i <<
"]=" <<
m_localDirec[i] <<
" not expected; m_localDirec forced to be 1 "
1364 for (k = 0; k < 2; k++) { *(buffo + k) = *(buffi + k); }
1370 if (!i) *(buffo + 1) = 0;
1380 ubit16 nup, first, i, j, k, l;
1383 cout <<
"------------------------" << endl <<
"| matrix: declustering |" << endl <<
"------------------------" << endl;
1388 for (i = 0; i < 2; i++) {
1389 for (j = 0; j < 2; j++) {
1392 for (l = 0; l <
s_nchan[i]; l++) {
1393 if (bitstatus(&
m_input[i][j][k][0], l)) {
1395 if (nup == 1) first = l;
1397 if (!bitstatus(&
m_input[i][j][k][0], l) || (l == (
s_nchan[i] - 1))) {
1399 reduce(i, j, k, 0, nup, first);
1425 cout <<
" --------------------" << endl
1426 <<
" | Matrix::reduce |" << endl
1427 <<
" --------------------" << endl
1428 <<
" nup= " << nup <<
" first " << first << endl;
1438 }
else if (nup == 3) {
1441 }
else if (nup == 4) {
1444 }
else if (nup > 4) {
1448 if (
m_matrixDebug & 1 << df) { cout <<
" j= " << j <<
" ncop= " << ncop << endl; }
1452 for (na = 0; na <
s_nthres; na++) {
1453 for (i = j; i < j + ncop; i++) {
1492 for (k = 0; k <
s_nchan[0]; k++) {
1508 const ubit16 maxchan = 100;
1509 const ubit16 maxtimes = 1000;
1511 ubit16 IJ[maxtimes][4] = {{0}};
1512 ubit16 channels[maxtimes][4][maxchan] = {{{0}}};
1513 float times[maxtimes] = {0};
1515 const float timeOffsetHit = 114.675;
1520 strcpy(plane[0],
"I0");
1521 strcpy(plane[1],
"I1");
1522 strcpy(plane[2],
"J0");
1523 strcpy(plane[3],
"J1");
1525 cout <<
"-------------------------------" << endl
1526 <<
"| Matrix::makeTestPattern |" << endl
1527 <<
"-------------------------------" << endl;
1535 for (i = 0; i < 2; i++) {
1539 rpcpnt = rpcpnt->
next;
1543 while (!completed) {
1545 timemin = 999999999.;
1546 for (i = 0; i < 2; i++) {
1549 if (rpcpnt->
time < timemin && !rpcpnt->
mark) {
1550 timemin = rpcpnt->
time;
1553 rpcpnt = rpcpnt->
next;
1557 if (ntimes < maxtimes) ntimes += 1;
1558 times[ntimes - 1] = timemin;
1559 for (i = 0; i < 2; i++) {
1562 if (rpcpnt->
time == timemin) {
1564 if (IJ[ntimes - 1][rpcpnt->
layer + 2 * i] < maxchan) { IJ[ntimes - 1][rpcpnt->
layer + 2 * i] += 1; }
1565 channels[ntimes - 1][rpcpnt->
layer + 2 * i][IJ[ntimes - 1][rpcpnt->
layer + 2 * i] - 1] = rpcpnt->
stripadd;
1567 rpcpnt = rpcpnt->
next;
1577 vhdlinput.open(
"k-trigger.output", ios::app);
1579 cout <<
" File for vhdl analysis not opened. " << endl <<
" ==================================" << endl << endl;
1582 cout <<
" File for vhdl analysis correctly opened" << endl << endl;
1587 vhdlinput <<
" LINES " << (ntimes + ktimes) << std::endl;
1589 for (l = 0; l < ntimes; l++) {
1590 vhdlinput <<
" TIME " << times[l] + timeOffsetHit <<
" ";
1591 for (i = 0; i < 4; i++) {
1592 vhdlinput << plane[i][0] << plane[i][1] <<
" " << IJ[l][i] <<
" ";
1593 for (j = 0; j < IJ[l][i]; j++) { vhdlinput << channels[l][i][IJ[l][i] - 1 - j] <<
" "; }
1595 vhdlinput << std::endl;
1603 const float timeOffsetKPa = 168.125;
1604 const float timeOffsetThr = 210.500;
1607 ubit16 chanHistory[32] = {0};
1608 const ubit16 maxchan = 100;
1617 for (i = 0; i <
m_nclock; i++) { nchannels[i][0][0] = 0; }
1622 for (l = 0; l <
s_nchan[0]; l++) {
1624 if (!chanHistory[l]) {
1626 if (ntimes < maxtimes) ntimes += 1;
1627 times[ntimes - 1] = time;
1629 if (nchannels[ntimes - 1][0][0] < maxchan) nchannels[ntimes - 1][0][0] += 1;
1630 channels[ntimes - 1][0][0][nchannels[ntimes - 1][0][0] - 1] = l;
1641 ubit16 nthresPass, thresPass[8], overlPass[8], BCidentifier[8];
1647 BCidentifier[nthresPass] = i;
1655 ofstream out_k_trigger;
1656 out_k_trigger.open(
"k-trigger.output", ios::app);
1660 for (i = 0; i < ntimes; i++) {
1661 out_k_trigger <<
" TIME " << times[i] + timeOffsetKPa <<
" K ";
1662 out_k_trigger << nchannels[i][0][0] <<
" ";
1663 for (l = 0; l < nchannels[i][0][0]; l++) { out_k_trigger << channels[i][0][0][l] <<
" "; }
1664 out_k_trigger << endl;
1668 for (i = 0; i < nthresPass; i++) {
1669 out_k_trigger <<
" TIME " << BCidentifier[i] * 25. + timeOffsetThr;
1670 out_k_trigger <<
" THR " << thresPass[i] << endl;
1672 out_k_trigger <<
" TIME " << BCidentifier[i] * 25. + timeOffsetThr;
1673 out_k_trigger <<
" OVL " << overlPass[i] << std::endl;
1678 out_k_trigger.close();
1722 default:
throw std::runtime_error(
"Matrix::config: the majority " + std::to_string(
m_majorities[i]) +
" is unforeseen");
1738 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: lowhighpt " + std::to_string(
m_lowhigh) +
" is unforeseen");
1772 std::array<ubit16, 2> i = inds(channel);
1773 if (!(channel < 0)) {
1774 *(p + i[0]) = *(p + i[0]) | j << i[1];
1776 throw std::out_of_range(
"Matrix::set_to_1: channel is negative; channel=" + std::to_string(channel));
1782 std::array<ubit16, 2> i = inds(channel);
1783 if (!(channel < 0)) {
1784 *(p + i[0]) = *(p + i[0]) & ~(j << i[1]);
1786 throw std::out_of_range(
"Matrix::set_to_1: channel is negative; channel=" + std::to_string(channel));
1793 cout <<
"-----------------------" << endl
1794 <<
"| Matrix::wind |" << endl
1795 <<
"-----------------------" << endl
1796 <<
" Matrix Roads " << endl;
1798 for (j = 0; j <
s_nchan[0]; j++) {
1799 cout <<
" thres. " << i <<
" channel "
1803 <<
" Road0 " << hex << (
m_trigRoad[i][j][0]) << dec <<
" Road1 " << hex << (
m_trigRoad[i][j][1]) << dec << endl;
1806 cout <<
" majorities: " << endl;
1807 for (i = 0; i < 3; i++) { cout <<
m_majorities[i] <<
" " << endl; }
1809 <<
" number of overlapping ' low' channels: " <<
m_matOverlap[0] << endl
1810 <<
" number of overlapping 'high' channels: " <<
m_matOverlap[1] << endl;
1811 for (i = 0; i <
s_nchan[0]; i++) { cout <<
" channel " << i <<
" in coincidence with " <<
m_diagonal[i] << endl; }
1820 cout <<
"=======================" << endl <<
"|| Matrix Display ||" << endl <<
"=======================" << endl << endl;
1823 cout << endl <<
" All raw data " << endl;
1824 for (i = 0; i < 2; i++) {
1825 cout <<
" Matrix Side is " << i << endl;
1828 cout <<
" Layer= " << rpcpnt->
layer <<
" stripadd= " << rpcpnt->
stripadd <<
" time= " << rpcpnt->
time
1829 <<
" mask= " << rpcpnt->
masked <<
" BC= " << rpcpnt->
BC <<
" DLL= " << rpcpnt->
DLL <<
" delay= " << rpcpnt->
delay << endl;
1830 rpcpnt = rpcpnt->
next;
1835 cout <<
" Display Matrix Input " << endl;
1841 cout <<
" Display Matrix Preprocessing " << endl;
1846 cout <<
" Display Matrix Majority " << endl;
1851 cout <<
" Display Trigger " << endl;
1863 cout <<
" Matrix Attributes: " << endl
1874 for (i = 0; i < 2; i++) {
1875 cout <<
" CMA Side (0=side-x; 1=side-y) " << i << endl;
1876 for (j = 0; j < 2; j++) {
1879 cout <<
" Layer " << j << endl;
1883 cout <<
" Layer " << j << endl;
1886 default: cout <<
" Matrix::disp_CMAreg id value " <<
id <<
" not foreseen " << endl;
1895 cout <<
" Threshold address " << i << endl;
1896 for (j = 0; j < 2; j++) {
1897 cout <<
" CMA Side (0=side-x; 1=side-y) " << j << endl;
1898 for (k = 0; k < 2; k++) {
1899 cout <<
" Majority type (0=1/2; 1=2/2) " << k << endl;
1907 cout <<
" Trigger Threshold address " << i << endl;
1910 cout <<
" ReadOut Buffer " << endl;
1913 default: cout <<
" Matrix::disp_CMAreg id value " <<
id <<
" not foreseen " << endl;
1917 cout <<
" " << endl;
1925 std::ostringstream strdisp;
1929 for (j = 0; j <
s_nchan[side]; j += 2) { strdisp <<
" " << j % 10; }
1930 strdisp <<
" " << endl;
1932 strdisp <<
" " << j % 10 <<
" ";
1933 for (k = 0; k < n; k++) {
1936 strdisp <<
" " << endl;
1940 cout << strdisp.str() << endl;
1949 std::ostringstream strdisp;
1952 for (j = 0; j <
s_nchan[0]; j += 2) { strdisp <<
" " << j % 10; }
1953 strdisp <<
" " << endl;
1955 strdisp <<
" " << j % 10 <<
" ";
1957 strdisp <<
" " << endl;
1960 cout << strdisp.str() << endl;
1982 std::ostringstream strdisp;
1985 <<
" =========================" << endl
1987 <<
" = Matrix::dispWind =" << endl
1988 <<
" = Threshold address " << thres <<
" =" << endl
1990 <<
" =========================" << endl
1997 strdisp <<
" " << j <<
" ";
1999 strdisp << j <<
" ";
2002 if ((
m_trigRoad[thres][k][ad1]) & (1 << ad2)) {
2008 strdisp <<
" " << endl;
2010 strdisp <<
" " << endl;
2011 strdisp <<
" 00000000001111111111222222222233" << endl <<
" 01234567890123456789012345678901" << endl;
2013 cout << strdisp.str() << endl;
2022 if (stringLength > 16) {
2025 for (
ubit16 i = 0; i < stringLength; i++) {
2027 if (*(
str + stringLength - 1 - i) ==
'0')
2028 the32[i / 8] = the32[i / 8] + 0;
2029 else if (*(
str + stringLength - 1 - i) ==
'1')
2030 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 1;
2031 else if (*(
str + stringLength - 1 - i) ==
'2')
2032 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 2;
2033 else if (*(
str + stringLength - 1 - i) ==
'3')
2034 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 3;
2035 else if (*(
str + stringLength - 1 - i) ==
'4')
2036 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 4;
2037 else if (*(
str + stringLength - 1 - i) ==
'5')
2038 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 5;
2039 else if (*(
str + stringLength - 1 - i) ==
'6')
2040 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 6;
2041 else if (*(
str + stringLength - 1 - i) ==
'7')
2042 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 7;
2043 else if (*(
str + stringLength - 1 - i) ==
'8')
2044 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 8;
2045 else if (*(
str + stringLength - 1 - i) ==
'9')
2046 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 9;
2047 else if (*(
str + stringLength - 1 - i) ==
'a' || *(
str + stringLength - 1 - i) ==
'A')
2048 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 10;
2049 else if (*(
str + stringLength - 1 - i) ==
'b' || *(
str + stringLength - 1 - i) ==
'B')
2050 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 11;
2051 else if (*(
str + stringLength - 1 - i) ==
'c' || *(
str + stringLength - 1 - i) ==
'C')
2052 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 12;
2053 else if (*(
str + stringLength - 1 - i) ==
'd' || *(
str + stringLength - 1 - i) ==
'D')
2054 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 13;
2055 else if (*(
str + stringLength - 1 - i) ==
'e' || *(
str + stringLength - 1 - i) ==
'E')
2056 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 14;
2057 else if (*(
str + stringLength - 1 - i) ==
'f' || *(
str + stringLength - 1 - i) ==
'F')
2058 the32[i / 8] = the32[i / 8] + (
intPow(16, i % 8)) * 15;
2078 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)