CMS 3D CMS Logo

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>

List of all members.

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

Private Member Functions

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

Static Private Member Functions

static const bool checkHistoValue (const CoHistoProps &h, const std::string &name, std::string &value)
 Find string histogram value in map.
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
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
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 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
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
static void getNodeProperties (DOMNode *&node, CoHistoProps &hp)
 Extract and write single histogram properties from XML node to map.
static const int ParseAxisLabels (const std::string &s, std::map< int, std::string > &labels)
 Parse Axis label string and return values in vector.

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 27 of file CSCDQM_Collection.cc.

References config.

                                                      {
    config = p_config;
  }

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 393 of file CSCDQM_Collection.cc.

References checkHistoValue(), config, debug_cff::d1, cscdqm::DEF_HISTO_COLOR, Exception, cscdqm::Configuration::fnBook, cscdqm::Configuration::fnPutHisto, cscdqm::HistoDef::getFullPath(), getHistoValue(), cscdqm::HistoDef::getName(), cscdqm::MonitorObject::getTH1Lock(), cscdqm::H1D, cscdqm::H2D, cscdqm::H3D, L1TDQM_cfg::labels, CommonMethods::lock(), LOG_INFO, cscdqm::Lock::mutex, AlCaRecoCosmics_cfg::name, cscdqm::Configuration::needBookMO(), NULL, ParseAxisLabels(), cscdqm::HistoDef::processTitle(), cscdqm::PROFILE, cscdqm::PROFILE2D, asciidump::s, cscdqm::MonitorObject::setAxisTitle(), cscdqm::MonitorObject::SetMaximum(), indexGen::title, cscdqm::Utility::tokenize(), cscdqm::LockType::unlock(), 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(), and bookEMUHistos().

                                                                                               {

    MonitorObject* me = NULL;
    std::string name = h.getName(), type, title, s;

    if (!config->needBookMO(h.getFullPath())) {
      LOG_INFO << "MOFilter excluded " << name << " from booking"; 
      config->fnPutHisto(h, me);
      return;
    }

    int i1, i2, i3;
    double d1, d2, d3, d4, d5, d6;
    bool ondemand = (getHistoValue(p, XML_BOOK_ONDEMAND, s, XML_BOOK_ONDEMAND_FALSE) == XML_BOOK_ONDEMAND_TRUE ? true : false);
      
    if (!checkHistoValue(p, XML_BOOK_HISTO_TYPE, type))   { throw Exception("Histogram does not have type!"); }
    checkHistoValue(p, XML_BOOK_HISTO_TITLE, title);

    if (ondemand) {
      title = h.processTitle(title);
    }

    if (type == "h1") {
      me = config->fnBook(
        HistoBookRequest(h, H1D, type, folder, title,
          getHistoValue(p, "XBins", i1, 1),
          getHistoValue(p, "XMin",  d1, 0),
          getHistoValue(p, "XMax",  d2, 1)));
    } else
    if(type == "h2") {
      me = config->fnBook(
        HistoBookRequest(h, H2D, type, folder, title,
          getHistoValue(p, "XBins", i1, 1),
          getHistoValue(p, "XMin",  d1, 0),
          getHistoValue(p, "XMax",  d2, 1),
          getHistoValue(p, "YBins", i2, 1),
          getHistoValue(p, "YMin",  d3, 0),
          getHistoValue(p, "YMax",  d4, 1)));
    } else
    if(type == "h3") {
      me = config->fnBook(
        HistoBookRequest(h, H3D, type, folder, title,
          getHistoValue(p, "XBins", i1, 1),
          getHistoValue(p, "XMin",  d1, 0),
          getHistoValue(p, "XMax",  d2, 1),
          getHistoValue(p, "YBins", i2, 1),
          getHistoValue(p, "YMin",  d3, 0),
          getHistoValue(p, "YMax",  d4, 1),
          getHistoValue(p, "ZBins", i3, 1),
          getHistoValue(p, "ZMin",  d5, 0),
          getHistoValue(p, "ZMax",  d6, 1)));
    } else
    if(type == "hp") {
      me = config->fnBook(
        HistoBookRequest(h, PROFILE, type, folder, title,
          getHistoValue(p, "XBins", i1, 1),
          getHistoValue(p, "XMin",  d1, 0),
          getHistoValue(p, "XMax",  d2, 1),
          getHistoValue(p, "YBins", i2, 1),
          getHistoValue(p, "YMin",  d3, 0),
          getHistoValue(p, "YMax",  d4, 1)));
    } else
    if(type == "hp2") {
      me = config->fnBook(
        HistoBookRequest(h, PROFILE2D, type, folder, title,
          getHistoValue(p, "XBins", i1, 1),
          getHistoValue(p, "XMin",  d1, 0),
          getHistoValue(p, "XMax",  d2, 1),
          getHistoValue(p, "YBins", i2, 1),
          getHistoValue(p, "YMin",  d3, 0),
          getHistoValue(p, "YMax",  d4, 1),
          getHistoValue(p, "ZBins", i3, 1),
          getHistoValue(p, "ZMin",  d5, 0),
          getHistoValue(p, "ZMax",  d6, 1)));
    } else { 
      throw Exception("Can not book histogram with type: " + type);
    }

    if(me != NULL) {

      LockType lock(me->mutex);
      TH1 *th = me->getTH1Lock();

      if(checkHistoValue(p, "XTitle", s)) {
        if (ondemand) {
          s = h.processTitle(s);
        }
        me->setAxisTitle(s, 1);
      }

      if(checkHistoValue(p, "YTitle", s)) {
        if (ondemand) {
          s = h.processTitle(s);
        }
        me->setAxisTitle(s, 2);
      }

      if(checkHistoValue(p, "ZTitle", s)) {
        if (ondemand) {
          s = h.processTitle(s);
        }
          me->setAxisTitle(s, 3);
        }

      if(checkHistoValue(p, "SetOption", s)) th->SetOption(s.c_str());
      if(checkHistoValue(p, "SetStats", i1)) th->SetStats(i1);
      th->SetFillColor(getHistoValue(p, "SetFillColor", i1, DEF_HISTO_COLOR));
      if(checkHistoValue(p, "SetXLabels", s)) {
        std::map<int, std::string> labels;
        ParseAxisLabels(s, labels);
        for (std::map<int, std::string>::iterator l_itr = labels.begin(); l_itr != labels.end(); ++l_itr) {
          th->GetXaxis()->SetBinLabel(l_itr->first, l_itr->second.c_str());
        }
      }
      if(checkHistoValue(p, "SetYLabels", s)) {
        std::map<int, std::string> labels;
        ParseAxisLabels(s, labels);
        for (std::map<int, std::string>::iterator l_itr = labels.begin(); l_itr != labels.end(); ++l_itr) {
          th->GetYaxis()->SetBinLabel(l_itr->first, l_itr->second.c_str());
        }
      }
      if(checkHistoValue(p, "LabelOption", s)) {
        std::vector<std::string> v;
        if(2 == Utility::tokenize(s, v, ",")) {
          th->LabelsOption(v[0].c_str(), v[1].c_str());
        }
      }
      if(checkHistoValue(p, "SetLabelSize", s)) {
        std::vector<std::string> v;
        if(2 == Utility::tokenize(s, v, ",")) {
          th->SetLabelSize((double) atof(v[0].c_str()), v[1].c_str());
        }
      }
      if(checkHistoValue(p, "SetTitleOffset", s)) {
        std::vector<std::string> v;
        if(2 == Utility::tokenize(s, v, ",")) {
          th->SetTitleOffset((double) atof(v[0].c_str()), v[1].c_str());
        }
      }
      if(checkHistoValue(p, "SetMinimum", d1)) th->SetMinimum(d1);
      if(checkHistoValue(p, "SetMaximum", d1)) me->SetMaximum(d1);
      if(checkHistoValue(p, "SetNdivisionsX", i1)) {
        th->SetNdivisions(i1, "X");
        th->GetXaxis()->CenterLabels(true);
      }
      if(checkHistoValue(p, "SetNdivisionsY", i1)) {
        th->SetNdivisions(i1, "Y");
        th->GetYaxis()->CenterLabels(true);
      }
      if(checkHistoValue(p, "SetTickLengthX", d1)) th->SetTickLength(d1, "X");
      if(checkHistoValue(p, "SetTickLengthY", d1)) th->SetTickLength(d1, "Y");
      if(checkHistoValue(p, "SetLabelSizeX", d1)) th->SetLabelSize(d1, "X");
      if(checkHistoValue(p, "SetLabelSizeY", d1)) th->SetLabelSize(d1, "Y");
      if(checkHistoValue(p, "SetLabelSizeZ", d1)) th->SetLabelSize(d1, "Z");
      if(checkHistoValue(p, "SetErrorOption", s)) reinterpret_cast<TProfile*>(th)->SetErrorOption(s.c_str());

      lock.unlock();

    }

    LOG_DEBUG << "[Collection::book] booked " << h.getFullPath() << " (" << me << ")"; 

    config->fnPutHisto(h, me);

  }
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 375 of file CSCDQM_Collection.cc.

