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