CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
cscdqm::Collection Class Reference

Manage collection of histograms, load histogram definitions from XML file and book histograms by calling MonitorObjectProvider routines. More...

#include <CSCDQM_Collection.h>

Public Types

typedef xercesc::DOMDocument DOMDocument
 
typedef xercesc::DOMElement DOMElement
 
typedef xercesc::DOMNamedNodeMap DOMNamedNodeMap
 
typedef xercesc::DOMNode DOMNode
 
typedef xercesc::DOMNodeList DOMNodeList
 
typedef xercesc::XercesDOMParser XercesDOMParser
 
typedef xercesc::XMLException XMLException
 
typedef xercesc::XMLPlatformUtils XMLPlatformUtils
 
typedef xercesc::XMLString XMLString
 

Public Member Functions

void bookCSCHistos (const HwId crateId, const HwId dmbId) const
 Book Chamber Histograms. More...
 
void bookCSCHistos (const HistoId hid, const HwId crateId, const HwId dmbId, const HwId addId) const
 Book Chamber Histogram with additional identifier (On Demand) More...
 
void bookDDUHistos (const HwId dduId) const
 Book DDU histograms. More...
 
void bookEMUHistos () const
 Book EMU histograms. More...
 
void bookFEDHistos (const HwId fedId) const
 Book FED histograms. More...
 
 Collection (Configuration *const p_config)
 Constructor. More...
 
const bool isOnDemand (const HistoName &name) const
 Check if the histogram is on demand (by histogram name) More...
 
void load ()
 Load XML file and fill definition map(s) More...
 
void printCollection () const
 Print collection of available histograms and their parameters. More...
 

Private Member Functions

void book (const HistoDef &h, const CoHistoProps &p, const std::string &folder) const
 Book histogram. More...
 

Static Private Member Functions

static const bool checkHistoValue (const CoHistoProps &h, const std::string &name, std::string &value)
 Find string histogram value in map. More...
 
static const bool checkHistoValue (const CoHistoProps &h, const std::string &name, int &value)
 get Histogram int value out of the map and return boolean result More...
 
static const bool checkHistoValue (const CoHistoProps &h, const std::string name, double &value)
 get Histogram double value out of the map and return boolean result More...
 
static std::string & getHistoValue (const CoHistoProps &h, const std::string &name, std::string &value, const std::string &def_value="")
 Find string histogram value in map. More...
 
static int & getHistoValue (const CoHistoProps &h, const std::string &name, int &value, const int &def_value=0)
 get Histogram int value out of the map and More...
 
static double & getHistoValue (const CoHistoProps &h, const std::string name, double &value, const int def_value=0.0)
 get Histogram double value out of the map and More...
 
static void getNodeProperties (DOMNode *&node, CoHistoProps &hp)
 Extract and write single histogram properties from XML node to map. More...
 
static const int ParseAxisLabels (const std::string &s, std::map< int, std::string > &labels)
 Parse Axis label string and return values in vector. More...
 

Private Attributes

CoHistoMap collection
 
Configurationconfig
 

Detailed Description

Manage collection of histograms, load histogram definitions from XML file and book histograms by calling MonitorObjectProvider routines.

Definition at line 73 of file CSCDQM_Collection.h.

Member Typedef Documentation

typedef xercesc::DOMDocument cscdqm::Collection::DOMDocument

Definition at line 76 of file CSCDQM_Collection.h.

typedef xercesc::DOMElement cscdqm::Collection::DOMElement

Definition at line 77 of file CSCDQM_Collection.h.

typedef xercesc::DOMNamedNodeMap cscdqm::Collection::DOMNamedNodeMap

Definition at line 80 of file CSCDQM_Collection.h.

typedef xercesc::DOMNode cscdqm::Collection::DOMNode

Definition at line 78 of file CSCDQM_Collection.h.

typedef xercesc::DOMNodeList cscdqm::Collection::DOMNodeList

Definition at line 79 of file CSCDQM_Collection.h.

typedef xercesc::XercesDOMParser cscdqm::Collection::XercesDOMParser

Definition at line 84 of file CSCDQM_Collection.h.

typedef xercesc::XMLException cscdqm::Collection::XMLException

Definition at line 81 of file CSCDQM_Collection.h.

typedef xercesc::XMLPlatformUtils cscdqm::Collection::XMLPlatformUtils

Definition at line 83 of file CSCDQM_Collection.h.

typedef xercesc::XMLString cscdqm::Collection::XMLString

Definition at line 82 of file CSCDQM_Collection.h.

Constructor & Destructor Documentation

cscdqm::Collection::Collection ( Configuration *const  p_config)

Constructor.

Parameters
p_configPointer to Global configuration object

Definition at line 31 of file CSCDQM_Collection.cc.

31  {
32  config = p_config;
33  }
Definition: config.py:1

Member Function Documentation

void cscdqm::Collection::book ( const HistoDef h,
const CoHistoProps p,
const std::string &  folder 
) const
private

Book histogram.

Parameters
hHistogram definition to book
pMap of Histogram properties
folderfolder to book histograms to
Returns

