OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
StatWriter Class Reference

#include <StatWriter.h>

Inheritance diagram for StatWriter:
Collaboration diagram for StatWriter:

Public Types

typedef std::vector< std::pair< std::string, unsigned int > > losses_t
typedef std::pair< std::string, std::string > desc_t
typedef std::tuple< std::string, std::string, std::string > param_t
typedef std::pair< std::string, size_t > data_t
typedef std::tuple< std::string, std::string, std::string, std::string > cols_t

Public Member Functions

 StatWriter (const std::string &fname, bool restart)
void write (const PartBunchBase< double, 3 > *beam, Vector_t FDext[], const losses_t &losses=losses_t(), const double &azimuth=-1, const size_t npOutside=0)
 Write statistical data.
virtual void write (PartBunchBase< double, 3 > *)
unsigned int rewindToSpos (double maxSpos)
 delete the last 'numberOfLines' lines of the statistics file
void rewindLines (size_t numberOfLines)
 delete the last 'numberOfLines' lines of the file 'fileName'
void replaceVersionString ()
double getLastValue (const std::string &column)
bool exists () const

Protected Member Functions

void addDescription (const std::string &text, const std::string &content)
template<typename T>
void addParameter (const std::string &name, const std::string &type, const std::string &desc, const T &value)
void addDefaultParameters ()
void addColumn (const std::string &name, const std::string &type, const std::string &unit, const std::string &desc)
void addInfo (const std::string &mode, const size_t &no_row_counts)
void writeRow ()
void open ()
void close ()
void writeHeader ()
 Write SDDS header.
template<typename T>
std::string toString (const T &val)
bool hasColumns () const

Protected Attributes

std::string fname_m
std::ios_base::openmode mode_m
 First write to the statistics output file.
SDDSColumnSet columns_m

Private Member Functions

void fillHeader (const losses_t &losses=losses_t())
void writeDescription ()
void writeParameters ()
void writeColumns ()
void writeInfo ()

Private Attributes

std::ofstream os_m
std::string indent_m
desc_t desc_m
std::queue< param_tparams_m
std::queue< std::string > paramValues_m
data_t info_m

Static Private Attributes

static constexpr unsigned int precision_m = 15

Detailed Description

Definition at line 24 of file StatWriter.h.

Member Typedef Documentation

◆ cols_t

typedef std::tuple<std::string, std::string, std::string, std::string> SDDSWriter::cols_t
inherited

Definition at line 57 of file SDDSWriter.h.

◆ data_t

typedef std::pair<std::string, size_t> SDDSWriter::data_t
inherited

Definition at line 51 of file SDDSWriter.h.

◆ desc_t

typedef std::pair<std::string, std::string> SDDSWriter::desc_t
inherited

Definition at line 43 of file SDDSWriter.h.

◆ losses_t

typedef std::vector<std::pair<std::string, unsigned int> > StatWriter::losses_t

Definition at line 27 of file StatWriter.h.

◆ param_t

typedef std::tuple<std::string, std::string, std::string> SDDSWriter::param_t
inherited

Definition at line 48 of file SDDSWriter.h.

Constructor & Destructor Documentation

◆ StatWriter()

StatWriter::StatWriter ( const std::string & fname,
bool restart )

Definition at line 28 of file StatWriter.cpp.

References StatBaseWriter::StatBaseWriter().

Here is the call graph for this function:

Member Function Documentation

◆ addColumn()

void SDDSWriter::addColumn ( const std::string & name,
const std::string & type,
const std::string & unit,
const std::string & desc )
protectedinherited

References name.

◆ addDefaultParameters()

void SDDSWriter::addDefaultParameters ( )
protectedinherited

Definition at line 209 of file SDDSWriter.cpp.

References addParameter(), Util::getGitRevision(), OpalData::getInstance(), and IpplInfo::getNodes().

Referenced by ElementPositionWriter::fillHeader(), GridLBalWriter::fillHeader(), LBalWriter::fillHeader(), MemoryWriter::fillHeader(), MonitorStatisticsWriter::fillHeader(), MultiBunchDump::fillHeader(), StatWriter::fillHeader(), and MemoryProfiler::header().

Here is the call graph for this function:

◆ addDescription()

void SDDSWriter::addDescription ( const std::string & text,
const std::string & content )
inlineprotectedinherited

◆ addInfo()

void SDDSWriter::addInfo ( const std::string & mode,
const size_t & no_row_counts )
inlineprotectedinherited

◆ addParameter()

template<typename T>
void SDDSWriter::addParameter ( const std::string & name,
const std::string & type,
const std::string & desc,
const T & value )
protectedinherited

Definition at line 166 of file SDDSWriter.h.

References name, params_m, and paramValues_m.

Referenced by addDefaultParameters().

◆ close()

void SDDSWriter::close ( )
protectedinherited

Definition at line 142 of file SDDSWriter.cpp.

References IpplInfo::myNode(), and os_m.

Referenced by ElementPositionWriter::addRow(), MonitorStatisticsWriter::addRow(), GridLBalWriter::write(), LBalWriter::write(), MemoryProfiler::write(), MemoryWriter::write(), MultiBunchDump::write(), and StatWriter::write().

