34 "The \"TSAVE\" sub-command saves the defined particles "
35 "on the given file.") {
37 (
"FILE",
"Name of file to be written",
"TRACKSAVE");
60 std::ofstream os(file.c_str());
64 "Unable to open output file \"" + file +
"\".");
67 os <<
"\nSaved particle positions:\n";
68 std::streamsize old_prec = os.precision(8);
69 os.setf(std::ios::fixed, std::ios::floatfield);
72 for(
unsigned int i = 0; i < bunch->
getLocalNum(); i++) {
74 os << part.
x() <<
' ' << part.
px() <<
' '
75 << part.
y() <<
' ' << part.
py() <<
' '
76 << part.
t() <<
' ' << part.
pt() <<
'\n';
80 os.precision(old_prec);
81 os.setf(std::ios::fixed, std::ios::floatfield);
double & py()
Get reference to vertical momentum (no dimension).
The base class for all OPAL actions.
The base class for all OPAL exceptions.
double & x()
Get reference to horizontal position in m.
std::vector< Attribute > itsAttr
The object attributes (see Attribute.hh).
OpalParticle get_part(int ii)
virtual TrackSave * clone(const std::string &name)
Make clone.
void registerOwnership(const AttributeHandler::OwnerType &itsClass) const
static Track * block
The block of track data.
size_t getLocalNum() const
PartBunchBase< double, 3 > * bunch
The particle bunch to be tracked.
double & pt()
Get reference to relative momentum error (no dimension).
TrackSave()
Exemplar constructor.
double & y()
Get reference to vertical displacement in m.
virtual void execute()
Execute the command.
double & t()
Get reference to longitudinal displacement c*t in m.
double & px()
Get reference to horizontal momentum (no dimension).
Attribute makeString(const std::string &name, const std::string &help)
Make string attribute.
std::string getString(const Attribute &attr)
Get string value.