23 using std::istringstream;
31 const string myname =
"test_ProtoduneChannelHelper: ";
33 cout << myname <<
"NDEBUG must be off." <<
endl;
36 string line =
"-----------------------------";
38 cout << myname << line <<
endl;
43 cout << myname <<
"Check some good values." <<
endl;
44 for (
Index ichaOff : { 0, 102, 1234, 1407, 3967, 15359 } ) {
46 cout << myname << ichaOff <<
" --> " << ichaOn <<
endl;
47 assert( ichaOff != badIndex );
50 cout << myname << line <<
endl;
51 cout << myname <<
"Check some bad values." <<
endl;
52 for (
Index ichaOff : { -1, 15360, 20000 } ) {
54 cout << myname << ichaOff <<
" --> " << ichaOn <<
endl;
55 assert( ichaOn == badIndex );
58 cout << myname << line <<
endl;
59 cout << myname <<
"Check each online index appears exactly once." <<
endl;
60 const Index ncha = 15360;
63 for (
Index ichaOff=0; ichaOff<ncha; ++ichaOff ) {
66 Index itps = irem/2560;
68 Index ifmb = irem/128 + 1;
70 Index iasc = irem/16 + 1;
72 if ( nshow*(ichaOff/nshow) == ichaOff || ichaOn >= ncha ) {
73 cout << myname <<
" " <<
setw(4) << ichaOff <<
" --> " <<
setw(4) << ichaOn
74 <<
" (" << itps <<
", " <<
setw(2) << ifmb <<
", " 75 << iasc <<
", " <<
setw(2) << iach <<
")" <<
endl;
77 assert( itps == chh.
tpcSet(ichaOn) );
78 assert( ifmb == chh.
femb(ichaOn) );
79 assert( iasc == chh.
asic(ichaOn) );
81 assert( ichaOn < ncha );
82 if ( offlineChannel[ichaOn] != badIndex ) {
83 cout << myname <<
"ERROR: Online channel " << ichaOn
84 <<
" is mapped to two offline channels:" <<
endl;
85 cout <<
" " << offlineChannel[ichaOn] <<
endl;
86 cout <<
" " << ichaOff <<
endl;
89 assert( onlineCounts[ichaOn] == 0 );
90 onlineCounts[ichaOn] += 1;
91 offlineChannel[ichaOn] = ichaOff;
93 for (
Index ichaOn=0; ichaOn<ncha; ++ichaOn ) {
94 assert( onlineCounts[ichaOn] == 1 );
95 assert( offlineChannel[ichaOn] != badIndex );
98 cout << myname << line <<
endl;
99 cout << myname <<
"Done." <<
endl;
108 string sarg(argv[1]);
109 if ( sarg ==
"-h" ) {
110 cout <<
"Usage: " << argv[0] <<
"[NSHOW]" <<
endl;
111 cout <<
" NSHOW [64]: Every nshow'th channels will be displayed in log." <<
endl;
114 nshow = std::stoi(sarg);
int main(int argc, char *argv[])
static Index onlineChannel(Index chanOff, Index dbg=0)
int test_ProtoduneChannelHelper(Index nshow=64)
static Index femb(Index chan, bool isOff)
static Index asicChannel(Index chan, bool isOff)
Q_EXPORT QTSManip setw(int w)
void line(double t, double *p, double &x, double &y, double &z)
static Index asic(Index chan, bool isOff)
static Index tpcSet(Index chan, bool isOff)
QTextStream & endl(QTextStream &s)