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 (const edm::Event &, const edm::EventSetup &)
 
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 47 of file DQMService.cc.

References alignCSCRings::e, edm::hlt::Exception, alcazmumu_cfi::filter, filter_, flush(), edm::ParameterSet::getUntrackedParameter(), query::host, query::port, publishFrequency_, releaseDQMAccess(), releaseDQMAccessM(), restrictDQMAccess(), restrictDQMAccessM(), shutdown(), edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPostModule(), edm::ActivityRegistry::watchPostProcessEvent(), edm::ActivityRegistry::watchPostSource(), edm::ActivityRegistry::watchPostSourceConstruction(), edm::ActivityRegistry::watchPreModule(), edm::ActivityRegistry::watchPreSource(), and edm::ActivityRegistry::watchPreSourceConstruction().

49  net_(0),
50  filter_(0),
51  lastFlush_(0),
53 {
62 
63  std::string host = pset.getUntrackedParameter<std::string>("collectorHost", "");
64  int port = pset.getUntrackedParameter<int>("collectorPort", 9090);
65  bool verbose = pset.getUntrackedParameter<bool>("verbose", false);
66  publishFrequency_ = pset.getUntrackedParameter<double>("publishFrequency", publishFrequency_);
67  std::string filter = pset.getUntrackedParameter<std::string>("filter", "");
68 
69  if (host != "" && port > 0)
70  {
71  net_ = new DQMBasicNet;
72  net_->debug(verbose);
73  net_->updateToCollector(host, port);
74  net_->start();
75  }
76 
77  if (! filter.empty())
78  {
79  try
80  {
81  filter_ = new lat::Regexp(filter);
82  if (! filter_->valid())
83  throw cms::Exception("DQMService")
84  << "Invalid 'filter' parameter value '" << filter << "':"
85  << " bad regular expression syntax at character "
86  << filter_->errorOffset() << ": " << filter_->errorMessage();
87  filter_->study();
88  }
89  catch (lat::Error &e)
90  {
91  throw cms::Exception("DQMService")
92  << "Invalid regular expression 'filter' parameter value '"
93  << filter << "': " << e.explain();
94  }
95  }
96 }
T getUntrackedParameter(std::string const &, T const &) const
static void releaseDQMAccessM(const edm::ModuleDescription &)
Definition: DQMService.cc:43
DQMBasicNet * net_
Definition: DQMService.h:25
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
void shutdown(void)
Definition: DQMService.cc:213
double publishFrequency_
Definition: DQMService.h:28
void watchPostModule(PostModule::slot_type const &iSlot)
void watchPreSourceConstruction(PreSourceConstruction::slot_type const &iSlot)
double lastFlush_
Definition: DQMService.h:27
void watchPostSourceConstruction(PostSourceConstruction::slot_type const &iSlot)
lat::Regexp * filter_
Definition: DQMService.h:26
int port
Definition: query.py:115
void watchPreModule(PreModule::slot_type const &iSlot)
void watchPostProcessEvent(PostProcessEvent::slot_type const &iSlot)
static void releaseDQMAccess(void)
Release access to the DQM core.
Definition: DQMService.cc:39
static void restrictDQMAccessM(const edm::ModuleDescription &)
Definition: DQMService.cc:34
DQMStore * store_
Definition: DQMService.h:24
void watchPreSource(PreSource::slot_type const &iSlot)
static void restrictDQMAccess(void)
Restrict access to the DQM core.
Definition: DQMService.cc:30
Definition: mlp_gen.h:16
string host
Definition: query.py:114
void flush(const edm::Event &, const edm::EventSetup &)
Definition: DQMService.cc:205
void watchPostSource(PostSource::slot_type const &iSlot)
DQMService::~DQMService ( void  )

Definition at line 98 of file DQMService.cc.

References shutdown().

99 {
100  shutdown();
101 }
void shutdown(void)
Definition: DQMService.cc:213

Member Function Documentation

void DQMService::flush ( const edm::Event ,
const edm::EventSetup  
)

Definition at line 205 of file DQMService.cc.

References flushStandalone().

Referenced by DQMService().

206 {
207  // Call a function independent to the framework
208  flushStandalone();
209 }
void flushStandalone()
Definition: DQMService.cc:106
void DQMService::flushStandalone ( )

Definition at line 106 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_, DQMNet::CoreObject::tag, BeamSplash_cfg::version, DQMNet::CoreObject::version, and MonitorElement::wasUpdated().

Referenced by evf::iDie::doFlush(), and flush().

107 {
108  // Avoid sending updates excessively often.
110  double vtime = version * 1e-9;
111  if (vtime - lastFlush_ < publishFrequency_)
112  return;
113 
114  // OK, send an update.
115  if (net_)
116  {
118  std::set<std::string> seen;
119  std::string fullpath;
120 
121  // Lock the network layer so we can modify the data.
122  net_->lock();
123  bool updated = false;
124 
125  // Find updated contents and update the network cache.
126  DQMStore::MEMap::iterator i, e;
127  net_->reserveLocalSpace(store_->data_.size());
128  for (i = store_->data_.begin(), e = store_->data_.end(); i != e; ++i)
129  {
130  const MonitorElement &me = *i;
131  fullpath.clear();
132  fullpath += *me.data_.dirname;
133  if (! me.data_.dirname->empty())
134  fullpath += '/';
135  fullpath += me.data_.objname;
136 
137  if (filter_ && filter_->search(fullpath) < 0)
138  continue;
139 
140  seen.insert(fullpath);
141  if (! me.wasUpdated())
142  continue;
143 
144  o.lastreq = 0;
145  o.hash = DQMNet::dqmhash(fullpath.c_str(), fullpath.size());
146  o.flags = me.data_.flags;
147  o.tag = me.data_.tag;
148  o.version = version;
149  o.dirname = me.data_.dirname;
150  o.objname = me.data_.objname;
151  assert(o.rawdata.empty());
152  assert(o.scalar.empty());
153  assert(o.qdata.empty());
154 
155  // Pack object and reference, scalar and quality data.
156  switch (me.kind())
157  {
161  me.packScalarData(o.scalar, "");
162  break;
163 
164  default:
165  {
166  TBufferFile buffer(TBufferFile::kWrite);
167  buffer.WriteObject(me.object_);
168  if (me.reference_)
169  buffer.WriteObject(me.reference_);
170  else
171  buffer.WriteObjectAny(0, 0);
172  o.rawdata.resize(buffer.Length());
173  memcpy(&o.rawdata[0], buffer.Buffer(), buffer.Length());
175  break;
176  }
177  }
178 
179  // Update.
180  net_->updateLocalObject(o);
181  DQMNet::DataBlob().swap(o.rawdata);
182  std::string().swap(o.scalar);
183  std::string().swap(o.qdata);
184  updated = true;
185  }
186 
187  // Find removed contents and clear the network cache.
188  if (net_->removeLocalExcept(seen))
189  updated = true;
190 
191  // Unlock the network layer.
192  net_->unlock();
193 
194  // Tell network to flush if we updated something.
195  if (updated)
196  net_->sendLocalChanges();
197  }
198 
199  store_->reset();
200  lastFlush_ = lat::Time::current().ns() * 1e-9;
201 
202 
203 }
int i
Definition: DBlmapReader.cc:9
QReports qreports
Definition: DQMNet.h:102
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:100
std::string qdata
Definition: DQMNet.h:111
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:108
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:199
Kind kind(void) const
Get the type of the monitor element.
Definition: mlp_gen.h:16
std::string objname
Definition: DQMNet.h:101
std::string scalar
Definition: DQMNet.h:110
DQMNet::CoreObject data_
unsigned long long uint64_t
Definition: Time.h:15
MEMap data_
Definition: DQMStore.h:457
uint64_t hash
Definition: DQMNet.h:107
static void packQualityData(std::string &into, const QReports &qr)
Definition: DQMNet.cc:177
void reset(void)
Definition: DQMStore.cc:1727
DataBlob rawdata
Definition: DQMNet.h:109
void DQMService::shutdown ( void  )
private

Definition at line 213 of file DQMService.cc.

Referenced by DQMService(), and ~DQMService().

214 {
215  // If we have a network, let it go.
216  if (net_)
217  net_->shutdown();
218 }
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().