Check if this histogram is included in booking by filters

Put histogram into cache

Definition at line 423 of file CSCDQM_Collection.cc.

References checkHistoValue(), cscdqm::DEF_HISTO_COLOR, Exception, cscdqm::HistoDef::getFullPath(), getHistoValue(), cscdqm::HistoDef::getName(), cscdqm::MonitorObject::getTH1Lock(), cscdqm::H1D, cscdqm::H2D, cscdqm::H3D, tablePrinter::labels, CommonMethods::lock(), LOG_INFO, cscdqm::Lock::mutex, dataset::name, ParseAxisLabels(), cscdqm::HistoDef::processTitle(), cscdqm::PROFILE, cscdqm::PROFILE2D, alignCSCRings::s, cscdqm::MonitorObject::setAxisTitle(), cscdqm::MonitorObject::SetMaximum(), AlCaHLTBitMon_QueryRunRegistry::string, fftjetcommon_cfi::title, cscdqm::Utility::tokenize(), cscdqm::LockType::unlock(), findQualityFiles::v, cscdqm::XML_BOOK_HISTO_TITLE, cscdqm::XML_BOOK_HISTO_TYPE, cscdqm::XML_BOOK_ONDEMAND, cscdqm::XML_BOOK_ONDEMAND_FALSE, and cscdqm::XML_BOOK_ONDEMAND_TRUE.

Referenced by bookCSCHistos(), bookDDUHistos(), bookEMUHistos(), and bookFEDHistos().

