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_varianceR = 0.050;
31 m_varianceZ = 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_varianceR = vR;
44 m_varianceZ = 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_varianceR = cv[0];
60 m_varianceZ = 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_varianceR; }
71 float varianceZ() const { return m_varianceZ; }
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_varianceR, m_varianceZ);
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_varianceR;
134 float m_varianceZ;
135 int m_id;
136 int m_layer;
137};
138
139} // namespace ldmx
140
141#endif