LDMX Software
TrackingUtils.h
1#ifndef TRACKUTILS_H_
2#define TRACKUTILS_H_
3
4// Recoil back layers numbering scheme for module_
5
6// +Y /\ 4 3 2 1 0
7// |
8// |
9// -Y \/ 9 8 7 6 5
10// -X <---- ----> +X
11
12// ModN (x_, y_, z_)
13// 0 (96, 40, z2)
14// 1 (48, 40, z1)
15// 2 (0, 40, z2)
16// 3 (-48, 40, z1)
17// 4 (-96, 40, z2)
18
19// 5 (96, -40, z2)
20// 6 (48, -40, z1)
21// 7 (0, -40, z2)
22// 8 (-48, -40, z1)
23// 9 (-96, -40, z2)
24
25// ---< SimCore >---//
27#include "Tracking/Sim/LdmxSpacePoint.h"
28
29// --- Tracking ---//
30#include "Tracking/Event/Track.h"
31
32// --- < ACTS > --- //
33#include "Acts/Definitions/Algebra.hpp"
34#include "Acts/Definitions/PdgParticle.hpp"
35#include "Acts/Definitions/TrackParametrization.hpp"
36#include "Acts/Definitions/Units.hpp"
37#include "Acts/EventData/TrackParameters.hpp"
38#include "Acts/Surfaces/PerigeeSurface.hpp"
39#include "Acts/Surfaces/PlaneSurface.hpp"
40#include "Acts/Surfaces/Surface.hpp"
41#include "Tracking/Event/Measurement.h"
42#include "Tracking/Sim/IndexSourceLink.h"
43
44namespace tracking {
45namespace sim {
46namespace utils {
47
48// This method returns the sensor ID
49int getSensorID(const ldmx::SimTrackerHit& hit);
50
51// This method converts a SimHit in a LdmxSpacePoint for the Acts seeder.
52// (1) Rotate the coordinates into acts::seedFinder coordinates defined by
53// B-Field along z_ axis [Z_ldmx -> X_acts, X_ldmx->Y_acts, Y_ldmx->Z_acts]
54// (2) Saves the error information. At the moment the errors are fixed. They
55// should be obtained from the digitized hits_.
56// Vol==2 for tagger, Vol==3 for recoil
57ldmx::LdmxSpacePoint* convertSimHitToLdmxSpacePoint(
58 const ldmx::SimTrackerHit& hit, unsigned int vol = 2, double sigma_u = 0.05,
59 double sigma_v = 1.);
60
61// BoundSymMatrix doesn't exist in v36 .. use BoundSquareMatrix
62// have to change this everywhere .. I think using BoundSysMatrix was defined
63// exactly the same as BoundSquareMatrix is now in ACTs
64void flatCov(Acts::BoundSquareMatrix cov, std::vector<double>& v_cov);
65
66Acts::BoundSquareMatrix unpackCov(const std::vector<double>& v_cov);
67
68// Rotate LDMX global -> ACTS frame: z_ldmx->x_acts, x_ldmx->y_acts,
69// y_ldmx->z_acts (0 0 1) * (x,y,z)_ldmx = x_acts (1 0 0) * (x,y,z)_ldmx =
70// y_acts (0 1 0) * (x,y,z)_ldmx = z_acts
71Acts::SquareMatrix3 ldmx2ActsRotation();
72
73Acts::Vector3 ldmx2Acts(Acts::Vector3 ldmx_v);
74
75// Rotate ACTS frame -> LDMX global (inverse of ldmx2Acts, i.e. transpose):
76// x_ldmx = y_acts, y_ldmx = z_acts, z_ldmx = x_acts
77Acts::SquareMatrix3 acts2LdmxRotation();
78
79Acts::Vector3 acts2Ldmx(Acts::Vector3 acts_v);
80
81// Transform position, momentum and charge to free parameters
82Acts::FreeVector toFreeParameters(Acts::Vector3 pos_, Acts::Vector3 mom,
83 Acts::ActsScalar q);
84
85// Pack the acts track parameters into something that is serializable for the
86// event bus
87std::vector<double> convertActsToLdmxPars(Acts::BoundVector acts_par);
88
89Acts::BoundVector boundState(const ldmx::Track& trk);
90
91Acts::BoundTrackParameters boundTrackParameters(
92 const ldmx::Track& trk, std::shared_ptr<Acts::PerigeeSurface> perigee);
93
94// Return an unbound surface
95const std::shared_ptr<Acts::PlaneSurface> unboundSurface(double xloc,
96 double yloc = 0.,
97 double zloc = 0.);
98
99// This method returns a source link index
100std::size_t sourceLinkHash(const Acts::SourceLink& a);
101
102// This method checks if two source links are equal by index
103bool sourceLinkEquality(const Acts::SourceLink& a, const Acts::SourceLink& b);
104
105/*
106 * Build a TrackState from ACTS BoundTrackParameters.
107 * All output quantities (position, momentum, covariance) are in the LDMX
108 * global frame: x=horizontal, y=vertical, z=downstream.
109 *
110 * Covariance transformation steps:
111 * 1. Bound (6x6) -> Free (8x8) via ACTS bound-to-free Jacobian
112 * 2. Drop time row/col -> 7x7
113 * 3. 7D (x,y,z,d0,d1,d2,qop) -> 6D Cartesian (x,y,z,px,py,pz) in ACTS frame
114 * 4. Rotate 6x6 covariance ACTS -> LDMX via block-diagonal rotation
115 * 5. Flatten upper triangle -> 21-element vector
116 */
117ldmx::Track::TrackState makeTrackState(
118 const Acts::GeometryContext& gctx,
119 const Acts::BoundTrackParameters& bound_pars,
120 ldmx::TrackStateType ts_type = ldmx::Invalid);
121
122} // namespace utils
123} // namespace sim
124} // namespace tracking
125
126#endif
Class which encapsulates information from a hit in a simulated tracking detector.
Represents a simulated tracker hit in the simulation.
Implementation of a track object.
Definition Track.h:53
The measurement calibrator can be a function or a class/struct able to retrieve the sim hits containe...