47 const string myname =
"test_VDColdboxOnlineChannel: ";
49 cout << myname <<
"NDEBUG must be off." <<
endl;
52 string line =
"-----------------------------";
54 cout << myname << line <<
endl;
55 string fclfile =
"test_VDColdboxOnlineChannel.fcl";
57 cout << myname <<
"Using existing top-level FCL." <<
endl;
59 cout << myname <<
"Creating top-level FCL." <<
endl;
60 ofstream
fout(fclfile.c_str());
61 fout <<
"#include \"VDColdboxChannelMapService.fcl\"" <<
endl;
62 fout <<
"services: { VDColdboxChannelMapService: @local::vdcoldboxchannelmap }" <<
endl;
65 fout <<
" tool_type: VDColdboxOnlineChannel" <<
endl;
72 cout << myname << line <<
endl;
73 cout << myname <<
"Fetching tool manager." <<
endl;
75 assert ( ptm !=
nullptr );
80 std::ifstream
config{fclfile};
83 cout << myname << line <<
endl;
84 cout << myname <<
"Fetching tool." <<
endl;
86 assert( cma !=
nullptr );
90 cout << myname << line <<
endl;
91 cout << myname <<
"Check some good values." <<
endl;
92 for (
Index ichaOff : { 1600, 1700, 3199, 3200, 3391 } ) {
93 Index ichaOn = cma->get(ichaOff);
94 cout << myname <<
setw(5) << ichaOff <<
" --> " <<
setw(5) << ichaOn <<
endl;
95 assert( ichaOff != badIndex );
98 cout << myname << line <<
endl;
99 cout << myname <<
"Check some bad values." <<
endl;
100 for (
Index ichaOff : { -1, 0, 100, 1599, 3392, 4000 } ) {
101 Index ichaOn = cma->get(ichaOff);
102 cout << myname << ichaOff <<
" --> " << ichaOn <<
endl;
103 assert( ichaOn == badIndex );
106 cout << myname << line <<
endl;
107 cout << myname <<
"Check each online index appears exactly once." <<
endl;
108 const Index nchaOn = 14*128;
109 const Index ichaOn1 = 128;
110 const Index ichaOn2 = ichaOn1 + nchaOn;
111 const Index ichaOff1 = 1600;
112 const Index ichaOff2 = ichaOff1 + nchaOn;
116 for (
Index ichaOff=ichaOff1; ichaOff<ichaOff2; ++ichaOff ) {
117 Index ichaOn = cma->get(ichaOff);
118 if ( nshow*(ichaOff/nshow) == ichaOff ) {
119 cout << myname <<
" " <<
setw(4) << ichaOff <<
" --> " <<
setw(4) << ichaOn
122 assert( ichaOn >= ichaOn1 );
123 assert( ichaOn < ichaOn2 );
124 if ( offlineChannel[ichaOn] != badIndex ) {
125 cout << myname <<
"ERROR: Online channel " <<
setw(4) << ichaOn
126 <<
" (" <<
sonline(ichaOn) <<
")" 127 <<
" is mapped to two offline channels: " 128 << offlineChannel[ichaOn]
129 <<
" " << ichaOff <<
endl;
132 onlineCounts[ichaOn] += 1;
133 offlineChannel[ichaOn] = ichaOff;
137 for (
Index ichaOn=ichaOn1; ichaOn<ichaOn2; ++ichaOn ) {
138 if ( onlineCounts[ichaOn] != 1 ) {
139 cout <<
"ERROR: Map count for online channel " << ichaOn <<
" is " << onlineCounts[ichaOn] <<
endl;;
141 }
else if ( offlineChannel[ichaOn] == badIndex ) {
142 cout <<
"ERROR: Online channel " << ichaOn <<
" is not mapped." <<
endl;
145 assert( ndup + nbadOn + nbadOff == 0 );
147 cout << myname << line <<
endl;
148 cout << myname <<
"Done." <<
endl;
string sonline(Index ichaOn)
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)