SQLamarr
The stand-alone ultra-fast simulation option for the LHCb experiment
schema.sql
1 /// Schema
2 
3 constexpr char SQL_CREATE_SCHEMA[] = R"(
4 
5  CREATE TABLE IF NOT EXISTS DataSources (
6  datasource_id INTEGER PRIMARY KEY AUTOINCREMENT,
7  datasource TEXT,
8  run_number UNSIGNED BIG INT,
9  evt_number UNSIGNED BIG INT
10  );
11 
12  CREATE TABLE IF NOT EXISTS GenEvents (
13  genevent_id INTEGER PRIMARY KEY AUTOINCREMENT,
14  collision INTEGER,
15  datasource_id INTEGER,
16  t REAL,
17  x REAL,
18  y REAL,
19  z REAL,
20  FOREIGN KEY(datasource_id) REFERENCES DataSources(datasource_id)
21  );
22 
23  CREATE TABLE IF NOT EXISTS GenVertices (
24  genvertex_id INTEGER PRIMARY KEY AUTOINCREMENT,
25  genevent_id INTEGER,
26  hepmc_id INTEGER,
27  status INTEGER,
28  t REAL,
29  x REAL,
30  y REAL,
31  z REAL,
32  is_primary INTEGER,
33  FOREIGN KEY(genevent_id) REFERENCES GenEvents(genevent_id)
34  );
35 
36  CREATE TABLE IF NOT EXISTS GenParticles (
37  genparticle_id INTEGER PRIMARY KEY AUTOINCREMENT,
38  genevent_id INTEGER,
39  hepmc_id INTEGER,
40  production_vertex INTEGER,
41  end_vertex INTEGER,
42  pid INTEGER,
43  status INTEGER,
44  pe REAL,
45  px REAL,
46  py REAL,
47  pz REAL,
48  m REAL,
49  FOREIGN KEY(genevent_id) REFERENCES GenEvents(genevent_id),
50  FOREIGN KEY(production_vertex) REFERENCES GenVertices(genvertex_id),
51  FOREIGN KEY(end_vertex) REFERENCES GenVertices(genvertex_id)
52  );
53 
54  CREATE INDEX IF NOT EXISTS GenParticles_production_vertex
55  ON GenParticles (production_vertex);
56 
57  CREATE INDEX IF NOT EXISTS GenParticles_end_vertex
58  ON GenParticles (end_vertex);
59 
60  CREATE TABLE IF NOT EXISTS MCVertices (
61  mcvertex_id INTEGER PRIMARY KEY AUTOINCREMENT,
62  genvertex_id INTEGER UNIQUE,
63  genevent_id INTEGER,
64  status INTEGER,
65  t REAL,
66  x REAL,
67  y REAL,
68  z REAL,
69  is_primary INTEGER,
70  FOREIGN KEY(genvertex_id) REFERENCES GenVertices(genvertex_id),
71  FOREIGN KEY(genevent_id) REFERENCES GenEvents(genevent_id)
72  );
73 
74  CREATE TABLE IF NOT EXISTS MCParticles (
75  mcparticle_id INTEGER PRIMARY KEY AUTOINCREMENT,
76  genparticle_id INTEGER UNIQUE,
77  genevent_id INTEGER,
78  production_vertex INTEGER,
79  end_vertex INTEGER,
80  pid INTEGER,
81  pe REAL,
82  px REAL,
83  py REAL,
84  pz REAL,
85  m REAL,
86  is_signal INTEGER,
87  FOREIGN KEY(genparticle_id) REFERENCES GenParticles(genparticle_id),
88  FOREIGN KEY(production_vertex) REFERENCES MCVertices(mcvertex_id),
89  FOREIGN KEY(genevent_id) REFERENCES GenEvents(genevent_id),
90  FOREIGN KEY(end_vertex) REFERENCES MCVertices(mcvertex_id)
91  );
92 
93  CREATE TABLE IF NOT EXISTS Vertices (
94  vertex_id INTEGER PRIMARY KEY AUTOINCREMENT,
95  mcvertex_id INTEGER UNIQUE,
96  genevent_id INTEGER,
97  t REAL,
98  x REAL,
99  y REAL,
100  z REAL,
101  sigma_x REAL,
102  sigma_y REAL,
103  sigma_z REAL,
104  vertex_type INTEGER,
105  FOREIGN KEY(mcvertex_id) REFERENCES MCVertices(mcvertex_id),
106  FOREIGN KEY(genevent_id) REFERENCES GenEvents(genevent_id)
107  );
108 )";