75 const string myname =
"test_ExpTailRemover: ";
77 cout << myname <<
"NDEBUG must be off." <<
endl;
80 string line =
"-----------------------------";
82 cout << myname << line <<
endl;
83 string fclfile =
"test_ExpTailRemover.fcl";
84 float decayTime = 100.0;
87 if ( ! useExistingFcl ) {
88 cout << myname <<
"Creating top-level FCL." <<
endl;
89 ofstream
fout(fclfile.c_str());
92 fout <<
" tool_type: AdcThresholdSignalFinder" <<
endl;
97 fout <<
" FlagPositive: true" <<
endl;
98 fout <<
" FlagNegative: true" <<
endl;
101 fout <<
" tool_type: ExpTailRemover" <<
endl;
103 fout <<
" SignalFlag: " << flag <<
endl;
104 fout <<
" SignalIterationLimit: 10" <<
endl;
105 fout <<
" SignalTool: \"sigfind\"" <<
endl;
106 fout <<
" DecayTime: " << decayTime <<
endl;
107 fout <<
" IncludeChannelRanges: [\"all\"]" <<
endl;
108 fout <<
" ExcludeChannelRanges: []" <<
endl;
113 cout << myname <<
"Using existing top-level FCL." <<
endl;
116 cout << myname << line <<
endl;
117 cout << myname <<
"Fetching tool manager." <<
endl;
119 assert ( ptm !=
nullptr );
124 cout << myname << line <<
endl;
125 cout << myname <<
"Fetching tool." <<
endl;
127 assert( ptoo !=
nullptr );
129 cout << myname <<
"Create signals." <<
endl;
131 FloatVector pulse = { 0.1, 4.5, 15.2, 66.4, 94.3, 100.0, 96.5, 88.4, 72.6, 58.4,
132 42.3, 35.1, 26.0, 18.6, 12.6, 8.8, 6.9, 4.4, 2.0, 0.3 };
133 Index npul = pulse.size();
138 Index npea = peakPoss.size();
139 for (
Index ipea=0; ipea<npea; ++ipea ) {
140 Index iposPeak = peakPoss[ipea];
141 float norm = peakAmps[ipea];
142 for (
Index ipul=0; ipul<npul; ++ipul ) {
143 Index isam = iposPeak + ipul;
144 if ( isam >= nsam )
break;
145 sigs1[isam] += norm*pulse[ipul];
146 isSignal[isam] =
true;
150 cout << myname << line <<
endl;
151 cout << myname <<
"Add noise to the signal." <<
endl;
152 if ( setSeed ) gRandom->SetSeed();
153 for (
float& sig : sigs1 ) sig += gRandom->Gaus(0.0, noiseSigma);
155 cout << myname <<
"Create sample tailer." <<
endl;
157 sta.setPedestal(ped);
159 sta.setUnit(
"ADC count");
160 cout << myname <<
" decayTime: " << sta.decayTime() <<
endl;
161 cout << myname <<
" beta: " << sta.beta() <<
endl;
162 cout << myname <<
" alpha: " << sta.alpha() <<
endl;
163 cout << myname <<
" pedestal: " << sta.pedestal() <<
endl;
164 cout << myname <<
" tail0: " << sta.tail0() <<
endl;
166 cout << myname << line <<
endl;
167 cout << myname <<
"Add pedestal and tail to the signal to create data." <<
endl;
168 assert( sta.setSignal(sigs1) == 0 );
170 cout << myname << line <<
endl;
171 cout << myname <<
"Create channel data." <<
endl;
179 cout << myname << line <<
endl;
180 cout << myname <<
"Check input noise." <<
endl;
181 SigStats inStats(acd, myname);
182 assert( inStats.count > 0 );
184 cout << myname << line <<
endl;
185 cout << myname <<
"Use tool to remove tail from data." <<
endl;
186 DataMap res = ptoo->update(acd);
190 cout << myname << line <<
endl;
191 cout << myname <<
"Check output noise." <<
endl;
192 SigStats ouStats(acd, myname);
193 assert( ouStats.count > 0 );
195 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)