ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4Hit.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4Hit.cc
1 #include "PHG4Hit.h"
2 
3 #include <TSystem.h> // for gSystem
4 
5 #include <cassert>
6 #include <cstdlib>
7 #include <type_traits>
8 
9 using namespace std;
10 
11 void
13 {
14  const PHG4Hit *g4hit = dynamic_cast<const PHG4Hit *> (phobj);
15  assert(g4hit);
16  for (int i =0; i<2; i++)
17  {
18  set_x(i,g4hit->get_x(i));
19  set_y(i,g4hit->get_y(i));
20  set_z(i,g4hit->get_z(i));
21  set_t(i,g4hit->get_t(i));
22  }
23  set_edep(g4hit->get_edep());
24  set_hit_id(g4hit->get_hit_id());
25  set_shower_id(g4hit->get_shower_id());
26  set_trkid(g4hit->get_trkid());
27 // This is a generic copy of ALL properties a hit has
28 // do not add explicit copies, they will be added to
29 // the new hits with their default value increasing memory use
30  for (unsigned char ic = 0; ic < UCHAR_MAX; ic++)
31  {
32  PROPERTY prop_id = static_cast<PHG4Hit::PROPERTY> (ic);
33  if (g4hit->has_property(prop_id))
34  {
35  set_property_nocheck(prop_id,g4hit->get_property_nocheck(prop_id));
36  }
37  }
38 }
39 
40 
41 void
42 PHG4Hit::identify(ostream& os) const
43 {
44  os << "Class " << this->ClassName() << endl;
45  os << "x0: " << get_x(0)
46  << ", y0: " << get_y(0)
47  << ", z0: " << get_z(0)
48  << ", t0: " << get_t(0) << endl;
49  os << "x1: " << get_x(1)
50  << ", y1: " << get_y(1)
51  << ", z1: " << get_z(1)
52  << ", t1: " << get_t(1) << endl;
53  os << "trackid: " << get_trkid() << ", edep: " << get_edep() << endl;
54  os << "strip_z_index: " << get_strip_z_index() << ", strip_y_index: " << get_strip_y_index() << endl;
55  os << "ladder_z_index: " << get_ladder_z_index() << ", ladder_phi_index: " << get_ladder_phi_index() << endl;
56  os << "stave_index: " << get_property_int(prop_stave_index) << " half_stave_index " << get_property_int(prop_half_stave_index) << endl;
57  os << "module_index: " << get_property_int(prop_module_index) << " chip_index " << get_property_int(prop_chip_index) << endl;
58  os << "layer id: " << get_layer() << ", scint_id: " << get_scint_id() << endl;
59  os << "hit type: " << get_hit_type() << endl;
60  return;
61 }
62 
63 ostream& operator<<(ostream& stream, const PHG4Hit * hit){
64  stream <<endl<< "(x,y,z) = "<< "("<<hit->get_avg_x()<<", "<<hit->get_avg_y()<<", "<<hit->get_avg_z()<<")"<<endl;
65  stream << "trackid: " << hit->get_trkid()<<" hitid: "<<hit->get_hit_id()<<" layer: "<<hit->get_layer()<<endl;
66  return stream;
67 }
68 
69 void
71 {
72  cout << "Reset not implemented by daughter class" << endl;
73  return;
74 }
75 
76 std::pair<const std::string,PHG4Hit::PROPERTY_TYPE>
78 {
79  switch (prop_id)
80  {
81  case prop_eion:
82  return make_pair("ionizing energy loss",PHG4Hit::type_float);
83  case prop_light_yield:
84  return make_pair("light yield",PHG4Hit::type_float);
85  case scint_gammas:
86  return make_pair("scintillation photons",PHG4Hit::type_float);
87  case cerenkov_gammas:
88  return make_pair("cerenkov photons",PHG4Hit::type_float);
89  case prop_px_0:
90  return make_pair("px in",PHG4Hit::type_float);
91  case prop_px_1:
92  return make_pair("px out",PHG4Hit::type_float);
93  case prop_py_0:
94  return make_pair("py in",PHG4Hit::type_float);
95  case prop_py_1:
96  return make_pair("py out",PHG4Hit::type_float);
97  case prop_pz_0:
98  return make_pair("pz in",PHG4Hit::type_float);
99  case prop_pz_1:
100  return make_pair("pz out",PHG4Hit::type_float);
101  case prop_local_x_0:
102  return make_pair("local x in",PHG4Hit::type_float);
103  case prop_local_x_1:
104  return make_pair("local x out",PHG4Hit::type_float);
105  case prop_local_y_0:
106  return make_pair("local y in",PHG4Hit::type_float);
107  case prop_local_y_1:
108  return make_pair("local y out",PHG4Hit::type_float);
109  case prop_local_z_0:
110  return make_pair("local z in",PHG4Hit::type_float);
111  case prop_local_z_1:
112  return make_pair("local z out",PHG4Hit::type_float);
113  case prop_path_length:
114  return make_pair("pathlength",PHG4Hit::type_float);
115  case prop_layer:
116  return make_pair("layer ID",PHG4Hit::type_uint);
117  case prop_scint_id:
118  return make_pair("scintillator ID",PHG4Hit::type_int);
119  case prop_row:
120  return make_pair("row",PHG4Hit::type_int);
121  case prop_strip_z_index:
122  return make_pair("strip z index",PHG4Hit::type_int);
123  case prop_strip_y_index:
124  return make_pair("strip y index",PHG4Hit::type_int);
125  case prop_ladder_z_index:
126  return make_pair("ladder z index",PHG4Hit::type_int);
127  case prop_ladder_phi_index:
128  return make_pair("ladder phi index",PHG4Hit::type_int);
129  case prop_index_i:
130  return make_pair("generic index i",PHG4Hit::type_int);
131  case prop_index_j:
132  return make_pair("generic index j",PHG4Hit::type_int);
133  case prop_index_k:
134  return make_pair("generic index k",PHG4Hit::type_int);
135  case prop_index_l:
136  return make_pair("generic index l",PHG4Hit::type_int);
137  case prop_stave_index:
138  return make_pair("stave index",PHG4Hit::type_int);
139  case prop_half_stave_index:
140  return make_pair("half stave index",PHG4Hit::type_int);
141  case prop_module_index:
142  return make_pair("module index",PHG4Hit::type_int);
143  case prop_chip_index:
144  return make_pair("chip index",PHG4Hit::type_int);
145  case prop_local_pos_x_0:
146  return make_pair("local x pos in",PHG4Hit::type_float);
147  case prop_local_pos_y_0:
148  return make_pair("local y pos in",PHG4Hit::type_float);
149  case prop_local_pos_z_0:
150  return make_pair("local z pos in",PHG4Hit::type_float);
151  case prop_hit_type:
152  return make_pair("hit type",PHG4Hit::type_int);
153  case prop_local_pos_x_1:
154  return make_pair("local x pos out",PHG4Hit::type_float);
155  case prop_local_pos_y_1:
156  return make_pair("local y pos out",PHG4Hit::type_float);
157  case prop_local_pos_z_1:
158  return make_pair("local z pos out",PHG4Hit::type_float);
159 
160  default:
161  cout << "PHG4Hit::get_property_info - Fatal Error - unknown index " << prop_id << endl;
162  gSystem->Exit(1);
163  exit(1);
164  }
165 }
166 
167 
168 bool
169 PHG4Hit::check_property(const PROPERTY prop_id, const PROPERTY_TYPE prop_type)
170 {
171  pair<const string,PROPERTY_TYPE> property_info = get_property_info(prop_id);
172  if (property_info.second != prop_type)
173  {
174  return false;
175  }
176  return true;
177 }
178 
179 string
181 {
182  switch(prop_type)
183  {
184  case type_int:
185  return "int";
186  case type_uint:
187  return "unsigned int";
188  case type_float:
189  return "float";
190  default:
191  return "unkown";
192  }
193 }