Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4HeadReco.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4HeadReco.cc
1 #include "PHG4HeadReco.h"
2 
3 #include "PHG4EventHeader.h" // for PHG4EventHeader
4 #include "PHG4EventHeaderv1.h"
5 
7 
9 #include <phool/PHIODataNode.h> // for PHIODataNode
10 #include <phool/PHNode.h> // for PHNode
11 #include <phool/PHNodeIterator.h> // for PHNodeIterator
12 #include <phool/PHObject.h> // for PHObject
13 #include <phool/getClass.h>
14 #include <phool/phool.h>
15 
16 #include <TSystem.h>
17 
18 #pragma GCC diagnostic push
19 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
20 #include <HepMC/GenEvent.h>
21 #pragma GCC diagnostic pop
22 #include <HepMC/HeavyIon.h> // for HeavyIon
23 
24 #include <cstdlib>
25 #include <iostream>
26 
28  : SubsysReco(name)
29 {
30 }
31 
33 {
34  enum
35  {
36  DSTNODE,
37  RUNNODE,
38  LAST
39  }; // leave LAST at end - it is used for loops
40  // first test if neccessary nodes have been created, if not bail out
41  const char *NName[] = {
42  "DST",
43  "RUN"};
44 
45  PHNodeIterator iter(topNode);
46  PHCompositeNode *outNode[LAST];
47  for (int i = 0; i < LAST; i++)
48  {
49  outNode[i] = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", NName[i]));
50  if (!outNode[i])
51  {
52  std::cout << PHWHERE << NName[i] << " node is missing, no point in continuing exiting now" << std::endl;
53  gSystem->Exit(1);
54  // just to make scan-build happy which does not know that gSystem->Exit() terminates
55  exit(1);
56  }
57  }
58  PHG4EventHeader *eventheader = new PHG4EventHeaderv1();
59  PHIODataNode<PHObject> *newNode = new PHIODataNode<PHObject>(eventheader, "EventHeader", "PHObject");
60  outNode[DSTNODE]->addNode(newNode);
62 }
63 
65 {
66  HepMC::GenEvent *hepmcevt = findNode::getClass<HepMC::GenEvent>(topNode, "HEPMC");
67  PHG4EventHeader *evtheader = findNode::getClass<PHG4EventHeader>(topNode, "EventHeader");
68  evtseq++;
69  if (hepmcevt)
70  {
71  evtseq = hepmcevt->event_number();
72  HepMC::HeavyIon *hi = hepmcevt->heavy_ion();
73  if (hi)
74  {
75  evtheader->set_ImpactParameter(hi->impact_parameter());
76  evtheader->set_EventPlaneAngle(hi->event_plane_angle());
77  }
78  }
79  evtheader->set_EvtSequence(evtseq);
80  if (Verbosity() > 0)
81  {
82  evtheader->identify();
83  }
85 }