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

#include <Roi2dToAdc.h>

Inheritance diagram for Roi2dToAdc:
TpcDataTool

Public Types

using Index = unsigned int
 

Public Member Functions

 Roi2dToAdc (fhicl::ParameterSet const &ps)
 
 ~Roi2dToAdc () override
 
DataMap updateTpcData (TpcData &tpd) const override
 

Private Attributes

int m_LogLevel
 

Additional Inherited Members

- Private Types inherited from AdcChannelTool
using Index = unsigned int
 
- Private Member Functions inherited from TpcDataTool
virtual DataMap viewTpcData (const TpcData &) const
 
virtual int forwardTpcData () const
 
- Private Member Functions inherited from AdcChannelTool
virtual ~AdcChannelTool ()=default
 
virtual DataMap update (AdcChannelData &) const
 
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)
 
- Static Private Member Functions inherited from AdcChannelTool
static int interfaceNotImplemented ()
 

Detailed Description

Definition at line 33 of file Roi2dToAdc.h.

Member Typedef Documentation

using Roi2dToAdc::Index = unsigned int

Definition at line 37 of file Roi2dToAdc.h.

Constructor & Destructor Documentation

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

Definition at line 19 of file Roi2dToAdc_tool.cc.

20 : m_LogLevel(ps.get<int>("LogLevel")) {
21  const string myname = "Roi2dToAdc::ctor: ";
22  // Display the configuration.
23  if ( m_LogLevel>= 1 ) {
24  cout << myname << " LogLevel: " << m_LogLevel << endl;
25  }
26 }
static constexpr double ps
Definition: Units.h:99
int m_LogLevel
Definition: Roi2dToAdc.h:49
QTextStream & endl(QTextStream &s)
Roi2dToAdc::~Roi2dToAdc ( )
override

Definition at line 30 of file Roi2dToAdc_tool.cc.

30 { }

Member Function Documentation

DataMap Roi2dToAdc::updateTpcData ( TpcData tpd) const
overridevirtual

Reimplemented from TpcDataTool.

Definition at line 34 of file Roi2dToAdc_tool.cc.

