10 #include "RecoLuminosity/TCPReceiver/interface/LumiStructures.hh"
24 #include <sys/types.h>
25 #include <sys/socket.h>
26 #include <arpa/inet.h>
27 #include <netinet/in.h>
36 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
45 std::cout <<
"End " << __PRETTY_FUNCTION__ << std::endl;
51 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
59 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
68 fd_set& ExceptFDs,
int ListeningSocket = -1,
69 int connectSocket = -1) {
76 if (ListeningSocket != -1) {
77 FD_SET(ListeningSocket, &ReadFDs);
78 FD_SET(ListeningSocket, &ExceptFDs);
81 if (connectSocket != -1) {
82 FD_SET(connectSocket, &ReadFDs);
83 FD_SET(connectSocket, &ExceptFDs);
90 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
99 unsigned int bytesRcvd, bytesToReceive, totalBytesRcvd;
100 const unsigned int Buffer_Size = 8192;
106 fd_set fdsRead, fdsWrite, fdsExcept;
114 time_t tempTime, curTime;
119 bytesToReceive =
sizeof(localSection);
120 Buffer =
new char[Buffer_Size];
121 BigBuffer =
new char[bytesToReceive];
124 memset(reinterpret_cast<char *>(&localSection), 0, Buffer_Size);
125 memset(Buffer, 0, Buffer_Size);
126 memset(BigBuffer, 0, bytesToReceive);
130 while((totalBytesRcvd < bytesToReceive) && (errorCode == 0)){
138 if((bytesRcvd = recv(
tcpSocket, Buffer, Buffer_Size, 0))<=0){
139 perror(
"Recv Error");
142 if((totalBytesRcvd + bytesRcvd)<= bytesToReceive){
143 memcpy(&BigBuffer[totalBytesRcvd], Buffer, bytesRcvd);
145 std::cout <<
"***** MEM OVER FLOW: Did someone forget to update LumiStructures.hh? *****" << std::endl;
148 totalBytesRcvd += bytesRcvd;
156 memcpy(reinterpret_cast<char *>(&localSection), BigBuffer,
sizeof(localSection));
173 std::cout <<
"End " << __PRETTY_FUNCTION__ <<
" " << errorCode << std::endl;
181 std::cout <<
"Begin and End " << __PRETTY_FUNCTION__ <<
" " <<
Connected << std::endl;
188 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
201 std::cout <<
"End " << __PRETTY_FUNCTION__ <<
" " << errorCode << std::endl;
208 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
221 std::cout <<
"End " << __PRETTY_FUNCTION__ <<
" " << errorCode << std::endl;
228 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
232 std::cout <<
"End " << __PRETTY_FUNCTION__ << std::endl;
238 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
244 struct hostent * hostInfo = gethostbyname(
servIP.c_str());
250 std::cout <<
"Requesting connection" << std::endl;
252 if((
tcpSocket = socket(AF_INET, SOCK_STREAM, 0))<0){
253 perror(
"Socket Error");
257 servAddr.sin_family = hostInfo->h_addrtype;
258 memcpy((
char *) &
servAddr.sin_addr.s_addr,
259 hostInfo->h_addr_list[0],
267 perror(
"Connect Error");
287 std::cout <<
"End " << __PRETTY_FUNCTION__ <<
" " << errorCode << std::endl;
294 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
302 perror(
"Shutdown Error");
315 std::cout <<
"End " << __PRETTY_FUNCTION__ <<
" " << errorCode << std::endl;
322 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
335 gettimeofday(&tvTemp,
NULL);
339 localSection.
lumiSummary.DeadtimeNormalization = 0.7;
359 for(j=0; j < 3564; j++){
375 for(i=0; i<36; i ++){
384 for(j=0; j < 3564; j ++){
386 for(k=0; k < 6; k++){
394 std::cout <<
"End " << __PRETTY_FUNCTION__ << std::endl;
401 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
414 localSection.
lumiSummary.DeadtimeNormalization = (float)(
rand() % 100)/100;
434 for(j=0; j < 3564; j++){
450 for(i=0; i<36; i ++){
459 for(j=0; j < 3564; j ++){
461 for(k=0; k < 6; k++){
469 std::cout <<
"End " << __PRETTY_FUNCTION__ << std::endl;
477 return !(memcmp(&L, &localSection,
sizeof(L)));
void SetupFDSets(fd_set &ReadFDs, fd_set &WriteFDs, fd_set &ExceptFDs, int ListeningSocket=-1, int connectSocket=-1)
unsigned char acquireMode
float InstantOccLumiErr[2]
int SetPort(unsigned short int)
ET_SUM_SECTION etSum[HCAL_HLX_MAX_HLXS]
float LHCLumi[HCAL_HLX_MAX_BUNCHES]
float data[HCAL_HLX_MAX_BUNCHES]
int16_t InstantETLumiQlty
uint32_t data[6][HCAL_HLX_MAX_BUNCHES]
LUMI_SECTION_SUB_HEADER hdr
float OccLumi[2][HCAL_HLX_MAX_BUNCHES]
uint32_t data[HCAL_HLX_MAX_BUNCHES]
float ETBXNormalization[HCAL_HLX_MAX_BUNCHES]
void SetIP(std::string IP)
float OccBXNormalization[2][HCAL_HLX_MAX_BUNCHES]
int16_t ETLumiQlty[HCAL_HLX_MAX_BUNCHES]
void GenerateRandomData(HCAL_HLX::LUMI_SECTION &localSection)
LHC_SECTION lhc[HCAL_HLX_MAX_HLXS]
float ETLumi[HCAL_HLX_MAX_BUNCHES]
LUMI_SECTION_SUB_HEADER hdr
OCCUPANCY_SECTION occupancy[HCAL_HLX_MAX_HLXS]
void GenerateFakeData(HCAL_HLX::LUMI_SECTION &localSection)
float ETLumiErr[HCAL_HLX_MAX_BUNCHES]
int16_t InstantOccLumiQlty[2]
int ReceiveLumiSection(HCAL_HLX::LUMI_SECTION &localSection)
int SetMode(unsigned char)
tuple connect
process.AlignmentProducer.algoConfig.uvarFile = '.
LUMI_SECTION_SUB_HEADER hdr
int16_t OccLumiQlty[2][HCAL_HLX_MAX_BUNCHES]
struct sockaddr_in servAddr
bool VerifyFakeData(HCAL_HLX::LUMI_SECTION &localSection)
float OccNormalization[2]
float OccLumiErr[2][HCAL_HLX_MAX_BUNCHES]