26 const string myname =
"test_AdcDataDumper: ";
28 cout << myname <<
"NDEBUG must be off." <<
endl;
31 string line =
"-----------------------------";
33 cout << myname << line <<
endl;
34 string fclfile =
"test_AdcDataDumper.fcl";
35 if ( ! useExistingFcl ) {
36 cout << myname <<
"Creating top-level FCL." <<
endl;
37 ofstream
fout(fclfile.c_str());
40 fout <<
" tool_type: AdcDataDumper" <<
endl;
42 fout <<
" Prefix: \"ADC dump for \"" <<
endl;
44 fout <<
" ShowChannelCount: true" <<
endl;
45 fout <<
" ShowTickCounts: true" <<
endl;
47 fout <<
" ShowPrepared: true" <<
endl;
51 fout <<
" ShowThreshold: 20" <<
endl;
57 cout << myname <<
"Using existing top-level FCL." <<
endl;
60 cout << myname << line <<
endl;
61 cout << myname <<
"Fetching tool manager." <<
endl;
63 assert ( ptm !=
nullptr );
68 cout << myname << line <<
endl;
69 cout << myname <<
"Fetching tool." <<
endl;
71 assert( padv !=
nullptr );
73 cout << myname << line <<
endl;
74 cout << myname <<
"Create data and call too." <<
endl;
76 float peds[20] = {701, 711, 733, 690, 688, 703, 720, 720, 695, 702,
77 410, 404, 388, 389, 400, 401, 410, 404, 395, 396};
78 for (
AdcIndex ievt=0; ievt<nevt; ++ievt ) {
79 cout << myname <<
"Event " << ievt <<
endl;
82 for (
AdcIndex icha=0; icha<ncha; ++icha ) {
83 std::pair<AdcChannelDataMap::iterator, bool> kdat = datamap.emplace(icha,
AdcChannelData());
87 float ped = peds[icha];
90 for (
AdcIndex itic=0; itic<100; ++itic ) {
91 float xadc = ped + rand()%20 - 10.0;
93 data.
raw.push_back(iadc);
94 data.
samples.push_back(iadc - ped);
96 AdcIndex tp = 10*ievt + 60 - 2.3*icha;
103 assert( padv->viewMap(datamap) == 0 );
106 cout << myname << line <<
endl;
107 cout << myname <<
"Done." <<
endl;
114 bool useExistingFcl =
false;
116 string sarg(argv[1]);
117 if ( sarg ==
"-h" ) {
118 cout <<
"Usage: " << argv[0] <<
" [ARG]" <<
endl;
119 cout <<
" If ARG = true, existing FCL file is used." <<
endl;
122 useExistingFcl = sarg ==
"true" || sarg ==
"1";
void setChannelInfo(ChannelInfoPtr pchi)
void line(double t, double *p, double &x, double &y, double &z)
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
int main(int argc, char *argv[])
int test_AdcDataDumper(bool useExistingFcl=false)
QTextStream & endl(QTextStream &s)