CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
HCAL_HLX::TCPReceiver Class Reference

#include <TCPReceiver.h>

Public Member Functions

int Connect ()
 
int Disconnect ()
 
void GenerateFakeData (HCAL_HLX::LUMI_SECTION &localSection)
 
void GenerateRandomData (HCAL_HLX::LUMI_SECTION &localSection)
 
bool IsConnected ()
 
int ReceiveLumiSection (HCAL_HLX::LUMI_SECTION &localSection)
 
void SetIP (std::string IP)
 
int SetMode (unsigned char)
 
int SetPort (unsigned short int)
 
 TCPReceiver ()
 
 TCPReceiver (unsigned short int, std::string, unsigned char)
 
bool VerifyFakeData (HCAL_HLX::LUMI_SECTION &localSection)
 
 ~TCPReceiver ()
 

Private Attributes

unsigned char acquireMode
 
bool Connected
 
struct sockaddr_in servAddr
 
std::string servIP
 
unsigned short servPort
 
int tcpSocket
 

Detailed Description

Definition at line 36 of file TCPReceiver.h.

Constructor & Destructor Documentation

HCAL_HLX::TCPReceiver::TCPReceiver ( )

Definition at line 34 of file TCPReceiver.cc.

References acquireMode, Connected, gather_cfg::cout, servIP, and servPort.

34  {
35 #ifdef DEBUG
36  std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
37 #endif
38 
39  acquireMode = 0;
40  servPort = 0;
41  servIP = "127.0.0.1";
42  Connected = false;
43 
44 #ifdef DEBUG
45  std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
46 #endif
47  }
unsigned char acquireMode
Definition: TCPReceiver.h:55
std::string servIP
Definition: TCPReceiver.h:59
tuple cout
Definition: gather_cfg.py:41
unsigned short servPort
Definition: TCPReceiver.h:58
HCAL_HLX::TCPReceiver::TCPReceiver ( unsigned short int  port,
std::string  IP,
unsigned char  mode = 0 
)

Definition at line 49 of file TCPReceiver.cc.

References acquireMode, Connected, gather_cfg::cout, mode, query::port, servIP, and servPort.

49  {
50 #ifdef DEBUG
51  std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
52 #endif
53  acquireMode = mode;
54  servPort = port;
55  servIP = IP;
56  Connected = false;
57 
58 #ifdef DEBUG
59  std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
60 #endif
61  }
unsigned char acquireMode
Definition: TCPReceiver.h:55
int port
Definition: query.py:115
int mode
Definition: AMPTWrapper.h:139
std::string servIP
Definition: TCPReceiver.h:59
tuple cout
Definition: gather_cfg.py:41
unsigned short servPort
Definition: TCPReceiver.h:58
HCAL_HLX::TCPReceiver::~TCPReceiver ( )

Definition at line 63 of file TCPReceiver.cc.

References Disconnect().

63  {
64  Disconnect();
65  }

Member Function Documentation

int HCAL_HLX::TCPReceiver::Connect ( )

Definition at line 236 of file TCPReceiver.cc.

References acquireMode, align_tpl::connect, Connected, gather_cfg::cout, servAddr, servIP, servPort, and tcpSocket.

Referenced by HLXMonitor::analyze(), and HLXMonitor::beginJob().

236  {
237 #ifdef DEBUG
238  std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
239 #endif
240 
241  int errorCode;
242 
243  if(acquireMode == 0){
244  struct hostent * hostInfo = gethostbyname(servIP.c_str());
245 
246  if(servPort < 1024){
247  errorCode = 101; // Protected ports
248  } else {
249 #ifdef DEBUG
250  std::cout << "Requesting connection" << std::endl;
251 #endif
252  if((tcpSocket = socket(AF_INET, SOCK_STREAM, 0))<0){
253  perror("Socket Error");
254  errorCode = 301; // Socket failed
255  }else{
256  memset(&servAddr, 0, sizeof(servAddr));
257  servAddr.sin_family = hostInfo->h_addrtype;
258  memcpy((char *) &servAddr.sin_addr.s_addr,
259  hostInfo->h_addr_list[0],
260  hostInfo->h_length);
261  // servAddr.sin_addr.s_addr = inet_addr(servIP.c_str());
262  servAddr.sin_port = htons(servPort);
263 #ifdef DEBUG
264  std::cout << "Connecting" << std::endl;
265 #endif
266  if(connect(tcpSocket, (struct sockaddr *) &servAddr, sizeof(servAddr))<0){
267  perror("Connect Error");
268  errorCode = 302; // connect failed
269  close(tcpSocket);
270  } else{
271  Connected = true;
272  errorCode = 1; // Successful connection
273  }
274  }
275  }
276  } else if(acquireMode == 1) {
277  Connected = true;
278  errorCode = 1; // do nothing for fake data
279  } else if(acquireMode == 2) {
280  Connected = true;
281  errorCode = 1; // do nothing for random data
282  } else {
283  errorCode = 201; // Invalid acquire mode
284  }
285 
286 #ifdef DEBUG
287  std::cout << "End " << __PRETTY_FUNCTION__ << " " << errorCode << std::endl;
288 #endif
289  return errorCode;
290  }
unsigned char acquireMode
Definition: TCPReceiver.h:55
std::string servIP
Definition: TCPReceiver.h:59
tuple connect
process.AlignmentProducer.algoConfig.uvarFile = &#39;.
Definition: align_tpl.py:66
tuple cout
Definition: gather_cfg.py:41
unsigned short servPort
Definition: TCPReceiver.h:58
struct sockaddr_in servAddr
Definition: TCPReceiver.h:61
int HCAL_HLX::TCPReceiver::Disconnect ( )

Definition at line 292 of file TCPReceiver.cc.

References acquireMode, Connected, gather_cfg::cout, and tcpSocket.

Referenced by HLXMonitor::analyze(), HLXMonitor::endJob(), HLXMonitor::~HLXMonitor(), and ~TCPReceiver().

292  {
293 #ifdef DEBUG
294  std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
295 #endif
296 
297  int errorCode = 0;
298 
299  if(Connected){
300  if( acquireMode == 0 ){
301  if(shutdown(tcpSocket,SHUT_RDWR)<0){
302  perror("Shutdown Error");
303  errorCode = 601; // Disconnect Failed
304  } else {
305 
306  errorCode = 1; // Successful Disconnect
307  }
308  }
309  Connected = false;
310  } else {
311  errorCode = 401; // Not Connected
312  }
313 
314 #ifdef DEBUG
315  std::cout << "End " << __PRETTY_FUNCTION__ << " " << errorCode << std::endl;
316 #endif
317  return errorCode;
318  }
unsigned char acquireMode
Definition: TCPReceiver.h:55
tuple cout
Definition: gather_cfg.py:41
void HCAL_HLX::TCPReceiver::GenerateFakeData ( HCAL_HLX::LUMI_SECTION localSection)

Definition at line 320 of file TCPReceiver.cc.

