19#ifndef BDSARRAYOPERATORCOORDREFLECT_H
20#define BDSARRAYOPERATORCOORDREFLECT_H
21#include "BDSArray4DCoords.hh"
22#include "BDSArrayInfo.hh"
23#include "BDSArrayOperatorIndex.hh"
24#include "BDSWarning.hh"
44 xyzt{
false,
false,
false,
false},
45 zeroInArrayCoords{0,0,0,0},
46 dimensionInverted{
false,
false,
false,
false}
54 G4String newName =
"Reflect(";
55 for (
const auto& v : xyzt)
56 {newName += std::to_string(v);}
60 auto zeroV = arrayInfo.zeroPoint;
61 auto nPoints = arrayInfo.nPoints;
62 for (G4int i = 0; i < 4; i++)
64 G4bool inverted = (zeroV[i] >= nPoints[i] - 1) && (nPoints[i] > 1);
65 dimensionInverted[i] = inverted;
66 zeroInArrayCoords[i] = inverted ? nPoints[i] - 1 : (G4int)std::floor(zeroV[i]);
76 G4int* values[4] = {&x, &y, &z, &t};
77 for (G4int i = 0; i < 4; i++)
79 G4int v = *(values[i]);
80 if (dimensionInverted[i])
81 { *(values[i]) = xyzt[i] && v > zeroInArrayCoords[i] ? zeroInArrayCoords[i] - (v- zeroInArrayCoords[i]) : v;}
83 { *(values[i]) = xyzt[i] && v < zeroInArrayCoords[i] ? std::abs(v - zeroInArrayCoords[i]) : v; }
87 virtual void ApplyX(G4int& x)
const {x = xyzt[0] ? std::abs(x) : x;}
88 virtual void ApplyY(G4int& y)
const {y = xyzt[1] ? std::abs(y) : y;}
89 virtual void ApplyZ(G4int& z)
const {z = xyzt[2] ? std::abs(z) : z;}
90 virtual void ApplyT(G4int& t)
const {t = xyzt[3] ? std::abs(t) : t;}
92 virtual void TransformLimits(G4double& xMin, G4double& xMax,
93 G4double& yMin, G4double& yMax,
94 G4double& zMin, G4double& zMax,
95 G4double& tMin, G4double& tMax)
const
97 xMin = -std::abs(xMax);
98 yMin = -std::abs(yMax);
99 zMin = -std::abs(zMax);
100 tMin = -std::abs(tMax);
104 std::array<G4bool,4> xyzt;
105 std::array<G4int, 4> zeroInArrayCoords;
106 std::array<G4bool,4> dimensionInverted;
Simple holder of information about an array.
1D array for completeness in array system.
virtual void Apply(G4int &x, G4int &y, G4int &z, G4int &t) const
Interface for modifying by reference array indices.