ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4InEventCompress.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4InEventCompress.cc
1 #include "PHG4InEventCompress.h"
2 
3 #include "PHG4InEvent.h"
4 #include "PHG4VtxPoint.h"
5 #include "PHG4Particle.h"
6 
10 
12 
13 #include <phool/getClass.h>
14 #include <phool/PHCompositeNode.h>
15 #include <phool/PHIODataNode.h>
16 #include <phool/PHNode.h> // for PHNode
17 #include <phool/PHNodeIterator.h> // for PHNodeIterator
18 #include <phool/PHObject.h> // for PHObject
19 
20 #include <cstdlib>
21 #include <iostream>
22 #include <map> // for _Rb_tree_const_iterator
23 #include <utility> // for pair
24 #include <vector>
25 
26 using namespace std;
27 
29  SubsysReco(name),
30  vtxarray(nullptr),
31  particlearray(nullptr)
32 {}
33 
34 int
36 {
37  PHNodeIterator iter(topNode);
38  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode*>(iter.findFirst("PHCompositeNode", "DST"));
39 
40 
41  PHIODataNode<PHObject> *PHObjectIONode;
42 
44  PHObjectIONode = new PHIODataNode<PHObject>(vtxarray, "PHG4Vtx_VarArray", "PHObject");
45  dstNode->addNode(PHObjectIONode);
46 
48  PHObjectIONode = new PHIODataNode<PHObject>(particlearray, "PHG4Particle_VarArray", "PHObject");
49  dstNode->addNode(PHObjectIONode);
50 
52 }
53 
54 int
56 {
57  PHG4InEvent *inEvent = findNode::getClass<PHG4InEvent>(topNode,"PHG4INEVENT");
58  if (!inEvent)
59  {
60  cout << "no PHG4INEVENT node found" << endl;
62  }
63 
64  map<int, PHG4VtxPoint *>::const_iterator vtxiter;
65  std::pair< std::map<int, PHG4VtxPoint *>::const_iterator, std::map<int, PHG4VtxPoint *>::const_iterator > vtxbegin_end = inEvent->GetVertices();
66  vector<short> svtxvec;
67  for (vtxiter = vtxbegin_end.first; vtxiter != vtxbegin_end.second; ++vtxiter)
68  {
69  if ((*vtxiter).first > 0xFFFF)
70  {
71  cout << "id of vertex " << (*vtxiter).first << " exceeds max val of " << 0xFFFF << endl;
72  exit(1);
73  }
74  svtxvec.push_back((*vtxiter).first);
75  svtxvec.push_back(VariableArrayUtils::FloatToShortBits((*vtxiter->second).get_x()));
76  svtxvec.push_back(VariableArrayUtils::FloatToShortBits((*vtxiter->second).get_y()));
77  svtxvec.push_back(VariableArrayUtils::FloatToShortBits((*vtxiter->second).get_z()));
78  svtxvec.push_back(VariableArrayUtils::FloatToShortBits((*vtxiter->second).get_t()));
79  }
80  vtxarray->set_val(svtxvec);
81 
82  pair<multimap<int, PHG4Particle *>::const_iterator, multimap<int, PHG4Particle *>::const_iterator > particlebegin_end = inEvent->GetParticles();
83  multimap<int,PHG4Particle *>::const_iterator particle_iter;
84  vector<short> spartvec;
85  for (particle_iter = particlebegin_end.first; particle_iter != particlebegin_end.second; ++particle_iter)
86  {
87  if ((*particle_iter).first > 0xFFFF)
88  {
89  cout << "id of vertex " << (*particle_iter).first << " exceeds max val of " << 0xFFFF << endl;
90  exit(1);
91  }
92  spartvec.push_back((*particle_iter).first);
93  if (abs((*particle_iter->second).get_pid()) > 0xFFFF)
94  {
95  cout << "pdg code of particle " << (*particle_iter->second).get_pid() << " exceeds max val of " << 0xFFFF << endl;
96  exit(1);
97  }
98  spartvec.push_back((*particle_iter->second).get_pid());
99 
100  spartvec.push_back(VariableArrayUtils::FloatToShortBits((*particle_iter->second).get_px()));
101  spartvec.push_back(VariableArrayUtils::FloatToShortBits((*particle_iter->second).get_py()));
102  spartvec.push_back(VariableArrayUtils::FloatToShortBits((*particle_iter->second).get_pz()));
103  }
104  particlearray->set_val(spartvec);
105  // inEvent->identify();
107 }
108 
109 int
111 {
113 }