References book(), collection, config, i, j, and h::names.

                                                                                                                {
    CoHistoMap::const_iterator i = collection.find("CSC");
    if (i != collection.end()) {
      CoHisto::const_iterator j = i->second.find(h::names[hid]);
      if (j != i->second.end()) {
        CSCHistoDef hdef(hid, crateId, dmbId, addId);
        book(hdef, j->second, config->getFOLDER_CSC());
      }
    }
  }
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 342 of file CSCDQM_Collection.cc.

References book(), checkHistoValue(), collection, config, Capri::details::from(), cscdqm::HistoDef::getHistoIdByName(), getHistoValue(), i, j, gen::k, asciidump::s, cscdqm::XML_BOOK_NAME_FROM, cscdqm::XML_BOOK_NAME_TO, cscdqm::XML_BOOK_ONDEMAND, and cscdqm::XML_BOOK_ONDEMAND_FALSE.

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

                                                                           {
    CoHistoMap::const_iterator i = collection.find("CSC");
    if (i != collection.end()) {
      const CoHisto hs = i->second;
      for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
        std::string s = "";
        HistoId hid = 0;
        if (HistoDef::getHistoIdByName(j->first, hid)) {
          if (getHistoValue(j->second, XML_BOOK_ONDEMAND, s, XML_BOOK_ONDEMAND_FALSE) == XML_BOOK_ONDEMAND_FALSE) {
            CSCHistoDef hdef(hid, crateId, dmbId);
            book(hdef, j->second, config->getFOLDER_CSC());
          } else {
            int from = 0, to = 0;
            if (checkHistoValue(j->second, XML_BOOK_NAME_FROM, from) && checkHistoValue(j->second, XML_BOOK_NAME_TO, to)) {
              for (int k = from; k <= to; k++) {
                CSCHistoDef hdef(hid, crateId, dmbId, k);
                book(hdef, j->second, config->getFOLDER_CSC());
              }
            }
          }
        }
      }
    }
  }
