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)
 
 ~DQMService (void)
 

Private Member Functions

void flush (const edm::Event &, const edm::EventSetup &)
 
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 edm::hlt::Exception, align_tpl::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:24
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
void shutdown(void)
Definition: DQMService.cc:206
double publishFrequency_
Definition: DQMService.h:27
void watchPostModule(PostModule::slot_type const &iSlot)
void watchPreSourceConstruction(PreSourceConstruction::slot_type const &iSlot)
double lastFlush_
Definition: DQMService.h:26
void watchPostSourceConstruction(PostSourceConstruction::slot_type const &iSlot)
lat::Regexp * filter_
Definition: DQMService.h:25
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:23
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
tuple filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
Definition: align_tpl.py:86
void flush(const edm::Event &, const edm::EventSetup &)
Definition: DQMService.cc:107
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:206

Member Function Documentation

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

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

Referenced by DQMService().

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

Definition at line 206 of file DQMService.cc.

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

207 {
208  // If we have a network, let it go.
209  if (net_)
210  net_->shutdown();
211 }
Definition: mlp_gen.h:16

Member Data Documentation

lat::Regexp* DQMService::filter_
private

Definition at line 25 of file DQMService.h.

Referenced by DQMService(), and flush().

double DQMService::lastFlush_
private

Definition at line 26 of file DQMService.h.

Referenced by flush().

DQMBasicNet* DQMService::net_
private

Definition at line 24 of file DQMService.h.

double DQMService::publishFrequency_
private

Definition at line 27 of file DQMService.h.

Referenced by DQMService(), and flush().

DQMStore* DQMService::store_
private

Definition at line 23 of file DQMService.h.

Referenced by flush().