423  {
424 
425  MonitorObject* me = nullptr;
426  std::string name = h.getName(), type, title, s;
427 
429  if (!config->needBookMO(h.getFullPath())) {
430  LOG_INFO << "MOFilter excluded " << name << " from booking";
431  config->fnPutHisto(h, me);
432  return;
433  }
434 
435  int i1, i2, i3;
436  double d1, d2, d3, d4, d5, d6;
437  bool ondemand = (getHistoValue(p, XML_BOOK_ONDEMAND, s, XML_BOOK_ONDEMAND_FALSE) == XML_BOOK_ONDEMAND_TRUE ? true : false);
438 
439  if (!checkHistoValue(p, XML_BOOK_HISTO_TYPE, type)) { throw Exception("Histogram does not have type!"); }
441 
442  if (ondemand) {
443  title = h.processTitle(title);
444  }
445 
446  if (type == "h1") {
447  me = config->fnBook(
448  HistoBookRequest(h, H1D, type, folder, title,
449  getHistoValue(p, "XBins", i1, 1),
450  getHistoValue(p, "XMin", d1, 0),
451  getHistoValue(p, "XMax", d2, 1)));
452  } else
453  if(type == "h2") {
454  me = config->fnBook(
455  HistoBookRequest(h, H2D, type, folder, title,
456  getHistoValue(p, "XBins", i1, 1),
457  getHistoValue(p, "XMin", d1, 0),
458  getHistoValue(p, "XMax", d2, 1),
459  getHistoValue(p, "YBins", i2, 1),
460  getHistoValue(p, "YMin", d3, 0),
461  getHistoValue(p, "YMax", d4, 1)));
462  } else
463  if(type == "h3") {
464  me = config->fnBook(
465  HistoBookRequest(h, H3D, type, folder, title,
466  getHistoValue(p, "XBins", i1, 1),
467  getHistoValue(p, "XMin", d1, 0),
468  getHistoValue(p, "XMax", d2, 1),
469  getHistoValue(p, "YBins", i2, 1),
470  getHistoValue(p, "YMin", d3, 0),
471  getHistoValue(p, "YMax", d4, 1),
472  getHistoValue(p, "ZBins", i3, 1),
473  getHistoValue(p, "ZMin", d5, 0),
474  getHistoValue(p, "ZMax", d6, 1)));
475  } else
476  if(type == "hp") {
477  me = config->fnBook(
478  HistoBookRequest(h, PROFILE, type, folder, title,
479  getHistoValue(p, "XBins", i1, 1),
480  getHistoValue(p, "XMin", d1, 0),
481  getHistoValue(p, "XMax", d2, 1)));
482  /*
483  HistoBookRequest(h, PROFILE, type, folder, title,
484  getHistoValue(p, "XBins", i1, 1),
485  getHistoValue(p, "XMin", d1, 0),
486  getHistoValue(p, "XMax", d2, 1),
487  getHistoValue(p, "YBins", i2, 1),
488  getHistoValue(p, "YMin", d3, 0),
489  getHistoValue(p, "YMax", d4, 1)));
490  */
491  } else
492  if(type == "hp2") {
493  me = config->fnBook(
494  HistoBookRequest(h, PROFILE2D, type, folder, title,
495  getHistoValue(p, "XBins", i1, 1),
496  getHistoValue(p, "XMin", d1, 0),
497  getHistoValue(p, "XMax", d2, 1),
498  getHistoValue(p, "YBins", i2, 1),
499  getHistoValue(p, "YMin", d3, 0),
500  getHistoValue(p, "YMax", d4, 1),
501  getHistoValue(p, "ZBins", i3, 1),
502  getHistoValue(p, "ZMin", d5, 0),
503  getHistoValue(p, "ZMax", d6, 1)));
504  } else {
505  throw Exception("Can not book histogram with type: " + type);
506  }
507 
508  if(me != nullptr) {
509 
510  LockType lock(me->mutex);
511  TH1 *th = me->getTH1Lock();
512 
513  if(checkHistoValue(p, "XTitle", s)) {
514  if (ondemand) {
515  s = h.processTitle(s);
516  }
517  me->setAxisTitle(s, 1);
518  }
519 
520  if(checkHistoValue(p, "YTitle", s)) {
521  if (ondemand) {
522  s = h.processTitle(s);
523  }
524  me->setAxisTitle(s, 2);
525  }
526 
527  if(checkHistoValue(p, "ZTitle", s)) {
528  if (ondemand) {
529  s = h.processTitle(s);
530  }
531  me->setAxisTitle(s, 3);
532  }
533 
534  if(checkHistoValue(p, "SetOption", s)) th->SetOption(s.c_str());
535  if(checkHistoValue(p, "SetStats", i1)) th->SetStats(i1);
536  th->SetFillColor(getHistoValue(p, "SetFillColor", i1, DEF_HISTO_COLOR));
537  if(checkHistoValue(p, "SetXLabels", s)) {
538  std::map<int, std::string> labels;
539  ParseAxisLabels(s, labels);
540  th->GetXaxis()->SetNoAlphanumeric(); // For ROOT6 to prevent getting zero means values
541  for (std::map<int, std::string>::iterator l_itr = labels.begin(); l_itr != labels.end(); ++l_itr) {
542  th->GetXaxis()->SetBinLabel(l_itr->first, l_itr->second.c_str());
543  }
544  }
545  if(checkHistoValue(p, "SetYLabels", s)) {
546  std::map<int, std::string> labels;
547  ParseAxisLabels(s, labels);
548  th->GetYaxis()->SetNoAlphanumeric(); // For ROOT6 to prevent getting zero means values
549  for (std::map<int, std::string>::iterator l_itr = labels.begin(); l_itr != labels.end(); ++l_itr) {
550  th->GetYaxis()->SetBinLabel(l_itr->first, l_itr->second.c_str());
551  }
552  }
553  if(checkHistoValue(p, "LabelOption", s)) {
554  std::vector<std::string> v;
555  if(2 == Utility::tokenize(s, v, ",")) {
556  th->LabelsOption(v[0].c_str(), v[1].c_str());
557  }
558  }
559  if(checkHistoValue(p, "SetLabelSize", s)) {
560  std::vector<std::string> v;
561  if(2 == Utility::tokenize(s, v, ",")) {
562  th->SetLabelSize((double) atof(v[0].c_str()), v[1].c_str());
563  }
564  }
565  if(checkHistoValue(p, "SetTitleOffset", s)) {
566  std::vector<std::string> v;
567  if(2 == Utility::tokenize(s, v, ",")) {
568  th->SetTitleOffset((double) atof(v[0].c_str()), v[1].c_str());
569  }
570  }
571  if(checkHistoValue(p, "SetMinimum", d1)) th->SetMinimum(d1);
572  if(checkHistoValue(p, "SetMaximum", d1)) me->SetMaximum(d1);
573  if(checkHistoValue(p, "SetNdivisionsX", i1)) {
574  th->SetNdivisions(i1, "X");
575  th->GetXaxis()->CenterLabels(true);
576  }
577  if(checkHistoValue(p, "SetNdivisionsY", i1)) {
578  th->SetNdivisions(i1, "Y");
579  th->GetYaxis()->CenterLabels(true);
580  }
581  if(checkHistoValue(p, "SetTickLengthX", d1)) th->SetTickLength(d1, "X");
582  if(checkHistoValue(p, "SetTickLengthY", d1)) th->SetTickLength(d1, "Y");
583  if(checkHistoValue(p, "SetLabelSizeX", d1)) th->SetLabelSize(d1, "X");
584  if(checkHistoValue(p, "SetLabelSizeY", d1)) th->SetLabelSize(d1, "Y");
585  if(checkHistoValue(p, "SetLabelSizeZ", d1)) th->SetLabelSize(d1, "Z");
586  if(checkHistoValue(p, "SetErrorOption", s)) reinterpret_cast<TProfile*>(th)->SetErrorOption(s.c_str());
587 
588  lock.unlock();
589 
590  }
591 
592  LOG_DEBUG << "[Collection::book] booked " << h.getFullPath() << " (" << me << ")";
593 
595  config->fnPutHisto(h, me);
596 
597  }
type
Definition: HCALResponse.h:21
static const char XML_BOOK_ONDEMAND_FALSE[]
static const char XML_BOOK_HISTO_TYPE[]
#define LOG_INFO
Definition: CSCDQM_Logger.h:43
static const char XML_BOOK_ONDEMAND[]
Definition: config.py:1
static std::string & getHistoValue(const CoHistoProps &h, const std::string &name, std::string &value, const std::string &def_value="")
Find string histogram value in map.
static const bool checkHistoValue(const CoHistoProps &h, const std::string &name, std::string &value)
Find string histogram value in map.
static const char XML_BOOK_ONDEMAND_TRUE[]
static const int DEF_HISTO_COLOR
static const char XML_BOOK_HISTO_TITLE[]
static const int ParseAxisLabels(const std::string &s, std::map< int, std::string > &labels)
Parse Axis label string and return values in vector.
static int tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
Break string into tokens.
void cscdqm::Collection::bookCSCHistos ( const HwId  crateId,
const HwId  dmbId 
) const

