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

#include <DuneAdcSignalFinder.h>

Inheritance diagram for DuneAdcSignalFinder:
TpcDataTool AdcChannelTool

Public Member Functions

 DuneAdcSignalFinder (fhicl::ParameterSet const &ps)
 
DataMap view (const AdcChannelData &acd) const override
 
DataMap update (AdcChannelData &acd) const override
 
- Public Member Functions inherited from TpcDataTool
virtual DataMap updateTpcData (TpcData &) const
 
virtual DataMap viewTpcData (const TpcData &) const
 
virtual int forwardTpcData () const
 
- Public Member Functions inherited from AdcChannelTool
virtual ~AdcChannelTool ()=default
 
virtual DataMap updateMap (AdcChannelDataMap &acds) const
 
virtual DataMap viewMap (const AdcChannelDataMap &acds) const
 
virtual bool updateWithView () const
 
virtual bool viewWithUpdate () const
 
virtual DataMap beginEvent (const DuneEventInfo &) const
 
virtual DataMap endEvent (const DuneEventInfo &) const
 
virtual DataMap close (const DataMap *dmin=nullptr)
 

Private Types

using Name = std::string
 

Private Attributes

int m_LogLevel
 
AdcSignal m_NoiseSigma
 
AdcSignal m_NSigmaStart
 
AdcSignal m_NSigmaEnd
 
AdcIndex m_TicksBefore
 
AdcIndex m_TicksAfter
 

Additional Inherited Members

- Public Types inherited from AdcChannelTool
using Index = unsigned int
 
- Static Public Member Functions inherited from AdcChannelTool
static int interfaceNotImplemented ()
 

Detailed Description

Definition at line 33 of file DuneAdcSignalFinder.h.

Member Typedef Documentation

Definition at line 46 of file DuneAdcSignalFinder.h.

Constructor & Destructor Documentation

DuneAdcSignalFinder::DuneAdcSignalFinder ( fhicl::ParameterSet const &  ps)

Definition at line 16 of file DuneAdcSignalFinder_tool.cc.

17 : m_LogLevel(ps.get<int>("LogLevel")),
18  m_NoiseSigma(ps.get<float>("NoiseSigma")),
19  m_NSigmaStart(ps.get<float>("NSigmaStart")),
20  m_NSigmaEnd(ps.get<float>("NSigmaEnd")),
21  m_TicksBefore(ps.get<AdcIndex>("TicksBefore")),
22  m_TicksAfter(ps.get<AdcIndex>("TicksAfter"))
23 {
24  const string myname = "DuneAdcSignalFinder::ctor: ";
25  if ( m_LogLevel >= 1 ) {
26  cout << myname << "Configuration parameters:" << endl;
27  cout << myname << " LogLevel: " << m_LogLevel << endl;
28  cout << myname << " NoiseSigma: " << m_NoiseSigma << endl;
29  cout << myname << " NSigmaStart: " << m_NSigmaStart << endl;
30  cout << myname << " NSigmaEnd: " << m_NSigmaEnd << endl;
31  cout << myname << " TicksBefore: " << m_TicksBefore << endl;
32  cout << myname << " TicksAfter: " << m_TicksAfter << endl;
33  }
34 }
static constexpr double ps
Definition: Units.h:99
unsigned int AdcIndex
Definition: AdcTypes.h:15
QTextStream & endl(QTextStream &s)

Member Function Documentation

DataMap DuneAdcSignalFinder::update ( AdcChannelData acd) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 38 of file DuneAdcSignalFinder_tool.cc.

