Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:09:27

0001 /*  =====================================================================================
0002  *
0003  *       Filename:  CSCDQM_Collection.cc
0004  *
0005  *    Description:  Histogram booking code
0006  *
0007  *        Version:  1.0
0008  *        Created:  04/18/2008 03:39:49 PM
0009  *       Revision:  none
0010  *       Compiler:  gcc
0011  *
0012  *         Author:  Valdas Rapsevicius (VR), Valdas.Rapsevicius@cern.ch
0013  *        Company:  CERN, CH
0014  *
0015  *  =====================================================================================
0016  */
0017 
0018 #include "CSCDQM_Collection.h"
0019 #include "Utilities/Xerces/interface/Xerces.h"
0020 #include <cstdio>
0021 #include <string>
0022 #include <xercesc/util/XMLString.hpp>
0023 #include <xercesc/util/TransService.hpp>
0024 
0025 namespace cscdqm {
0026 
0027   /**
0028    * @brief  Constructor
0029    * @param  p_config Pointer to Global configuration object
0030    */
0031   Collection::Collection(Configuration* const p_config) { config = p_config; }
0032 
0033   /**
0034    * @brief  Load XML file and fill definition map(s)
0035    * @return 
0036    */
0037   void Collection::load() {
0038     LOG_INFO << "Reading histograms from " << config->getBOOKING_XML_FILE();
0039 
0040     if (config->getBOOKING_XML_FILE().empty()) {
0041       return;
0042     }
0043 
0044     try {
0045       cms::concurrency::xercesInitialize();
0046       {
0047         XercesDOMParser parser;
0048 
0049         parser.setValidationScheme(XercesDOMParser::Val_Always);
0050         parser.setDoNamespaces(true);
0051         parser.setDoSchema(true);
0052         parser.setExitOnFirstFatalError(true);
0053         parser.setValidationConstraintFatal(true);
0054         XMLFileErrorHandler eh;
0055         parser.setErrorHandler(&eh);
0056         parser.parse(config->getBOOKING_XML_FILE().c_str());
0057 
0058         DOMDocument* doc = parser.getDocument();
0059         DOMElement* docNode = doc->getDocumentElement();
0060         DOMNodeList* itemList = docNode->getChildNodes();
0061 
0062         CoHisto definitions;
0063         for (XMLSize_t i = 0; i < itemList->getLength(); i++) {
0064           DOMNode* node = itemList->item(i);
0065           if (node->getNodeType() != DOMNode::ELEMENT_NODE) {
0066             continue;
0067           }
0068 
0069           std::string nodeName = XMLString::transcode(node->getNodeName());
0070 
0071           ///
0072           /// Load histogram definition
0073           ///
0074           if (nodeName == XML_BOOK_DEFINITION) {
0075             CoHistoProps dp;
0076             getNodeProperties(node, dp);
0077 
0078             DOMElement* el = dynamic_cast<DOMElement*>(node);
0079             std::string id(XMLString::transcode(el->getAttribute(XMLString::transcode(XML_BOOK_DEFINITION_ID))));
0080             definitions.insert(make_pair(id, dp));
0081 
0082           } else
0083 
0084               ///
0085               /// Load histogram
0086               ///
0087               if (nodeName == XML_BOOK_HISTOGRAM) {
0088             CoHistoProps hp;
0089 
0090             DOMElement* el = dynamic_cast<DOMElement*>(node);
0091             if (el->hasAttribute(XMLString::transcode(XML_BOOK_DEFINITION_REF))) {
0092               std::string id(XMLString::transcode(el->getAttribute(XMLString::transcode(XML_BOOK_DEFINITION_REF))));
0093 
0094               CoHistoProps d = definitions[id];
0095               for (CoHistoProps::iterator it = d.begin(); it != d.end(); it++) {
0096                 hp[it->first] = it->second;
0097               }
0098             }
0099 
0100             getNodeProperties(node, hp);
0101 
0102             std::string name = hp[XML_BOOK_HISTO_NAME];
0103             std::string prefix = hp[XML_BOOK_HISTO_PREFIX];
0104 
0105             // Check if this histogram is an ON DEMAND histogram?
0106             hp[XML_BOOK_ONDEMAND] =
0107                 (Utility::regexMatch(REGEXP_ONDEMAND, name) ? XML_BOOK_ONDEMAND_TRUE : XML_BOOK_ONDEMAND_FALSE);
0108 
0109             LOG_DEBUG << "[Collection::load] loading " << prefix << "::" << name
0110                       << " XML_BOOK_ONDEMAND = " << hp[XML_BOOK_ONDEMAND];
0111 
0112             CoHistoMap::iterator it = collection.find(prefix);
0113             if (it == collection.end()) {
0114               CoHisto h;
0115               h[name] = hp;
0116               collection[prefix] = h;
0117             } else {
0118               it->second.insert(make_pair(name, hp));
0119             }
0120           }
0121         }
0122       }
0123 
0124       cms::concurrency::xercesTerminate();
0125 
0126     } catch (XMLException& e) {
0127       char* message = XMLString::transcode(e.getMessage());
0128       throw Exception(message);
0129     }
0130 
0131     for (CoHistoMap::const_iterator i = collection.begin(); i != collection.end(); i++) {
0132       LOG_INFO << i->second.size() << " " << i->first << " histograms defined";
0133     }
0134   }
0135 
0136   /**
0137    * @brief  Extract and write single histogram properties from XML node to
0138    * map.
0139    * @param  node XML node
0140    * @param  p List of properties to fill
0141    * @return 
0142    */
0143 
0144   void Collection::getNodeProperties(DOMNode*& node, CoHistoProps& p) {
0145     DOMNodeList* props = node->getChildNodes();
0146 
0147     for (XMLSize_t j = 0; j < props->getLength(); j++) {
0148       DOMNode* node = props->item(j);
0149       if (node->getNodeType() != DOMNode::ELEMENT_NODE) {
0150         continue;
0151       }
0152       DOMElement* element = dynamic_cast<DOMElement*>(node);
0153       std::string name = XMLString::transcode(element->getNodeName());
0154 
0155       const XMLCh* content = element->getTextContent();
0156       XERCES_CPP_NAMESPACE_QUALIFIER TranscodeToStr tc(content, "UTF-8");
0157       std::istringstream buffer((const char*)tc.str());
0158       std::string value = buffer.str();
0159 
0160       DOMNamedNodeMap* attributes = node->getAttributes();
0161       if (attributes) {
0162         for (XMLSize_t i = 0; i < attributes->getLength(); i++) {
0163           DOMNode* attribute = attributes->item(i);
0164           std::string aname = XMLString::transcode(attribute->getNodeName());
0165           std::string avalue = XMLString::transcode(attribute->getNodeValue());
0166           p[name + "_" + aname] = avalue;
0167         }
0168       }
0169       p[name] = value;
0170     }
0171   }
0172 
0173   /**
0174    * @brief  Find string histogram value in map
0175    * @param  h Histogram map
0176    * @param  name parameter name
0177    * @param  value handler for parameter value
0178    * @return true if parameter found and filled, false - otherwise
0179    */
0180   const bool Collection::checkHistoValue(const CoHistoProps& h, const std::string& name, std::string& value) {
0181     CoHistoProps::const_iterator i = h.find(name);
0182     if (i == h.end()) {
0183       return false;
0184     }
0185     value = i->second;
0186     return true;
0187   }
0188 
0189   /**
0190    * @brief  get Histogram int value out of the map and return boolean result
0191    * @param  h Histogram map
0192    * @param  name parameter name
0193    * @param  value handler for parameter value
0194    * @return true if parameter found and filled, false - otherwise
0195    */
0196   const bool Collection::checkHistoValue(const CoHistoProps& h, const std::string& name, int& value) {
0197     CoHistoProps::const_iterator i = h.find(name);
0198     if (i == h.end()) {
0199       return false;
0200     }
0201     if (EOF == std::sscanf(i->second.c_str(), "%d", &value)) {
0202       return false;
0203     }
0204     return true;
0205   }
0206 
0207   /**
0208    * @brief  get Histogram double value out of the map and return boolean
0209    * result
0210    * @param  h Histogram map
0211    * @param  name parameter name
0212    * @param  value handler for parameter value
0213    * @return true if parameter found and filled, false - otherwise
0214    */
0215   const bool Collection::checkHistoValue(const CoHistoProps& h, const std::string name, double& value) {
0216     CoHistoProps::const_iterator i = h.find(name);
0217     if (i == h.end()) {
0218       return false;
0219     }
0220     if (EOF == std::sscanf(i->second.c_str(), "%lf", &value)) {
0221       return false;
0222     }
0223     return true;
0224   }
0225 
0226   /**
0227    * @brief  Find string histogram value in map
0228    * @param  h Histogram map
0229    * @param  name parameter name
0230    * @param  value handler for parameter value
0231    * @param  def_value default value if parameter not found 
0232    * @return pointer to value
0233    */
0234   std::string& Collection::getHistoValue(const CoHistoProps& h,
0235                                          const std::string& name,
0236                                          std::string& value,
0237                                          const std::string& def_value) {
0238     if (!checkHistoValue(h, name, value)) {
0239       value = def_value;
0240     }
0241     return value;
0242   }
0243 
0244   /**
0245    * @brief  get Histogram int value out of the map and 
0246    * @param  h Histogram map
0247    * @param  name parameter name
0248    * @param  value handler for parameter value
0249    * @param  def_value default value if parameter not found 
0250    * @return pointer to value
0251    */
0252   int& Collection::getHistoValue(const CoHistoProps& h, const std::string& name, int& value, const int& def_value) {
0253     if (!checkHistoValue(h, name, value)) {
0254       value = def_value;
0255     }
0256     return value;
0257   }
0258 
0259   /**
0260    * @brief  get Histogram double value out of the map and 
0261    * @param  h Histogram map
0262    * @param  name parameter name
0263    * @param  value handler for parameter value
0264    * @param  def_value default value if parameter not found 
0265    * @return pointer to value
0266    */
0267   double& Collection::getHistoValue(const CoHistoProps& h, const std::string name, double& value, const int def_value) {
0268     if (!checkHistoValue(h, name, value)) {
0269       value = def_value;
0270     }
0271     return value;
0272   }
0273 
0274   /**
0275    * @brief  Parse Axis label string and return values in vector
0276    * @param  s source string to parse
0277    * @param  labels pointer to result vector
0278    * @return number of labels found
0279    */
0280   const int Collection::ParseAxisLabels(const std::string& s, std::map<int, std::string>& labels) {
0281     std::string tmp = s;
0282     std::string::size_type pos = tmp.find('|');
0283     char* stopstring = nullptr;
0284 
0285     while (pos != std::string::npos) {
0286       std::string label_pair = tmp.substr(0, pos);
0287       tmp.replace(0, pos + 1, "");
0288       if (label_pair.find('=') != std::string::npos) {
0289         int nbin = strtol(label_pair.substr(0, label_pair.find('=')).c_str(), &stopstring, 10);
0290         std::string label = label_pair.substr(label_pair.find('=') + 1, label_pair.length());
0291         while (label.find('\'') != std::string::npos) {
0292           label.erase(label.find('\''), 1);
0293         }
0294         labels[nbin] = label;
0295       }
0296       pos = tmp.find('|');
0297     }
0298     return labels.size();
0299   }
0300 
0301   /**
0302    * @brief  Book EMU histograms
0303    * @return 
0304    */
0305   void Collection::bookEMUHistos() const {
0306     CoHistoMap::const_iterator i = collection.find("EMU");
0307     if (i != collection.end()) {
0308       const CoHisto hs = i->second;
0309       for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
0310         std::string s = "";
0311         if (getHistoValue(j->second, XML_BOOK_ONDEMAND, s, XML_BOOK_ONDEMAND_FALSE) == XML_BOOK_ONDEMAND_FALSE) {
0312           HistoId hid = 0;
0313           if (HistoDef::getHistoIdByName(j->first, hid)) {
0314             EMUHistoDef hdef(hid);
0315             book(hdef, j->second, config->getFOLDER_EMU());
0316           }
0317         }
0318       }
0319     }
0320   }
0321 
0322   /**
0323    * @brief  Book FED histograms
0324    * @param  fedId FED Id
0325    * @return 
0326    */
0327   void Collection::bookFEDHistos(const HwId fedId) const {
0328     CoHistoMap::const_iterator i = collection.find("FED");
0329     if (i != collection.end()) {
0330       const CoHisto hs = i->second;
0331       for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
0332         std::string s = "";
0333         if (getHistoValue(j->second, XML_BOOK_ONDEMAND, s, XML_BOOK_ONDEMAND_FALSE) == XML_BOOK_ONDEMAND_FALSE) {
0334           HistoId hid = 0;
0335           if (HistoDef::getHistoIdByName(j->first, hid)) {
0336             FEDHistoDef hdef(hid, fedId);
0337             book(hdef, j->second, config->getFOLDER_FED());
0338           }
0339         }
0340       }
0341     }
0342   }
0343 
0344   /**
0345    * @brief  Book DDU histograms
0346    * @param  dduId DDU Id
0347    * @return 
0348    */
0349   void Collection::bookDDUHistos(const HwId dduId) const {
0350     CoHistoMap::const_iterator i = collection.find("DDU");
0351     if (i != collection.end()) {
0352       const CoHisto hs = i->second;
0353       for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
0354         std::string s = "";
0355         if (getHistoValue(j->second, XML_BOOK_ONDEMAND, s, XML_BOOK_ONDEMAND_FALSE) == XML_BOOK_ONDEMAND_FALSE) {
0356           HistoId hid = 0;
0357           if (HistoDef::getHistoIdByName(j->first, hid)) {
0358             DDUHistoDef hdef(hid, dduId);
0359             book(hdef, j->second, config->getFOLDER_DDU());
0360           }
0361         }
0362       }
0363     }
0364   }
0365 
0366   /**
0367    * @brief  Book Chamber Histograms
0368    * @param  crateId CSC Crate Id
0369    * @param  dmbId CSC DMB Id
0370    * @return 
0371    */
0372   void Collection::bookCSCHistos(const HwId crateId, const HwId dmbId) const {
0373     CoHistoMap::const_iterator i = collection.find("CSC");
0374     if (i != collection.end()) {
0375       const CoHisto hs = i->second;
0376       for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
0377         std::string s = "";
0378         HistoId hid = 0;
0379         if (HistoDef::getHistoIdByName(j->first, hid)) {
0380           if (getHistoValue(j->second, XML_BOOK_ONDEMAND, s, XML_BOOK_ONDEMAND_FALSE) == XML_BOOK_ONDEMAND_FALSE) {
0381             CSCHistoDef hdef(hid, crateId, dmbId);
0382             book(hdef, j->second, config->getFOLDER_CSC());
0383           } else {
0384             int from = 0, to = 0;
0385             if (checkHistoValue(j->second, XML_BOOK_NAME_FROM, from) &&
0386                 checkHistoValue(j->second, XML_BOOK_NAME_TO, to)) {
0387               for (int k = from; k <= to; k++) {
0388                 CSCHistoDef hdef(hid, crateId, dmbId, k);
0389                 book(hdef, j->second, config->getFOLDER_CSC());
0390               }
0391             }
0392           }
0393         }
0394       }
0395     }
0396   }
0397 
0398   /**
0399    * @brief  Book Chamber Histogram with additional identifier (On Demand)
0400    * @param  hid Histogram Identifier
0401    * @param  crateId CSC Crate Id
0402    * @param  dmbId CSC DMB Id
0403    * @param  addId CSC Additional identifier, ex. Layer Id, ALCT Id, etc.
0404    * @return 
0405    */
0406   void Collection::bookCSCHistos(const HistoId hid, const HwId crateId, const HwId dmbId, const HwId addId) const {
0407     CoHistoMap::const_iterator i = collection.find("CSC");
0408     if (i != collection.end()) {
0409       CoHisto::const_iterator j = i->second.find(h::names[hid]);
0410       if (j != i->second.end()) {
0411         CSCHistoDef hdef(hid, crateId, dmbId, addId);
0412         book(hdef, j->second, config->getFOLDER_CSC());
0413       }
0414     }
0415   }
0416 
0417   /**
0418    * @brief  Book histogram
0419    * @param  h Histogram definition to book
0420    * @param  p Map of Histogram properties
0421    * @param  folder folder to book histograms to
0422    * @return 
0423    */
0424   void Collection::book(const HistoDef& h, const CoHistoProps& p, const std::string& folder) const {
0425     MonitorObject* me = nullptr;
0426     std::string name = h.getName(), type, title, s;
0427 
0428     /** Check if this histogram is included in booking by filters */
0429     if (!config->needBookMO(h.getFullPath())) {
0430       LOG_INFO << "MOFilter excluded " << name << " from booking";
0431       config->fnPutHisto(h, me);
0432       return;
0433     }
0434 
0435     int i1, i2, i3;
0436     double d1, d2, d3, d4, d5, d6;
0437     bool ondemand =
0438         (getHistoValue(p, XML_BOOK_ONDEMAND, s, XML_BOOK_ONDEMAND_FALSE) == XML_BOOK_ONDEMAND_TRUE ? true : false);
0439 
0440     if (!checkHistoValue(p, XML_BOOK_HISTO_TYPE, type)) {
0441       throw Exception("Histogram does not have type!");
0442     }
0443     checkHistoValue(p, XML_BOOK_HISTO_TITLE, title);
0444 
0445     if (ondemand) {
0446       title = h.processTitle(title);
0447     }
0448 
0449     if (type == "h1") {
0450       me = config->fnBook(HistoBookRequest(h,
0451                                            H1D,
0452                                            type,
0453                                            folder,
0454                                            title,
0455                                            getHistoValue(p, "XBins", i1, 1),
0456                                            getHistoValue(p, "XMin", d1, 0),
0457                                            getHistoValue(p, "XMax", d2, 1)));
0458     } else if (type == "h2") {
0459       me = config->fnBook(HistoBookRequest(h,
0460                                            H2D,
0461                                            type,
0462                                            folder,
0463                                            title,
0464                                            getHistoValue(p, "XBins", i1, 1),
0465                                            getHistoValue(p, "XMin", d1, 0),
0466                                            getHistoValue(p, "XMax", d2, 1),
0467                                            getHistoValue(p, "YBins", i2, 1),
0468                                            getHistoValue(p, "YMin", d3, 0),
0469                                            getHistoValue(p, "YMax", d4, 1)));
0470     } else if (type == "h3") {
0471       me = config->fnBook(HistoBookRequest(h,
0472                                            H3D,
0473                                            type,
0474                                            folder,
0475                                            title,
0476                                            getHistoValue(p, "XBins", i1, 1),
0477                                            getHistoValue(p, "XMin", d1, 0),
0478                                            getHistoValue(p, "XMax", d2, 1),
0479                                            getHistoValue(p, "YBins", i2, 1),
0480                                            getHistoValue(p, "YMin", d3, 0),
0481                                            getHistoValue(p, "YMax", d4, 1),
0482                                            getHistoValue(p, "ZBins", i3, 1),
0483                                            getHistoValue(p, "ZMin", d5, 0),
0484                                            getHistoValue(p, "ZMax", d6, 1)));
0485     } else if (type == "hp") {
0486       me = config->fnBook(HistoBookRequest(h,
0487                                            PROFILE,
0488                                            type,
0489                                            folder,
0490                                            title,
0491                                            getHistoValue(p, "XBins", i1, 1),
0492                                            getHistoValue(p, "XMin", d1, 0),
0493                                            getHistoValue(p, "XMax", d2, 1)));
0494       /*
0495         HistoBookRequest(h, PROFILE, type, folder, title,
0496           getHistoValue(p, "XBins", i1, 1),
0497           getHistoValue(p, "XMin",  d1, 0),
0498           getHistoValue(p, "XMax",  d2, 1),
0499           getHistoValue(p, "YBins", i2, 1),
0500           getHistoValue(p, "YMin",  d3, 0),
0501           getHistoValue(p, "YMax",  d4, 1)));
0502     */
0503     } else if (type == "hp2") {
0504       me = config->fnBook(HistoBookRequest(h,
0505                                            PROFILE2D,
0506                                            type,
0507                                            folder,
0508                                            title,
0509                                            getHistoValue(p, "XBins", i1, 1),
0510                                            getHistoValue(p, "XMin", d1, 0),
0511                                            getHistoValue(p, "XMax", d2, 1),
0512                                            getHistoValue(p, "YBins", i2, 1),
0513                                            getHistoValue(p, "YMin", d3, 0),
0514                                            getHistoValue(p, "YMax", d4, 1),
0515                                            getHistoValue(p, "ZBins", i3, 1),
0516                                            getHistoValue(p, "ZMin", d5, 0),
0517                                            getHistoValue(p, "ZMax", d6, 1)));
0518     } else {
0519       throw Exception("Can not book histogram with type: " + type);
0520     }
0521 
0522     if (me != nullptr) {
0523       LockType lock(me->mutex);
0524       TH1* th = me->getTH1Lock();
0525 
0526       if (checkHistoValue(p, "XTitle", s)) {
0527         if (ondemand) {
0528           s = h.processTitle(s);
0529         }
0530         me->setAxisTitle(s, 1);
0531       }
0532 
0533       if (checkHistoValue(p, "YTitle", s)) {
0534         if (ondemand) {
0535           s = h.processTitle(s);
0536         }
0537         me->setAxisTitle(s, 2);
0538       }
0539 
0540       if (checkHistoValue(p, "ZTitle", s)) {
0541         if (ondemand) {
0542           s = h.processTitle(s);
0543         }
0544         me->setAxisTitle(s, 3);
0545       }
0546 
0547       if (checkHistoValue(p, "SetOption", s))
0548         th->SetOption(s.c_str());
0549       if (checkHistoValue(p, "SetStats", i1))
0550         th->SetStats(i1);
0551       th->SetFillColor(getHistoValue(p, "SetFillColor", i1, DEF_HISTO_COLOR));
0552       if (checkHistoValue(p, "SetXLabels", s)) {
0553         std::map<int, std::string> labels;
0554         ParseAxisLabels(s, labels);
0555         th->GetXaxis()->SetNoAlphanumeric();  // For ROOT6 to prevent getting zero means values
0556         for (std::map<int, std::string>::iterator l_itr = labels.begin(); l_itr != labels.end(); ++l_itr) {
0557           th->GetXaxis()->SetBinLabel(l_itr->first, l_itr->second.c_str());
0558         }
0559       }
0560       if (checkHistoValue(p, "SetYLabels", s)) {
0561         std::map<int, std::string> labels;
0562         ParseAxisLabels(s, labels);
0563         th->GetYaxis()->SetNoAlphanumeric();  // For ROOT6 to prevent getting zero means values
0564         for (std::map<int, std::string>::iterator l_itr = labels.begin(); l_itr != labels.end(); ++l_itr) {
0565           th->GetYaxis()->SetBinLabel(l_itr->first, l_itr->second.c_str());
0566         }
0567       }
0568       if (checkHistoValue(p, "LabelOption", s)) {
0569         std::vector<std::string> v;
0570         if (2 == Utility::tokenize(s, v, ",")) {
0571           th->LabelsOption(v[0].c_str(), v[1].c_str());
0572         }
0573       }
0574       if (checkHistoValue(p, "SetLabelSize", s)) {
0575         std::vector<std::string> v;
0576         if (2 == Utility::tokenize(s, v, ",")) {
0577           th->SetLabelSize((double)atof(v[0].c_str()), v[1].c_str());
0578         }
0579       }
0580       if (checkHistoValue(p, "SetTitleOffset", s)) {
0581         std::vector<std::string> v;
0582         if (2 == Utility::tokenize(s, v, ",")) {
0583           th->SetTitleOffset((double)atof(v[0].c_str()), v[1].c_str());
0584         }
0585       }
0586       if (checkHistoValue(p, "SetMinimum", d1))
0587         th->SetMinimum(d1);
0588       if (checkHistoValue(p, "SetMaximum", d1))
0589         me->SetMaximum(d1);
0590       if (checkHistoValue(p, "SetNdivisionsX", i1)) {
0591         th->SetNdivisions(i1, "X");
0592         th->GetXaxis()->CenterLabels(true);
0593       }
0594       if (checkHistoValue(p, "SetNdivisionsY", i1)) {
0595         th->SetNdivisions(i1, "Y");
0596         th->GetYaxis()->CenterLabels(true);
0597       }
0598       if (checkHistoValue(p, "SetTickLengthX", d1))
0599         th->SetTickLength(d1, "X");
0600       if (checkHistoValue(p, "SetTickLengthY", d1))
0601         th->SetTickLength(d1, "Y");
0602       if (checkHistoValue(p, "SetLabelSizeX", d1))
0603         th->SetLabelSize(d1, "X");
0604       if (checkHistoValue(p, "SetLabelSizeY", d1))
0605         th->SetLabelSize(d1, "Y");
0606       if (checkHistoValue(p, "SetLabelSizeZ", d1))
0607         th->SetLabelSize(d1, "Z");
0608       if (checkHistoValue(p, "SetErrorOption", s))
0609         reinterpret_cast<TProfile*>(th)->SetErrorOption(s.c_str());
0610 
0611       lock.unlock();
0612     }
0613 
0614     LOG_DEBUG << "[Collection::book] booked " << h.getFullPath() << " (" << me << ")";
0615 
0616     /** Put histogram into cache */
0617     config->fnPutHisto(h, me);
0618   }
0619 
0620   /**
0621    * @brief  Check if the histogram is on demand (by histogram name)
0622    * @param  name name of the histogram
0623    * @return true if this histogram is on demand, false - otherwise
0624    */
0625   const bool Collection::isOnDemand(const HistoName& name) const {
0626     CoHistoMap::const_iterator i = collection.find("CSC");
0627     if (i != collection.end()) {
0628       CoHisto hs = i->second;
0629       CoHisto::const_iterator j = hs.find(name);
0630       if (j != hs.end()) {
0631         std::string s;
0632         return (getHistoValue(j->second, XML_BOOK_ONDEMAND, s, XML_BOOK_ONDEMAND_FALSE) == XML_BOOK_ONDEMAND_TRUE);
0633       }
0634     }
0635     return false;
0636   }
0637 
0638   /**
0639   * @brief  Print collection of available histograms and their parameters
0640   * @return 
0641   */
0642   void Collection::printCollection() const {
0643     std::ostringstream buffer;
0644     for (CoHistoMap::const_iterator hdmi = collection.begin(); hdmi != collection.end(); hdmi++) {
0645       buffer << hdmi->first << " [" << std::endl;
0646       for (CoHisto::const_iterator hdi = hdmi->second.begin(); hdi != hdmi->second.end(); hdi++) {
0647         buffer << "   " << hdi->first << " [" << std::endl;
0648         for (CoHistoProps::const_iterator hi = hdi->second.begin(); hi != hdi->second.end(); hi++) {
0649           buffer << "     " << hi->first << " = " << hi->second << std::endl;
0650         }
0651         buffer << "   ]" << std::endl;
0652       }
0653       buffer << " ]" << std::endl;
0654     }
0655     LOG_INFO << buffer.str();
0656   }
0657 
0658 }  // namespace cscdqm