BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSElement.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2022.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef BDSELEMENT_H
20#define BDSELEMENT_H
21
22#include "BDSAcceleratorComponent.hh"
23#include "BDSGeometryExternal.hh"
24
25#include "globals.hh"
26
27#include <set>
28#include <vector>
29
39{
40public:
41 BDSElement() = delete;
42 BDSElement(const G4String& name,
43 G4double arcLength,
44 G4double horizontalWidthIn,
45 const G4String& geometry,
46 G4double angle = 0,
47 std::vector<G4String>* namedVacuumVolumesIn = nullptr,
48 G4bool autoColourGeometryIn = true,
49 G4bool markAsCollimatorIn = false,
50 G4bool stripOuterVolume = false);
51 virtual ~BDSElement(){;}
52
53 // This is a little convoluted because ultimately we can't change the
54 // behaviour of the base class destructor, which will always be called
55 // even if overridden. So if we want a BDSGeometryComponent that's uniquely
56 // managed by the geometry factory (ie we don't own here) we have to forward
57 // things on for the same access but no deletion.
59 virtual std::set<G4VPhysicalVolume*> GetAllPhysicalVolumes() const;
60 virtual std::set<G4RotationMatrix*> GetAllRotationMatrices() const;
61 virtual std::set<G4VisAttributes*> GetAllVisAttributes() const;
62 virtual std::set<G4UserLimits*> GetAllUserLimits() const;
63 virtual std::set<BDSGeometryComponent*> GetAllDaughters() const;
64 virtual std::set<G4VSolid*> GetAllSolids() const;
65 virtual std::set<G4LogicalVolume*> GetAllLogicalVolumes() const;
66 virtual std::map<G4LogicalVolume*, BDSSDType> GetAllSensitiveVolumes() const;
67 virtual std::set<G4LogicalVolume*> GetAllBiasingVolumes() const;
68 virtual void ExcludeLogicalVolumeFromBiasing(G4LogicalVolume* lv);
69 virtual void AttachSensitiveDetectors();
71
72protected:
75 virtual void Build();
76
78 virtual void BuildContainerLogicalVolume();
79
80private:
82 BDSElement& operator=(const BDSElement&) = delete;
85
86 G4double horizontalWidth;
87 G4String geometryFileName;
88 std::vector<G4String> namedVacuumVolumes;
89 G4bool autoColourGeometry;
90 G4bool markAsCollimator;
91 G4bool stripOuterVolume;
92
95};
96
97#endif
Abstract class that represents a component of an accelerator.
const G4double arcLength
Const protected member variable that may not be changed by derived classes.
const G4String name
Const protected member variable that may not be changed by derived classes.
G4double angle
Protected member variable that can be modified by derived classes.
A class for a generic piece of external geometry.
Definition: BDSElement.hh:39
virtual std::set< BDSGeometryComponent * > GetAllDaughters() const
Overloads of functions in BDSGeometryComponent.
Definition: BDSElement.cc:158
virtual std::set< G4VSolid * > GetAllSolids() const
Overloads of functions in BDSGeometryComponent.
Definition: BDSElement.cc:163
virtual void ExcludeLogicalVolumeFromBiasing(G4LogicalVolume *lv)
Overloads of functions in BDSGeometryComponent.
Definition: BDSElement.cc:183
BDSElement & operator=(const BDSElement &)=delete
Assignment and copy constructor not implemented nor used.
BDSGeometryExternal * geometry
Cache of the constructed geometry. Used to forward onto various BDSGeometryComponent functions.
Definition: BDSElement.hh:94
BDSElement(BDSElement &)=delete
Assignment and copy constructor not implemented nor used.
virtual std::set< G4LogicalVolume * > GetAllBiasingVolumes() const
Overloads of functions in BDSGeometryComponent.
Definition: BDSElement.cc:173
virtual void Build()
Definition: BDSElement.cc:57
virtual void BuildContainerLogicalVolume()
This does the full construction. Loads the external geometry and field if there is one.
Definition: BDSElement.cc:65
virtual std::set< G4UserLimits * > GetAllUserLimits() const
Overloads of functions in BDSGeometryComponent.
Definition: BDSElement.cc:153
virtual void AttachSensitiveDetectors()
Overloads of functions in BDSGeometryComponent.
Definition: BDSElement.cc:189
virtual std::map< G4LogicalVolume *, BDSSDType > GetAllSensitiveVolumes() const
Overloads of functions in BDSGeometryComponent.
Definition: BDSElement.cc:178
virtual std::set< G4LogicalVolume * > GetAllLogicalVolumes() const
Overloads of functions in BDSGeometryComponent.
Definition: BDSElement.cc:168
virtual std::set< G4VisAttributes * > GetAllVisAttributes() const
Overloads of functions in BDSGeometryComponent.
Definition: BDSElement.cc:148
virtual std::set< G4RotationMatrix * > GetAllRotationMatrices() const
Overloads of functions in BDSGeometryComponent.
Definition: BDSElement.cc:143
virtual std::set< G4VPhysicalVolume * > GetAllPhysicalVolumes() const
Overloads of functions in BDSGeometryComponent.
Definition: BDSElement.cc:138
A loaded piece of externally provided geometry.