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

#include <AdcRoiSlicer.h>

Inheritance diagram for AdcRoiSlicer:
TpcDataTool AdcChannelTool

Public Types

using Name = std::string
 
- Public Types inherited from AdcChannelTool
using Index = unsigned int
 

Public Member Functions

 AdcRoiSlicer (fhicl::ParameterSet const &ps)
 
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 view (const AdcChannelData &acd) const
 
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 Attributes

int m_LogLevel
 
Name m_OutViewName
 
int m_SliceOpt
 
bool m_CopyRaw
 

Additional Inherited Members

- Static Public Member Functions inherited from AdcChannelTool
static int interfaceNotImplemented ()
 

Detailed Description

Definition at line 21 of file AdcRoiSlicer.h.

Member Typedef Documentation

Definition at line 26 of file AdcRoiSlicer.h.

Constructor & Destructor Documentation

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

Definition at line 15 of file AdcRoiSlicer_tool.cc.

16 : m_LogLevel(ps.get<int>("LogLevel")),
17  m_OutViewName(ps.get<Name>("OutViewName")),
18  m_SliceOpt(ps.get<int>("SliceOpt")),
19  m_CopyRaw(ps.get<bool>("CopyRaw")) {
20  const Name myname = "AdcRoiSlicer::ctor: ";
21  if ( m_LogLevel >= 1 ) {
22  cout << myname << "Configuration parameters:" << endl;
23  cout << myname << " LogLevel: " << m_LogLevel << endl;
24  cout << myname << " OutViewName: " << m_OutViewName << endl;
25  cout << myname << " SliceOpt: " << m_SliceOpt << endl;
26  cout << myname << " CopyRaw: " << (m_CopyRaw ? "true" : "false") << endl;
27  }
28 }
ChannelGroupService::Name Name
Name m_OutViewName
Definition: AdcRoiSlicer.h:36
static constexpr double ps
Definition: Units.h:99
QTextStream & endl(QTextStream &s)

Member Function Documentation

DataMap AdcRoiSlicer::update ( AdcChannelData acd) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 32 of file AdcRoiSlicer_tool.cc.

32  {
33  const Name myname = "AdcRoiSlicer::update: ";
34  DataMap ret;
35  bool keepRoi = m_SliceOpt == 1 || m_SliceOpt == 3;
36  bool keepNot = m_SliceOpt == 2 || m_SliceOpt == 3;
37  bool copyRaw = m_CopyRaw;
38  if ( ! keepRoi && ! keepNot ) {
39  cout << "ERROR: Invalid slice option: " << m_SliceOpt << endl;
40  return ret.setStatus(1);
41  }
42  Index nsam = acd.samples.size();
43  if ( acd.signal.size() != nsam ) {
44  cout << "ERROR: Signal size does not match samples: " << acd.signal.size()
45  << " != " << nsam << endl;
46  return ret.setStatus(2);
47  }
48  if ( acd.hasView(m_OutViewName) ) {
49  cout << "ERROR: Data for channel " << acd.channel() << " already has view " << m_OutViewName << endl;
50  return ret.setStatus(3);
51  }
52  if ( copyRaw && acd.raw.size() < nsam ) {
53  cout << "ERROR: Insufficient raw data for channel " << acd.channel() << ": "
54  << acd.raw.size() << " < " << nsam << "." << endl;
55  copyRaw = false;
56  }
58  Index nsamKeep = 0;
59  Index nsamSkip = 0;
60  if ( m_LogLevel >= 3 ) {
61  cout << myname << "Looping over " << nsam << " samples for channel "
62  << acd.channel() << endl;
63  }
64  for ( Index isam=0; isam<nsam; ++isam ) {
65  bool isRoi = acd.signal[isam];
66  bool keep = (isRoi && keepRoi) || (!isRoi && keepNot);
67  bool changeRoi = isam==0 || acd.signal[isam] != acd.signal[isam-1];
68  bool startData = keep && changeRoi;
69  if ( startData ) {
70  if ( m_LogLevel >= 3 ) cout << myname << "Creating data view at tick " << isam << endl;
71  view.push_back(acd);
72  AdcChannelData& acdout = view.back();
73  acdout.viewParent = &acd;
74  acdout.tick0 = isam;
75  }
76  if ( keep ) {
77  AdcChannelData& acdout = view.back();
78  if ( copyRaw ) acdout.raw.push_back(acd.raw[isam]);
79  acdout.samples.push_back(acd.samples[isam]);
80  acdout.signal.push_back(acd.signal[isam]);
81  ++nsamKeep;
82  } else {
83  ++nsamSkip;
84  }
85  }
86  if ( m_LogLevel >= 2 ) {
87  cout << myname << "End of update. Nview=" << view.size()
88  << ". # sample keep/skip/tot: " << nsamKeep << "/" << nsamSkip
89  << "/" << nsam << endl;
90  }
91  ret.setInt("nRoiView", view.size());
92  return ret;
93 }
std::vector< AdcChannelData > View
DataMap & setStatus(int stat)
Definition: DataMap.h:130
ChannelGroupService::Name Name
unsigned int Index
virtual DataMap view(const AdcChannelData &acd) const
Name m_OutViewName
Definition: AdcRoiSlicer.h:36
AdcChannelData * viewParent
void setInt(Name name, int val)
Definition: DataMap.h:131
AdcCountVector raw
Channel channel() const
AdcFilterVector signal
View & updateView(Name vnam)
bool hasView(Name vnam) const
AdcSignalVector samples
QTextStream & endl(QTextStream &s)

Member Data Documentation

bool AdcRoiSlicer::m_CopyRaw
private

Definition at line 38 of file AdcRoiSlicer.h.

int AdcRoiSlicer::m_LogLevel
private

Definition at line 35 of file AdcRoiSlicer.h.

Name AdcRoiSlicer::m_OutViewName
private

Definition at line 36 of file AdcRoiSlicer.h.

int AdcRoiSlicer::m_SliceOpt
private

Definition at line 37 of file AdcRoiSlicer.h.


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