SQLamarr
The stand-alone ultra-fast simulation option for the LHCb experiment
SQLamarr::AbsDataLoader Class Reference

Abstract Interface for loading data to the internal database. More...

#include <AbsDataLoader.h>

Inheritance diagram for SQLamarr::AbsDataLoader:

Public Member Functions

 BaseSqlInterface (SQLite3DB &db)
 Constructor, acquiring the database without ownership. More...
 
- Public Member Functions inherited from SQLamarr::BaseSqlInterface
 BaseSqlInterface (SQLite3DB &db)
 Constructor, acquiring the database without ownership. More...
 
virtual ~BaseSqlInterface ()
 
void sync_database (const std::string &db_uri)
 
void invalidate_cache (void)
 Invalidate the cache of the queries. More...
 

Protected Member Functions

int insert_event (const std::string &data_source, uint64_t run_number, uint64_t evt_number)
 Insert data source reference in the DataSources table. More...
 
int insert_collision (int datasource_id, int collision, float t, float x, float y, float z)
 Insert a collision in the GenEvent table. More...
 
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 More...
 
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. More...
 
- Protected Member Functions inherited from SQLamarr::BaseSqlInterface
sqlite3_stmt * get_statement (const std::string &name, const std::string &query)
 Creates or retrieve from cache a statement. More...
 
void begin_transaction ()
 Begin an SQL transaction stopping update to disk util end_transaction() is issued
More...
 
void end_transaction ()
 End an SQL transaction re-enabling disk updates. More...
 
int last_insert_row ()
 Return the index of the last rows inserted in any table. More...
 
void using_sql_function (const std::string &name, int argc, void(*xFunc)(sqlite3_context *, int, sqlite3_value **))
 Register a static function in DB, enabling usage from SQL. More...
 
bool exec_stmt (sqlite3_stmt *)
 Execute a statement, possibly throwing an exception on failure. More...
 

Additional Inherited Members

- Protected Attributes inherited from SQLamarr::BaseSqlInterface
SQLite3DBm_database
 Reference to the SQLite database (not owned). More...
 

Detailed Description

Abstract Interface for loading data to the internal database.

AbsDataLoader provides a generic interface to load generator-level data to the database from external sources.

The input data follows the schema of the HepMC data format with generator-level vertices (GenVertex) nodes connected by generator-level particles (GenParticle). Each particle connects at most two vertices:

  • a production_vertex representing the origin of the particle;
  • an end_vertex representing the end of the particle trajectory.

Each GenVertex may have multiple input and multiple output particles.

In the HepMC standard, vertices and particles belonging to the same graph are grouped in a GenEvent object. Unfortunately, in LHCb as in most experiments with accelerators, the word "event" refers to a time-slice corresponding to a bunch crossing and may include multiple concurrent collisions, each resulting in an independent graph.

In Lamarr, we stick to such a naming convention:

  • what HepMC names as GenEvent, in Lamarr is a collision
  • a collection of simultaneous GenEvents due to pile-up, is an event.

AbsDataLoader should be implemented to provide the logic for loading the data, without the need of re-implementing the interactions with the database.

Definition at line 53 of file AbsDataLoader.h.

Member Function Documentation

◆ BaseSqlInterface()

SQLamarr::BaseSqlInterface::BaseSqlInterface

Constructor, acquiring the database without ownership.

Definition at line 38 of file BaseSqlInterface.cpp.

◆ insert_collision()

int SQLamarr::AbsDataLoader::insert_collision ( int  datasource_id,
int  collision,
float  t,
float  x,
float  y,
float  z 
)
protected

Insert a collision in the GenEvent table.

Coordinates represent the origin of the event enabling global and rigid translation of the whole decay tree.

Parameters
datasource_idUnique identifier of the HEP event
collisionHepMC identifier of the `GenEvent`
tTime coordinate
xx coordinate
yy coordinate
zz coordinate

◆ insert_event()

int SQLamarr::AbsDataLoader::insert_event ( const std::string &  data_source,
uint64_t  run_number,
uint64_t  evt_number 
)
protected

Insert data source reference in the DataSources table.

Parameters
data_sourceUnique identifer of the data source, e.g. a file path
run_numberUnique identifier of the run
evt_numberUnique identifier of the event

◆ insert_particle()

int SQLamarr::AbsDataLoader::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 
)
protected

Insert a particle in the GenParticles table.

Parameters
genevent_idGlobal identifier of the collision
hepmc_idHepMC identifier of the particle
production_vertexGlobal identifier of the production vertex
end_vertexGlobal identifier of the end vertex
pidPDG Identifier of the particle type
statusHepMC status value
peEnergy of the particle
px*x* coordinate of the momentum
py*y* coordinate of the momentum
pz*z* coordinate of the momentum
mGenerated mass which in HepMC may differ from \(\sqrt{e^2-p^2}\) for resonances

◆ insert_vertex()

int SQLamarr::AbsDataLoader::insert_vertex ( int  genevent_id,
int  hepmc_id,
int  status,
float  t,
float  x,
float  y,
float  z,
bool  is_primary 
)
protected

Insert a vertex in the GenVertices

Parameters
genevent_idGlobal identifier of the collision
hepmc_idHepMC identifier of the vertex
statusHepMC status
tVertex time coordinate
xVertex *x* coordinate
yVertex *y* coordinate
zVertex *z* coordinate
is_primaryBoolean flag identifying primary vertices

The documentation for this class was generated from the following file: