11 #include <geometry/modules/GeometryModule.h>
12 #include <geometry/GeometryManager.h>
13 #include <framework/gearbox/GearDir.h>
14 #include <framework/database/DBImportObjPtr.h>
27 GeometryModule::GeometryModule()
29 setDescription(
"Setup geometry description");
30 setPropertyFlags(c_ParallelProcessingCertified);
32 addParam(
"geometryPath", m_geometryPath,
33 "Path where the parameters for the Geometry can be found",
string(
"/Detector"));
34 addParam(
"geometryType", m_geometryType,
35 "Type of geometry to build. Valid values: Full, Tracking, Display", 0);
36 addParam(
"components", m_components,
37 "Name of the components to be created. If not empty, all other components found "
38 "in the parameter file will be ignored", m_components);
39 addParam(
"excludedComponents", m_excluded,
40 "Name of the components to excluded from creation", m_excluded);
41 addParam(
"additionalComponents", m_additional,
42 "Name of components to be created in addition to the default parameters", m_additional);
43 addParam(
"assignRegions", m_assignRegions,
44 "If true, automatically assign a Geant4 Region with the name of the "
45 "creator to all volumes created by that creator", m_assignRegions);
46 addParam(
"ignoreIfPresent", m_ignoreIfPresent,
47 "If true this module will silently ignore if the geometry is already "
48 "present and do nothing in that case. If false a B2FATAL will be "
49 "if the geometry was already created before", m_ignoreIfPresent);
50 addParam(
"useDB", m_useDB,
"If true load the Geometry from the database instead of the gearbox", m_useDB);
51 addParam(
"payloadIov", m_payloadIov,
"Payload IoV when creating a geometry configuration", m_payloadIov);
52 addParam(
"createPayloads", m_createGeometryPayload,
"If true create a "
53 "Geometry payload with the given configuration", m_createGeometryPayload);
56 void GeometryModule::initialize()
60 if (m_ignoreIfPresent) {
61 B2DEBUG(10,
"Geometry already created, skipping");
64 B2FATAL(
"Geometry already created, more than one Geometry module present?");
69 vector<string> filteredComponents;
70 copy_if(m_components.begin(), m_components.end(),
71 std::back_inserter(filteredComponents), [](
const std::string & component) { return component !=
"TRG"; });
78 if (m_createGeometryPayload) {
79 B2INFO(
"Creating Database configuration.");
80 if (m_payloadIov.size() != 4) {
81 B2ERROR(
"Geometry: payloadIov must be ecactly 4 values: [first experiment, first run, final experiment, final run]");
85 IntervalOfValidity iov(m_payloadIov[0], m_payloadIov[1], m_payloadIov[2], m_payloadIov[3]);
87 B2ERROR(
"Cannot create payloads for an empty iov");
96 if (getParam<std::string>(
"geometryPath").isSetInSteering()) {
97 B2WARNING(
"Loading Geometry from Database: parameter 'geometryPath' is ignored");
99 for (
auto par : {
"components",
"additionalComponents",
"excludedComponents"}) {
100 if (getParam<std::vector<std::string>>(par).isSetInSteering()) {
101 B2WARNING(
"Loading Geometry from Database: parameter '" << par <<
"' is ignored");
105 if (!m_geometryConfig->isValid()) {
106 B2ERROR(
"Cannot create Geometry from Database: no configuration found");
110 m_geometryConfig->addCallback([]() {B2FATAL(
"Geometry cannot change during processing, aborting");});
114 if (!evtMeta.
isValid() or not(evtMeta->getExperiment() == 0 and evtMeta->getRun() == 0)) {
115 B2FATAL(R
"RAW(We no longer allow to disable the database when exp, run != 0, 0
117 If you want to create geometry configuration please create them from the
118 correct set of xml files and test them with exp,run == 0, 0 and then create
119 payloads for the correct iovs.
121 Otherwise just use the database configuration created by the experts.
123 This is for your own protection.)RAW");
126 B2WARNING(R
"RAW(You've decided to disable database for the Geometry.
128 Be aware, this is ONLY VALID for debugging purposes and validation of
131 Do NOT USE THIS just to disable some parts in the geometry.
133 -> This is in any case very dangerous and will result in unrealistic
134 results. If you really want this and really know what you are doing you
135 will have no problems to create and use a custom geometry configuration
136 using the parameter `createPayloads=True`.
138 DEFINITELY don't use this just because it works without internet connection.
140 -> Please just use `b2conditionsdb` to download a snapshot of the global
141 tag you want to use ahead of time. Your results will not be correct if
142 you disable building the geometry from the database configuration
144 YOU HAVE BEEN WARNED!)RAW");
149 void GeometryModule::terminate()
153 delete m_geometryConfig;