PyLamarr
Pythonizations for the ultra-fast simulation option for the LHCb experiment
 
Loading...
Searching...
No Matches
PropagateToClosestToBeam.py
1from typing import Tuple, Optional
2from dataclasses import dataclass
3from pydantic import validate_arguments
4
5from PyLamarr import Wrapper
6
7
8@validate_arguments
9@dataclass(frozen=True)
11 output_table: Optional[str] = "tmp_closest_to_beam"
12 output_columns: Optional[Tuple[str, ...]] = ("mcparticle_id", "x", "y", "z")
13 make_persistent: Optional[bool] = True
14
15 def query(self):
16 return """
17 WITH ctb AS (
18 SELECT
19 mcparticle_id,
20 z_closest_to_beam(gv.x, gv.y, gv.z, p.px/p.pz, p.py/p.pz) AS z,
21 gv.x AS x0,
22 gv.y AS y0,
23 gv.z AS z0,
24 p.px/p.pz AS tx,
25 p.py/p.pz AS ty
26 FROM MCParticles AS p
27 JOIN GenParticles AS gp ON gp.genparticle_id == p.genparticle_id
28 JOIN GenVertices as gv ON gp.production_vertex == gv.genvertex_id
29 )
30 SELECT
31 mcparticle_id,
32 x0 + (z - z0)*tx AS x,
33 y0 + (z - z0)*ty AS y,
34 z AS z
35 FROM ctb;
36 """
37
38 implements: str = "TemporaryTable"
39
40 @property
41 def config(self):
42 return dict(
43 output_table=self.output_table,
44 outputs=self.output_columns,
45 query=self.query(),
46 make_persistent=self.make_persistent,
47 )