99 const string myname =
"test_Roi2dToAdc: ";
101 cout << myname <<
"NDEBUG must be off." <<
endl;
104 string line =
"-----------------------------";
106 cout << myname << line <<
endl;
107 string fclfile =
"test_Roi2dToAdc.fcl";
108 if ( ! useExistingFcl ) {
109 cout << myname <<
"Creating top-level FCL." <<
endl;
110 ofstream
fout(fclfile.c_str());
111 fout <<
"#include \"dataprep_tools.fcl\"" <<
endl;
113 fout <<
" tool_type: Roi2dToAdc" <<
endl;
118 cout << myname <<
"Using existing top-level FCL." <<
endl;
121 cout << myname << line <<
endl;
122 cout << myname <<
"Fetching tool manager." <<
endl;
124 assert ( ptm !=
nullptr );
129 cout << myname << line <<
endl;
130 cout << myname <<
"Create test data." <<
endl;
143 tpd.
get2dRois().emplace_back(ncha, ntckroi, icha0, itck0+tckoff);
151 for (
Index kcha=0; kcha<ncha; ++kcha, ++dtck ) {
152 Index icha = icha0 + kcha;
158 float val = 10*(kcha + 1);
165 acdchk.
samples.resize(ntck, 0.0);
166 for (
Index ktck=tckoff; ktck<tckoff+3; ++ktck, ++idxs[1] ) {
167 roi.data().setValue(idxs, val);
169 if ( acdchk.
rois.size() == 0 ) {
170 acdchk.
rois.push_back({ktck, ktck});
172 acdchk.
rois.back().second = ktck;
175 acdchk.
signal.resize(ntck,
false);
176 Index isig1 = tckoff > kcha ? tckoff - kcha : 0;
178 for (
Index ktck=isig1; ktck<isig2; ++ktck ) {
179 acdchk.
signal[ktck] =
true;
184 assert( tpd.
getAdcData()[0]->size() == ncha );
187 assert( acd.
samples.size() == ntck );
189 assert( roi.channelSize() == ncha );
190 assert( roi.channelOffset() == icha0 );
191 assert( roi.sampleSize() == ntckroi );
192 assert( roi.sampleOffset() == itck0 + tckoff );
194 cout << myname << line <<
endl;
195 cout << myname <<
"Check ROI data." <<
endl;
197 assert( &tpd.
get2dRois().front() == &roi );
199 cout << myname << line <<
endl;
201 cout << myname << line <<
endl;
202 cout << myname <<
"Check ADC data before tool:" <<
endl;
208 cout << myname << line <<
endl;
209 cout << myname <<
"Expected data after tool:" <<
endl;
212 cout << myname << line <<
endl;
213 cout << myname <<
"Fetching tool." <<
endl;
215 assert( ptoo !=
nullptr );
217 cout << myname << line <<
endl;
218 cout << myname <<
"Call tool." <<
endl;
219 DataMap res = ptoo->updateTpcData(tpd);
221 assert( res.
status() == 0 );
223 cout << myname << line <<
endl;
224 cout << myname <<
"Check ADC data after tool." <<
endl;
227 assert(
showAdcMap(acm, myname, &acmchk) == 0 );
228 assert( res.
getInt(
"r2a_nchaZeroed") ==
int(ncha) );
229 assert( res.
getInt(
"r2a_nchaFilled") ==
int(ncha) );
230 assert( res.
getInt(
"r2a_nsamZeroed") ==
int(ncha*ntck) );
231 assert( res.
getInt(
"r2a_nsamFilled") ==
int(nsig) );
233 cout << myname << line <<
endl;
234 cout << myname <<
"Done." <<
endl;
std::shared_ptr< AdcChannelDataMap > AdcDataPtr
void print(std::ostream *pout) const
std::shared_ptr< const EventInfo > EventInfoPtr
int showRoi(const Tpc2dRoi &roi, string myname)
AdcDataVector & getAdcData()
void setChannelInfo(ChannelInfoPtr pchi)
std::array< Index, 2 > IndexArray
void setEventInfo(EventInfoPtr pevi)
int showAdcMap(const AdcChannelDataMap &acm, string myname, const AdcChannelDataMap *pacmchk=0)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
int getInt(Name name, int def=0) const
void line(double t, double *p, double &x, double &y, double &z)
AdcDataPtr createAdcData(bool updateParent=true)
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
Tpc2dRoiVector & get2dRois()
QTextStream & endl(QTextStream &s)