|
|
Go to the documentation of this file.
19 #ifndef CSCDQM_Configuration_H
20 #define CSCDQM_Configuration_H
26 #include <xercesc/parsers/XercesDOMParser.hpp>
27 #include <xercesc/dom/DOMNodeList.hpp>
28 #include <xercesc/dom/DOMElement.hpp>
29 #include <xercesc/dom/DOMComment.hpp>
30 #include <xercesc/sax/ErrorHandler.hpp>
31 #include <xercesc/sax/SAXParseException.hpp>
32 #include <xercesc/dom/DOMImplementation.hpp>
33 #include <xercesc/framework/StdOutFormatTarget.hpp>
34 #include <xercesc/dom/DOM.hpp>
36 #include <boost/multi_index_container.hpp>
37 #include <boost/multi_index/member.hpp>
38 #include <boost/multi_index/composite_key.hpp>
39 #include <boost/multi_index/ordered_index.hpp>
40 #include "boost/tuple/tuple.hpp"
42 #include <boost/preprocessor/tuple/elem.hpp>
43 #include <boost/preprocessor/seq/for_each_i.hpp>
44 #include <boost/preprocessor/stringize.hpp>
45 #include <boost/preprocessor/cat.hpp>
46 #include <boost/preprocessor/comparison/equal.hpp>
48 #include <boost/timer.hpp>
63 #define CONFIG_PARAMETERS_SEQ_LEN 4
69 #define CONFIG_PARAMETERS_SEQ \
71 ((bool, PROCESS_DDU, true, "enter DDU (and latter Chamber) sections (EventProcessor flag)"))( \
72 (bool, PROCESS_CSC, true, "enter Chamber section (EventProcessor flag)"))( \
73 (bool, PROCESS_EFF_HISTOS, true, "calculate efficiency histograms (Dispatcher flag)"))(( \
74 bool, PROCESS_EFF_PARAMETERS, true, "calculate efficiency parameters (EventProcessor flag)"))(( \
75 bool, BINCHECKER_CRC_ALCT, false, "check ALCT CRC (CSCDCCExaminer flag)"))(( \
76 bool, BINCHECKER_CRC_CLCT, false, "check CLCT CRC (CSCDCCExaminer flag)"))(( \
77 bool, BINCHECKER_CRC_CFEB, false, "check CFEB CRC (CSCDCCExaminer flag)"))(( \
78 bool, BINCHECKER_MODE_DDU, true, "set DDU mode (CSCDCCExaminer flag)"))(( \
79 bool, BINCHECKER_OUTPUT, false, "print 1 and 2 output (CSCDCCExaminer flag)"))(( \
83 "start fractional and efficiency histogram update automatically (Dispatcher flag)"))(( \
85 FRAEFF_SEPARATE_THREAD, \
87 "start fractional and efficiency histogram update on separate thread (EventProcessor flag)"))(( \
88 bool, PRINT_STATS_ON_EXIT, true, "print statistics on exit (destruction)"))(( \
89 bool, IN_FULL_STANDBY, true, "full detector is in standby mode from the beginning of the run"))(( \
90 std::string, BOOKING_XML_FILE, "", "histogram description (booking) file in XML format (Collection)"))(( \
91 std::string, FOLDER_EMU, "", "root file folder name to be used for EMU histograms (EventProcessor)"))(( \
92 std::string, FOLDER_DDU, "", "root file folder name to be used for DDU histograms (EventProcessor)"))(( \
93 std::string, FOLDER_CSC, "", "root file folder name to be used for CSC histograms (EventProcessor)"))(( \
94 std::string, FOLDER_PAR, "", "root file folder name to be used for parameters (EventProcessor)"))(( \
98 "mask for cumulative EmuFileReader DDU error flags (EventProcessor)"))(( \
99 unsigned int, DDU_BINCHECK_MASK, 0x02080016, "mask for DDU level examiner errors (CSCDCCExaminer)"))(( \
100 unsigned int, BINCHECK_MASK, 0xFFFFFFFF, "mask for chamber level examiner errors (CSCDCCExaminer)"))(( \
102 FRAEFF_AUTO_UPDATE_START, \
104 "event number to start automatic fractional and efficiency histogram updates from (Dispatcer)"))(( \
106 FRAEFF_AUTO_UPDATE_FREQ, \
108 "frequency in events to perform automatic fractional and efficiency histogram updates (Dispatcher)"))(( \
110 EFF_COLD_THRESHOLD, \
112 "threshold in fraction to check for cold (not reporting) HW (EventProcessor)"))(( \
113 double, EFF_COLD_SIGFAIL, 5.0, "statistical significance for cold (not reporting) HW (EventProcessor)"))(( \
114 double, EFF_HOT_THRESHOLD, 0.1, "threshold in fraction to check for hot HW (EventProcessor)"))(( \
115 double, EFF_HOT_SIGFAIL, 5.0, "statistical significance for hot HW (EventProcessor)"))(( \
116 double, EFF_ERR_THRESHOLD, 0.1, "threshold in fraction to check for errors in HW (EventProcessor)"))(( \
117 double, EFF_ERR_SIGFAIL, 5.0, "statistical significance for errors in HW (EventProcessor)"))(( \
119 EFF_NODATA_THRESHOLD, \
121 "threshold in fraction to check for not reporting elements in HW (EventProcessor)"))(( \
122 double, EFF_NODATA_SIGFAIL, 5.0, "statistical significance for not reportingelements in HW (EventProcessor)"))(( \
123 unsigned int, EVENTS_ECHO, 1000, "frequency in events to print echo message (EventProcessor)"))(( \
124 std::string, FOLDER_FED, "", "root file folder name to be used for FED histograms (EventProcessor)"))(( \
125 bool, PREBOOK_ALL_HISTOS, true, "pre-book all FED, DDU, CSC histogragrams before run begins"))
132 #define CONFIG_PARAMETER_DEFINE_MACRO(r, data, i, elem) \
133 BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 0, elem) BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem);
136 #define CONFIG_PARAMETER_DEFAULT_MACRO(r, data, i, elem) \
137 BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem) = BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 2, elem);
140 #define CONFIG_PARAMETER_GETTER_MACRO(r, data, i, elem) \
141 const BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 0, elem) \
142 BOOST_PP_CAT(get, BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem))() const { \
143 return BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem); \
147 #define CONFIG_PARAMETER_SETTER_MACRO(r, data, i, elem) \
148 void BOOST_PP_CAT(set, BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem))( \
149 BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 0, elem) p) { \
150 BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem) = p; \
156 #define CONFIG_PARAMETER_LOADPS_MACRO(r, data, i, elem) \
157 BOOST_PP_CAT(set, BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem)) \
158 (ps.getUntrackedParameter<BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 0, elem)>( \
159 BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem)), \
160 BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 2, elem)));
167 #define CONFIG_PARAMETER_LOADXML_MACRO(r, data, i, elem) \
168 if (nodeName.compare(BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem))) == 0) { \
169 stm >> BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem); \
174 #define CONFIG_PARAMETER_PRINTXML_MACRO(r, data, i, elem) \
176 DOMComment* comment = \
177 doc->createComment(XERCES_TRANSCODE(BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 3, elem))); \
178 DOMElement* el = doc->createElement( \
179 XERCES_TRANSCODE(BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem)))); \
180 std::string value = toString(config.BOOST_PP_CAT(get, BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem))()); \
181 DOMText* tdata = doc->createTextNode(XERCES_TRANSCODE(value.c_str())); \
182 el->appendChild(tdata); \
183 rootElem->appendChild(comment); \
184 rootElem->appendChild(el); \
225 typedef boost::multi_index_container<
226 ChamberCounterKeyType,
227 boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<
228 ChamberCounterKeyType,
229 boost::multi_index::member<ChamberCounterKeyType, HwId, &ChamberCounterKeyType::crateId>,
230 boost::multi_index::member<ChamberCounterKeyType, HwId, &ChamberCounterKeyType::dmbId> > > > >
334 parser.setErrorHandler(&eh);
338 DOMNode* docNode = (DOMNode*)
doc->getDocumentElement();
340 DOMNodeList* itemList = docNode->getChildNodes();
341 for (XMLSize_t
i = 0;
i < itemList->getLength();
i++) {
342 DOMNode* node = itemList->item(
i);
343 if (node->getNodeType() != DOMNode::ELEMENT_NODE) {
347 std::string nodeName = XMLString::transcode(node->getNodeName());
349 std::istringstream stm(
value);
353 if (nodeName.compare(
"MO_FILTER") == 0) {
354 DOMNodeList* filterList = node->getChildNodes();
355 for (XMLSize_t
j = 0;
j < filterList->getLength();
j++) {
356 DOMNode*
filter = filterList->item(
j);
357 if (
filter->getNodeType() != DOMNode::ELEMENT_NODE) {
363 MOFilterItem(filterValue, (
filterName.compare(
"INCLUDE") == 0)));
380 DOMImplementation* domImpl = DOMImplementationRegistry::getDOMImplementation(XERCES_TRANSCODE(
"core"));
381 DOMDocument*
doc = domImpl->createDocument(0, XERCES_TRANSCODE(
"processor_configuration"), 0);
382 DOMElement* rootElem =
doc->getDocumentElement();
386 DOMLSSerializer* ser = domImpl->createLSSerializer();
387 if (ser->getDomConfig()->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true)) {
388 ser->getDomConfig()->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint,
true);
390 XMLFileErrorHandler eh;
391 ser->setErrorHandler((DOMErrorHandler*)&eh);
392 ser->writeNode(
new StdOutFormatTarget(), *
doc);
409 std::vector<std::string> moFilter = ps.
getUntrackedParameter<std::vector<std::string> >(
"MO_FILTER");
410 for (std::vector<std::string>::iterator it = moFilter.begin(); it != moFilter.end(); it++) {
413 LOG_WARN <<
"MO_FILTER item " <<
f <<
" does not recognized to be a valid one. Skipping...";
452 #define STATFIELD(caption, value, units) \
453 logger << std::setfill(' '); \
454 logger << std::setiosflags(std::ios::right) << std::setw(25) << caption << " : "; \
455 logger << std::setiosflags(std::ios::right) << std::setw(12); \
456 if (((double)value) < 0) { \
461 logger << std::setiosflags(std::ios::left) << std::setw(2) << units; \
466 logger << std::setfill('-'); \
467 logger << std::setw(25) << ""; \
468 logger << std::setw(10) << ""; \
469 logger << std::setw(2) << ""; \
491 STATFIELD(
"Avg. event time", eventTimeAverage,
"s")
493 STATFIELD(
"Avg. event rate", eventRateAverage,
"Hz")
495 STATFIELD(
"Avg. chamber rate", chamberRateAverage,
"Hz")
502 STATFIELD(
"Avg. fra update time", fraTimeAverage,
"s")
509 STATFIELD(
"Avg. eff update time", effTimeAverage,
"s")
515 STATFIELD(
"Avg. event all time", allTimeAverage,
"s")
516 double allRateAverage = (allTime > 0 ?
nEvents / allTime : -1.0);
517 STATFIELD(
"Avg. event all rate", allRateAverage,
"Hz")
518 double chamberAllRateAverage = (allTime > 0 ?
nUnpackedCSC / allTime : -1.0);
519 STATFIELD(
"Avg. chamber all rate", chamberAllRateAverage,
"Hz")
619 if (getEVENTS_ECHO() > 0) {
652 const uint32_t
value) {
653 ChamberMapCounterMapType::iterator it =
chamberCounters.find(boost::make_tuple(crateId, dmbId));
659 ChamberCounterMapType::iterator itc =
cs->find(
counter);
660 if (itc ==
cs->end()) {
691 const HwId dmbId)
const {
692 ChamberMapCounterMapType::iterator it =
chamberCounters.find(boost::make_tuple(crateId, dmbId));
695 ChamberCounterMapType::const_iterator itc = it->counters.find(
counter);
696 if (itc == it->counters.end())
733 #undef CONFIG_PARAMETERS_SEQ_LEN
734 #undef CONFIG_PARAMETERS_SEQ
735 #undef CONFIG_PARAMETER_DEFINE_MACRO
736 #undef CONFIG_PARAMETER_DEFAULT_MACRO
737 #undef CONFIG_PARAMETER_GETTER_MACRO
738 #undef CONFIG_PARAMETER_SETTER_MACRO
739 #undef CONFIG_PARAMETER_LOADPS_MACRO
740 #undef CONFIG_PARAMETER_LOADXML_MACRO
741 #undef CONFIG_PARAMETER_PRINTXML_MACRO
std::function< bool(unsigned int &, unsigned int &)> fnIsBookedCSC
unsigned short printStatsLocal
std::function< bool(unsigned int &)> fnIsBookedDDU
ChamberCounterMapType counters
void eventProcessTimer(const bool start)
Switch on/off event processing timer.
Configuration()
Constructor.
Abstract Base Histogram Definition.
boost::multi_index_container< ChamberCounterKeyType, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::composite_key< ChamberCounterKeyType, boost::multi_index::member< ChamberCounterKeyType, HwId, &ChamberCounterKeyType::crateId >, boost::multi_index::member< ChamberCounterKeyType, HwId, &ChamberCounterKeyType::dmbId > > > > > ChamberMapCounterMapType
void updateEffTimer(const bool start)
Switch on/off efficiency MO processing timer.
MOFilterItem(const std::string pattern_, const bool include_)
std::function< bool(const HistoId id, const HwId &id1, MonitorObject *&mo)> fnGetCacheDDUHisto
std::function< bool(const HistoId id, MonitorObject *&mo)> fnGetCacheParHisto
unique_ptr< ClusterSequence > cs
std::function< MonitorObject *(const HistoBookRequest &)> fnBook
unsigned long nEventsGood
std::function< void(const HistoDef &histoT, MonitorObject *&)> fnPutHisto
const unsigned long getNEventsBad() const
static bool regexMatch(const std::string &expression, const std::string &message)
Match RegExp expression string against string message and return result.
T getUntrackedParameter(std::string const &, T const &) const
std::function< bool(unsigned int &, unsigned int &, unsigned int &)> fnNextBookedCSC
void printStats()
Print Statistics on Exit (Destruction)
ChamberMapCounterMapType chamberCounters
Chamber Counters key type.
std::function< bool(const unsigned int, const unsigned int, CSCDetId &)> fnGetCSCDetId
Takes care of errors and warnings while parsing XML files file in XML format.
const unsigned long getNUnpackedCSC() const
std::function< bool(const HistoId id, const HwId &id1, const HwId &id2, const HwId &id3, MonitorObject *&mo)> fnGetCacheCSCHisto
unsigned long nUnpackedCSC
ChamberCounterType
Chamber level counter types.
#define CONFIG_PARAMETER_SETTER_MACRO(r, data, i, elem)
std::function< bool(unsigned int &)> fnIsBookedFED
const unsigned long getNEvents() const
#define CONFIG_PARAMETER_GETTER_MACRO(r, data, i, elem)
std::map< ChamberCounterType, uint32_t > ChamberCounterMapType
const unsigned long getNEventsCSC() const
std::function< bool(const HistoDef &histoT, MonitorObject *&)> fnGetHisto
#define CONFIG_PARAMETERS_SEQ
#define STATFIELD(caption, value, units)
std::function< bool(const HistoId id, MonitorObject *&mo)> fnGetCacheEMUHisto
ChamberCounterKeyType(const HwId &crateId_, const HwId &dmbId_, const ChamberCounterMapType &c_)
Information level logger. Use LOG_INFO macros instead, i.e. LOG_INFO << "x = " << x;.
#define CONFIG_PARAMETER_DEFINE_MACRO(r, data, i, elem)
void copyChamberCounterValue(const ChamberCounterType counter_from, const ChamberCounterType counter_to, const HwId crateId, const HwId dmbId)
Copy Chamber counter value from one counter to another.
CSCDQM Framework Global Configuration.
void setChamberCounterValue(const ChamberCounterType counter, const HwId crateId, const HwId dmbId, const uint32_t value)
Set Chamber counter value.
const unsigned long getNEventsGood() const
#define CONFIG_PARAMETER_DEFAULT_MACRO(r, data, i, elem)
std::vector< MOFilterItem > MOFilterItems
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
static void regexReplace(const std::string &expression, std::string &message, const std::string replace="")
Replace string part that matches RegExp expression with some string.
std::function< bool(const HistoId id, const HwId &id1, MonitorObject *&mo)> fnGetCacheFEDHisto
TEMPL(T2) struct Divides void
void reset()
Reset counters.
MO filter Item definition (loaded from XML/PSet)
bool include(const CollT &coll, const ItemT &item)
const bool needBookMO(const std::string name) const
Check if MO is not excluded by MO Filter.
void init()
Initialize parameter values and reset counters (used by constructors)
void incChamberCounter(const ChamberCounterType counter, const HwId crateId, const HwId dmbId)
Increment Chamber counter by 1.
const uint32_t getChamberCounterValue(const ChamberCounterType counter, const HwId crateId, const HwId dmbId) const
Get Chamber counter value.
~Configuration()
Destructor.
void updateFraTimer(const bool start)
Switch on/off fractional MO processing timer.
Configuration(const bool printStats)
Constructor.