CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
DQMService Class Reference

#include <DQMService.h>

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 

Public Member Functions

 DQMService (const edm::ParameterSet &pset, edm::ActivityRegistry &ar)
 
void flush (edm::StreamContext const &sc)
 
void flushStandalone ()
 
 ~DQMService ()
 

Private Member Functions

void shutdown ()
 

Private Attributes

double lastFlush_
 
DQMBasicNetnet_
 
double publishFrequency_
 
DQMStorestore_
 

Detailed Description

A bridge to udpate the DQM network layer at the end of every event.

Definition at line 12 of file DQMService.h.

Member Typedef Documentation

◆ DQMStore

Definition at line 14 of file DQMService.h.

◆ MonitorElement

Definition at line 15 of file DQMService.h.

Constructor & Destructor Documentation

◆ DQMService()

DQMService::DQMService ( const edm::ParameterSet pset,
edm::ActivityRegistry ar 
)

Definition at line 25 of file DQMService.cc.

29 
30  std::string host = pset.getUntrackedParameter<std::string>("collectorHost", "");
31  int port = pset.getUntrackedParameter<int>("collectorPort", 9090);
32  bool verbose = pset.getUntrackedParameter<bool>("verbose", false);
33  publishFrequency_ = pset.getUntrackedParameter<double>("publishFrequency", publishFrequency_);
34 
35  if (!host.empty() && port > 0) {
36  net_ = new DQMBasicNet;
37  net_->debug(verbose);
39  net_->start();
40  }
41 }

References DQMNet::debug(), flush(), query::host, net_, query::port, muonDTDigis_cfi::pset, publishFrequency_, DQMNet::start(), AlCaHLTBitMon_QueryRunRegistry::string, DQMNet::updateToCollector(), verbose, edm::ActivityRegistry::watchPostEvent(), and edm::ActivityRegistry::watchPostStreamEndLumi().

◆ ~DQMService()

DQMService::~DQMService ( )

Definition at line 43 of file DQMService.cc.

43 { shutdown(); }

References shutdown().

Member Function Documentation

◆ flush()

void DQMService::flush ( edm::StreamContext const &  sc)

Definition at line 123 of file DQMService.cc.

123  {
124  // Call a function independent to the framework
125  flushStandalone();
126 }

References flushStandalone().

Referenced by DQMService().

◆ flushStandalone()

void DQMService::flushStandalone ( )

Definition at line 48 of file DQMService.cc.

48  {
49  // Avoid sending updates excessively often.
50  uint64_t version = lat::Time::current().ns();
51  double vtime = version * 1e-9;
52  if (vtime - lastFlush_ < publishFrequency_)
53  return;
54 
55  // OK, send an update.
56  if (net_) {
58  std::set<std::string> seen;
60 
61  // Lock the network layer so we can modify the data.
62  net_->lock();
63  bool updated = false;
64 
65  auto mes = store_->getAllContents("");
66  for (MonitorElement *me : mes) {
67  auto fullpath = me->getFullname();
68  seen.insert(fullpath);
69  if (!me->wasUpdated())
70  continue;
71 
72  o.lastreq = 0;
73  o.hash = DQMNet::dqmhash(fullpath.c_str(), fullpath.size());
74  o.flags = me->data_.flags;
75  o.version = version;
76  o.dirname = me->data_.dirname.substr(0, me->data_.dirname.size() - 1);
77  o.objname = me->data_.objname;
78  assert(o.rawdata.empty());
79  assert(o.scalar.empty());
80  assert(o.qdata.empty());
81 
82  // Pack object and reference, scalar and quality data.
83 
84  switch (me->kind()) {
88  me->packScalarData(o.scalar, "");
89  break;
90  default: {
91  TBufferFile buffer(TBufferFile::kWrite);
92  buffer.WriteObject(me->getTH1());
93  // placeholder for (no longer supported) reference
94  buffer.WriteObjectAny(nullptr, nullptr);
95  o.rawdata.resize(buffer.Length());
96  memcpy(&o.rawdata[0], buffer.Buffer(), buffer.Length());
97  DQMNet::packQualityData(o.qdata, me->data_.qreports);
98  break;
99  }
100  }
101 
103  DQMNet::DataBlob().swap(o.rawdata);
104  std::string().swap(o.scalar);
105  std::string().swap(o.qdata);
106  updated = true;
107  }
108 
109  // Find removed contents and clear the network cache.
111  updated = true;
112 
113  // Unlock the network layer.
114  net_->unlock();
115 
116  // Tell network to flush if we updated something.
117  if (updated)
119  }
120 
121  lastFlush_ = lat::Time::current().ns() * 1e-9;
122 }

References cms::cuda::assert(), edmScanValgrind::buffer, DQMNet::dqmhash(), MillePedeFileConverter_cfg::e, reco_skim_cfg_mod::fullpath, dqm::implementation::IGetter::getAllContents(), MonitorElementData::INT, lastFlush_, DQMNet::lock(), hlt_dqm_clientPB-live_cfg::me, net_, EcalTangentSkim_cfg::o, DQMNet::packQualityData(), publishFrequency_, MonitorElementData::REAL, DQMBasicNet::removeLocalExcept(), postprocess-scan-build::seen, DQMNet::sendLocalChanges(), store_, MonitorElementData::STRING, AlCaHLTBitMon_QueryRunRegistry::string, DQMNet::unlock(), DQMBasicNet::updateLocalObject(), and BeamSplash_cfg::version.

Referenced by flush().

◆ shutdown()

void DQMService::shutdown ( )
private

Definition at line 129 of file DQMService.cc.

129  {
130  // If we have a network, let it go.
131  if (net_)
132  net_->shutdown();
133 }

References net_, and DQMNet::shutdown().

Referenced by ~DQMService().

Member Data Documentation

◆ lastFlush_

double DQMService::lastFlush_
private

Definition at line 28 of file DQMService.h.

Referenced by flushStandalone().

◆ net_

DQMBasicNet* DQMService::net_
private

Definition at line 27 of file DQMService.h.

Referenced by DQMService(), flushStandalone(), and shutdown().

◆ publishFrequency_

double DQMService::publishFrequency_
private

Definition at line 29 of file DQMService.h.

Referenced by DQMService(), and flushStandalone().

◆ store_

DQMStore* DQMService::store_
private

Definition at line 26 of file DQMService.h.

Referenced by flushStandalone().

edm::ActivityRegistry::watchPostStreamEndLumi
void watchPostStreamEndLumi(PostStreamEndLumi::slot_type const &iSlot)
Definition: ActivityRegistry.h:450
DQMBasicNet::updateLocalObject
void updateLocalObject(Object &o)
Definition: DQMNet.cc:1212
MonitorElementData::Kind::INT
reco_skim_cfg_mod.fullpath
fullpath
Definition: reco_skim_cfg_mod.py:202
DQMNet::shutdown
void shutdown()
Stop the network layer and wait it to finish.
Definition: DQMNet.cc:1038
DQMNet::Object
Definition: DQMNet.h:101
DQMNet::dqmhash
static size_t dqmhash(const void *key, size_t keylen)
Definition: DQMNet.h:194
DQMService::shutdown
void shutdown()
Definition: DQMService.cc:129
DQMService::publishFrequency_
double publishFrequency_
Definition: DQMService.h:29
MonitorElementData::Kind::STRING
cms::cuda::assert
assert(be >=bs)
DQMService::flushStandalone
void flushStandalone()
Definition: DQMService.cc:48
DQMNet::unlock
void unlock()
Release the lock on the DQM net layer.
Definition: DQMNet.cc:1064
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
dqm::implementation::IGetter::getAllContents
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
Definition: DQMStore.cc:609
query.host
string host
Definition: query.py:115
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
DQMNet::packQualityData
static void packQualityData(std::string &into, const QReports &qr)
Definition: DQMNet.cc:158
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
DQMService::flush
void flush(edm::StreamContext const &sc)
Definition: DQMService.cc:123
DQMBasicNet
Definition: DQMNet.h:591
DQMService::store_
DQMStore * store_
Definition: DQMService.h:26
DQMNet::debug
void debug(bool doit)
Definition: DQMNet.cc:937
DQMService::net_
DQMBasicNet * net_
Definition: DQMService.h:27
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DQMBasicNet::removeLocalExcept
bool removeLocalExcept(const std::set< std::string > &known)
Definition: DQMNet.cc:1233
DQMNet::DataBlob
std::vector< unsigned char > DataBlob
Definition: DQMNet.h:83
edm::ActivityRegistry::watchPostEvent
void watchPostEvent(PostEvent::slot_type const &iSlot)
Definition: ActivityRegistry.h:464
DQMService::lastFlush_
double lastFlush_
Definition: DQMService.h:28
query.port
int port
Definition: query.py:116
postprocess-scan-build.seen
seen
Definition: postprocess-scan-build.py:9
edm::Service
Definition: Service.h:30
DQMNet::start
void start()
Definition: DQMNet.cc:1072
DQMNet::lock
void lock()
Acquire a lock on the DQM net layer.
Definition: DQMNet.cc:1058
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
DQMNet::sendLocalChanges
void sendLocalChanges()
Definition: DQMNet.cc:1195
DQMNet::updateToCollector
void updateToCollector(const std::string &host, int port)
Definition: DQMNet.cc:1010
MonitorElementData::Kind::REAL
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37