100 art::Handle< std::vector<raw::RawDigit> > raw;
103 const size_t nraw = raw->size();
105 art::Handle< std::vector<recob::Wire> > sig;
108 const size_t nsig = sig->size();
116 std::unordered_map<raw::ChannelID_t, art::Ptr<raw::RawDigit> > chid2rawptr;
119 auto outrsa = std::make_unique< art::Assns<raw::RawDigit,recob::Wire> >();
120 auto outraw = std::make_unique< std::vector<raw::RawDigit> >();
121 auto outsig = std::make_unique< std::vector<recob::Wire> >();
128 for (
size_t iraw=0; iraw != nraw; ++iraw) {
129 const auto& inrd = raw->at(iraw);
130 const auto& inadcs = inrd.ADCs();
131 const size_t inlen = inadcs.size();
133 const int outlen = std::min(inlen-ndrop, nkeep < 0 ? inlen : nkeep);
139 size_t outind = outraw->size();
144 auto& outrd = outraw->back();
145 outrd.SetPedestal(inrd.GetPedestal(), inrd.GetSigma());
147 chid2rawptr[chid] = RawPtr(outind);
152 for (
size_t isig=0; isig != nsig; ++isig) {
153 const auto& inw = sig->at(isig);
154 std::vector<float> wave = inw.Signal();
155 const size_t inlen = wave.size();
157 const int outlen = std::min(inlen-ndrop, nkeep < 0 ? inlen : nkeep);
163 const auto chid = inw.Channel();
164 const auto view = inw.View();
168 auto first = wave.begin()+ndrop;
169 auto done = wave.begin()+ndrop+outlen;
172 beg = std::find_if(beg, done, [](
float v){
return v != 0.0;});
176 auto end = std::find_if(beg, done, [](
float v){
return v == 0.0;});
178 std::vector<float> scaled(beg,
end);
179 for (
int ind=0; ind<
end-beg; ++ind) {
180 scaled[ind] *= sigscale;
182 roi.add_range(beg-
first, scaled.begin(), scaled.end());
186 const size_t outind = outsig->size();
187 outsig->emplace_back(
recob::Wire(roi, chid, view));
190 auto rawit = chid2rawptr.find(chid);
191 if (rawit == chid2rawptr.end()) {
194 auto const& rawptr = rawit->second;
195 auto const sigptr = SigPtr(outind);
196 outrsa->addSingle(rawptr, sigptr);
Collection of charge vs time digitized from a single readout channel.
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
fhicl::Atom< double > sigscale
fhicl::Atom< std::string > outRawTag
fhicl::Atom< std::string > outAssnTag
auto end(FixedBins< T, C > const &) noexcept
fhicl::Atom< std::string > outSigTag
Class holding the regions of interest of signal from a channel.
const EventButcherConfig m_cfg
unsigned int ChannelID_t
Type representing the ID of a readout channel.