Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:56

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);  // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
0026   if (thisNode)
0027   {
0028     phg4hitcontainer = thisNode->getData();
0029   }
0030   if (phg4hitcontainer)
0031   {
0032     PHG4HitContainer::ConstIterator hiter;
0033     PHG4HitContainer::ConstRange hit_begin_end = phg4hitcontainer->getHits();
0034     *fout << "size: " << phg4hitcontainer->size() << std::endl;
0035     *fout << "num layers: " << phg4hitcontainer->num_layers() << std::endl;
0036     for (hiter = hit_begin_end.first; hiter != hit_begin_end.second; hiter++)
0037     {
0038       *fout << "id: 0x" << std::hex << hiter->second->get_hit_id() << std::dec << std::endl;
0039       *fout << "detid: " << hiter->second->get_detid() << std::endl;
0040       *fout << "trkid: " << hiter->second->get_trkid() << std::endl;
0041       *fout << "edep: " << hiter->second->get_edep() << std::endl;
0042       for (int i = 0; i < 2; i++)
0043       {
0044         *fout << "x(" << i << "): " << hiter->second->get_x(i) << std::endl;
0045         *fout << "y(" << i << "): " << hiter->second->get_y(i) << std::endl;
0046         *fout << "z(" << i << "): " << hiter->second->get_z(i) << std::endl;
0047         *fout << "t(" << i << "): " << hiter->second->get_t(i) << std::endl;
0048       }
0049       for (auto ic = 0; ic < UCHAR_MAX; ic++)
0050       {
0051         PHG4Hit::PROPERTY prop_id = static_cast<PHG4Hit::PROPERTY>(ic);
0052         if (hiter->second->has_property(prop_id))
0053         {
0054           *fout << "prop id: " << static_cast<unsigned int>(ic);
0055           std::pair<const std::string, PHG4Hit::PROPERTY_TYPE> property_info = PHG4Hit::get_property_info(prop_id);
0056           *fout << ", name " << property_info.first << " value ";
0057           switch (property_info.second)
0058           {
0059           case PHG4Hit::type_int:
0060             *fout << hiter->second->get_property_int(prop_id);
0061             break;
0062           case PHG4Hit::type_uint:
0063             *fout << hiter->second->get_property_uint(prop_id);
0064             break;
0065           case PHG4Hit::type_float:
0066             *fout << hiter->second->get_property_float(prop_id);
0067             break;
0068           default:
0069             *fout << " unknown type ";
0070           }
0071           *fout << std::endl;
0072         }
0073       }
0074     }
0075   }
0076   return 0;
0077 }