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

#include <AdcChannelDumper.h>

Inheritance diagram for AdcChannelDumper:
TpcDataTool

Public Member Functions

 AdcChannelDumper (fhicl::ParameterSet const &ps)
 
 ~AdcChannelDumper () override
 
DataMap view (const AdcChannelData &acd) const override
 
bool updateWithView () const override
 

Private Attributes

std::string m_FileName
 
std::string m_Prefix
 
bool m_NewFile
 
int m_MaxSample
 
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 updateMap (AdcChannelDataMap &acds) const
 
virtual DataMap viewMap (const 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 22 of file AdcChannelDumper.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file AdcChannelDumper_tool.cc.

26 : m_FileName(ps.get<string>("FileName")),
27  m_Prefix(ps.get<string>("Prefix")),
28  m_NewFile(ps.get<bool>("NewFile")),
29  m_MaxSample(ps.get<int>("MaxSample")),
30  m_pout(nullptr) {
31  if ( m_FileName.size() == 0 ) m_pout = &cout;
32  else if ( ! m_NewFile ) m_pout = new ofstream(m_FileName.c_str());
33 }
std::string m_Prefix
std::string m_FileName
static constexpr double ps
Definition: Units.h:99
std::ostream * m_pout
AdcChannelDumper::~AdcChannelDumper ( )
override

Definition at line 37 of file AdcChannelDumper_tool.cc.

37  {
38  if ( m_pout != nullptr && m_pout != &cout ) {
39  delete m_pout;
40  m_pout = nullptr;
41  }
42 }
std::ostream * m_pout

Member Function Documentation

bool AdcChannelDumper::updateWithView ( ) const
inlineoverridevirtual

Reimplemented from AdcChannelTool.

Definition at line 31 of file AdcChannelDumper.h.

31 { return true; }
DataMap AdcChannelDumper::view ( const AdcChannelData acd) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 46 of file AdcChannelDumper_tool.cc.

46  {
47  DataMap res;
48  ostream* pout = m_pout;
49  bool newfile = pout == nullptr;
50  // If file is not already set, build the file name and open it.
51  if ( newfile ) {
52  if ( ! m_NewFile ) return res.setStatus(1);
53  string fname = m_FileName;
54  pout = new ofstream(fname.c_str());
55  }
56  if ( pout == nullptr ) return res.setStatus(2);
57  ostream& out = *pout;
58  string pre = m_Prefix;
59  string sbad = "<Unknown>";
60  out << pre << " Run: ";
61  if ( acd.run() == AdcChannelData::badIndex() ) out << sbad;
62  else out << acd.run();
63  out << "-";
64  if ( acd.subRun() == AdcChannelData::badIndex() ) out << sbad;
65  else out << acd.subRun();
66  out << endl;
67  out << pre << " Event: ";
68  if ( acd.event() == AdcChannelData::badIndex() ) out << sbad;
69  else out << acd.event();
70  out << endl;
71  out << pre << " Channel: ";
72  if ( acd.channel() == AdcChannelData::badChannel() ) out << sbad;
73  else out << acd.channel();
74  out << endl;
75  out << pre << " Pedestal: ";
76  if ( acd.pedestal == AdcChannelData::badSignal() ) out << sbad;
77  else out << acd.pedestal;
78  out << endl;
79  Index nraw = acd.raw.size();
80  Index nflg = acd.flags.size();
81  Index nprp = acd.samples.size();
82  Index nsig = acd.signal.size();
83  Index nkeep = 0;
84  for ( bool keep : acd.signal ) if ( keep ) ++nkeep;
85  Index nsam = nraw;
86  if ( nprp > nsam ) nsam = nprp;
87  if ( m_MaxSample >= 0 ) {
88  Index maxsam = m_MaxSample;
89  if ( maxsam < nsam ) nsam = maxsam;
90  }
91  Index widx = 2 + log10(nsam);
92  if ( widx < 6 ) widx = 6;
93  Index wraw = 6;
94  Index wflg = 4;
95  Index wprp = 9;
96  Index wsig = 2;
97  Index wcnt = wprp;
98  out << pre << " Nraw: " << setw(wcnt) << nraw << endl;
99  out << pre << " Nprep: " << setw(wcnt) << nprp << endl;
100  out << pre << " Nsig: " << setw(wcnt) << acd.signal.size() << endl;
101  out << pre << " Nkeep: " << setw(wcnt) << nkeep << endl;
102  out << pre << " Nroi: " << setw(wcnt) << acd.rois.size() << endl;
103  out << pre << " Ndftm: " << setw(wcnt) << acd.dftmags.size() << endl;
104  out << pre << " Ndftp: " << setw(wcnt) << acd.dftphases.size() << endl;
105  if ( nsam > 0 ) {
106  out << pre
107  << setw(widx) << "Data:"
108  << setw(wraw) << "Raw"
109  << setw(wflg) << "Flg"
110  << setw(wprp) << "Prepared"
111  << setw(wsig) << "S" << endl;
112  }
113  for ( Index isam=0; isam<nsam; ++isam ) {
114  ostringstream ssline;
115  ssline << setw(widx) << isam;
116  if ( isam < nraw ) ssline << setw(wraw) << acd.raw[isam];
117  else ssline << setw(wraw) << "";
118  if ( isam < nflg ) ssline << setw(wflg) << acd.flags[isam];
119  else ssline << setw(wflg) << "";
120  if ( isam < nprp ) ssline << fixed << setprecision(2) << setw(wprp) << acd.samples[isam];
121  else ssline << setw(wprp) << "";
122  if ( isam < nsig ) ssline << setw(wsig) << acd.signal[isam];
123  else ssline << setw(wsig) << "";
124  out << pre << ssline.str() << endl;
125  }
126  if ( newfile ) delete pout;
127  return res;
128 }
std::string m_Prefix
AdcIndex subRun() const
DataMap & setStatus(int stat)
Definition: DataMap.h:130
unsigned int Index
Q_EXPORT QTSManip setprecision(int p)
Definition: qtextstream.h:343
std::string m_FileName
static Index badSignal()
AdcRoiVector rois
AdcIndex run() const
AdcIndex event() const
AdcSignalVector dftphases
AdcCountVector raw
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
Channel channel() const
AdcSignal pedestal
AdcFilterVector signal
static Index badChannel()
static Index badIndex()
std::ostream * m_pout
AdcSignalVector samples
AdcSignalVector dftmags
QTextStream & endl(QTextStream &s)
AdcFlagVector flags

Member Data Documentation

std::string AdcChannelDumper::m_FileName
private

Definition at line 36 of file AdcChannelDumper.h.

int AdcChannelDumper::m_MaxSample
private

Definition at line 39 of file AdcChannelDumper.h.

bool AdcChannelDumper::m_NewFile
private

Definition at line 38 of file AdcChannelDumper.h.

std::ostream* AdcChannelDumper::m_pout
private

Definition at line 42 of file AdcChannelDumper.h.

std::string AdcChannelDumper::m_Prefix
private

Definition at line 37 of file AdcChannelDumper.h.


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