34  {
35  const string myname = "Roi2dToAdc::updateTpcData: ";
36  DataMap ret;
37  const float zero = 0.0;
38  Index nerr = 0;
39  Index nchaZeroed = 0;
40  Index nsamZeroed = 0;
41  if ( m_LogLevel >= 3 ) cout << myname << "ADC map count " << tpd.getAdcData().size() << endl;
42  // Zero the ADC samples, signal, ROIs and DFTs.
43  for ( TpcData::AdcDataPtr pacm : tpd.getAdcData() ) {
44  if ( ! pacm ) {
45  if ( m_LogLevel >= 4 ) cout << myname << " Skipping null map." << endl;
46  continue;
47  }
48  if ( m_LogLevel >= 4 ) cout << myname << " Processing map with channel count "
49  << pacm->size() << endl;
50  for ( auto& iacd : *(pacm) ) {
51  AdcChannelData& acd = iacd.second;
52  Index nsam = acd.samples.size();
53  if ( m_LogLevel >= 5 ) cout << myname << " Zeroing channel " << acd.channel()
54  << " with sample count " << nsam << endl;
55  std::fill(acd.samples.begin(), acd.samples.end(), zero);
56  nsamZeroed += nsam;
57  acd.signal.resize(nsam);
58  std::fill(acd.signal.begin(), acd.signal.end(), false);
59  acd.rois.clear();
60  acd.dftmags.clear();
61  acd.dftphases.clear();
62  ++nchaZeroed;
63  }
64  }
65  // Copy ROI samples to ADC.
66  if ( m_LogLevel >= 3 ) cout << myname << "ROI count " << tpd.get2dRois().size() << endl;
67  Index nchaFilled = 0;
68  Index nsamFilled = 0;
69  Index iroi = 0;
70  for ( const Tpc2dRoi& roi : tpd.get2dRois() ) {
71  if ( m_LogLevel >= 4 ) cout << myname << " Processing ROI " << iroi << " with "
72  << roi.channelSize() << " channels and "
73  << roi.sampleSize() << " samples." << endl;
74  Index nsamRoi = roi.sampleSize();
75  LongIndex ioffRoi = roi.sampleOffset();
76  IndexArray idxs;
77  Index& kcha = idxs[0];
78  Index& ksamRoi = idxs[1];
79  for ( kcha=0; kcha<roi.channelSize(); ++kcha ) {
80  Index icha = kcha + roi.channelOffset();
81  Index foundChannel = 0;
82  for ( TpcData::AdcDataPtr pacm : tpd.getAdcData() ) {
83  if ( pacm && pacm->count(icha) ) {
84  ++foundChannel = true;
85  AdcChannelData& acd = (*pacm)[icha];
86  Index nsamAdc = acd.samples.size();
87  if ( m_LogLevel >= 5 ) cout << myname << " Copying channel " << acd.channel()
88  << " from ROI sample count " << nsamRoi
89  << " to ADC sample count " << nsamAdc << endl;
90  LongIndex ioffAdc = acd.tickOffset();
91  bool agr = ioffAdc > ioffRoi;
92  Index isamAdc = agr ? 0 : Index(ioffRoi - ioffAdc);
93  ksamRoi = agr ? Index(ioffAdc - ioffRoi) : 0;
94  while ( ksamRoi < nsamRoi && isamAdc < nsamAdc ) {
95  acd.samples[isamAdc] = roi.data().value(idxs);
96  acd.signal[isamAdc] = true;
97  ++ksamRoi;
98  ++isamAdc;
99  ++nsamFilled;
100  } // End loop over copied samples
101  }
102  } // End loop over ADC channel maps
103  if ( foundChannel ) ++nchaFilled;
104  } // end loop over channels in the ROI
105  ++iroi;
106  } // end loop over ROIs
107  // Add ROI info.
108  for ( TpcData::AdcDataPtr pacm : tpd.getAdcData() ) {
109  if ( ! pacm ) continue;
110  for ( auto& iacd : *(pacm) ) {
111  AdcChannelData& acd = iacd.second;
112  if ( m_LogLevel >= 5 ) cout << myname << " Recording ROIs for channel " << acd.channel() << endl;
113  acd.roisFromSignal();
114  }
115  }
116  // Fill result.
117  ret.setStatus(nerr);
118  ret.setInt("r2a_nchaZeroed", nchaZeroed);
119  ret.setInt("r2a_nsamZeroed", nsamZeroed);
120  ret.setInt("r2a_nchaFilled", nchaFilled);
121  ret.setInt("r2a_nsamFilled", nsamFilled);
122  return ret;
123 }
unsigned long int LongIndex
DataMap & setStatus(int stat)
Definition: DataMap.h:130
std::shared_ptr< AdcChannelDataMap > AdcDataPtr
Definition: TpcData.h:35
DftData::IndexArray IndexArray
unsigned int Index
unsigned int Index
Definition: Roi2dToAdc.h:37
AdcDataVector & getAdcData()
Definition: TpcData.h:55
AdcRoiVector rois
AdcLongIndex tickOffset() const
void setInt(Name name, int val)
Definition: DataMap.h:131
AdcSignalVector dftphases
Channel channel() const
AdcFilterVector signal
def fill(s)
Definition: translator.py:93
int m_LogLevel
Definition: Roi2dToAdc.h:49
Tpc2dRoiVector & get2dRois()
Definition: TpcData.h:57
AdcSignalVector samples
AdcSignalVector dftmags
QTextStream & endl(QTextStream &s)

Member Data Documentation

int Roi2dToAdc::m_LogLevel
private

Definition at line 49 of file Roi2dToAdc.h.


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