Public Member Functions | Private Member Functions | Private Attributes | List of all members
DuneDPhaseRoiBuildingService Class Reference

#include <DuneDPhaseRoiBuildingService.h>

Inheritance diagram for DuneDPhaseRoiBuildingService:
AdcRoiBuildingService

Public Member Functions

 DuneDPhaseRoiBuildingService (fhicl::ParameterSet const &pset, art::ActivityRegistry &)
 
int build (AdcChannelData &data) const
 
std::ostream & print (std::ostream &out=std::cout, std::string prefix="") const
 
- Public Member Functions inherited from AdcRoiBuildingService
virtual ~AdcRoiBuildingService ()=default
 

Private Member Functions

AdcSignalVector getLowFreqFiltered (const AdcSignalVector &adc) const
 

Private Attributes

bool m_UseFilter
 
std::vector< float > m_FltCoeffs
 
int m_LogLevel
 
AdcSignal m_NSigmaStart
 
AdcSignal m_NSigmaEnd
 
AdcIndex m_PadLow
 
AdcIndex m_PadHigh
 

Detailed Description

Definition at line 47 of file DuneDPhaseRoiBuildingService.h.

Constructor & Destructor Documentation

DuneDPhaseRoiBuildingService::DuneDPhaseRoiBuildingService ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry  
)

Definition at line 23 of file DuneDPhaseRoiBuildingService_service.cc.

23  :
24  m_UseFilter( pset.get<bool>("UseFilter") ),
25  m_FltCoeffs( pset.get<std::vector<float>>("FltCoeffs") ),
26  m_LogLevel(1)
27 {
28  const string myname = "DuneDPhaseRoiBuildingService::ctor: ";
29  pset.get_if_present<int>("LogLevel", m_LogLevel);
30  m_NSigmaStart = pset.get<AdcSignal>("NSigmaStart");
31  m_NSigmaEnd = pset.get<AdcSignal>("NSigmaEnd");
32  m_PadLow = pset.get<AdcSignal>("PadLow");
33  m_PadHigh = pset.get<AdcSignal>("PadHigh");
34  if ( m_LogLevel > 0 ) print(cout, myname);
35 }
float AdcSignal
Definition: AdcTypes.h:21
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const

Member Function Documentation

int DuneDPhaseRoiBuildingService::build ( AdcChannelData data) const
virtual

Implements AdcRoiBuildingService.

Definition at line 40 of file DuneDPhaseRoiBuildingService_service.cc.

40  {
41  const string myname = "DuneDPhaseRoiBuildingService:build: ";
42  if ( m_LogLevel >= 2 ) cout << myname << "Building ROIs for channel "
43  << data.channel() << "." << endl;
44  data.rois.clear();
45  // Get signal shaping service.
47  AdcSignal sigma = hsss->GetDeconNoise(data.channel());
48 
49  // Use filtered or raw ADC.
50  AdcSignalVector sigs;
51  if (m_UseFilter) { sigs = getLowFreqFiltered(data.samples); }
52  else { sigs = data.samples; }
53 
54  // Build ROIS before padding and merging.
55  AdcFilterVector& signal = data.signal;
56  AdcRoiVector& rois = data.rois;
57  signal.clear();
58  signal.resize(sigs.size(), false);
59  bool inroi = false;
60  AdcSignal siglow = m_NSigmaEnd*sigma;
61  AdcSignal sighigh = m_NSigmaStart*sigma;
62  AdcIndex nsig = sigs.size();
63  if ( nsig < 1 ) {
64  if ( m_LogLevel >= 2 ) cout << myname << "Channel " << data.channel()
65  << " has no samples." << endl;
66  return 0;
67  }
68  for ( AdcIndex isig=0; isig<sigs.size(); ++isig ) {
69  AdcSignal sig = sigs[isig];
70  if ( inroi ) {
71  if ( sig > siglow ) {
72  signal[isig] = true;
73  } else {
74  inroi = false;
75  }
76  } else {
77  if ( sig > sighigh ) {
78  signal[isig] = true;
79  inroi = true;
80  }
81  }
82  }
83  // Fill the unpadded ROIs.
84  data.roisFromSignal();
85  // Display ROIs before padding and merging.
86  if ( m_LogLevel >= 3 ) {
87  cout << myname << " ROIs before merge (size = " << rois.size() << "):" << endl;
88  for ( const AdcRoi& roi : rois ) {
89  cout << myname << setw(8) << roi.first << " " << setw(8) << roi.second << endl;
90  }
91  } else if ( m_LogLevel >= 2 ) {
92  cout << myname << " ROI count before merge: " << data.rois.size() << endl;
93  }
94  if ( rois.size() == 0 ) return 0;
95  // Pad ROIs.
96  unsigned int isig1 = 0;
97  unsigned int isig2 = 0;
98  for ( AdcRoi roi : rois ) {
99  isig2 = roi.first;
100  isig1 = isig2 > m_PadLow ? isig2 - m_PadLow : 0;
101  for ( unsigned int isig=isig1; isig<isig2; ++isig ) signal[isig] = true;
102  isig1 = roi.second + 1;
103  isig2 = isig1 + m_PadHigh;
104  if ( isig2 > nsig ) isig2 = nsig;
105  for ( unsigned int isig=isig1; isig<isig2; ++isig ) signal[isig] = true;
106  }
107  // Fill the final ROIs.
108  data.roisFromSignal();
109  // Display final ROIs.
110  if ( m_LogLevel >= 3 ) {
111  cout << myname << " ROIs after merge (size = " << rois.size() << "):" << endl;
112  for ( const AdcRoi& roi : rois ) {
113  cout << myname << setw(8) << roi.first << " " << setw(8) << roi.second << endl;
114  }
115  } else if ( m_LogLevel >= 2 ) {
116  cout << myname << " ROI count after merge: " << data.rois.size() << endl;
117  }
118  return 0;
119 }
AdcSignalVector getLowFreqFiltered(const AdcSignalVector &adc) const
float AdcSignal
Definition: AdcTypes.h:21
std::pair< AdcIndex, AdcIndex > AdcRoi
Definition: AdcTypes.h:54
double GetDeconNoise(Channel channel) const override
AdcRoiVector rois
unsigned int AdcIndex
Definition: AdcTypes.h:15
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
std::vector< AdcRoi > AdcRoiVector
Definition: AdcTypes.h:55
Channel channel() const
AdcFilterVector signal
std::vector< bool > AdcFilterVector
Definition: AdcTypes.h:27
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
AdcSignalVector samples
QTextStream & endl(QTextStream &s)
AdcSignalVector DuneDPhaseRoiBuildingService::getLowFreqFiltered ( const AdcSignalVector adc) const
private

