22 #include "cetlib_except/exception.h" 80 produces< std::vector<raw::RawDigit> >(
fSpillName);
98 if( pos!=std::string::npos ) {
121 std::unique_ptr< std::vector<raw::RawDigit> > digcol(
new std::vector<raw::RawDigit>);
125 auto digitVecHandle = evt.
getHandle< std::vector<raw::RawDigit> >(itag1);
127 if (!digitVecHandle->size())
return;
128 mf::LogInfo(
"UnstickADCCodes") <<
"UnstickADCCodes:: digitVecHandle size is " << digitVecHandle->size();
133 unsigned int dataSize = digitVec0->
Samples();
138 std::vector<short> rawadc(dataSize);
143 digcol->reserve(digitVecHandle->size());
144 for(
size_t rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){
155 dataSize = rawadc.size();
156 rawadc_a = rawadc.data();
159 for(
size_t i = 0; i < dataSize; ++i){
161 unsigned int sixlsbs = rawadc_a[i] &
onemask;
163 if(sixlsbs==onemask || sixlsbs==0){
167 rawadc_a[i] = (short) pedestal;
173 size_t last_unstuck = i > 0 ? i - 1 : 0;
177 size_t next_unstuck = i;
178 unsigned short next_unstuck_sixlsbs;
179 unsigned short sixlsbs_stuck_in_a_row = 0;
186 rawadc_a[next_unstuck] = (short) pedestal;
189 next_unstuck_sixlsbs = rawadc_a[next_unstuck] &
onemask;
190 if(next_unstuck_sixlsbs==0 || next_unstuck_sixlsbs==onemask)
191 ++sixlsbs_stuck_in_a_row;
193 sixlsbs_stuck_in_a_row = 0;
196 while(next_unstuck_sixlsbs==onemask || next_unstuck_sixlsbs==0);
201 float interpolated_unstuck_value = 1.0*(rawadc_a[next_unstuck] - rawadc_a[last_unstuck])/(next_unstuck-last_unstuck)*(i-last_unstuck)+rawadc_a[last_unstuck];
202 rawadc_a[i] = (short) interpolated_unstuck_value;
211 digcol->push_back(rd);
float GetPedestal() const
void produce(art::Event &evt)
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
enum raw::_compress Compress_t
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
Collection of charge vs time digitized from a single readout channel.
void reconfigure(fhicl::ParameterSet const &p)
creation of calibrated signals on wires
Handle< PROD > getHandle(SelectorBase const &) const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
EDProducer(fhicl::ParameterSet const &pset)
ChannelID_t Channel() const
DAQ channel this raw data was read from.
std::string fDigitModuleLabel
constants
UnstickADCCodes(fhicl::ParameterSet const &pset)
const unsigned int onemask
Unsigned int ending in 111111 used to select 6 LSBs with bitwise AND.
art framework interface to geometry description
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
#define DEFINE_ART_MODULE(klass)
T get(std::string const &key) const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
void SetPedestal(float ped, float sigma=1.)
Set pedestal and its RMS (the latter is 0 by default)
unsigned int ChannelID_t
Type representing the ID of a readout channel.
unsigned int fStickyADCCodesLimit
Number of ADC codes to check for stickiness at 0x00 or 0x3f before stopping.
raw::Compress_t fCompression
compression type to use
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
float GetSigma() const
TODO RMS of the pedestal level?
virtual ~UnstickADCCodes()