Analysis Software
Documentation for sPHENIX simulation 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 prop_raw_light_yield:
86  return make_pair("raw light yield",PHG4Hit::type_float);
87  case scint_gammas:
88  return make_pair("scintillation photons",PHG4Hit::type_float);
89  case cerenkov_gammas:
90  return make_pair("cerenkov photons",PHG4Hit::type_float);
91  case prop_px_0:
92  return make_pair("px in",PHG4Hit::type_float);
93  case prop_px_1:
94  return make_pair("px out",PHG4Hit::type_float);
95  case prop_py_0:
96  return make_pair("py in",PHG4Hit::type_float);
97  case prop_py_1:
98  return make_pair("py out",PHG4Hit::type_float);
99  case prop_pz_0:
100  return make_pair("pz in",PHG4Hit::type_float);
101  case prop_pz_1:
102  return make_pair("pz out",PHG4Hit::type_float);
103  case prop_local_x_0:
104  return make_pair("local x in",PHG4Hit::type_float);
105  case prop_local_x_1:
106  return make_pair("local x out",PHG4Hit::type_float);
107  case prop_local_y_0:
108  return make_pair("local y in",PHG4Hit::type_float);
109  case prop_local_y_1:
110  return make_pair("local y out",PHG4Hit::type_float);
111  case prop_local_z_0:
112  return make_pair("local z in",PHG4Hit::type_float);
113  case prop_local_z_1:
114  return make_pair("local z out",PHG4Hit::type_float);
115  case prop_path_length:
116  return make_pair("pathlength",PHG4Hit::type_float);
117  case prop_layer:
118  return make_pair("layer ID",PHG4Hit::type_uint);
119  case prop_scint_id:
120  return make_pair("scintillator ID",PHG4Hit::type_int);
121  case prop_row:
122  return make_pair("row",PHG4Hit::type_int);
123  case prop_sector:
124  return make_pair("sector",PHG4Hit::type_int);
125  case prop_strip_z_index:
126  return make_pair("strip z index",PHG4Hit::type_int);
127  case prop_strip_y_index:
128  return make_pair("strip y index",PHG4Hit::type_int);
129  case prop_ladder_z_index:
130  return make_pair("ladder z index",PHG4Hit::type_int);
131  case prop_ladder_phi_index:
132  return make_pair("ladder phi index",PHG4Hit::type_int);
133  case prop_index_i:
134  return make_pair("generic index i",PHG4Hit::type_int);
135  case prop_index_j:
136  return make_pair("generic index j",PHG4Hit::type_int);
137  case prop_index_k:
138  return make_pair("generic index k",PHG4Hit::type_int);
139  case prop_index_l:
140  return make_pair("generic index l",PHG4Hit::type_int);
141  case prop_stave_index:
142  return make_pair("stave index",PHG4Hit::type_int);
143  case prop_half_stave_index:
144  return make_pair("half stave index",PHG4Hit::type_int);
145  case prop_module_index:
146  return make_pair("module index",PHG4Hit::type_int);
147  case prop_chip_index:
148  return make_pair("chip index",PHG4Hit::type_int);
149  case prop_local_pos_x_0:
150  return make_pair("local x pos in",PHG4Hit::type_float);
151  case prop_local_pos_y_0:
152  return make_pair("local y pos in",PHG4Hit::type_float);
153  case prop_local_pos_z_0:
154  return make_pair("local z pos in",PHG4Hit::type_float);
155  case prop_hit_type:
156  return make_pair("hit type",PHG4Hit::type_int);
157  case prop_local_pos_x_1:
158  return make_pair("local x pos out",PHG4Hit::type_float);
159  case prop_local_pos_y_1:
160  return make_pair("local y pos out",PHG4Hit::type_float);
161  case prop_local_pos_z_1:
162  return make_pair("local z pos out",PHG4Hit::type_float);
163 
164  default:
165  cout << "PHG4Hit::get_property_info - Fatal Error - unknown index " << prop_id << endl;
166  gSystem->Exit(1);
167  exit(1);
168  }
169 }
170 
171 
172 bool
173 PHG4Hit::check_property(const PROPERTY prop_id, const PROPERTY_TYPE prop_type)
174 {
175  pair<const string,PROPERTY_TYPE> property_info = get_property_info(prop_id);
176  if (property_info.second != prop_type)
177  {
178  return false;
179  }
180  return true;
181 }
182 
183 string
185 {
186  switch(prop_type)
187  {
188  case type_int:
189  return "int";
190  case type_uint:
191  return "unsigned int";
192  case type_float:
193  return "float";
194  default:
195  return "unkown";
196  }
197 }