References HCAL_HLX::LUMI_SECTION_HEADER::bCMSLive, HCAL_HLX::LUMI_SECTION_SUB_HEADER::bIsComplete, gather_cfg::cout, HCAL_HLX::ET_SUM_SECTION::data, HCAL_HLX::OCCUPANCY_SECTION::data, HCAL_HLX::LHC_SECTION::data, HCAL_HLX::LUMI_DETAIL::ETBXNormalization, HCAL_HLX::LUMI_DETAIL::ETLumi, HCAL_HLX::LUMI_DETAIL::ETLumiErr, HCAL_HLX::LUMI_DETAIL::ETLumiQlty, HCAL_HLX::LUMI_SUMMARY::ETNormalization, HCAL_HLX::LUMI_SECTION::etSum, HCAL_HLX::ET_SUM_SECTION::hdr, HCAL_HLX::OCCUPANCY_SECTION::hdr, HCAL_HLX::LHC_SECTION::hdr, HCAL_HLX::LUMI_SECTION::hdr, i, HCAL_HLX::LUMI_SUMMARY::InstantETLumi, HCAL_HLX::LUMI_SUMMARY::InstantETLumiErr, HCAL_HLX::LUMI_SUMMARY::InstantETLumiQlty, HCAL_HLX::LUMI_SUMMARY::InstantLumi, HCAL_HLX::LUMI_SUMMARY::InstantLumiErr, HCAL_HLX::LUMI_SUMMARY::InstantLumiQlty, HCAL_HLX::LUMI_SUMMARY::InstantOccLumi, HCAL_HLX::LUMI_SUMMARY::InstantOccLumiErr, HCAL_HLX::LUMI_SUMMARY::InstantOccLumiQlty, j, gen::k, HCAL_HLX::LUMI_SECTION::lhc, HCAL_HLX::LUMI_DETAIL::LHCLumi, HCAL_HLX::LUMI_SUMMARY::LHCNormalization, HCAL_HLX::LUMI_SECTION::lumiDetail, HCAL_HLX::LUMI_SUMMARY::lumiNoise, HCAL_HLX::LUMI_SECTION::lumiSummary, NULL, HCAL_HLX::LUMI_SECTION_HEADER::numBunches, HCAL_HLX::LUMI_SECTION_HEADER::numHLXs, HCAL_HLX::LUMI_SECTION_SUB_HEADER::numNibbles, HCAL_HLX::LUMI_SECTION_HEADER::numOrbits, HCAL_HLX::LUMI_DETAIL::OccBXNormalization, HCAL_HLX::LUMI_DETAIL::OccLumi, HCAL_HLX::LUMI_DETAIL::OccLumiErr, HCAL_HLX::LUMI_DETAIL::OccLumiQlty, HCAL_HLX::LUMI_SUMMARY::OccNormalization, HCAL_HLX::LUMI_SECTION::occupancy, HCAL_HLX::LUMI_SECTION_HEADER::runNumber, HCAL_HLX::LUMI_SECTION_HEADER::sectionNumber, HCAL_HLX::LUMI_SECTION_HEADER::startOrbit, HCAL_HLX::LUMI_SECTION_HEADER::timestamp, and HCAL_HLX::LUMI_SECTION_HEADER::timestamp_micros.

Referenced by ReceiveLumiSection(), and VerifyFakeData().

320  {
321 #ifdef DEBUG
322  std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
323 #endif
324  int i, j, k;
325 
326  localSection.hdr.runNumber = 1;
327  localSection.hdr.startOrbit = 2;
328  localSection.hdr.numOrbits = 3;
329  localSection.hdr.numBunches = 4;
330  localSection.hdr.numHLXs = 5;
331  localSection.hdr.bCMSLive = true;
332  localSection.hdr.sectionNumber = 120;
333 
334  timeval tvTemp;
335  gettimeofday(&tvTemp, NULL);
336  localSection.hdr.timestamp = tvTemp.tv_sec;
337  localSection.hdr.timestamp_micros = tvTemp.tv_usec;
338 
339  localSection.lumiSummary.DeadtimeNormalization = 0.7;
340  localSection.lumiSummary.LHCNormalization = 0.75;
341  localSection.lumiSummary.OccNormalization[0] = 0.8;
342  localSection.lumiSummary.OccNormalization[1] = 0.85;
343  localSection.lumiSummary.ETNormalization = 0.8;
344  localSection.lumiSummary.InstantLumi = 0.9;
345  localSection.lumiSummary.InstantLumiErr = 0.10;
346  localSection.lumiSummary.InstantLumiQlty = 11;
347  localSection.lumiSummary.InstantETLumi = 0.12;
348  localSection.lumiSummary.InstantETLumiErr = 0.13;
349  localSection.lumiSummary.InstantETLumiQlty = 14;
350  localSection.lumiSummary.InstantOccLumi[0] = 0.15;
351  localSection.lumiSummary.InstantOccLumiErr[0] = 0.16;
352  localSection.lumiSummary.InstantOccLumiQlty[0] = 17;
353  localSection.lumiSummary.lumiNoise[0] = 0.18;
354  localSection.lumiSummary.InstantOccLumi[1] = 0.19;
355  localSection.lumiSummary.InstantOccLumiErr[1] = 0.20;
356  localSection.lumiSummary.InstantOccLumiQlty[1] = 21;
357  localSection.lumiSummary.lumiNoise[1] = 0.22;
358 
359  for(j=0; j < 3564; j++){
360  localSection.lumiDetail.ETBXNormalization[j] = 0.25*j/35640.0;
361  localSection.lumiDetail.OccBXNormalization[0][j] = 0.5*j/35640.0;
362  localSection.lumiDetail.OccBXNormalization[1][j] = 0.75*j/35640.0;
363  localSection.lumiDetail.LHCLumi[j] = 1*j/35640.0;
364  localSection.lumiDetail.ETLumi[j] = 2*j/35640.0;
365  localSection.lumiDetail.ETLumiErr[j] = 3*j/35640.0;
366  localSection.lumiDetail.ETLumiQlty[j] = 4*j;
367  localSection.lumiDetail.OccLumi[0][j] = 5*j/35640.0;
368  localSection.lumiDetail.OccLumiErr[0][j] = 6*j/35640.0;
369  localSection.lumiDetail.OccLumiQlty[0][j] = 7*j;
370  localSection.lumiDetail.OccLumi[1][j] = 8*j/35640.0;
371  localSection.lumiDetail.OccLumiErr[1][j] = 9*j/35640.0;
372  localSection.lumiDetail.OccLumiQlty[1][j] = 10*j;
373  }
374 
375  for(i=0; i<36; i ++){
376  localSection.etSum[i].hdr.numNibbles = 7;
377  localSection.occupancy[i].hdr.numNibbles = 8;
378  localSection.lhc[i].hdr.numNibbles = 9;
379 
380  localSection.etSum[i].hdr.bIsComplete = true;
381  localSection.occupancy[i].hdr.bIsComplete = true;
382  localSection.lhc[i].hdr.bIsComplete = true;
383 
384  for(j=0; j < 3564; j ++){
385  localSection.etSum[i].data[j] = 6*j+ 10*i;
386  for(k=0; k < 6; k++){
387  localSection.occupancy[i].data[k][j] = k*j + 11*i;
388  }
389  localSection.lhc[i].data[j] = 7*j + 12*i;
390  }
391  }
392 
393 #ifdef DEBUG
394  std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
395 #endif
396 
397  }
int i
Definition: DBlmapReader.cc:9
ET_SUM_SECTION etSum[HCAL_HLX_MAX_HLXS]
float LHCLumi[HCAL_HLX_MAX_BUNCHES]
float data[HCAL_HLX_MAX_BUNCHES]
uint32_t data[6][HCAL_HLX_MAX_BUNCHES]
#define NULL
Definition: scimark2.h:8
float OccLumi[2][HCAL_HLX_MAX_BUNCHES]
uint32_t data[HCAL_HLX_MAX_BUNCHES]
float ETBXNormalization[HCAL_HLX_MAX_BUNCHES]
float OccBXNormalization[2][HCAL_HLX_MAX_BUNCHES]
int16_t ETLumiQlty[HCAL_HLX_MAX_BUNCHES]
LHC_SECTION lhc[HCAL_HLX_MAX_HLXS]
int j
Definition: DBlmapReader.cc:9
float ETLumi[HCAL_HLX_MAX_BUNCHES]
LUMI_SECTION_SUB_HEADER hdr
int k[5][pyjets_maxn]
OCCUPANCY_SECTION occupancy[HCAL_HLX_MAX_HLXS]
float ETLumiErr[HCAL_HLX_MAX_BUNCHES]
LUMI_SECTION_SUB_HEADER hdr
tuple cout
Definition: gather_cfg.py:41
int16_t OccLumiQlty[2][HCAL_HLX_MAX_BUNCHES]
float OccLumiErr[2][HCAL_HLX_MAX_BUNCHES]
void HCAL_HLX::TCPReceiver::GenerateRandomData ( HCAL_HLX::LUMI_SECTION localSection)

Definition at line 399 of file TCPReceiver.cc.