Here is the call graph for this function:

◆ exists()

bool SDDSWriter::exists ( ) const
inlineinherited

Definition at line 153 of file SDDSWriter.h.

References fname_m.

◆ fillHeader()

void StatWriter::fillHeader ( const losses_t & losses = losses_t())
private

Definition at line 33 of file StatWriter.cpp.

References SDDSWriter::addDefaultParameters(), SDDSWriter::addDescription(), SDDSWriter::addInfo(), SDDSWriter::columns_m, Options::computePercentiles, OPALTimer::Timer::date(), Options::dumpBeamMatrix, OpalData::getInputFn(), OpalData::getInstance(), IpplInfo::getNodes(), SDDSWriter::hasColumns(), SDDSWriter::mode_m, and OPALTimer::Timer::time().

Referenced by write().

Here is the call graph for this function:

◆ getLastValue()

double SDDSWriter::getLastValue ( const std::string & column)
inherited

Definition at line 123 of file SDDSWriter.cpp.

References fname_m, SDDS::SDDSParser::getValue(), and SDDS::SDDSParser::run().

Here is the call graph for this function:

◆ hasColumns()

◆ open()

void SDDSWriter::open ( )
protectedinherited

Definition at line 132 of file SDDSWriter.cpp.

References fname_m, mode_m, IpplInfo::myNode(), os_m, and precision_m.

Referenced by ElementPositionWriter::addRow(), MonitorStatisticsWriter::addRow(), GridLBalWriter::write(), LBalWriter::write(), MemoryProfiler::write(), MemoryWriter::write(), MultiBunchDump::write(), and StatWriter::write().

Here is the call graph for this function:

◆ replaceVersionString()

void SDDSWriter::replaceVersionString ( )
inherited

Definition at line 78 of file SDDSWriter.cpp.

References fname_m, Util::getGitRevision(), SDDS::SDDSParser::getParameterValue(), IpplInfo::myNode(), and SDDS::SDDSParser::run().

Here is the call graph for this function:

◆ rewindLines()

void SDDSWriter::rewindLines ( size_t numberOfLines)
inherited

delete the last 'numberOfLines' lines of the file 'fileName'

Definition at line 48 of file SDDSWriter.cpp.

References fname_m, and IpplInfo::myNode().

Here is the call graph for this function:

◆ rewindToSpos()

unsigned int StatBaseWriter::rewindToSpos ( double maxSpos)
inlineinherited

delete the last 'numberOfLines' lines of the statistics file

Definition at line 40 of file StatBaseWriter.h.

References SDDSWriter::fname_m, IpplInfo::myNode(), and Util::rewindLinesSDDS().

Here is the call graph for this function:

◆ toString()

template<typename T>
std::string SDDSWriter::toString ( const T & val)
protectedinherited

Definition at line 191 of file SDDSWriter.h.

References precision_m.

Referenced by GridLBalWriter::write(), and MemoryProfiler::write().

◆ write() [1/2]

void StatWriter::write ( const PartBunchBase< double, 3 > * beam,
Vector_t FDext[],
const losses_t & losses = losses_t(),
const double & azimuth = -1,
const size_t npOutside = 0 )

Write statistical data.

Writes statistical beam data to proper output file. This is information such as RMS beam parameters etc.

Also gathers and writes load balancing data to load balance statistics file.

Parameters
beamThe beam.
FDextThe external E and B field for the head, reference and tail particles. The vector array has the following layout:
  • FDext[0] = B at head particle location (in x, y and z).

  • FDext[1] = E at head particle location (in x, y and z).

  • FDext[2] = B at reference particle location (in x, y and z).

  • FDext[3] = E at reference particle location (in x, y and z).

  • FDext[4] = B at tail particle location (in x, y, and z).

  • FDext[5] = E at tail particle location (in x, y, and z).

Write data to files. If this is the first write to the beam statistics file, write SDDS header information.

Definition at line 224 of file StatWriter.cpp.

