Belle II Software  release-05-02-19
GeometryManager.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef GEOMETRYMANAGER_H
12 #define GEOMETRYMANAGER_H
13 
14 #include <vector>
15 #include <set>
16 #include <string>
17 #include <memory>
18 #include <map>
19 
20 class G4VPhysicalVolume;
21 class G4VisAttributes;
22 
23 namespace Belle2 {
29  class GearDir;
30  class GeoConfiguration;
31  class IntervalOfValidity;
32 
33  namespace geometry {
34  class CreatorBase;
35 
43  };
44 
51  public:
53  static GeometryManager& getInstance();
54 
59  G4VPhysicalVolume* getTopVolume() { return m_topVolume; }
60 
71  void createGeometry(const GearDir& params, GeometryTypes type = FullGeometry);
72 
84  void createGeometry(const GeoConfiguration& params, GeometryTypes type = FullGeometry, bool useDB = true);
85 
91  GeoConfiguration createGeometryConfig(const GearDir& detectorDir, const IntervalOfValidity& iov);
92 
100  void setDetectorComponents(const std::vector<std::string>& components)
101  {
102  m_components.clear();
103  m_components.insert(components.begin(), components.end());
104  }
105 
112  void setExcludedComponents(const std::vector<std::string>& components)
113  {
114  m_excluded.clear();
115  m_excluded.insert(components.begin(), components.end());
116  }
117 
127  void setAdditionalComponents(const std::vector<std::string>& components)
128  {
129  m_additional.clear();
130  m_additional.insert(components.begin(), components.end());
131  }
132 
136  void setDensityScaling(const std::map<std::string, double>& components)
137  {
138  m_densityScaling = components;
139  }
140 
145  void setAssignRegions(bool assignRegions)
146  {
147  m_assignRegions = assignRegions;
148  }
149 
153  void clear();
154 
163 
169  G4VisAttributes* newVisAttributes();
170 
171  private:
175  GeometryManager(const GeometryManager&) = delete;
177  GeometryManager& operator=(const GeometryManager&) = delete;
180 
182  G4VPhysicalVolume* m_topVolume;
184  std::vector<CreatorBase*> m_creators;
186  std::set<std::string> m_components;
188  std::set<std::string> m_excluded;
190  std::set<std::string> m_additional;
192  std::map<std::string, double> m_densityScaling;
196  bool m_assignRegions {false};
198  std::vector<G4VisAttributes*> m_VisAttributes;
200  friend struct std::default_delete<GeometryManager>;
201  };
202 
203  }
204 
206 } //Belle2 namespace
207 #endif //GEOMETRYMANAGER_H
Belle2::IntervalOfValidity
A class that describes the interval of experiments/runs for which an object in the database is valid.
Definition: IntervalOfValidity.h:35
Belle2::geometry::GeometryManager::createGeometry
void createGeometry(const GearDir &params, GeometryTypes type=FullGeometry)
Create Geometry.
Definition: GeometryManager.cc:221
Belle2::GeoConfiguration
configuration of the geometry
Definition: GeoConfiguration.h:33
Belle2::geometry::GeometryManager::operator=
GeometryManager & operator=(const GeometryManager &)=delete
Assignment operator declared private since class is a Singleton.
Belle2::geometry::GeometryManager::getTopVolume
G4VPhysicalVolume * getTopVolume()
Return a pointer to the top volume.
Definition: GeometryManager.h:59
Belle2::geometry::GeometryManager::GeometryManager
GeometryManager()
Default constructor declared private since class is a Singleton.
Definition: GeometryManager.h:173
Belle2::geometry::GeometryManager::getInstance
static GeometryManager & getInstance()
Return a reference to the instance.
Definition: GeometryManager.cc:98
Belle2::geometry::GeometryManager::clear
void clear()
Delete the existing Geant4 Geometry.
Definition: GeometryManager.cc:104
Belle2::geometry::GeometryManager::createTGeoRepresentation
void createTGeoRepresentation()
Create a TGeo representation of the native geometry description.
Definition: GeometryManager.cc:351
Belle2::geometry::GeometryManager::setExcludedComponents
void setExcludedComponents(const std::vector< std::string > &components)
Set the names of the components to exclude from creation.
Definition: GeometryManager.h:112
Belle2::geometry::TrackingGeometry
@ TrackingGeometry
Simplified geometry for tracking purposes.
Definition: GeometryManager.h:41
Belle2::geometry::GeometryManager
Class to manage the creation and conversion of the geometry.
Definition: GeometryManager.h:50
Belle2::geometry::FullGeometry
@ FullGeometry
Full geometry for simulation.
Definition: GeometryManager.h:40
Belle2::geometry::GeometryManager::m_densityScaling
std::map< std::string, double > m_densityScaling
Scaling factors for densities.
Definition: GeometryManager.h:192
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::geometry::DisplayGeometry
@ DisplayGeometry
Simplified geometry for display purposes.
Definition: GeometryManager.h:42
Belle2::GearDir
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:41
Belle2::geometry::GeometryManager::setAdditionalComponents
void setAdditionalComponents(const std::vector< std::string > &components)
Set the names of addtional components to be added to the default set.
Definition: GeometryManager.h:127
Belle2::geometry::GeometryManager::createGeometryConfig
GeoConfiguration createGeometryConfig(const GearDir &detectorDir, const IntervalOfValidity &iov)
Create Geometry configuration object.
Definition: GeometryManager.cc:124
Belle2::geometry::GeometryManager::newVisAttributes
G4VisAttributes * newVisAttributes()
Create an anonymous G4VisAttributes for an existing G4LogicalVolume.
Definition: GeometryManager.cc:374
Belle2::geometry::GeometryManager::m_VisAttributes
std::vector< G4VisAttributes * > m_VisAttributes
List of visualization attributes.
Definition: GeometryManager.h:198
Belle2::geometry::GeometryManager::setAssignRegions
void setAssignRegions(bool assignRegions)
Choose whether a region should be assigned to each creator.
Definition: GeometryManager.h:145
Belle2::geometry::GeometryManager::m_components
std::set< std::string > m_components
List of names of components to be created, all other components will be ignored.
Definition: GeometryManager.h:186
Belle2::geometry::GeometryManager::setDensityScaling
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...
Definition: GeometryManager.h:136
Belle2::geometry::GeometryManager::m_topVolume
G4VPhysicalVolume * m_topVolume
Pointer to the top volume of the native geometry description.
Definition: GeometryManager.h:182
Belle2::geometry::GeometryManager::~GeometryManager
~GeometryManager()
Destructor: make sure we clean up memory at the end.
Definition: GeometryManager.h:179
Belle2::geometry::GeometryManager::m_excluded
std::set< std::string > m_excluded
List of names of components to be excluded from creation.
Definition: GeometryManager.h:188
Belle2::geometry::GeometryManager::m_additional
std::set< std::string > m_additional
List of additional components to be added to the default set of components.
Definition: GeometryManager.h:190
Belle2::geometry::GeometryManager::setDetectorComponents
void setDetectorComponents(const std::vector< std::string > &components)
Set the names of the components to create.
Definition: GeometryManager.h:100
Belle2::geometry::GeometryTypes
GeometryTypes
Flag indiciating the type of geometry to be used.
Definition: GeometryManager.h:39
Belle2::geometry::GeometryManager::m_creators
std::vector< CreatorBase * > m_creators
List of all creators, to be freed when geometry is destucted.
Definition: GeometryManager.h:184
Belle2::geometry::GeometryManager::m_assignRegions
bool m_assignRegions
Bool to indicate whether we automatically assign a region with the creator name to all volumes create...
Definition: GeometryManager.h:196