Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DumpPHG4HitContainer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DumpPHG4HitContainer.cc
1 #include "DumpPHG4HitContainer.h"
2 
3 #include <phool/PHIODataNode.h>
4 
5 #include <g4main/PHG4Hit.h>
7 
8 #include <climits>
9 #include <map>
10 #include <ostream>
11 #include <string>
12 #include <utility>
13 
15 
17  : DumpObject(NodeName)
18 {
19  return;
20 }
21 
23 {
24  PHG4HitContainer *phg4hitcontainer = nullptr;
25  MyNode_t *thisNode = static_cast<MyNode_t *>(myNode);
26  if (thisNode)
27  {
28  phg4hitcontainer = thisNode->getData();
29  }
30  if (phg4hitcontainer)
31  {
33  PHG4HitContainer::ConstRange hit_begin_end = phg4hitcontainer->getHits();
34  *fout << "size: " << phg4hitcontainer->size() << std::endl;
35  *fout << "num layers: " << phg4hitcontainer->num_layers() << std::endl;
36  for (hiter = hit_begin_end.first; hiter != hit_begin_end.second; hiter++)
37  {
38  *fout << "id: 0x" << std::hex << hiter->second->get_hit_id() << std::dec << std::endl;
39  *fout << "detid: " << hiter->second->get_detid() << std::endl;
40  *fout << "trkid: " << hiter->second->get_trkid() << std::endl;
41  *fout << "edep: " << hiter->second->get_edep() << std::endl;
42  for (int i = 0; i < 2; i++)
43  {
44  *fout << "x(" << i << "): " << hiter->second->get_x(i) << std::endl;
45  *fout << "y(" << i << "): " << hiter->second->get_y(i) << std::endl;
46  *fout << "z(" << i << "): " << hiter->second->get_z(i) << std::endl;
47  *fout << "t(" << i << "): " << hiter->second->get_t(i) << std::endl;
48  }
49  for (auto ic = 0; ic < UCHAR_MAX; ic++)
50  {
51  PHG4Hit::PROPERTY prop_id = static_cast<PHG4Hit::PROPERTY>(ic);
52  if (hiter->second->has_property(prop_id))
53  {
54  *fout << "prop id: " << static_cast<unsigned int>(ic);
55  std::pair<const std::string, PHG4Hit::PROPERTY_TYPE> property_info = PHG4Hit::get_property_info(prop_id);
56  *fout << ", name " << property_info.first << " value ";
57  switch (property_info.second)
58  {
59  case PHG4Hit::type_int:
60  *fout << hiter->second->get_property_int(prop_id);
61  break;
62  case PHG4Hit::type_uint:
63  *fout << hiter->second->get_property_uint(prop_id);
64  break;
66  *fout << hiter->second->get_property_float(prop_id);
67  break;
68  default:
69  *fout << " unknown type ";
70  }
71  *fout << std::endl;
72  }
73  }
74  }
75  }
76  return 0;
77 }