CMS 3D CMS Logo

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

◆ DQMMonitoringService()

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

Definition at line 18 of file DQMMonitoringService.cc.

18  {
19  const char* x = std::getenv("DQM2_SOCKET");
20  if (x) {
21  std::cerr << "Monitoring pipe: " << x << std::endl;
22  mstream_.connect(boost::asio::local::stream_protocol::endpoint(x));
23  } else {
24  std::cerr << "Monitoring file not found, disabling." << std::endl;
25  }
26 
27  // init counters
28  nevents_ = 0;
29 
30  last_lumi_ = 0;
33 
34  run_ = 0;
35  lumi_ = 0;
36 
39  }

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, evEvent(), evLumi(), last_lumi_, last_lumi_nevents_, last_lumi_time_, lumi_, mstream_, nevents_, submitPVValidationJobs::now, run_, edm::ActivityRegistry::watchPreGlobalBeginLumi(), and edm::ActivityRegistry::watchPreSourceEvent().

◆ ~DQMMonitoringService()

dqmservices::DQMMonitoringService::~DQMMonitoringService ( )

Definition at line 41 of file DQMMonitoringService.cc.

41 {}

Member Function Documentation

◆ connect()

void dqmservices::DQMMonitoringService::connect ( )

◆ evEvent()

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

Definition at line 100 of file DQMMonitoringService.cc.

100  {
101  nevents_ += 1;
102  tryUpdate();
103  }

References nevents_, and tryUpdate().

Referenced by DQMMonitoringService().

◆ evLumi()

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

Definition at line 84 of file DQMMonitoringService.cc.

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

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

Referenced by DQMMonitoringService().

◆ keepAlive()

void dqmservices::DQMMonitoringService::keepAlive ( )

Definition at line 123 of file DQMMonitoringService.cc.

123  {
124  if (!mstream_)
125  return;
126 
127  mstream_ << "\n";
128  mstream_.flush();
129 
130  tryUpdate();
131  }

References mstream_, and tryUpdate().

◆ outputLumiUpdate()

void dqmservices::DQMMonitoringService::outputLumiUpdate ( )

Definition at line 43 of file DQMMonitoringService.cc.

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(nullptr);
78  doc.add_child(fmt::sprintf("extra.lumi_stats.%d", hkey), plumi);
79  }
80 
82  }

References common_cff::doc, dqmMemoryStats::float, last_lumi_, last_lumi_nevents_, last_lumi_time_, lumi_, nevents_, submitPVValidationJobs::now, outputUpdate(), RPCpg::rate(), run_, and protons_cff::time.

Referenced by evLumi(), and tryUpdate().

◆ outputUpdate()

void dqmservices::DQMMonitoringService::outputUpdate ( ptree &  doc)

Definition at line 105 of file DQMMonitoringService.cc.

105  {
106  using std::chrono::duration_cast;
107  using std::chrono::milliseconds;
108 
109  if (!mstream_)
110  return;
111 
112  try {
114  doc.put("update_timestamp", std::time(nullptr));
115 
116  write_json(mstream_, doc, false);
117  mstream_.flush();
118  } catch (...) {
119  // pass
120  }
121  }

References common_cff::doc, last_update_time_, mstream_, submitPVValidationJobs::now, and protons_cff::time.

Referenced by outputLumiUpdate().

◆ tryUpdate()

void dqmservices::DQMMonitoringService::tryUpdate ( )

Definition at line 133 of file DQMMonitoringService.cc.

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

References last_update_time_, mstream_, submitPVValidationJobs::now, and outputLumiUpdate().

Referenced by evEvent(), and keepAlive().

Member Data Documentation

◆ last_lumi_

unsigned long dqmservices::DQMMonitoringService::last_lumi_
private

Definition at line 68 of file DQMMonitoringService.h.

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

◆ last_lumi_nevents_

long dqmservices::DQMMonitoringService::last_lumi_nevents_
private

Definition at line 72 of file DQMMonitoringService.h.

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

◆ last_lumi_time_

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

Definition at line 70 of file DQMMonitoringService.h.

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

◆ last_update_time_

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

Definition at line 71 of file DQMMonitoringService.h.

Referenced by outputUpdate(), and tryUpdate().

◆ lumi_

unsigned long dqmservices::DQMMonitoringService::lumi_
private

Definition at line 75 of file DQMMonitoringService.h.

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

◆ mstream_

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().

◆ nevents_

long dqmservices::DQMMonitoringService::nevents_
private

Definition at line 64 of file DQMMonitoringService.h.

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

◆ run_

unsigned long dqmservices::DQMMonitoringService::run_
private

Definition at line 74 of file DQMMonitoringService.h.

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

dqmservices::DQMMonitoringService::outputUpdate
void outputUpdate(ptree &doc)
Definition: DQMMonitoringService.cc:105
common_cff.doc
doc
Definition: common_cff.py:54
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
dqmservices::DQMMonitoringService::last_lumi_
unsigned long last_lumi_
Definition: DQMMonitoringService.h:68
submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
protons_cff.time
time
Definition: protons_cff.py:39
dqmservices::DQMMonitoringService::lumi_
unsigned long lumi_
Definition: DQMMonitoringService.h:75
DDAxes::x
RPCpg::rate
double rate(double x)
Definition: Constants.cc:3
dqmservices::DQMMonitoringService::last_lumi_nevents_
long last_lumi_nevents_
Definition: DQMMonitoringService.h:72
dqmservices::DQMMonitoringService::run_
unsigned long run_
Definition: DQMMonitoringService.h:74
dqmservices::DQMMonitoringService::outputLumiUpdate
void outputLumiUpdate()
Definition: DQMMonitoringService.cc:43
dqmservices::DQMMonitoringService::evEvent
void evEvent(StreamID const &)
Definition: DQMMonitoringService.cc:100
dqmservices::DQMMonitoringService::mstream_
boost::asio::local::stream_protocol::iostream mstream_
Definition: DQMMonitoringService.h:61
edm::ActivityRegistry::watchPreGlobalBeginLumi
void watchPreGlobalBeginLumi(PreGlobalBeginLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:391
dqmservices::DQMMonitoringService::last_lumi_time_
std::chrono::high_resolution_clock::time_point last_lumi_time_
Definition: DQMMonitoringService.h:70
edm::ActivityRegistry::watchPreSourceEvent
void watchPreSourceEvent(PreSourceEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:184
dqmservices::DQMMonitoringService::nevents_
long nevents_
Definition: DQMMonitoringService.h:64
dqmservices::DQMMonitoringService::evLumi
void evLumi(GlobalContext const &)
Definition: DQMMonitoringService.cc:84
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
dqmservices::DQMMonitoringService::last_update_time_
std::chrono::high_resolution_clock::time_point last_update_time_
Definition: DQMMonitoringService.h:71
dqmservices::DQMMonitoringService::tryUpdate
void tryUpdate()
Definition: DQMMonitoringService.cc:133