10 #include "../SampleTailer.h" 35 return "-----------------------------";
38 void drawResults(
const SampleTailer& sta,
string httl,
string fnam) {
39 const string myname =
"drawResults: ";
41 cout << myname <<
"Draw data." <<
endl;
45 assert( phd !=
nullptr );
46 assert( phs !=
nullptr );
47 assert( pht !=
nullptr );
48 TCanvas* pcan =
new TCanvas(
"mycan",
"mycan", 700, 500);
53 TH1* pha =
dynamic_cast<TH1*
>(phd->Clone(
"hax"));
54 pha->SetDirectory(
nullptr);
55 pha->GetYaxis()->SetRangeUser(-50, 220);
57 pha->SetTitle(httl.c_str());
59 TLine* plin =
new TLine(0, 0, sta.
size(), 0);
64 pcan->Print(fnam.c_str());
68 const string myname =
"printResults: ";
70 cout << myname <<
"Display results." <<
endl;
71 cout << myname <<
" i data signal tail" <<
endl;
72 for (
Index isam=0; isam<sta.
size(); ++isam ) {
73 cout << myname <<
setw(5) << isam <<
":";
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;
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;
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 ) {
184 bool useVector = argc > 1;
std::vector< float > FloatVector
int setData(const FloatVector &inData)
int setSignal(const FloatVector &inSignal)
Q_EXPORT QTSManip setprecision(int p)
int setPedestal(float val)
const FloatVector & data() const
const FloatVector & signal() const
auto norm(Vector const &v)
Return norm of the specified vector.
Q_EXPORT QTSManip setw(int w)
int setPedestalVector(const FloatVector *pval)
void line(double t, double *p, double &x, double &y, double &z)
int main(int argc, char **)
Dft::FloatVector FloatVector
int test_SampleTailer(bool useVector)
const FloatVector & tail() const
QTextStream & endl(QTextStream &s)