Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PktSizeCommon.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PktSizeCommon.cc
1 #include "PktSizeCommon.h"
2 #include <onlmon/OnlMonServer.h>
3 
4 #include <cstdlib>
5 #include <fstream>
6 #include <iostream>
7 #include <set>
8 #include <sstream>
9 #include <string>
10 
11 int PktSizeCommon::fillgranules(std::map<std::string, std::pair<unsigned int, unsigned int> > &granulepacketlimits)
12 {
13  std::pair<unsigned int, unsigned int> pktlimits;
14  pktlimits.first = 17000;
15  pktlimits.second = 17999;
16  granulepacketlimits["ACC"] = pktlimits;
17 
18  pktlimits.first = 1000;
19  pktlimits.second = 1999;
20  granulepacketlimits["BBC"] = pktlimits;
21 
22  pktlimits.first = 3000;
23  pktlimits.second = 3999;
24  granulepacketlimits["DCH"] = pktlimits;
25 
26  pktlimits.first = 8000;
27  pktlimits.second = 8999;
28  granulepacketlimits["EMC"] = pktlimits;
29 
30  pktlimits.first = 14200;
31  pktlimits.second = 14201;
32  granulepacketlimits["ERT"] = pktlimits;
33 
34  // pktlimits.first = 16000;
35  // pktlimits.second = 16999;
36  // granulepacketlimits["FCAL"] = pktlimits;
37 
38  pktlimits.first = 25000;
39  pktlimits.second = 25999;
40  granulepacketlimits["FVTX"] = pktlimits;
41 
42  pktlimits.first = 14000;
43  pktlimits.second = 14024;
44  granulepacketlimits["GL1"] = pktlimits;
45 
46  pktlimits.first = 14050;
47  pktlimits.second = 14199;
48  granulepacketlimits["LVL2"] = pktlimits;
49 
50  pktlimits.first = 14777;
51  pktlimits.second = 14777;
52  granulepacketlimits["LVL1"] = pktlimits;
53 
54  pktlimits.first = 21100;
55  pktlimits.second = 21110;
56  granulepacketlimits["MPC"] = pktlimits;
57 
58  pktlimits.first = 12000;
59  pktlimits.second = 12999;
60  granulepacketlimits["MUID"] = pktlimits;
61 
62  pktlimits.first = 11000;
63  pktlimits.second = 11999;
64  granulepacketlimits["MUTR"] = pktlimits;
65 
66  // this one is for testing if no packet exists
67  // pktlimits.first = 2000;
68  // pktlimits.second = 2999;
69  // granulepacketlimits["MVD"] = pktlimits;
70 
71  pktlimits.first = 4000;
72  pktlimits.second = 4999;
73  granulepacketlimits["PAD"] = pktlimits;
74 
75  pktlimits.first = 6000;
76  pktlimits.second = 6999;
77  granulepacketlimits["RICH"] = pktlimits;
78 
79  pktlimits.first = 19000;
80  pktlimits.second = 19999;
81  granulepacketlimits["RPC"] = pktlimits;
82 
83  pktlimits.first = 7000;
84  pktlimits.second = 7099;
85  granulepacketlimits["TOFE"] = pktlimits;
86 
87  pktlimits.first = 7100;
88  pktlimits.second = 7999;
89  granulepacketlimits["TOFW"] = pktlimits;
90 
91  pktlimits.first = 21300;
92  pktlimits.second = 21360;
93  granulepacketlimits["MPCEX"] = pktlimits;
94 
95  pktlimits.first = 24000;
96  pktlimits.second = 24099;
97  granulepacketlimits["VTXP"] = pktlimits;
98 
99  pktlimits.first = 24100;
100  pktlimits.second = 24199;
101  granulepacketlimits["VTXS"] = pktlimits;
102 
103  pktlimits.first = 13000;
104  pktlimits.second = 13999;
105  granulepacketlimits["ZDC"] = pktlimits;
106 
107  return 0;
108 }
109 
110 int PktSizeCommon::filldcmgroups(std::map<unsigned int, std::string> &dcmgroupmap)
111 {
112  // OnlMonServer *se = OnlMonServer::instance();
113  std::set<std::string> pcffiles;
114  // se->parse_granuleDef(pcffiles);
115  std::set<std::string>::const_iterator piter;
116  for (piter = pcffiles.begin(); piter != pcffiles.end(); ++piter)
117  {
118  std::ostringstream filenam;
119  if (getenv("ONLINE_CONFIGURATION"))
120  {
121  filenam << getenv("ONLINE_CONFIGURATION") << "/rc/hw/";
122  }
123  filenam << *piter;
124  std::ifstream infile;
125  infile.open(filenam.str().c_str(), std::ifstream::in);
126  if (!infile)
127  {
128  if (filenam.str().find("gl1test.pcf") != std::string::npos)
129  {
130  std::cout << " Could not open " << filenam.str() << std::endl;
131  }
132  continue;
133  }
134  std::string FullLine; // a complete line in the config file
135  getline(infile, FullLine);
136  std::string::size_type pos1;
137  std::string::size_type pos2;
138  std::string dcmgrp = "NONE";
139  while (!infile.eof())
140 
141  {
142  if (FullLine.find("//") == std::string::npos)
143  {
144  if ((pos1 = FullLine.find("DCMGROUP")) != std::string::npos && FullLine.find("level1dd") != std::string::npos)
145  {
146  FullLine.erase(0, pos1); // erase all before DCMGROUP string
147  pos2 = FullLine.find(',');
148  dcmgrp = FullLine.substr(0, pos2);
149  // std::cout << dcmgrp << std::endl;
150  }
151  if ((pos1 = FullLine.find("packetid")) != std::string::npos)
152  {
153  FullLine.erase(0, pos1); // erase all before packetid string
154  while ((pos1 = FullLine.find(':')) != std::string::npos)
155  {
156  pos2 = FullLine.find(',');
157  // search the int between the ":" and the ","
158  std::string packetidstr = FullLine.substr(pos1 + 1, pos2 - (pos1 + 1));
159  std::istringstream line;
160  line.str(packetidstr);
161  unsigned int packetid;
162  line >> packetid;
163  if (packetid > 0)
164  {
165  if (dcmgrp != "NONE")
166  {
167  dcmgroupmap[packetid] = dcmgrp;
168  }
169  else
170  {
171  std::cout << "error assigning packet " << packetid << " to dcm group" << std::endl;
172  }
173  }
174  // erase this entry from the line
175  FullLine.erase(0, pos2 + 1);
176  }
177  }
178  }
179  getline(infile, FullLine);
180  }
181  infile.close();
182  }
183  return 0;
184 }
185 
186 int PktSizeCommon::fillfibergroups(std::map<unsigned int, std::string> &fibergroupmap)
187 {
188  // OnlMonServer *se = OnlMonServer::instance();
189  std::set<std::string> pcffiles;
190  // se->parse_granuleDef(pcffiles);
191  std::set<std::string>::const_iterator piter;
192  for (piter = pcffiles.begin(); piter != pcffiles.end(); ++piter)
193  {
194  std::ostringstream filenam;
195  if (getenv("ONLINE_CONFIGURATION"))
196  {
197  filenam << getenv("ONLINE_CONFIGURATION") << "/rc/hw/";
198  }
199  filenam << *piter;
200  std::ifstream infile;
201  infile.open(filenam.str().c_str(), std::ifstream::in);
202  if (!infile)
203  {
204  std::cout << " Could not open " << filenam.str() << std::endl;
205  continue;
206  }
207  std::string FullLine; // a complete line in the config file
208  getline(infile, FullLine);
209  std::string::size_type pos1;
210  std::string::size_type pos2;
211  std::string dcmgrp = "NONE";
212  std::string unitgrp = "NONE";
213  while (!infile.eof())
214  {
215  if (FullLine.find("//") == std::string::npos)
216  {
217  if ((pos1 = FullLine.find("DCMGROUP")) != std::string::npos && FullLine.find("level1dd") != std::string::npos)
218  {
219  FullLine.erase(0, pos1); // erase all before DCMGROUP string
220  pos2 = FullLine.find(',');
221  dcmgrp = FullLine.substr(0, pos2);
222  // std::cout << dcmgrp << std::endl;
223  }
224  if ((pos1 = FullLine.find("unit")) != std::string::npos)
225  {
226  FullLine.erase(0, pos1); // erase all before unit string
227  pos1 = FullLine.find(':');
228  FullLine.erase(0, pos1 + 1); // erase all before : string
229  pos2 = FullLine.find(',');
230  unitgrp = FullLine.substr(0, pos2);
231  // std::cout << unitgrp << std::endl;
232  }
233  if ((pos1 = FullLine.find("packetid")) != std::string::npos)
234  {
235  FullLine.erase(0, pos1); // erase all before packetid string
236  while ((pos1 = FullLine.find(':')) != std::string::npos)
237  {
238  pos2 = FullLine.find(',');
239  // search the int between the ":" and the ","
240  std::string packetidstr = FullLine.substr(pos1 + 1, pos2 - (pos1 + 1));
241  std::istringstream line;
242  line.str(packetidstr);
243  unsigned int packetid;
244  line >> packetid;
245  if (packetid > 0)
246  {
247  if (dcmgrp != "NONE" && unitgrp != "NONE")
248  {
249  std::string fibergrp = dcmgrp + ":" + unitgrp;
250  fibergroupmap[packetid] = fibergrp;
251  }
252  else
253  {
254  std::cout << "error assigning packet " << packetid << " to fiber group" << std::endl;
255  }
256  }
257  // erase this entry from the line
258  FullLine.erase(0, pos2 + 1);
259  }
260  }
261  }
262  getline(infile, FullLine);
263  }
264  infile.close();
265  }
266  return 0;
267 }