void cscdqm::Collection::bookDDUHistos ( const HwId  dduId) const

Book DDU histograms.

Parameters:
dduIdDDU Id
Returns:

Definition at line 319 of file CSCDQM_Collection.cc.

References book(), collection, config, cscdqm::HistoDef::getHistoIdByName(), getHistoValue(), i, j, asciidump::s, cscdqm::XML_BOOK_ONDEMAND, and cscdqm::XML_BOOK_ONDEMAND_FALSE.

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

                                                       {
    CoHistoMap::const_iterator i = collection.find("DDU");
    if (i != collection.end()) {
      const CoHisto hs = i->second;
      for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
        std::string s = "";
        if (getHistoValue(j->second, XML_BOOK_ONDEMAND, s, XML_BOOK_ONDEMAND_FALSE) == XML_BOOK_ONDEMAND_FALSE) {
          HistoId hid = 0;
          if (HistoDef::getHistoIdByName(j->first, hid)) {
            DDUHistoDef hdef(hid, dduId);
            book(hdef, j->second, config->getFOLDER_DDU());
          }
        }
      }
    }
  }
void cscdqm::Collection::bookEMUHistos ( ) const

Book EMU histograms.

Returns:

Definition at line 297 of file CSCDQM_Collection.cc.

References book(), collection, config, cscdqm::HistoDef::getHistoIdByName(), getHistoValue(), i, j, asciidump::s, cscdqm::XML_BOOK_ONDEMAND, and cscdqm::XML_BOOK_ONDEMAND_FALSE.

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

                                       {
    CoHistoMap::const_iterator i = collection.find("EMU");
    if (i != collection.end()) {
      const CoHisto hs = i->second;
      for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
        std::string s = "";
        if (getHistoValue(j->second, XML_BOOK_ONDEMAND, s, XML_BOOK_ONDEMAND_FALSE) == XML_BOOK_ONDEMAND_FALSE) {
          HistoId hid = 0;
          if (HistoDef::getHistoIdByName(j->first, hid)) {
            EMUHistoDef hdef(hid);
            book(hdef, j->second, config->getFOLDER_EMU());
          }
        }
      }
    }
  }