Definition at line 123 of file DuneDPhaseRoiBuildingService_service.cc.

124 {
126  std::vector< TComplex > ch_spectrum(fft->FFTSize() / 2 + 1);
127  std::vector< float > ch_waveform(fft->FFTSize(), 0);
128 
129  size_t n_samples = adc.size();
130 
131  std::copy(adc.begin(), adc.end(), ch_waveform.begin());
132  for (size_t s = n_samples; s < ch_waveform.size(); ++s)
133  {
134  ch_waveform[s] = ch_waveform[s-1];
135  }
136  fft->DoFFT(ch_waveform, ch_spectrum);
137  for (size_t c = 0; c < m_FltCoeffs.size(); ++c)
138  {
139  ch_spectrum[c] *= m_FltCoeffs[c];
140  }
141  fft->DoInvFFT(ch_spectrum, ch_waveform);
142 
143  AdcSignalVector flt_out(n_samples);
144  std::copy(ch_waveform.begin(), ch_waveform.begin()+n_samples, flt_out.begin());
145  return flt_out;
146 }
int16_t adc
Definition: CRTFragment.hh:202
void DoFFT(std::vector< T > &input, std::vector< TComplex > &output)
Definition: LArFFT.h:98
uint size() const
Definition: qcstring.h:201
void DoInvFFT(std::vector< TComplex > &input, std::vector< T > &output)
Definition: LArFFT.h:120
int FFTSize() const
Definition: LArFFT.h:69
T copy(T const &v)
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
static QCString * s
Definition: config.cpp:1042
ostream & DuneDPhaseRoiBuildingService::print ( std::ostream &  out = std::cout,
std::string  prefix = "" 
) const
virtual

Implements AdcRoiBuildingService.

Definition at line 150 of file DuneDPhaseRoiBuildingService_service.cc.

150  {
151  out << prefix << "DuneDPhaseRoiBuildingService:" << endl;
152  out << prefix << " LogLevel: " << m_LogLevel << endl;
153  out << prefix << " NSigmaStart: " << m_NSigmaStart << endl;
154  out << prefix << " NSigmaEnd: " << m_NSigmaEnd << endl;
155  out << prefix << " PadLow: " << m_PadLow << endl;
156  out << prefix << " PadHigh: " << m_PadHigh << endl;
157  out << prefix << " UseFilter: " << m_UseFilter << endl;
158  return out;
159 }
QTextStream & endl(QTextStream &s)

Member Data Documentation

std::vector< float > DuneDPhaseRoiBuildingService::m_FltCoeffs
private

Definition at line 62 of file DuneDPhaseRoiBuildingService.h.

int DuneDPhaseRoiBuildingService::m_LogLevel
private

Definition at line 64 of file DuneDPhaseRoiBuildingService.h.

AdcSignal DuneDPhaseRoiBuildingService::m_NSigmaEnd
private

Definition at line 66 of file DuneDPhaseRoiBuildingService.h.

AdcSignal DuneDPhaseRoiBuildingService::m_NSigmaStart
private

Definition at line 65 of file DuneDPhaseRoiBuildingService.h.

AdcIndex DuneDPhaseRoiBuildingService::m_PadHigh
private

Definition at line 68 of file DuneDPhaseRoiBuildingService.h.

AdcIndex DuneDPhaseRoiBuildingService::m_PadLow
private

Definition at line 67 of file DuneDPhaseRoiBuildingService.h.

bool DuneDPhaseRoiBuildingService::m_UseFilter
private

Definition at line 61 of file DuneDPhaseRoiBuildingService.h.


The documentation for this class was generated from the following files: