124 const string myname =
"test_ExpTailPedRemover: ";
126 cout << myname <<
"NDEBUG must be off." <<
endl;
129 string line =
"-----------------------------";
131 cout << myname << line <<
endl;
132 string fclfile =
"test_ExpTailPedRemover.fcl";
133 float decayTime = 100.0;
136 int pedDegree = slope == 0.0 ? 0 : 1;
137 if ( ! useExistingFcl ) {
138 cout << myname <<
"Creating top-level FCL." <<
endl;
139 ofstream
fout(fclfile.c_str());
142 fout <<
" tool_type: AdcThresholdSignalFinder" <<
endl;
147 fout <<
" FlagPositive: true" <<
endl;
148 fout <<
" FlagNegative: true" <<
endl;
151 fout <<
" tool_type: ExpTailPedRemover" <<
endl;
153 fout <<
" SignalFlag: " << flag <<
endl;
154 fout <<
" SignalIterationLimit: 10" <<
endl;
155 fout <<
" SignalTool: \"sigfind\"" <<
endl;
156 fout <<
" DecayTime: " << decayTime <<
endl;
158 fout <<
" PedDegree: " << pedDegree <<
endl;
159 fout <<
" PedTick0: " << tick0 <<
endl;
161 fout <<
" NoWarnStatuses: []" <<
endl;
162 fout <<
" IncludeChannelRanges: [\"all\"]" <<
endl;
163 fout <<
" ExcludeChannelRanges: []" <<
endl;
168 cout << myname <<
"Using existing top-level FCL." <<
endl;
171 cout << myname << line <<
endl;
172 cout << myname <<
"Fetching tool manager." <<
endl;
174 assert ( ptm !=
nullptr );
179 cout << myname << line <<
endl;
180 cout << myname <<
"Fetching tool." <<
endl;
182 assert( ptoo !=
nullptr );
184 cout << myname <<
"Create signals." <<
endl;
186 FloatVector pulse = { 0.1, 4.5, 15.2, 66.4, 94.3, 100.0, 96.5, 88.4, 72.6, 58.4,
187 42.3, 35.1, 26.0, 18.6, 12.6, 8.8, 6.9, 4.4, 2.0, 0.3 };
188 Index npul = pulse.size();
193 Index npea = peakPoss.size();
194 for (
Index ipea=0; ipea<npea; ++ipea ) {
195 Index iposPeak = peakPoss[ipea];
196 float norm = peakAmps[ipea];
197 for (
Index ipul=0; ipul<npul; ++ipul ) {
198 Index isam = iposPeak + ipul;
199 if ( isam >= nsam )
break;
200 sigs1[isam] += norm*pulse[ipul];
201 isSignal[isam] =
true;
206 cout << myname << line <<
endl;
207 cout << myname <<
"Add noise to the signal." <<
endl;
208 if ( setSeed ) gRandom->SetSeed();
209 for (
float& sig : sigs1 ) sig += gRandom->Gaus(0.0, noiseSigma);
211 cout << myname <<
"Create sample tailer." <<
endl;
215 if ( slope == 0.0 ) {
216 sta.setPedestal(ped);
219 for (
Index isam=0; isam<nsam; ++isam ) {
220 float x =
float(isam) - tick0;
221 peds[isam] = ped + slope*x + curv*x*
x;
223 sta.setPedestalVector(&peds);
226 sta.setUnit(
"ADC count");
227 cout << myname <<
" decayTime: " << sta.decayTime() <<
endl;
228 cout << myname <<
" beta: " << sta.beta() <<
endl;
229 cout << myname <<
" alpha: " << sta.alpha() <<
endl;
230 cout << myname <<
" pedestal: " << ped <<
endl;
231 cout << myname <<
" slope: " << slope <<
endl;
232 cout << myname <<
" curvature: " << curv <<
endl;
233 cout << myname <<
" tail0: " << sta.tail0() <<
endl;
235 cout << myname << line <<
endl;
236 cout << myname <<
"Add pedestal and tail to the signal to create data." <<
endl;
237 assert( sta.setSignal(sigs1) == 0 );
239 cout << myname << line <<
endl;
240 cout << myname <<
"Create channel data." <<
endl;
248 cout << myname << line <<
endl;
249 cout << myname <<
"Check input noise." <<
endl;
250 SigStats inStats(acd, sigs0, myname);
251 assert( inStats.count > 0 );
253 cout << myname << line <<
endl;
254 cout << myname <<
"Use tool to remove tail from data." <<
endl;
255 DataMap res = ptoo->update(acd);
259 cout << myname << line <<
endl;
260 cout << myname <<
"Check output noise." <<
endl;
261 SigStats ouStats(acd, sigs0, myname);
262 assert( ouStats.count > 0 );
264 drawResults(sigs0, sta.data(), acd.
samples);
266 cout << myname <<
"Done." <<
endl;
void print(std::ostream *pout) const
void setChannelInfo(ChannelInfoPtr pchi)
void setEventInfo(EventInfoPtr pevi)
auto norm(Vector const &v)
Return norm of the specified vector.
std::vector< bool > AdcFilterVector
void line(double t, double *p, double &x, double &y, double &z)
Dft::FloatVector FloatVector
QTextStream & endl(QTextStream &s)