const bool cscdqm::Collection::checkHistoValue ( const CoHistoProps h,
const std::string &  name,
std::string &  value 
) [static, private]

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 175 of file CSCDQM_Collection.cc.

References i.

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

                                                                                                       {
    CoHistoProps::const_iterator i = h.find(name);
    if(i == h.end()) {
      return false;
    }
    value = i->second;
    return true;
  }
const bool cscdqm::Collection::checkHistoValue ( const CoHistoProps h,
const std::string &  name,
int &  value 
) [static, private]

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 191 of file CSCDQM_Collection.cc.

References i, and relativeConstraints::value.

                                                                                                 {
    CoHistoProps::const_iterator i = h.find(name);
    if(i == h.end()) {
      return false;
    } 
    if(EOF == std::sscanf(i->second.c_str(), "%d", &value)) {
      return false;
    }
    return true;
  }
const bool cscdqm::Collection::checkHistoValue ( const CoHistoProps h,
const std::string  name,
double &  value 
) [static, private]

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 210 of file CSCDQM_Collection.cc.

References i, and relativeConstraints::value.

                                                                                                   {
    CoHistoProps::const_iterator i = h.find(name);
    if(i == h.end()) {
      return false;
    }
    if(EOF == std::sscanf(i->second.c_str(), "%lf", &value)) {
      return false;
    }
    return true;
  }
std::string & cscdqm::Collection::getHistoValue ( const CoHistoProps h,
const std::string &  name,
std::string &  value,
const std::string &  def_value = "" 
) [static, private]

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 229 of file CSCDQM_Collection.cc.

References checkHistoValue(), and relativeConstraints::value.

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

                                                                                                                                 {
    if (!checkHistoValue(h, name, value)) {
      value = def_value;
    }
    return value;
  }
double & cscdqm::Collection::getHistoValue ( const CoHistoProps h,
const std::string  name,
double &  value,
const int  def_value = 0.0 
) [static, private]

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 259 of file CSCDQM_Collection.cc.

References checkHistoValue(), and relativeConstraints::value.

                                                                                                                   {
    if (!checkHistoValue(h, name, value)) {
      value = def_value;
    }
    return value;
  }
int & cscdqm::Collection::getHistoValue ( const CoHistoProps h,
const std::string &  name,
int &  value,
const int &  def_value = 0 
) [static, private]

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 244 of file CSCDQM_Collection.cc.

References checkHistoValue(), and relativeConstraints::value.

                                                                                                               {
    if (!checkHistoValue(h, name, value)) {
      value = def_value;
    }
    return value;
  }
void cscdqm::Collection::getNodeProperties ( DOMNode *&  node,
CoHistoProps p 
) [static, private]

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

Parameters:
nodeXML node
pList of properties to fill
Returns:

Definition at line 148 of file CSCDQM_Collection.cc.

