LDMX Software
PFCandidate.h
Go to the documentation of this file.
1
7#ifndef RECON_EVENT_PFCANDIDATE_H_
8#define RECON_EVENT_PFCANDIDATE_H_
9
10// ROOT
11#include <Rtypes.h> // For ClassDef
12
13#include <vector>
14
15namespace ldmx {
16
22 public:
23 PFCandidate() = default;
24 virtual ~PFCandidate() {}
25
26 friend std::ostream& operator<<(std::ostream& o, const PFCandidate& d);
27
28 bool operator<(const PFCandidate& rhs) const {
29 return this->getEnergy() < rhs.getEnergy();
30 }
31
32 /*
33 Setters
34 */
35 // detector bitmask: 1 track, 2 Ecal, 4 Hcal
36 void setPID(int x_) { pid_ = x_; }
37 // PF type as a signed PDG ID, as in CMS: 11 e, 13 mu, 22 gamma,
38 // 211 charged hadron, 130 neutral hadron; see getMass for the hypothesis
39 void setPdgId(int x_) { pdg_id_ = x_; }
40 void setCharge(int x_) { charge_ = x_; }
41 // tracker dE/dx estimate of the charged track
42 void setDeDxMassSquared(float x_) { dedx_mass2_ = x_; }
43 void setDeDxIh(float x_) { dedx_ih_ = x_; }
44 void setDeDxNhits(int x_) { dedx_nhits_ = x_; }
45 // mass hypothesis used for the energy [MeV]
46 void setMass(float x_) { mass_ = x_; }
47 void setEnergy(float x_) { energy_ = x_; }
48
49 void setTargetPositionXYZ(float x_, float y_, float z_) {
50 pos_targ_x_ = x_;
51 pos_targ_y_ = y_;
52 pos_targ_z_ = z_;
53 }
54 void setEcalPositionXYZ(float x_, float y_, float z_) {
55 pos_ecal_x_ = x_;
56 pos_ecal_y_ = y_;
57 pos_ecal_z_ = z_;
58 }
59 void setHcalPositionXYZ(float x_, float y_, float z_) {
60 pos_hcal_x_ = x_;
61 pos_hcal_y_ = y_;
62 pos_hcal_z_ = z_;
63 }
64 void setTrackPxPyPz(float x_, float y_, float z_) {
65 track_px_ = x_;
66 track_py_ = y_;
67 track_pz_ = z_;
68 }
69 // associate component indices to the pf candidate
70 void setTrackIndex(int x) { track_idx_ = x; }
71 void setEcalIndex(int x) { ecal_idx_ = x; }
72 void setHcalIndex(int x) { hcal_idx_ = x; }
73
74 void setEcalEnergy(float x_) { ecal_energy_ = x_; }
75 // rec hits behind the candidate with the raw energy it owns of each; a hit
76 // shared by Ecal clusters is listed in each candidate with its share
77 void clearEcalHits() {
78 ecal_hit_ids_.clear();
79 ecal_hit_energies_.clear();
80 }
81 void clearHcalHits() {
82 hcal_hit_ids_.clear();
83 hcal_hit_energies_.clear();
84 }
85 void addEcalHits(const std::vector<unsigned int>& ids,
86 const std::vector<float>& energies) {
87 addHits(ecal_hit_ids_, ecal_hit_energies_, ids, energies);
88 }
89 void addHcalHits(const std::vector<unsigned int>& ids,
90 const std::vector<float>& energies) {
91 addHits(hcal_hit_ids_, hcal_hit_energies_, ids, energies);
92 }
93 // energy-weighted mean depth behind the Ecal front [mm]
94 void setEcalDepth(float x_) { ecal_depth_ = x_; }
95 // energy-weighted RMS distance of the hits from the track line [mm]
96 void setEcalWidth(float x_) { ecal_width_ = x_; }
97 void setEcalRawEnergy(float x_) { ecal_raw_energy_ = x_; }
98 void setEcalClusterXYZ(float x_, float y_, float z_) {
99 ecal_cluster_x_ = x_;
100 ecal_cluster_y_ = y_;
101 ecal_cluster_z_ = z_;
102 }
103 void setEcalClusterEXYZ(float x_, float y_, float z_) {
104 ecal_cluster_ex_ = x_;
105 ecal_cluster_ey_ = y_;
106 ecal_cluster_ez_ = z_;
107 }
108 void setEcalClusterDXDZ(float x_) { ecal_cluster_dxdz_ = x_; }
109 void setEcalClusterDYDZ(float x_) { ecal_cluster_dydz_ = x_; }
110 void setEcalClusterEDXDZ(float x_) { ecal_cluster_edxdz_ = x_; }
111 void setEcalClusterEDYDZ(float x_) { ecal_cluster_edydz_ = x_; }
112
113 void setHcalEnergy(float x_) { hcal_energy_ = x_; }
114 void setHcalRawEnergy(float x_) { hcal_raw_energy_ = x_; }
115 void setHcalClusterXYZ(float x_, float y_, float z_) {
116 hcal_cluster_x_ = x_;
117 hcal_cluster_y_ = y_;
118 hcal_cluster_z_ = z_;
119 }
120 void setHcalClusterEXYZ(float x_, float y_, float z_) {
121 hcal_cluster_ex_ = x_;
122 hcal_cluster_ey_ = y_;
123 hcal_cluster_ez_ = z_;
124 }
125 void setHcalClusterDXDZ(float x_) { hcal_cluster_dxdz_ = x_; }
126 void setHcalClusterDYDZ(float x_) { hcal_cluster_dydz_ = x_; }
127 void setHcalClusterEDXDZ(float x_) { hcal_cluster_edxdz_ = x_; }
128 void setHcalClusterEDYDZ(float x_) { hcal_cluster_edydz_ = x_; }
129
130 void setTruthEcalXYZ(double x_, double y_, double z_) {
131 truth_ecal_x_ = x_;
132 truth_ecal_y_ = y_;
133 truth_ecal_z_ = z_;
134 }
135 void setTruthPxPyPz(double x_, double y_, double z_) {
136 truth_px_ = x_;
137 truth_py_ = y_;
138 truth_pz_ = z_;
139 }
140 void setTruthMass(double x_) { truth_mass_ = x_; }
141 void setTruthEnergy(double x_) { truth_energy_ = x_; }
142 void setTruthPdgId(int x_) { truth_pdg_id_ = x_; }
143 void setTruthTrackId(int x_) { truth_track_id_ = x_; }
144
145 /*
146 Getters
147 */
148 int getPID() const { return pid_; }
149 int getPdgId() const { return pdg_id_; }
150 int getCharge() const { return charge_; }
151 float getDeDxMassSquared() const { return dedx_mass2_; }
152 float getDeDxIh() const { return dedx_ih_; }
153 int getDeDxNhits() const { return dedx_nhits_; }
154 float getMass() const { return mass_; }
155 float getEnergy() const { return energy_; }
156
157 std::vector<float> getTargetPositionXYZ() const {
158 return {pos_targ_x_, pos_targ_y_, pos_targ_z_};
159 }
160 std::vector<float> getEcalPositionXYZ() const {
161 return {pos_ecal_x_, pos_ecal_y_, pos_ecal_z_};
162 }
163 std::vector<float> getHcalPositionXYZ() const {
164 return {pos_hcal_x_, pos_hcal_y_, pos_hcal_z_};
165 }
166 // associate component indices to the pf candidate
167 int getTrackIndex() const { return track_idx_; }
168 int getEcalIndex() const { return ecal_idx_; }
169 int getHcalIndex() const { return hcal_idx_; }
170
171 std::vector<float> getTrackPxPyPz() const {
172 return {track_px_, track_py_, track_pz_};
173 }
174
175 float getEcalEnergy() const { return ecal_energy_; }
176 const std::vector<unsigned int>& getEcalHitIds() const {
177 return ecal_hit_ids_;
178 }
179 const std::vector<float>& getEcalHitEnergies() const {
180 return ecal_hit_energies_;
181 }
182 const std::vector<unsigned int>& getHcalHitIds() const {
183 return hcal_hit_ids_;
184 }
185 const std::vector<float>& getHcalHitEnergies() const {
186 return hcal_hit_energies_;
187 }
188 float getEcalDepth() const { return ecal_depth_; }
189 float getEcalWidth() const { return ecal_width_; }
190 float getEcalRawEnergy() const { return ecal_raw_energy_; }
191 std::vector<float> getEcalClusterXYZ() const {
192 return {ecal_cluster_x_, ecal_cluster_y_, ecal_cluster_z_};
193 }
194 std::vector<float> getEcalClusterEXYZ() const {
195 return {ecal_cluster_ex_, ecal_cluster_ey_, ecal_cluster_ez_};
196 }
197 float getEcalClusterDXDZ() const { return ecal_cluster_dxdz_; }
198 float getEcalClusterDYDZ() const { return ecal_cluster_dydz_; }
199 float getEcalClusterEDXDZ() const { return ecal_cluster_edxdz_; }
200 float getEcalClusterEDYDZ() const { return ecal_cluster_edydz_; }
201
202 float getHcalEnergy() const { return hcal_energy_; }
203 float getHcalRawEnergy() const { return hcal_raw_energy_; }
204 std::vector<float> getHcalClusterXYZ() const {
205 return {hcal_cluster_x_, hcal_cluster_y_, hcal_cluster_z_};
206 }
207 std::vector<float> getHcalClusterEXYZ() const {
208 return {hcal_cluster_ex_, hcal_cluster_ey_, hcal_cluster_ez_};
209 }
210 float getHcalClusterDXDZ() const { return hcal_cluster_dxdz_; }
211 float getHcalClusterDYDZ() const { return hcal_cluster_dydz_; }
212 float getHcalClusterEDXDZ() const { return hcal_cluster_edxdz_; }
213 float getHcalClusterEDYDZ() const { return hcal_cluster_edydz_; }
214
215 std::vector<double> const getTruthEcalXYZ() {
216 return {truth_ecal_x_, truth_ecal_y_, truth_ecal_z_};
217 }
218 std::vector<double> const getTruthPxPyPz() {
219 return {truth_px_, truth_py_, truth_pz_};
220 }
221 double getTruthMass() { return truth_mass_; }
222 double getTruthEnergy() { return truth_energy_; }
223 int getTruthPdgId() { return truth_pdg_id_; }
224 int getTruthTrackId() const { return truth_track_id_; }
225
226 private:
227 /* Particle ID enum */
228 int pid_{0};
229 /* Reconstructed particle type and charge */
230 int pdg_id_{0};
231 int charge_{0};
232 /* Tracker dE/dx, nhits 0 when not available */
233 float dedx_mass2_{0};
234 float dedx_ih_{0};
235 int dedx_nhits_{0};
236 float mass_{0};
237 float energy_{0};
238
239 /* Position at the Target */
240 float pos_targ_x_{0};
241 float pos_targ_y_{0};
242 float pos_targ_z_{0};
243 /* Position at the ECal face */
244 float pos_ecal_x_{0};
245 float pos_ecal_y_{0};
246 float pos_ecal_z_{0};
247 /* Position at the HCal face */
248 float pos_hcal_x_{0};
249 float pos_hcal_y_{0};
250 float pos_hcal_z_{0};
251
252 /* track momenta */
253 float track_px_{0};
254 float track_py_{0};
255 float track_pz_{0};
256
257 /* Ecal energy, cluster info */
258 float ecal_energy_{0};
259 float ecal_depth_{0};
260 /* Rec hits used and the raw energy owned of each [MeV] */
261 std::vector<unsigned int> ecal_hit_ids_;
262 std::vector<float> ecal_hit_energies_;
263 std::vector<unsigned int> hcal_hit_ids_;
264 std::vector<float> hcal_hit_energies_;
265
266 /* append hits, summing the energy of ids already listed */
267 static void addHits(std::vector<unsigned int>& ids, std::vector<float>& es,
268 const std::vector<unsigned int>& new_ids,
269 const std::vector<float>& new_es);
270 float ecal_width_{0};
271 float ecal_raw_energy_{0};
272 float ecal_cluster_x_{0};
273 float ecal_cluster_y_{0};
274 float ecal_cluster_z_{0};
275 float ecal_cluster_ex_{0};
276 float ecal_cluster_ey_{0};
277 float ecal_cluster_ez_{0};
278 float ecal_cluster_dxdz_{0};
279 float ecal_cluster_dydz_{0};
280 float ecal_cluster_edxdz_{0};
281 float ecal_cluster_edydz_{0};
282
283 /* Hcal energy, cluster info */
284 float hcal_energy_{0};
285 float hcal_raw_energy_{0};
286 float hcal_cluster_x_{0};
287 float hcal_cluster_y_{0};
288 float hcal_cluster_z_{0};
289 float hcal_cluster_ex_{0};
290 float hcal_cluster_ey_{0};
291 float hcal_cluster_ez_{0};
292 float hcal_cluster_dxdz_{0};
293 float hcal_cluster_dydz_{0};
294 float hcal_cluster_edxdz_{0};
295 float hcal_cluster_edydz_{0};
296
297 /* Information for truth matched particles */
298 double truth_ecal_x_{0};
299 double truth_ecal_y_{0};
300 double truth_ecal_z_{0};
301 double truth_px_{0};
302 double truth_py_{0};
303 double truth_pz_{0};
304 double truth_mass_{0};
305 double truth_energy_{0};
306 int truth_pdg_id_{0};
307 int truth_track_id_{-1};
308
309 /* Indices of the components making up the PFlow object */
310 int track_idx_{-1};
311 int ecal_idx_{-1};
312 int hcal_idx_{-1};
313
314 /* The ROOT class definition. */
315 ClassDef(PFCandidate, 4);
316};
317} // namespace ldmx
318
319#endif /* RECON_EVENT_PFCANDIDATE_H_ */
Represents a reconstructed particle.
Definition PFCandidate.h:21