Introduction
The dbselect module provides a Qt widget (DBSelectView) that presents experiments and system variations retrieved from an SQLite database. Users can enable/disable system variations and choose the corresponding run, then trigger a geometry reload through a supplied GDetectorConstruction instance.
The typical flow is:
Ownership and lifecycle
Ownership and responsibilities are intentionally separated:
DBSelectView owns its UI elements (Qt parent/child ownership) and manages the SQLite handle (sqlite3*) opened read-only.
DBSelectView does not own the provided GDetectorConstruction pointer; it is treated as an external service used to reload geometry.
- The selection state is stored in the Qt model (
QStandardItemModel) and mirrored into a SystemList only when requested.
Lifecycle notes:
- The database is opened during
DBSelectView construction and closed in the destructor.
- Changes in the model mark the view as “modified” and enable the Reload button.
- Calling reload_geometry() rebuilds the SystemList, invokes geometry reload on the detector construction, then clears the modified flag.
Architecture
Design notes
Internally the view is a thin integration of three concerns:
- Data source: an SQLite database containing a
geometry table with at least the columns used by the queries (experiment/system/variation/run).
- Selection model: a
QStandardItemModel with four columns:
- column 0: experiment or system name (checkable)
- column 1: entry count (computed from the database)
- column 2: variation represented by the row
- column 3: run (edited via a drop-down delegate)
- Application bridge: translating checked systems into a SystemList of
GSystem objects via get_gsystems().
UI behavior:
- Selecting an experiment checks only one experiment at a time.
- Enabling a system variation shows an availability indicator (green/red icon) driven by the computed count of matching geometry entries.
- Changing run recomputes counts and availability.
Available Options and their usage
This module reads the following option keys from the runtime option provider:
sql
- Type: string
- Meaning: path (or identifier) of the SQLite database file to open (read-only)
- Behavior:
- the database is opened during
DBSelectView construction
- the value is also used as the default geometry source when building a
SystemList
- Note: this key is commonly provided by the aggregated gsystem/g4system option sets.
experiment
- Type: string
- Meaning: default experiment name to preselect in the view
- Behavior:
- when present, the view attempts to select that experiment on startup
- if the experiment is not found, the view falls back to the first available experiment
gui
- Type: boolean (switch)
- Meaning: enable GUI execution path for examples / host applications
- Behavior:
- when
true, example programs typically start a Qt event loop and show the widget
- when
false, examples may run in CLI mode (no widget created)
- Note: this switch is defined by GOptions(argc,argv,...) and is globally available.
This module’s option schema is composed by dbselect::defineOptions(), which aggregates:
Additional keys contributed by gdetector::defineOptions() may affect detector construction and geometry reload behavior. Refer to the gdetector documentation for the full list.
Module verbosity
The module uses the logger name "dbselect".
Typical conventions used in this module:
- Level 0: high-level lifecycle messages (startup, mode selection, geometry reload trigger).
- Level 1: environment and configuration messages (database opened and resolved location).
- Level 2: detailed selection and rebuild information (systems being added and reloaded).
- Debug: reserved for verbose troubleshooting (not used directly in the provided sources).
Examples
test_dbselect
Summary: The test_dbselect example demonstrates how to instantiate a GOptions configuration for dbselect, optionally start a Qt GUI, and trigger a geometry reload from the view.
Example snippet:
if (gopts->getSwitch("gui")) {
window->show();
}
Qt widget used to select experiment/system configurations from an SQLite geometry database.
Namespace containing dbselect module functions.
GOptions defineOptions()
Define and return the option set used by the dbselect module.