14 #include "DipFactory.h"
15 #include "DipPublication.h"
16 #include "DipTimestamp.h"
21 const char*
qualities[3] = {
"Uncertain",
"Bad",
"Good"};
92 const string subjectPV =
"dip/CMS/Tracker/PrimaryVertices";
94 string sourceFile =
"/nfshome0/dqmpro/BeamMonitorDQM/BeamFitResultsForDIP.txt";
95 string sourceFile1 =
"/nfshome0/dqmpro/BeamMonitorDQM/BeamFitResultsOld_TkStatus.txt";
104 strftime(mbstr,
sizeof(mbstr),
"%Y.%m.%d %H:%M:%S %z", std::localtime(&t));
110 time_t
t = time(
nullptr);
122 cerr <<
"exception (create): " << e.what() << endl;
128 struct stat stat_buf;
129 int rc =
stat(filename.c_str(), &stat_buf);
130 return (rc == 0 ? stat_buf.st_size : -1);
135 struct stat stat_buf;
136 int rc =
stat(filename.c_str(), &stat_buf);
137 return (rc == 0 ? stat_buf.st_mtime : -1);
141 vector<string>
parse(
string line,
const string& delimiter) {
145 while ((pos = line.find(delimiter)) != string::npos) {
146 string token = line.substr(0, pos);
148 list.push_back(token);
150 line.erase(0, pos + delimiter.length());
153 list.push_back(line);
251 cerr <<
"exception (trueRcd): " << e.what() << endl;
273 cerr <<
"exception (fakeRcd): " << e.what() << endl;
283 cerr <<
"sending (" << qlty <<
" | " << err <<
")";
287 cerr <<
" to CCC and CMS";
289 cerr <<
" to CCC only";
299 zeit = DipTimestamp(epoch);
301 zeit = DipTimestamp();
322 }
else if (qlty ==
"UNINITIALIZED") {
329 cerr <<
"exception (publishRcd): " << e.what() << endl;
336 bool rcdQlty =
false;
340 while (getline(file, record)) {
343 vector<string>
tmp =
parse(record,
" ");
345 switch (nthLnInRcd) {
347 if (record.rfind(
"Run", 0) != 0) {
348 cerr <<
"Reading of results text file interrupted. " +
getDateTime() << endl;
354 startTime = tmp[1] +
" " + tmp[2] +
" " + tmp[3];
358 endTime = tmp[1] +
" " + tmp[2] +
" " + tmp[3];
442 rmsPV = stof(tmp[1]);
448 maxPV = stoi(tmp[1]);
462 cerr <<
"io exception (readRcd): " << e.what() << endl;
476 outstr =
"No CMS Tracker status available. No DAQ/DQM.";
484 while (getline(logfile, record)) {
486 vector<string>
tmp =
parse(record,
" ");
488 switch (nthLnInRcd) {
490 if (tmp[1].
find(
"Yes") == string::npos)
491 outstr =
"CMS Tracker OFF.";
493 outstr =
"CMS not taking data or no beam.";
503 cerr <<
"exception (tkStatus): " << e.what() << endl;
515 cerr <<
"no update | alive = " <<
alive << endl;
523 if (!
alive.test(2)) {
529 stringstream warnMsg;
530 warnMsg <<
"No new data for " <<
lsCount <<
" LS";
531 publishRcd(
"Uncertain", warnMsg.str(),
false,
false);
535 stringstream warnMsg;
537 publishRcd(
"Bad", warnMsg.str(),
false,
false);
544 stringstream warnMsg;
546 publishRcd(
"Bad", warnMsg.str(),
false,
false);
555 if (!logFile.good()) {
568 cerr <<
"New run starts. Run number: " <<
runnum << endl;
590 cerr <<
"got new record from file" << endl;
597 cerr <<
"problem with new record" << endl;
612 cerr <<
"io exception (end of lumi): " << e.what() << endl;
638 cerr <<
"exception (start up): " << e.what() << endl;
663 verbose = strcmp(args[1],
"true");
664 testing = strcmp(args[2],
"true");
675 dip->setDNSNode(
"cmsdimns2.cern.ch");
677 cerr <<
"reading from file (NFS)" << endl;
682 cerr <<
"entering polling loop" << endl;
689 cerr <<
"[done]" << endl;
vector< string > parse(string line, const string &delimiter)
string getDateTime(time_t t)
DipPublication * publicationPV
void handleException(DipPublication *publication, DipException &e) override
void publishRcd(string qlty, string err, bool pubCMS, bool fitTime)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
long getFileSize(string filename)
bool readRcd(ifstream &file)
DipPublication * publicationCMS
const bool publishStatErrors
time_t getLastTime(string filename)
const char * qualities[3]
DipPublication * publicationLHC
void CMS2LHCRF_POS(float x, float y, float z)