Belle II Software development
GeometryManager.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <vector>
12#include <set>
13#include <string>
14#include <memory>
15#include <map>
16
17class G4VPhysicalVolume;
18class G4VisAttributes;
19
20namespace Belle2 {
26 class GearDir;
27 class GeoConfiguration;
28 class IntervalOfValidity;
29
30 namespace geometry {
31 class CreatorBase;
32
40 };
41
48 public:
51
56 G4VPhysicalVolume* getTopVolume() { return m_topVolume; }
57
68 void createGeometry(const GearDir& params, GeometryTypes type = FullGeometry);
69
81 void createGeometry(const GeoConfiguration& params, GeometryTypes type = FullGeometry, bool useDB = true);
82
90
98 void setDetectorComponents(const std::vector<std::string>& components)
99 {
100 m_components.clear();
101 m_components.insert(components.begin(), components.end());
102 }
103
110 void setExcludedComponents(const std::vector<std::string>& components)
111 {
112 m_excluded.clear();
113 m_excluded.insert(components.begin(), components.end());
114 }
115
125 void setAdditionalComponents(const std::vector<std::string>& components)
126 {
127 m_additional.clear();
128 m_additional.insert(components.begin(), components.end());
129 }
130
134 void setDensityScaling(const std::map<std::string, double>& components)
135 {
136 m_densityScaling = components;
137 }
138
143 void setAssignRegions(bool assignRegions)
144 {
145 m_assignRegions = assignRegions;
146 }
147
151 void clear();
152
161
167 G4VisAttributes* newVisAttributes();
168
169 private:
178
180 G4VPhysicalVolume* m_topVolume;
182 std::vector<CreatorBase*> m_creators;
184 std::set<std::string> m_components;
186 std::set<std::string> m_excluded;
188 std::set<std::string> m_additional;
190 std::map<std::string, double> m_densityScaling;
194 bool m_assignRegions {false};
196 std::vector<G4VisAttributes*> m_VisAttributes;
198 friend struct std::default_delete<GeometryManager>;
199 };
200
201 }
202
204} //Belle2 namespace
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
configuration of the geometry
A class that describes the interval of experiments/runs for which an object in the database is valid.
Class to manage the creation and conversion of the geometry.
G4VisAttributes * newVisAttributes()
Create an anonymous G4VisAttributes for an existing G4LogicalVolume.
void setDetectorComponents(const std::vector< std::string > &components)
Set the names of the components to create.
void setAssignRegions(bool assignRegions)
Choose whether a region should be assigned to each creator.
G4VPhysicalVolume * m_topVolume
Pointer to the top volume of the native geometry description.
void setExcludedComponents(const std::vector< std::string > &components)
Set the names of the components to exclude from creation.
bool m_assignRegions
Bool to indicate whether we automatically assign a region with the creator name to all volumes create...
GeometryManager(const GeometryManager &)=delete
Copy constructor declared private since class is a Singleton.
~GeometryManager()
Destructor: make sure we clean up memory at the end.
std::vector< G4VisAttributes * > m_VisAttributes
List of visualization attributes.
G4VPhysicalVolume * getTopVolume()
Return a pointer to the top volume.
GeoConfiguration createGeometryConfig(const GearDir &detectorDir, const IntervalOfValidity &iov)
Create Geometry configuration object.
std::set< std::string > m_components
List of names of components to be created, all other components will be ignored.
std::set< std::string > m_additional
List of additional components to be added to the default set of components.
void createGeometry(const GearDir &params, GeometryTypes type=FullGeometry)
Create Geometry.
std::set< std::string > m_excluded
List of names of components to be excluded from creation.
std::vector< CreatorBase * > m_creators
List of all creators, to be freed when geometry is destucted.
void clear()
Delete the existing Geant4 Geometry.
static GeometryManager & getInstance()
Return a reference to the instance.
GeometryManager & operator=(const GeometryManager &)=delete
Assignment operator declared private since class is a Singleton.
GeometryManager()
Default constructor declared private since class is a Singleton.
void setAdditionalComponents(const std::vector< std::string > &components)
Set the names of addtional components to be added to the default set.
void createTGeoRepresentation()
Create a TGeo representation of the native geometry description.
std::map< std::string, double > m_densityScaling
Scaling factors for densities.
void setDensityScaling(const std::map< std::string, double > &components)
Set the density scaling: This is intended for systematic studies only and will scale the density of a...
GeometryTypes
Flag indiciating the type of geometry to be used.
@ TrackingGeometry
Simplified geometry for tracking purposes.
@ FullGeometry
Full geometry for simulation.
@ DisplayGeometry
Simplified geometry for display purposes.
Abstract base class for different kinds of events.