40 fhicl::Comment(
"Number of remaining ticks to keep after initial drop"),
45 fhicl::Comment(
"A multiplicative scale factor applied to the output recob::Wires"),
92 const size_t nraw = raw->size();
97 const size_t nsig = sig->size();
105 std::unordered_map<raw::ChannelID_t, art::Ptr<raw::RawDigit>> chid2rawptr;
108 auto outrsa = std::make_unique<art::Assns<raw::RawDigit, recob::Wire>>();
109 auto outraw = std::make_unique<std::vector<raw::RawDigit>>();
110 auto outsig = std::make_unique<std::vector<recob::Wire>>();
117 for (
size_t iraw = 0; iraw != nraw; ++iraw) {
118 const auto& inrd = raw->at(iraw);
119 const auto& inadcs = inrd.ADCs();
120 const size_t inlen = inadcs.size();
122 const int outlen = std::min(inlen - ndrop, nkeep < 0 ? inlen : nkeep);
128 size_t outind = outraw->size();
133 auto& outrd = outraw->back();
134 outrd.SetPedestal(inrd.GetPedestal(), inrd.GetSigma());
136 chid2rawptr[chid] = RawPtr(outind);
140 for (
size_t isig = 0; isig != nsig; ++isig) {
141 const auto& inw = sig->at(isig);
142 std::vector<float> wave = inw.Signal();
143 const size_t inlen = wave.size();
145 const int outlen = std::min(inlen - ndrop, nkeep < 0 ? inlen : nkeep);
147 if (outlen <= 0) {
continue; }
149 const auto chid = inw.Channel();
150 const auto view = inw.View();
154 auto first = wave.begin() + ndrop;
155 auto done = wave.begin() + ndrop + outlen;
158 beg = std::find_if(beg, done, [](
float v) {
return v != 0.0; });
159 if (beg == done) {
break; }
160 auto end = std::find_if(beg, done, [](
float v) {
return v == 0.0; });
162 std::vector<float> scaled(beg,
end);
163 for (
int ind = 0; ind <
end - beg; ++ind) {
164 scaled[ind] *= sigscale;
166 roi.
add_range(beg - first, scaled.begin(), scaled.end());
170 const size_t outind = outsig->size();
171 outsig->emplace_back(
recob::Wire(roi, chid, view));
174 auto rawit = chid2rawptr.find(chid);
175 if (rawit == chid2rawptr.end()) {
178 auto const& rawptr = rawit->second;
179 auto const sigptr = SigPtr(outind);
180 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.
const datarange_t & add_range(size_type offset, ITER first, ITER last)
Adds a sequence of elements as a range with specified offset.
Definition of basic raw digits.
fhicl::Atom< double > sigscale
fhicl::Atom< std::string > outRawTag
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
fhicl::Atom< std::string > outAssnTag
#define DEFINE_ART_MODULE(klass)
fhicl::Atom< std::string > inSigTag
void produce(art::Event &evt)
fhicl::Atom< std::string > inRawTag
fhicl::Atom< std::string > outSigTag
EventButcher(Parameters const ¶ms)
Class holding the regions of interest of signal from a channel.
Declaration of basic channel signal object.
const EventButcherConfig m_cfg
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Event finding and building.