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

lat::Regexp * filter_
 
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 15 of file DQMService.h.

Member Typedef Documentation

Definition at line 17 of file DQMService.h.

Definition at line 18 of file DQMService.h.

Constructor & Destructor Documentation

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

Definition at line 27 of file DQMService.cc.

References DQMNet::debug(), MillePedeFileConverter_cfg::e, Exception, ALCARECOTkAlBeamHalo_cff::filter, filter_, flush(), edm::ParameterSet::getUntrackedParameter(), query::host, net_, query::port, publishFrequency_, DQMNet::start(), AlCaHLTBitMon_QueryRunRegistry::string, DQMNet::updateToCollector(), edm::ActivityRegistry::watchPostEvent(), and edm::ActivityRegistry::watchPostStreamEndLumi().

28  : store_(&*edm::Service<DQMStore>()), net_(nullptr), filter_(nullptr), lastFlush_(0), publishFrequency_(5.0) {
31 
32  std::string host = pset.getUntrackedParameter<std::string>("collectorHost", "");
33  int port = pset.getUntrackedParameter<int>("collectorPort", 9090);
34  bool verbose = pset.getUntrackedParameter<bool>("verbose", false);
35  publishFrequency_ = pset.getUntrackedParameter<double>("publishFrequency", publishFrequency_);
37 
38  if (!host.empty() && port > 0) {
39  net_ = new DQMBasicNet;
40  net_->debug(verbose);
41  net_->updateToCollector(host, port);
42  net_->start();
43  }
44 
45  if (!filter.empty()) {
46  try {
47  filter_ = new lat::Regexp(filter);
48  if (!filter_->valid())
49  throw cms::Exception("DQMService") << "Invalid 'filter' parameter value '" << filter << "':"
50  << " bad regular expression syntax at character " << filter_->errorOffset()
51  << ": " << filter_->errorMessage();
52  filter_->study();
53  } catch (lat::Error &e) {
54  throw cms::Exception("DQMService") << "Invalid regular expression 'filter' parameter value '" << filter
55  << "': " << e.explain();
56  }
57  }
58 }
edm::ErrorSummaryEntry Error
T getUntrackedParameter(std::string const &, T const &) const
host
Definition: query.py:115
DQMBasicNet * net_
Definition: DQMService.h:30
double publishFrequency_
Definition: DQMService.h:33
void watchPostEvent(PostEvent::slot_type const &iSlot)
double lastFlush_
Definition: DQMService.h:32
void watchPostStreamEndLumi(PostStreamEndLumi::slot_type const &iSlot)
lat::Regexp * filter_
Definition: DQMService.h:31
port
Definition: query.py:116
void debug(bool doit)
Definition: DQMNet.cc:928
DQMStore * store_
Definition: DQMService.h:29
void start()
Definition: DQMNet.cc:1068
void flush(edm::StreamContext const &sc)
Definition: DQMService.cc:156
void updateToCollector(const std::string &host, int port)
Definition: DQMNet.cc:1006
DQMService::~DQMService ( )

Definition at line 60 of file DQMService.cc.

References shutdown().

60 { shutdown(); }
void shutdown()
Definition: DQMService.cc:162

Member Function Documentation

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

Definition at line 156 of file DQMService.cc.

References flushStandalone().

Referenced by DQMService().

156  {
157  // Call a function independent to the framework
158  flushStandalone();
159 }
void flushStandalone()
Definition: DQMService.cc:65
void DQMService::flushStandalone ( )

Definition at line 65 of file DQMService.cc.

References edmScanValgrind::buffer, dqm::impl::MonitorElement::data_, dqm::dqmstoreimpl::DQMStore::data_, DQMNet::CoreObject::dirname, DQMNet::dqmhash(), MillePedeFileConverter_cfg::e, filter_, DQMNet::CoreObject::flags, reco_skim_cfg_mod::fullpath, dqm::legacy::MonitorElement::getRootObject(), DQMNet::Object::hash, mps_fire::i, MonitorElementData::INT, dqm::impl::MonitorElement::kind(), lastFlush_, DQMNet::Object::lastreq, DQMNet::lock(), hlt_dqm_clientPB-live_cfg::me, net_, EcalTangentSkim_cfg::o, DQMNet::CoreObject::objname, DQMNet::packQualityData(), dqm::impl::MonitorElement::packScalarData(), publishFrequency_, DQMNet::Object::qdata, DQMNet::CoreObject::qreports, DQMNet::Object::rawdata, MonitorElementData::REAL, dqm::impl::MonitorElement::reference_, DQMBasicNet::removeLocalExcept(), DQMBasicNet::reserveLocalSpace(), dqm::dqmstoreimpl::DQMStore::reset(), DQMNet::Object::scalar, postprocess-scan-build::seen, DQMNet::sendLocalChanges(), store_, MonitorElementData::STRING, AlCaHLTBitMon_QueryRunRegistry::string, DQMNet::CoreObject::tag, DQMNet::unlock(), DQMBasicNet::updateLocalObject(), BeamSplash_cfg::version, DQMNet::CoreObject::version, and dqm::impl::MonitorElement::wasUpdated().

Referenced by flush().

65  {
66  // Avoid sending updates excessively often.
67  uint64_t version = lat::Time::current().ns();
68  double vtime = version * 1e-9;
69  if (vtime - lastFlush_ < publishFrequency_)
70  return;
71 
72  // OK, send an update.
73  if (net_) {
75  std::set<std::string> seen;
77 
78  // Lock the network layer so we can modify the data.
79  net_->lock();
80  bool updated = false;
81 
82  // Find updated contents and update the network cache.
83  DQMStore::MEMap::iterator i, e;
85  for (i = store_->data_.begin(), e = store_->data_.end(); i != e; ++i) {
86  const MonitorElement &me = *i;
87  fullpath.clear();
88  fullpath += *me.data_.dirname;
89  if (!me.data_.dirname->empty())
90  fullpath += '/';
91  fullpath += me.data_.objname;
92 
93  if (filter_ && filter_->search(fullpath) < 0)
94  continue;
95 
96  seen.insert(fullpath);
97  if (!me.wasUpdated())
98  continue;
99 
100  o.lastreq = 0;
101  o.hash = DQMNet::dqmhash(fullpath.c_str(), fullpath.size());
102  o.flags = me.data_.flags;
103  o.tag = me.data_.tag;
104  o.version = version;
105  o.dirname = me.data_.dirname;
106  o.objname = me.data_.objname;
107  assert(o.rawdata.empty());
108  assert(o.scalar.empty());
109  assert(o.qdata.empty());
110 
111  // Pack object and reference, scalar and quality data.
112  switch (me.kind()) {
116  me.packScalarData(o.scalar, "");
117  break;
118 
119  default: {
120  TBufferFile buffer(TBufferFile::kWrite);
121  buffer.WriteObject(me.getRootObject());
122  if (me.reference_)
123  buffer.WriteObject(me.reference_);
124  else
125  buffer.WriteObjectAny(nullptr, nullptr);
126  o.rawdata.resize(buffer.Length());
127  memcpy(&o.rawdata[0], buffer.Buffer(), buffer.Length());
129  break;
130  }
131  }
132 
133  // Update.
135  DQMNet::DataBlob().swap(o.rawdata);
136  std::string().swap(o.scalar);
137  std::string().swap(o.qdata);
138  updated = true;
139  }
140 
141  // Find removed contents and clear the network cache.
142  if (net_->removeLocalExcept(seen))
143  updated = true;
144 
145  // Unlock the network layer.
146  net_->unlock();
147 
148  // Tell network to flush if we updated something.
149  if (updated)
151  }
152 
153  store_->reset();
154  lastFlush_ = lat::Time::current().ns() * 1e-9;
155 }
QReports qreports
Definition: DQMNet.h:103
DQMBasicNet * net_
Definition: DQMService.h:30
uint64_t version
Definition: DQMNet.h:96
void lock()
Acquire a lock on the DQM net layer.
Definition: DQMNet.cc:1054
DQMNet::CoreObject data_
double publishFrequency_
Definition: DQMService.h:33
uint32_t flags
Definition: DQMNet.h:94
double lastFlush_
Definition: DQMService.h:32
Kind kind() const
Get the type of the monitor element.
lat::Regexp * filter_
Definition: DQMService.h:31
uint32_t tag
Definition: DQMNet.h:95
const std::string * dirname
Definition: DQMNet.h:101
std::string qdata
Definition: DQMNet.h:111
uint64_t lastreq
Definition: DQMNet.h:108
DQMStore * store_
Definition: DQMService.h:29
void sendLocalChanges()
Definition: DQMNet.cc:1191
static size_t dqmhash(const void *key, size_t keylen)
Definition: DQMNet.h:199
std::string objname
Definition: DQMNet.h:102
std::string scalar
Definition: DQMNet.h:110
void packScalarData(std::string &into, const char *prefix) const
convert scalar data into a string.
unsigned long long uint64_t
Definition: Time.h:13
bool removeLocalExcept(const std::set< std::string > &known)
Definition: DQMNet.cc:1229
uint64_t hash
Definition: DQMNet.h:107
static void packQualityData(std::string &into, const QReports &qr)
Definition: DQMNet.cc:149
bool wasUpdated() const
true if ME was updated in last monitoring cycle
void unlock()
Release the lock on the DQM net layer.
Definition: DQMNet.cc:1060
TObject * getRootObject() const override
void updateLocalObject(Object &o)
Definition: DQMNet.cc:1208
void reserveLocalSpace(uint32_t size)
Give a hint of how much capacity to allocate for local objects.
Definition: DQMNet.cc:1204
std::vector< unsigned char > DataBlob
Definition: DQMNet.h:80
DataBlob rawdata
Definition: DQMNet.h:109
void DQMService::shutdown ( )
private

Definition at line 162 of file DQMService.cc.

References net_, and DQMNet::shutdown().

Referenced by ~DQMService().

162  {
163  // If we have a network, let it go.
164  if (net_)
165  net_->shutdown();
166 }
DQMBasicNet * net_
Definition: DQMService.h:30
void shutdown()
Stop the network layer and wait it to finish.
Definition: DQMNet.cc:1034

Member Data Documentation

lat::Regexp* DQMService::filter_
private

Definition at line 31 of file DQMService.h.

Referenced by DQMService(), and flushStandalone().

double DQMService::lastFlush_
private

Definition at line 32 of file DQMService.h.

Referenced by flushStandalone().

DQMBasicNet* DQMService::net_
private

Definition at line 30 of file DQMService.h.

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

double DQMService::publishFrequency_
private

Definition at line 33 of file DQMService.h.

Referenced by DQMService(), and flushStandalone().

DQMStore* DQMService::store_
private

Definition at line 29 of file DQMService.h.

Referenced by flushStandalone().