File indexing completed on 2025-08-06 08:19:21
0001 #include "PHG4HeadReco.h"
0002
0003 #include "PHG4EventHeader.h" // for PHG4EventHeader
0004 #include "PHG4EventHeaderv1.h"
0005
0006 #include <fun4all/Fun4AllReturnCodes.h>
0007
0008 #include <phool/PHCompositeNode.h>
0009 #include <phool/PHIODataNode.h> // for PHIODataNode
0010 #include <phool/PHNode.h> // for PHNode
0011 #include <phool/PHNodeIterator.h> // for PHNodeIterator
0012 #include <phool/PHObject.h> // for PHObject
0013 #include <phool/getClass.h>
0014 #include <phool/phool.h>
0015
0016 #include <TSystem.h>
0017
0018 #pragma GCC diagnostic push
0019 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
0020 #include <HepMC/GenEvent.h>
0021 #pragma GCC diagnostic pop
0022 #include <HepMC/HeavyIon.h> // for HeavyIon
0023
0024 #include <cstdlib>
0025 #include <iostream>
0026
0027 PHG4HeadReco::PHG4HeadReco(const std::string &name)
0028 : SubsysReco(name)
0029 {
0030 }
0031
0032 int PHG4HeadReco::Init(PHCompositeNode *topNode)
0033 {
0034 enum
0035 {
0036 DSTNODE,
0037 RUNNODE,
0038 LAST
0039 };
0040
0041 const char *NName[] = {
0042 "DST",
0043 "RUN"};
0044
0045 PHNodeIterator iter(topNode);
0046 PHCompositeNode *outNode[LAST];
0047 for (int i = 0; i < LAST; i++)
0048 {
0049 outNode[i] = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", NName[i]));
0050 if (!outNode[i])
0051 {
0052 std::cout << PHWHERE << NName[i] << " node is missing, no point in continuing exiting now" << std::endl;
0053 gSystem->Exit(1);
0054
0055 exit(1);
0056 }
0057 }
0058 PHG4EventHeader *eventheader = new PHG4EventHeaderv1();
0059 PHIODataNode<PHObject> *newNode = new PHIODataNode<PHObject>(eventheader, "EventHeader", "PHObject");
0060 outNode[DSTNODE]->addNode(newNode);
0061 return Fun4AllReturnCodes::EVENT_OK;
0062 }
0063
0064 int PHG4HeadReco::process_event(PHCompositeNode *topNode)
0065 {
0066 HepMC::GenEvent *hepmcevt = findNode::getClass<HepMC::GenEvent>(topNode, "HEPMC");
0067 PHG4EventHeader *evtheader = findNode::getClass<PHG4EventHeader>(topNode, "EventHeader");
0068 evtseq++;
0069 if (hepmcevt)
0070 {
0071 evtseq = hepmcevt->event_number();
0072 HepMC::HeavyIon *hi = hepmcevt->heavy_ion();
0073 if (hi)
0074 {
0075 evtheader->set_ImpactParameter(hi->impact_parameter());
0076 evtheader->set_EventPlaneAngle(hi->event_plane_angle());
0077 }
0078 }
0079 evtheader->set_EvtSequence(evtseq);
0080 if (Verbosity() > 0)
0081 {
0082 evtheader->identify();
0083 }
0084 return Fun4AllReturnCodes::EVENT_OK;
0085 }