CMS 3D CMS Logo

BeamSpotDipServer.cc
Go to the documentation of this file.
2 
9 
10 #include <fstream>
11 #include <vector>
12 #include <ctime>
13 #include <sys/stat.h>
14 
15 #include "Dip.h"
16 #include "DipFactory.h"
17 #include "DipPublication.h"
18 #include "DipTimestamp.h"
19 
20 using namespace std;
21 
22 /*****************************************************************************/
23 class ErrHandler : public DipPublicationErrorHandler {
24 public:
25  virtual ~ErrHandler() = default;
26 
27 private:
28  void handleException(DipPublication* publication, DipException& e) override {
29  edm::LogError("BeamSpotDipServer") << "exception (create): " << e.what();
30  }
31 };
32 
33 /*****************************************************************************/
35  //
36  verbose = ps.getUntrackedParameter<bool>("verbose");
37  testing = ps.getUntrackedParameter<bool>("testing");
38 
39  subjectCMS = ps.getUntrackedParameter<string>("subjectCMS");
40  subjectLHC = ps.getUntrackedParameter<string>("subjectLHC");
41  subjectPV = ps.getUntrackedParameter<string>("subjectPV");
42 
43  readFromNFS = ps.getUntrackedParameter<bool>("readFromNFS");
44  // only if readFromNFS = true
45  sourceFile = ps.getUntrackedParameter<string>("sourceFile"); // beamspot
46  sourceFile1 = ps.getUntrackedParameter<string>("sourceFile1"); // tk status
47 
48  timeoutLS = ps.getUntrackedParameter<vector<int>>("timeoutLS");
49 
50  //
51  bsLegacyToken_ = esConsumes<edm::Transition::EndLuminosityBlock>();
52 
53  dcsRecordInputTag_ = ps.getParameter<edm::InputTag>("dcsRecordInputTag");
54  dcsRecordToken_ = consumes<DCSRecord>(dcsRecordInputTag_);
55 
56  //
57  dip = Dip::create("CmsBeamSpotServer");
58 
59  // Use both CMS-based DIM DNS server (https://its.cern.ch/jira/browse/CMSOMS-280)
60  dip->setDNSNode("cmsdimns1.cern.ch,cmsdimns2.cern.ch");
61 
62  edm::LogInfo("BeamSpotDipServer") << "reading from " << (readFromNFS ? "file (NFS)" : "database");
63 }
64 
65 /*****************************************************************************/
67  // do nothing
68 }
69 
70 /*****************************************************************************/
72  edm::LogInfo("BeamSpotDipServer") << "begin run " << r.run();
73 
74  try {
75  ErrHandler errHandler;
76 
77  edm::LogInfo("BeamSpotDipServer") << "server started at " + getDateTime();
78 
79  edm::LogInfo("BeamSpotDipServer") << "creating publication " + subjectCMS;
80  publicationCMS = dip->createDipPublication(subjectCMS.c_str(), &errHandler);
81  messageCMS = dip->createDipData();
82 
83  edm::LogInfo("BeamSpotDipServer") << "creating publication " + subjectLHC;
84  publicationLHC = dip->createDipPublication(subjectLHC.c_str(), &errHandler);
85  messageLHC = dip->createDipData();
86 
87  edm::LogInfo("BeamSpotDipServer") << "creating publication " + subjectPV;
88  publicationPV = dip->createDipPublication(subjectPV.c_str(), &errHandler);
89  messagePV = dip->createDipData();
90 
91  trueRcd(); // starts with all 0
92  publishRcd("UNINITIALIZED", "", true, false);
93  } catch (exception& e) {
94  edm::LogError("BeamSpotDipServer") << "exception (start up): " << e.what();
95  }
96 
97  quality = qualities[0]; // start with Uncertain
98 }
99 
100 /*****************************************************************************/
102  // do nothing
103 }
104 
105 /*****************************************************************************/
107  if (!readFromNFS) {
108  // get runnumber
109  runnum = iEvent.run();
110 
111  // get tracker status if in a new lumisection
112  int nthlumi = iEvent.luminosityBlock();
113 
114  if (nthlumi > lastlumi) { // check every LS
115  lastlumi = nthlumi;
116 
118  iEvent.getByToken(dcsRecordToken_, dcsRecord);
119 
120  wholeTrackerOn =
121  (*dcsRecord).highVoltageReady(DCSRecord::BPIX) && (*dcsRecord).highVoltageReady(DCSRecord::FPIX) &&
122  (*dcsRecord).highVoltageReady(DCSRecord::TIBTID) && (*dcsRecord).highVoltageReady(DCSRecord::TOB) &&
123  (*dcsRecord).highVoltageReady(DCSRecord::TECp) && (*dcsRecord).highVoltageReady(DCSRecord::TECm);
124 
125  if (verbose)
126  edm::LogInfo("BeamSpotDipServer") << "whole tracker on? " << (wholeTrackerOn ? "yes" : "no");
127  }
128  }
129 }
130 
131 /*****************************************************************************/
133  edm::LogInfo("BeamSpotDipServer") << "--------------------- end of LS " << lumiSeg.luminosityBlock();
134 
135  try {
136  if (readFromNFS) {
137  ifstream logFile(sourceFile);
138 
139  if (!logFile.good()) {
140  edm::LogWarning("BeamSpotDipServer") << "Source File: " + sourceFile + " doesn't exist!";
141  problem();
142  } else {
144 
145  if (lastFitTime == 0)
147 
148  if (getFileSize(sourceFile) == 0) {
149  // source file has zero length
150  if (lastModTime > lastFitTime) {
151  string tmp = tkStatus();
152  edm::LogInfo("BeamSpotDipServer") << "New run starts. Run number: " << runnum;
153  if (verbose)
154  edm::LogInfo("BeamSpotDipServer") << "Initial lastModTime = " + getDateTime(lastModTime);
155  }
157  }
158 
159  if (lastModTime > lastFitTime) {
160  // source file modified
161  if (verbose) {
162  edm::LogInfo("BeamSpotDipServer") << "time of last fit = " + getDateTime(lastFitTime);
163  edm::LogInfo("BeamSpotDipServer") << "time of current fit = " + getDateTime(lastModTime);
164  }
166 
167  // source file length > 0
168  if (getFileSize(sourceFile) > 0) {
169  if (verbose)
170  edm::LogInfo("BeamSpotDipServer") << "reading record from " + sourceFile;
171 
172  if (readRcd(logFile)) {
173  if (verbose)
174  edm::LogInfo("BeamSpotDipServer") << "got new record from file";
175 
176  trueRcd();
177  alive.reset();
178  alive.flip(7);
179  } else {
180  if (verbose)
181  edm::LogInfo("BeamSpotDipServer") << "problem with new record";
182  fakeRcd();
183  }
184 
185  lsCount = 0;
186  }
187  } else {
188  // source file not touched
189  problem();
190  }
191  }
192 
193  logFile.close();
194  } else {
195  edm::ESHandle<BeamSpotOnlineObjects> bsLegacyHandle = iSetup.getHandle(bsLegacyToken_);
196  auto const& bs = *bsLegacyHandle;
197 
198  // from database
199  if (readRcd(bs)) {
200  if (verbose)
201  edm::LogInfo("BeamSpotDipServer") << "got new record from database";
202  trueRcd();
203  alive.reset();
204  alive.flip(7);
205  } else {
206  if (verbose)
207  edm::LogInfo("BeamSpotDipServer") << "problem with new record";
208  fakeRcd();
209  }
210 
211  lsCount = 0;
212  }
213 
214  // quality of the publish results
215  if (testing)
216  publishRcd(qualities[0], "Testing", true, true); // Uncertain
217  else if (quality == qualities[1]) // Bad
218  publishRcd(quality, "No fit or fit fails", true, true);
219  else
220  publishRcd(quality, "", true, true); // Good
221  } catch (exception& e) {
222  edm::LogWarning("BeamSpotDipServer") << "io exception (end of lumi): " << e.what();
223  };
224 }
225 
226 /*****************************************************************************/
228  // destroy publications and data
229  edm::LogInfo("BeamSpotDipServer") << "destroying publication " + subjectCMS;
230  dip->destroyDipPublication(publicationCMS);
231  delete messageCMS;
232 
233  edm::LogInfo("BeamSpotDipServer") << "destroying publication " + subjectLHC;
234  dip->destroyDipPublication(publicationLHC);
235  delete messageLHC;
236 
237  edm::LogInfo("BeamSpotDipServer") << "destroying publication " + subjectPV;
238  dip->destroyDipPublication(publicationPV);
239  delete messagePV;
240 }
241 
242 /*****************************************************************************/
244  struct stat stat_buf;
245  int rc = stat(filename.c_str(), &stat_buf);
246  return (rc == 0 ? stat_buf.st_size : -1);
247 }
248 
249 /*****************************************************************************/
251  struct stat stat_buf;
252  int rc = stat(filename.c_str(), &stat_buf);
253  return (rc == 0 ? stat_buf.st_mtime : -1);
254 }
255 
256 /*****************************************************************************/
257 vector<string> BeamSpotDipServer::parse(string line, const string& delimiter) {
258  vector<string> list;
259 
260  size_t pos = 0;
261  while ((pos = line.find(delimiter)) != string::npos) {
262  string token = line.substr(0, pos);
263 
264  list.push_back(token);
265 
266  line.erase(0, pos + delimiter.length());
267  }
268 
269  list.push_back(line); // remainder
270 
271  return list;
272 }
273 
274 /*****************************************************************************/
276  string outstr;
277 
278  if (readFromNFS) { // get from file on /nfs
279  ifstream logfile(sourceFile1);
280 
281  if (!logfile.good() || getFileSize(sourceFile1) == 0) {
282  // file does not exist or has zero size
283  outstr = "No CMS Tracker status available. No DAQ/DQM.";
284  } else {
285  int nthLnInRcd = 0;
286  string record;
287 
288  try {
289  string record;
290 
291  while (getline(logfile, record)) {
292  nthLnInRcd++;
293  vector<string> tmp = parse(record, " ");
294 
295  switch (nthLnInRcd) {
296  case 7:
297  if (tmp[1].find("Yes") == string::npos)
298  outstr = "CMS Tracker OFF.";
299  else
300  outstr = "CMS not taking data or no beam.";
301  break;
302  case 8:
303  runnum = stoi(tmp[1]);
304  break;
305  default:
306  break;
307  }
308  }
309  } catch (exception& e) {
310  edm::LogWarning("BeamSpotDipServer") << "exception (tkStatus): " << e.what();
311  }
312  }
313 
314  logfile.close();
315  } else {
316  // get from DCS
317  if (wholeTrackerOn)
318  outstr = "CMS not taking data or no beam.";
319  else
320  outstr = "CMS Tracker OFF.";
321  }
322 
323  return outstr;
324 }
325 
326 /*****************************************************************************/
328  if (verbose)
329  edm::LogInfo("BeamSpotDipServer") << "no update | alive = " << alive;
330 
331  lsCount++;
332 
333  if ((lsCount % timeoutLS[0] == 0) && (lsCount % timeoutLS[1] != 0)) // first time out
334  {
335  if (!alive.test(1))
336  alive.flip(1);
337  if (!alive.test(2)) {
338  if (!alive.test(7))
339  fakeRcd();
340  else
341  trueRcd();
342 
343  stringstream warnMsg;
344  warnMsg << "No new data for " << lsCount << " LS";
345  publishRcd("Uncertain", warnMsg.str(), false, false);
346  } else {
347  fakeRcd();
348 
349  stringstream warnMsg;
350  warnMsg << "No new data for " << lsCount << " LS: " << tkStatus();
351  publishRcd("Bad", warnMsg.str(), false, false);
352  }
353  } else if (lsCount % timeoutLS[1] == 0) // second time out
354  {
355  if (!alive.test(2))
356  alive.flip(2);
357  fakeRcd();
358 
359  stringstream warnMsg;
360  warnMsg << "No new data for " << lsCount << " LS: " << tkStatus();
361  publishRcd("Bad", warnMsg.str(), false, false);
362  }
363 }
364 
365 /*****************************************************************************/
367 // read from database
368 {
369  runnum = bs.lastAnalyzedRun();
370 
371  // get from BeamSpotOnlineObject
372 
373  try {
374  startTime = bs.startTime();
375  startTimeStamp = bs.startTimeStamp();
376  endTime = bs.endTime();
377  endTimeStamp = bs.endTimeStamp();
378  } catch (exception& e) {
379  edm::LogWarning("BeamSpotDipServer") << "time variables are not available (readRcd): " << e.what();
380 
381  startTime = bs.creationTime();
382  startTimeStamp = bs.creationTime();
383  endTime = bs.creationTime();
384  endTimeStamp = bs.creationTime();
385  }
386 
387  try {
388  lumiRange = bs.lumiRange();
389  } catch (exception& e) {
390  edm::LogWarning("BeamSpotDipServer") << "lumirange variable not avaialble (readRcd): " << e.what();
391 
392  lumiRange = to_string(bs.lastAnalyzedLumi());
393  }
394 
395  currentLS = bs.lastAnalyzedLumi();
396 
397  type = bs.beamType();
398 
399  if (verbose)
400  edm::LogInfo("BeamSpotDipServer") << "run: " << runnum << ", LS: " << currentLS << ", time: " << startTime << " "
401  << startTimeStamp << ", type: " << type;
402 
403  if (testing)
404  quality = qualities[0]; // Uncertain
405  else if (type >= 2)
406  quality = qualities[2]; // Good
407  else
408  quality = qualities[1]; // Bad
409 
410  x = bs.x();
411  y = bs.y();
412  z = bs.z();
413 
414  sigma_z = bs.sigmaZ();
415  dxdz = bs.dxdz();
416  dydz = bs.dydz();
417  width_x = bs.beamWidthX();
418  width_y = bs.beamWidthX();
419 
420  err_x = bs.xError();
421  err_y = bs.yError();
422  err_z = bs.zError();
423  err_sigma_z = bs.sigmaZError();
424  err_dxdz = bs.dxdzError();
425  err_dydz = bs.dydzError();
426  err_width_x = bs.beamWidthXError();
427  err_width_y = bs.beamWidthYError();
428 
429  try {
430  events = bs.usedEvents();
431  meanPV = bs.meanPV();
432  err_meanPV = bs.meanErrorPV();
433  rmsPV = bs.rmsPV();
434  err_rmsPV = bs.rmsErrorPV();
435  maxPV = bs.maxPVs();
436  } catch (exception& e) {
437  edm::LogWarning("BeamSpotDipServer") << "PV variables are not available (readRcd): " << e.what();
438 
439  events = 0.;
440  meanPV = 0.;
441  err_meanPV = 0.;
442  rmsPV = 0.;
443  err_rmsPV = 0.;
444  maxPV = 0.;
445  }
446 
447  nPV = bs.numPVs();
448 
449  if (verbose)
450  edm::LogInfo("BeamSpotDipServer") << "pos: (" << x << "," << y << "," << z << ")"
451  << " nPV: " << nPV;
452 
453  return true;
454 }
455 
456 /*****************************************************************************/
457 bool BeamSpotDipServer::readRcd(ifstream& file) // readFromNFS
458 {
459  int nthLnInRcd = 0;
460  bool rcdQlty = false;
461 
462  try {
463  string record;
464  while (getline(file, record)) {
465  nthLnInRcd++;
466 
467  vector<string> tmp = parse(record, " ");
468 
469  switch (nthLnInRcd) {
470  case 1:
471  if (record.rfind("Run", 0) != 0) {
472  edm::LogError("BeamSpotDipServer") << "Reading of results text file interrupted. " + getDateTime();
473  return false;
474  }
475  runnum = stoi(tmp[1]);
476  break;
477  case 2:
478  startTime = tmp[1] + " " + tmp[2] + " " + tmp[3];
479  startTimeStamp = stol(tmp[4]);
480  break;
481  case 3:
482  endTime = tmp[1] + " " + tmp[2] + " " + tmp[3];
483  endTimeStamp = stol(tmp[4]);
484  break;
485  case 4:
486  lumiRange = record.substr(10);
487  if (verbose)
488  edm::LogInfo("BeamSpotDipServer") << "lumisection range: " + lumiRange;
489  currentLS = stoi(tmp[3]);
490  break;
491  case 5:
492  type = stoi(tmp[1]);
493  if (testing)
494  quality = qualities[0]; // Uncertain
495  else if (type >= 2)
496  quality = qualities[2]; // Good
497  else
498  quality = qualities[1]; // Bad
499  break;
500 
501  case 6:
502  x = stof(tmp[1]);
503  break;
504  case 7:
505  y = stof(tmp[1]);
506  break;
507  case 8:
508  z = stof(tmp[1]);
509  break;
510 
511  case 9:
512  sigma_z = stof(tmp[1]);
513  break;
514  case 10:
515  dxdz = stof(tmp[1]);
516  break;
517  case 11:
518  dydz = stof(tmp[1]);
519  break;
520  case 12:
521  width_x = stof(tmp[1]);
522  break;
523  case 13:
524  width_y = stof(tmp[1]);
525  break;
526 
527  case 14:
528  err_x = sqrt(stof(tmp[1]));
529  break;
530  case 15:
531  err_y = sqrt(stof(tmp[2]));
532  break;
533  case 16:
534  err_z = sqrt(stof(tmp[3]));
535  break;
536  case 17:
537  err_sigma_z = sqrt(stof(tmp[4]));
538  break;
539  case 18:
540  err_dxdz = sqrt(stof(tmp[5]));
541  break;
542  case 19:
543  err_dydz = sqrt(stof(tmp[6]));
544  break;
545  case 20:
546  err_width_x = sqrt(stof(tmp[7]));
548  break;
549  case 21:
550  break;
551  case 22:
552  break;
553  case 23:
554  break;
555  case 24:
556  events = stoi(tmp[1]);
557  break;
558 
559  case 25:
560  meanPV = stof(tmp[1]);
561  break;
562  case 26:
563  err_meanPV = stof(tmp[1]);
564  break;
565  case 27:
566  rmsPV = stof(tmp[1]);
567  break;
568  case 28:
569  err_rmsPV = stof(tmp[1]);
570  break;
571  case 29:
572  maxPV = stoi(tmp[1]);
573  break;
574  case 30:
575  nPV = stoi(tmp[1]);
576  rcdQlty = true;
577  break;
578 
579  default:
580  break;
581  }
582  }
583 
584  file.close();
585  } catch (exception& e) {
586  edm::LogWarning("BeamSpotDipServer") << "io exception (readRcd): " << e.what();
587  }
588 
589  return rcdQlty;
590 }
591 
592 /*****************************************************************************/
593 void BeamSpotDipServer::CMS2LHCRF_POS(float x, float y, float z) {
594  if (x != 0) { // Rotation + Translation + Inversion + Scaling
595  double tmpx = x;
596  // x*rotY[0]*rotZ[0] + y*rotY[0]*rotZ[1] - z*rotY[1] + trans[0];
597  Centroid[0] = tmpx;
598  Centroid[0] *= -1.0 * cm2um;
599  } else
600  Centroid[0] = x;
601 
602  if (y != 0) { // Rotation + Translation + Scaling
603  double tmpy = y;
604  // x*(rotX[1]*rotY[1]*rotZ[0] - rotX[0]*rotZ[1]) +
605  // y*(rotX[0]*rotZ[0] + rotX[1]*rotY[1]*rotZ[1]) +
606  // z*rotX[1]*rotY[0] + trans[1];
607  Centroid[1] = tmpy;
608  Centroid[1] *= cm2um;
609  } else
610  Centroid[1] = y;
611 
612  if (z != 0) { // Rotation + Translation + Inversion + Scaling
613  double tmpz = z;
614  // x*(rotX[0]*rotY[1]*rotZ[0] + rotX[1]*rotZ[1]) +
615  // y*(rotX[0]*rotY[1]*rotZ[1] - rotX[1]*rotZ[0]) +
616  // z*rotX[0]*rotY[0] + trans[2];
617  Centroid[2] = tmpz;
618  Centroid[2] *= -1.0 * cm2mm;
619  } else
620  Centroid[2] = z;
621 }
622 
623 /*****************************************************************************/
625  try {
626  // CMS to LHC RF
627  CMS2LHCRF_POS(x, y, z);
628 
629  Tilt[0] = dxdz * rad2urad;
630  Tilt[1] = (dydz != 0 ? (dydz * -1 * rad2urad) : 0);
631 
632  Size[0] = width_x * cm2um;
633  Size[1] = width_y * cm2um;
634  Size[2] = sigma_z * cm2mm;
635 
636  // CMS
637  messageCMS->insert(runnum, "runnum");
638  messageCMS->insert(startTime, "startTime");
639  messageCMS->insert(endTime, "endTime");
640  messageCMS->insert(startTimeStamp, "startTimeStamp");
641  messageCMS->insert(endTimeStamp, "endTimeStamp");
642  messageCMS->insert(lumiRange, "lumiRange");
643  messageCMS->insert(quality, "quality");
644  messageCMS->insert(type, "type"); // Unknown=-1, Fake=0, Tracker=2(Good)
645  messageCMS->insert(x, "x");
646  messageCMS->insert(y, "y");
647  messageCMS->insert(z, "z");
648  messageCMS->insert(dxdz, "dxdz");
649  messageCMS->insert(dydz, "dydz");
650  messageCMS->insert(width_x, "width_x");
651  messageCMS->insert(width_y, "width_y");
652  messageCMS->insert(sigma_z, "sigma_z");
653 
654  if (publishStatErrors) {
655  messageCMS->insert(err_x, "err_x");
656  messageCMS->insert(err_y, "err_y");
657  messageCMS->insert(err_z, "err_z");
658  messageCMS->insert(err_dxdz, "err_dxdz");
659  messageCMS->insert(err_dydz, "err_dydz");
660  messageCMS->insert(err_width_x, "err_width_x");
661  messageCMS->insert(err_width_y, "err_width_y");
662  messageCMS->insert(err_sigma_z, "err_sigma_z");
663  }
664 
665  // LHC
666  messageLHC->insert(Size, 3, "Size");
667  messageLHC->insert(Centroid, 3, "Centroid");
668  messageLHC->insert(Tilt, 2, "Tilt");
669 
670  // PV
671  messagePV->insert(runnum, "runnum");
672  messagePV->insert(startTime, "startTime");
673  messagePV->insert(endTime, "endTime");
674  messagePV->insert(startTimeStamp, "startTimeStamp");
675  messagePV->insert(endTimeStamp, "endTimeStamp");
676  messagePV->insert(lumiRange, "lumiRange");
677  messagePV->insert(events, "events");
678  messagePV->insert(meanPV, "meanPV");
679  messagePV->insert(err_meanPV, "err_meanPV");
680  messagePV->insert(rmsPV, "rmsPV");
681  messagePV->insert(err_rmsPV, "err_rmsPV");
682  messagePV->insert(maxPV, "maxPV");
683  messagePV->insert(nPV, "nPV");
684  } catch (exception& e) {
685  edm::LogWarning("BeamSpotDipServer") << "exception (trueRcd): " << e.what();
686  }
687 }
688 
689 /*****************************************************************************/
691  try {
692  Centroid[0] = 0;
693  Centroid[1] = 0;
694  Centroid[2] = 0;
695 
696  Size[0] = 0;
697  Size[1] = 0;
698  Size[2] = 0;
699 
700  Tilt[0] = 0;
701  Tilt[1] = 0;
702 
703  messageLHC->insert(Size, 3, "Size");
704  messageLHC->insert(Centroid, 3, "Centroid");
705  messageLHC->insert(Tilt, 2, "Tilt");
706  } catch (exception& e) {
707  edm::LogWarning("BeamSpotDipServer") << "exception (fakeRcd): " << e.what();
708  }
709 }
710 
711 /*****************************************************************************/
712 void BeamSpotDipServer::publishRcd(string qlty, string err, bool pubCMS, bool fitTime) {
713  try {
714  bool updateCMS = pubCMS && (currentLS % intLS == 0);
715 
716  if (verbose) {
717  edm::LogInfo("BeamSpotDipServer") << "sending (" << qlty << " | " << err << ")";
718 
719  if (alive.test(7)) {
720  if (updateCMS)
721  edm::LogInfo("BeamSpotDipServer") << " to CCC and CMS";
722  else if (!alive.test(1) && !alive.test(2))
723  edm::LogInfo("BeamSpotDipServer") << " to CCC only";
724  }
725  }
726 
727  DipTimestamp zeit;
728  if (fitTime) {
729  long epoch;
730  epoch = endTimeStamp * 1000; // convert to ms
731  zeit = DipTimestamp(epoch);
732  } else
733  zeit = DipTimestamp();
734 
735  // send
736  if (updateCMS)
737  publicationCMS->send(*messageCMS, zeit);
738 
739  publicationLHC->send(*messageLHC, zeit);
740  publicationPV->send(*messagePV, zeit);
741 
742  // set qualities
743  if (qlty == qualities[0]) { // Uncertain
744  if (updateCMS)
745  publicationCMS->setQualityUncertain(err.c_str());
746 
747  publicationLHC->setQualityUncertain(err.c_str());
748  } else if (qlty == qualities[1]) { // Bad
749  if (updateCMS)
750  publicationCMS->setQualityBad(err.c_str());
751 
752  publicationLHC->setQualityBad(err.c_str());
753  } else if (qlty == "UNINITIALIZED") {
754  if (updateCMS)
755  publicationCMS->setQualityBad("UNINITIALIZED");
756 
757  publicationLHC->setQualityBad("UNINITIALIZED");
758  }
759  } catch (exception& e) {
760  edm::LogWarning("BeamSpotDipServer") << "exception (publishRcd): " << e.what();
761  }
762 }
763 
764 /*****************************************************************************/
765 string BeamSpotDipServer::getDateTime(time_t t) {
766  char mbstr[100];
767  strftime(mbstr, sizeof(mbstr), "%Y.%m.%d %H:%M:%S %z", std::localtime(&t));
768 
769  return mbstr;
770 }
771 
772 //
774  time_t t = time(nullptr);
775 
776  return getDateTime(t);
777 }
778 
const int rad2urad
float dydz
float width_x
float err_dydz
vector< string > parse(string line, const string &delimiter)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const string subjectLHC
void CMS2LHCRF_POS(float x, float y, float z)
string getDateTime(time_t t)
bool testing
int runnum
std::string getDateTime()
def create(alignables, pedeDump, additionalData, outputFile, config)
void dqmEndRun(const edm::Run &, const edm::EventSetup &iSetup) override
float dxdz
float width_y
bool verbose
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const int cm2mm
bool readRcd(const BeamSpotOnlineObjects &bs)
std::string to_string(const V &value)
Definition: OMSAccess.h:71
DipPublication * publicationPV
void handleException(DipPublication *publication, DipException &e) override
void publishRcd(string qlty, string err, bool pubCMS, bool fitTime)
Log< level::Error, false > LogError
float rmsPV
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
long getFileSize(string filename)
string tkStatus()
void trueRcd()
void dqmEndLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &) override
T getUntrackedParameter(std::string const &, T const &) const
const int intLS
DipData * messageCMS
void publishRcd(std::string qlty, std::string err, bool pubCMS, bool fitTime)
bool readRcd(ifstream &file)
string startTime
int iEvent
Definition: GenABIO.cc:224
long lastFitTime
const string subjectCMS
long getFileSize(std::string filename)
DipPublication * publicationCMS
BeamSpotDipServer(const edm::ParameterSet &)
T sqrt(T t)
Definition: SSEVec.h:19
const bool publishStatErrors
long lastModTime
float err_x
void analyze(const edm::Event &e, const edm::EventSetup &) override
time_t startTimeStamp
int lsCount
float err_rmsPV
time_t getLastTime(string filename)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
const int timeoutLS[2]
float err_z
const string subjectPV
const char * qualities[3]
std::vector< std::string > parse(std::string line, const std::string &delimiter)
float Centroid[3]
string sourceFile1
Log< level::Info, false > LogInfo
DipData * messageLHC
DipPublication * publicationLHC
float Tilt[2]
time_t endTimeStamp
time_t getLastTime(std::string filename)
float err_width_x
void dqmBeginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &) override
DipData * messagePV
DipFactory * dip
float err_dxdz
float sigma_z
const int cm2um
string sourceFile
void fakeRcd()
void dqmBeginRun(const edm::Run &r, const edm::EventSetup &) override
float Size[3]
float err_meanPV
string lumiRange
std::bitset< 8 > alive
void problem()
float err_y
Log< level::Warning, false > LogWarning
float err_sigma_z
string quality
tmp
align.sh
Definition: createJobs.py:716
LuminosityBlockNumber_t luminosityBlock() const
int currentLS
float err_width_y
void bookHistograms(DQMStore::IBooker &, const edm::Run &, const edm::EventSetup &) override
void CMS2LHCRF_POS(float x, float y, float z)
int events
Definition: Run.h:45
string endTime
float meanPV
std::string tkStatus()