19 : m_threshold(p.
get<unsigned
int>(
"Threshold", 10)),
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)),
29 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]);
81 std::transform(filtered.begin(), filtered.end(),
90 std::vector<TriggerPrimitiveFinderTool::Hit>& hits,
99 for(
size_t isample=0; isample<waveform.size()-1; ++isample){
102 short adc=waveform[isample];
104 if(is_hit && !was_hit){
110 if(is_hit && was_hit){
114 if(!is_hit && was_hit){
124 std::vector<TriggerPrimitiveFinderTool::Hit>
126 const std::vector<std::vector<short>>& collection_samples)
128 auto hits=std::vector<TriggerPrimitiveFinderTool::Hit>();
129 std::cout <<
"findHits called with " << collection_samples.size()
130 <<
" channels. First chan has " << collection_samples[0].size() <<
" samples" <<
std::endl;
135 for(
size_t ich=0; ich<collection_samples.size(); ++ich){
136 const std::vector<short>& waveformOrig=collection_samples[ich];
138 std::vector<short> waveform=
downSample(waveformOrig);
141 std::vector<short> pedsub(waveform.size(), 0);
142 for(
size_t i=0; i<pedsub.size(); ++i){
143 pedsub[i]=waveform[i]-pedestal[i];
146 std::vector<short> filtered=
filter(pedsub);
147 hitFinding(filtered, hits, channel_numbers[ich]);
149 std::cout <<
"Returning " << hits.size() <<
" hits" <<
std::endl;
150 std::cout <<
"hits/channel=" <<
float(hits.size())/collection_samples.size() <<
std::endl;
151 std::cout <<
"hits/tick=" <<
float(hits.size())/collection_samples[0].
size() <<
std::endl;
void hitFinding(const std::vector< short > &waveform, std::vector< TriggerPrimitiveFinderTool::Hit > &hits, int channel)
short m_signalKillLookahead
std::vector< short > downSample(const std::vector< short > &orig)
std::vector< short > findPedestal(const std::vector< short > &orig)
unsigned int m_downsampleFactor
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
virtual std::vector< TriggerPrimitiveFinderTool::Hit > findHits(const std::vector< unsigned int > &channel_numbers, const std::vector< std::vector< short >> &collection_samples)
std::vector< short > filter(const std::vector< short > &orig)
std::vector< short > apply_fir_filter(const std::vector< short > &input, const size_t ntaps, const short *taps)
short m_signalKillNContig
std::vector< short > frugal_pedestal_sigkill(const std::vector< short > &raw_in, const int lookahead, const int threshold, const int ncontig)
short m_signalKillThreshold
auto const & get(AssnsNode< L, R, D > const &r)
TriggerPrimitiveFinderPass1(fhicl::ParameterSet const &p)
std::vector< short > m_filterTaps
std::vector< short > frugal_pedestal(const std::vector< short > &raw_in, const int ncontig)
QTextStream & endl(QTextStream &s)