References HCAL_HLX::LUMI_SECTION_HEADER::bCMSLive, HCAL_HLX::LUMI_SECTION_SUB_HEADER::bIsComplete, gather_cfg::cout, HCAL_HLX::ET_SUM_SECTION::data, HCAL_HLX::OCCUPANCY_SECTION::data, HCAL_HLX::LHC_SECTION::data, HCAL_HLX::LUMI_DETAIL::ETBXNormalization, HCAL_HLX::LUMI_DETAIL::ETLumi, HCAL_HLX::LUMI_DETAIL::ETLumiErr, HCAL_HLX::LUMI_DETAIL::ETLumiQlty, HCAL_HLX::LUMI_SUMMARY::ETNormalization, HCAL_HLX::LUMI_SECTION::etSum, HCAL_HLX::ET_SUM_SECTION::hdr, HCAL_HLX::OCCUPANCY_SECTION::hdr, HCAL_HLX::LHC_SECTION::hdr, HCAL_HLX::LUMI_SECTION::hdr, i, HCAL_HLX::LUMI_SUMMARY::InstantETLumi, HCAL_HLX::LUMI_SUMMARY::InstantETLumiErr, HCAL_HLX::LUMI_SUMMARY::InstantETLumiQlty, HCAL_HLX::LUMI_SUMMARY::InstantLumi, HCAL_HLX::LUMI_SUMMARY::InstantLumiErr, HCAL_HLX::LUMI_SUMMARY::InstantLumiQlty, HCAL_HLX::LUMI_SUMMARY::InstantOccLumi, HCAL_HLX::LUMI_SUMMARY::InstantOccLumiErr, HCAL_HLX::LUMI_SUMMARY::InstantOccLumiQlty, j, gen::k, HCAL_HLX::LUMI_SECTION::lhc, HCAL_HLX::LUMI_DETAIL::LHCLumi, HCAL_HLX::LUMI_SUMMARY::LHCNormalization, HCAL_HLX::LUMI_SECTION::lumiDetail, HCAL_HLX::LUMI_SUMMARY::lumiNoise, HCAL_HLX::LUMI_SECTION::lumiSummary, NULL, HCAL_HLX::LUMI_SECTION_HEADER::numBunches, HCAL_HLX::LUMI_SECTION_HEADER::numHLXs, HCAL_HLX::LUMI_SECTION_SUB_HEADER::numNibbles, HCAL_HLX::LUMI_SECTION_HEADER::numOrbits, HCAL_HLX::LUMI_DETAIL::OccBXNormalization, HCAL_HLX::LUMI_DETAIL::OccLumi, HCAL_HLX::LUMI_DETAIL::OccLumiErr, HCAL_HLX::LUMI_DETAIL::OccLumiQlty, HCAL_HLX::LUMI_SUMMARY::OccNormalization, HCAL_HLX::LUMI_SECTION::occupancy, rand(), HCAL_HLX::LUMI_SECTION_HEADER::runNumber, HCAL_HLX::LUMI_SECTION_HEADER::sectionNumber, HCAL_HLX::LUMI_SECTION_HEADER::startOrbit, and cond::rpcobgas::time.

Referenced by ReceiveLumiSection().

