Class TextOutput

Inheritance Relationships

Base Type

Class Documentation

class TextOutput : public Output

Configurable plain text output for particle information. This type of output can also be used to generate a .tar.gz file if the library zlib is available. For details see: http://zlib.net/.

Public Types

enum OutputColumn

Values:

enumerator TrajectoryLengthColumn
enumerator ColumnDensityColumn
enumerator RedshiftColumn
enumerator CurrentIdColumn
enumerator CurrentEnergyColumn
enumerator CurrentPositionColumn
enumerator CurrentDirectionColumn
enumerator SourceIdColumn
enumerator SourceEnergyColumn
enumerator SourcePositionColumn
enumerator SourceDirectionColumn
enumerator CreatedIdColumn
enumerator CreatedEnergyColumn
enumerator CreatedPositionColumn
enumerator CreatedDirectionColumn
enumerator CandidateTagColumn
enumerator SerialNumberColumn
enumerator WeightColumn
enum OutputType

Values:

enumerator Trajectory1D
enumerator Trajectory3D
enumerator Event1D
enumerator Event3D
enumerator Everything

Public Functions

TextOutput()

Default constructor

TextOutput(OutputType outputType)

Constructor

Parameters:

outputType – type of output: Trajectory1D, Trajectory3D, Event1D, Event3D, Everything

TextOutput(std::ostream &out)

Constructor

Parameters:

out – output stream

TextOutput(std::ostream &out, OutputType outputType)

Constructor

Parameters:
  • out – output stream

  • outputType – type of output: Trajectory1D, Trajectory3D, Event1D, Event3D, Everything

TextOutput(const std::string &filename)

Constructor with the default OutputType (everything).

Parameters:

filename – string containing name of output text file

TextOutput(const std::string &filename, OutputType outputType)

Constructor

Parameters:
  • filename – string containing name of output text file

  • outputType – type of output: Trajectory1D, Trajectory3D, Event1D, Event3D, Everything

~TextOutput()

Destructor

inline void enableRandomSeeds()

Whether to store the random seeds used in the simulation. This enables reproducibility of each realisation of the simulation.

void close()
void gzip()
virtual void process(Candidate *candidate) const
virtual std::string getDescription() const
std::string OutputTypeName(OutputType outputtype)
void setEnergyScale(double scale)

Set energy scale.

Parameters:

scale – energy scale (scale = 1 corresponds to 1 Joule)

void setLengthScale(double scale)

Set length scale.

Parameters:

scale – length scale (scale = 1 corresponds to 1 meter)

void setOutputType(OutputType outputType)

Set type of output.

Parameters:

outputType – type of output: Trajectory1D, Trajectory3D, Event1D, Event3D, Everything

void set(OutputColumn field, bool value)

Determines whether a given column will be displayed in the output.

Parameters:
  • field – name of the field to be added/removed from output

  • value – boolean flag adding (true) or removing (false) the field

void enableProperty(const std::string &property, const Variant &defaultValue, const std::string &comment = "")

Add a property to output. Default value is required to assign a type in the output.

Parameters:
  • property – string containing name of property

  • defaultValue – default value of property

  • comment – string with a comment

void enable(OutputColumn field)

Enable specific column in the output.

Parameters:

field – name of the field to be enabled

void disable(OutputColumn field)

Disable specific column in the output.

Parameters:

field – name of the field to be disabled

void enableAll()

Enable all fields. Essentially a wrapper for set(field, true).

void disableAll()

Disable all fields. Essentially a wrapper for set(field, false).

void set1D(bool value)

If true, output is of 1D type. 3D quantities such as vectors will be reduced to the relevant components (x, by default).

Parameters:

value – boolean flag

size_t size() const

Returns the size of the output

inline void process(ref_ptr<Candidate> candidate) const
void setDescription(const std::string &description)
inline size_t addReference() const
inline size_t removeReference() const
inline int removeReferenceNoDelete() const
inline size_t getReferenceCount() const

Public Members

const std::string outputName

Public Static Functions

static void load(const std::string &filename, ParticleCollector *collector)

Loads a file to a particle collector. This is useful for analysis involving, e.g., magnetic lenses.

Parameters:
  • filename – string containing the name of the file to be loaded

  • collector – object of type ParticleCollector that will store the information

Protected Functions

void printHeader() const
void modify()

Protected Attributes

std::ostream *out
std::ofstream outfile
std::string filename
bool storeRandomSeeds
double lengthScale
double energyScale
std::bitset<64> fields
std::vector<Property> properties
bool oneDimensional
mutable size_t count
mutable size_t _referenceCount