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
if
(
count
< 30) {
55
// we don't want to report too often
56
return
;
57
}
58
59
ptree
doc
;
60
doc.put(
"events_total"
,
nevents_
);
61
62
if
(
count
> 0) {
63
float
rate
= (
nevents_
-
last_report_nevents_
) /
count
;
64
doc.put(
"events_rate"
, rate);
65
}
66
67
last_report_time_
=
now
;
68
last_report_nevents_
=
nevents_
;
69
70
outputUpdate
(doc);
71
}
72
73
void
DQMMonitoringService::outputUpdate
(ptree&
doc
) {
74
if
(!
mstream_
)
75
return
;
76
77
try
{
78
doc.put(
"update_timestamp"
,
std::time
(
NULL
));
79
80
write_json(*
mstream_
, doc,
false
);
81
mstream_
->flush();
82
}
catch
(...) {
83
// pass
84
}
85
}
86
87
void
DQMMonitoringService::keepAlive
() {
88
if
(!
mstream_
)
89
return
;
90
91
*
mstream_
<<
"\n"
;
92
mstream_
->flush();
93
}
94
95
96
}
// end-of-namespace
97
98
#include "
FWCore/ServiceRegistry/interface/ServiceMaker.h
"
99
100
using
dqmservices::DQMMonitoringService
;
101
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:87
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:317
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:41
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:42
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:150
x
Definition:
DDAxes.h:10
dqmservices::DQMMonitoringService::nevents_
long nevents_
Definition:
DQMMonitoringService.h:59
edm::ActivityRegistry
Definition:
ActivityRegistry.h:88
dqmservices::DQMMonitoringService::evLumi
void evLumi(GlobalContext const &)
Definition:
DQMMonitoringService.cc:35
dqmservices::DQMMonitoringService::outputUpdate
void outputUpdate(ptree &doc)
Definition:
DQMMonitoringService.cc:73
dqmservices::DQMMonitoringService::mstream_
std::shared_ptr< std::ostream > mstream_
Definition:
DQMMonitoringService.h:56
Generated for CMSSW Reference Manual by
1.8.5