References SDDSWriter::close(), SDDSWriter::columns_m, Options::computePercentiles, Options::dumpBeamMatrix, fillHeader(), PartBunchBase< T, Dim >::get_68Percentile(), PartBunchBase< T, Dim >::get_95Percentile(), PartBunchBase< T, Dim >::get_99_99Percentile(), PartBunchBase< T, Dim >::get_99Percentile(), PartBunchBase< T, Dim >::get_DDx(), PartBunchBase< T, Dim >::get_DDy(), PartBunchBase< T, Dim >::get_debyeLength(), PartBunchBase< T, Dim >::get_Dx(), PartBunchBase< T, Dim >::get_Dy(), PartBunchBase< T, Dim >::get_halo(), PartBunchBase< T, Dim >::get_maxExtent(), PartBunchBase< T, Dim >::get_meanKineticEnergy(), PartBunchBase< T, Dim >::get_norm_emit(), PartBunchBase< T, Dim >::get_normalizedEps_68Percentile(), PartBunchBase< T, Dim >::get_normalizedEps_95Percentile(), PartBunchBase< T, Dim >::get_normalizedEps_99_99Percentile(), PartBunchBase< T, Dim >::get_normalizedEps_99Percentile(), PartBunchBase< T, Dim >::get_plasmaParameter(), PartBunchBase< T, Dim >::get_prms(), PartBunchBase< T, Dim >::get_rmean(), PartBunchBase< T, Dim >::get_rmsDensity(), PartBunchBase< T, Dim >::get_rprms(), PartBunchBase< T, Dim >::get_rrms(), PartBunchBase< T, Dim >::get_sPos(), PartBunchBase< T, Dim >::get_temperature(), PartBunchBase< T, Dim >::getCharge(), PartBunchBase< T, Dim >::getdE(), PartBunchBase< T, Dim >::getdT(), OpalData::getInstance(), PartBunchBase< T, Dim >::getLocalNum(), IpplInfo::getNodes(), PartBunchBase< T, Dim >::getSigmaMatrix(), PartBunchBase< T, Dim >::getT(), PartBunchBase< T, Dim >::getTotalNum(), IpplInfo::myNode(), SDDSWriter::open(), PartBunchBase< T, Dim >::P, PartBunchBase< T, Dim >::R, PartBunchBase< T, Dim >::RefPartP_m, PartBunchBase< T, Dim >::RefPartR_m, Units::s2ns, SDDSWriter::writeHeader(), and SDDSWriter::writeRow().

Here is the call graph for this function:

◆ write() [2/2]

virtual void SDDSWriter::write ( PartBunchBase< double, 3 > * )
inlinevirtual

Reimplemented from SDDSWriter.

Definition at line 63 of file SDDSWriter.h.

◆ writeColumns()

void SDDSWriter::writeColumns ( )
privateinherited

Definition at line 189 of file SDDSWriter.cpp.

References columns_m, indent_m, and os_m.

Referenced by writeHeader().

◆ writeDescription()

void SDDSWriter::writeDescription ( )
privateinherited

Definition at line 165 of file SDDSWriter.cpp.

References desc_m, indent_m, and os_m.

Referenced by writeHeader().

◆ writeHeader()

void SDDSWriter::writeHeader ( )
protectedinherited

Write SDDS header.

Writes the appropriate SDDS format header information, The SDDS tools can be used for plotting data.

Definition at line 149 of file SDDSWriter.cpp.

References mode_m, IpplInfo::myNode(), writeColumns(), writeDescription(), writeInfo(), and writeParameters().

Referenced by ElementPositionWriter::addRow(), MonitorStatisticsWriter::addRow(), GridLBalWriter::write(), LBalWriter::write(), MemoryProfiler::write(), MemoryWriter::write(), MultiBunchDump::write(), and StatWriter::write().

Here is the call graph for this function:

◆ writeInfo()

void SDDSWriter::writeInfo ( )
privateinherited

Definition at line 194 of file SDDSWriter.cpp.

References indent_m, info_m, os_m, and paramValues_m.

Referenced by writeHeader().

◆ writeParameters()

void SDDSWriter::writeParameters ( )
privateinherited

Definition at line 174 of file SDDSWriter.cpp.

References indent_m, os_m, and params_m.

Referenced by writeHeader().

◆ writeRow()

Member Data Documentation

◆ columns_m

◆ desc_m

desc_t SDDSWriter::desc_m
privateinherited

Definition at line 142 of file SDDSWriter.h.

Referenced by addDescription(), and writeDescription().

◆ fname_m

std::string SDDSWriter::fname_m
protectedinherited

◆ indent_m

std::string SDDSWriter::indent_m
privateinherited

Definition at line 140 of file SDDSWriter.h.

Referenced by SDDSWriter(), writeColumns(), writeDescription(), writeInfo(), and writeParameters().

◆ info_m

data_t SDDSWriter::info_m
privateinherited

Definition at line 145 of file SDDSWriter.h.

Referenced by addInfo(), and writeInfo().

◆ mode_m

std::ios_base::openmode SDDSWriter::mode_m
protectedinherited

First write to the statistics output file.

Initially set to std::ios::out so that SDDS format header information is written to file during the first write call to the statistics output file. Variable is then reset to std::ios::app so that header information is only written once.

Definition at line 120 of file SDDSWriter.h.

Referenced by GridLBalWriter::fillHeader(), LBalWriter::fillHeader(), MemoryWriter::fillHeader(), MultiBunchDump::fillHeader(), StatWriter::fillHeader(), MemoryProfiler::header(), open(), SDDSWriter(), and writeHeader().

◆ os_m

std::ofstream SDDSWriter::os_m
privateinherited

◆ params_m

std::queue<param_t> SDDSWriter::params_m
privateinherited

Definition at line 143 of file SDDSWriter.h.

Referenced by addParameter(), and writeParameters().

◆ paramValues_m

std::queue<std::string> SDDSWriter::paramValues_m
privateinherited

Definition at line 144 of file SDDSWriter.h.

Referenced by addParameter(), and writeInfo().

◆ precision_m

unsigned int SDDSWriter::precision_m = 15
staticconstexprprivateinherited

Definition at line 148 of file SDDSWriter.h.

Referenced by open(), and toString().


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