CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
DQMService Class Reference

#include <DQMService.h>

Public Member Functions

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

Private Member Functions

void shutdown (void)
 

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 13 of file DQMService.h.

Constructor & Destructor Documentation

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

Definition at line 29 of file DQMService.cc.

References alignCSCRings::e, edm::hlt::Exception, alcazmumu_cfi::filter, filter_, flush(), edm::ParameterSet::getUntrackedParameter(), query::host, query::port, publishFrequency_, AlCaHLTBitMon_QueryRunRegistry::string, and edm::ActivityRegistry::watchPostEvent().

31  net_(0),
32  filter_(0),
33  lastFlush_(0),
35 {
37 
38  std::string host = pset.getUntrackedParameter<std::string>("collectorHost", "");
39  int port = pset.getUntrackedParameter<int>("collectorPort", 9090);
40  bool verbose = pset.getUntrackedParameter<bool>("verbose", false);
41  publishFrequency_ = pset.getUntrackedParameter<double>("publishFrequency", publishFrequency_);
43 
44  if (host != "" && port > 0)
45  {
46  net_ = new DQMBasicNet;
47  net_->debug(verbose);
48  net_->updateToCollector(host, port);
49  net_->start();
50  }
51 
52  if (! filter.empty())
53  {
54  try
55  {
56  filter_ = new lat::Regexp(filter);
57  if (! filter_->valid())
58  throw cms::Exception("DQMService")
59  << "Invalid 'filter' parameter value '" << filter << "':"
60  << " bad regular expression syntax at character "
61  << filter_->errorOffset() << ": " << filter_->errorMessage();
62  filter_->study();
63  }
64  catch (lat::Error &e)
65  {
66  throw cms::Exception("DQMService")
67  << "Invalid regular expression 'filter' parameter value '"
68  << filter << "': " << e.explain();
69  }
70  }
71 }
T getUntrackedParameter(std::string const &, T const &) const
DQMBasicNet * net_
Definition: DQMService.h:25
double publishFrequency_
Definition: DQMService.h:28
void watchPostEvent(PostEvent::slot_type const &iSlot)
double lastFlush_
Definition: DQMService.h:27
lat::Regexp * filter_
Definition: DQMService.h:26
int port
Definition: query.py:115
DQMStore * store_
Definition: DQMService.h:24
void flush(edm::StreamContext const &sc)
Definition: DQMService.cc:180
Definition: mlp_gen.h:16
string host
Definition: query.py:114
DQMService::~DQMService ( void  )

Definition at line 73 of file DQMService.cc.

References shutdown().

74 {
75  shutdown();
76 }
void shutdown(void)
Definition: DQMService.cc:188

Member Function Documentation

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

Definition at line 180 of file DQMService.cc.

References flushStandalone().

Referenced by DQMService().

181 {
182  // Call a function independent to the framework
183  flushStandalone();
184 }
void flushStandalone()
Definition: DQMService.cc:81
void DQMService::flushStandalone ( )

Definition at line 81 of file DQMService.cc.

References cond::rpcobimon::current, MonitorElement::data_, DQMStore::data_, DQMNet::CoreObject::dirname, MonitorElement::DQM_KIND_INT, MonitorElement::DQM_KIND_REAL, MonitorElement::DQM_KIND_STRING, DQMNet::dqmhash(), alignCSCRings::e, filter_, DQMNet::CoreObject::flags, DQMNet::Object::hash, i, MonitorElement::kind(), lastFlush_, DQMNet::Object::lastreq, python.connectstrParser::o, MonitorElement::object_, DQMNet::CoreObject::objname, DQMNet::packQualityData(), MonitorElement::packScalarData(), publishFrequency_, DQMNet::Object::qdata, DQMNet::CoreObject::qreports, DQMNet::Object::rawdata, MonitorElement::reference_, DQMStore::reset(), DQMNet::Object::scalar, store_, AlCaHLTBitMon_QueryRunRegistry::string, DQMNet::CoreObject::tag, BeamSplash_cfg::version, DQMNet::CoreObject::version, and MonitorElement::wasUpdated().

Referenced by flush().

