40 const string myname =
"test_AdcRoiSlicer: ";
42 cout << myname <<
"NDEBUG must be off." <<
endl;
45 string line =
"-----------------------------";
47 cout << myname << line <<
endl;
48 string fclfile =
"test_AdcRoiSlicer.fcl";
49 NameVector tnams = {
"",
"mytool1",
"mytool2",
"mytool3"};
50 if ( ! useExistingFcl ) {
51 cout << myname <<
"Creating top-level FCL." <<
endl;
52 ofstream
fout(fclfile.c_str());
54 for (
int iopt : {1, 2, 3} ) {
55 fout <<
" mytool" <<iopt <<
": {" <<
endl;
56 fout <<
" tool_type: AdcRoiSlicer" <<
endl;
58 fout <<
" OutViewName: rois" <<
endl;
59 fout <<
" SliceOpt: " << iopt <<
endl;
66 cout << myname <<
"Using existing top-level FCL." <<
endl;
69 cout << myname << line <<
endl;
70 cout << myname <<
"Fetching tool manager." <<
endl;
72 assert ( ptm !=
nullptr );
77 cout << myname << line <<
endl;
78 cout << myname <<
"Fetching tool." <<
endl;
80 assert( psli !=
nullptr );
82 cout << myname << line <<
endl;
83 cout << myname <<
"Create data and call tool." <<
endl;
85 bool endInSig =
false;
90 for (
AdcIndex isam=0; isam<nsam; ++isam ) {
91 float xadc = rand()%20 - 10.0;
92 bool isSig = (isam >= isam1 && isam < isam2) || (isam >= isam3 && isam < isam4);
93 if ( isSig ) xadc += 100;
94 data.
signal.push_back(isSig);
103 if ( ! endInSig ) ++nnot;
104 cout << myname <<
" opt: " <<
opt <<
endl;
105 cout << myname <<
"nroi: " << nroi <<
endl;
106 cout << myname <<
"nnot: " << nnot <<
endl;
110 if ( nsam < isam4 ) isam4 = nsam;
111 if ( nsam < isam3 ) isam3 = nsam;
114 viewTick0s.push_back(isam1);
115 viewTick0s.push_back(isam3);
116 viewSizes.push_back(isam2 - isam1);
117 viewSizes.push_back(isam4 - isam3);
118 }
else if (
opt == 2 ) {
120 viewTick0s.push_back(0);
121 viewTick0s.push_back(isam2);
122 viewTick0s.push_back(isam4);
123 viewSizes.push_back(isam1);
124 viewSizes.push_back(isam3 - isam2);
125 viewSizes.push_back(nsam - isam4);
126 }
else if (
opt == 3 ) {
128 viewTick0s.push_back(0);
129 viewTick0s.push_back(isam1);
130 viewTick0s.push_back(isam2);
131 viewTick0s.push_back(isam3);
132 viewTick0s.push_back(isam4);
133 viewSizes.push_back(isam1);
134 viewSizes.push_back(isam2 - isam1);
135 viewSizes.push_back(isam3 - isam2);
136 viewSizes.push_back(isam4 - isam3);
137 viewSizes.push_back(nsam - isam4);
141 cout << myname <<
"nexp: " << nexp <<
endl;
142 assert( data.
signal.size() == nsam );
143 assert( data.
samples.size() == nsam );
145 cout << myname << line <<
endl;
146 cout << myname <<
"Running tool." <<
endl;
147 DataMap res = psli->update(data);
150 cout << myname << line <<
endl;
151 cout << myname <<
"Checking results." <<
endl;
158 assert( data.
view(vnam).size() == nexp );
159 for (
Index ivie=0; ivie<nexp; ++ivie ) {
160 cout << myname <<
"..entry " << ivie <<
endl;
165 Index nvsam = viewSizes[ivie];
168 for (
Index ivsam=0; ivsam<nvsam; ++ivsam ) {
169 int qv = 1000*acd.
samples[ivsam];
171 int sv = acd.
signal[ivsam];
173 cout << myname <<
setw(3) << ivsam <<
": " << sv <<
" " 180 cout << myname << line <<
endl;
181 cout << myname <<
"Done." <<
endl;
bool checkint(int i1, int i2)
ChannelGroupService::Name Name
void print(std::ostream *pout) const
NameVector viewNames() const
AdcChannelData * viewParent
Q_EXPORT QTSManip setw(int w)
const View & view(Name vnam) const
int getInt(Name name, int def=0) const
void line(double t, double *p, double &x, double &y, double &z)
QTextStream & endl(QTextStream &s)