Book Chamber Histograms.

Parameters
crateIdCSC Crate Id
dmbIdCSC DMB Id
Returns

Definition at line 370 of file CSCDQM_Collection.cc.

References book(), checkHistoValue(), collection, cscdqm::HistoDef::getHistoIdByName(), getHistoValue(), mps_fire::i, gen::k, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, cscdqm::XML_BOOK_NAME_FROM, cscdqm::XML_BOOK_NAME_TO, cscdqm::XML_BOOK_ONDEMAND, and cscdqm::XML_BOOK_ONDEMAND_FALSE.

Referenced by cscdqm::Dispatcher::book(), and cscdqm::Dispatcher::getHisto().

370  {
371  CoHistoMap::const_iterator i = collection.find("CSC");
372  if (i != collection.end()) {
373  const CoHisto hs = i->second;
374  for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
375  std::string s = "";
376  HistoId hid = 0;
377  if (HistoDef::getHistoIdByName(j->first, hid)) {
379  CSCHistoDef hdef(hid, crateId, dmbId);
380  book(hdef, j->second, config->getFOLDER_CSC());
381  } else {
382  int from = 0, to = 0;
383  if (checkHistoValue(j->second, XML_BOOK_NAME_FROM, from) && checkHistoValue(j->second, XML_BOOK_NAME_TO, to)) {
384  for (int k = from; k <= to; k++) {
385  CSCHistoDef hdef(hid, crateId, dmbId, k);
386  book(hdef, j->second, config->getFOLDER_CSC());
387  }
388  }
389  }
390  }
391  }
392  }
393  }
static const bool getHistoIdByName(const std::string &p_name, HistoId &p_id)
Get Histogram ID by name.
static const char XML_BOOK_ONDEMAND_FALSE[]
static const char XML_BOOK_NAME_FROM[]
static const char XML_BOOK_NAME_TO[]
static const char XML_BOOK_ONDEMAND[]
Definition: config.py:1
unsigned int HistoId
static std::string & getHistoValue(const CoHistoProps &h, const std::string &name, std::string &value, const std::string &def_value="")
Find string histogram value in map.
static const bool checkHistoValue(const CoHistoProps &h, const std::string &name, std::string &value)
Find string histogram value in map.
int k[5][pyjets_maxn]
std::map< std::string, CoHistoProps > CoHisto
void book(const HistoDef &h, const CoHistoProps &p, const std::string &folder) const
Book histogram.
void cscdqm::Collection::bookCSCHistos ( const HistoId  hid,
const HwId  crateId,
const HwId  dmbId,
const HwId  addId 
) const

Book Chamber Histogram with additional identifier (On Demand)

Parameters
hidHistogram Identifier
crateIdCSC Crate Id
dmbIdCSC DMB Id
addIdCSC Additional identifier, ex. Layer Id, ALCT Id, etc.
Returns

Definition at line 405 of file CSCDQM_Collection.cc.

References book(), collection, mps_fire::i, and cscdqm::h::names.

405  {
406  CoHistoMap::const_iterator i = collection.find("CSC");
407  if (i != collection.end()) {
408  CoHisto::const_iterator j = i->second.find(h::names[hid]);
409  if (j != i->second.end()) {
410  CSCHistoDef hdef(hid, crateId, dmbId, addId);
411  book(hdef, j->second, config->getFOLDER_CSC());
412  }
413  }
414  }
static const HistoName names[]
Definition: config.py:1
void book(const HistoDef &h, const CoHistoProps &p, const std::string &folder) const
Book histogram.
void cscdqm::Collection::bookDDUHistos ( const HwId  dduId) const

Book DDU histograms.

Parameters
dduIdDDU Id
Returns

Definition at line 347 of file CSCDQM_Collection.cc.

References book(), collection, cscdqm::HistoDef::getHistoIdByName(), getHistoValue(), mps_fire::i, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, cscdqm::XML_BOOK_ONDEMAND, and cscdqm::XML_BOOK_ONDEMAND_FALSE.

Referenced by cscdqm::Dispatcher::book(), and cscdqm::Dispatcher::getHisto().

