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 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);
89 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
98 unsigned int bytesRcvd, bytesToReceive, totalBytesRcvd;
99 const unsigned int Buffer_Size = 8192;
105 fd_set fdsRead, fdsWrite, fdsExcept;
109 time_t tempTime, curTime;
114 bytesToReceive =
sizeof(localSection);
115 Buffer =
new char[Buffer_Size];
116 BigBuffer =
new char[bytesToReceive];
119 memset(reinterpret_cast<char *>(&localSection), 0, Buffer_Size);
120 memset(Buffer, 0, Buffer_Size);
121 memset(BigBuffer, 0, bytesToReceive);
125 while ((totalBytesRcvd < bytesToReceive) && (errorCode == 0)) {
128 if (
select(
tcpSocket + 1, &fdsRead,
nullptr, &fdsExcept,
nullptr) > 0) {
130 if ((bytesRcvd = recv(
tcpSocket, Buffer, Buffer_Size, 0)) <= 0) {
131 perror(
"Recv Error");
134 if ((totalBytesRcvd + bytesRcvd) <= bytesToReceive) {
135 memcpy(&BigBuffer[totalBytesRcvd], Buffer, bytesRcvd);
137 std::cout <<
"***** MEM OVER FLOW: Did someone forget to update LumiStructures.hh? *****" 141 totalBytesRcvd += bytesRcvd;
148 if (errorCode == 0) {
149 memcpy(reinterpret_cast<char *>(&localSection), BigBuffer,
sizeof(localSection));
166 std::cout <<
"End " << __PRETTY_FUNCTION__ <<
" " << errorCode << std::endl;
174 std::cout <<
"Begin and End " << __PRETTY_FUNCTION__ <<
" " <<
Connected << std::endl;
181 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
194 std::cout <<
"End " << __PRETTY_FUNCTION__ <<
" " << errorCode << std::endl;
201 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
214 std::cout <<
"End " << __PRETTY_FUNCTION__ <<
" " << errorCode << std::endl;
221 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
225 std::cout <<
"End " << __PRETTY_FUNCTION__ << std::endl;
231 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
237 struct hostent *hostInfo = gethostbyname(
servIP.c_str());
243 std::cout <<
"Requesting connection" << std::endl;
245 if ((
tcpSocket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
246 perror(
"Socket Error");
250 servAddr.sin_family = hostInfo->h_addrtype;
251 memcpy((
char *)&
servAddr.sin_addr.s_addr, hostInfo->h_addr_list[0], hostInfo->h_length);
258 perror(
"Connect Error");
278 std::cout <<
"End " << __PRETTY_FUNCTION__ <<
" " << errorCode << std::endl;
285 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
292 if (shutdown(
tcpSocket, SHUT_RDWR) < 0) {
293 perror(
"Shutdown Error");
305 std::cout <<
"End " << __PRETTY_FUNCTION__ <<
" " << errorCode << std::endl;
312 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
325 gettimeofday(&tvTemp,
nullptr);
329 localSection.
lumiSummary.DeadtimeNormalization = 0.7;
349 for (j = 0; j < 3564; j++) {
365 for (i = 0; i < 36; i++) {
374 for (j = 0; j < 3564; j++) {
376 for (k = 0; k < 6; k++) {
384 std::cout <<
"End " << __PRETTY_FUNCTION__ << std::endl;
390 std::cout <<
"Begin " << __PRETTY_FUNCTION__ << std::endl;
394 srand(
time(
nullptr));
423 for (j = 0; j < 3564; j++) {
439 for (i = 0; i < 36; i++) {
448 for (j = 0; j < 3564; j++) {
450 for (k = 0; k < 6; k++) {
458 std::cout <<
"End " << __PRETTY_FUNCTION__ << std::endl;
465 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)
int16_t InstantETLumiQlty
LUMI_SECTION_SUB_HEADER hdr
void SetIP(std::string IP)
int16_t OccLumiQlty[2][4096]
void GenerateRandomData(HCAL_HLX::LUMI_SECTION &localSection)
float ETBXNormalization[4096]
float OccLumiErr[2][4096]
LUMI_SECTION_SUB_HEADER hdr
OCCUPANCY_SECTION occupancy[36]
void GenerateFakeData(HCAL_HLX::LUMI_SECTION &localSection)
int16_t InstantOccLumiQlty[2]
int ReceiveLumiSection(HCAL_HLX::LUMI_SECTION &localSection)
select
when omitted electron plots will be filled w/o cut on electronId electronId = cms.PSet( src = cms.InputTag("mvaTrigV0"), cutValue = cms.double(0.5) ), when omitted electron plots will be filled w/o additional pre- selection of the electron candidates
int SetMode(unsigned char)
LUMI_SECTION_SUB_HEADER hdr
struct sockaddr_in servAddr
float OccBXNormalization[2][4096]
bool VerifyFakeData(HCAL_HLX::LUMI_SECTION &localSection)
float OccNormalization[2]