12void GSystemSQLiteFactory::loadGeometry(
GSystem* system) {
17 if (db ==
nullptr) { initialize_sqlite_db(system); }
23 const char* sql_query =
24 "SELECT DISTINCT * FROM geometry WHERE experiment = ? AND system = ? AND variation = ? AND run = ?";
25 sqlite3_stmt* stmt =
nullptr;
26 int rc = sqlite3_prepare_v2(db, sql_query, -1, &stmt,
nullptr);
27 if (rc != SQLITE_OK) {
29 sqlite3_errmsg(db),
" (", rc,
") using query: ", sql_query);
34 std::string system_name = system->
getName();
38 rc = sqlite3_bind_text(stmt, 1, experiment.c_str(), -1, SQLITE_STATIC);
39 if (rc != SQLITE_OK) {
42 rc = sqlite3_bind_text(stmt, 2, system_name.c_str(), -1, SQLITE_STATIC);
43 if (rc != SQLITE_OK) {
46 rc = sqlite3_bind_text(stmt, 3, variation.c_str(), -1, SQLITE_STATIC);
47 if (rc != SQLITE_OK) {
50 rc = sqlite3_bind_int(stmt, 4, runno);
51 if (rc != SQLITE_OK) {
56 if (
auto sql = sqlite3_expanded_sql(stmt)) {
62 std::vector<std::string> gvolumePars;
63 while ((rc = sqlite3_step(stmt)) == SQLITE_ROW) {
64 int colCount = sqlite3_column_count(stmt);
65 for (
int i = 0; i < colCount; i++) {
66 const char* colName = sqlite3_column_name(stmt, i);
67 const unsigned char* colText = sqlite3_column_text(stmt, i);
69 log->
info(2,
"<sqlite> column: ", (colName ? colName :
"NULL"),
" = ",
70 (colText ? reinterpret_cast<const char*>(colText) :
"NULL"),
" (column ", i,
")");
74 colText = sqlite3_column_text(stmt, i);
75 gvolumePars.emplace_back(colText ?
reinterpret_cast<const char*
>(colText) :
"");
82 if (rc != SQLITE_DONE) {
84 sqlite3_errmsg(db),
" (", rc,
")");
87 sqlite3_finalize(stmt);
std::shared_ptr< GLogger > log
void info(int level, Args &&... args) const
void error(int exit_code, Args &&... args) const
Represents a single detector system (e.g., calorimeter, tracker).
std::string getExperiment() const
std::string getVariation() const
void addGVolume(std::vector< std::string > pars)
Build and add a volume from a serialized parameter list.
std::string getName() const
Conventions and shared constants for the detector-system module.
#define ROOTWORLDGVOLUMENAME
Canonical name for the ROOT/world gvolume entry.