BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSArrayOperatorIndex.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef BDSARRAYOPERATORINDEX_H
19#define BDSARRAYOPERATORINDEX_H
20#include "G4String.hh"
21#include "G4Types.hh"
22
23#include <array>
24
36{
37public:
38 BDSArrayOperatorIndex() = delete;
39 explicit BDSArrayOperatorIndex(const G4String& nameIn = "None"):
40 name(nameIn),
41 operatesOn{false, false, false, false}
42 {;}
43 virtual ~BDSArrayOperatorIndex(){;}
44
46 virtual G4String Name() const {return name;}
47
50 virtual void Apply(G4int& /*x*/,
51 G4int& /*y*/,
52 G4int& /*z*/,
53 G4int& /*t*/) const {;}
54 virtual void ApplyX(G4int& /*x*/) const {;}
55 virtual void ApplyY(G4int& /*y*/) const {;}
56 virtual void ApplyZ(G4int& /*z*/) const {;}
57 virtual void ApplyT(G4int& /*t*/) const {;}
58
60 virtual std::array<G4bool, 4> OperatesOnXYZT() const {return operatesOn;}
61
62 void Apply(G4int& x) const
63 {
64 G4int v[3] = {0,0,0};
65 return Apply(x, v[0], v[1], v[2]);
66 }
67
68 void Apply(G4int& x, G4int& y) const
69 {
70 G4int v[2] = {0,0};
71 return Apply(x, y, v[0], v[1]);
72 }
73
74 void Apply(G4int& x, G4int& y, G4int& z) const
75 {
76 G4int t = 0;
77 Apply(x, y, z, t);
78 }
79
80 virtual void TransformLimits(G4double& xMin, G4double& xMax,
81 G4double& yMin, G4double& yMax,
82 G4double& zMin, G4double& zMax,
83 G4double& tMin, G4double& tMax) const = 0;
84
85 void TransformLimits(G4double& xMin, G4double xMax) const
86 {
87 G4double v[6] = {0,0,0,0,0,0};
88 TransformLimits(xMin, xMax, v[0], v[1], v[2], v[3], v[4], v[5]);
89 }
90 void TransformLimits(G4double& xMin, G4double& xMax,
91 G4double& yMin, G4double& yMax) const
92 {
93 G4double v[4] = {0,0,0,0};
94 TransformLimits(xMin, xMax, yMin, yMax, v[0], v[1], v[2], v[3]);
95 }
96 void TransformLimits(G4double& xMin, G4double& xMax,
97 G4double& yMin, G4double& yMax,
98 G4double& zMin, G4double& zMax) const
99 {
100 G4double v[2] = {0, 0};
101 TransformLimits(xMin, xMax, yMin, yMax, zMin, zMax, v[0], v[1]);
102 }
103
104protected:
105 G4String name;
106 std::array<G4bool, 4> operatesOn;
107};
108
109#endif
Interface for modifying by reference array indices.
virtual G4String Name() const
Supply a name of this operator for feedback to the user in print out.
virtual void Apply(G4int &, G4int &, G4int &, G4int &) const
virtual std::array< G4bool, 4 > OperatesOnXYZT() const
Return which axes this object operates on overall.