399  {
400 #ifdef DEBUG
401  std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
402 #endif
403  int i, j, k;
404 
405  srand(time(NULL));
406  localSection.hdr.runNumber = 55; //(rand() % 100);
407  localSection.hdr.startOrbit = (rand() % 100);
408  localSection.hdr.numOrbits = (rand() % 100);
409  localSection.hdr.numBunches = (rand() % 100);
410  localSection.hdr.numHLXs = (rand() % 100);
411  localSection.hdr.bCMSLive = true;
412  localSection.hdr.sectionNumber = (rand() %100);
413 
414  localSection.lumiSummary.DeadtimeNormalization = (float)(rand() % 100)/100;
415  localSection.lumiSummary.LHCNormalization = (float)(rand() % 100)/100;
416  localSection.lumiSummary.OccNormalization[0] = (float)(rand() % 100)/100;
417  localSection.lumiSummary.OccNormalization[1] = (float)(rand() % 100)/100;
418  localSection.lumiSummary.ETNormalization = (float)(rand() % 100)/100;
419  localSection.lumiSummary.InstantLumi = (float)(rand() % 100)/100;
420  localSection.lumiSummary.InstantLumiErr = (float)(rand() % 100)/100;
421  localSection.lumiSummary.InstantLumiQlty = (rand() % 100);
422  localSection.lumiSummary.InstantETLumi = (float)(rand() % 100)/100;
423  localSection.lumiSummary.InstantETLumiErr = (float)(rand() % 100)/100;
424  localSection.lumiSummary.InstantETLumiQlty = (rand() % 100);
425  localSection.lumiSummary.InstantOccLumi[0] = (float)(rand() % 100)/100;
426  localSection.lumiSummary.InstantOccLumiErr[0] = (float)(rand() % 100)/100;
427  localSection.lumiSummary.InstantOccLumiQlty[0] = (rand() % 100);
428  localSection.lumiSummary.lumiNoise[0] = (float)(rand() % 100)/100;
429  localSection.lumiSummary.InstantOccLumi[1] = (float)(rand() % 100)/100;
430  localSection.lumiSummary.InstantOccLumiErr[1] = (float)(rand() % 100)/100;
431  localSection.lumiSummary.InstantOccLumiQlty[1] = (rand() % 100);
432  localSection.lumiSummary.lumiNoise[1] = (float)(rand() % 100)/100;
433 
434  for(j=0; j < 3564; j++){
435  localSection.lumiDetail.ETBXNormalization[j] = 0.25*j/35640.0;
436  localSection.lumiDetail.OccBXNormalization[0][j] = 0.5*j/35640.0;
437  localSection.lumiDetail.OccBXNormalization[1][j] = 0.75*j/35640.0;
438  localSection.lumiDetail.LHCLumi[j] = (float)(rand() % 100)/100.0;
439  localSection.lumiDetail.ETLumi[j] = (float)(rand() % 100)/100.0;
440  localSection.lumiDetail.ETLumiErr[j] = (float)(rand() % 100)/100.0;
441  localSection.lumiDetail.ETLumiQlty[j] = (rand() % 100);
442  localSection.lumiDetail.OccLumi[0][j] = (float)(rand() % 100)/100.0;
443  localSection.lumiDetail.OccLumiErr[0][j] = (float)(rand() % 100)/100.0;
444  localSection.lumiDetail.OccLumiQlty[0][j] = (rand() % 100);
445  localSection.lumiDetail.OccLumi[1][j] = (float)(rand() % 100)/100.0;
446  localSection.lumiDetail.OccLumiErr[1][j] = (float)(rand() % 100)/100.0;
447  localSection.lumiDetail.OccLumiQlty[1][j] = (rand() % 100);
448  }
449 
450  for(i=0; i<36; i ++){
451  localSection.etSum[i].hdr.numNibbles = (rand() % 100);
452  localSection.occupancy[i].hdr.numNibbles = 8*(rand() % 100);
453  localSection.lhc[i].hdr.numNibbles = 9*(rand() % 100);
454 
455  localSection.etSum[i].hdr.bIsComplete = true;
456  localSection.occupancy[i].hdr.bIsComplete = true;
457  localSection.lhc[i].hdr.bIsComplete = true;
458 
459  for(j=0; j < 3564; j ++){
460  localSection.etSum[i].data[j] = 6*(rand() % 3564);
461  for(k=0; k < 6; k++){
462  localSection.occupancy[i].data[k][j] = k*(rand() % 3564);
463  }
464  localSection.lhc[i].data[j] = 7*(rand() % 3564);
465  }
466  }
467 
468 #ifdef DEBUG
469  std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
470 #endif
471  }
int i
Definition: DBlmapReader.cc:9
ET_SUM_SECTION etSum[HCAL_HLX_MAX_HLXS]
float LHCLumi[HCAL_HLX_MAX_BUNCHES]
float data[HCAL_HLX_MAX_BUNCHES]
uint32_t data[6][HCAL_HLX_MAX_BUNCHES]
#define NULL
Definition: scimark2.h:8
float OccLumi[2][HCAL_HLX_MAX_BUNCHES]
uint32_t data[HCAL_HLX_MAX_BUNCHES]
float ETBXNormalization[HCAL_HLX_MAX_BUNCHES]
float OccBXNormalization[2][HCAL_HLX_MAX_BUNCHES]
int16_t ETLumiQlty[HCAL_HLX_MAX_BUNCHES]
LHC_SECTION lhc[HCAL_HLX_MAX_HLXS]
int j
Definition: DBlmapReader.cc:9
float ETLumi[HCAL_HLX_MAX_BUNCHES]
LUMI_SECTION_SUB_HEADER hdr
int k[5][pyjets_maxn]
OCCUPANCY_SECTION occupancy[HCAL_HLX_MAX_HLXS]
float ETLumiErr[HCAL_HLX_MAX_BUNCHES]
LUMI_SECTION_SUB_HEADER hdr
Signal rand(Signal arg)
Definition: vlib.cc:442
tuple cout
Definition: gather_cfg.py:41
int16_t OccLumiQlty[2][HCAL_HLX_MAX_BUNCHES]
float OccLumiErr[2][HCAL_HLX_MAX_BUNCHES]
bool HCAL_HLX::TCPReceiver::IsConnected ( )

