Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DumpPHG4CellContainer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DumpPHG4CellContainer.cc
2 
3 #include <phool/PHIODataNode.h>
4 
5 #include <g4detectors/PHG4Cell.h>
8 
9 #include <climits>
10 #include <map>
11 #include <ostream>
12 #include <string>
13 #include <utility>
14 
16 
18  : DumpObject(NodeName)
19 {
20  return;
21 }
22 
24 {
25  PHG4CellContainer *phg4cellcontainer = nullptr;
26  MyNode_t *thisNode = static_cast<MyNode_t *>(myNode);
27  if (thisNode)
28  {
29  phg4cellcontainer = thisNode->getData();
30  }
31  if (phg4cellcontainer)
32  {
34  PHG4CellContainer::ConstRange cell_begin_end = phg4cellcontainer->getCells();
35  *fout << "size: " << phg4cellcontainer->size() << std::endl;
36  for (celler = cell_begin_end.first; celler != cell_begin_end.second; celler++)
37  {
38  *fout << "id: 0x" << std::hex << celler->second->get_cellid() << std::dec << std::endl;
39  if (celler->second->has_binning(PHG4CellDefs::scintillatorslatbinning))
40  {
41  *fout << "get_column: " << PHG4CellDefs::ScintillatorSlatBinning::get_column(celler->second->get_cellid()) << std::endl;
42  *fout << "get_row: " << PHG4CellDefs::ScintillatorSlatBinning::get_row(celler->second->get_cellid()) << std::endl;
43  }
44  else if (celler->second->has_binning(PHG4CellDefs::sizebinning))
45  {
46  *fout << "get_phibin: " << PHG4CellDefs::SizeBinning::get_phibin(celler->second->get_cellid()) << std::endl;
47  *fout << "get_zbin: " << PHG4CellDefs::SizeBinning::get_zbin(celler->second->get_cellid()) << std::endl;
48  }
49  else if (celler->second->has_binning(PHG4CellDefs::etaphibinning))
50  {
51  *fout << "get_etabin: " << PHG4CellDefs::EtaPhiBinning::get_etabin(celler->second->get_cellid()) << std::endl;
52  *fout << "get_phibin: " << PHG4CellDefs::EtaPhiBinning::get_phibin(celler->second->get_cellid()) << std::endl;
53  }
54  else if (celler->second->has_binning(PHG4CellDefs::spacalbinning))
55  {
56  *fout << "get_etabin: " << PHG4CellDefs::SpacalBinning::get_etabin(celler->second->get_cellid()) << std::endl;
57  *fout << "get_phibin: " << PHG4CellDefs::SpacalBinning::get_phibin(celler->second->get_cellid()) << std::endl;
58  *fout << "get_fiberid: " << PHG4CellDefs::SpacalBinning::get_fiberid(celler->second->get_cellid()) << std::endl;
59  }
60  else if (celler->second->has_binning(PHG4CellDefs::etaxsizebinning))
61  {
62  *fout << "get_etabin: " << PHG4CellDefs::EtaXsizeBinning::get_etabin(celler->second->get_cellid()) << std::endl;
63  *fout << "get_xsizebin: " << PHG4CellDefs::EtaXsizeBinning::get_xsizebin(celler->second->get_cellid()) << std::endl;
64  }
65  else if (celler->second->has_binning(PHG4CellDefs::mvtxbinning))
66  {
67  *fout << "get_index: " << PHG4CellDefs::MVTXBinning::get_index(celler->second->get_cellid()) << std::endl;
68  }
69  else if (celler->second->has_binning(PHG4CellDefs::tpcbinning))
70  {
71  *fout << "get_radbin: " << PHG4CellDefs::TPCBinning::get_radbin(celler->second->get_cellid()) << std::endl;
72  *fout << "get_phibin: " << PHG4CellDefs::TPCBinning::get_phibin(celler->second->get_cellid()) << std::endl;
73  }
74  else
75  {
76  *fout << "binning "
77  << PHG4CellDefs::get_binning(celler->second->get_cellid())
78  << " for detid: "
79  << PHG4CellDefs::get_detid(celler->second->get_cellid())
80  << " not implemented in DumpPHG4CellContainer" << std::endl;
81  }
82 
83  for (auto ic = 0; ic < UCHAR_MAX; ic++)
84  {
85  PHG4Cell::PROPERTY prop_id = static_cast<PHG4Cell::PROPERTY>(ic);
86  if (celler->second->has_property(prop_id))
87  {
88  *fout << "prop id: " << static_cast<unsigned int>(ic);
89  std::pair<const std::string, PHG4Cell::PROPERTY_TYPE> property_info = PHG4Cell::get_property_info(prop_id);
90  *fout << ", name " << property_info.first << " value ";
91  switch (property_info.second)
92  {
93  case PHG4Cell::type_int:
94  *fout << celler->second->get_property_int(prop_id);
95  break;
97  *fout << celler->second->get_property_uint(prop_id);
98  break;
100  *fout << celler->second->get_property_float(prop_id);
101  break;
102  default:
103  *fout << " unknown type ";
104  }
105  *fout << std::endl;
106  }
107  }
108  PHG4Cell::EdepConstRange hitedep_begin_end = celler->second->get_g4hits();
109  for (PHG4Cell::EdepConstIterator iter = hitedep_begin_end.first; iter != hitedep_begin_end.second; ++iter)
110  {
111  *fout << "hit 0x" << std::hex << iter->first << std::dec << " edep: " << iter->second << std::endl;
112  }
113  PHG4Cell::ShowerEdepConstRange shower_begin_end = celler->second->get_g4showers();
114  for (PHG4Cell::ShowerEdepConstIterator iter = shower_begin_end.first; iter != shower_begin_end.second; ++iter)
115  {
116  *fout << "shower 0x" << std::hex << iter->first << std::dec << " edep: " << iter->second << std::endl;
117  }
118  }
119  }
120  return 0;
121 }