Produce method.
evt - Art event.
This is the primary method.
191 std::unique_ptr<std::vector<raw::RawDigit> > erosionRawDigit(
new std::vector<raw::RawDigit>);
192 std::unique_ptr<std::vector<raw::RawDigit> > dilationRawDigit(
new std::vector<raw::RawDigit>);
193 std::unique_ptr<std::vector<raw::RawDigit> > edgeRawDigit(
new std::vector<raw::RawDigit>);
194 std::unique_ptr<std::vector<raw::RawDigit> > differenceRawDigit(
new std::vector<raw::RawDigit>);
195 std::unique_ptr<std::vector<raw::RawDigit> > averageRawDigit(
new std::vector<raw::RawDigit>);
196 std::unique_ptr<std::vector<raw::RawDigit> > medianRawDigit(
new std::vector<raw::RawDigit>);
198 erosionRawDigit->clear();
199 dilationRawDigit->clear();
200 edgeRawDigit->clear();
201 differenceRawDigit->clear();
202 averageRawDigit->clear();
203 medianRawDigit->clear();
206 art::Handle< std::vector<raw::RawDigit> > digitVecHandle;
210 if (digitVecHandle.isValid() && digitVecHandle->size() > 0)
212 erosionRawDigit->reserve(digitVecHandle->size());
213 dilationRawDigit->reserve(digitVecHandle->size());
214 edgeRawDigit->reserve(digitVecHandle->size());
215 differenceRawDigit->reserve(digitVecHandle->size());
216 averageRawDigit->reserve(digitVecHandle->size());
217 medianRawDigit->reserve(digitVecHandle->size());
223 std::vector<const raw::RawDigit*> rawDigitVec;
226 for(
size_t idx = 0; idx < digitVecHandle->size(); idx++) rawDigitVec.push_back(&digitVecHandle->at(idx));
232 size_t rawDataSize = rawDigitVec.front()->Samples();
260 size_t validIndex = 0;
263 size_t maxAdcBinSize(0);
267 for(
const auto& structElemVal : rowVec)
268 if (structElemVal) maxAdcBinSize++;
271 std::vector<short> adcBinValVec(maxAdcBinSize, 0);
279 for(
const auto& rawDigit : rawDigitVec)
283 if (channel >= maxChannels)
continue;
289 if (lastWireID.
asPlaneID().
cmp(wids[0].asPlaneID()) != 0)
292 WaveformList::iterator inputWaveItr = inputWaveformList.begin();
294 std::advance(inputWaveItr, fStructuringElementWireSize/2);
296 while(++inputWaveItr != inputWaveformList.end())
311 lastWireID = wids[0];
314 unsigned int plane = wids[0].Plane;
315 unsigned int wire = wids[0].Wire;
317 if (rawDigit->Samples() < 1)
319 std::cout <<
"****>> Found zero length raw digit buffer, channel: " << channel <<
", plane: " << plane <<
", wire: " << wire << std::endl;
324 if (validIndex == inputWaveformList.size())
326 inputWaveformList.push_back(inputWaveformList.front());
327 inputWaveformList.pop_front();
332 WaveformList::iterator inputWaveItr = inputWaveformList.begin();
333 WaveformList::iterator midWaveItr = inputWaveItr;
335 std::advance(inputWaveItr, validIndex - 1);
336 std::advance(midWaveItr, validIndex / 2);
341 raw::Uncompress(rawDigit->ADCs(), inputAdcVector, rawDigit->Compression());
353 std::transform(inputAdcVector.begin(),inputAdcVector.end(),rawadc.begin(),std::bind(std::minus<short>(),std::placeholders::_1,pedCorVal));
355 std::get<0>(**inputWaveItr) = channel;
356 std::get<1>(**inputWaveItr) = pedestal;
357 std::get<2>(**inputWaveItr) = rmsVal;
360 if (validIndex == inputWaveformList.size())
364 float midPedestal = std::get<1>(**midWaveItr);
365 float midRmsVal = std::get<2>(**midWaveItr);
371 for(
size_t adcBinIdx = 0; adcBinIdx < halfStructuringElementTickSize; adcBinIdx++)
373 size_t adcLastBinIdx = rawDataSize - adcBinIdx - 1;
375 erosionVec[adcBinIdx] = midPedestal;
376 erosionVec[adcLastBinIdx] = midPedestal;
377 dilationVec[adcBinIdx] = midPedestal;
378 dilationVec[adcLastBinIdx] = midPedestal;
379 edgeVec[adcBinIdx] = midPedestal;
380 edgeVec[adcLastBinIdx] = midPedestal;
381 differenceVec[adcBinIdx] = midPedestal;
382 differenceVec[adcLastBinIdx] = midPedestal;
383 averageVec[adcBinIdx] = midPedestal;
384 averageVec[adcLastBinIdx] = midPedestal;
385 medianVec[adcBinIdx] = midPedestal;
386 medianVec[adcLastBinIdx] = midPedestal;
391 for(
size_t adcBinIdx = halfStructuringElementTickSize; adcBinIdx < erosionVec.size() - halfStructuringElementTickSize; adcBinIdx++)
394 size_t adcBinVecIdx(0);
397 for(
const auto& curTuple : inputWaveformList)
403 if (fStructuringElement[rowIdx][colIdx]) adcBinValVec[adcBinVecIdx++] = curAdcVec[colIdx + adcBinIdx - halfStructuringElementTickSize];
409 std::sort(adcBinValVec.begin(),adcBinValVec.end());
411 erosionVec[adcBinIdx] = adcBinValVec.front();
412 dilationVec[adcBinIdx] = adcBinValVec.back();
413 edgeVec[adcBinIdx] = (dilationVec[adcBinIdx] - currentVec[adcBinIdx]) + midPedestal;
414 differenceVec[adcBinIdx] = (dilationVec[adcBinIdx] - erosionVec[adcBinIdx]) + midPedestal;
415 averageVec[adcBinIdx] = (dilationVec[adcBinIdx] + erosionVec[adcBinIdx]) / 2;
416 medianVec[adcBinIdx] = adcBinValVec[adcBinValVec.size()/2];
419 saveRawDigits(erosionRawDigit, midChannel, midPedestal, midRmsVal, std::get<3>(erosionTuple));
420 saveRawDigits(dilationRawDigit, midChannel, midPedestal, midRmsVal, std::get<3>(dilationTuple));
421 saveRawDigits(edgeRawDigit, midChannel, midPedestal, midRmsVal, std::get<3>(edgeTuple));
422 saveRawDigits(differenceRawDigit, midChannel, midPedestal, midRmsVal, std::get<3>(differenceTuple));
423 saveRawDigits(averageRawDigit, midChannel, midPedestal, midRmsVal, std::get<3>(averageTuple));
424 saveRawDigits(medianRawDigit, midChannel, midPedestal, midRmsVal, std::get<3>(medianTuple));
426 else if (validIndex <= fStructuringElementWireSize / 2)
479 event.put(std::move(erosionRawDigit),
"erosion");
480 event.put(std::move(dilationRawDigit),
"dilation");
481 event.put(std::move(edgeRawDigit),
"edge");
482 event.put(std::move(differenceRawDigit),
"difference");
483 event.put(std::move(averageRawDigit),
"average");
484 event.put(std::move(medianRawDigit),
"median");
Collection of charge vs time digitized from a single readout channel.
void getMeanRmsAndPedCor(const RawDigitVector &rawWaveform, unsigned int channel, unsigned int view, unsigned int wire, float &aveVal, float &rmsVal, float &pedCorVal) const
geo::GeometryCore const * fGeometry
pointer to Geometry service
ChannelID_t Channel() const
DAQ channel this raw data was read from.
const lariov::DetPedestalProvider & fPedestalRetrievalAlg
Keep track of an instance to the pedestal retrieval alg.
raw::RawDigit::ADCvector_t RawDigitVector
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
size_t fStructuringElementWireSize
void saveRawDigits(std::unique_ptr< std::vector< raw::RawDigit > > &, WireTuple &)
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
std::list< WireTuple * > WaveformList
constexpr PlaneID const & asPlaneID() const
Conversion to PlaneID (for convenience of notation).
std::string fDigitModuleLabel
The full collection of hits.
virtual float PedMean(raw::ChannelID_t ch) const =0
Retrieve pedestal information.
size_t fStructuringElementTickSize
std::vector< WireTuple > WaveformVec
caldata::RawDigitCharacterizationAlg fCharacterizationAlg
std::tuple< raw::ChannelID_t, float, float, caldata::RawDigitVector > WireTuple
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.
int fNumEvent
Number of events seen.
constexpr int cmp(PlaneID const &other) const
Returns < 0 if this is smaller than other, 0 if equal, > 0 if larger.
BEGIN_PROLOG could also be cout
StructuringElement fStructuringElement