Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4Hitv1.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4Hitv1.h
1 // Tell emacs that this is a C++ source
2 // -*- C++ -*-.
3 #ifndef G4MAIN_PHG4HITV1_H
4 #define G4MAIN_PHG4HITV1_H
5 
6 #include "PHG4Hit.h"
7 #include "PHG4HitDefs.h"
8 
9 #include <climits> // for INT_MIN, ULONG_LONG_MAX
10 #include <cmath>
11 #include <cstdint>
12 #include <iostream>
13 #include <map>
14 
15 class PHG4Hitv1 : public PHG4Hit
16 {
17  public:
18  PHG4Hitv1() = default;
19  explicit PHG4Hitv1(const PHG4Hit* g4hit);
20  ~PHG4Hitv1() override = default;
21  void identify(std::ostream& os = std::cout) const override;
22  void Reset() override;
23 
24  // The indices here represent the entry and exit points of the particle
25  float get_x(const int i) const override { return x[i]; }
26  float get_y(const int i) const override { return y[i]; }
27  float get_z(const int i) const override { return z[i]; }
28  float get_t(const int i) const override { return t[i]; }
29  float get_edep() const override { return edep; }
30  PHG4HitDefs::keytype get_hit_id() const override { return hitid; }
31  int get_detid() const override;
32  int get_shower_id() const override { return showerid; }
33  int get_trkid() const override { return trackid; }
34 
35  void set_x(const int i, const float f) override { x[i] = f; }
36  void set_y(const int i, const float f) override { y[i] = f; }
37  void set_z(const int i, const float f) override { z[i] = f; }
38  void set_t(const int i, const float f) override { t[i] = f; }
39  void set_edep(const float f) override { edep = f; }
40  void set_hit_id(const PHG4HitDefs::keytype i) override { hitid = i; }
41  void set_shower_id(const int i) override { showerid = i; }
42  void set_trkid(const int i) override { trackid = i; }
43 
44  void print() const override;
45 
46  bool has_property(const PROPERTY prop_id) const override;
47  float get_property_float(const PROPERTY prop_id) const override;
48  int get_property_int(const PROPERTY prop_id) const override;
49  unsigned int get_property_uint(const PROPERTY prop_id) const override;
50  void set_property(const PROPERTY prop_id, const float value) override;
51  void set_property(const PROPERTY prop_id, const int value) override;
52  void set_property(const PROPERTY prop_id, const unsigned int value) override;
53 
54  float get_px(const int i) const override;
55  float get_py(const int i) const override;
56  float get_pz(const int i) const override;
57  float get_local_x(const int i) const override;
58  float get_local_y(const int i) const override;
59  float get_local_z(const int i) const override;
60  float get_eion() const override { return get_property_float(prop_eion); }
61  float get_light_yield() const override { return get_property_float(prop_light_yield); }
62  float get_raw_light_yield() const override { return get_property_float(prop_raw_light_yield); }
63  float get_path_length() const override { return get_property_float(prop_path_length); }
64  unsigned int get_layer() const override { return get_property_uint(prop_layer); }
65  int get_scint_id() const override { return get_property_int(prop_scint_id); }
66  int get_row() const override { return get_property_int(prop_row); }
67  int get_sector() const override { return get_property_int(prop_sector); }
68  int get_strip_z_index() const override { return get_property_int(prop_strip_z_index); }
69  int get_strip_y_index() const override { return get_property_int(prop_strip_y_index); }
70  int get_ladder_z_index() const override { return get_property_int(prop_ladder_z_index); }
72  int get_index_i() const override { return get_property_int(prop_index_i); }
73  int get_index_j() const override { return get_property_int(prop_index_j); }
74  int get_index_k() const override { return get_property_int(prop_index_k); }
75  int get_index_l() const override { return get_property_int(prop_index_l); }
76  int get_hit_type() const override { return get_property_int(prop_hit_type); }
77 
78  void set_px(const int i, const float f) override;
79  void set_py(const int i, const float f) override;
80  void set_pz(const int i, const float f) override;
81  void set_local_x(const int i, const float f) override;
82  void set_local_y(const int i, const float f) override;
83  void set_local_z(const int i, const float f) override;
84  void set_eion(const float f) override { set_property(prop_eion, f); }
85  void set_light_yield(const float f) override { set_property(prop_light_yield, f); }
86  void set_raw_light_yield(const float f) override { set_property(prop_raw_light_yield, f); }
87  void set_path_length(const float f) override { set_property(prop_path_length, f); }
88  void set_layer(const unsigned int i) override { set_property(prop_layer, i); }
89  void set_scint_id(const int i) override { set_property(prop_scint_id, i); }
90  void set_row(const int i) override { set_property(prop_row, i); }
91  void set_sector(const int i) override { set_property(prop_sector, i); }
92  void set_strip_z_index(const int i) override { set_property(prop_strip_z_index, i); }
93  void set_strip_y_index(const int i) override { set_property(prop_strip_y_index, i); }
94  void set_ladder_z_index(const int i) override { set_property(prop_ladder_z_index, i); }
95  void set_ladder_phi_index(const int i) override { set_property(prop_ladder_phi_index, i); }
96  void set_index_i(const int i) override { set_property(prop_index_i, i); }
97  void set_index_j(const int i) override { set_property(prop_index_j, i); }
98  void set_index_k(const int i) override { set_property(prop_index_k, i); }
99  void set_index_l(const int i) override { set_property(prop_index_l, i); }
100  void set_hit_type(const int i) override { set_property(prop_hit_type, i); }
101 
102  protected:
103  unsigned int get_property_nocheck(const PROPERTY prop_id) const override;
104  void set_property_nocheck(const PROPERTY prop_id, const unsigned int ui) override { prop_map[prop_id] = ui; }
105  // Store both the entry and exit points of the particle
106  // Remember, particles do not always enter on the inner edge!
107  float x[2] = {NAN, NAN};
108  float y[2] = {NAN, NAN};
109  float z[2] = {NAN, NAN};
110  float t[2] = {NAN, NAN};
111  PHG4HitDefs::keytype hitid = ULONG_LONG_MAX;
112  int trackid = INT_MIN;
113  int showerid = INT_MIN;
114  float edep = NAN;
115 
117  typedef uint8_t prop_id_t;
118  typedef uint32_t prop_storage_t;
119  typedef std::map<prop_id_t, prop_storage_t> prop_map_t;
120 
123  {
124  float fdata;
125  int32_t idata;
126  uint32_t uidata;
127 
128  u_property(int32_t in)
129  : idata(in)
130  {
131  }
132  u_property(uint32_t in)
133  : uidata(in)
134  {
135  }
136  u_property(float in)
137  : fdata(in)
138  {
139  }
141  : uidata(0)
142  {
143  }
144 
145  prop_storage_t get_storage() const { return uidata; }
146  };
147 
150 
151  ClassDefOverride(PHG4Hitv1, 2)
152 };
153 
154 #endif