23 #include "cetlib_except/exception.h" 101 produces< std::vector<recob::Wire> >(
fSpillName);
102 produces<art::Assns<raw::RawDigit, recob::Wire>>(
fSpillName);
112 const string myname =
"CalWireDUNE10kt::reconfigure: ";
113 std::vector<unsigned short> uin; std::vector<unsigned short> vin;
114 std::vector<unsigned short> zin;
119 uin = pset.
get<std::vector<unsigned short>>(
"PlaneROIPad");
131 if( pos!=std::string::npos ) {
136 if ( fLogLevel >= 1 ) {
138 cout << myname <<
" PostsampleBins: " << fPostsampleBins <<
endl;
139 cout << myname <<
" DoBaselineSub: " << fDoBaselineSub <<
endl;
140 cout << myname <<
" PlaneROIPad[0]: " << fPreROIPad <<
endl;
142 cout << myname <<
" SigThrFact: " << fSigThrFact <<
endl;
144 cout << myname <<
" LogLevel: " << fLogLevel <<
endl;
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 ) {
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);
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;
257 for ( bin=0; bin<dataSize; ++
bin ) holder[bin] = rawadc[bin];
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;
288 for ( bin = 0; bin < dataSize; ++
bin ) {
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.";
395 for (
unsigned int bin = 0;
bin < holder.size();
bin++){
397 if (holder[
bin] < min) min = holder[
bin];
401 TH1F *
h1 =
new TH1F(
"h1",
"h1",nbin,min,
max);
402 for (
unsigned int bin = 0;
bin < holder.size();
bin++){
403 h1->Fill(holder[
bin]);
405 float ped = h1->GetMaximum();
406 float ave=0,ncount = 0;
407 for (
unsigned int bin = 0;
bin < holder.size();
bin++){
408 if (fabs(holder[
bin]-ped)<2){
413 if (ncount==0) ncount=1;
415 for (
unsigned int bin = 0;
bin < holder.size();
bin++){
virtual bool IsBad(raw::ChannelID_t channel) const =0
Returns whether the specified channel is bad in the current run.
float GetPedestal() const
void Deconvolute(detinfo::DetectorClocksData const &clockData, Channel channel, std::vector< T > &func) const
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
virtual ~CalWireDUNE10kt()
void reconfigure(fhicl::ParameterSet const &p)
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
Handle< PROD > getHandle(SelectorBase const &) const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
int fDoBaselineSub
number of postsample bins
Helper functions to create a wire.
EDProducer(fhicl::ParameterSet const &pset)
ChannelID_t Channel() const
DAQ channel this raw data was read from.
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
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
creation of calibrated signals on wires
unsigned short fPreROIPad
ROI padding.
art framework interface to geometry description
int fLogLevel
Log level: 0=none, 1=init.
std::string fDigitModuleLabel
constants
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
#define DEFINE_ART_MODULE(klass)
key_type key() const noexcept
T get(std::string const &key) const
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)
raw::Compress_t Compression() const
Compression algorithm used to store the ADC counts.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
void produce(art::Event &evt)
std::optional< T > get_if_present(std::string const &key) const
int fPostsampleBins
number of postsample bins
QTextStream & bin(QTextStream &s)
Declaration of basic channel signal object.
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.
Interface for experiment-specific service for channel quality info.
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
CalWireDUNE10kt(fhicl::ParameterSet const &pset)
QTextStream & endl(QTextStream &s)
Service providing information about the quality of channels.
virtual Channel online(Channel offlineChannel) const =0