35 const string myname =
"test_PdspOnlineChannel: ";
37 cout << myname <<
"NDEBUG must be off." <<
endl;
40 string line =
"-----------------------------";
42 cout << myname << line <<
endl;
43 string fclfile =
"test_PdspOnlineChannel.fcl";
45 cout << myname <<
"Using existing top-level FCL." <<
endl;
47 cout << myname <<
"Creating top-level FCL." <<
endl;
48 ofstream
fout(fclfile.c_str());
49 fout <<
"#include \"PdspChannelMapService.fcl\"" <<
endl;
50 fout <<
"services: { PdspChannelMapService: @local::pdspchannelmap }" <<
endl;
53 fout <<
" tool_type: PdspOnlineChannel" <<
endl;
55 fout <<
" Ordering: \"FEMB\"" <<
endl;
58 fout <<
" tool_type: ProtoduneOnlineChannel" <<
endl;
65 cout << myname << line <<
endl;
66 cout << myname <<
"Fetching tool manager." <<
endl;
68 assert ( ptm !=
nullptr );
73 std::ifstream
config{fclfile};
76 cout << myname << line <<
endl;
77 cout << myname <<
"Fetching tool." <<
endl;
79 assert( cma !=
nullptr );
83 cout << myname << line <<
endl;
84 cout << myname <<
"Check some good values." <<
endl;
85 for (
Index ichaOff : { 0, 102, 1234, 2560, 8480, 15359 } ) {
86 Index ichaOn = cma->get(ichaOff);
87 cout << myname <<
setw(5) << ichaOff <<
" --> " <<
setw(5) << ichaOn <<
endl;
88 assert( ichaOff != badIndex );
91 cout << myname << line <<
endl;
92 cout << myname <<
"Check some bad values." <<
endl;
93 for (
Index ichaOff : { -1, 15360, 20000 } ) {
94 Index ichaOn = cma->get(ichaOff);
95 cout << myname << ichaOff <<
" --> " << ichaOn <<
endl;
96 assert( ichaOn == badIndex );
99 cout << myname << line <<
endl;
100 cout << myname <<
"Check each online index appears exactly once." <<
endl;
101 const Index ncha = 15360;
104 for (
Index ichaOff=0; ichaOff<ncha; ++ichaOff ) {
105 Index ichaOn = cma->get(ichaOff);
106 if ( nshow*(ichaOff/nshow) == ichaOff || ichaOn >= ncha ) {
108 Index itps = irem/2560;
110 Index ifmb = irem/128 + 1;
112 Index iasc = irem/16 + 1;
113 Index ifch = irem%16;
114 cout << myname <<
" " <<
setw(4) << ichaOff <<
" --> " <<
setw(4) << ichaOn
115 <<
" (" << itps <<
", " <<
setw(2) << ifmb <<
", " 116 << iasc <<
", " <<
setw(2) << ifch <<
")" <<
endl;
118 assert( ichaOn < ncha );
119 if ( offlineChannel[ichaOn] != badIndex ) {
120 cout << myname <<
"ERROR: Online channel " << ichaOn
121 <<
" is mapped to two offline channels:" <<
endl;
122 cout <<
" " << offlineChannel[ichaOn] <<
endl;
123 cout <<
" " << ichaOff <<
endl;
126 assert( onlineCounts[ichaOn] == 0 );
127 onlineCounts[ichaOn] += 1;
128 offlineChannel[ichaOn] = ichaOff;
130 for (
Index ichaOn=0; ichaOn<ncha; ++ichaOn ) {
131 assert( onlineCounts[ichaOn] == 1 );
132 assert( offlineChannel[ichaOn] != badIndex );
135 cout << myname << line <<
endl;
136 cout << myname <<
"Compare with ProtoduneChannelmap." <<
endl;
138 assert( ref !=
nullptr );
139 bool skipDiv1 =
false;
140 for (
Index idiv : {2560, 128, 1} ) {
141 if ( skipDiv1 && idiv == 1 ) {
142 cout << myname <<
"WARNING: Skipping div 1 test" <<
endl;
145 cout << myname <<
"...checking div " << idiv <<
endl;
146 for (
Index ichaOff=0; ichaOff<ncha; ++ichaOff ) {
147 Index ichaOnl = cma->get(ichaOff);
148 Index ichaRef = ref->get(ichaOff);
149 Index ichaOnlDiv = ichaOnl/idiv;
150 Index ichaRefDiv = ichaRef/idiv;
151 if ( ichaOnlDiv != ichaRefDiv ) {
152 cout << myname <<
"Maps disagree:" <<
endl;
153 cout << myname <<
" Offline: " << ichaOff <<
endl;
154 cout << myname <<
" Online: " << ichaOnl <<
" (" << ichaOnlDiv <<
")" <<
endl;
155 cout << myname <<
" Ref: " << ichaRef <<
" (" << ichaRefDiv <<
")" <<
endl;
161 cout << myname << line <<
endl;
162 cout << myname <<
"Done." <<
endl;
static void load_services(std::string const &config)
Q_EXPORT QTSManip setw(int w)
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)