347  {
348  CoHistoMap::const_iterator i = collection.find("DDU");
349  if (i != collection.end()) {
350  const CoHisto hs = i->second;
351  for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
352  std::string s = "";
354  HistoId hid = 0;
355  if (HistoDef::getHistoIdByName(j->first, hid)) {
356  DDUHistoDef hdef(hid, dduId);
357  book(hdef, j->second, config->getFOLDER_DDU());
358  }
359  }
360  }
361  }
362  }
static const bool getHistoIdByName(const std::string &p_name, HistoId &p_id)
Get Histogram ID by name.
static const char XML_BOOK_ONDEMAND_FALSE[]
static const char XML_BOOK_ONDEMAND[]
Definition: config.py:1
unsigned int HistoId
static std::string & getHistoValue(const CoHistoProps &h, const std::string &name, std::string &value, const std::string &def_value="")
Find string histogram value in map.
std::map< std::string, CoHistoProps > CoHisto
void book(const HistoDef &h, const CoHistoProps &p, const std::string &folder) const
Book histogram.
void cscdqm::Collection::bookEMUHistos ( ) const

Book EMU histograms.

Returns

Definition at line 303 of file CSCDQM_Collection.cc.

References book(), collection, cscdqm::HistoDef::getHistoIdByName(), getHistoValue(), mps_fire::i, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, cscdqm::XML_BOOK_ONDEMAND, and cscdqm::XML_BOOK_ONDEMAND_FALSE.

Referenced by cscdqm::Dispatcher::book().

303  {
304  CoHistoMap::const_iterator i = collection.find("EMU");
305  if (i != collection.end()) {
306  const CoHisto hs = i->second;
307  for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
308  std::string s = "";
310  HistoId hid = 0;
311  if (HistoDef::getHistoIdByName(j->first, hid)) {
312  EMUHistoDef hdef(hid);
313  book(hdef, j->second, config->getFOLDER_EMU());
314  }
315  }
316  }
317  }
318  }
static const bool getHistoIdByName(const std::string &p_name, HistoId &p_id)
Get Histogram ID by name.
static const char XML_BOOK_ONDEMAND_FALSE[]
static const char XML_BOOK_ONDEMAND[]
Definition: config.py:1
unsigned int HistoId
static std::string & getHistoValue(const CoHistoProps &h, const std::string &name, std::string &value, const std::string &def_value="")
Find string histogram value in map.
std::map< std::string, CoHistoProps > CoHisto
void book(const HistoDef &h, const CoHistoProps &p, const std::string &folder) const
Book histogram.
void cscdqm::Collection::bookFEDHistos ( const HwId  fedId) const

Book FED histograms.

Parameters
fedIdFED Id
Returns

Definition at line 325 of file CSCDQM_Collection.cc.

References book(), collection, cscdqm::HistoDef::getHistoIdByName(), getHistoValue(), mps_fire::i, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, cscdqm::XML_BOOK_ONDEMAND, and cscdqm::XML_BOOK_ONDEMAND_FALSE.

Referenced by cscdqm::Dispatcher::book(), and cscdqm::Dispatcher::getHisto().

325  {
326  CoHistoMap::const_iterator i = collection.find("FED");
327  if (i != collection.end()) {
328  const CoHisto hs = i->second;
329  for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
330  std::string s = "";
332  HistoId hid = 0;
333  if (HistoDef::getHistoIdByName(j->first, hid)) {
334  FEDHistoDef hdef(hid, fedId);
335  book(hdef, j->second, config->getFOLDER_FED());
336  }
337  }
338  }
339  }
340  }
static const bool getHistoIdByName(const std::string &p_name, HistoId &p_id)
Get Histogram ID by name.
static const char XML_BOOK_ONDEMAND_FALSE[]
static const char XML_BOOK_ONDEMAND[]
Definition: config.py:1
unsigned int HistoId
static std::string & getHistoValue(const CoHistoProps &h, const std::string &name, std::string &value, const std::string &def_value="")
Find string histogram value in map.
std::map< std::string, CoHistoProps > CoHisto
void book(const HistoDef &h, const CoHistoProps &p, const std::string &folder) const
Book histogram.
const bool cscdqm::Collection::checkHistoValue ( const CoHistoProps h,
const std::string &  name,
std::string &  value 
)
staticprivate

Find string histogram value in map.

Parameters
hHistogram map
nameparameter name
valuehandler for parameter value
Returns
true if parameter found and filled, false - otherwise

Definition at line 181 of file CSCDQM_Collection.cc.

References mps_fire::i.

Referenced by book(), bookCSCHistos(), and getHistoValue().

181  {
182  CoHistoProps::const_iterator i = h.find(name);
183  if(i == h.end()) {
184  return false;
185  }
186  value = i->second;
187  return true;
188  }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: value.py:1
const bool cscdqm::Collection::checkHistoValue ( const CoHistoProps h,
const std::string &  name,
int &  value 
)
staticprivate

get Histogram int value out of the map and return boolean result

Parameters
hHistogram map
nameparameter name
valuehandler for parameter value
Returns
true if parameter found and filled, false - otherwise

Definition at line 197 of file CSCDQM_Collection.cc.

References mps_fire::i, and relativeConstraints::value.

