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})),
46 std::vector<short> waveform;
48 waveform.push_back(orig[i]);
80 std::transform(filtered.begin(), filtered.end(),
92 std::vector<short> runningSum(filtered.size(), 0); runningSum[0] = 0;
93 for (
size_t i=0; i<filtered.size(); ++i) {
96 if (sumValue < 0) runningSum[i] = 0;
97 else runningSum[i] = sumValue;
105 const std::vector<short>& iqr,
106 std::vector<RunningSumTPFinderTool::Hit>& hits,
113 bool was_hit =
false;
115 for(
size_t isample=0; isample<waveform.size()-1; ++isample){
117 short adc = waveform[isample];
119 if(is_hit && !was_hit) {
124 if(is_hit && was_hit) {
128 if(!is_hit && was_hit) {
136 std::vector<RunningSumTPFinderTool::Hit>
138 const std::vector<std::vector<short>>& collection_samples) {
140 auto hits = std::vector<RunningSumTPFinderTool::Hit>();
141 std::cout <<
"findHits called with " << collection_samples.size()
142 <<
" channels. First chan has " << collection_samples[0].size() <<
" samples" <<
std::endl;
144 for(
size_t ich=0; ich<collection_samples.size(); ++ich){
145 const std::vector<short>& waveformOrig = collection_samples[ich];
147 std::vector<short> waveform =
downSample (waveformOrig);
149 std::vector<short> pedsub(waveform.size(), 0);
150 for(
size_t i=0; i<pedsub.size(); ++i)
151 pedsub[i]=waveform[i]-pedestal[i];
153 std::vector<short> filtered =
filter(pedsub);
154 std::vector<short> runingSum =
runSum(filtered);
155 hitFinding(runingSum, iqr, hits, channel_numbers[ich]);
157 std::cout <<
"Returning " << hits.size() <<
" hits" <<
std::endl;
158 std::cout <<
"hits/channel=" <<
float(hits.size())/collection_samples .
size() <<
std::endl;
159 std::cout <<
"hits/tick=" <<
float(hits.size())/collection_samples[0].
size() <<
std::endl;
short m_signalKillLookahead
short m_signalKillNContig
std::vector< short > filter(const std::vector< short > &orig)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
std::vector< short > m_filterTaps
std::vector< short > findPedestal(const std::vector< short > &orig)
std::vector< short > downSample(const std::vector< short > &orig)
void hitFinding(const std::vector< short > &waveform, const std::vector< short > &iqr, std::vector< RunningSumTPFinderTool::Hit > &hits, int channel)
virtual std::vector< RunningSumTPFinderTool::Hit > findHits(const std::vector< unsigned int > &channel_numbers, const std::vector< std::vector< short >> &collection_samples)
unsigned int m_downsampleFactor
short m_signalKillThreshold
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)
RunningSumTPFinderPass3(fhicl::ParameterSet const &p)
auto const & get(AssnsNode< L, R, D > const &r)
std::vector< short > frugal_pedestal(const std::vector< short > &raw_in, const int ncontig)
QTextStream & endl(QTextStream &s)
std::vector< short > runSum(const std::vector< short > &orig)