References asciidump::attributes, i, j, AlCaRecoCosmics_cfg::name, and relativeConstraints::value.

Referenced by load().

                                                                    {
    DOMNodeList *props  = node->getChildNodes();
    for(uint32_t j = 0; j < props->getLength(); j++) {
      DOMNode* node = props->item(j);
      if (node->getNodeType() != DOMNode::ELEMENT_NODE) { continue; }
      std::string name  = XMLString::transcode(node->getNodeName());
      std::string value = XMLString::transcode(node->getTextContent());
      DOMNamedNodeMap* attributes = node->getAttributes();
      if (attributes) {
        for (uint32_t i = 0; i < attributes->getLength(); i++) {
          DOMNode* attribute = attributes->item(i);
          std::string aname  = XMLString::transcode(attribute->getNodeName());
          std::string avalue = XMLString::transcode(attribute->getNodeValue());
          p[name + "_" + aname] = avalue;
        }
      }
      p[name] = value;
    }
  }
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 566 of file CSCDQM_Collection.cc.

References collection, getHistoValue(), i, j, asciidump::s, cscdqm::XML_BOOK_ONDEMAND, cscdqm::XML_BOOK_ONDEMAND_FALSE, and cscdqm::XML_BOOK_ONDEMAND_TRUE.

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

                                                               {
    CoHistoMap::const_iterator i = collection.find("CSC");
    if (i != collection.end()) {
      CoHisto hs  = i->second;
      CoHisto::const_iterator j = hs.find(name);
      if (j != hs.end()) { 
        std::string s;
        return (getHistoValue(j->second, XML_BOOK_ONDEMAND, s, XML_BOOK_ONDEMAND_FALSE) == XML_BOOK_ONDEMAND_TRUE);
      }
    }
    return false;
  }
void cscdqm::Collection::load ( )

Load XML file and fill definition map(s)

Returns:

Load histogram definition

Load histogram

Definition at line 36 of file CSCDQM_Collection.cc.

References collection, config, asciidump::doc, ExpressReco_HICollisions_FallBack::e, Exception, getNodeProperties(), h, i, ExpressReco_HICollisions_FallBack::id, LOG_INFO, argparse::message, AlCaRecoCosmics_cfg::name, python::Node::node, geometryXMLtoCSV::parser, prof2calltree::prefix, edm::regexMatch(), cscdqm::REGEXP_ONDEMAND(), 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().

                        {

    LOG_INFO << "Reading histograms from " << config->getBOOKING_XML_FILE();

    if (config->getBOOKING_XML_FILE().empty()) {
      return;
    }

    try {

      XMLPlatformUtils::Initialize();

      {

        XercesDOMParser parser;

        parser.setValidationScheme(XercesDOMParser::Val_Always);
        parser.setDoNamespaces(true);
        parser.setDoSchema(true);
        parser.setExitOnFirstFatalError(true);
        parser.setValidationConstraintFatal(true);
        XMLFileErrorHandler eh;
        parser.setErrorHandler(&eh);

        parser.parse(config->getBOOKING_XML_FILE().c_str());
        DOMDocument *doc = parser.getDocument();
        DOMNode *docNode = (DOMNode*) doc->getDocumentElement();
  
        DOMNodeList *itemList = docNode->getChildNodes();

        CoHisto definitions;
        for (uint32_t i = 0; i < itemList->getLength(); i++) {
  
          DOMNode* node = itemList->item(i);
          if (node->getNodeType() != DOMNode::ELEMENT_NODE) { continue; }

          std::string nodeName = XMLString::transcode(node->getNodeName());

          if (nodeName.compare(XML_BOOK_DEFINITION) == 0) {

            CoHistoProps dp;
            getNodeProperties(node, dp);

            DOMElement* el = dynamic_cast<DOMElement*>(node);
            std::string id(XMLString::transcode(el->getAttribute(XMLString::transcode(XML_BOOK_DEFINITION_ID))));
            definitions.insert(make_pair(id, dp));

          } else

          if (nodeName.compare(XML_BOOK_HISTOGRAM) == 0) {
  
            CoHistoProps hp;

            DOMElement* el = dynamic_cast<DOMElement*>(node);
            if (el->hasAttribute(XMLString::transcode(XML_BOOK_DEFINITION_REF))) {
              std::string id(XMLString::transcode(el->getAttribute(XMLString::transcode(XML_BOOK_DEFINITION_REF))));
              CoHistoProps d = definitions[id];
              for (CoHistoProps::iterator it = d.begin(); it != d.end(); it++) {
                hp[it->first] = it->second;
              }
            }

            getNodeProperties(node, hp);

            std::string name   = hp[XML_BOOK_HISTO_NAME];
            std::string prefix = hp[XML_BOOK_HISTO_PREFIX];

            // Check if this histogram is an ON DEMAND histogram?
            hp[XML_BOOK_ONDEMAND] = (Utility::regexMatch(REGEXP_ONDEMAND, name) ? XML_BOOK_ONDEMAND_TRUE : XML_BOOK_ONDEMAND_FALSE );

            LOG_DEBUG << "[Collection::load] loading " << prefix << "::" << name << " XML_BOOK_ONDEMAND = " << hp[XML_BOOK_ONDEMAND]; 
  
            CoHistoMap::iterator it = collection.find(prefix);
            if (it == collection.end()) {
              CoHisto h;
              h[name] = hp;
              collection[prefix] = h; 
            } else {
              it->second.insert(make_pair(name, hp));
            }

          }
        }

      }

      XMLPlatformUtils::Terminate();

    } catch (XMLException& e) {
      char* message = XMLString::transcode(e.getMessage());
      throw Exception(message);
    }

    for (CoHistoMap::const_iterator i = collection.begin(); i != collection.end(); i++) {
      LOG_INFO << i->second.size() << " " << i->first << " histograms defined";
    }
    
  }