197  {
198  CoHistoProps::const_iterator i = h.find(name);
199  if(i == h.end()) {
200  return false;
201  }
202  if(EOF == std::sscanf(i->second.c_str(), "%d", &value)) {
203  return false;
204  }
205  return true;
206  }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const bool cscdqm::Collection::checkHistoValue ( const CoHistoProps h,
const std::string  name,
double &  value 
)
staticprivate

get Histogram double value out of the map and return boolean result

Parameters
hHistogram map
nameparameter name
valuehandler for parameter value
Returns
true if parameter found and filled, false - otherwise

Definition at line 216 of file CSCDQM_Collection.cc.

References mps_fire::i, and relativeConstraints::value.

216  {
217  CoHistoProps::const_iterator i = h.find(name);
218  if(i == h.end()) {
219  return false;
220  }
221  if(EOF == std::sscanf(i->second.c_str(), "%lf", &value)) {
222  return false;
223  }
224  return true;
225  }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::string & cscdqm::Collection::getHistoValue ( const CoHistoProps h,
const std::string &  name,
std::string &  value,
const std::string &  def_value = "" 
)
staticprivate

Find string histogram value in map.

Parameters
hHistogram map
nameparameter name
valuehandler for parameter value
def_valuedefault value if parameter not found
Returns
pointer to value

Definition at line 235 of file CSCDQM_Collection.cc.

References checkHistoValue(), and relativeConstraints::value.

Referenced by book(), bookCSCHistos(), bookDDUHistos(), bookEMUHistos(), bookFEDHistos(), and isOnDemand().

235  {
236  if (!checkHistoValue(h, name, value)) {
237  value = def_value;
238  }
239  return value;
240  }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
static const bool checkHistoValue(const CoHistoProps &h, const std::string &name, std::string &value)
Find string histogram value in map.
Definition: value.py:1
int & cscdqm::Collection::getHistoValue ( const CoHistoProps h,
const std::string &  name,
int &  value,
const int &  def_value = 0 
)
staticprivate

get Histogram int value out of the map and

Parameters
hHistogram map
nameparameter name
valuehandler for parameter value
def_valuedefault value if parameter not found
Returns
pointer to value

Definition at line 250 of file CSCDQM_Collection.cc.

References checkHistoValue(), and relativeConstraints::value.

250  {
251  if (!checkHistoValue(h, name, value)) {
252  value = def_value;
253  }
254  return value;
255  }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
static const bool checkHistoValue(const CoHistoProps &h, const std::string &name, std::string &value)
Find string histogram value in map.
Definition: value.py:1
double & cscdqm::Collection::getHistoValue ( const CoHistoProps h,
const std::string  name,
double &  value,
const int  def_value = 0.0 
)
staticprivate

get Histogram double value out of the map and

Parameters
hHistogram map
nameparameter name
valuehandler for parameter value
def_valuedefault value if parameter not found
Returns
pointer to value

Definition at line 265 of file CSCDQM_Collection.cc.

References checkHistoValue(), and relativeConstraints::value.

265  {
266  if (!checkHistoValue(h, name, value)) {
267  value = def_value;
268  }
269  return value;
270  }
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
static const bool checkHistoValue(const CoHistoProps &h, const std::string &name, std::string &value)
Find string histogram value in map.
Definition: value.py:1
void cscdqm::Collection::getNodeProperties ( DOMNode *&  node,
CoHistoProps p 
)
staticprivate

Extract and write single histogram properties from XML node to map.

Parameters
nodeXML node
pList of properties to fill
Returns

Definition at line 147 of file CSCDQM_Collection.cc.

References edmScanValgrind::buffer, ws_sso_content_reader::content, mps_fire::i, dataset::name, AlCaHLTBitMon_QueryRunRegistry::string, relativeConstraints::value, and XERCES_CPP_NAMESPACE_QUALIFIER.

Referenced by load().

147  {
148  DOMNodeList *props = node->getChildNodes();
149 
150  for(XMLSize_t j = 0; j < props->getLength(); j++) {
151  DOMNode* node = props->item(j);
152  if (node->getNodeType() != DOMNode::ELEMENT_NODE) { continue; }
153  DOMElement* element = dynamic_cast<DOMElement*>(node);
154  std::string name = XMLString::transcode(element->getNodeName());
155 
156  const XMLCh *content = element->getTextContent();
157  XERCES_CPP_NAMESPACE_QUALIFIER TranscodeToStr tc(content, "UTF-8");
158  std::istringstream buffer((const char*)tc.str());
159  std::string value = buffer.str();
160 
161  DOMNamedNodeMap* attributes = node->getAttributes();
162  if (attributes) {
163  for (XMLSize_t i = 0; i < attributes->getLength(); i++) {
164  DOMNode* attribute = attributes->item(i);
165  std::string aname = XMLString::transcode(attribute->getNodeName());
166  std::string avalue = XMLString::transcode(attribute->getNodeValue());
167  p[name + "_" + aname] = avalue;
168  }
169  }
170  p[name] = value;
171  }
172  }
#define XERCES_CPP_NAMESPACE_QUALIFIER
Definition: LHERunInfo.h:16
xercesc::DOMNode DOMNode
xercesc::DOMElement DOMElement
Definition: value.py:1
xercesc::DOMNodeList DOMNodeList
xercesc::DOMNamedNodeMap DOMNamedNodeMap
const bool cscdqm::Collection::isOnDemand ( const HistoName name) const