38  {
39  const string myname = "DuneAdcSignalFinder::update: ";
40  DataMap ret;
41  if ( m_LogLevel >= 2 ) {
42  cout << myname << "Finding ROIs for channel " << acd.channel() << endl;
43  }
44  AdcIndex nsam = acd.samples.size();
45  if ( nsam == 0 ) {
46  cout << myname << "ERROR: No samples found in channel " << acd.channel() << endl;
47  acd.signal.clear();
48  acd.rois.clear();
49  return ret.setStatus(1);
50  }
51  AdcSignal sigma = m_NoiseSigma > 0 ? m_NoiseSigma : acd.sampleNoise;
52  if ( sigma <= 0 ) {
53  cout << myname << "ERROR: Unable to determine noise level." << endl;
54  return ret.setStatus(2);
55  }
56  if ( m_LogLevel >= 3 ) cout << myname << "Noise level: " << sigma << endl;
57  // Build ROIS before padding and merging.
58  const AdcSignalVector& sams = acd.samples;
59  AdcFilterVector& signal = acd.signal;
60  AdcRoiVector& rois = acd.rois;
61  signal.clear();
62  signal.resize(sams.size(), false);
63  bool inroi = false;
64  AdcSignal siglow = m_NSigmaEnd*sigma;
65  AdcSignal sighigh = m_NSigmaStart*sigma;
66  for ( AdcIndex isam=0; isam<nsam; ++isam ) {
67  AdcSignal sig = sams[isam];
68  if ( inroi ) {
69  if ( sig > siglow ) {
70  signal[isam] = true;
71  } else {
72  inroi = false;
73  }
74  } else {
75  if ( sig > sighigh ) {
76  signal[isam] = true;
77  inroi = true;
78  }
79  }
80  }
81  // Fill the unpadded ROIs.
82  acd.roisFromSignal();
83  if ( rois.size() == 0 ) {
84  if ( m_LogLevel >= 3 ) cout << myname << " No ROIs found." << endl;
85  } else {
86  // Display ROIs before padding and merging.
87  if ( m_LogLevel >= 3 ) {
88  cout << myname << " ROIs before merge (size = " << rois.size() << "):" << endl;
89  for ( const AdcRoi& roi : rois ) {
90  cout << myname << setw(8) << roi.first << " " << setw(8) << roi.second << endl;
91  }
92  } else if ( m_LogLevel >= 2 ) {
93  cout << myname << " ROI count before merge: " << acd.rois.size() << endl;
94  }
95  // Pad ROIs.
96  unsigned int isam1 = 0;
97  unsigned int isam2 = 0;
98  for ( AdcRoi roi : rois ) {
99  isam2 = roi.first;
100  isam1 = isam2 > m_TicksBefore ? isam2 - m_TicksBefore : 0;
101  for ( unsigned int isam=isam1; isam<isam2; ++isam ) signal[isam] = true;
102  isam1 = roi.second + 1;
103  isam2 = isam1 + m_TicksAfter;
104  if ( isam2 > nsam ) isam2 = nsam;
105  for ( unsigned int isam=isam1; isam<isam2; ++isam ) signal[isam] = true;
106  }
107  // Fill the final ROIs.
108  acd.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: " << acd.rois.size() << endl;
117  }
118  }
119  ret.setInt("nroi", acd.rois.size());
120  return ret;
121 }
DataMap & setStatus(int stat)
Definition: DataMap.h:130
float AdcSignal
Definition: AdcTypes.h:21
std::pair< AdcIndex, AdcIndex > AdcRoi
Definition: AdcTypes.h:54
AdcSignal sampleNoise
AdcRoiVector rois
void setInt(Name name, int val)
Definition: DataMap.h:131
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)
DataMap DuneAdcSignalFinder::view ( const AdcChannelData acd) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 125 of file DuneAdcSignalFinder_tool.cc.

125  {
126  AdcChannelData acdtmp;
127  acdtmp.samples = acd.samples;
128  return update(acdtmp);
129 }
AdcSignalVector samples
DataMap update(AdcChannelData &acd) const override

Member Data Documentation

int DuneAdcSignalFinder::m_LogLevel
private

Definition at line 49 of file DuneAdcSignalFinder.h.

AdcSignal DuneAdcSignalFinder::m_NoiseSigma
private

Definition at line 50 of file DuneAdcSignalFinder.h.

AdcSignal DuneAdcSignalFinder::m_NSigmaEnd
private

Definition at line 52 of file DuneAdcSignalFinder.h.

AdcSignal DuneAdcSignalFinder::m_NSigmaStart
private

Definition at line 51 of file DuneAdcSignalFinder.h.

AdcIndex DuneAdcSignalFinder::m_TicksAfter
private

Definition at line 54 of file DuneAdcSignalFinder.h.

AdcIndex DuneAdcSignalFinder::m_TicksBefore
private

Definition at line 53 of file DuneAdcSignalFinder.h.


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