Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HeadReco.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HeadReco.cc
1 #include "HeadReco.h"
2 
5 #include <ffaobjects/RunHeader.h>
7 
10 
12 #include <fun4all/Fun4AllServer.h>
13 #include <fun4all/SubsysReco.h> // for SubsysReco
14 
15 #include <phool/PHCompositeNode.h>
16 #include <phool/PHIODataNode.h> // for PHIODataNode
17 #include <phool/PHNode.h> // for PHNode
18 #include <phool/PHNodeIterator.h> // for PHNodeIterator
19 #include <phool/PHObject.h> // for PHObject
20 #include <phool/getClass.h>
21 #include <phool/recoConsts.h>
22 
23 #include <Event/Event.h>
24 
25 #pragma GCC diagnostic push
26 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
27 #include <HepMC/GenEvent.h>
28 #pragma GCC diagnostic pop
29 
30 #include <HepMC/HeavyIon.h> // for HeavyIon
31 
32 #include <iterator> // for operator!=, reverse_iterator
33 #include <map> // for _Rb_tree_iterator
34 #include <utility> // for pair
35 
37  : SubsysReco(name)
38 {
39 }
40 
41 // the nodes need to be created here since at least one input manager uses
42 // the event header. Creating them in InitRun() will be too late
44 {
45  PHNodeIterator iter(topNode);
46  PHCompositeNode *runNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "RUN"));
47  RunHeader *runheader = new RunHeaderv1();
48  PHIODataNode<PHObject> *newNode = new PHIODataNode<PHObject>(runheader, "RunHeader", "PHObject");
49  runNode->addNode(newNode);
50 
51  PHCompositeNode *dstNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "DST"));
52  EventHeader *eventheader = new EventHeaderv1();
53  newNode = new PHIODataNode<PHObject>(eventheader, "EventHeader", "PHObject");
54  dstNode->addNode(newNode);
55 
57 }
58 
60 {
62  RunHeader *runheader = findNode::getClass<RunHeader>(topNode, "RunHeader");
63  runheader->set_RunNumber(rc->get_IntFlag("RUNNUMBER"));
65 }
66 
68 {
70  EventHeader *evtheader = findNode::getClass<EventHeader>(topNode, "EventHeader");
71  PHHepMCGenEventMap *genevtmap = findNode::getClass<PHHepMCGenEventMap>(topNode, "PHHepMCGenEventMap");
72 
73  if (genevtmap)
74  {
75  for (PHHepMCGenEventMap::ReverseIter iter = genevtmap->rbegin(); iter != genevtmap->rend(); ++iter)
76  {
77  PHHepMCGenEvent *genevt = iter->second;
78  int embed_flag = genevt->get_embedding_id();
79  if (embed_flag == 0) // should be foreground event
80  {
81  HepMC::GenEvent *hepmcevt = genevt->getEvent();
82 
83  if (hepmcevt)
84  {
85  HepMC::HeavyIon *hi = hepmcevt->heavy_ion();
86  if (hi)
87  {
88  evtheader->set_ImpactParameter(hi->impact_parameter());
89  evtheader->set_EventPlaneAngle(hi->event_plane_angle());
90  evtheader->set_eccentricity(hi->eccentricity());
91  evtheader->set_ncoll(hi->Ncoll());
92  evtheader->set_npart(hi->Npart_targ() + hi->Npart_proj());
93  }
94  }
95  }
96  }
97  }
98  else
99  {
100  Event *evt = findNode::getClass<Event>(topNode, "PRDF");
101  if (evt)
102  {
103  evtheader->set_EvtType(evt->getEvtType());
104  }
105  }
106  evtheader->set_RunNumber(se->RunNumber());
107  evtheader->set_EvtSequence(se->EventNumber());
108  if (Verbosity() > 0)
109  {
110  evtheader->identify();
111  }
112 
114 }