Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MvtxRunInfoUnpackPRDF.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MvtxRunInfoUnpackPRDF.C
2 
3 #include <Event/Event.h>
4 #include <Event/EventTypes.h>
5 #include <Event/packetConstants.h>
6 #include <Event/packet.h>
7 #include <Event/packet_hbd_fpgashort.h>
9 #include <phool/phool.h>
10 #include <phool/getClass.h>
11 #include <phool/recoConsts.h>
13 #include <pdbcalbase/PdbParameterMap.h>
14 #include <phparameter/PHParameters.h>
15 
17 
18 #include <iostream>
19 #include <string>
20 #include <cassert>
21 #include <sstream>
22 
23 using namespace std;
24 
26 
27 //____________________________________
29  SubsysReco("MvtxRunInfoUnpackPRDF"),
30  /*PHCompositeNode **/ dstNode(NULL),
31  /*Event**/_event(NULL),
32  /*Packet_hbd_fpgashort**/_packet(NULL)
33 {
34 
35 }
36 
37 //____________________________________
38 int
40 {
41 
42  cout << "-----MvtxRunInfoUnpackPRDF::Init-----" << endl;
44 }
45 
46 //_____________________________________
47 int
49 {
50 
51  CreateNodeTree(topNode);
52 
53  cout << "-----MvtxRunInfoUnpackPRDF::Init-----" << endl;
55 }
56 
57 //____________________________________
58 int
60 {
61  /*
62  _event = findNode::getClass<Event>(topNode, "PRDF");
63  if (_event==0)
64  {
65  cout << "MvtxRunInfoUnpackPRDF::Process_Event - Event not found" << endl;
66  return -1;
67  }
68  */
69 
70  stringstream ss_packet;
71  string s_packet;
72  char par_name[30], par_sval[30], par_unit[30];
73  int par_ival;
74 
75  Event *event = findNode::getClass<Event>(topNode, "PRDF");
76  if ( event==NULL )
77  {
78  if ( Verbosity()>=VERBOSITY_SOME )
79  cout << "RunInfoUnpackPRDF::Process_Event - Event not found" << endl;
81  }
82 
83  EventHeaderv1 *eventheader = findNode::getClass<EventHeaderv1>(topNode, "EventHeader");
84  if ( eventheader )
85  {
86  eventheader->set_RunNumber(event->getRunNumber());
87  eventheader->set_EvtSequence(event->getEvtSequence());
88  eventheader->set_EvtType(event->getEvtType());
89  eventheader->set_TimeStamp(event->getTime());
90  if ( verbosity )
91  {
92  eventheader->identify();
93  }
94  }
95 
96  if ( event->getEvtType()!=BEGRUNEVENT )
98  else
99  {
100  if ( verbosity>=VERBOSITY_SOME )
101  {
102  cout << "RunInfoUnpackPRDF::process_event - with BEGRUNEVENT events ";
103  event->identify();
104  }
105 
106  PHParameters Params("RunInfo");
107 
108  Packet *packet = event->getPacket(910);
109  if ( !packet )
110  {
111  cout << "RunInfoUnpackPRDF::process_event - failed to locate packet 910" << endl;
112  }else{
113  ss_packet.clear();
114  packet->dump(ss_packet);
115 
116  getline(ss_packet,s_packet);
117  sscanf(s_packet.c_str(), "%s = %i %s", par_name, &par_ival, par_unit);
118  Params.set_int_param(par_name,par_ival);
119 
120  getline(ss_packet,s_packet);
121  sscanf(s_packet.c_str(), "%s = %s", par_name, par_sval);
122  Params.set_string_param(par_name,par_sval);
123  }//910
124 
125  packet = event->getPacket(920);
126  if ( !packet )
127  {
128  cout << "RunInfoUnpackPRDF::process_event - failed to locate packet 910" << endl;
129  //Params.set_double_param(name, NAN);
130  }else{
131  ss_packet.clear();
132  packet->dump(ss_packet);
133 
134  getline(ss_packet,s_packet);
135  sscanf(s_packet.c_str(), "%s = %i", par_name, &par_ival);
136  Params.set_int_param(par_name,par_ival);
137 
138  getline(ss_packet,s_packet);
139  sscanf(s_packet.c_str(), "%s = %s", par_name, par_sval);
140  Params.set_string_param(par_name,par_sval);
141 
142  getline(ss_packet,s_packet);
143  sscanf(s_packet.c_str(), "%s = %i %s", par_name, &par_ival, par_unit);
144  Params.set_int_param(par_name,par_ival);
145 
146  while ( getline(ss_packet,s_packet) )
147  {
148  sscanf(s_packet.c_str(), "%s = %i", par_name, &par_ival);
149  Params.set_int_param(par_name,par_ival);
150  }
151  }//920
152 
153  packet = event->getPacket(930);
154  if ( !packet )
155  {
156  cout << "RunInfoUnpackPRDF::process_event - failed to locate packet 930" << endl;
157  //Params.set_double_param(name, NAN);
158  }else{
159  ss_packet.clear();
160  packet->dump(ss_packet);
161 
162  while ( getline(ss_packet,s_packet) )
163  {
164  sscanf(s_packet.c_str(), "%s = %i %s", par_name, &par_ival, par_unit);
165  Params.set_int_param(par_name,par_ival);
166  }
167  }//930
168 
169  Params.SaveToNodeTree(topNode, "RUN_INFO");
170 
171  if ( verbosity>=VERBOSITY_SOME )
172  {
173  Params.Print();
174  }
175 
176  }//
177 
178 
180 }
181 
182 //_______________________________________
183 void
185 {
186 
187  PHNodeIterator nodeItr(topNode);
188 
189  PHCompositeNode *run_node = static_cast<PHCompositeNode *>(nodeItr.findFirst("PHCompositeNode", "RUN"));
190  if (!run_node)
191  {
192  cout << "PHComposite node created: RUN" << endl;
193  run_node = new PHCompositeNode("RUN");
194  topNode->addNode(run_node);
195  }
196 
197  PdbParameterMap *nodeparams = findNode::getClass<PdbParameterMap>(run_node,"RUN_INFO");
198  if (!nodeparams)
199  {
200  run_node->addNode(new PHIODataNode<PdbParameterMap>(new PdbParameterMap(),"RUN_INFO"));
201  }
202 
203  //DST node
204  PHCompositeNode *dst_node = static_cast<PHCompositeNode *>(nodeItr.findFirst("PHCompositeNode", "DST"));
205  if (!dst_node)
206  {
207  cout << "PHComposite node created: DST" << endl;
208  dst_node = new PHCompositeNode("DST");
209  topNode->addNode(dst_node);
210  }
211 
212  EventHeaderv1 *eventheader = new EventHeaderv1();
213  PHObjectNode_t *EventHeaderNode = new PHObjectNode_t(eventheader, "EventHeader", "PHObject"); // contain PHObject
214  dst_node->addNode(EventHeaderNode);
215 
216 }
217 
218 //___________________________________
219 int
221 {
222  cout << "-----MvtxRunInfoUnpackPRDF::End-----" << endl;
223 
225 }
226