Definition at line 179 of file TCPReceiver.cc.

References Connected, and gather_cfg::cout.

Referenced by HLXMonitor::analyze(), and HLXMonitor::beginJob().

179  {
180 #ifdef DEBUG
181  std::cout << "Begin and End " << __PRETTY_FUNCTION__ << " " << Connected << std::endl;
182 #endif
183  return Connected;
184  }
tuple cout
Definition: gather_cfg.py:41
int HCAL_HLX::TCPReceiver::ReceiveLumiSection ( HCAL_HLX::LUMI_SECTION localSection)

Definition at line 88 of file TCPReceiver.cc.

References acquireMode, Connected, gather_cfg::cout, GenerateFakeData(), GenerateRandomData(), benchmark_cfg::select, HCAL_HLX::SetupFDSets(), tcpSocket, and cond::rpcobgas::time.

Referenced by HLXMonitor::analyze().

88  {
89 #ifdef DEBUG
90  std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
91 #endif
92 
93  int errorCode = 0;
94 
95  if(acquireMode == 0){ // real data
96  if(Connected == false){
97  errorCode = 701; // not connected
98  } else {
99  unsigned int bytesRcvd, bytesToReceive, totalBytesRcvd;
100  const unsigned int Buffer_Size = 8192;
101  char *Buffer;
102  char *BigBuffer;
103 
104  // From John's code
105 
106  fd_set fdsRead, fdsWrite, fdsExcept;
107  struct timeval tv;
108 
109  tv.tv_sec = 1;
110  tv.tv_usec = 0;
111 
112  // int outputcode;
113  //int z = 0, localCount = 0;
114  time_t tempTime, curTime;
115  //int ret;
116 
117  time(&curTime);
118 
119  bytesToReceive = sizeof(localSection);
120  Buffer = new char[Buffer_Size];
121  BigBuffer = new char[bytesToReceive];
122  totalBytesRcvd = 0;
123 
124  memset(reinterpret_cast<char *>(&localSection), 0, Buffer_Size);
125  memset(Buffer, 0, Buffer_Size);
126  memset(BigBuffer, 0, bytesToReceive);
127 
128  usleep(10000);
129 
130  while((totalBytesRcvd < bytesToReceive) && (errorCode == 0)){
131 
132  SetupFDSets(fdsRead, fdsWrite, fdsExcept, -1, tcpSocket);
133 
134  if(select(tcpSocket+1, &fdsRead, 0, &fdsExcept, 0)> 0){
135 
136  if (FD_ISSET(tcpSocket, &fdsRead)) {
137 
138  if((bytesRcvd = recv(tcpSocket, Buffer, Buffer_Size, 0))<=0){
139  perror("Recv Error");
140  errorCode = 501;
141  }else{
142  if((totalBytesRcvd + bytesRcvd)<= bytesToReceive){
143  memcpy(&BigBuffer[totalBytesRcvd], Buffer, bytesRcvd);
144  }else{
145  std::cout << "***** MEM OVER FLOW: Did someone forget to update LumiStructures.hh? *****" << std::endl;
146  errorCode = 502;
147  }
148  totalBytesRcvd += bytesRcvd;
149  time(&tempTime);
150  }
151  }
152  }
153  }
154 
155  if(errorCode == 0){
156  memcpy(reinterpret_cast<char *>(&localSection), BigBuffer, sizeof(localSection));
157  errorCode = 1; // success
158  }
159  delete [] Buffer;
160  delete [] BigBuffer;
161  }
162  } else if(acquireMode == 1){ // fill with fake data. Should be unique.
163  GenerateFakeData(localSection);
164  errorCode = 1;
165  } else if(acquireMode == 2){ // fill with random fake data.
166  GenerateRandomData(localSection);
167  errorCode = 1;
168  } else {
169  errorCode = 201;
170  }
171 
172 #ifdef DEBUG
173  std::cout << "End " << __PRETTY_FUNCTION__ << " " << errorCode << std::endl;
174 #endif
175 
176  return errorCode;
177  }
void SetupFDSets(fd_set &ReadFDs, fd_set &WriteFDs, fd_set &ExceptFDs, int ListeningSocket=-1, int connectSocket=-1)
Definition: TCPReceiver.cc:67
unsigned char acquireMode
Definition: TCPReceiver.h:55
void GenerateRandomData(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:399
void GenerateFakeData(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:320
tuple cout
Definition: gather_cfg.py:41
void HCAL_HLX::TCPReceiver::SetIP ( std::string  IP)

Definition at line 226 of file TCPReceiver.cc.

References gather_cfg::cout, and servIP.

Referenced by HLXMonitor::analyze(), and HLXMonitor::beginJob().

226  {
227 #ifdef DEBUG
228  std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
229 #endif
230  servIP = IP;
231 #ifdef DEBUG
232  std::cout << "End " << __PRETTY_FUNCTION__ << std::endl;
233 #endif
234  }
std::string servIP
Definition: TCPReceiver.h:59
tuple cout
Definition: gather_cfg.py:41
int HCAL_HLX::TCPReceiver::SetMode ( unsigned char  mode)

Definition at line 206 of file TCPReceiver.cc.

References acquireMode, gather_cfg::cout, and mode.

Referenced by HLXMonitor::beginJob().

206  {
207 #ifdef DEBUG
208  std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
209 #endif
210 
211  int errorCode;
212 
213  if(mode > 2){
214  errorCode = 201;
215  } else {
216  acquireMode = mode;
217  errorCode = 1;
218  }
219 
220 #ifdef DEBUG
221  std::cout << "End " << __PRETTY_FUNCTION__ << " " << errorCode << std::endl;
222 #endif
223  return errorCode;
224  }
unsigned char acquireMode
Definition: TCPReceiver.h:55
int mode
Definition: AMPTWrapper.h:139
tuple cout
Definition: gather_cfg.py:41
int HCAL_HLX::TCPReceiver::SetPort ( unsigned short int  port)

Definition at line 186 of file TCPReceiver.cc.

References gather_cfg::cout, query::port, and servPort.

Referenced by HLXMonitor::beginJob().

186  {
187 #ifdef DEBUG
188  std::cout << "Begin " << __PRETTY_FUNCTION__ << std::endl;
189 #endif
190 
191  int errorCode;
192 
193  if(port < 1024){
194  errorCode = 101;
195  }else{
196  servPort = port;
197  errorCode = 1;
198  }
199 
200 #ifdef DEBUG
201  std::cout << "End " << __PRETTY_FUNCTION__ << " " << errorCode << std::endl;
202 #endif
203  return errorCode;
204  }
int port
Definition: query.py:115
tuple cout
Definition: gather_cfg.py:41
unsigned short servPort
Definition: TCPReceiver.h:58
bool HCAL_HLX::TCPReceiver::VerifyFakeData ( HCAL_HLX::LUMI_SECTION localSection)

Definition at line 473 of file TCPReceiver.cc.

References GenerateFakeData(), and dttmaxenums::L.

473  {
474 
476  GenerateFakeData(L);
477  return !(memcmp(&L, &localSection, sizeof(L)));
478  }
void GenerateFakeData(HCAL_HLX::LUMI_SECTION &localSection)
Definition: TCPReceiver.cc:320

Member Data Documentation

unsigned char HCAL_HLX::TCPReceiver::acquireMode
private

Definition at line 55 of file TCPReceiver.h.

Referenced by Connect(), Disconnect(), ReceiveLumiSection(), SetMode(), and TCPReceiver().

bool HCAL_HLX::TCPReceiver::Connected
private

Definition at line 56 of file TCPReceiver.h.

Referenced by Connect(), Disconnect(), IsConnected(), ReceiveLumiSection(), and TCPReceiver().

struct sockaddr_in HCAL_HLX::TCPReceiver::servAddr
private

Definition at line 61 of file TCPReceiver.h.

Referenced by Connect().

std::string HCAL_HLX::TCPReceiver::servIP
private

Definition at line 59 of file TCPReceiver.h.

Referenced by Connect(), SetIP(), and TCPReceiver().

unsigned short HCAL_HLX::TCPReceiver::servPort
private

Definition at line 58 of file TCPReceiver.h.

Referenced by Connect(), SetPort(), and TCPReceiver().

int HCAL_HLX::TCPReceiver::tcpSocket
private

Definition at line 60 of file TCPReceiver.h.

Referenced by Connect(), Disconnect(), and ReceiveLumiSection().