15 #include "SQLamarr/AbsDataLoader.h"
16 #include "SQLamarr/db_functions.h"
17 #include "SQLamarr/preprocessor_symbols.h"
25 const std::string& datasource,
31 "INSERT INTO DataSources(datasource, run_number, evt_number) "
35 sqlite3_bind_text (stmt, 1, datasource.c_str(), datasource.length()+1, SQLITE_TRANSIENT);
36 sqlite3_bind_int64(stmt, 2, run_number);
37 sqlite3_bind_int64(stmt, 3, evt_number);
58 "INSERT INTO GenEvents(datasource_id, collision, x, y, z, t) "
59 "VALUES (?, ?, ?, ?, ?, ?) "
62 sqlite3_bind_int(stmt, 1, datasource_id);
63 sqlite3_bind_int(stmt, 2, collision);
64 sqlite3_bind_double(stmt, 3, x);
65 sqlite3_bind_double(stmt, 4, y);
66 sqlite3_bind_double(stmt, 5, z);
67 sqlite3_bind_double(stmt, 6, t);
90 "INSERT INTO GenVertices"
91 " (genevent_id, hepmc_id, status, x, y, z, t, is_primary) "
92 "VALUES (?, ?, ?, ?, ?, ?, ?, ?) "
95 sqlite3_bind_int(stmt, 1, genevent_id);
96 sqlite3_bind_int(stmt, 2, hepmc_id);
97 sqlite3_bind_int(stmt, 3, status);
98 sqlite3_bind_double(stmt, 4, x);
99 sqlite3_bind_double(stmt, 5, y);
100 sqlite3_bind_double(stmt, 6, z);
101 sqlite3_bind_double(stmt, 7, t);
102 sqlite3_bind_int(stmt, 8,
int(is_primary));
115 int production_vertex,
127 INSERT INTO GenParticles(
128 genevent_id, hepmc_id,
129 production_vertex, end_vertex,
133 VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); "
137 sqlite3_bind_int(stmt, iVar++, genevent_id);
138 sqlite3_bind_int(stmt, iVar++, hepmc_id);
140 if (production_vertex != LAMARR_BAD_INDEX)
141 sqlite3_bind_int(stmt, iVar++, production_vertex);
144 sqlite3_bind_null(stmt, iVar++);
147 if (end_vertex != LAMARR_BAD_INDEX)
148 sqlite3_bind_int(stmt, iVar++, end_vertex);
150 sqlite3_bind_null(stmt, iVar++);
152 sqlite3_bind_int(stmt, iVar++, pid);
153 sqlite3_bind_int(stmt, iVar++, status);
154 sqlite3_bind_double(stmt, iVar++, pe);
155 sqlite3_bind_double(stmt, iVar++, px);
156 sqlite3_bind_double(stmt, iVar++, py);
157 sqlite3_bind_double(stmt, iVar++, pz);
158 sqlite3_bind_double(stmt, iVar++, m);
int insert_collision(int datasource_id, int collision, float t, float x, float y, float z)
Insert a collision in the GenEvent table.
int insert_particle(int genevent_id, int hepmc_id, int production_vertex, int end_vertex, int pid, int status, float pe, float px, float py, float pz, float m)
Insert a particle in the GenParticles table.
int insert_vertex(int genevent_id, int hepmc_id, int status, float t, float x, float y, float z, bool is_primary)
Insert a vertex in the GenVertices
int insert_event(const std::string &data_source, uint64_t run_number, uint64_t evt_number)
Insert data source reference in the DataSources table.
sqlite3_stmt * get_statement(const std::string &name, const std::string &query)
Creates or retrieve from cache a statement.
int last_insert_row()
Return the index of the last rows inserted in any table.
bool exec_stmt(sqlite3_stmt *)
Execute a statement, possibly throwing an exception on failure.