CMS 3D CMS Logo

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 MillePedeFileConverter_cfg::e, Exception, ALCARECOTkAlBeamHalo_cff::filter, filter_, flush(), edm::ParameterSet::getUntrackedParameter(), query::host, query::port, publishFrequency_, AlCaHLTBitMon_QueryRunRegistry::string, edm::ActivityRegistry::watchPostEvent(), and edm::ActivityRegistry::watchPostStreamEndLumi().

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

Definition at line 74 of file DQMService.cc.

References shutdown().

75 {
76  shutdown();
77 }
void shutdown(void)
Definition: DQMService.cc:189

Member Function Documentation

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

Definition at line 181 of file DQMService.cc.

References flushStandalone().

Referenced by DQMService().

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

Definition at line 82 of file DQMService.cc.

References edmScanValgrind::buffer, MonitorElement::data_, DQMStore::data_, DQMNet::CoreObject::dirname, MonitorElement::DQM_KIND_INT, MonitorElement::DQM_KIND_REAL, MonitorElement::DQM_KIND_STRING, DQMNet::dqmhash(), MillePedeFileConverter_cfg::e, filter_, DQMNet::CoreObject::flags, DQMNet::Object::hash, mps_fire::i, MonitorElement::kind(), lastFlush_, DQMNet::Object::lastreq, 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, jetIDSelector_cfi::version, DQMNet::CoreObject::version, and MonitorElement::wasUpdated().

Referenced by flush().

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

Definition at line 189 of file DQMService.cc.

Referenced by ~DQMService().

190 {
191  // If we have a network, let it go.
192  if (net_)
193  net_->shutdown();
194 }
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().