2from particle
import Particle
5@PyLamarr.persistent_table((
6 'event_id',
'eventNumber',
'runNumber',
'timeStamp',
'weight'
10 Event Header. Additional parameters are assumed to go into the metadata tree.
12 return "SELECT datasource_id, evt_number, run_number, 0, 0 FROM DataSources;"
15@PyLamarr.persistent_table((
45 The Monte Carlo particle - based on the lcio::MCParticle.
49 gev.datasource_id AS event_id,
50 mcp.mcparticle_id AS mcparticle_id,
52 gp.status AS generator_status,
53 mcp.is_signal AS simulator_status,
54 propagation_charge(mcp.pid) AS charge,
66 FROM MCParticles AS mcp
67 LEFT JOIN GenParticles AS gp
68 ON mcp.genparticle_id == gp.genparticle_id
69 LEFT JOIN GenVertices AS ov
70 ON gp.production_vertex == ov.genvertex_id
71 LEFT JOIN GenVertices AS end
72 ON gp.end_vertex == end.genvertex_id
73 LEFT JOIN GenEvents AS gev
74 ON gp.genevent_id == gev.genevent_id
78@PyLamarr.persistent_table(('event_id', 'daughter', 'parent'))
79def MCParticle__parents__MCParticle():
81 Zip table from parent to daughter
85 gev.datasource_id AS event_id,
86 mcp.mcparticle_id AS daughter,
87 parent.mcparticle_id AS parent
88 FROM MCParticles AS mcp
89 LEFT JOIN GenParticles AS daughter_gp
90 ON mcp.genparticle_id == daughter_gp.genparticle_id
91 INNER JOIN GenParticles AS parent_gp
92 ON parent_gp.end_vertex == daughter_gp.production_vertex
93 LEFT JOIN MCParticles AS parent
94 ON parent.genparticle_id == parent_gp.genparticle_id
95 LEFT JOIN GenParticles AS gp
96 ON mcp.genparticle_id == gp.genparticle_id
97 LEFT JOIN GenEvents AS gev
98 ON gp.genevent_id == gev.genevent_id
102@PyLamarr.persistent_table(('parent', 'daughter'))
103def MCParticle__daughters__MCParticle():
105 Zip table from daughter to parent
109 mcp.mcparticle_id AS parent,
110 daughter.mcparticle_id AS daughter
111 FROM MCParticles AS mcp
112 LEFT JOIN GenParticles AS parent_gp
113 ON mcp.genparticle_id == parent_gp.genparticle_id
114 INNER JOIN GenParticles AS daughter_gp
115 ON daughter_gp.end_vertex == parent_gp.production_vertex
116 LEFT JOIN MCParticles AS daughter
117 ON daughter.genparticle_id == daughter_gp.genparticle_id
121@PyLamarr.persistent_table((
122 'event_id',
'particle_id',
'type',
'PDG',
'algorithmType',
'likelihood'
126 Particle Identification algorithms.
127 - particle_id: index of the Particle table
129 - 0: boolean (e.g. isMuon)
130 - 1: efficiency (e.g. isMuonEfficiency)
131 - 2: log-likelihood (e.g. RichDLL or Global DLL)
132 - 3: classifier (e.g. ProbNN)
133 - type (unit digit is reserved for future additional versions):
138 - 100: CombinedDLL wrt pion hypothesis
141 join_clause =
" JOIN MCParticle AS mcp ON mcp.mcparticle_id=t.mcparticle_id"
142 return [stmt + join_clause
144 "SELECT mcp.event_id, t.mcparticle_id, 0, 13, 0, ismuoneff FROM tmp_is_muon AS t",
145 "SELECT mcp.event_id, t.mcparticle_id, 10, 13, 1, is_muon FROM tmp_is_muon AS t",
146 "SELECT mcp.event_id, t.mcparticle_id, 20, 11, 2, RichDLLe FROM pid AS t",
147 "SELECT mcp.event_id, t.mcparticle_id, 20, 13, 2, RichDLLmu FROM pid AS t",
148 "SELECT mcp.event_id, t.mcparticle_id, 20, 211, 2, 0 FROM pid AS t",
149 "SELECT mcp.event_id, t.mcparticle_id, 20, 321, 2, RichDLLK FROM pid AS t",
150 "SELECT mcp.event_id, t.mcparticle_id, 20, 2212, 2, RichDLLp FROM pid AS t",
151 "SELECT mcp.event_id, t.mcparticle_id, 30, 13, 2, MuonMuLL FROM pid AS t",
152 "SELECT mcp.event_id, t.mcparticle_id, 30, 2212, 2, MuonBkgLL FROM pid AS t",
153 "SELECT mcp.event_id, t.mcparticle_id, 100, 11, 2, PIDe FROM pid AS t",
154 "SELECT mcp.event_id, t.mcparticle_id, 100, 13, 2, PIDmu FROM pid AS t",
155 "SELECT mcp.event_id, t.mcparticle_id, 100, 211, 2, 0 FROM pid AS t",
156 "SELECT mcp.event_id, t.mcparticle_id, 100, 321, 2, PIDK FROM pid AS t",
157 "SELECT mcp.event_id, t.mcparticle_id, 100, 2212, 2, PIDp FROM pid AS t",
158 "SELECT mcp.event_id, t.mcparticle_id, 110, 11, 2, ProbNNe FROM pid AS t",
159 "SELECT mcp.event_id, t.mcparticle_id, 110, 13, 2, ProbNNmu FROM pid AS t",
160 "SELECT mcp.event_id, t.mcparticle_id, 110, 211, 2, ProbNNpi FROM pid AS t",
161 "SELECT mcp.event_id, t.mcparticle_id, 110, 321, 2, ProbNNk FROM pid AS t",
162 "SELECT mcp.event_id, t.mcparticle_id, 110, 2212, 2, ProbNNp FROM pid AS t",
166@PyLamarr.persistent_table((
167 'event_id',
'track_id',
'mcparticle_id',
'type',
'chi2',
'ndf',
'ghostProb',
172 Reconstructed track, intended as a collection of track states.
176 mcp.event_id AS event_id,
177 reco.mcparticle_id AS track_id,
178 reco.mcparticle_id AS mcparticle_id,
179 reco.track_type AS track_type,
180 res.chi2PerDoF * floor(res.nDoF_f), floor(res.nDoF_f), res.ghostProb
181 FROM tmp_particles_recoed_as AS reco
182 LEFT JOIN tmp_resolution_out AS res ON reco.mcparticle_id == res.mcparticle_id
183 LEFT JOIN MCParticle AS mcp ON mcp.mcparticle_id == res.mcparticle_id
184 WHERE reco.track_type != 0
188@PyLamarr.persistent_table((
223 TrackState encodes the knowledge of a track in a specific location.
233 For LHCb, AtIP (1) is used to indicate ClosestToBeam.
235 Given the different variables used to describe a track state in LHCb
236 and in 4pi experiments, we redefine the TrackState
240 gev.datasource_id AS event_id,
243 ctb.x + res.dx AS referencePoint_x,
244 ctb.y + res.dy AS referencePoint_y,
245 ctb.z + res.dz AS referencePoint_z,
246 (mcp.px / mcp.pz) + res.dtx AS slope_x,
247 (mcp.py / mcp.pz) + res.dty AS slope_y,
248 norm2(mcp.px, mcp.py, mcp.pz) + res.dp AS momentum,
249 propagation_charge(mcp.pid) / (norm2(mcp.px, mcp.py, mcp.pz) + res.dp) AS qOverP,
265 FROM tmp_particles_recoed_as AS reco
266 LEFT JOIN MCParticles AS mcp
267 ON mcp.mcparticle_id == reco.mcparticle_id
268 LEFT JOIN tmp_resolution_out AS res
269 ON res.mcparticle_id == reco.mcparticle_id
270 LEFT JOIN covariance AS cov
271 ON cov.mcparticle_id == reco.mcparticle_id
272 LEFT JOIN tmp_closest_to_beam AS ctb
273 ON ctb.mcparticle_id == reco.mcparticle_id
274 LEFT JOIN GenEvents AS gev
275 ON gev.genevent_id == mcp.genevent_id
276 WHERE reco.track_type != 0
281@PyLamarr.persistent_table((
295 gev.datasource_id AS event_id,
296 v.mcvertex_id AS vertex_id,
303 JOIN GenEvents AS gev
304 ON gev.genevent_id == v.genevent_id
307@PyLamarr.persistent_table((
327 gev.datasource_id AS event_id,
328 v.mcvertex_id AS vertex_id,
334 v.sigma_x*v.sigma_x AS cov_xx,
337 v.sigma_y*v.sigma_y AS cov_yy,
339 v.sigma_z*v.sigma_z AS cov_zz
341 JOIN GenEvents AS gev
342 ON gev.genevent_id == v.genevent_id
345@PyLamarr.persistent_table((
373def ReconstructedParticle():
376 gev.datasource_id AS event_id,
378 mcp.mcparticle_id AS mcparticle_id,
379 {pdg}*propagation_charge(mcp.pid) AS PDG,
382 POW({Particle.from_pdgid(pdg).mass},2) +
383 POW(norm2(mcp.px, mcp.py, mcp.pz) + res.dp, 2),
385 slopes_to_cartesian(0,
386 abs(norm2(mcp.px, mcp.py, mcp.pz) + res.dp),
387 mcp.px/mcp.pz + res.dp,
388 mcp.py/mcp.pz + res.dp
390 slopes_to_cartesian(1,
391 abs(norm2(mcp.px, mcp.py, mcp.pz) + res.dp),
392 mcp.px/mcp.pz + res.dp,
393 mcp.py/mcp.pz + res.dp
395 slopes_to_cartesian(2,
396 abs(norm2(mcp.px, mcp.py, mcp.pz) + res.dp),
397 mcp.px/mcp.pz + res.dp,
398 mcp.py/mcp.pz + res.dp
400 ctb.x + res.dx AS referencePoint_x,
401 ctb.y + res.dy AS referencePoint_y,
402 ctb.z + res.dz AS referencePoint_z,
403 propagation_charge(mcp.pid) AS charge,
404 {Particle.from_pdgid(pdg).mass} AS mass
406 LEFT JOIN MCParticles AS mcp
407 ON mcp.mcparticle_id == trk.mcparticle_id
408 LEFT JOIN tmp_closest_to_beam AS ctb
409 ON ctb.mcparticle_id == trk.mcparticle_id
410 LEFT JOIN tmp_resolution_out AS res
411 ON res.mcparticle_id == trk.mcparticle_id
412 LEFT JOIN GenEvents AS gev
413 ON gev.genevent_id == mcp.genevent_id
415 """ for pdg
in (-11, -13, 211, 321, 2212)]
418CleanUp = PyLamarr.custom_query([
419 "DROP TABLE IF EXISTS tmp_particles_recoed_as",
420 "DROP TABLE IF EXISTS tmp_is_muon",
421 "DROP TABLE IF EXISTS tmp_closest_to_beam",
422 "DROP TABLE IF EXISTS pid",
423 "DROP TABLE IF EXISTS ismuoneff",
424 "DROP TABLE IF EXISTS covariance",