openPMD_raytrace_API  0.1.0
rays.cc
Go to the documentation of this file.
1 //#include "rays.hh"
2 #include "openPMD_io.hh"
3 #include <array>
4 #include <cmath>
6 
8 using raytracing::Ray;
9 // using raytracing::openPMD_io::Rays;
10 #ifndef V2SE
11 #define VS2E 5.22703725e-6 /* Convert (v[m/s])**2 to E[meV] */
12 #endif
13 namespace raytracing {
14 std::ostream&
15 operator<<(std::ostream& os, const Ray& ray) {
16  return os << "(" << ray.x() << ", " << ray.y() << "\t" << ray.z() << ")";
17 }
18 } // namespace raytracing
19 
20 openPMD_io::Rays::Rays(): _size(0), _read(0) {}
21 
22 //------------------------------
23 void
24 openPMD_io::Rays::push(const Ray& this_ray) {
25  _x.push_back(this_ray.x());
26  _y.push_back(this_ray.y());
27  _z.push_back(this_ray.z());
28 
29  _dx.push_back(this_ray.dx());
30  _dy.push_back(this_ray.dy());
31  _dz.push_back(this_ray.dz());
32 
33  _sx.push_back(this_ray.sx());
34  _sy.push_back(this_ray.sy());
35  _sz.push_back(this_ray.sz());
36 
37  _sPolAx.push_back(this_ray.sPolAx());
38  _sPolAy.push_back(this_ray.sPolAy());
39  _sPolAz.push_back(this_ray.sPolAz());
40  _sPolPh.push_back(this_ray.sPolPh());
41 
42  _pPolAx.push_back(this_ray.pPolAx());
43  _pPolAy.push_back(this_ray.pPolAy());
44  _pPolAz.push_back(this_ray.pPolAz());
45  _pPolPh.push_back(this_ray.pPolPh());
46 
47  _wavelength.push_back(this_ray.get_wavelength());
48  _time.push_back(this_ray.get_time());
49  _weight.push_back(this_ray.get_weight());
50 
51  _id.push_back(this_ray.get_id());
52  _status.push_back(this_ray.get_status());
53  ++_size;
54 };
55 
56 //------------------------------
57 Ray
58 openPMD_io::Rays::pop(bool next) {
59 
60  Ray r;
61  r.set_position(_x[_read], _y[_read], _z[_read]);
62  r.set_direction(_dx[_read], _dy[_read], _dz[_read]);
63 
64  r.set_polarization(_sx[_read], _sy[_read], _sz[_read]);
65 
66  r.set_sPolarization(_sPolAx[_read], _sPolAy[_read], _sPolAz[_read], _sPolPh[_read]);
67  r.set_pPolarization(_pPolAx[_read], _pPolAy[_read], _pPolAz[_read], _pPolPh[_read]);
68 
69  r.set_wavelength(_wavelength[_read]);
70  r.set_time(_time[_read]);
71  r.set_weight(_weight[_read]);
72 
73  r.set_id(_id[_read]);
74  r.set_status(_status[_read]);
75 
76  if (next) ++_read;
77  return r;
78 }
79 
I/O API for the ray trace extension of the openPMD format.
Definition: openPMD_io.hh:20
void set_wavelength(double w)
set wavelength
Definition: ray.hh:224
void set_polarization(double x, double y, double z, double scale=1)
scale and set polarization for non-photons
Definition: ray.hh:204
void set_weight(double w)
set weight
Definition: ray.hh:228
Generic ray, containing all the ray information being stored by the API into the openPMD file...
Definition: ray.hh:39
void set_direction(double x, double y, double z, double scale=1)
scale and set the direction
Definition: ray.hh:191
defines the maximum number of rays that can be stored in memory before dumping to file ...
Definition: openPMD_io.hh:10
void set_sPolarization(double x, double y, double z, double phase, double scale=1)
scale and set s-polarization for photons
Definition: ray.hh:210
void set_pPolarization(double x, double y, double z, double phase, double scale=1)
scale and set p-polarization for photons
Definition: ray.hh:217
void set_time(double t)
set time
Definition: ray.hh:226
void set_position(double x, double y, double z, double scale=1)
scale and set the position
Definition: ray.hh:184
particleStatus_t get_status(void) const
return the particle status
Definition: ray.hh:175