OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
MonitorStatisticsWriter.cpp
Go to the documentation of this file.
1 //
2 // Class MonitorStatisticsWriter
3 // This class writes statistics of monitor element.
4 //
5 // Copyright (c) 2019, Christof Metzger-Kraus, Open Sourcerer
6 // All rights reserved
7 //
8 // This file is part of OPAL.
9 //
10 // OPAL is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17 //
19 
20 #include "Structure/LossDataSink.h"
21 #include "Utility/IpplInfo.h"
22 
23 MonitorStatisticsWriter::MonitorStatisticsWriter(const std::string& fname, bool restart)
24  : SDDSWriter(fname, restart)
25 { }
26 
27 
29 
30  if (this->hasColumns()) {
31  return;
32  }
33 
34  this->addDescription("Statistics data of monitors",
35  "stat parameters");
36  this->addDefaultParameters();
37 
38  columns_m.addColumn("name", "string", "", "Monitor name");
39  columns_m.addColumn("s", "double", "m", "Longitudinal Position");
40  columns_m.addColumn("t", "double", "ns", "Passage Time Reference Particle");
41  columns_m.addColumn("numParticles", "long", "1", "Number of Macro Particles");
42  columns_m.addColumn("rms_x", "double", "m", "RMS Beamsize in x");
43  columns_m.addColumn("rms_y", "double", "m", "RMS Beamsize in y");
44  columns_m.addColumn("rms_s", "double", "m", "RMS Beamsize in s");
45  columns_m.addColumn("rms_t", "double", "ns", "RMS Passage Time");
46  columns_m.addColumn("rms_px", "double", "1", "RMS Momenta in x");
47  columns_m.addColumn("rms_py", "double", "1", "RMS Momenta in y");
48  columns_m.addColumn("rms_ps", "double", "1", "RMS Momenta in s");
49  columns_m.addColumn("emit_x", "double", "m", "Normalized Emittance x");
50  columns_m.addColumn("emit_y", "double", "m", "Normalized Emittance y");
51  columns_m.addColumn("emit_s", "double", "m", "Normalized Emittance s");
52  columns_m.addColumn("mean_x", "double", "m", "Mean Beam Position in x");
53  columns_m.addColumn("mean_y", "double", "m", "Mean Beam Position in y");
54  columns_m.addColumn("mean_s", "double", "m", "Mean Beam Position in s");
55  columns_m.addColumn("mean_t", "double", "ns", "Mean Passage Time");
56  columns_m.addColumn("ref_x", "double", "m", "x coordinate of reference particle in lab cs");
57  columns_m.addColumn("ref_y", "double", "m", "y coordinate of reference particle in lab cs");
58  columns_m.addColumn("ref_z", "double", "m", "z coordinate of reference particle in lab cs");
59  columns_m.addColumn("ref_px", "double", "1", "x momentum of reference particle in lab cs");
60  columns_m.addColumn("ref_py", "double", "1", "y momentum of reference particle in lab cs");
61  columns_m.addColumn("ref_pz", "double", "1", "z momentum of reference particle in lab cs");
62  columns_m.addColumn("min_x", "double", "m", "Max Beamsize in x");
63  columns_m.addColumn("min_y", "double", "m", "Max Beamsize in y");
64  columns_m.addColumn("min_s", "double", "m", "Max Beamsize in s");
65  columns_m.addColumn("max_x", "double", "m", "Max Beamsize in x");
66  columns_m.addColumn("max_y", "double", "m", "Max Beamsize in y");
67  columns_m.addColumn("max_s", "double", "m", "Max Beamsize in s");
68  columns_m.addColumn("xpx", "double", "1", "Correlation xpx");
69  columns_m.addColumn("ypy", "double", "1", "Correlation ypy");
70  columns_m.addColumn("zpz", "double", "1", "Correlation zpz");
71 
72  this->addInfo("ascii", 1);
73 }
74 
75 
77 
78  if ( Ippl::myNode() != 0 ) {
79  return;
80  }
81 
82  this->fillHeader();
83 
84  this->open();
85 
86  this->writeHeader();
87 
91  columns_m.addColumnValue("numParticles", set.nTotal_m);
92  columns_m.addColumnValue("rms_x", set.rrms_m(0));
93  columns_m.addColumnValue("rms_y", set.rrms_m(1));
94  columns_m.addColumnValue("rms_s", set.rrms_m(2));
95  columns_m.addColumnValue("rms_t", set.trms_m * 1e9);
96  columns_m.addColumnValue("rms_px", set.prms_m(0));
97  columns_m.addColumnValue("rms_py", set.prms_m(1));
98  columns_m.addColumnValue("rms_ps", set.prms_m(2));
99  columns_m.addColumnValue("emit_x", set.eps_norm_m(0));
100  columns_m.addColumnValue("emit_y", set.eps_norm_m(1));
101  columns_m.addColumnValue("emit_s", set.eps_norm_m(2));
102  columns_m.addColumnValue("mean_x", set.rmean_m(0));
103  columns_m.addColumnValue("mean_y", set.rmean_m(1));
104  columns_m.addColumnValue("mean_s", set.rmean_m(2));
105  columns_m.addColumnValue("mean_t", set.tmean_m * 1e9);
106  columns_m.addColumnValue("ref_x", set.RefPartR_m(0));
107  columns_m.addColumnValue("ref_y", set.RefPartR_m(1));
108  columns_m.addColumnValue("ref_z", set.RefPartR_m(2));
109  columns_m.addColumnValue("ref_px", set.RefPartP_m(0));
110  columns_m.addColumnValue("ref_py", set.RefPartP_m(1));
111  columns_m.addColumnValue("ref_pz", set.RefPartP_m(2));
112  columns_m.addColumnValue("min_x", set.rmin_m[0]);
113  columns_m.addColumnValue("min_y", set.rmin_m[1]);
114  columns_m.addColumnValue("min_s", set.rmin_m[2]);
115  columns_m.addColumnValue("max_x", set.rmax_m[0]);
116  columns_m.addColumnValue("max_y", set.rmax_m[1]);
117  columns_m.addColumnValue("max_s", set.rmax_m[2]);
118  columns_m.addColumnValue("xpx", set.rprms_m(0));
119  columns_m.addColumnValue("ypy", set.rprms_m(1));
120  columns_m.addColumnValue("zpz", set.rprms_m(2));
121 
122  this->writeRow();
123 
124  this->close();
125 }
Vector_t eps_norm_m
Definition: LossDataSink.h:60
Vector_t rmax_m
Definition: LossDataSink.h:49
Vector_t RefPartP_m
Definition: LossDataSink.h:47
std::string outputName_m
Definition: LossDataSink.h:40
Vector_t prms_m
Definition: LossDataSink.h:53
double tmean_m
Definition: LossDataSink.h:43
Vector_t rmean_m
Definition: LossDataSink.h:50
unsigned long nTotal_m
Definition: LossDataSink.h:45
Vector_t rrms_m
Definition: LossDataSink.h:52
Vector_t RefPartR_m
Definition: LossDataSink.h:46
Vector_t rmin_m
Definition: LossDataSink.h:48
double refTime_m
Definition: LossDataSink.h:42
Vector_t rprms_m
Definition: LossDataSink.h:54
void addRow(const SetStatistics &set)
MonitorStatisticsWriter(const std::string &fname, bool restart)
void addColumn(const std::string &name, const std::string &type, const std::string &unit, const std::string &desc, std::ios_base::fmtflags flags=std::ios_base::scientific, unsigned short precision=15)
void addColumnValue(const std::string &name, const T &val)
Definition: SDDSColumnSet.h:63
SDDSColumnSet columns_m
Definition: SDDSWriter.h:126
bool hasColumns() const
Definition: SDDSWriter.h:207
void addDefaultParameters()
Definition: SDDSWriter.cpp:211
void addDescription(const std::string &text, const std::string &content)
Definition: SDDSWriter.h:164
void open()
Definition: SDDSWriter.cpp:134
void writeHeader()
Write SDDS header.
Definition: SDDSWriter.cpp:151
void close()
Definition: SDDSWriter.cpp:144
void writeRow()
Definition: SDDSWriter.h:192
void addInfo(const std::string &mode, const size_t &no_row_counts)
Definition: SDDSWriter.h:185
static int myNode()
Definition: IpplInfo.cpp:691