86 const string myname =
"test_SampleTailer: ";
87 cout << myname <<
"Starting test" <<
endl;
89 cout << myname <<
"NDEBUG must be off." <<
endl;
94 cout << myname <<
"Create signals." <<
endl;
96 FloatVector pulse = { 0.1, 4.5, 15.2, 66.4, 94.3, 100.0, 96.5, 88.4, 72.6, 58.4,
97 42.3, 35.1, 26.0, 18.6, 12.6, 8.8, 6.9, 4.4, 2.0, 0.3 };
98 Index npul = pulse.size();
102 Index npea = peakPoss.size();
103 for (
Index ipea=0; ipea<npea; ++ipea ) {
104 Index iposPeak = peakPoss[ipea];
105 float norm = peakAmps[ipea];
106 for (
Index ipul=0; ipul<npul; ++ipul ) {
107 Index isam = iposPeak + ipul;
108 if ( isam >= nsam )
break;
109 sigs1[isam] += norm*pulse[ipul];
113 cout << myname <<
"Create utility." <<
endl;
116 for (
unsigned int isam=0; isam<peds.size(); ++isam ) {
117 peds[isam] = 5.0 + 0.1*isam;
120 sta.setPedestalVector(&peds);
122 sta.setPedestal(5.0);
125 sta.setUnit(
"ADC count");
126 cout << myname <<
" decayTime: " << sta.decayTime() <<
endl;
127 cout << myname <<
" beta: " << sta.beta() <<
endl;
128 cout << myname <<
" alpha: " << sta.alpha() <<
endl;
129 cout << myname <<
" pedestal: " << sta.pedestal() <<
endl;
130 cout << myname <<
" tail0: " << sta.tail0() <<
endl;
133 cout << myname <<
"Create data from signal." <<
endl;
134 assert( sta.setSignal(sigs1) == 0 );
135 assert( sta.data().size() == nsam );
136 assert( sta.signal().size() == nsam );
137 assert( sta.tail().size() == nsam );
141 drawResults(sta,
"Data, signal and tail from signal",
"SampleTrailerFromSignal.png");
144 cout << myname <<
"Create signal from data." <<
endl;
146 assert( sta.data().size() == 0 );
147 assert( sta.signal().size() == 0 );
148 assert( sta.tail().size() == 0 );
149 assert( sta.setData(dats1) == 0 );
150 assert( sta.data().size() == nsam );
151 assert( sta.signal().size() == nsam );
152 assert( sta.tail().size() == nsam );
156 drawResults(sta,
"Data, signal and tail from data",
"SampleTrailerFromData.png");
159 cout << myname <<
"Compare new signal with original.";
160 cout << myname <<
" i sig1 sig2 diff" <<
endl;
161 assert( sigs1.size() == sigs2.size() );
163 for (
Index isam=0; isam<nsam; ++isam ) {
164 float dif = sigs2[isam] - sigs1[isam];
165 float adif = fabs(dif);
166 cout << myname <<
setw(5) << isam <<
":";
170 if ( adif > 1.
e-3 ) {
Q_EXPORT QTSManip setprecision(int p)
auto norm(Vector const &v)
Return norm of the specified vector.
Q_EXPORT QTSManip setw(int w)
void line(double t, double *p, double &x, double &y, double &z)
Dft::FloatVector FloatVector
QTextStream & endl(QTextStream &s)