28 #include "cetlib_except/exception.h" 37 #include "nurandom/RandomUtils/NuRandomService.h" 84 std::vector<float>
filter( std::vector<short unsigned int> vec, Int_t
nBins);
103 produces< vector< raw::OpDetWaveform > >(
label);
116 auto wfHandle = evt.
getHandle< vector< raw::OpDetWaveform > >(itag1);
119 if (!wfHandle.isValid()) {
125 vector< raw::OpDetWaveform > in_waveforms = *wfHandle;
128 auto out_waveforms = std::make_unique< vector< raw::OpDetWaveform > >();
131 for (
auto const& in_wave : in_waveforms) {
135 Int_t
nBins = in_wave.size();
136 std::vector<short unsigned int > out_wave(nBins);
137 std::vector<short unsigned int > out_wave_double(nBins);
138 for(Int_t i=0; i<
nBins; i++) out_wave_double[i]=2*in_wave[i];
148 std::vector<float> filtered =
filter(out_wave_double,nBins);
152 for(Int_t i=0; i<
nBins; i++){
153 convert = filtered[i];
154 convert2 = (short) convert + 0.5;
155 out_wave[i] = convert2;
162 raw::OpDetWaveform out_waveFinal(in_wave.TimeStamp(), in_wave.ChannelNumber(), out_wave);
164 out_waveforms->emplace_back(
std::move(out_waveFinal));
183 Int_t nComp = vec.size();
188 for(Int_t
n=0;
n<nComp ;
n++){
189 if(
n>mobileAVG &&
n<nComp-mobileAVG){
190 for(Int_t i=
n-mobileAVG; i<=
n+mobileAVG; i++){avg = avg + vec[i]; c0=c0+1;}
192 firstFilter[
n] =
avg;
198 for(Int_t i=0; i<=
n+mobileAVG; i++){ avg = avg + vec[i]; c1=c1+1;}
200 firstFilter[
n] =
avg;
204 else if(
n>=nComp-mobileAVG){
205 for(Int_t i=
n-mobileAVG; i<nComp; i++) {avg = avg + vec[i]; c2=c2+1;}
207 firstFilter[
n] =
avg;
229 float umin=lambda, umax=-lambda;
230 float vmin=input[0]-lambda, vmax=input[0]+lambda;
231 int kplus=0, kminus=0;
232 const float twolambda=2.0*lambda;
233 const float minlambda=-lambda;
237 do secondFilter[k0++]=vmin;
while (k0<=kminus);
238 umax=(vmin=input[kminus=k=k0])+(umin=lambda)-vmax;
239 }
else if (umax>0.0) {
240 do secondFilter[k0++]=vmax;
while (k0<=kplus);
241 umin=(vmax=input[kplus=k=k0])+(umax=minlambda)-vmin;
244 do secondFilter[k0++]=vmin;
while(k0<=k);
248 if ((umin+=input[k+1]-vmin)<minlambda) {
249 do secondFilter[k0++]=vmin;
while (k0<=kminus);
250 vmax=(vmin=input[kplus=kminus=k=k0])+twolambda;
251 umin=lambda; umax=minlambda;
252 }
else if ((umax+=input[k+1]-vmax)>lambda) {
253 do secondFilter[k0++]=vmax;
while (k0<=kplus);
254 vmin=(vmax=input[kplus=kminus=k=k0])-twolambda;
255 umin=lambda; umax=minlambda;
259 vmin+=(umin-lambda)/((kminus=k)-k0+1);
262 if (umax<=minlambda) {
263 vmax+=(umax+lambda)/((kplus=k)-k0+1);
Handle< PROD > getHandle(SelectorBase const &) const
EDProducer(fhicl::ParameterSet const &pset)
fhicl::Sequence< string > InputLabels
ChannelGroupService::Name Name
PDSNoiseFilter(Parameters const &config)
void produce(art::Event &)
void TV1D_denoise(vector< float > input, vector< float > &secondFilter, const int width, const float lambda)
#define DEFINE_ART_MODULE(klass)
def convert(inputfile, outputfile="wire-cell-garfield-fine-response.json.bz2", average=False, shaped=False)
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::vector< float > filter(std::vector< short unsigned int > vec, Int_t nBins)
fhicl::Atom< string > InputModule
vector< string > fInputLabels
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning