CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
dqmservices::DQMMonitoringService Class Reference

#include <DQMMonitoringService.h>

Public Member Functions

void connect ()
 
 DQMMonitoringService (const edm::ParameterSet &, edm::ActivityRegistry &)
 
void evEvent (StreamID const &)
 
void evLumi (GlobalContext const &)
 
void keepAlive ()
 
void outputLumiUpdate ()
 
void outputUpdate (ptree &doc)
 
void tryUpdate ()
 
 ~DQMMonitoringService ()
 

Private Attributes

unsigned long last_lumi_
 
long last_lumi_nevents_
 
std::chrono::high_resolution_clock::time_point last_lumi_time_
 
std::chrono::high_resolution_clock::time_point last_update_time_
 
unsigned long lumi_
 
boost::asio::local::stream_protocol::iostream mstream_
 
long nevents_
 
unsigned long run_
 

Detailed Description

Definition at line 44 of file DQMMonitoringService.h.

Constructor & Destructor Documentation

dqmservices::DQMMonitoringService::DQMMonitoringService ( const edm::ParameterSet pset,
edm::ActivityRegistry ar 
)

Definition at line 17 of file DQMMonitoringService.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, evEvent(), evLumi(), last_lumi_, last_lumi_nevents_, last_lumi_time_, lumi_, mstream_, nevents_, fileCollector::now, run_, edm::ActivityRegistry::watchPreGlobalBeginLumi(), edm::ActivityRegistry::watchPreSourceEvent(), and x().

17  {
18  const char* x = getenv("DQM2_SOCKET");
19  if (x) {
20  std::cerr << "Monitoring pipe: " << x << std::endl;
21  mstream_.connect(boost::asio::local::stream_protocol::endpoint(x));
22  } else {
23  std::cerr << "Monitoring file not found, disabling." << std::endl;
24  }
25 
26  // init counters
27  nevents_ = 0;
28 
29  last_lumi_ = 0;
32 
33  run_ = 0;
34  lumi_ = 0;
35 
38 }
void watchPreGlobalBeginLumi(PreGlobalBeginLumi::slot_type const &iSlot)
boost::asio::local::stream_protocol::iostream mstream_
std::chrono::high_resolution_clock::time_point last_lumi_time_
void watchPreSourceEvent(PreSourceEvent::slot_type const &iSlot)
void evLumi(GlobalContext const &)
dqmservices::DQMMonitoringService::~DQMMonitoringService ( )

Definition at line 40 of file DQMMonitoringService.cc.

40  {
41 }

Member Function Documentation

void dqmservices::DQMMonitoringService::connect ( )

