30 const string myname =
"test_FloatArrayGainCalibration: ";
32 cout << myname <<
"NDEBUG must be off." <<
endl;
35 string line =
"-----------------------------";
37 cout << myname << line <<
endl;
38 string fclfile =
"test_FloatArrayGainCalibration.fcl";
39 double scaleFac = 2.0;
40 if ( ! useExistingFcl ) {
41 cout << myname <<
"Creating top-level FCL." <<
endl;
42 ofstream
fout(fclfile.c_str());
45 fout <<
" tool_type: FclFloatArray" <<
endl;
51 fout <<
" Values: [ 0.012, 0.014, 0.016, 0.018, 0.020 ]" <<
endl;
54 fout <<
" tool_type: FloatArrayGainCalibration" <<
endl;
57 fout <<
" GainDefault: \"1.0\"" <<
endl;
58 fout <<
" AdcUnderflowDefault: 0" <<
endl;
59 fout <<
" AdcOverflowDefault: 255" <<
endl;
60 fout <<
" GainTool: calvals" <<
endl;
61 fout <<
" ScaleFactor: \"" << scaleFac <<
"*[gain]/14.0\"" <<
endl;
64 fout <<
" tool_type: FclRunDataTool" <<
endl;
66 fout <<
" FileNames: [\"rundata.fcl\"]" <<
endl;
70 ofstream fout2(
"rundata.fcl");
71 fout2 <<
"run: 123" <<
endl;
72 fout2 <<
"gain: 14.0" <<
endl;
73 fout2 <<
"shaping: 2.0" <<
endl;
77 cout << myname <<
"Using existing top-level FCL." <<
endl;
80 cout << myname << line <<
endl;
81 cout << myname <<
"Fetching tool manager." <<
endl;
83 assert ( ptm !=
nullptr );
88 cout << myname << line <<
endl;
89 cout << myname <<
"Fetching tool." <<
endl;
91 assert( ptoo !=
nullptr );
93 cout << myname << line <<
endl;
94 cout << myname <<
"Create data." <<
endl;
105 float gain = 0.01 + 0.002*(icha+1);
111 acd.
raw.push_back(adc);
116 cout << myname << line <<
endl;
117 cout << myname <<
"Calibrate and check data." <<
endl;
119 for (
auto& ient : acds ) {
121 cout << myname <<
"-------------------- Channel " << icha <<
endl;
123 DataMap res = ptoo->update(acd);
125 assert( res.
status() == 0 );
126 assert( res.
getInt(
"calibSampleCount") ==
int(nsam) );
127 assert( acd.
channel() == icha );
128 assert( acd.
raw.size() == nsam );
129 assert( acd.
samples.size() == nsam );
131 cout <<
" ADC signal flag [ exp]" <<
endl;
132 for (
Index isam=0; isam<nsam; ++isam ) {
133 cout <<
setw(3) << isam <<
": " <<
setw(5) << acd.
raw[isam]
136 <<
" [" <<
setw(6) << sigvals[isam] <<
"]" <<
endl;
137 assert( fabs(acd.
samples[isam] - sigvals[isam]) < 0.2 );
141 cout << myname <<
"Done." <<
endl;
void print(std::ostream *pout) const
void setChannelInfo(ChannelInfoPtr pchi)
Q_EXPORT QTSManip setw(int w)
int getInt(Name name, int def=0) const
void line(double t, double *p, double &x, double &y, double &z)
std::vector< AdcSignal > AdcSignalVector
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
QTextStream & endl(QTextStream &s)