24 using std::istringstream;
25 using std::ostringstream;
37 const string myname =
"test_ApaChannelGroups: ";
39 cout << myname <<
"NDEBUG must be off." <<
endl;
42 string line =
"-----------------------------";
44 cout << myname << line <<
endl;
45 string fclfile =
"test_ApaChannelGroups.fcl";
46 if ( ! useExistingFcl ) {
47 cout << myname <<
"Creating top-level FCL." <<
endl;
48 ofstream
fout(fclfile.c_str());
51 fout <<
" tool_type: ProtoDuneChannelRanges" <<
endl;
53 fout <<
" ExtraRanges: \"\"" <<
endl;
56 fout <<
" tool_type: ApaChannelGroups" <<
endl;
58 fout <<
" ApaNumbers: [3, 5, 2, 6, 1, 4]" <<
endl;
59 fout <<
" IndexRangeTool: crtool" <<
endl;
64 cout << myname <<
"Using existing top-level FCL." <<
endl;
67 cout << myname << line <<
endl;
68 cout << myname <<
"Fetching tool manager." <<
endl;
70 assert ( ptm !=
nullptr );
75 cout << myname << line <<
endl;
76 cout << myname <<
"Fetching tool." <<
endl;
78 assert( pcgt !=
nullptr );
80 cout << myname << line <<
endl;
81 cout << myname <<
"Fetch invalid." <<
endl;
86 vector<string> expApas = {
"apa3",
"apa5",
"apa2",
"apa6",
"apa1",
"apa4"};
87 vector<string> expTpss = {
"tps0",
"tps1",
"tps2",
"tps3",
"tps4",
"tps5"};
89 cout << myname << line <<
endl;
90 cout << myname <<
"Check apas." <<
endl;
91 chg = pcgt->get(
"apas");
92 cout << myname << chg <<
endl;
94 assert( chg.
name ==
"apas" );
96 assert( nran == expApas.size() );
97 for (
Index iran=0; iran<nran; ++iran ) {
99 cout << myname <<
setw(5) << iran <<
": " << ran <<
endl;
100 assert( ran.
name == expApas[iran] );
103 cout << myname << line <<
endl;
104 cout << myname <<
"Check tpss." <<
endl;
105 chg = pcgt->get(
"tpss");
106 cout << myname << chg <<
endl;
108 assert( chg.
name ==
"tpss" );
110 assert( nran == expTpss.size() );
111 for (
Index iran=0; iran<nran; ++iran ) {
113 cout << myname <<
setw(5) << iran <<
": " << ran <<
endl;
114 assert( ran.
name == expTpss[iran] );
118 for (
Name sapt : {
"apa",
"tps"} ) {
120 if ( sapt ==
"tps" ) rbas =
"tpp";
121 for (
Name sori : {
"z",
"c",
"u",
"v"} ) {
122 vector<string> rnams;
123 if ( sapt ==
"apa" ) {
124 for (
Name sapa : {
"3",
"5",
"2",
"6",
"1",
"4" } ) rnams.push_back(rbas + sapa + sori);
126 for (
Name stps : {
"0",
"1",
"2",
"3",
"4",
"5" } ) rnams.push_back(rbas + stps + sori);
128 Name gnam = rbas + sori +
"s";
129 cout << myname << line <<
endl;
130 cout << myname <<
"Check " << gnam <<
"." <<
endl;
131 chg = pcgt->get(gnam);
132 cout << myname << chg <<
endl;
134 assert( chg.
name == gnam );
136 assert( nran == rnams.size() );
137 for (
Index iran=0; iran<nran; ++iran ) {
139 cout << myname <<
setw(5) << iran <<
": " << ran <<
endl;
140 assert( ran.
name == rnams[iran] );
146 cout << myname <<
"Checking FEMBs" <<
endl;
147 for (
Name sapa : {
"1",
"2",
"3",
"4",
"5",
"6" } ) {
148 for (
Name sfmb : {
"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
149 "11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20" } ) {
150 Name gnam =
"femb" + sapa + sfmb;
151 chg = pcgt->get(gnam);
153 assert( chg.
name == gnam );
156 cout << myname <<
" " << gnam <<
": ";
157 for (
Index iran=0; iran<nran; ++iran ) {
158 if ( iran ) cout <<
",";
159 cout <<
" " << chg.
ranges[iran].name;
165 cout << myname << line <<
endl;
166 cout << myname <<
"Done." <<
endl;
173 bool useExistingFcl =
false;
176 string sarg(argv[1]);
177 if ( sarg ==
"-h" ) {
178 cout <<
"Usage: " << argv[0] <<
" [keepFCL] [SHOW]" <<
endl;
179 cout <<
" If keepFCL = true, existing FCL file is used." <<
endl;
180 cout <<
" SHOW > 1 also shows the 480 FEMB blocks." <<
endl;
183 useExistingFcl = sarg ==
"true" || sarg ==
"1";
186 string sarg(argv[2]);
187 show = std::stoi(sarg);
ChannelGroupService::Name Name
IndexRange range(Index iran) const
int main(int argc, char *argv[])
int test_ApaChannelGroups(bool useExistingFcl=false, int show=1)
Q_EXPORT QTSManip setw(int w)
void line(double t, double *p, double &x, double &y, double &z)
Q_EXPORT QTSManip setfill(int f)
QTextStream & endl(QTextStream &s)