22 #include <xercesc/util/XMLString.hpp> 23 #include <xercesc/util/TransService.hpp> 41 LOG_INFO <<
"Reading histograms from " <<
config->getBOOKING_XML_FILE();
43 if (
config->getBOOKING_XML_FILE().empty()) {
53 parser.setValidationScheme(XercesDOMParser::Val_Always);
54 parser.setDoNamespaces(
true);
55 parser.setDoSchema(
true);
56 parser.setExitOnFirstFatalError(
true);
57 parser.setValidationConstraintFatal(
true);
59 parser.setErrorHandler(&eh);
60 parser.parse(
config->getBOOKING_XML_FILE().c_str());
63 DOMElement *docNode = doc->getDocumentElement();
67 for (XMLSize_t
i = 0;
i < itemList->getLength();
i++) {
70 if (node->getNodeType() != DOMNode::ELEMENT_NODE) {
continue; }
72 std::string nodeName = XMLString::transcode(node->getNodeName());
84 definitions.insert(make_pair(
id, dp));
100 for (CoHistoProps::iterator it = d.begin(); it != d.end(); it++) {
101 hp[it->first] = it->second;
113 LOG_DEBUG <<
"[Collection::load] loading " << prefix <<
"::" << name <<
" XML_BOOK_ONDEMAND = " << hp[
XML_BOOK_ONDEMAND];
115 CoHistoMap::iterator it =
collection.find(prefix);
121 it->second.insert(make_pair(name, hp));
130 char* message = XMLString::transcode(e.getMessage());
135 LOG_INFO <<
i->second.size() <<
" " <<
i->first <<
" histograms defined";
150 for(XMLSize_t j = 0; j < props->getLength(); j++) {
151 DOMNode* node = props->item(j);
152 if (node->getNodeType() != DOMNode::ELEMENT_NODE) {
continue; }
156 const XMLCh *
content = element->getTextContent();
158 std::istringstream
buffer((
const char*)tc.str());
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;
182 CoHistoProps::const_iterator
i = h.find(name);
198 CoHistoProps::const_iterator
i = h.find(name);
202 if(EOF == std::sscanf(i->second.c_str(),
"%d", &
value)) {
217 CoHistoProps::const_iterator
i = h.find(name);
221 if(EOF == std::sscanf(i->second.c_str(),
"%lf", &
value)) {
281 char* stopstring =
nullptr;
283 while (pos != std::string::npos) {
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);
292 labels[nbin] =
label;
296 return labels.size();
304 CoHistoMap::const_iterator
i =
collection.find(
"EMU");
307 for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
313 book(hdef, j->second,
config->getFOLDER_EMU());
326 CoHistoMap::const_iterator
i =
collection.find(
"FED");
329 for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
335 book(hdef, j->second,
config->getFOLDER_FED());
348 CoHistoMap::const_iterator
i =
collection.find(
"DDU");
351 for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
357 book(hdef, j->second,
config->getFOLDER_DDU());
371 CoHistoMap::const_iterator
i =
collection.find(
"CSC");
374 for (CoHisto::const_iterator j = hs.begin(); j != hs.end(); j++) {
380 book(hdef, j->second,
config->getFOLDER_CSC());
382 int from = 0,
to = 0;
384 for (
int k = from;
k <=
to;
k++) {
386 book(hdef, j->second,
config->getFOLDER_CSC());
406 CoHistoMap::const_iterator
i =
collection.find(
"CSC");
408 CoHisto::const_iterator j = i->second.find(
h::names[hid]);
409 if (j != i->second.end()) {
411 book(hdef, j->second,
config->getFOLDER_CSC());
430 LOG_INFO <<
"MOFilter excluded " << name <<
" from booking";
431 config->fnPutHisto(h, me);
436 double d1, d2, d3, d4, d5, d6;
505 throw Exception(
"Can not book histogram with type: " +
type);
538 std::map<int, std::string>
labels;
540 th->GetXaxis()->SetNoAlphanumeric();
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());
546 std::map<int, std::string>
labels;
548 th->GetYaxis()->SetNoAlphanumeric();
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());
554 std::vector<std::string>
v;
556 th->LabelsOption(v[0].c_str(), v[1].c_str());
560 std::vector<std::string>
v;
562 th->SetLabelSize((
double) atof(v[0].c_str()), v[1].c_str());
566 std::vector<std::string>
v;
568 th->SetTitleOffset((
double) atof(v[0].c_str()), v[1].c_str());
574 th->SetNdivisions(i1,
"X");
575 th->GetXaxis()->CenterLabels(
true);
578 th->SetNdivisions(i1,
"Y");
579 th->GetYaxis()->CenterLabels(
true);
581 if(
checkHistoValue(p,
"SetTickLengthX", d1)) th->SetTickLength(d1,
"X");
582 if(
checkHistoValue(p,
"SetTickLengthY", d1)) th->SetTickLength(d1,
"Y");
586 if(
checkHistoValue(p,
"SetErrorOption", s))
reinterpret_cast<TProfile*
>(th)->SetErrorOption(s.c_str());
592 LOG_DEBUG <<
"[Collection::book] booked " << h.
getFullPath() <<
" (" << me <<
")";
595 config->fnPutHisto(h, me);
605 CoHistoMap::const_iterator
i =
collection.find(
"CSC");
608 CoHisto::const_iterator j = hs.find(name);
623 std::ostringstream
buffer;
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;
631 buffer <<
" ]" << std::endl;
633 buffer <<
" ]" << std::endl;
static const bool getHistoIdByName(const std::string &p_name, HistoId &p_id)
Get Histogram ID by name.
static const char XML_BOOK_DEFINITION_ID[]
static const char XML_BOOK_ONDEMAND_FALSE[]
static const char XML_BOOK_HISTO_TYPE[]
static const char XML_BOOK_NAME_FROM[]
static const HistoName names[]
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
virtual const std::string processTitle(const std::string &p_title) const
Process Title by Adding appropriate ID.
void bookEMUHistos() const
Book EMU histograms.
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
Abstract Base Histogram Definition.
static const char XML_BOOK_NAME_TO[]
static const char XML_BOOK_ONDEMAND[]
static const char XML_BOOK_DEFINITION_REF[]
static const char XML_BOOK_HISTOGRAM[]
xercesc::DOMDocument DOMDocument
const bool isOnDemand(const HistoName &name) const
Check if the histogram is on demand (by histogram name)
static bool regexMatch(const std::string &expression, const std::string &message)
Match RegExp expression string against string message and return result.
#define XERCES_CPP_NAMESPACE_QUALIFIER
CSC Level Histogram Type.
Collection(Configuration *const p_config)
Constructor.
CSCDQM Framework Global Configuration.
static const char XML_BOOK_HISTO_PREFIX[]
virtual TH1 * getTH1Lock(void)=0
static void getNodeProperties(DOMNode *&node, CoHistoProps &hp)
Extract and write single histogram properties from XML node to map.
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.
xercesc::DOMElement DOMElement
EMU Level Histogram Definition.
void load()
Load XML file and fill definition map(s)
static const bool checkHistoValue(const CoHistoProps &h, const std::string &name, std::string &value)
Find string histogram value in map.
xercesc::DOMNodeList DOMNodeList
DDU Level Histogram Definition.
static const char XML_BOOK_ONDEMAND_TRUE[]
xercesc::XercesDOMParser XercesDOMParser
void bookFEDHistos(const HwId fedId) const
Book FED histograms.
std::map< std::string, CoHistoProps > CoHisto
static const int DEF_HISTO_COLOR
static const char XML_BOOK_DEFINITION[]
void bookDDUHistos(const HwId dduId) const
Book DDU histograms.
void book(const HistoDef &h, const CoHistoProps &p, const std::string &folder) const
Book histogram.
FED Level Histogram Definition.
xercesc::DOMNamedNodeMap DOMNamedNodeMap
std::vector< std::vector< double > > tmp
const std::string getFullPath() const
Get full path of the histogram. It is being constructed by appending path and histogam name...
virtual const std::string getName() const
Get processed histogram name. It can include additional parameter in formated name. This Name is being constructed from raw name and additional parameter.
void bookCSCHistos(const HwId crateId, const HwId dmbId) const
Book Chamber Histograms.
static const TPRegexp REGEXP_ONDEMAND("^.*%d.*$")
Takes care of errors and warnings while parsing XML files file in XML format.
static const char XML_BOOK_HISTO_NAME[]
void printCollection() const
Print collection of available histograms and their parameters.
static const char XML_BOOK_HISTO_TITLE[]
virtual void SetMaximum(const double d)=0
static const int ParseAxisLabels(const std::string &s, std::map< int, std::string > &labels)
Parse Axis label string and return values in vector.
std::map< std::string, std::string > CoHistoProps
static int tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
Break string into tokens.
virtual void setAxisTitle(const std::string title, const int axisN)=0
xercesc::XMLException XMLException