Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add enum EventType #337

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Intern/rayx-core/src/Beamline/Objects/CircleSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ std::vector<Ray> CircleSource::getRays([[maybe_unused]] int thread_count) const
// main ray (main ray: xDir=0,yDir=0,zDir=1 for phi=psi=0)
glm::dvec3 direction = getDirection();

const auto rotation = glm::dmat3(m_orientation);
const auto field = rotation * stokesToElectricField(m_stokes);
const auto field = stokesToElectricField(m_stokes, direction);

Ray r = {position, ETYPE_UNINIT, direction, en, field, 0.0, 0.0, -1.0, -1.0};
Ray r = {position, EventType::Uninit, direction, en, field, 0.0, 0.0, -1.0, -1.0};

rayList.push_back(r);
}
Expand Down
5 changes: 2 additions & 3 deletions Intern/rayx-core/src/Beamline/Objects/DipoleSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ std::vector<Ray> DipoleSource::getRays(int thread_count) const {
glm::dvec4 tempDir = m_orientation * glm::dvec4(direction, 0.0);
direction = glm::dvec3(tempDir.x, tempDir.y, tempDir.z);

const auto rotation = glm::dmat3(m_orientation);
const auto field = rotation * stokesToElectricField(psiandstokes.stokes);
const auto field = stokesToElectricField(psiandstokes.stokes, direction);

Ray r = {position, ETYPE_UNINIT, direction, en, field, 0.0, 0.0, -1.0, -1.0};
Ray r = {position, EventType::Uninit, direction, en, field, 0.0, 0.0, -1.0, -1.0};
#if defined(DIPOLE_OMP)
#pragma omp critical // thread-safety for writing rayList
{ rayList.push_back(r); }
Expand Down
5 changes: 2 additions & 3 deletions Intern/rayx-core/src/Beamline/Objects/MatrixSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ std::vector<Ray> MatrixSource::getRays([[maybe_unused]] int thread_count) const
glm::dvec4 tempDir = m_orientation * glm::dvec4(direction, 0.0);
direction = glm::dvec3(tempDir.x, tempDir.y, tempDir.z);

const auto rotation = glm::dmat3(m_orientation);
const auto field = rotation * stokesToElectricField(m_pol);
const auto field = stokesToElectricField(m_pol, direction);

Ray r = {position, ETYPE_UNINIT, direction, en, field, 0.0, 0.0, -1.0, -1.0};
Ray r = {position, EventType::Uninit, direction, en, field, 0.0, 0.0, -1.0, -1.0};

returnList.push_back(r);
}
Expand Down
4 changes: 2 additions & 2 deletions Intern/rayx-core/src/Beamline/Objects/PixelSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ std::vector<Ray> PixelSource::getRays([[maybe_unused]] int thread_count) const {
direction = glm::dvec3(tempDir.x, tempDir.y, tempDir.z);

const auto rotation = glm::dmat3(m_orientation);
const auto field = rotation * stokesToElectricField(m_pol);
const auto field = stokesToElectricField(m_pol, rotation);

Ray r = {position, ETYPE_UNINIT, direction, en, field, 0.0, 0.0, -1.0, -1.0};
Ray r = {position, EventType::Uninit, direction, en, field, 0.0, 0.0, -1.0, -1.0};

rayList.push_back(r);
}
Expand Down
5 changes: 2 additions & 3 deletions Intern/rayx-core/src/Beamline/Objects/PointSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ std::vector<Ray> PointSource::getRays(int thread_count) const {
glm::dvec4 tempDir = m_orientation * glm::dvec4(direction, 0.0);
direction = glm::dvec3(tempDir.x, tempDir.y, tempDir.z);

// const auto rotation = rotationMatrix(direction);
const auto field = /* rotation * */ stokesToElectricField(m_pol);
const auto field = stokesToElectricField(m_pol, direction);

Ray r = {position, ETYPE_UNINIT, direction, en, field, 0.0, 0.0, -1.0, -1.0};
Ray r = {position, EventType::Uninit, direction, en, field, 0.0, 0.0, -1.0, -1.0};
#if defined(DIPOLE_OMP)
#pragma omp critical
{ rayList.push_back(r); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ std::vector<Ray> SimpleUndulatorSource::getRays([[maybe_unused]] int thread_coun
glm::dvec4 tempDir = m_orientation * glm::dvec4(direction, 0.0);
direction = glm::dvec3(tempDir.x, tempDir.y, tempDir.z);

const auto rotation = glm::dmat3(m_orientation);
const auto field = rotation * stokesToElectricField(m_pol);
const auto field = stokesToElectricField(m_pol, direction);

Ray r = {position, ETYPE_UNINIT, direction, en, field, 0.0, 0.0, -1.0, -1.0};
Ray r = {position, EventType::Uninit, direction, en, field, 0.0, 0.0, -1.0, -1.0};

rayList.push_back(r);
}
Expand Down
3 changes: 2 additions & 1 deletion Intern/rayx-core/src/Debug/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ inline std::vector<double> formatAsVec(double arg) { return {arg}; }
inline std::vector<double> formatAsVec(complex::Complex comp) { return {comp.real(), comp.imag()}; }

inline std::vector<double> formatAsVec(const Ray arg) {
const auto eventType = static_cast<double>(arg.m_eventType);
return {
arg.m_position.x, arg.m_position.y, arg.m_position.z, arg.m_eventType, arg.m_direction.x, arg.m_direction.y,
arg.m_position.x, arg.m_position.y, arg.m_position.z, eventType, arg.m_direction.x, arg.m_direction.y,
arg.m_direction.z, arg.m_energy, arg.m_field.x.real(), arg.m_field.x.imag(), arg.m_field.y.real(), arg.m_field.y.imag(),
arg.m_field.z.real(), arg.m_field.z.imag(), arg.m_pathLength, arg.m_order, arg.m_lastElement, arg.m_sourceID,
};
Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-core/src/Shader/Behave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Ray behaveSlit(Ray r, int id, [[maybe_unused]] Collision col, InvState& inv) {
bool withinBeamstop = inCutout(beamstopCutout, r.m_position.x, r.m_position.z);

if (!withinOpening || withinBeamstop) {
recordFinalEvent(r, ETYPE_ABSORBED, inv);
recordFinalEvent(r, EventType::Absorbed, inv);
return r;
}

Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-core/src/Shader/Behave.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace RAYX {
/// The `behave*` functions, will
/// - change the rays direction, typically by reflecting using the normal
/// - change the rays stokes vector
/// - potentially absorb the ray (by calling `recordFinalEvent(_, ETYPE_ABSORBED)`)
/// - potentially absorb the ray (by calling `recordFinalEvent(_, EventType::Absorbed)`)

RAYX_FN_ACC Ray behaveSlit(Ray r, int id, Collision col, InvState& inv);
RAYX_FN_ACC Ray behaveRZP(Ray r, int id, Collision col, InvState& inv);
Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-core/src/Shader/DynamicElements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void dynamicElements(int gid, InvState& inv) {
break;
}

recordEvent(ray, ETYPE_JUST_HIT_ELEM, inv);
recordEvent(ray, EventType::HitElement, inv);

// transform back to WORLD coordinates
ray = rayMatrixMult(ray, nextElement.m_outTrans);
Expand Down
Loading
Loading