Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
DQMServices
StreamerIO
plugins
DQMMonitoringService.cc
Go to the documentation of this file.
1
#include "
DQMMonitoringService.h
"
2
3
#include <boost/algorithm/string.hpp>
4
5
#include <ctime>
6
7
/*
8
* This service is very similar to the FastMonitoringService in the HLT,
9
* except that it is used for monitoring online DQM applications
10
*/
11
12
namespace
dqmservices {
13
14
DQMMonitoringService::DQMMonitoringService
(
const
edm::ParameterSet
&pset,
edm::ActivityRegistry
& ar) {
15
const
char
*
x
= getenv(
"DQMMON_UPDATE_PIPE"
);
16
17
if
(x) {
18
std::cerr
<<
"Monitoring pipe: "
<< x << std::endl;
19
mstream_
.reset(
new
std::ofstream(x));
20
}
else
{
21
std::cerr
<<
"Monitoring file not found, disabling."
<< std::endl;
22
}
23
24
nevents_
= 0;
25
last_report_nevents_
= 0;
26
last_report_time_
=
std::chrono::high_resolution_clock::now
();
27
28
ar.
watchPreGlobalBeginLumi
(
this
, &
DQMMonitoringService::evLumi
);
29
ar.
watchPreSourceEvent
(
this
, &
DQMMonitoringService::evEvent
);
30
}
31
32
DQMMonitoringService::~DQMMonitoringService
() {
33
}
34
35
void
DQMMonitoringService::evLumi
(
GlobalContext
const
& iContext) {
36
unsigned
int
run
= iContext.
luminosityBlockID
().
run
();
37
unsigned
int
lumi
= iContext.
luminosityBlockID
().
luminosityBlock
();
38
39
ptree
doc
;
40
doc.put(
"cmssw_run"
, run);
41
doc.put(
"cmssw_lumi"
, lumi);
42
outputUpdate
(doc);
43
}
44
45
void
DQMMonitoringService::evEvent
(
StreamID
const
& iContext) {
46
nevents_
+= 1;
47
48
using
std::chrono::duration_cast;
49
using
std::chrono::seconds
;
50
51
auto
now
=
std::chrono::high_resolution_clock::now
();
52
auto
count
= duration_cast<
seconds
>(
now
-
last_report_time_
).
count
();
53
54
ptree
doc
;
55
doc.put(
"events_total"
,
nevents_
);
56
57
if
(
count
> 0) {
58
float
rate
= (
nevents_
-
last_report_nevents_
) /
count
;
59
doc.put(
"events_rate"
, rate);
60
}
61
62
last_report_time_
=
now
;
63
last_report_nevents_
=
nevents_
;
64
65
outputUpdate
(doc);
66
}
67
68
void
DQMMonitoringService::outputUpdate
(ptree&
doc
) {
69
if
(!
mstream_
)
70
return
;
71
72
try
{
73
doc.put(
"update_timestamp"
,
std::time
(
NULL
));
74
75
write_json(*
mstream_
, doc,
false
);
76
mstream_
->flush();
77
}
catch
(...) {
78
// pass
79
}
80
}
81
82
void
DQMMonitoringService::keepAlive
() {
83
if
(!
mstream_
)
84
return
;
85
86
*
mstream_
<<
"\n"
;
87
mstream_
->flush();
88
}
89
90
91
}
// end-of-namespace
92
93
#include "
FWCore/ServiceRegistry/interface/ServiceMaker.h
"
94
95
using
dqmservices::DQMMonitoringService
;
96
DEFINE_FWK_SERVICE
(
DQMMonitoringService
);
prof2calltree.count
list count
Definition:
prof2calltree.py:146
DQMMonitoringService.h
seconds
double seconds()
edm::GlobalContext
Definition:
GlobalContext.h:29
dqmservices::DQMMonitoringService::keepAlive
void keepAlive()
Definition:
DQMMonitoringService.cc:82
fjr2json.lumi
tuple lumi
Definition:
fjr2json.py:35
edm::StreamID
Definition:
StreamID.h:30
edm::GlobalContext::luminosityBlockID
LuminosityBlockID const & luminosityBlockID() const
Definition:
GlobalContext.h:52
edm::ActivityRegistry::watchPreGlobalBeginLumi
void watchPreGlobalBeginLumi(PreGlobalBeginLumi::slot_type const &iSlot)
Definition:
ActivityRegistry.h:297
NULL
#define NULL
Definition:
scimark2.h:8
ServiceMaker.h
dqmservices::DQMMonitoringService
Definition:
DQMMonitoringService.h:42
fileCollector.now
tuple now
Definition:
fileCollector.py:205
cond::rpcobgas::time
Definition:
RPCObGasPyWrapper.cc:61
edm::LuminosityBlockID::run
RunNumber_t run() const
Definition:
LuminosityBlockID.h:42
asciidump.doc
tuple doc
Definition:
asciidump.py:381
dqmservices::DQMMonitoringService::last_report_nevents_
long last_report_nevents_
Definition:
DQMMonitoringService.h:60
dqmservices::DQMMonitoringService::evEvent
void evEvent(StreamID const &)
Definition:
DQMMonitoringService.cc:45
dqmservices::DQMMonitoringService::~DQMMonitoringService
~DQMMonitoringService()
Definition:
DQMMonitoringService.cc:32
DTTTrigCorrFirst.run
run
Definition:
DTTTrigCorrFirst.py:63
DEFINE_FWK_SERVICE
#define DEFINE_FWK_SERVICE(type)
Definition:
ServiceMaker.h:113
dqmservices::DQMMonitoringService::last_report_time_
std::chrono::high_resolution_clock::time_point last_report_time_
Definition:
DQMMonitoringService.h:61
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition:
LuminosityBlockID.h:43
dtNoiseDBValidation_cfg.cerr
tuple cerr
Definition:
dtNoiseDBValidation_cfg.py:22
RPCpg::rate
double rate(double x)
Definition:
Constants.cc:3
dqmservices::DQMMonitoringService::DQMMonitoringService
DQMMonitoringService(const edm::ParameterSet &, edm::ActivityRegistry &)
Definition:
DQMMonitoringService.cc:14
edm::ParameterSet
Definition:
ParameterSet.h:35
edm::ActivityRegistry::watchPreSourceEvent
void watchPreSourceEvent(PreSourceEvent::slot_type const &iSlot)
Definition:
ActivityRegistry.h:130
x
Definition:
DDAxes.h:10
dqmservices::DQMMonitoringService::nevents_
long nevents_
Definition:
DQMMonitoringService.h:59
edm::ActivityRegistry
Definition:
ActivityRegistry.h:87
dqmservices::DQMMonitoringService::evLumi
void evLumi(GlobalContext const &)
Definition:
DQMMonitoringService.cc:35
dqmservices::DQMMonitoringService::outputUpdate
void outputUpdate(ptree &doc)
Definition:
DQMMonitoringService.cc:68
dqmservices::DQMMonitoringService::mstream_
std::shared_ptr< std::ostream > mstream_
Definition:
DQMMonitoringService.h:56
Generated for CMSSW Reference Manual by
1.8.5