BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSArrayOperatorIndexV.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 BDSARRAYOPERATORINDEXV_H
19#define BDSARRAYOPERATORINDEXV_H
20#include "BDSArrayOperatorIndex.hh"
21
22#include "G4Types.hh"
23
24#include <array>
25#include <vector>
26
34{
35public:
37 BDSArrayOperatorIndex("Vector( "){;}
39 {
40 for (auto op : operators)
41 {delete op;}
42 }
43
46 {
47 operators.push_back(operatorIn);
48 // update base class record of what this oeprates on
49 const std::array<G4bool, 4> ops = operatorIn->OperatesOnXYZT();
50 for (G4int i = 0; i < (G4int)ops.size(); i++)
51 {operatesOn[i] = operatesOn[i] || ops[i];}
52 }
53
55 virtual G4String Name() const
56 {
57 G4String result = "Vector(";
58 for (auto op : operators)
59 {result += op->Name() + " ";}
60 result += ")";
61 return result;
62 }
63
66 virtual void Apply(G4int& x,
67 G4int& y,
68 G4int& z,
69 G4int& t) const
70 {
71 for (auto op : operators)
72 {op->Apply(x,y,z,t);}
73 }
74 virtual void ApplyX(G4int& x) const
75 {
76 for (auto op : operators)
77 {op->ApplyX(x);}
78 }
79 virtual void ApplyY(G4int& y) const
80 {
81 for (auto op : operators)
82 {op->ApplyY(y);}
83 }
84 virtual void ApplyZ(G4int& z) const
85 {
86 for (auto op : operators)
87 {op->ApplyZ(z);}
88 }
89 virtual void ApplyT(G4int& t) const
90 {
91 for (auto op : operators)
92 {op->ApplyT(t);}
93 }
94
95 virtual void TransformLimits(G4double& xMin, G4double& xMax,
96 G4double& yMin, G4double& yMax,
97 G4double& zMin, G4double& zMax,
98 G4double& tMin, G4double& tMax) const
99 {
100 for (auto op : operators)
101 {op->TransformLimits(xMin, xMax, yMin, yMax, zMin, zMax, tMin, tMax);}
102 }
103
104 std::vector<BDSArrayOperatorIndex*> operators;
105};
106
107#endif
Vectorised version of BDSArrayOperatorIndex.
virtual void Apply(G4int &x, G4int &y, G4int &z, G4int &t) const
virtual G4String Name() const
Supply a name of this operator for feedback to the user in print out.
void push_back(BDSArrayOperatorIndex *operatorIn)
Append an operator to the vector.
Interface for modifying by reference array indices.
virtual std::array< G4bool, 4 > OperatesOnXYZT() const
Return which axes this object operates on overall.