26 const string myname =
"test_AdcChannelPlotter: ";
28 cout << myname <<
"NDEBUG must be off." <<
endl;
31 string line =
"-----------------------------";
33 cout << myname << line <<
endl;
34 string fclfile =
"test_AdcChannelPlotter.fcl";
35 if ( ! useExistingFcl ) {
36 cout << myname <<
"Creating top-level FCL." <<
endl;
37 ofstream
fout(fclfile.c_str());
38 fout <<
"#include \"dataprep_tools.fcl\"" <<
endl;
40 fout <<
" tool_type: AdcChannelPlotter" <<
endl;
42 fout <<
" HistTypes: [\"raw\", \"rawdist\", \"prepared\"]" <<
endl;
43 fout <<
" HistName: \"adc%TYPE%_%EVENT%_%CHAN%\"" <<
endl;
44 fout <<
" HistTitle: \"ADC %TYPE% event %EVENT% channel %CHAN%\"" <<
endl;
45 fout <<
" RootFileName: \"adcplot.root\"" <<
endl;
46 fout <<
" PlotFileName: \"adcsigs.png\"" <<
endl;
56 fout <<
" HistManager: \"\"" <<
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( padv !=
nullptr );
79 cout << myname << line <<
endl;
80 cout << myname <<
"Create data and call too." <<
endl;
82 string lab =
"plane 3u";
83 float peds[10] = {701.1, 711.2, 733.3, 690.4, 688.5, 703.6, 720.7, 720.8, 695.9, 702.0};
84 for (
AdcIndex ievt=0; ievt<nevt; ++ievt ) {
85 cout << myname <<
"Event " << ievt <<
endl;
88 for (
AdcIndex icha=0; icha<ncha; ++icha ) {
89 std::pair<AdcChannelDataMap::iterator, bool> kdat = datamap.emplace(icha,
AdcChannelData());
93 float ped = peds[icha];
97 for (
AdcIndex itic=0; itic<100; ++itic ) {
98 float xadc = ped + rand()%20 - 10.0;
100 if ( iticeff > 20 && iticeff < 40 ) xadc +=600;
102 data.
raw.push_back(iadc);
103 data.
flags.push_back(0);
104 data.
samples.push_back(iadc - ped);
105 data.
signal.push_back(xadc - ped > 300.0 );
107 AdcIndex tp = 10*ievt + 60 - 2.3*icha;
115 assert( padv->view(datamap[icha]) == 0 );
119 cout << myname << line <<
endl;
120 cout << myname <<
"Done." <<
endl;
127 bool useExistingFcl =
false;
129 string sarg(argv[1]);
130 if ( sarg ==
"-h" ) {
131 cout <<
"Usage: " << argv[0] <<
" [ARG]" <<
endl;
132 cout <<
" If ARG = true, existing FCL file is used." <<
endl;
135 useExistingFcl = sarg ==
"true" || sarg ==
"1";
int main(int argc, char *argv[])
void setChannelInfo(ChannelInfoPtr pchi)
void setEventInfo(EventInfoPtr pevi)
void line(double t, double *p, double &x, double &y, double &z)
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
int test_AdcChannelPlotter(bool useExistingFcl=false)
QTextStream & endl(QTextStream &s)