19 : m_useSignalKill (p.
get<
bool> (
"UseSignalKill" , true)),
20 m_signalKillLookahead(p.
get<short> (
"SignalKillLookahead" , 5)),
21 m_signalKillThreshold(p.
get<short> (
"SignalKillThreshold" , 15)),
22 m_signalKillNContig (p.
get<short> (
"SignalKillNContig" , 1)),
23 m_frugalNContig (p.
get<short> (
"FrugalPedestalNContig", 10)),
24 m_doFiltering (p.
get<
bool> (
"DoFiltering" , true)),
25 m_downsampleFactor (p.
get<unsigned
int> (
"DownsampleFactor" , 1)),
26 m_filterTaps (p.
get<
std::
vector<short>>(
"FilterCoeffs" , {2, 9, 23, 31, 23, 9, 2})),
45 std::vector<short> waveform;
47 waveform.push_back(orig[i]);
79 std::transform(filtered.begin(), filtered.end(),
88 const std::vector<short>& iqr,
89 std::vector<RunningSumTPFinderTool::Hit>& hits,
98 for(
size_t isample=0; isample<waveform.size()-1; ++isample){
100 short adc = waveform[isample];
102 if(is_hit && !was_hit) {
107 if(is_hit && was_hit) {
111 if(!is_hit && was_hit) {
119 std::vector<RunningSumTPFinderTool::Hit>
121 const std::vector<std::vector<short>>& collection_samples) {
123 auto hits = std::vector<RunningSumTPFinderTool::Hit>();
124 std::cout <<
"findHits called with " << collection_samples.size()
125 <<
" channels. First chan has " << collection_samples[0].size() <<
" samples" <<
std::endl;
127 for(
size_t ich=0; ich<collection_samples.size(); ++ich){
128 const std::vector<short>& waveformOrig = collection_samples[ich];
130 std::vector<short> waveform =
downSample (waveformOrig);
132 std::vector<short> pedsub(waveform.size(), 0);
133 for(
size_t i=0; i<pedsub.size(); ++i)
134 pedsub[i]=waveform[i]-pedestal[i];
136 std::vector<short> filtered =
filter(pedsub);
137 hitFinding(filtered, iqr, hits, channel_numbers[ich]);
139 std::cout <<
"Returning " << hits.size() <<
" hits" <<
std::endl;
140 std::cout <<
"hits/channel=" <<
float(hits.size())/collection_samples .
size() <<
std::endl;
141 std::cout <<
"hits/tick=" <<
float(hits.size())/collection_samples[0].
size() <<
std::endl;
short m_signalKillThreshold
unsigned int m_downsampleFactor
virtual std::vector< RunningSumTPFinderTool::Hit > findHits(const std::vector< unsigned int > &channel_numbers, const std::vector< std::vector< short >> &collection_samples)
std::vector< short > findPedestal(const std::vector< short > &orig)
std::vector< short > downSample(const std::vector< short > &orig)
std::vector< short > m_filterTaps
short m_signalKillLookahead
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
void hitFinding(const std::vector< short > &waveform, const std::vector< short > &iqr, std::vector< RunningSumTPFinderTool::Hit > &hits, int channel)
std::vector< short > apply_fir_filter(const std::vector< short > &input, const size_t ntaps, const short *taps)
std::vector< short > frugal_iqr(const std::vector< short > &raw_in, const std::vector< short > &median, const int ncontig)
std::vector< short > frugal_pedestal_sigkill(const std::vector< short > &raw_in, const int lookahead, const int threshold, const int ncontig)
RunningSumTPFinderPass4(fhicl::ParameterSet const &p)
auto const & get(AssnsNode< L, R, D > const &r)
short m_signalKillNContig
std::vector< short > frugal_pedestal(const std::vector< short > &raw_in, const int ncontig)
QTextStream & endl(QTextStream &s)
std::vector< short > filter(const std::vector< short > &orig)