const int cscdqm::Collection::ParseAxisLabels ( const std::string &  s,
std::map< int, std::string > &  labels 
) [static, private]

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 272 of file CSCDQM_Collection.cc.

References label, NULL, pos, asciidump::s, and tmp.

Referenced by book().

                                                                                          {
    std::string tmp = s;
    std::string::size_type pos = tmp.find("|");
    char* stopstring = NULL;
  
    while (pos != std::string::npos) {
      std::string label_pair = tmp.substr(0, pos);
      tmp.replace(0, pos + 1, "");
      if (label_pair.find("=") != std::string::npos) {
        int nbin = strtol(label_pair.substr(0, label_pair.find("=")).c_str(), &stopstring, 10);
        std::string label = label_pair.substr(label_pair.find("=") + 1, label_pair.length());
        while (label.find("\'") != std::string::npos) {
          label.erase(label.find("\'"), 1);
        }
        labels[nbin] = label;
      }
      pos = tmp.find("|");
    }
    return labels.size();
  }
void cscdqm::Collection::printCollection ( ) const

Print collection of available histograms and their parameters.

Returns:

Definition at line 583 of file CSCDQM_Collection.cc.

References collection, and LOG_INFO.

                                        {

    std::ostringstream buffer;
    for(CoHistoMap::const_iterator hdmi = collection.begin(); hdmi != collection.end(); hdmi++) {
      buffer << hdmi->first << " [" << std::endl;
      for(CoHisto::const_iterator hdi = hdmi->second.begin(); hdi != hdmi->second.end(); hdi++) {
        buffer << "   " << hdi->first << " [" << std::endl;
        for(CoHistoProps::const_iterator hi = hdi->second.begin(); hi != hdi->second.end(); hi++) {
          buffer << "     " << hi->first << " = " << hi->second << std::endl;
        }
        buffer << "   ]" << std::endl;
      }
      buffer << " ]" << std::endl;
    }
    LOG_INFO << buffer.str();
  }

Member Data Documentation

Definition at line 111 of file CSCDQM_Collection.h.

Referenced by book(), bookCSCHistos(), bookDDUHistos(), bookEMUHistos(), Collection(), and load().