ECCE @ EIC 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/FlagSave.h>
7 #include <ffaobjects/RunHeader.h>
9 
12 
14 #include <fun4all/Fun4AllServer.h>
15 #include <fun4all/SubsysReco.h> // for SubsysReco
16 
17 #include <phool/PHCompositeNode.h>
18 #include <phool/PHIODataNode.h> // for PHIODataNode
19 #include <phool/PHNode.h> // for PHNode
20 #include <phool/PHNodeIterator.h> // for PHNodeIterator
21 #include <phool/PHObject.h> // for PHObject
22 #include <phool/getClass.h>
23 #include <phool/recoConsts.h>
24 
25 #include <HepMC/GenEvent.h>
26 #include <HepMC/HeavyIon.h> // for HeavyIon
27 
28 #include <iostream>
29 #include <iterator> // for operator!=, reverse_iterator
30 #include <utility> // for pair
31 
32 HeadReco::HeadReco(const std::string &name)
33  : SubsysReco(name)
34 {
35 }
36 
37 // the nodes need to be created here since at least one input manager uses
38 // the event header. Creating them in InitRun() will be too late
40 {
41  PHNodeIterator iter(topNode);
42  PHCompositeNode *runNode = dynamic_cast<PHCompositeNode *>(iter.findFirst("PHCompositeNode", "RUN"));
43  RunHeader *runheader = new RunHeaderv1();
44  PHIODataNode<PHObject> *newNode = new PHIODataNode<PHObject>(runheader, "RunHeader", "PHObject");
45  runNode->addNode(newNode);
46 
47  FlagSave *flgsv = new FlagSavev1();
48  newNode = new PHIODataNode<PHObject>(flgsv, "Flags", "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  evtheader->set_RunNumber(se->RunNumber());
99  evtheader->set_EvtSequence(se->EventNumber());
100  if (Verbosity() > 0)
101  {
102  evtheader->identify();
103  }
104 
106 }
107 
108 int HeadReco::EndRun(const int /*runno*/)
109 {
111  FlagSave *flagsave = findNode::getClass<FlagSave>(se->topNode(), "Flags");
112  if (flagsave)
113  {
115  std::cout << "Saving recoConst Flags: " << std::endl;
116  flagsave->FillFromPHFlag(rc);
117  flagsave->identify();
118  }
120 }