gsystem
Loading...
Searching...
No Matches
gsystem_options.cc
Go to the documentation of this file.
1
7
8// gemc
9#include "gfactory_options.h"
10
11// gsystem
12#include "gsystem_options.h"
13#include "gsystemConventions.h"
14
15// project goption to a system
16namespace gsystem {
17// See gsystem_options.h for API docs.
18SystemList getSystems(const std::shared_ptr<GOptions>& gopts) {
19 auto gsystem_node = gopts->getOptionNode("gsystem");
20
21 SystemList systems;
22 systems.reserve(gsystem_node.size());
23
24 auto exp = gopts->getRequiredScalarString("experiment");
25 auto run = gopts->getRequiredScalarInt("runno");
26 auto dbhost = gopts->getRequiredScalarString("sql");
27 auto ascii_db = gopts->getRequiredScalarString("ascii_db");
28
29 for (auto gsystem_item : gsystem_node) {
30 auto factory = gopts->get_variable_in_option<std::string>(gsystem_item, "factory",
32
33 // ASCII factory can use an alternate search root (ascii_db).
34 if (factory == gsystem::GSYSTEMASCIIFACTORYLABEL) { dbhost = ascii_db; }
35
36 systems.emplace_back(
37 std::make_shared<GSystem>(
38 gopts,
39 dbhost,
40 gopts->get_required_variable_in_option<std::string>(gsystem_item, "name"),
41 factory,
42 exp,
43 run,
44 gopts->get_variable_in_option<std::string>(gsystem_item, "variation", "default"),
45 gopts->get_optional_variable_in_option<std::string>(gsystem_item, "annotations")
46 ));
47 }
48
49 return systems;
50}
51
52
53// See gsystem_options.h for API docs.
54std::vector<GModifier> getModifiers(const std::shared_ptr<GOptions>& gopts) {
55 std::vector<GModifier> gmods;
56
57 auto gmodifier_node = gopts->getOptionNode("gmodifier");
58
59 for (auto gmodifier_item : gmodifier_node) {
60 gmods.emplace_back(
61 gopts->get_required_variable_in_option<std::string>(gmodifier_item, "name"),
62 gopts->get_optional_variable_in_option<std::string>(gmodifier_item, "shift"),
63 gopts->get_optional_variable_in_option<std::string>(gmodifier_item, "tilt"),
64 gopts->get_variable_in_option<bool>(gmodifier_item, "isPresent", true));
65 }
66
67 return gmods;
68}
69
70
71// See gsystem_options.h for API docs.
79
80 // System
81 std::string help;
82 help = "A system definition includes the geometry location, factory and variation \n \n";
83 help += "Possible factories are: \n";
84 help += " - " + std::string(gsystem::GSYSTEMASCIIFACTORYLABEL) + "\n";
85 help += " - " + std::string(gsystem::GSYSTEMSQLITETFACTORYLABEL) + "\n";
86 help += " - " + std::string(gsystem::GSYSTEMMYSQLTFACTORYLABEL) + "\n";
87 help += " - " + std::string(gsystem::GSYSTEMCADTFACTORYLABEL) + "\n";
88 help +=
89 R"RAWS(Example: -gsystem="[{name: b1}]")RAWS";
90
91 std::vector<GVariable> gsystem = {
92 {"name", goptions::REQUIRED,
93 "system name (mandatory). For ascii factories, it may include the path to the file"},
94 {"factory", gsystem::GSYSTEMSQLITETFACTORYLABEL, "factory name."},
95 {"variation", "default", "geometry variation"},
96 {"annotations", std::nullopt,
97 "optional system annotations. Examples: \"mats_only\" "},
98 {"digitization", std::nullopt,
99 "optional digitization plugin name when it differs from the system name (shared plugin, e.g. \"ecal\" "
100 "for the EC and PCAL systems)"}};
101 goptions.defineOption(GSYSTEM_LOGGER, "defines the group of volumes in a system", gsystem, help);
102
103 // Modifier
104 help = "The volume modifier can shift, tilt, or delete a volume from the gworld \n \n";
105 help += R"RAWS(Example: -gmodifier="[{name: targetCell, tilt: '0*deg, 0*deg, -10*deg'}]")RAWS";
106
107 std::vector<GVariable> gmodifier = {
108 {"name", goptions::REQUIRED, "volume name (mandatory)"},
109 {"shift", std::nullopt, "volume shift added to existing position"},
110 {"tilt", std::nullopt, "volume tilt added to existing rotation"},
111 {"isPresent", true, "If set to false, remove the volume from the world"}
112 };
113 goptions.defineOption("gmodifier", "modify volume existence or placement", gmodifier, help);
114
115 help = "root volume definition. Default is: " + std::string(gsystem::ROOTDEFINITION) + ". \n\n";
116 help += "Command line Example: -root=\"G4Box 25*cm 24*cm 40*cm G4_WATER\"\n";
117 help += "YAML file example: root: G4Box, 24*cm, 24*cm, 40*cm, G4_WATER\n";
118 goptions.defineOption(
119 GVariable(gsystem::ROOTWORLDGVOLUMENAME, gsystem::ROOTDEFINITION, "root volume definition"), help);
120
121 // add sql option to define host or sqlite file
122 help = "sqlite file or sql host. Default is: " + std::string(gsystem::GSYSTEMSQLITETDEFAULTFILE) + ". \n\n";
123 help += "Example (sqlite file): -sql=myGeometry.sqlite\n";
124 goptions.defineOption(GVariable("sql", gsystem::GSYSTEMSQLITETDEFAULTFILE, "sql host or sqlite file"),
125 help);
126
127 // add ascii_db option to define an alternative search path for the ascii factory
128 help = "ascii search path. Default is: " + std::string(gsystem::GSYSTEMSASCIISEARCHDIR) + ". \n\n";
129 help += "Example: -ascii_db=/path/to/geometry/text/files\n";
130 goptions.defineOption(GVariable("ascii_db", gsystem::GSYSTEMSASCIISEARCHDIR, "ascii factory search path"),
131 help);
132
133 // add the experiment option to define the experiment, common for all systems
134 goptions.defineOption(GVariable("experiment", "examples", "experiment selection"),
135 "Each experiment has a subset of unique systems.\n \nExample: -experiment=clas12\n");
136
137 // add run number options, common for all systems
138 goptions.defineOption(GVariable("runno", 1, "geometry/conditions run number"),
139 "Run number used to select the geometry/conditions variation loaded from the\n"
140 "database; all systems share it. This is distinct from -run, the run number\n"
141 "assigned to generated events.\n \nExample: -runno=11\n");
142
143 return goptions;
144}
145}
run
Conventions and shared constants for the detector-system module.
std::vector< SystemPtr > SystemList
Definition gsystem.h:280
Option definitions and extraction helpers for the gsystem module.
constexpr const char * GSFACTORY_LOGGER
constexpr const char * GSYSTEM_LOGGER
constexpr const char * GVOLUME_LOGGER
constexpr const char * GWORLD_LOGGER
constexpr const char * GMATERIAL_LOGGER
GOptions defineOptions()
constexpr RequiredValue REQUIRED
constexpr char GSYSTEMSQLITETDEFAULTFILE[]
Default sqlite DB filename used when the user does not specify one.
constexpr char GSYSTEMCADTFACTORYLABEL[]
GOptions defineOptions()
Define and return all option groups required by the gsystem module.
constexpr char ROOTDEFINITION[]
constexpr char GSYSTEMMYSQLTFACTORYLABEL[]
constexpr char GSYSTEMSASCIISEARCHDIR[]
Default search directory for ASCII factory files.
constexpr char GSYSTEMSQLITETFACTORYLABEL[]
constexpr char GSYSTEMASCIIFACTORYLABEL[]
std::vector< GModifier > getModifiers(const std::shared_ptr< GOptions > &gopts)
Build a list of volume modifiers from options.
constexpr char ROOTWORLDGVOLUMENAME[]
Canonical name for the ROOT/world gvolume entry.
SystemList getSystems(const std::shared_ptr< GOptions > &gopts)
Build a list of systems from options.