92 const string myname =
"test_ExponentialChannelNoiseService: ";
94 cout << myname <<
"NDEBUG must be off." <<
endl;
97 const string line =
"-----------------------------";
101 cout << myname << line <<
endl;
102 cout << myname <<
"Create noise service." <<
endl;
104 pset.
put(
"NoiseNormZ", 3.16);
105 pset.
put(
"NoiseNormU", 3.16);
106 pset.
put(
"NoiseNormV", 3.16);
107 pset.
put(
"NoiseWidthZ", 2000.0);
108 pset.
put(
"NoiseWidthU", 2000.0);
109 pset.
put(
"NoiseWidthV", 2000.0);
110 pset.
put(
"LowCutoffZ", 7.5);
111 pset.
put(
"LowCutoffU", 7.5);
112 pset.
put(
"LowCutoffV", 7.5);
113 pset.
put(
"WhiteNoiseZ", 0.0);
114 pset.
put(
"WhiteNoiseU", 0.0);
115 pset.
put(
"WhiteNoiseV", 0.0);
116 pset.
put(
"NoiseArrayPoints", 1000);
117 pset.
put(
"OldNoiseIndex",
true);
118 pset.
put(
"RandomSeed", 54321);
125 cout << myname << line <<
endl;
126 cout << myname <<
"Create signal with ped=" << ped <<
" and " << ntick <<
" ticks." <<
endl;
127 cout << myname <<
"FFT size: " << hfftsvc->
FFTSize() <<
endl;
130 for (
unsigned int isig=0; isig<20; ++isig ) {
136 double sumsqcol = 0.0;
137 double sumdsqcol = 0.0;
139 double sumsqind = 0.0;
140 double sumdsqind = 0.0;
141 unsigned int nchan = 0;
142 unsigned int nchancol = 0;
143 unsigned int nchanind = 0;
144 unsigned int count = 0;
145 unsigned int countcol = 0;
146 unsigned int countind = 0;
148 cout << myname <<
"Looping over channels." <<
endl;
149 for (
unsigned int icha=0; icha<1000000; ++icha ) {
152 if ( icha >= maxchan )
break;
154 bool firstcol =
false;
155 bool firstind =
false;
156 string labtyp =
"unknown";
158 firstcol = nchancol == 0;
159 labtyp =
"collection";
162 firstind = nchanind == 0;
163 labtyp =
"induction";
169 assert( noisvc.addNoise(clockData, detProp, icha, sigs) == 0 );
170 if ( firstcol || firstind ) {
171 cout << myname <<
"First " << labtyp <<
" channel: " << icha <<
endl;
173 for (
unsigned int isig=0; isig<ntick; ++isig ) {
174 if ( firstcol || firstind ) {
175 if ( isig < 20 || ntick-isig < 20 ) {
176 cout << myname <<
setw(5) << isig <<
": " <<
setw(8) << sigs[isig] <<
endl;
178 if ( isig == 20 && ntick-isig > 20 ) {
179 cout << myname <<
setw(5) <<
"..." <<
endl;
182 float sig = sigs[isig];
183 double dif = sig - ped;
191 sumdsqcol += dif*dif;
196 sumdsqind += dif*dif;
201 cout << myname <<
" # channels: " << nchan <<
endl;
202 cout << myname <<
"# collection channels: " << nchancol <<
endl;
203 cout << myname <<
" # induction channels: " << nchanind <<
endl;
204 double nticktot = double(nchan)*ntick;
205 double nticktotcol = double(nchancol)*ntick;
206 double nticktotind = double(nchanind)*ntick;
207 cout << myname <<
" # tick total: " << nticktot <<
endl;
208 cout << myname <<
" Count: " << count <<
endl;
209 cout << myname <<
" Collection # tick total: " << nticktotcol <<
endl;
210 cout << myname <<
" Collection Count: " << countcol <<
endl;
211 cout << myname <<
" Induction # tick total: " << nticktotind <<
endl;
212 cout << myname <<
" Induction Count: " << countind <<
endl;
214 float mean = sum/nticktot;
215 float rms = sqrt(sumsq/nticktot - mean*mean);
216 float rms2 = sqrt(sumdsq/nticktot);
217 float meancol = sumcol/nticktotcol;
218 float rmscol = sqrt(sumsqcol/nticktotcol - meancol*meancol);
219 float rms2col = sqrt(sumdsqcol/nticktotcol);
220 float meanind = sumind/nticktotind;
221 float rmsind = sqrt(sumsqind/nticktotind - meanind*meanind);
222 float rms2ind = sqrt(sumdsqind/nticktotind);
223 cout << myname <<
" Mean: " << mean <<
endl;
224 cout << myname <<
" RMS: " << rms <<
endl;
225 cout << myname <<
" RMS2: " << rms2 <<
endl;
226 cout << myname <<
" Collection Mean: " << meancol <<
endl;
227 cout << myname <<
" Collection RMS: " << rmscol <<
endl;
228 cout << myname <<
" Collection RMS2: " << rms2col <<
endl;
229 cout << myname <<
" Induction Mean: " << meanind <<
endl;
230 cout << myname <<
" Induction RMS: " << rmsind <<
endl;
231 cout << myname <<
" Induction RMS2: " << rms2ind <<
endl;
233 cout << myname <<
"Done." <<
endl;
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
Signal from induction planes.
enum geo::_plane_sigtype SigType_t
Q_EXPORT QTSManip setw(int w)
void line(double t, double *p, double &x, double &y, double &z)
std::vector< AdcSignal > AdcSignalVector
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
void put(std::string const &key)
QTextStream & endl(QTextStream &s)
Signal from collection planes.