19 : m_threshold (p.
get<unsigned
int> (
"Threshold" )),
20 m_useSignalKill (p.
get<
bool> (
"UseSignalKill" , true)),
21 m_signalKillLookahead(p.
get<short> (
"SignalKillLookahead" , 5)),
22 m_signalKillThreshold(p.
get<short> (
"SignalKillThreshold" , 15)),
23 m_signalKillNContig (p.
get<short> (
"SignalKillNContig" , 1)),
24 m_frugalNContig (p.
get<short> (
"FrugalPedestalNContig", 10)),
25 m_doFiltering (p.
get<
bool> (
"DoFiltering" , true)),
26 m_downsampleFactor (p.
get<unsigned
int> (
"DownsampleFactor" , 1)),
27 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 std::vector<RunningSumTPFinderTool::Hit>& hits,
112 bool was_hit =
false;
114 for(
size_t isample=0; isample<waveform.size()-1; ++isample){
116 short adc = waveform[isample];
118 if(is_hit && !was_hit) {
123 if(is_hit && was_hit) {
127 if(!is_hit && was_hit) {
135 std::vector<RunningSumTPFinderTool::Hit>
137 const std::vector<std::vector<short>>& collection_samples) {
139 auto hits = std::vector<RunningSumTPFinderTool::Hit>();
140 std::cout <<
"findHits called with " << collection_samples.size()
141 <<
" channels. First chan has " << collection_samples[0].size() <<
" samples" <<
std::endl;
143 for(
size_t ich=0; ich<collection_samples.size(); ++ich){
144 const std::vector<short>& waveformOrig = collection_samples[ich];
146 std::vector<short> waveform =
downSample (waveformOrig);
148 std::vector<short> pedsub(waveform.size(), 0);
149 for(
size_t i=0; i<pedsub.size(); ++i)
150 pedsub[i]=waveform[i]-pedestal[i];
151 std::vector<short> filtered =
filter(pedsub);
152 std::vector<short> runingSum =
runSum(filtered);
153 hitFinding(runingSum, hits, channel_numbers[ich]);
155 std::cout <<
"Returning " << hits.size() <<
" hits" <<
std::endl;
156 std::cout <<
"hits/channel=" <<
float(hits.size())/collection_samples .
size() <<
std::endl;
157 std::cout <<
"hits/tick=" <<
float(hits.size())/collection_samples[0].
size() <<
std::endl;
short m_signalKillLookahead
std::vector< short > m_filterTaps
unsigned int m_downsampleFactor
short m_signalKillThreshold
short m_signalKillNContig
void hitFinding(const std::vector< short > &waveform, std::vector< RunningSumTPFinderTool::Hit > &hits, int channel)
std::vector< short > filter(const std::vector< short > &orig)
std::vector< short > findPedestal(const std::vector< short > &orig)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
std::vector< short > runSum(const std::vector< short > &orig)
std::vector< short > apply_fir_filter(const std::vector< short > &input, const size_t ntaps, const short *taps)
std::vector< short > frugal_pedestal_sigkill(const std::vector< short > &raw_in, const int lookahead, const int threshold, const int ncontig)
std::vector< short > downSample(const std::vector< short > &orig)
auto const & get(AssnsNode< L, R, D > const &r)
std::vector< short > frugal_pedestal(const std::vector< short > &raw_in, const int ncontig)
virtual std::vector< RunningSumTPFinderTool::Hit > findHits(const std::vector< unsigned int > &channel_numbers, const std::vector< std::vector< short >> &collection_samples)
RunningSumTPFinderPass1(fhicl::ParameterSet const &p)
QTextStream & endl(QTextStream &s)