LDMX Software
Measurement.h
1#pragma once
2
3//~~ StdLib ~~//
4#include <array>
5#include <limits>
6
8
9//~~ ROOT ~~//
10#include "TObject.h" // Needed for ClassDef, ClassImp
11
12namespace ldmx {
14 public:
16 Measurement() = default;
17
27 Measurement(const ldmx::SimTrackerHit& hit, const float& cov_uu = 0.05,
28 const float& cov_vv = 1.0);
29
31 virtual ~Measurement() = default;
32
41 void setGlobalPosition(const float& meas_x, const float& meas_y,
42 const float& meas_z) {
43 meas_x_ = meas_x;
44 meas_y_ = meas_y;
45 meas_z_ = meas_z;
46 };
47
49 [[nodiscard]] std::array<float, 3> getGlobalPosition() const {
50 return std::array<float, 3>{meas_x_, meas_y_, meas_z_};
51 };
52
60 void setLocalPosition(const float& meas_u, const float& meas_v) {
61 meas_u_ = meas_u;
62 meas_v_ = meas_v;
63 };
64
66 [[nodiscard]] std::array<float, 2> getLocalPosition() const {
67 return std::array<float, 2>{meas_u_, meas_v_};
68 };
69
76 void setLocalCovariance(const float& cov_uu, const float& cov_vv) {
77 cov_uu_ = cov_uu;
78 cov_vv_ = cov_vv;
79 }
80
83 [[nodiscard]] std::array<float, 2> getLocalCovariance() const {
84 return std::array<float, 2>{cov_uu_, cov_vv_};
85 };
86
92 void setTime(const float& meas_t) { meas_t_ = meas_t; };
93
95 [[nodiscard]] float getTime() const { return meas_t_; };
96
103 void setLayerID(const int& layer_id) {
104 layer_id_ = layer_id;
105 layer_ = ((layer_id_ / 100) % 10 - 1) * 2 + layer_id % 2;
106 };
107
109 [[nodiscard]] int getLayerID() const { return layer_id_; };
110
112 int getLayer() const { return layer_; }
113
115 void addTrackId(int trk_id) { track_ids_.push_back(trk_id); };
117 std::vector<unsigned int> getTrackIds() const { return track_ids_; };
118
121 float getEdep() const { return edep_; };
122
124 void setEdep(float e) { edep_ = e; };
125
126 // --- Truth local position (set by DigitizationProcessor before digitization)
127 // ---
128
131 void setTruthU(float u) { truth_u_ = u; }
133 float getTruthU() const { return truth_u_; }
134
135 // --- Cluster metadata (set by StripClusterProcessor; default -1/0 otherwise)
136 // ---
137
139 void setNStrips(int n) { n_strips_ = n; }
141 int getNStrips() const { return n_strips_; }
142
144 void setClusterAmplitude(float amp) { cluster_amplitude_ = amp; }
147 float getClusterAmplitude() const { return cluster_amplitude_; }
148
161 friend std::ostream& operator<<(std::ostream& output,
162 const Measurement& measurement);
163
164 private:
166 float meas_x_{0.};
168 float meas_y_{0.};
170 float meas_z_{0.};
172 float meas_t_{0.};
174 float meas_u_{0.};
176 float meas_v_{0.};
178 int layer_id_{0};
180 int layer_{0};
182 float edep_{0.};
184 float cov_uu_{0.};
186 float cov_vv_{0.};
188 int id_{0};
190 std::vector<unsigned int> track_ids_{};
191
194 float truth_u_{std::numeric_limits<float>::quiet_NaN()};
195
197 int n_strips_{-1};
200
201 ClassDef(Measurement, 3);
202}; // Measurement
203
204typedef std::vector<Measurement> Measurements;
205// typedef std::vector<std::reference_wrapper<const Measurement>> Measurements;
206
207} // 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:95
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:49
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:60
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:66
std::array< float, 2 > getLocalCovariance() const
Definition Measurement.h:83
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:41
void setLocalCovariance(const float &cov_uu, const float &cov_vv)
Set cov(U,U) and cov(V, V).
Definition Measurement.h:76
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:92
int id_
The ID of the hit.
Represents a simulated tracker hit in the simulation.