82 {
83  // Avoid sending updates excessively often.
85  double vtime = version * 1e-9;
86  if (vtime - lastFlush_ < publishFrequency_)
87  return;
88 
89  // OK, send an update.
90  if (net_)
91  {
93  std::set<std::string> seen;
94  std::string fullpath;
95 
96  // Lock the network layer so we can modify the data.
97  net_->lock();
98  bool updated = false;
99 
100  // Find updated contents and update the network cache.
101  DQMStore::MEMap::iterator i, e;
102  net_->reserveLocalSpace(store_->data_.size());
103  for (i = store_->data_.begin(), e = store_->data_.end(); i != e; ++i)
104  {
105  const MonitorElement &me = *i;
106  fullpath.clear();
107  fullpath += *me.data_.dirname;
108  if (! me.data_.dirname->empty())
109  fullpath += '/';
110  fullpath += me.data_.objname;
111 
112  if (filter_ && filter_->search(fullpath) < 0)
113  continue;
114 
115  seen.insert(fullpath);
116  if (! me.wasUpdated())
117  continue;
118 
119  o.lastreq = 0;
120  o.hash = DQMNet::dqmhash(fullpath.c_str(), fullpath.size());
121  o.flags = me.data_.flags;
122  o.tag = me.data_.tag;
123  o.version = version;
124  o.dirname = me.data_.dirname;
125  o.objname = me.data_.objname;
126  assert(o.rawdata.empty());
127  assert(o.scalar.empty());
128  assert(o.qdata.empty());
129 
130  // Pack object and reference, scalar and quality data.
131  switch (me.kind())
132  {
136  me.packScalarData(o.scalar, "");
137  break;
138 
139  default:
140  {
141  TBufferFile buffer(TBufferFile::kWrite);
142  buffer.WriteObject(me.object_);
143  if (me.reference_)
144  buffer.WriteObject(me.reference_);
145  else
146  buffer.WriteObjectAny(0, 0);
147  o.rawdata.resize(buffer.Length());
148  memcpy(&o.rawdata[0], buffer.Buffer(), buffer.Length());
150  break;
151  }
152  }
153 
154  // Update.
155  net_->updateLocalObject(o);
156  DQMNet::DataBlob().swap(o.rawdata);
157  std::string().swap(o.scalar);
158  std::string().swap(o.qdata);
159  updated = true;
160  }
161 
162  // Find removed contents and clear the network cache.
163  if (net_->removeLocalExcept(seen))
164  updated = true;
165 
166  // Unlock the network layer.
167  net_->unlock();
168 
169  // Tell network to flush if we updated something.
170  if (updated)
171  net_->sendLocalChanges();
172  }
173 
174  store_->reset();
175  lastFlush_ = lat::Time::current().ns() * 1e-9;
176 
177 
178 }
int i
Definition: DBlmapReader.cc:9
QReports qreports
Definition: DQMNet.h:106
uint64_t version
Definition: DQMNet.h:99
double publishFrequency_
Definition: DQMService.h:28
uint32_t flags
Definition: DQMNet.h:97
double lastFlush_
Definition: DQMService.h:27
lat::Regexp * filter_
Definition: DQMService.h:26
uint32_t tag
Definition: DQMNet.h:98
const std::string * dirname
Definition: DQMNet.h:104
std::string qdata
Definition: DQMNet.h:115
void packScalarData(std::string &into, const char *prefix) const
convert scalar data into a string.
bool wasUpdated(void) const
true if ME was updated in last monitoring cycle
uint64_t lastreq
Definition: DQMNet.h:112
DQMStore * store_
Definition: DQMService.h:24
std::vector< unsigned char > DataBlob
Definition: DQMNet.h:79
static size_t dqmhash(const void *key, size_t keylen)
Definition: DQMNet.h:215
Kind kind(void) const
Get the type of the monitor element.
Definition: mlp_gen.h:16
std::string objname
Definition: DQMNet.h:105
std::string scalar
Definition: DQMNet.h:114
DQMNet::CoreObject data_
unsigned long long uint64_t
Definition: Time.h:15
MEMap data_
Definition: DQMStore.h:695
uint64_t hash
Definition: DQMNet.h:111
static void packQualityData(std::string &into, const QReports &qr)
Definition: DQMNet.cc:177
void reset(void)
Definition: DQMStore.cc:1983
DataBlob rawdata
Definition: DQMNet.h:113
void DQMService::shutdown ( void  )
private

Definition at line 188 of file DQMService.cc.

Referenced by ~DQMService().

189 {
190  // If we have a network, let it go.
191  if (net_)
192  net_->shutdown();
193 }
Definition: mlp_gen.h:16

Member Data Documentation

lat::Regexp* DQMService::filter_
private

Definition at line 26 of file DQMService.h.

Referenced by DQMService(), and flushStandalone().

double DQMService::lastFlush_
private

Definition at line 27 of file DQMService.h.

Referenced by flushStandalone().

DQMBasicNet* DQMService::net_
private

Definition at line 25 of file DQMService.h.

double DQMService::publishFrequency_
private

Definition at line 28 of file DQMService.h.

Referenced by DQMService(), and flushStandalone().

DQMStore* DQMService::store_
private

Definition at line 24 of file DQMService.h.

Referenced by flushStandalone().