9#include <geometry/modules/GeometryModule.h>
10#include <geometry/GeometryManager.h>
11#include <framework/gearbox/GearDir.h>
12#include <framework/database/DBImportObjPtr.h>
31 "Path where the parameters for the Geometry can be found",
string(
"/Detector"));
33 "Type of geometry to build. Valid values: Full, Tracking, Display", 0);
35 "Name of the components to be created. If not empty, all other components found "
38 "Name of the components to excluded from creation",
m_excluded);
40 "Name of components to be created in addition to the default parameters",
m_additional);
42 "If true, automatically assign a Geant4 Region with the name of the "
45 "If true this module will silently ignore if the geometry is already "
46 "present and do nothing in that case. If false a B2FATAL will be "
59 B2DEBUG(10,
"Geometry already created, skipping");
62 B2FATAL(
"Geometry already created, more than one Geometry module present?");
67 vector<string> filteredComponents;
69 std::back_inserter(filteredComponents), [](
const std::string & component) { return component !=
"TRG"; });
77 B2INFO(
"Creating Database configuration.");
79 B2ERROR(
"Geometry: payloadIov must be exactly 4 values: [first experiment, first run, final experiment, final run]");
85 B2ERROR(
"Cannot create payloads for an empty iov");
94 if (getParam<std::string>(
"geometryPath").isSetInSteering()) {
95 B2WARNING(
"Loading Geometry from Database: parameter 'geometryPath' is ignored");
97 for (
auto par : {
"components",
"additionalComponents",
"excludedComponents"}) {
98 if (
getParam<std::vector<std::string>>(par).isSetInSteering()) {
99 B2WARNING(
"Loading Geometry from Database: parameter '" << par <<
"' is ignored");
104 B2ERROR(
"Cannot create Geometry from Database: no configuration found");
108 m_geometryConfig->addCallback([]() {B2FATAL(
"Geometry cannot change during processing, aborting");});
112 if (!evtMeta.
isValid() or not(evtMeta->getExperiment() == 0 and evtMeta->getRun() == 0)) {
113 B2FATAL(R
"RAW(We no longer allow to disable the database when exp, run != 0, 0
115 If you want to create geometry configuration please create them from the
116 correct set of xml files and test them with exp,run == 0, 0 and then create
117 payloads for the correct iovs.
119 Otherwise just use the database configuration created by the experts.
121 This is for your own protection.)RAW");
124 B2WARNING(R
"RAW(You've decided to disable database for the Geometry.
126 Be aware, this is ONLY VALID for debugging purposes and validation of
129 Do NOT USE THIS just to disable some parts in the geometry.
131 -> This is in any case very dangerous and will result in unrealistic
132 results. If you really want this and really know what you are doing you
133 will have no problems to create and use a custom geometry configuration
134 using the parameter `createPayloads=True`.
136 DEFINITELY don't use this just because it works without internet connection.
138 -> Please just use `b2conditionsdb` to download a snapshot of the global
139 tag you want to use ahead of time. Your results will not be correct if
140 you disable building the geometry from the database configuration
142 YOU HAVE BEEN WARNED!)RAW");
Class for importing a single object to the database.
Class for accessing objects in the database.
GearDir is the basic class used for accessing the parameter store.
std::string m_geometryPath
Path for the geometry in the parameter space.
std::vector< std::string > m_components
Components to be created, if empty all components will be created.
void initialize() override
Create geometry.
bool m_assignRegions
Whether or not a region should be assigned to all volumes created by a given creator.
void terminate() override
Clean up the geometry.
std::vector< std::string > m_additional
Components to be added in addition to the default ones.
std::vector< int > m_payloadIov
Payload iov when creating a geometry configuration.
DBObjPtr< GeoConfiguration > * m_geometryConfig
Database object pointing to the geometry configuration in case we load the geometry from database.
bool m_createGeometryPayload
If true we need to create a payload.
std::vector< std::string > m_excluded
Components to excluded from creation.
GeometryModule()
Constructor.
int m_geometryType
Type of the geometry to be built.
bool m_useDB
Whether or not to build the geometry from the database.
bool m_ignoreIfPresent
Whether or not this module will raise an error if the geometry is already present.
A class that describes the interval of experiments/runs for which an object in the database is valid.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Type-safe access to single objects in the data store.
bool isValid() const
Check whether the object was created.
Class to manage the creation and conversion of the geometry.
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.
void setExcludedComponents(const std::vector< std::string > &components)
Set the names of the components to exclude from creation.
G4VPhysicalVolume * getTopVolume()
Return a pointer to the top volume.
GeoConfiguration createGeometryConfig(const GearDir &detectorDir, const IntervalOfValidity &iov)
Create Geometry configuration object.
void createGeometry(const GearDir ¶ms, GeometryTypes type=FullGeometry)
Create Geometry.
void clear()
Delete the existing Geant4 Geometry.
static GeometryManager & getInstance()
Return a reference to the instance.
void setAdditionalComponents(const std::vector< std::string > &components)
Set the names of addtional components to be added to the default set.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
ModuleParam< T > & getParam(const std::string &name) const
Returns a reference to a parameter.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
@ FullGeometry
Full geometry for simulation.
Abstract base class for different kinds of events.