11 #include "SQLamarr/PVFinder.h"
12 #include "SQLamarr/preprocessor_symbols.h"
19 , m_signal_status_code (signal_status_code)
24 sqlite3_stmt* make_pv_from_signal =
get_statement(
"make_pv_from_signal", R
"(
38 FIRST_VALUE(production_vertex)
39 OVER (PARTITION BY genevent_id ORDER BY hepmc_id ASC) AS root_vtx
49 INNER JOIN noPV_events AS pv ON v.genevent_id = pv.genevent_id
50 INNER JOIN signal_root AS p ON p.root_vtx = v.genvertex_id
56 SELECT NULL FROM selected_vertices
57 WHERE selected_vertices.genvertex_id = GenVertices.genvertex_id
61 sqlite3_stmt* make_pv_from_barcode = get_statement("make_pv_from_barcode", R
"(
75 FIRST_VALUE(production_vertex)
76 OVER (PARTITION BY genevent_id ORDER BY hepmc_id ASC) AS root_vtx
85 INNER JOIN noPV_events AS pv ON v.genevent_id = pv.genevent_id
86 INNER JOIN signal_root AS p ON p.root_vtx = v.genvertex_id
92 SELECT NULL FROM selected_vertices
93 WHERE selected_vertices.genvertex_id = GenVertices.genvertex_id
99 INSERT INTO MCVertices (
100 genvertex_id, genevent_id,
105 v.genvertex_id, v.genevent_id,
106 v.status, v.is_primary,
111 FROM GenVertices AS v
112 INNER JOIN GenEvents AS e ON e.genevent_id = v.genevent_id
115 GROUP BY v.genevent_id
117 v.hepmc_id == MAX(v.hepmc_id);
121 sqlite3_stmt* count_missing_PVs = get_statement("count_missing_PVs", R
"(
122 SELECT COUNT(genevent_id)
130 if (sqlite3_column_int(count_missing_PVs, 0))
132 sqlite3_bind_int(make_pv_from_signal, 1, m_signal_status_code);
136 sqlite3_reset(count_missing_PVs);
138 if (sqlite3_column_int(count_missing_PVs, 0))
Abstract interface with helper functions to access an SQLite DB.
sqlite3_stmt * get_statement(const std::string &name, const std::string &query)
Creates or retrieve from cache a statement.
bool exec_stmt(sqlite3_stmt *)
Execute a statement, possibly throwing an exception on failure.
PVFinder(SQLite3DB &db, int signal_status_code=889)
Constructor, with configurable signal status code.
void execute() override
Execute the algorithm.
A database connection handler easying sharing the DB between C++ and Python.