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

#include <AdcDataDumper.h>

Inheritance diagram for AdcDataDumper:
TpcDataTool

Public Member Functions

 AdcDataDumper (fhicl::ParameterSet const &ps)
 
 ~AdcDataDumper () override
 
DataMap viewMap (const AdcChannelDataMap &acds) const override
 
bool updateWithView () const override
 

Private Attributes

std::string m_FileName
 
std::string m_Prefix
 
bool m_NewFile
 
bool m_ShowChannelCount
 
bool m_ShowTickCounts
 
bool m_ShowRaw
 
bool m_ShowPrepared
 
unsigned int m_ShowFirst
 
unsigned int m_ShowRebin
 
unsigned int m_ShowMax
 
float m_ShowThreshold
 
unsigned int m_ShowOpt
 
std::ostream * m_pout
 

Additional Inherited Members

- Private Types inherited from AdcChannelTool
using Index = unsigned int
 
- Private Member Functions inherited from TpcDataTool
virtual DataMap updateTpcData (TpcData &) const
 
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 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 37 of file AdcDataDumper.h.

Constructor & Destructor Documentation

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

Definition at line 90 of file AdcDataDumper_tool.cc.

91 : m_FileName(ps.get<string>("FileName")),
92  m_Prefix(ps.get<string>("Prefix")),
93  m_NewFile(ps.get<bool>("NewFile")),
94  m_ShowChannelCount(ps.get<bool>("ShowChannelCount")),
95  m_ShowTickCounts(ps.get<bool>("ShowTickCounts")),
96  m_ShowRaw(ps.get<bool>("ShowRaw")),
97  m_ShowPrepared(ps.get<bool>("ShowPrepared")),
98  m_ShowFirst(ps.get<unsigned int>("ShowFirst")),
99  m_ShowRebin(ps.get<unsigned int>("ShowRebin")),
100  m_ShowMax(ps.get<unsigned int>("ShowMax")),
101  m_ShowThreshold(ps.get<float>("ShowThreshold")),
102  m_ShowOpt(ps.get<unsigned int>("ShowOpt")),
103  m_pout(nullptr) {
104  if ( m_FileName.size() == 0 ) m_pout = &cout;
105  else if ( ! m_NewFile ) m_pout = new ofstream(m_FileName.c_str());
106 }
bool m_ShowChannelCount
Definition: AdcDataDumper.h:54
unsigned int m_ShowRebin
Definition: AdcDataDumper.h:59
unsigned int m_ShowFirst
Definition: AdcDataDumper.h:58
std::string m_Prefix
Definition: AdcDataDumper.h:52
std::ostream * m_pout
Definition: AdcDataDumper.h:65
static constexpr double ps
Definition: Units.h:99
std::string m_FileName
Definition: AdcDataDumper.h:51
unsigned int m_ShowMax
Definition: AdcDataDumper.h:60
unsigned int m_ShowOpt
Definition: AdcDataDumper.h:62
bool m_ShowTickCounts
Definition: AdcDataDumper.h:55
float m_ShowThreshold
Definition: AdcDataDumper.h:61
AdcDataDumper::~AdcDataDumper ( )
override

Definition at line 110 of file AdcDataDumper_tool.cc.

110  {
111  if ( m_pout != nullptr && m_pout != &cout ) {
112  delete m_pout;
113  m_pout = nullptr;
114  }
115 }
std::ostream * m_pout
Definition: AdcDataDumper.h:65

Member Function Documentation

bool AdcDataDumper::updateWithView ( ) const
inlineoverridevirtual

Reimplemented from AdcChannelTool.

Definition at line 46 of file AdcDataDumper.h.

46 { return true; }
DataMap AdcDataDumper::viewMap ( const AdcChannelDataMap acds) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 119 of file AdcDataDumper_tool.cc.

