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 55 of file DQMService.cc.

References alignCSCRings::e, edm::hlt::Exception, alcazmumu_cfi::filter, filter_, flush(), edm::ParameterSet::getUntrackedParameter(), query::host, query::port, publishFrequency_, releaseDQMAccessM(), releaseDQMAccessS(), restrictDQMAccessM(), restrictDQMAccessS(), shutdown(), AlCaHLTBitMon_QueryRunRegistry::string, edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPostModule(), edm::ActivityRegistry::watchPostProcessEvent(), edm::ActivityRegistry::watchPostSourceConstruction(), edm::ActivityRegistry::watchPostSourceEvent(), edm::ActivityRegistry::watchPreModule(), edm::ActivityRegistry::watchPreSourceConstruction(), and edm::ActivityRegistry::watchPreSourceEvent().

57  net_(0),
58  filter_(0),
59  lastFlush_(0),
61 {
70 
71  std::string host = pset.getUntrackedParameter<std::string>("collectorHost", "");
72  int port = pset.getUntrackedParameter<int>("collectorPort", 9090);
73  bool verbose = pset.getUntrackedParameter<bool>("verbose", false);
74  publishFrequency_ = pset.getUntrackedParameter<double>("publishFrequency", publishFrequency_);
76 
77  if (host != "" && port > 0)
78  {
79  net_ = new DQMBasicNet;
80  net_->debug(verbose);
81  net_->updateToCollector(host, port);
82  net_->start();
83  }
84 
85  if (! filter.empty())
86  {
87  try
88  {
89  filter_ = new lat::Regexp(filter);
90  if (! filter_->valid())
91  throw cms::Exception("DQMService")
92  << "Invalid 'filter' parameter value '" << filter << "':"
93  << " bad regular expression syntax at character "
94  << filter_->errorOffset() << ": " << filter_->errorMessage();
95  filter_->study();
96  }
97  catch (lat::Error &e)
98  {
99  throw cms::Exception("DQMService")
100  << "Invalid regular expression 'filter' parameter value '"
101  << filter << "': " << e.explain();
102  }
103  }
104 }
T getUntrackedParameter(std::string const &, T const &) const
static void releaseDQMAccessM(const edm::ModuleDescription &)
Definition: DQMService.cc:47
DQMBasicNet * net_
Definition: DQMService.h:25
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
void shutdown(void)
Definition: DQMService.cc:221
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
void watchPostSourceEvent(PostSourceEvent::slot_type const &iSlot)
int port
Definition: query.py:115
void watchPreModule(PreModule::slot_type const &iSlot)
void watchPostProcessEvent(PostProcessEvent::slot_type const &iSlot)
static void restrictDQMAccessM(const edm::ModuleDescription &)
Definition: DQMService.cc:34
static void restrictDQMAccessS(edm::StreamID)
Definition: DQMService.cc:38
DQMStore * store_
Definition: DQMService.h:24
Definition: mlp_gen.h:16
string host
Definition: query.py:114
static void releaseDQMAccessS(edm::StreamID)
Definition: DQMService.cc:51
void flush(const edm::Event &, const edm::EventSetup &)
Definition: DQMService.cc:213
void watchPreSourceEvent(PreSourceEvent::slot_type const &iSlot)
DQMService::~DQMService ( void  )

Definition at line 106 of file DQMService.cc.

References shutdown().

107 {
108  shutdown();
109 }
void shutdown(void)
Definition: DQMService.cc:221

Member Function Documentation

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

Definition at line 213 of file DQMService.cc.

References flushStandalone().

Referenced by DQMService().

214 {
215  // Call a function independent to the framework
216  flushStandalone();
217 }
void flushStandalone()
Definition: DQMService.cc:114
void DQMService::flushStandalone ( )

Definition at line 114 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().

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

Definition at line 221 of file DQMService.cc.

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

222 {
223  // If we have a network, let it go.
224  if (net_)
225  net_->shutdown();
226 }
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().