Skip to content

Commit 42b2e55

Browse files
authored
Merge pull request #159 from HaiwangYu/idft-uboone-fix
Fix a legacy issue in uboone revealed by new IDFT
2 parents 6900d02 + c195e84 commit 42b2e55

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

sigproc/src/Microboone.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,9 @@ WireCell::Waveform::ChannelMaskMap Microboone::OneChannelNoise::apply(int ch, si
944944

945945
int nspec = 0; // just catch any non-zero
946946
if (!is_partial) {
947-
auto const& spec = m_noisedb->rcrc(ch);
947+
auto const& spec_old = m_noisedb->rcrc(ch);
948+
auto spec = spec_old.size() == spectrum.size() ? spec_old :
949+
Waveform::resample(spec_old, {0,spec_old.size()}, spectrum.size(), {0,spectrum.size()});
948950
WireCell::Waveform::shrink(spectrum, spec);
949951

950952
if (nsiglen != spec.size()) {

util/inc/WireCellUtil/Waveform.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ namespace WireCell {
7575
/// Return a new sequence resampled and interpolated from the
7676
/// original wave defined over the domain to a new domain of
7777
/// nsamples.
78-
template <typename Val>
78+
/// if Val is complex then Scalar must match the scala rtype of Val
79+
template <typename Val, typename Scalar>
7980
Sequence<Val> resample(const Sequence<Val>& wave, const Domain& domain, int nsamples, const Domain& newdomain)
8081
{
8182
const int oldnsamples = wave.size();
82-
const double oldstep = sample_width(domain, oldnsamples);
83+
const Scalar oldstep = sample_width(domain, oldnsamples);
8384
const double step = sample_width(newdomain, nsamples);
8485
Sequence<Val> ret;
8586
for (int ind = 0; ind < nsamples; ++ind) {
@@ -94,14 +95,24 @@ namespace WireCell {
9495
ret.push_back(wave[oldnsamples - 1]);
9596
continue;
9697
}
97-
double d1 = oldfracsteps - oldstep * oldind;
98-
double d2 = oldstep - d1;
98+
Scalar d1 = oldfracsteps - oldstep * oldind;
99+
Scalar d2 = oldstep - d1;
99100
Val newval = (wave[oldind] * d1 + wave[oldind + 1] * d2) / oldstep;
100101
ret.push_back(newval);
101102
}
102103
return ret;
103104
}
104105

106+
/// two supported overloads
107+
inline realseq_t resample(const realseq_t& wave, const Domain& domain, int nsamples, const Domain& newdomain)
108+
{
109+
return resample<real_t, real_t>(wave, domain, nsamples, newdomain);
110+
}
111+
inline compseq_t resample(const compseq_t& wave, const Domain& domain, int nsamples, const Domain& newdomain)
112+
{
113+
return resample<complex_t, real_t>(wave, domain, nsamples, newdomain);
114+
}
115+
105116
/// Return the real part of the sequence
106117
realseq_t real(const compseq_t& seq);
107118
/// Return the imaginary part of the sequence

0 commit comments

Comments
 (0)