119  {
120  DataMap ret;
121  ostream* pout = m_pout;
122  bool newfile = pout == nullptr;
123  // If file is not already set, build the file name and open it.
124  if ( newfile ) {
125  if ( ! m_NewFile ) return ret.setStatus(1);
126  string fname = m_FileName;
127  string::size_type npos = string::npos;
128  string::size_type ipos = fname.find("%PAT%");
129  ipos = fname.find("%CHAN1%");
130  if ( ipos != npos ) {
131  string srep = "NOCHAN";
132  if ( acds.size() ) {
133  ostringstream ssrep;
134  ssrep << acds.begin()->first;
135  srep = ssrep.str();
136  }
137  while ( ipos != npos ) {
138  fname.replace(ipos, 7, srep);
139  ipos = fname.find("%CHAN1%", ipos+7);
140  }
141  }
142  ipos = fname.find("%CHAN2%");
143  if ( ipos != npos ) {
144  string srep = "NOCHAN";
145  if ( acds.size() ) {
146  ostringstream ssrep;
147  ssrep << acds.rbegin()->first;
148  string srep = ssrep.str();
149  while ( ipos != npos ) {
150  fname.replace(ipos, 7, srep);
151  ipos = fname.find("%CHAN2%", ipos+7);
152  }
153  }
154  }
155  pout = new ofstream(fname.c_str());
156  }
157  if ( pout == nullptr ) return ret.setStatus(2);
158  ostream& out = *pout;
159  string pre = m_Prefix + ":";
160  if ( m_ShowChannelCount ) out << pre << " Channel count: " << acds.size() << endl;
161  Index wcha = 6;
162  Index wcou = 0;
163  if ( m_ShowRaw || m_ShowPrepared ) {
164  out << pre << " Values are displayed starting at tick " << m_ShowFirst;
165  if ( m_ShowRebin > 1 ) out << " with rebinning of " << m_ShowRebin;
166  else out << " without rebinning";
167  out << endl;
168  }
169  for ( const AdcChannelDataMap::value_type& iacd : acds ) {
170  const AdcChannelData& acd = iacd.second;
171  ostringstream sschanpre;
172  sschanpre << pre << setw(wcha) << acd.channel() << ":";
173  string chanpre = sschanpre.str();
174  sschanpre.str("");
175  sschanpre << pre << setw(wcha+1) << " ";
176  string nochanpre = sschanpre.str();
177  if ( m_ShowTickCounts ) {
178  out << chanpre;
179  out << " nraw=" << setw(wcou) << acd.raw.size();
180  out << " nsam=" << setw(wcou) << acd.samples.size();
181  out << " nflg=" << setw(wcou) << acd.flags.size();
182  out << " nsig=" << setw(wcou) << acd.signal.size();
183  out << " nroi=" << setw(wcou) << acd.rois.size();
184  out << endl;
185  chanpre = nochanpre;
186  }
187  if ( m_ShowRaw ) {
188  DisplayVector<AdcCountVector> dvec(m_ShowFirst, m_ShowRebin, m_ShowMax, acd.raw);
189  out << chanpre << " Raw:";
190  if ( m_ShowOpt == 2 ) {
191  out << " |";
192  for ( AdcCount val : dvec.vout ) out << setw(1) << charThresh(val, m_ShowThreshold);
193  out << "|";
194  } else {
195  for ( AdcCount val : dvec.vout ) out << setw(6) << val;
196  }
197  out << endl;
198  chanpre = nochanpre;
199  }
200  if ( m_ShowPrepared ) {
201  DisplayVector<AdcSignalVector> dvec(m_ShowFirst, m_ShowRebin, m_ShowMax, acd.samples);
202  out << chanpre << " Prp:";
203  if ( m_ShowOpt == 2 ) {
204  out << " |";
205  for ( AdcCount val : dvec.vout ) out << setw(1) << charThresh(val, m_ShowThreshold);
206  out << "|";
207  } else {
208  for ( AdcCount val : dvec.vout ) out << setw(6) << int(round(val));
209  }
210  out << endl;
211  chanpre = nochanpre;
212  }
213  }
214  if ( newfile ) delete pout;
215  return ret;
216 }
bool m_ShowChannelCount
Definition: AdcDataDumper.h:54
DataMap & setStatus(int stat)
Definition: DataMap.h:130
unsigned int m_ShowRebin
Definition: AdcDataDumper.h:59
unsigned int Index
unsigned int m_ShowFirst
Definition: AdcDataDumper.h:58
AdcRoiVector rois
std::string m_Prefix
Definition: AdcDataDumper.h:52
std::ostream * m_pout
Definition: AdcDataDumper.h:65
std::string m_FileName
Definition: AdcDataDumper.h:51
AdcCountVector raw
unsigned int m_ShowMax
Definition: AdcDataDumper.h:60
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
Channel channel() const
AdcFilterVector signal
unsigned int m_ShowOpt
Definition: AdcDataDumper.h:62
bool m_ShowTickCounts
Definition: AdcDataDumper.h:55
short AdcCount
Definition: AdcTypes.h:18
float m_ShowThreshold
Definition: AdcDataDumper.h:61
AdcSignalVector samples
QTextStream & endl(QTextStream &s)
AdcFlagVector flags

Member Data Documentation

std::string AdcDataDumper::m_FileName
private

Definition at line 51 of file AdcDataDumper.h.

bool AdcDataDumper::m_NewFile
private

Definition at line 53 of file AdcDataDumper.h.

std::ostream* AdcDataDumper::m_pout
private

Definition at line 65 of file AdcDataDumper.h.

std::string AdcDataDumper::m_Prefix
private

Definition at line 52 of file AdcDataDumper.h.

bool AdcDataDumper::m_ShowChannelCount
private

Definition at line 54 of file AdcDataDumper.h.

unsigned int AdcDataDumper::m_ShowFirst
private

Definition at line 58 of file AdcDataDumper.h.

unsigned int AdcDataDumper::m_ShowMax
private

Definition at line 60 of file AdcDataDumper.h.

unsigned int AdcDataDumper::m_ShowOpt
private

Definition at line 62 of file AdcDataDumper.h.

bool AdcDataDumper::m_ShowPrepared
private

Definition at line 57 of file AdcDataDumper.h.

bool AdcDataDumper::m_ShowRaw
private

Definition at line 56 of file AdcDataDumper.h.

unsigned int AdcDataDumper::m_ShowRebin
private

Definition at line 59 of file AdcDataDumper.h.

float AdcDataDumper::m_ShowThreshold
private

Definition at line 61 of file AdcDataDumper.h.

bool AdcDataDumper::m_ShowTickCounts
private

Definition at line 55 of file AdcDataDumper.h.


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