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){
148 channel = digitVec->Channel();
150 float pedestal = digitVec->GetPedestal();
153 int pedestal_value = (
int) digitVec->GetPedestal();
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;
210 rd.SetPedestal( digitVec->GetPedestal(), digitVec->GetSigma() );
211 digcol->push_back(rd);
Collection of charge vs time digitized from a single readout channel.
Handle< PROD > getHandle(SelectorBase const &) const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::string fDigitModuleLabel
constants
const unsigned int onemask
Unsigned int ending in 111111 used to select 6 LSBs with bitwise AND.
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
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.