160 const string myname =
"CalWireDUNE10kt::produce: ";
167 int transformSize = fFFT->
FFTSize();
168 if (
fLogLevel >= 2 ) cout << myname <<
"FFT size: " << transformSize <<
endl;
179 pchanmap = &*hchanmap;
182 if ( pcsp ==
nullptr ) {
183 cout << myname <<
"ERROR: Channel status service not found." <<
endl;
189 std::unique_ptr<std::vector<recob::Wire> > wirecol(
new std::vector<recob::Wire>);
191 std::unique_ptr<art::Assns<raw::RawDigit,recob::Wire> > WireDigitAssn
196 auto digitVecHandle = evt.
getHandle< std::vector<raw::RawDigit> >(itag1);
198 if (!digitVecHandle->size())
return;
199 mf::LogInfo(
"CalWireDUNE10kt") <<
"CalWireDUNE10kt:: digitVecHandle size is " << digitVecHandle->size();
204 unsigned int dataSize = digitVec0->Samples();
205 if (
fLogLevel >= 2 ) cout << myname <<
"Expected raw data size: " << dataSize <<
endl;
209 int readoutwindowsize = detProp.ReadOutWindowSize();
210 if (
int(dataSize) != readoutwindowsize){
212 <<
"ReadOutWindowSize "<<readoutwindowsize<<
" does not match data size "<<dataSize<<
". Please set services.DetectorPropertiesService.NumberTimeSamples and services.DetectorPropertiesService.ReadOutWindowSize in fcl file to "<<dataSize;
218 std::vector<float> holder;
219 std::vector<short> rawadc(transformSize);
220 std::vector<TComplex> freqHolder(transformSize+1);
223 wirecol->reserve(digitVecHandle->size());
226 for (
size_t rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter ) {
231 channel = digitVec->Channel();
232 unsigned int onlineChannel =
channel;
233 if ( pchanmap !=
nullptr ) onlineChannel = pchanmap->
online(channel);
237 if (
fLogLevel >= 2 ) cout << myname <<
"Skipping bad channel " << channel <<
endl;
240 holder.resize(transformSize);
243 raw::Uncompress(digitVec->ADCs(), rawadc, digitVec->GetPedestal(), digitVec->Compression());
244 for (
unsigned int ibin=0; ibin<rawadc.size(); ++ibin ) rawadc[ibin] -= digitVec->GetPedestal();
246 cout << myname <<
"Processing channel " << channel <<
endl;
247 if (
fLogLevel == 2 ) cout << myname <<
" Uncompressed raw data size: " << rawadc.size() <<
endl;
249 cout <<
" Raw data vector has " << rawadc.size() <<
" entries." <<
endl;
250 for (
unsigned int ibin=0; ibin<rawadc.size(); ++ibin ) {
251 cout <<
setw(8) << ibin <<
": " << rawadc[ibin] <<
endl;
259 for (
bin=dataSize;
bin<holder.size(); ++
bin) holder[
bin] = holder[
bin-dataSize];
263 for (
bin = 0;
bin < holder.size(); ++
bin) holder[
bin]=holder[
bin]/DeconNorm;
266 holder.resize(dataSize,1
e-5);
273 for (
bin = 0;
bin < holder.size(); ++
bin ) holder[
bin]-=average;
281 std::vector<std::pair<unsigned int, unsigned int>> holderInfo;
282 std::vector<std::pair<unsigned int, unsigned int>> rois;
287 unsigned int roiStart = 0;
289 double SigVal = holder[
bin];
290 if (SigVal > max) max = SigVal;
294 if (SigVal < deconNoise){
295 rois.push_back(std::make_pair(roiStart,
bin));
301 rois.push_back(std::make_pair(roiStart, dataSize-1));
314 if ( rois.size() == 0 )
continue;
316 for(
unsigned int ii = 0; ii<rois.size(); ++ii ) {
320 rois[ii].first = low;
323 if(high >= dataSize) high = dataSize-1;
324 rois[ii].second = high;
327 if ( rois.size() >= 1 ) {
330 for (
unsigned int ii = 0; ii<rois.size(); ++ii ) {
331 unsigned int roiStart = rois[ii].first;
332 unsigned int roiEnd = rois[ii].second;
334 unsigned int jj=ii+1;
336 if ( jj<rois.size() ) {
337 if( rois[jj].first <= roiEnd ) {
338 roiEnd = rois[jj].second;
348 std::vector<float> sigTemp;
349 for(
unsigned int kk = roiStart; kk < roiEnd; ++kk) {
350 sigTemp.push_back(holder[kk]);
376 <<
"Can't associate wire #" << (wirecol->size() - 1)
377 <<
" with raw digit #" << digitVec.key();
381 if ( wirecol->size() == 0 )
382 mf::LogWarning(
"CalWireDUNE10kt") <<
"No wires made for this event.";
virtual bool IsBad(raw::ChannelID_t channel) const =0
Returns whether the specified channel is bad in the current run.
void Deconvolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
Handle< PROD > getHandle(SelectorBase const &) const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fDoBaselineSub
number of postsample bins
const datarange_t & add_range(size_type offset, ITER first, ITER last)
Adds a sequence of elements as a range with specified offset.
Class managing the creation of a new recob::Wire object.
void SubtractBaseline(std::vector< float > &holder)
double GetDeconNoise(Channel channel) const override
unsigned short fPreROIPad
ROI padding.
int fLogLevel
Log level: 0=none, 1=init.
std::string fDigitModuleLabel
constants
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
bool fSkipBadChannels
Skip bad channels.
Class providing information about the quality of channels.
static int max(int a, int b)
Q_EXPORT QTSManip setw(int w)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
int fPostsampleBins
number of postsample bins
QTextStream & bin(QTextStream &s)
ChannelStatusProvider const * GetProviderPtr() const
Returns a pointer to the service provider.
unsigned short fPostROIPad
ROI padding.
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.
double fSigThrFact
Signal shreshold factor.
double GetDeconNorm() const override
QTextStream & endl(QTextStream &s)
virtual Channel online(Channel offlineChannel) const =0