File indexing completed on 2025-12-16 09:20:16
0001 #include "DumpPHG4HitContainer.h"
0002
0003 #include <phool/PHIODataNode.h>
0004
0005 #include <g4main/PHG4Hit.h>
0006 #include <g4main/PHG4HitContainer.h>
0007
0008 #include <climits>
0009 #include <map>
0010 #include <ostream>
0011 #include <string>
0012 #include <utility>
0013
0014 using MyNode_t = PHIODataNode<PHG4HitContainer>;
0015
0016 DumpPHG4HitContainer::DumpPHG4HitContainer(const std::string &NodeName)
0017 : DumpObject(NodeName)
0018 {
0019 return;
0020 }
0021
0022 int DumpPHG4HitContainer::process_Node(PHNode *myNode)
0023 {
0024 PHG4HitContainer *phg4hitcontainer = nullptr;
0025 MyNode_t *thisNode = static_cast<MyNode_t *>(myNode);
0026 if (thisNode)
0027 {
0028 phg4hitcontainer = thisNode->getData();
0029 }
0030 if (phg4hitcontainer)
0031 {
0032 (*fout).precision(std::numeric_limits<float>::max_digits10);
0033 PHG4HitContainer::ConstIterator hiter;
0034 PHG4HitContainer::ConstRange hit_begin_end = phg4hitcontainer->getHits();
0035 *fout << "size: " << phg4hitcontainer->size() << std::endl;
0036 *fout << "num layers: " << phg4hitcontainer->num_layers() << std::endl;
0037 for (hiter = hit_begin_end.first; hiter != hit_begin_end.second; hiter++)
0038 {
0039 *fout << "id: 0x" << std::hex << hiter->second->get_hit_id() << std::dec << std::endl;
0040 *fout << "detid: " << hiter->second->get_detid() << std::endl;
0041 *fout << "trkid: " << hiter->second->get_trkid() << std::endl;
0042 *fout << "edep: " << hiter->second->get_edep() << std::endl;
0043 for (int i = 0; i < 2; i++)
0044 {
0045 *fout << "x(" << i << "): " << hiter->second->get_x(i) << std::endl;
0046 *fout << "y(" << i << "): " << hiter->second->get_y(i) << std::endl;
0047 *fout << "z(" << i << "): " << hiter->second->get_z(i) << std::endl;
0048 *fout << "t(" << i << "): " << hiter->second->get_t(i) << std::endl;
0049 }
0050 for (auto ic = 0; ic < UCHAR_MAX; ic++)
0051 {
0052 PHG4Hit::PROPERTY prop_id = static_cast<PHG4Hit::PROPERTY>(ic);
0053 if (hiter->second->has_property(prop_id))
0054 {
0055 *fout << "prop id: " << static_cast<unsigned int>(ic);
0056 std::pair<const std::string, PHG4Hit::PROPERTY_TYPE> property_info = PHG4Hit::get_property_info(prop_id);
0057 *fout << ", name " << property_info.first << " value ";
0058 switch (property_info.second)
0059 {
0060 case PHG4Hit::type_int:
0061 *fout << hiter->second->get_property_int(prop_id);
0062 break;
0063 case PHG4Hit::type_uint:
0064 *fout << hiter->second->get_property_uint(prop_id);
0065 break;
0066 case PHG4Hit::type_float:
0067 *fout << hiter->second->get_property_float(prop_id);
0068 break;
0069 default:
0070 *fout << " unknown type ";
0071 }
0072 *fout << std::endl;
0073 }
0074 }
0075 }
0076 }
0077 return 0;
0078 }