LDMX Software
LdmxSpacePoint.h
1#ifndef LDMXSPACEPOINT_H_
2#define LDMXSPACEPOINT_H_
3
4// TODO:: Covariance?!
5// VarianceR is the variance in the more sensitive direction
6// VarianceZ is the variance in the less sensitive direction
7// TODO:: Get rid of this class and change it with something that makes some
8// sort of sense
9
10// TODO:: The projector should support time as well
11// MG Aug 2024 Change all SymMatrix2 to SquareMatrix2 to support ACTs v36
12#include <cmath>
13
14//--- Acts ---//
15#include "Acts/Definitions/Algebra.hpp"
16
17namespace ldmx {
18
20 public:
21 // Global position constructor with fixed covariance
22 LdmxSpacePoint(float x_, float y_, float z_, float t, int layer_) {
23 m_x_ = x_;
24 m_y_ = y_;
25 m_z_ = z_;
26 m_t_ = t;
27 m_edep_ = 0.;
28 m_layer_ = layer_;
29 m_id_ = -999;
30 m_variance_r_ = 0.050;
31 m_variance_z_ = 0.050;
32 initialize();
33 }
34
35 // Global position constructor with user specified covariance
36 LdmxSpacePoint(float x_, float y_, float z_, float t, int layer_, float edep,
37 float vR, float vZ, int id) {
38 m_x_ = x_;
39 m_y_ = y_;
40 m_z_ = z_;
41 m_t_ = t;
42 m_edep_ = edep;
43 m_variance_r_ = vR;
44 m_variance_z_ = vZ;
45 m_layer_ = layer_;
46 m_id_ = id;
47 initialize();
48 }
49
50 LdmxSpacePoint(const std::vector<float>& gp, float t, int layer_,
51 const std::vector<float>& cv, int id) {
52 m_x_ = gp[0];
53 m_y_ = gp[1];
54 m_z_ = gp[2];
55 m_t_ = t;
56 m_edep_ = 0.;
57 m_layer_ = layer_;
58 m_id_ = id;
59 m_variance_r_ = cv[0];
60 m_variance_z_ = cv[1];
61 initialize();
62 }
63
64 float x() const { return m_x_; }
65 float y() const { return m_y_; }
66 float z() const { return m_z_; }
67 float t() const { return m_t_; }
68 float r() const { return m_r_; }
69 float edep() const { return m_edep_; }
70 float varianceR() const { return m_variance_r_; }
71 float varianceZ() const { return m_variance_z_; }
72 int layer() const { return m_layer_; }
73 int id() const { return m_id_; }
74
75 void setGlobalPosition(float x_, float y_, float z_) {
76 global_pos_.setZero();
77 global_pos_(0) = x_;
78 global_pos_(1) = y_;
79 global_pos_(2) = z_;
80 }
81
82 void setLocalPosition(float u, float v) {
83 local_pos_.setZero();
84 local_pos_(0) = u;
85 local_pos_(1) = v;
86 }
87
88 void setLocalPosition(const Acts::Vector2& local) { local_pos_ = local; }
89
90 void setLocalCovariance(float vR, float vZ) {
91 local_cov_.setZero();
92 local_cov_(0, 0) = vR;
93 local_cov_(1, 1) = vZ;
94 }
95
96 //(1 0 0 0 0 0)
97 //(0 1 0 0 0 0)
98
99 void setProjector() {
100 projector_.setZero();
101 projector_(0, 0) = 1;
102 projector_(1, 1) = 1;
103 }
104
105 const Acts::SquareMatrix2 getLocalCovariance() const { return local_cov_; };
106 const Acts::Vector3 getGlobalPosition() const { return global_pos_; };
107 const Acts::Vector2 getLocalPosition() const { return local_pos_; };
108
109 Acts::Vector3 global_pos_;
110 Acts::Vector2 local_pos_;
111 // TODO:: not sure about this
112 Acts::SquareMatrix2 local_cov_;
113
114 // Projection matrix from the full space to the (u,v) space.
115 // This can be expanded to (u,v,t) space in the case time needs to be added.
116
117 Acts::ActsMatrix<2, 6> projector_;
118
119 private:
120 void initialize() {
121 setGlobalPosition(m_x_, m_y_, m_z_);
122 m_r_ = std::sqrt(m_x_ * m_x_ + m_y_ * m_y_);
123 setLocalCovariance(m_variance_r_, m_variance_z_);
124 setProjector();
125 };
126
127 float m_x_;
128 float m_y_;
129 float m_z_;
130 float m_t_;
131 float m_r_;
132 float m_edep_;
133 float m_variance_r_;
134 float m_variance_z_;
135 int m_id_;
136 int m_layer_;
137};
138
139} // namespace ldmx
140
141#endif