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

#include <DuneRoiBuildingService.h>

Inheritance diagram for DuneRoiBuildingService:
AdcRoiBuildingService

Public Member Functions

 DuneRoiBuildingService (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 Attributes

int m_LogLevel
 
AdcSignal m_NSigmaStart
 
AdcSignal m_NSigmaEnd
 
AdcIndex m_PadLow
 
AdcIndex m_PadHigh
 

Detailed Description

Definition at line 39 of file DuneRoiBuildingService.h.

Constructor & Destructor Documentation

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

Definition at line 22 of file DuneRoiBuildingService_service.cc.

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

Member Function Documentation

int DuneRoiBuildingService::build ( AdcChannelData data) const
virtual

Implements AdcRoiBuildingService.

Definition at line 36 of file DuneRoiBuildingService_service.cc.

36  {
37  const string myname = "DuneRoiBuildingService:build: ";
38  if ( m_LogLevel >= 2 ) cout << myname << "Building ROIs for channel "
39  << data.channel() << "." << endl;
40  data.rois.clear();
41  // Get signal shaping service.
43  AdcSignal sigma = hsss->GetDeconNoise(data.channel());
44  if ( m_LogLevel >= 3 ) {
45  cout << myname << " Noise level: " << sigma << " " << data.sampleUnit << endl;
46  }
47  const AdcSignalVector& sigs = data.samples;
48  // Build ROIS before padding and merging.
49  AdcFilterVector& signal = data.signal;
50  AdcRoiVector& rois = data.rois;
51  signal.clear();
52  signal.resize(sigs.size(), false);
53  bool inroi = false;
54  AdcSignal siglow = m_NSigmaEnd*sigma;
55  AdcSignal sighigh = m_NSigmaStart*sigma;
56  AdcIndex nsig = sigs.size();
57  if ( nsig < 1 ) {
58  if ( m_LogLevel >= 2 ) cout << myname << "Channel " << data.channel()
59  << " has no samples." << endl;
60  return 0;
61  }
62  for ( AdcIndex isig=0; isig<sigs.size(); ++isig ) {
63  AdcSignal sig = sigs[isig];
64  if ( inroi ) {
65  if ( sig > siglow ) {
66  signal[isig] = true;
67  } else {
68  inroi = false;
69  }
70  } else {
71  if ( sig > sighigh ) {
72  signal[isig] = true;
73  inroi = true;
74  }
75  }
76  }
77  // Fill the unpadded ROIs.
78  data.roisFromSignal();
79  // Display ROIs before padding and merging.
80  if ( m_LogLevel >= 3 ) {
81  cout << myname << " ROIs before merge (size = " << rois.size() << "):" << endl;
82  for ( const AdcRoi& roi : rois ) {
83  cout << myname << setw(8) << roi.first << " " << setw(8) << roi.second << endl;
84  }
85  } else if ( m_LogLevel >= 2 ) {
86  cout << myname << " ROI count before merge: " << data.rois.size() << endl;
87  }
88  if ( rois.size() == 0 ) return 0;
89  // Pad ROIs.
90  unsigned int isig1 = 0;
91  unsigned int isig2 = 0;
92  for ( AdcRoi roi : rois ) {
93  isig2 = roi.first;
94  isig1 = isig2 > m_PadLow ? isig2 - m_PadLow : 0;
95  for ( unsigned int isig=isig1; isig<isig2; ++isig ) signal[isig] = true;
96  isig1 = roi.second + 1;
97  isig2 = isig1 + m_PadHigh;
98  if ( isig2 > nsig ) isig2 = nsig;
99  for ( unsigned int isig=isig1; isig<isig2; ++isig ) signal[isig] = true;
100  }
101  // Fill the final ROIs.
102  data.roisFromSignal();
103  // Display final ROIs.
104  if ( m_LogLevel >= 3 ) {
105  cout << myname << " ROIs after merge (size = " << rois.size() << "):" << endl;
106  for ( const AdcRoi& roi : rois ) {
107  cout << myname << setw(8) << roi.first << " " << setw(8) << roi.second << endl;
108  }
109  } else if ( m_LogLevel >= 2 ) {
110  cout << myname << " ROI count after merge: " << data.rois.size() << endl;
111  }
112  return 0;
113 }
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)
ostream & DuneRoiBuildingService::print ( std::ostream &  out = std::cout,
std::string  prefix = "" 
) const
virtual

Implements AdcRoiBuildingService.

Definition at line 118 of file DuneRoiBuildingService_service.cc.

118  {
119  out << prefix << "DuneRoiBuildingService:" << endl;
120  out << prefix << " LogLevel: " << m_LogLevel << endl;
121  out << prefix << " NSigmaStart: " << m_NSigmaStart << endl;
122  out << prefix << " NSigmaEnd: " << m_NSigmaEnd << endl;
123  out << prefix << " PadLow: " << m_PadLow << endl;
124  out << prefix << " PadHigh: " << m_PadHigh << endl;
125  return out;
126 }
QTextStream & endl(QTextStream &s)

Member Data Documentation

int DuneRoiBuildingService::m_LogLevel
private

Definition at line 52 of file DuneRoiBuildingService.h.

AdcSignal DuneRoiBuildingService::m_NSigmaEnd
private

Definition at line 54 of file DuneRoiBuildingService.h.

AdcSignal DuneRoiBuildingService::m_NSigmaStart
private

Definition at line 53 of file DuneRoiBuildingService.h.

AdcIndex DuneRoiBuildingService::m_PadHigh
private

Definition at line 56 of file DuneRoiBuildingService.h.

AdcIndex DuneRoiBuildingService::m_PadLow
private

Definition at line 55 of file DuneRoiBuildingService.h.


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