Check if the histogram is on demand (by histogram name)

Parameters
namename of the histogram
Returns
true if this histogram is on demand, false - otherwise

Definition at line 604 of file CSCDQM_Collection.cc.

References collection, getHistoValue(), mps_fire::i, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, cscdqm::XML_BOOK_ONDEMAND, cscdqm::XML_BOOK_ONDEMAND_FALSE, and cscdqm::XML_BOOK_ONDEMAND_TRUE.

Referenced by cscdqm::Dispatcher::getHisto().

604  {
605  CoHistoMap::const_iterator i = collection.find("CSC");
606  if (i != collection.end()) {
607  CoHisto hs = i->second;
608  CoHisto::const_iterator j = hs.find(name);
609  if (j != hs.end()) {
610  std::string s;
612  }
613  }
614  return false;
615  }
static const char XML_BOOK_ONDEMAND_FALSE[]
static const char XML_BOOK_ONDEMAND[]
static std::string & getHistoValue(const CoHistoProps &h, const std::string &name, std::string &value, const std::string &def_value="")
Find string histogram value in map.
static const char XML_BOOK_ONDEMAND_TRUE[]
std::map< std::string, CoHistoProps > CoHisto
void cscdqm::Collection::load ( )

Load XML file and fill definition map(s)

Returns

Load histogram definition

Load histogram

Definition at line 40 of file CSCDQM_Collection.cc.

References collection, edmIntegrityCheck::d, common_cff::doc, MillePedeFileConverter_cfg::e, Exception, getNodeProperties(), h, AnalysisDataFormats_SUSYBSMObjects::hp, mps_fire::i, triggerObjects_cff::id, LOG_INFO, dataset::name, writedatasetfile::parser, tablePrinter::prefix, cscdqm::Utility::regexMatch(), cscdqm::REGEXP_ONDEMAND(), AlCaHLTBitMon_QueryRunRegistry::string, cms::concurrency::xercesInitialize(), cms::concurrency::xercesTerminate(), cscdqm::XML_BOOK_DEFINITION, cscdqm::XML_BOOK_DEFINITION_ID, cscdqm::XML_BOOK_DEFINITION_REF, cscdqm::XML_BOOK_HISTO_NAME, cscdqm::XML_BOOK_HISTO_PREFIX, cscdqm::XML_BOOK_HISTOGRAM, cscdqm::XML_BOOK_ONDEMAND, cscdqm::XML_BOOK_ONDEMAND_FALSE, and cscdqm::XML_BOOK_ONDEMAND_TRUE.

Referenced by cscdqm::Dispatcher::init().

