24 using std::istringstream;
25 using std::ostringstream;
36 const string myname =
"test_HalfApaChannelRanges: ";
38 cout << myname <<
"NDEBUG must be off." <<
endl;
41 string line =
"-----------------------------";
43 cout << myname << line <<
endl;
44 string fclfile =
"test_HalfApaChannelRanges.fcl";
45 if ( ! useExistingFcl ) {
46 cout << myname <<
"Creating top-level FCL." <<
endl;
47 ofstream
fout(fclfile.c_str());
50 fout <<
" tool_type: HalfApaChannelRanges" <<
endl;
52 fout <<
" ApaNumbers: [1, 2]" <<
endl;
53 fout <<
" ExtraRanges: \"\"" <<
endl;
58 cout << myname <<
"Using existing top-level FCL." <<
endl;
61 cout << myname << line <<
endl;
62 cout << myname <<
"Fetching tool manager." <<
endl;
64 assert ( ptm !=
nullptr );
69 cout << myname << line <<
endl;
70 cout << myname <<
"Fetching tool." <<
endl;
72 assert( irt !=
nullptr );
74 cout << myname << line <<
endl;
75 cout << myname <<
"Fetching TPC ranges." <<
endl;
77 vector<string> namSufs = {
"",
"u",
"v",
"z1",
"z2",
"x",
"i"};
78 vector<string> namPres = {
"tps",
"tpp",
"tpp",
"tpp",
"tpp",
"tpp",
"tpp"};
79 for (
Index inam=0; inam<namPres.size(); ++inam ) {
80 for (
Index itps=0; itps<2; ++itps ) {
82 string nam = namPres[inam] + stps + namSufs[inam];
85 cout << myname <<
"Invalid range: " << nam <<
endl;
90 for (
Index ilab=1; ilab<ir.
labels.size(); ++ilab ) cout <<
", " << ir.
label(ilab);
92 assert( ir.
name == nam );
98 cout << myname << line <<
endl;
99 cout << myname <<
"Fetching APA ranges." <<
endl;
101 vector<string> namPresApa = {
"apa",
"apa",
"apa",
"apa",
"apa",
"apa",
"apa"};
102 for (
Index inam=0; inam<namPres.size(); ++inam ) {
103 for (
Index iapa=1; iapa<=2; ++iapa ) {
105 string nam = namPresApa[inam] + stps + namSufs[inam];
108 cout << myname <<
"Invalid range: " << nam <<
endl;
112 <<
" " << ir.
label();
113 for (
Index ilab=1; ilab<ir.
labels.size(); ++ilab ) cout <<
", " << ir.
label(ilab);
115 assert( ir.
name == nam );
121 bool showFembBlocks = show > 1;
122 if ( showFembBlocks ) {
123 cout << myname << line <<
endl;
124 cout << myname <<
"Fetching FEMB block ranges." <<
endl;
127 for (
Index iapa=1; iapa<=6; ++iapa ) {
128 for (
string view : {
"u",
"v",
"x"} ) {
129 for (
Index ifmb=1; ifmb<=20; ++ifmb ) {
131 ssnam <<
"femb" << iapa <<
setfill(
'0') <<
setw(2) << ifmb << view;
132 string nam = ssnam.str();
135 cout << myname <<
"Invalid range: " << nam <<
endl;
139 <<
" " << ir.
label();
140 for (
Index ilab=1; ilab<ir.
labels.size(); ++ilab ) cout <<
", " << ir.
label(ilab);
141 for (
Index icha=ir.
begin; icha<ir.
end; ++icha ) chk[icha] += 1;
147 for (
Index icha=0; icha<15360; ++icha ) {
148 assert( chk[icha] == 1 );
153 cout << myname << line <<
endl;
154 cout <<
"Fetch bad range" <<
endl;
159 cout << myname << line <<
endl;
160 cout << myname <<
"Done." <<
endl;
167 bool useExistingFcl =
false;
170 string sarg(argv[1]);
171 if ( sarg ==
"-h" ) {
172 cout <<
"Usage: " << argv[0] <<
" [keepFCL] [SHOW]" <<
endl;
173 cout <<
" If keepFCL = true, existing FCL file is used." <<
endl;
174 cout <<
" SHOW > 1 also shows the 480 FEMB blocks." <<
endl;
177 useExistingFcl = sarg ==
"true" || sarg ==
"1";
180 string sarg(argv[2]);
181 show = std::stoi(sarg);
int test_HalfApaChannelRanges(bool useExistingFcl=false, int show=1)
Name label(Index ilab=0) const
int main(int argc, char *argv[])
Q_EXPORT QTSManip setw(int w)
void line(double t, double *p, double &x, double &y, double &z)
std::string rangeString() const
Q_EXPORT QTSManip setfill(int f)
std::string to_string(ModuleType const mt)
QTextStream & endl(QTextStream &s)