24 using std::istringstream;
25 using std::ostringstream;
37 const string myname =
"test_ProtoDuneChannelGroups: ";
39 cout << myname <<
"NDEBUG must be off." <<
endl;
42 string line =
"-----------------------------";
44 cout << myname << line <<
endl;
45 string fclfile =
"test_ProtoDuneChannelGroups.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: ProtoDuneChannelGroups" <<
endl;
58 fout <<
" IndexRangeTool: crtool" <<
endl;
63 cout << myname <<
"Using existing top-level FCL." <<
endl;
66 cout << myname << line <<
endl;
67 cout << myname <<
"Fetching tool manager." <<
endl;
69 assert ( ptm !=
nullptr );
74 cout << myname << line <<
endl;
75 cout << myname <<
"Fetching tool." <<
endl;
77 assert( pcgt !=
nullptr );
79 cout << myname << line <<
endl;
80 cout << myname <<
"Fetch invalid." <<
endl;
85 vector<string> expApas = {
"apa1",
"apa2",
"apa3",
"apa4",
"apa5",
"apa6"};
86 vector<string> expTpss = {
"tps0",
"tps1",
"tps2",
"tps3",
"tps4",
"tps5"};
88 cout << myname << line <<
endl;
89 cout << myname <<
"Check apas." <<
endl;
90 chg = pcgt->get(
"apas");
91 cout << myname << chg <<
endl;
93 assert( chg.
name ==
"apas" );
95 assert( nran == expApas.size() );
96 for (
Index iran=0; iran<nran; ++iran ) {
98 cout << myname <<
setw(5) << iran <<
": " << ran <<
endl;
99 assert( ran.
name == expApas[iran] );
102 cout << myname << line <<
endl;
103 cout << myname <<
"Check tpss." <<
endl;
104 chg = pcgt->get(
"tpss");
105 cout << myname << chg <<
endl;
107 assert( chg.
name ==
"tpss" );
109 assert( nran == expTpss.size() );
110 for (
Index iran=0; iran<nran; ++iran ) {
112 cout << myname <<
setw(5) << iran <<
": " << ran <<
endl;
113 assert( ran.
name == expTpss[iran] );
117 for (
Name sapt : {
"apa",
"tps"} ) {
119 if ( sapt ==
"tps" ) rbas =
"tpp";
120 for (
Name sori : {
"z",
"c",
"u",
"v"} ) {
121 vector<string> rnams;
122 if ( sapt ==
"apa" ) {
123 for (
Name sapa : {
"1",
"2",
"3",
"4",
"5",
"6" } ) rnams.push_back(rbas + sapa + sori);
125 for (
Name stps : {
"0",
"1",
"2",
"3",
"4",
"5" } ) rnams.push_back(rbas + stps + sori);
127 Name gnam = rbas + sori +
"s";
128 cout << myname << line <<
endl;
129 cout << myname <<
"Check " << gnam <<
"." <<
endl;
130 chg = pcgt->get(gnam);
131 cout << myname << chg <<
endl;
133 assert( chg.
name == gnam );
135 assert( nran == rnams.size() );
136 for (
Index iran=0; iran<nran; ++iran ) {
138 cout << myname <<
setw(5) << iran <<
": " << ran <<
endl;
139 assert( ran.
name == rnams[iran] );
145 cout << myname <<
"Checking FEMBs" <<
endl;
146 for (
Name sapa : {
"1",
"2",
"3",
"4",
"5",
"6" } ) {
147 for (
Name sfmb : {
"01",
"02",
"03",
"04",
"05",
"06",
"07",
"08",
"09",
"10",
148 "11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20" } ) {
149 Name gnam =
"femb" + sapa + sfmb;
150 chg = pcgt->get(gnam);
152 assert( chg.
name == gnam );
155 cout << myname <<
" " << gnam <<
": ";
156 for (
Index iran=0; iran<nran; ++iran ) {
157 if ( iran ) cout <<
",";
158 cout <<
" " << chg.
ranges[iran].name;
164 cout << myname << line <<
endl;
165 cout << myname <<
"Done." <<
endl;
172 bool useExistingFcl =
false;
175 string sarg(argv[1]);
176 if ( sarg ==
"-h" ) {
177 cout <<
"Usage: " << argv[0] <<
" [keepFCL] [SHOW]" <<
endl;
178 cout <<
" If keepFCL = true, existing FCL file is used." <<
endl;
179 cout <<
" SHOW > 1 also shows the 480 FEMB blocks." <<
endl;
182 useExistingFcl = sarg ==
"true" || sarg ==
"1";
185 string sarg(argv[2]);
186 show = std::stoi(sarg);
ChannelGroupService::Name Name
int main(int argc, char *argv[])
IndexRange range(Index iran) const
Q_EXPORT QTSManip setw(int w)
int test_ProtoDuneChannelGroups(bool useExistingFcl=false, int show=1)
void line(double t, double *p, double &x, double &y, double &z)
Q_EXPORT QTSManip setfill(int f)
QTextStream & endl(QTextStream &s)