40  {
41  LOG_INFO << "Reading histograms from " << config->getBOOKING_XML_FILE();
42 
43  if (config->getBOOKING_XML_FILE().empty()) {
44  return;
45  }
46 
47  try {
48 
50  {
52 
53  parser.setValidationScheme(XercesDOMParser::Val_Always);
54  parser.setDoNamespaces(true);
55  parser.setDoSchema(true);
56  parser.setExitOnFirstFatalError(true);
57  parser.setValidationConstraintFatal(true);
58  XMLFileErrorHandler eh;
59  parser.setErrorHandler(&eh);
60  parser.parse(config->getBOOKING_XML_FILE().c_str());
61 
62  DOMDocument *doc = parser.getDocument();
63  DOMElement *docNode = doc->getDocumentElement();
64  DOMNodeList *itemList = docNode->getChildNodes();
65 
67  for (XMLSize_t i = 0; i < itemList->getLength(); i++) {
68 
69  DOMNode* node = itemList->item(i);
70  if (node->getNodeType() != DOMNode::ELEMENT_NODE) { continue; }
71 
72  std::string nodeName = XMLString::transcode(node->getNodeName());
73 
77  if (nodeName == XML_BOOK_DEFINITION) {
78 
79  CoHistoProps dp;
80  getNodeProperties(node, dp);
81 
82  DOMElement* el = dynamic_cast<DOMElement*>(node);
83  std::string id(XMLString::transcode(el->getAttribute(XMLString::transcode(XML_BOOK_DEFINITION_ID))));
84  definitions.insert(make_pair(id, dp));
85 
86  } else
87 
91  if (nodeName == XML_BOOK_HISTOGRAM) {
92 
94 
95  DOMElement* el = dynamic_cast<DOMElement*>(node);
96  if (el->hasAttribute(XMLString::transcode(XML_BOOK_DEFINITION_REF))) {
97  std::string id(XMLString::transcode(el->getAttribute(XMLString::transcode(XML_BOOK_DEFINITION_REF))));
98 
99  CoHistoProps d = definitions[id];
100  for (CoHistoProps::iterator it = d.begin(); it != d.end(); it++) {
101  hp[it->first] = it->second;
102  }
103  }
104 
105  getNodeProperties(node, hp);
106 
109 
110  // Check if this histogram is an ON DEMAND histogram?
112 
113  LOG_DEBUG << "[Collection::load] loading " << prefix << "::" << name << " XML_BOOK_ONDEMAND = " << hp[XML_BOOK_ONDEMAND];
114 
115  CoHistoMap::iterator it = collection.find(prefix);
116  if (it == collection.end()) {
117  CoHisto h;
118  h[name] = hp;
119  collection[prefix] = h;
120  } else {
121  it->second.insert(make_pair(name, hp));
122  }
123  }
124  }
125  }
126 
128 
129  } catch (XMLException& e) {
130  char* message = XMLString::transcode(e.getMessage());
131  throw Exception(message);
132  }
133 
134  for (CoHistoMap::const_iterator i = collection.begin(); i != collection.end(); i++) {
135  LOG_INFO << i->second.size() << " " << i->first << " histograms defined";
136  }
137  }
static const char XML_BOOK_DEFINITION_ID[]
static const char XML_BOOK_ONDEMAND_FALSE[]
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
#define LOG_INFO
Definition: CSCDQM_Logger.h:43
void xercesTerminate()
Definition: Xerces.cc:23
static const char XML_BOOK_ONDEMAND[]
static const char XML_BOOK_DEFINITION_REF[]
static const char XML_BOOK_HISTOGRAM[]
xercesc::DOMDocument DOMDocument
Definition: config.py:1
static bool regexMatch(const std::string &expression, const std::string &message)
Match RegExp expression string against string message and return result.
void xercesInitialize()
Definition: Xerces.cc:18
static const char XML_BOOK_HISTO_PREFIX[]
susybsm::HSCParticleRefProd hp
Definition: classes.h:27
static void getNodeProperties(DOMNode *&node, CoHistoProps &hp)
Extract and write single histogram properties from XML node to map.
xercesc::DOMNode DOMNode
xercesc::DOMElement DOMElement
xercesc::DOMNodeList DOMNodeList
static const char XML_BOOK_ONDEMAND_TRUE[]
xercesc::XercesDOMParser XercesDOMParser
std::map< std::string, CoHistoProps > CoHisto
static const char XML_BOOK_DEFINITION[]
static const TPRegexp REGEXP_ONDEMAND("^.*%d.*$")
static const char XML_BOOK_HISTO_NAME[]
std::map< std::string, std::string > CoHistoProps
xercesc::XMLException XMLException
const int cscdqm::Collection::ParseAxisLabels ( const std::string &  s,
std::map< int, std::string > &  labels 
)
staticprivate

Parse Axis label string and return values in vector.

Parameters
ssource string to parse
labelspointer to result vector
Returns
number of labels found

Definition at line 278 of file CSCDQM_Collection.cc.

References label, alignCSCRings::s, AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

Referenced by book().

278  {
279  std::string tmp = s;
280  std::string::size_type pos = tmp.find("|");
281  char* stopstring = nullptr;
282 
283  while (pos != std::string::npos) {
284  std::string label_pair = tmp.substr(0, pos);
285  tmp.replace(0, pos + 1, "");
286  if (label_pair.find("=") != std::string::npos) {
287  int nbin = strtol(label_pair.substr(0, label_pair.find("=")).c_str(), &stopstring, 10);
288  std::string label = label_pair.substr(label_pair.find("=") + 1, label_pair.length());
289  while (label.find("\'") != std::string::npos) {
290  label.erase(label.find("\'"), 1);
291  }
292  labels[nbin] = label;
293  }
294  pos = tmp.find("|");
295  }
296  return labels.size();
297  }
uint16_t size_type
char const * label
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void cscdqm::Collection::printCollection ( ) const

Print collection of available histograms and their parameters.

Returns

Definition at line 621 of file CSCDQM_Collection.cc.

References edmScanValgrind::buffer, collection, and LOG_INFO.

621  {
622 
623  std::ostringstream buffer;
624  for(CoHistoMap::const_iterator hdmi = collection.begin(); hdmi != collection.end(); hdmi++) {
625  buffer << hdmi->first << " [" << std::endl;
626  for(CoHisto::const_iterator hdi = hdmi->second.begin(); hdi != hdmi->second.end(); hdi++) {
627  buffer << " " << hdi->first << " [" << std::endl;
628  for(CoHistoProps::const_iterator hi = hdi->second.begin(); hi != hdi->second.end(); hi++) {
629  buffer << " " << hi->first << " = " << hi->second << std::endl;
630  }
631  buffer << " ]" << std::endl;
632  }
633  buffer << " ]" << std::endl;
634  }
635  LOG_INFO << buffer.str();
636  }
#define LOG_INFO
Definition: CSCDQM_Logger.h:43

Member Data Documentation

CoHistoMap cscdqm::Collection::collection
private
Configuration* cscdqm::Collection::config
private

Definition at line 112 of file CSCDQM_Collection.h.