Referenced by Vispa.Gui.ZoomableScrollArea.ZoomableScrollArea::__init__(), Vispa.Views.PropertyView.BooleanProperty::__init__(), Vispa.Gui.FindDialog.FindDialog::_addScript(), Vispa.Gui.FindDialog.FindDialog::_addStringProperty(), Vispa.Main.Application.Application::_connectSignals(), Vispa.Plugins.ConfigEditor.CodeTableView.CodeTableView::_createItem(), Vispa.Gui.BoxContentDialog.BoxContentDialog::addButton(), Vispa.Gui.ToolBoxContainer.ToolBoxContainer::addWidget(), Vispa.Views.PropertyView.PropertyView::append(), Vispa.Views.PropertyView.PropertyView::appendAddRow(), Vispa.Main.Application.Application::createAction(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createButton(), Vispa.Views.LineDecayView.LineDecayView::createLineDecayContainer(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createLineEdit(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.PropertyView.TextEditWithButtonProperty::createTextEdit(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filterDialog(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Gui.PortWidget.PortWidget::mouseMoveEvent(), Vispa.Views.PropertyView.BooleanProperty::setChecked(), Vispa.Main.SplitterTab.SplitterTab::setController(), Vispa.Plugins.Browser.BrowserTab.BrowserTab::setController(), Vispa.Views.PropertyView.BooleanProperty::setReadOnly(), Vispa.Views.PropertyView.DropDownProperty::setReadOnly(), Vispa.Views.PropertyView.TextEditWithButtonProperty::setReadOnly(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setTab(), Vispa.Views.PropertyView.IntegerProperty::setValue(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView(), Vispa.Plugins.EdmBrowser.EdmBrowserTabController.EdmBrowserTabController::updateViewMenu(), and Vispa.Plugins.ConfigEditor.ConfigEditorTabController.ConfigEditorTabController::updateViewMenu().

void dqmservices::DQMMonitoringService::evEvent ( StreamID const &  iContext)

Definition at line 101 of file DQMMonitoringService.cc.

References nevents_, and tryUpdate().

Referenced by DQMMonitoringService().

void dqmservices::DQMMonitoringService::evLumi ( GlobalContext const &  iContext)

Definition at line 85 of file DQMMonitoringService.cc.

References last_lumi_, last_lumi_nevents_, last_lumi_time_, lumi_, edm::LuminosityBlockID::luminosityBlock(), edm::GlobalContext::luminosityBlockID(), nevents_, fileCollector::now, outputLumiUpdate(), edm::LuminosityBlockID::run(), and run_.

Referenced by DQMMonitoringService().

85  {
86  using std::chrono::duration_cast;
87  using std::chrono::milliseconds;
88 
89  // these might be different than the numbers we want to report
90  // rate/stats per lumi are calculated from last_*_ fields
91  run_ = iContext.luminosityBlockID().run();
92  lumi_ = iContext.luminosityBlockID().luminosityBlock();
93 
95 
98  last_lumi_ = lumi_;
99 }
std::chrono::high_resolution_clock::time_point last_lumi_time_
void dqmservices::DQMMonitoringService::keepAlive ( )

Definition at line 124 of file DQMMonitoringService.cc.

References mstream_, and tryUpdate().

124  {
125  if (!mstream_)
126  return;
127 
128  mstream_ << "\n";
129  mstream_.flush();
130 
131  tryUpdate();
132 }
boost::asio::local::stream_protocol::iostream mstream_
void dqmservices::DQMMonitoringService::outputLumiUpdate ( )

Definition at line 43 of file DQMMonitoringService.cc.

References prof2calltree::count, cmsPerfStripChart::format, last_lumi_, last_lumi_nevents_, last_lumi_time_, lumi_, nevents_, fileCollector::now, NULL, outputUpdate(), RPCpg::rate(), run_, and cond::rpcobgas::time.

Referenced by evLumi(), and tryUpdate().

43  {
44  using std::chrono::duration_cast;
45  using std::chrono::milliseconds;
46 
48 
49  ptree doc;
50 
51  // these might be different than the numbers we want to report
52  // rate/stats per lumi are calculated from last_*_ fields
53  doc.put("cmssw_run", run_);
54  doc.put("cmssw_lumi", lumi_);
55  doc.put("events_total", nevents_);
56 
57  // do statistics for the last (elapsed) ls
58  auto lumi_millis = duration_cast<milliseconds>(now - last_lumi_time_).count();
59  auto lumi_events = nevents_ - last_lumi_nevents_;
60  auto lumi_last = last_lumi_;
61 
62  if ((lumi_last > 0) && (lumi_millis > 0)) {
63  doc.put("lumi_number", lumi_last);
64  doc.put("lumi_events", lumi_events);
65  doc.put("lumi_duration_ms", lumi_millis);
66 
67  float rate = ((float)lumi_events * 1000) / lumi_millis;
68  doc.put("events_rate", rate);
69 
70  // also save the history entry
71  ptree plumi;
72  plumi.put("n", lumi_last);
73  plumi.put("nevents", lumi_events);
74  plumi.put("nmillis", lumi_millis);
75  plumi.put("rate", rate);
76 
77  std::time_t hkey = std::time(NULL);
78  doc.add_child(str(boost::format("extra.lumi_stats.%d") % hkey), plumi);
79  }
80 
81  outputUpdate(doc);
82 
83 }
#define NULL
Definition: scimark2.h:8
string format
Some error handling for the usage.
std::chrono::high_resolution_clock::time_point last_lumi_time_
double rate(double x)
Definition: Constants.cc:3
void dqmservices::DQMMonitoringService::outputUpdate ( ptree &  doc)

Definition at line 106 of file DQMMonitoringService.cc.

References last_update_time_, mstream_, fileCollector::now, NULL, and cond::rpcobgas::time.

Referenced by outputLumiUpdate().

106  {
107  using std::chrono::duration_cast;
108  using std::chrono::milliseconds;
109 
110  if (!mstream_)
111  return;
112 
113  try {
115  doc.put("update_timestamp", std::time(NULL));
116 
117  write_json(mstream_, doc, false);
118  mstream_.flush();
119  } catch (...) {
120  // pass
121  }
122 }
#define NULL
Definition: scimark2.h:8
boost::asio::local::stream_protocol::iostream mstream_
std::chrono::high_resolution_clock::time_point last_update_time_
void dqmservices::DQMMonitoringService::tryUpdate ( )

Definition at line 134 of file DQMMonitoringService.cc.

References prof2calltree::count, last_update_time_, mstream_, fileCollector::now, and outputLumiUpdate().

Referenced by evEvent(), and keepAlive().

134  {
135  using std::chrono::duration_cast;
136  using std::chrono::milliseconds;
137 
138  if (!mstream_)
139  return;
140 
141  // sometimes we don't see any transition for a very long time
142  // but we still want updates
143  // luckily, keepAlive is called rather often by the input source
145  auto millis = duration_cast<milliseconds>(now - last_update_time_).count();
146  if (millis >= (25*1000)) {
148  }
149 }
boost::asio::local::stream_protocol::iostream mstream_
std::chrono::high_resolution_clock::time_point last_update_time_

Member Data Documentation

unsigned long dqmservices::DQMMonitoringService::last_lumi_
private

Definition at line 67 of file DQMMonitoringService.h.

Referenced by DQMMonitoringService(), evLumi(), and outputLumiUpdate().

long dqmservices::DQMMonitoringService::last_lumi_nevents_
private

Definition at line 70 of file DQMMonitoringService.h.

Referenced by DQMMonitoringService(), evLumi(), and outputLumiUpdate().

std::chrono::high_resolution_clock::time_point dqmservices::DQMMonitoringService::last_lumi_time_
private

Definition at line 68 of file DQMMonitoringService.h.

Referenced by DQMMonitoringService(), evLumi(), and outputLumiUpdate().

std::chrono::high_resolution_clock::time_point dqmservices::DQMMonitoringService::last_update_time_
private

Definition at line 69 of file DQMMonitoringService.h.

Referenced by outputUpdate(), and tryUpdate().

unsigned long dqmservices::DQMMonitoringService::lumi_
private

Definition at line 73 of file DQMMonitoringService.h.

Referenced by DQMMonitoringService(), evLumi(), and outputLumiUpdate().

boost::asio::local::stream_protocol::iostream dqmservices::DQMMonitoringService::mstream_
private

Definition at line 61 of file DQMMonitoringService.h.

Referenced by DQMMonitoringService(), keepAlive(), outputUpdate(), and tryUpdate().

long dqmservices::DQMMonitoringService::nevents_
private

Definition at line 64 of file DQMMonitoringService.h.

Referenced by DQMMonitoringService(), evEvent(), evLumi(), and outputLumiUpdate().

unsigned long dqmservices::DQMMonitoringService::run_
private

Definition at line 72 of file DQMMonitoringService.h.

Referenced by DQMMonitoringService(), evLumi(), and outputLumiUpdate().