16 #include "DipFactory.h"
17 #include "DipPublication.h"
18 #include "DipTimestamp.h"
23 class ErrHandler :
public DipPublicationErrorHandler {
29 edm::LogError(
"BeamSpotDipServer") <<
"exception (create): " << e.what();
51 bsLegacyToken_ = esConsumes<edm::Transition::EndLuminosityBlock>();
54 dcsRecordToken_ = consumes<DCSRecord>(dcsRecordInputTag_);
60 dip->setDNSNode(
"cmsdimns1.cern.ch");
62 edm::LogInfo(
"BeamSpotDipServer") <<
"reading from " << (readFromNFS ?
"file (NFS)" :
"database");
94 edm::LogError(
"BeamSpotDipServer") <<
"exception (start up): " << e.what();
114 if (nthlumi > lastlumi) {
118 iEvent.
getByToken(dcsRecordToken_, dcsRecord);
126 edm::LogInfo(
"BeamSpotDipServer") <<
"whole tracker on? " << (wholeTrackerOn ?
"yes" :
"no");
139 if (!logFile.good()) {
174 edm::LogInfo(
"BeamSpotDipServer") <<
"got new record from file";
181 edm::LogInfo(
"BeamSpotDipServer") <<
"problem with new record";
196 auto const&
bs = *bsLegacyHandle;
201 edm::LogInfo(
"BeamSpotDipServer") <<
"got new record from database";
207 edm::LogInfo(
"BeamSpotDipServer") <<
"problem with new record";
222 edm::LogWarning(
"BeamSpotDipServer") <<
"io exception (end of lumi): " << e.what();
244 struct stat stat_buf;
245 int rc =
stat(filename.c_str(), &stat_buf);
246 return (rc == 0 ? stat_buf.st_size : -1);
251 struct stat stat_buf;
252 int rc =
stat(filename.c_str(), &stat_buf);
253 return (rc == 0 ? stat_buf.st_mtime : -1);
261 while ((pos = line.find(delimiter)) != string::npos) {
262 string token = line.substr(0, pos);
264 list.push_back(token);
266 line.erase(0, pos + delimiter.length());
269 list.push_back(line);
283 outstr =
"No CMS Tracker status available. No DAQ/DQM.";
291 while (getline(logfile, record)) {
293 vector<string>
tmp =
parse(record,
" ");
295 switch (nthLnInRcd) {
297 if (tmp[1].
find(
"Yes") == string::npos)
298 outstr =
"CMS Tracker OFF.";
300 outstr =
"CMS not taking data or no beam.";
310 edm::LogWarning(
"BeamSpotDipServer") <<
"exception (tkStatus): " << e.what();
318 outstr =
"CMS not taking data or no beam.";
320 outstr =
"CMS Tracker OFF.";
337 if (!
alive.test(2)) {
343 stringstream warnMsg;
344 warnMsg <<
"No new data for " <<
lsCount <<
" LS";
345 publishRcd(
"Uncertain", warnMsg.str(),
false,
false);
349 stringstream warnMsg;
351 publishRcd(
"Bad", warnMsg.str(),
false,
false);
359 stringstream warnMsg;
361 publishRcd(
"Bad", warnMsg.str(),
false,
false);
379 edm::LogWarning(
"BeamSpotDipServer") <<
"time variables are not available (readRcd): " << e.what();
390 edm::LogWarning(
"BeamSpotDipServer") <<
"lumirange variable not avaialble (readRcd): " << e.what();
437 edm::LogWarning(
"BeamSpotDipServer") <<
"PV variables are not available (readRcd): " << e.what();
450 edm::LogInfo(
"BeamSpotDipServer") <<
"pos: (" <<
x <<
"," <<
y <<
"," <<
z <<
")"
460 bool rcdQlty =
false;
464 while (getline(file, record)) {
467 vector<string>
tmp =
parse(record,
" ");
469 switch (nthLnInRcd) {
471 if (record.rfind(
"Run", 0) != 0) {
478 startTime = tmp[1] +
" " + tmp[2] +
" " + tmp[3];
482 endTime = tmp[1] +
" " + tmp[2] +
" " + tmp[3];
566 rmsPV = stof(tmp[1]);
572 maxPV = stoi(tmp[1]);
586 edm::LogWarning(
"BeamSpotDipServer") <<
"io exception (readRcd): " << e.what();
685 edm::LogWarning(
"BeamSpotDipServer") <<
"exception (trueRcd): " << e.what();
707 edm::LogWarning(
"BeamSpotDipServer") <<
"exception (fakeRcd): " << e.what();
717 edm::LogInfo(
"BeamSpotDipServer") <<
"sending (" << qlty <<
" | " << err <<
")";
731 zeit = DipTimestamp(epoch);
733 zeit = DipTimestamp();
753 }
else if (qlty ==
"UNINITIALIZED") {
760 edm::LogWarning(
"BeamSpotDipServer") <<
"exception (publishRcd): " << e.what();
767 strftime(mbstr,
sizeof(mbstr),
"%Y.%m.%d %H:%M:%S %z", std::localtime(&t));
774 time_t t = time(
nullptr);
T getUntrackedParameter(std::string const &, T const &) const
double z() const
get Z beam position
vector< string > parse(string line, const string &delimiter)
void CMS2LHCRF_POS(float x, float y, float z)
double yError() const
get Y beam position Error
string getDateTime(time_t t)
double xError() const
get X beam position Error
std::string getDateTime()
void dqmEndRun(const edm::Run &, const edm::EventSetup &iSetup) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::string lumiRange() const
int lastAnalyzedRun() const
#define DEFINE_FWK_MODULE(type)
double dydzError() const
get dydz slope, crossing angle in YZ Error
bool readRcd(const BeamSpotOnlineObjects &bs)
edm::LuminosityBlockNumber_t luminosityBlock() const
std::string to_string(const V &value)
double dxdzError() const
get dxdz slope, crossing angle in XZ Error
double y() const
get Y beam position
DipPublication * publicationPV
double dxdz() const
get dxdz slope, crossing angle in XZ
double zError() const
get Z beam position Error
void handleException(DipPublication *publication, DipException &e) override
void publishRcd(string qlty, string err, bool pubCMS, bool fitTime)
Log< level::Error, false > LogError
double beamWidthYError() const
get average transverse beam width error X = Y
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
cond::Time_t creationTime() const
long getFileSize(string filename)
void dqmEndLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &) override
double sigmaZ() const
get sigma Z, RMS bunch length
LuminosityBlockNumber_t luminosityBlock() const
float meanErrorPV() const
void publishRcd(std::string qlty, std::string err, bool pubCMS, bool fitTime)
bool readRcd(ifstream &file)
cond::Time_t startTimeStamp() const
long getFileSize(std::string filename)
DipPublication * publicationCMS
int lastAnalyzedLumi() const
Getters Methods.
BeamSpotDipServer(const edm::ParameterSet &)
double beamWidthX() const
get average transverse beam width
std::string startTime() const
const bool publishStatErrors
void analyze(const edm::Event &e, const edm::EventSetup &) override
cond::Time_t endTimeStamp() const
time_t getLastTime(string filename)
double x() const
get X beam position
const char * qualities[3]
std::vector< std::string > parse(std::string line, const std::string &delimiter)
double sigmaZError() const
get sigma Z, RMS bunch length Error
Log< level::Info, false > LogInfo
DipPublication * publicationLHC
time_t getLastTime(std::string filename)
void dqmBeginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &) override
T getParameter(std::string const &) const
double dydz() const
get dydz slope, crossing angle in YZ
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &) override
int beamType() const
get beam type
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Log< level::Warning, false > LogWarning
double beamWidthXError() const
get average transverse beam width error ASSUME the same for X and Y
std::string endTime() const
void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) override
void CMS2LHCRF_POS(float x, float y, float z)