File indexing completed on 2025-08-06 08:17:56
0001 #include "DumpPHG4CellContainer.h"
0002
0003 #include <phool/PHIODataNode.h>
0004
0005 #include <g4detectors/PHG4Cell.h>
0006 #include <g4detectors/PHG4CellContainer.h>
0007 #include <g4detectors/PHG4CellDefs.h>
0008
0009 #include <climits>
0010 #include <map>
0011 #include <ostream>
0012 #include <string>
0013 #include <utility>
0014
0015 using MyNode_t = PHIODataNode<PHG4CellContainer>;
0016
0017 DumpPHG4CellContainer::DumpPHG4CellContainer(const std::string &NodeName)
0018 : DumpObject(NodeName)
0019 {
0020 return;
0021 }
0022
0023 int DumpPHG4CellContainer::process_Node(PHNode *myNode)
0024 {
0025 PHG4CellContainer *phg4cellcontainer = nullptr;
0026 MyNode_t *thisNode = static_cast<MyNode_t *>(myNode);
0027 if (thisNode)
0028 {
0029 phg4cellcontainer = thisNode->getData();
0030 }
0031 if (phg4cellcontainer)
0032 {
0033 PHG4CellContainer::ConstIterator celler;
0034 PHG4CellContainer::ConstRange cell_begin_end = phg4cellcontainer->getCells();
0035 *fout << "size: " << phg4cellcontainer->size() << std::endl;
0036 for (celler = cell_begin_end.first; celler != cell_begin_end.second; celler++)
0037 {
0038 *fout << "id: 0x" << std::hex << celler->second->get_cellid() << std::dec << std::endl;
0039 if (celler->second->has_binning(PHG4CellDefs::scintillatorslatbinning))
0040 {
0041 *fout << "get_column: " << PHG4CellDefs::ScintillatorSlatBinning::get_column(celler->second->get_cellid()) << std::endl;
0042 *fout << "get_row: " << PHG4CellDefs::ScintillatorSlatBinning::get_row(celler->second->get_cellid()) << std::endl;
0043 }
0044 else if (celler->second->has_binning(PHG4CellDefs::sizebinning))
0045 {
0046 *fout << "get_phibin: " << PHG4CellDefs::SizeBinning::get_phibin(celler->second->get_cellid()) << std::endl;
0047 *fout << "get_zbin: " << PHG4CellDefs::SizeBinning::get_zbin(celler->second->get_cellid()) << std::endl;
0048 }
0049 else if (celler->second->has_binning(PHG4CellDefs::etaphibinning))
0050 {
0051 *fout << "get_etabin: " << PHG4CellDefs::EtaPhiBinning::get_etabin(celler->second->get_cellid()) << std::endl;
0052 *fout << "get_phibin: " << PHG4CellDefs::EtaPhiBinning::get_phibin(celler->second->get_cellid()) << std::endl;
0053 }
0054 else if (celler->second->has_binning(PHG4CellDefs::spacalbinning))
0055 {
0056 *fout << "get_etabin: " << PHG4CellDefs::SpacalBinning::get_etabin(celler->second->get_cellid()) << std::endl;
0057 *fout << "get_phibin: " << PHG4CellDefs::SpacalBinning::get_phibin(celler->second->get_cellid()) << std::endl;
0058 *fout << "get_fiberid: " << PHG4CellDefs::SpacalBinning::get_fiberid(celler->second->get_cellid()) << std::endl;
0059 }
0060 else if (celler->second->has_binning(PHG4CellDefs::etaxsizebinning))
0061 {
0062 *fout << "get_etabin: " << PHG4CellDefs::EtaXsizeBinning::get_etabin(celler->second->get_cellid()) << std::endl;
0063 *fout << "get_xsizebin: " << PHG4CellDefs::EtaXsizeBinning::get_xsizebin(celler->second->get_cellid()) << std::endl;
0064 }
0065 else if (celler->second->has_binning(PHG4CellDefs::mvtxbinning))
0066 {
0067 *fout << "get_index: " << PHG4CellDefs::MVTXBinning::get_index(celler->second->get_cellid()) << std::endl;
0068 }
0069 else if (celler->second->has_binning(PHG4CellDefs::tpcbinning))
0070 {
0071 *fout << "get_radbin: " << PHG4CellDefs::TPCBinning::get_radbin(celler->second->get_cellid()) << std::endl;
0072 *fout << "get_phibin: " << PHG4CellDefs::TPCBinning::get_phibin(celler->second->get_cellid()) << std::endl;
0073 }
0074 else
0075 {
0076 *fout << "binning "
0077 << PHG4CellDefs::get_binning(celler->second->get_cellid())
0078 << " for detid: "
0079 << PHG4CellDefs::get_detid(celler->second->get_cellid())
0080 << " not implemented in DumpPHG4CellContainer" << std::endl;
0081 }
0082
0083 for (auto ic = 0; ic < UCHAR_MAX; ic++)
0084 {
0085 PHG4Cell::PROPERTY prop_id = static_cast<PHG4Cell::PROPERTY>(ic);
0086 if (celler->second->has_property(prop_id))
0087 {
0088 *fout << "prop id: " << static_cast<unsigned int>(ic);
0089 std::pair<const std::string, PHG4Cell::PROPERTY_TYPE> property_info = PHG4Cell::get_property_info(prop_id);
0090 *fout << ", name " << property_info.first << " value ";
0091 switch (property_info.second)
0092 {
0093 case PHG4Cell::type_int:
0094 *fout << celler->second->get_property_int(prop_id);
0095 break;
0096 case PHG4Cell::type_uint:
0097 *fout << celler->second->get_property_uint(prop_id);
0098 break;
0099 case PHG4Cell::type_float:
0100 *fout << celler->second->get_property_float(prop_id);
0101 break;
0102 default:
0103 *fout << " unknown type ";
0104 }
0105 *fout << std::endl;
0106 }
0107 }
0108 PHG4Cell::EdepConstRange hitedep_begin_end = celler->second->get_g4hits();
0109 for (PHG4Cell::EdepConstIterator iter = hitedep_begin_end.first; iter != hitedep_begin_end.second; ++iter)
0110 {
0111 *fout << "hit 0x" << std::hex << iter->first << std::dec << " edep: " << iter->second << std::endl;
0112 }
0113 PHG4Cell::ShowerEdepConstRange shower_begin_end = celler->second->get_g4showers();
0114 for (PHG4Cell::ShowerEdepConstIterator iter = shower_begin_end.first; iter != shower_begin_end.second; ++iter)
0115 {
0116 *fout << "shower 0x" << std::hex << iter->first << std::dec << " edep: " << iter->second << std::endl;
0117 }
0118 }
0119 }
0120 return 0;
0121 }