ECCE @ EIC 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 <limits.h>
9 #include <map>
10 #include <ostream>
11 #include <string>
12 #include <utility>
13 
14 using namespace std;
15 
17 
19  : DumpObject(NodeName)
20 {
21  return;
22 }
23 
25 {
26  PHG4HitContainer *phg4hitcontainer = nullptr;
27  MyNode_t *thisNode = static_cast<MyNode_t *>(myNode);
28  if (thisNode)
29  {
30  phg4hitcontainer = thisNode->getData();
31  }
32  if (phg4hitcontainer)
33  {
35  PHG4HitContainer::ConstRange hit_begin_end = phg4hitcontainer->getHits();
36  *fout << "size: " << phg4hitcontainer->size() << endl;
37  *fout << "num layers: " << phg4hitcontainer->num_layers() << endl;
38  for (hiter = hit_begin_end.first; hiter != hit_begin_end.second; hiter++)
39  {
40  *fout << "id: 0x" << hex << hiter->second->get_hit_id() << dec << endl;
41  *fout << "detid: " << hiter->second->get_detid() << endl;
42  *fout << "trkid: " << hiter->second->get_trkid() << endl;
43  *fout << "edep: " << hiter->second->get_edep() << endl;
44  for (int i = 0; i < 2; i++)
45  {
46  *fout << "x(" << i << "): " << hiter->second->get_x(i) << endl;
47  *fout << "y(" << i << "): " << hiter->second->get_y(i) << endl;
48  *fout << "z(" << i << "): " << hiter->second->get_z(i) << endl;
49  *fout << "t(" << i << "): " << hiter->second->get_t(i) << endl;
50  }
51  for (unsigned char ic = 0; ic < UCHAR_MAX; ic++)
52  {
53  PHG4Hit::PROPERTY prop_id = static_cast<PHG4Hit::PROPERTY>(ic);
54  if (hiter->second->has_property(prop_id))
55  {
56  *fout << "prop id: " << static_cast<unsigned int>(ic);
57  pair<const string, PHG4Hit::PROPERTY_TYPE> property_info = PHG4Hit::get_property_info(prop_id);
58  *fout << ", name " << property_info.first << " value ";
59  switch (property_info.second)
60  {
61  case PHG4Hit::type_int:
62  *fout << hiter->second->get_property_int(prop_id);
63  break;
64  case PHG4Hit::type_uint:
65  *fout << hiter->second->get_property_uint(prop_id);
66  break;
68  *fout << hiter->second->get_property_float(prop_id);
69  break;
70  default:
71  *fout << " unknown type ";
72  }
73  *fout << endl;
74  }
75  }
76  }
77  }
78  return 0;
79 }