LDMX Software
Measurement.h
1#pragma once
2
3//~~ StdLib ~~//
4#include <Rtypes.h>
5
6#include <array>
7#include <limits>
8
10
11//~~ ROOT ~~//
12
13namespace ldmx {
15 public:
17 Measurement() = default;
18
28 Measurement(const ldmx::SimTrackerHit& hit, const float& cov_uu = 0.05,
29 const float& cov_vv = 1.0);
30
32 virtual ~Measurement() = default;
33
42 void setGlobalPosition(const float& meas_x, const float& meas_y,
43 const float& meas_z) {
44 meas_x_ = meas_x;
45 meas_y_ = meas_y;
46 meas_z_ = meas_z;
47 };
48
50 [[nodiscard]] std::array<float, 3> getGlobalPosition() const {
51 return std::array<float, 3>{meas_x_, meas_y_, meas_z_};
52 };
53
61 void setLocalPosition(const float& meas_u, const float& meas_v) {
62 meas_u_ = meas_u;
63 meas_v_ = meas_v;
64 };
65
67 [[nodiscard]] std::array<float, 2> getLocalPosition() const {
68 return std::array<float, 2>{meas_u_, meas_v_};
69 };
70
77 void setLocalCovariance(const float& cov_uu, const float& cov_vv) {
78 cov_uu_ = cov_uu;
79 cov_vv_ = cov_vv;
80 }
81
84 [[nodiscard]] std::array<float, 2> getLocalCovariance() const {
85 return std::array<float, 2>{cov_uu_, cov_vv_};
86 };
87
93 void setTime(const float& meas_t) { meas_t_ = meas_t; };
94
96 [[nodiscard]] float getTime() const { return meas_t_; };
97
104 void setLayerID(const int& layer_id) {
105 layer_id_ = layer_id;
106 layer_ = ((layer_id_ / 100) % 10 - 1) * 2 + layer_id % 2;
107 };
108
110 [[nodiscard]] int getLayerID() const { return layer_id_; };
111
113 int getLayer() const { return layer_; }
114
116 void addTrackId(int trk_id) { track_ids_.push_back(trk_id); };
118 std::vector<unsigned int> getTrackIds() const { return track_ids_; };
119
122 float getEdep() const { return edep_; };
123
125 void setEdep(float e) { edep_ = e; };
126
127 // --- Truth local position (set by DigitizationProcessor before digitization)
128 // ---
129
132 void setTruthU(float u) { truth_u_ = u; }
134 float getTruthU() const { return truth_u_; }
135
136 // --- Cluster metadata (set by StripClusterProcessor; default -1/0 otherwise)
137 // ---
138
140 void setNStrips(int n) { n_strips_ = n; }
142 int getNStrips() const { return n_strips_; }
143
145 void setClusterAmplitude(float amp) { cluster_amplitude_ = amp; }
148 float getClusterAmplitude() const { return cluster_amplitude_; }
149
162 friend std::ostream& operator<<(std::ostream& output,
163 const Measurement& measurement);
164
165 private:
167 float meas_x_{0.};
169 float meas_y_{0.};
171 float meas_z_{0.};
173 float meas_t_{0.};
175 float meas_u_{0.};
177 float meas_v_{0.};
179 int layer_id_{0};
181 int layer_{0};
183 float edep_{0.};
185 float cov_uu_{0.};
187 float cov_vv_{0.};
189 int id_{0};
191 std::vector<unsigned int> track_ids_{};
192
195 float truth_u_{std::numeric_limits<float>::quiet_NaN()};
196
198 int n_strips_{-1};
201
202 ClassDef(Measurement, 3);
203}; // Measurement
204
205typedef std::vector<Measurement> Measurements;
206// typedef std::vector<std::reference_wrapper<const Measurement>> Measurements;
207
208} // namespace ldmx
Class which encapsulates information from a hit in a simulated tracking detector.
void setTruthU(float u)
Set the truth local U [mm]: the sim-hit global position projected onto the sensor surface,...
float cov_vv_
cov(V, V)
float getTime() const
Definition Measurement.h:96
float meas_y_
The global position in x (mm).
void setNStrips(int n)
Set the number of strips that formed this cluster (-1 if not a cluster).
friend std::ostream & operator<<(std::ostream &output, const Measurement &measurement)
Overload the stream insertion operator to output a string representation of this Measurement.
Measurement()=default
Default constructor.
std::array< float, 3 > getGlobalPosition() const
Definition Measurement.h:50
int layer_
The layer number internal to the tracker.
float getClusterAmplitude() const
void setLocalPosition(const float &meas_u, const float &meas_v)
Set the local position i.e.
Definition Measurement.h:61
void setLayerID(const int &layer_id)
Set the layer ID of the sensor where this measurement took place.
void addTrackId(int trk_id)
Add a trackId to the internal vector.
virtual ~Measurement()=default
Default destructor.
int getLayerID() const
int n_strips_
Number of strips in the cluster (-1 = not from strip clustering).
float cluster_amplitude_
Total cluster amplitude [ADC counts] (0 = not from strip clustering).
void setEdep(float e)
Set the energy deposited in the sensor [MeV].
int getLayer() const
std::vector< unsigned int > track_ids_
TrackIDs the vector of TrackIDs that form the measurement.
std::array< float, 2 > getLocalPosition() const
Definition Measurement.h:67
std::array< float, 2 > getLocalCovariance() const
Definition Measurement.h:84
float meas_v_
Local position in v (mm).
float edep_
The energy deposited in the sensor where the measurement took place.
float meas_z_
The global position in x (mm).
float getTruthU() const
float truth_u_
Truth local U [mm] projected from the SimTrackerHit before digitization.
float getEdep() const
float meas_u_
Local position in u (mm).
float meas_t_
Measurement time (ns).
float meas_x_
The global position in x (mm).
void setGlobalPosition(const float &meas_x, const float &meas_y, const float &meas_z)
Set the global position i.e.
Definition Measurement.h:42
void setLocalCovariance(const float &cov_uu, const float &cov_vv)
Set cov(U,U) and cov(V, V).
Definition Measurement.h:77
int getNStrips() const
float cov_uu_
cov(U, U)
void setClusterAmplitude(float amp)
Set the total cluster amplitude [ADC counts].
int layer_id_
The ID of the sensor where the measurement took place.
std::vector< unsigned int > getTrackIds() const
void setTime(const float &meas_t)
Set the measurement time in ns.
Definition Measurement.h:93
int id_
The ID of the hit.
Represents a simulated tracker hit in the simulation.