Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4Cell.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4Cell.cc
1 #include "PHG4Cell.h"
2 
3 #include <g4main/PHG4HitDefs.h> // for keytype
4 
5 #include <phool/PHObject.h> // for PHObject
6 
7 #include <cassert>
8 #include <cstdlib>
9 
10 void PHG4Cell::CopyFrom(const PHObject* phobj)
11 {
12  const PHG4Cell* g4cell = dynamic_cast<const PHG4Cell*>(phobj);
13  assert(g4cell);
14  set_cellid(g4cell->get_cellid());
15  for (unsigned char ic = 0; ic < UCHAR_MAX; ic++)
16  {
17  PROPERTY prop_id = static_cast<PHG4Cell::PROPERTY>(ic);
18  if (g4cell->has_property(prop_id))
19  {
20  set_property_nocheck(prop_id, g4cell->get_property_nocheck(prop_id));
21  }
22  }
23 }
24 
25 void PHG4Cell::identify(std::ostream& os) const
26 {
27  os << "Class " << this->ClassName() << std::endl;
28  return;
29 }
30 
31 std::ostream& operator<<(std::ostream& stream, const PHG4Cell* /*cell*/)
32 {
33  stream << "PHG4Cell" << std::endl;
34  return stream;
35 }
36 
38 {
39  static std::map<PHG4HitDefs::keytype, float> dummy;
40  return std::make_pair(dummy.begin(), dummy.end());
41 }
42 
44 {
45  static std::map<int, float> dummy;
46  return std::make_pair(dummy.begin(), dummy.end());
47 }
48 
50 {
51  std::cout << "Reset not implemented by daughter class" << std::endl;
52  return;
53 }
54 
55 std::pair<const std::string, PHG4Cell::PROPERTY_TYPE>
57 {
58  switch (prop_id)
59  {
60  case prop_stave_index:
61  return std::make_pair("stave index", PHG4Cell::type_int);
63  return std::make_pair("half stave index", PHG4Cell::type_int);
64  case prop_module_index:
65  return std::make_pair("module index", PHG4Cell::type_int);
66  case prop_chip_index:
67  return std::make_pair("chip index", PHG4Cell::type_int);
68  case prop_pixel_index:
69  return std::make_pair("pixel index", PHG4Cell::type_int);
70  case prop_phibin:
71  return std::make_pair("phibin", PHG4Cell::type_int);
72  case prop_zbin:
73  return std::make_pair("zbin", PHG4Cell::type_int);
75  return std::make_pair("ladder z index", PHG4Cell::type_int);
77  return std::make_pair("ladder phi index", PHG4Cell::type_int);
78  case prop_edep:
79  return std::make_pair("energy deposition", PHG4Cell::type_float);
80  case prop_eion:
81  return std::make_pair("ionizing energy loss", PHG4Cell::type_float);
82  case prop_light_yield:
83  return std::make_pair("light yield", PHG4Cell::type_float);
85  return std::make_pair("raw light yield", PHG4Cell::type_float);
86  default:
87  std::cout << "PHG4Cell::get_property_info - Fatal Error - unknown index " << prop_id << std::endl;
88  exit(1);
89  }
90 }
91 
92 bool PHG4Cell::check_property(const PROPERTY prop_id, const PROPERTY_TYPE prop_type)
93 {
94  std::pair<const std::string, PROPERTY_TYPE> property_info = get_property_info(prop_id);
95  if (property_info.second != prop_type)
96  {
97  return false;
98  }
99  return true;
100 }
101 
103 {
104  switch (prop_type)
105  {
106  case type_int:
107  return "int";
108  case type_uint:
109  return "unsigned int";
110  case type_float:
111  return "float";
112  default:
113  return "unkown";
114  }
115 }