95 if (detProp.NumberTimeSamples() > 6000) {
96 std::cerr <<
"InfillChannels_module.cc: Networks cannot handle more than 6000 time ticks\n";
100 typedef std::array<short, 6000> vecAdc;
101 std::map<raw::ChannelID_t, vecAdc> infilledAdcs;
102 torch::Tensor maskedRopTensor;
103 torch::Tensor infilledRopTensor;
109 maskedRopTensor = torch::zeros(
110 {1, 1 ,6000,
fGeom->
Nchannels(currentRop)}, torch::dtype(torch::kFloat32).device(torch::kCPU).requires_grad(
false)
112 auto maskedRopTensorAccess = maskedRopTensor.accessor<
float, 4>();
121 if (rop != currentRop)
continue;
126 for (
unsigned int tick = 0;
tick < adcs.size(); ++
tick) {
127 const int adc = adcs[
tick] ?
int(adcs[
tick]) - dig.GetPedestal() : 0;
129 maskedRopTensorAccess[0][0][
tick][dig.Channel() - firstCh] =
adc;
134 std::vector<torch::jit::IValue>
inputs;
135 inputs.push_back(maskedRopTensor);
137 torch::NoGradGuard no_grad_guard;
141 torch::NoGradGuard no_grad_guard;
146 auto infilledRopTensorAccess = infilledRopTensor.accessor<
float, 4>();
149 for (
unsigned int tick = 0;
tick < detProp.NumberTimeSamples(); ++
tick) {
150 infilledAdcs[ch][
tick] = (short)std::round(infilledRopTensorAccess[0][0][
tick][ch - firstCh]);
157 auto infilledDigs = std::make_unique<std::vector<raw::RawDigit>>();
158 *infilledDigs = *digs;
160 if (infilledAdcs.count(dig.Channel())) {
162 infilledAdcs[dig.Channel()].begin(), (infilledAdcs[dig.Channel()].begin() + detProp.NumberTimeSamples())
166 auto infilledAdcMin = std::min_element(infilledAdc.begin(), infilledAdc.end());
167 short ped = *infilledAdcMin < 0 ?
std::abs(*infilledAdcMin) + 1 : 0;
168 for (
short& adc : infilledAdc) adc += ped;
171 dig =
raw::RawDigit(dig.Channel(), dig.Samples(), infilledAdc, dig.Compression());
std::set< raw::ChannelID_t > fDeadChannels
Collection of charge vs time digitized from a single readout channel.
Handle< PROD > getHandle(SelectorBase const &) const
std::vector< short > ADCvector_t
Type representing a (compressed) vector of ADC counts.
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
const std::string fInputLabel
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
const geo::GeometryCore * fGeom
Signal from induction planes.
raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const
Returns the ID of the first channel in the specified readout plane.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Class identifying a set of planes sharing readout channels.
readout::ROPID ChannelToROP(raw::ChannelID_t channel) const
void SetPedestal(float ped, float sigma=1.)
Set pedestal and its RMS (the latter is 0 by default)
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
torch::jit::script::Module fInductionModule
unsigned int ChannelID_t
Type representing the ID of a readout channel.
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
torch::jit::script::Module fCollectionModule
Signal from collection planes.
std::set< readout::ROPID > fActiveRops