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