00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CSCDQM_Configuration_H
00020 #define CSCDQM_Configuration_H
00021
00022 #include <string>
00023 #include <sstream>
00024
00025 #include <xercesc/parsers/XercesDOMParser.hpp>
00026 #include <xercesc/dom/DOMNodeList.hpp>
00027 #include <xercesc/dom/DOMElement.hpp>
00028 #include <xercesc/dom/DOMComment.hpp>
00029 #include <xercesc/sax/ErrorHandler.hpp>
00030 #include <xercesc/sax/SAXParseException.hpp>
00031 #include <xercesc/dom/DOMImplementation.hpp>
00032 #include <xercesc/dom/DOMWriter.hpp>
00033 #include <xercesc/framework/StdOutFormatTarget.hpp>
00034 #include <xercesc/dom/DOM.hpp>
00035
00036 #include <boost/multi_index_container.hpp>
00037 #include <boost/multi_index/member.hpp>
00038 #include <boost/multi_index/composite_key.hpp>
00039 #include <boost/multi_index/ordered_index.hpp>
00040 #include "boost/tuple/tuple.hpp"
00041
00042 #include <boost/preprocessor/tuple/elem.hpp>
00043 #include <boost/preprocessor/seq/for_each_i.hpp>
00044 #include <boost/preprocessor/stringize.hpp>
00045 #include <boost/preprocessor/cat.hpp>
00046 #include <boost/preprocessor/comparison/equal.hpp>
00047
00048 #include <boost/shared_ptr.hpp>
00049 #include <boost/function.hpp>
00050 #include <boost/bind.hpp>
00051
00052 #include <boost/timer.hpp>
00053
00055 #ifdef DQMGLOBAL
00056
00057 #include <FWCore/ParameterSet/interface/ParameterSet.h>
00058
00059 #endif
00060
00061 #include "DQM/CSCMonitorModule/interface/CSCDQM_MonitorObjectProvider.h"
00062 #include "DQM/CSCMonitorModule/interface/CSCDQM_Exception.h"
00063 #include "DQM/CSCMonitorModule/interface/CSCDQM_Utility.h"
00064 #include "DQM/CSCMonitorModule/interface/CSCDQM_Logger.h"
00065
00067 #define CONFIG_PARAMETERS_SEQ_LEN 4
00068
00073 #define CONFIG_PARAMETERS_SEQ \
00074 \
00075 \
00076 (( bool, PROCESS_DDU, true, "enter DDU (and latter Chamber) sections (EventProcessor flag)" )) \
00077 (( bool, PROCESS_CSC, true, "enter Chamber section (EventProcessor flag)" )) \
00078 (( bool, PROCESS_EFF_HISTOS, true, "calculate efficiency histograms (Dispatcher flag)" )) \
00079 (( bool, PROCESS_EFF_PARAMETERS, true, "calculate efficiency parameters (EventProcessor flag)" )) \
00080 (( bool, BINCHECKER_CRC_ALCT, false , "check ALCT CRC (CSCDCCExaminer flag)" )) \
00081 (( bool, BINCHECKER_CRC_CLCT, false , "check CLCT CRC (CSCDCCExaminer flag)" )) \
00082 (( bool, BINCHECKER_CRC_CFEB, false , "check CFEB CRC (CSCDCCExaminer flag)" )) \
00083 (( bool, BINCHECKER_MODE_DDU, true , "set DDU mode (CSCDCCExaminer flag)" )) \
00084 (( bool, BINCHECKER_OUTPUT, false , "print 1 and 2 output (CSCDCCExaminer flag)" )) \
00085 (( bool, FRAEFF_AUTO_UPDATE, false , "start fractional and efficiency histogram update automatically (Dispatcher flag)" )) \
00086 (( bool, FRAEFF_SEPARATE_THREAD, false , "start fractional and efficiency histogram update on separate thread (EventProcessor flag)" )) \
00087 (( bool, PRINT_STATS_ON_EXIT, true , "print statistics on exit (destruction)" )) \
00088 (( bool, IN_FULL_STANDBY, true , "full detector is in standby mode from the beginning of the run" )) \
00089 (( std::string, BOOKING_XML_FILE, "" , "histogram description (booking) file in XML format (Collection)" )) \
00090 (( std::string, FOLDER_EMU, "" , "root file folder name to be used for EMU histograms (EventProcessor)" )) \
00091 (( std::string, FOLDER_DDU, "" , "root file folder name to be used for DDU histograms (EventProcessor)" )) \
00092 (( std::string, FOLDER_CSC, "" , "root file folder name to be used for CSC histograms (EventProcessor)" )) \
00093 (( std::string, FOLDER_PAR, "" , "root file folder name to be used for parameters (EventProcessor)" )) \
00094 (( unsigned int, DDU_CHECK_MASK, 0xFFFFFFFF , "mask for cumulative EmuFileReader DDU error flags (EventProcessor)" )) \
00095 (( unsigned int, DDU_BINCHECK_MASK, 0x02080016 , "mask for DDU level examiner errors (CSCDCCExaminer)" )) \
00096 (( unsigned int, BINCHECK_MASK, 0xFFFFFFFF , "mask for chamber level examiner errors (CSCDCCExaminer)" )) \
00097 (( unsigned int, FRAEFF_AUTO_UPDATE_START, 5 , "event number to start automatic fractional and efficiency histogram updates from (Dispatcer)" )) \
00098 (( unsigned int, FRAEFF_AUTO_UPDATE_FREQ, 1 , "frequency in events to perform automatic fractional and efficiency histogram updates (Dispatcher)" )) \
00099 (( double, EFF_COLD_THRESHOLD, 0.1 , "threshold in fraction to check for cold (not reporting) HW (EventProcessor)" )) \
00100 (( double, EFF_COLD_SIGFAIL, 5.0 , "statistical significance for cold (not reporting) HW (EventProcessor)" )) \
00101 (( double, EFF_HOT_THRESHOLD, 0.1 , "threshold in fraction to check for hot HW (EventProcessor)" )) \
00102 (( double, EFF_HOT_SIGFAIL, 5.0 , "statistical significance for hot HW (EventProcessor)" )) \
00103 (( double, EFF_ERR_THRESHOLD, 0.1 , "threshold in fraction to check for errors in HW (EventProcessor)" )) \
00104 (( double, EFF_ERR_SIGFAIL, 5.0 , "statistical significance for errors in HW (EventProcessor)" )) \
00105 (( double, EFF_NODATA_THRESHOLD, 0.1 , "threshold in fraction to check for not reporting elements in HW (EventProcessor)" )) \
00106 (( double, EFF_NODATA_SIGFAIL, 5.0 , "statistical significance for not reportingelements in HW (EventProcessor)" )) \
00107 (( unsigned int, EVENTS_ECHO, 1000, "frequency in events to print echo message (EventProcessor)" )) \
00108 (( std::string, FOLDER_FED, "" , "root file folder name to be used for FED histograms (EventProcessor)" )) \
00109 \
00110 \
00111
00112
00117 #define CONFIG_PARAMETER_DEFINE_MACRO(r, data, i, elem) \
00118 BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 0, elem) BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem);
00119
00121 #define CONFIG_PARAMETER_DEFAULT_MACRO(r, data, i, elem) \
00122 BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem) = BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 2, elem);
00123
00125 #define CONFIG_PARAMETER_GETTER_MACRO(r, data, i, elem) \
00126 const BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 0, elem) BOOST_PP_CAT(get, BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem))() const { \
00127 return BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem); \
00128 }
00129
00131 #define CONFIG_PARAMETER_SETTER_MACRO(r, data, i, elem) \
00132 void BOOST_PP_CAT(set, BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem))(BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 0, elem) p) { \
00133 BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem) = p; \
00134 }
00135
00136 #ifdef DQMGLOBAL
00137
00139 #define CONFIG_PARAMETER_LOADPS_MACRO(r, data, i, elem) \
00140 BOOST_PP_CAT(set, BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem))(ps.getUntrackedParameter<BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 0, elem)>(BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem)), BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 2, elem)));
00141
00142 #endif
00143
00144 #ifdef DQMLOCAL
00145
00147 #define CONFIG_PARAMETER_LOADXML_MACRO(r, data, i, elem) \
00148 if (nodeName.compare(BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem))) == 0) { \
00149 stm >> BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem); \
00150 continue; \
00151 }
00152
00154 #define CONFIG_PARAMETER_PRINTXML_MACRO(r, data, i, elem) \
00155 { \
00156 DOMComment* comment = doc->createComment(XERCES_TRANSCODE(BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 3, elem))); \
00157 DOMElement* el = doc->createElement(XERCES_TRANSCODE(BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem)))); \
00158 std::string value = toString(config.BOOST_PP_CAT(get, BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem))()); \
00159 DOMText* tdata = doc->createTextNode(XERCES_TRANSCODE(value.c_str())); \
00160 el->appendChild(tdata); \
00161 rootElem->appendChild(comment); \
00162 rootElem->appendChild(el); \
00163 }
00164
00165 #endif
00166
00167 namespace cscdqm {
00168
00170 struct MOFilterItem {
00172 TPRegexp pattern;
00174 bool include;
00176 MOFilterItem(const std::string pattern_, const bool include_) :
00177 pattern(pattern_.c_str()), include(include_) { }
00178 };
00179
00181 enum ChamberCounterType {
00182 DMB_EVENTS,
00183 BAD_EVENTS,
00184 DMB_TRIGGERS,
00185 ALCT_TRIGGERS,
00186 CLCT_TRIGGERS,
00187 CFEB_TRIGGERS,
00188 EVENT_DISPLAY_PLOT
00189 };
00190
00192 typedef std::map<ChamberCounterType, uint32_t> ChamberCounterMapType;
00193
00195 struct ChamberCounterKeyType {
00196 HwId crateId;
00197 HwId dmbId;
00198 ChamberCounterMapType counters;
00199 ChamberCounterKeyType(const HwId& crateId_, const HwId& dmbId_, const ChamberCounterMapType& c_) : crateId(crateId_), dmbId(dmbId_), counters(c_) { }
00200 };
00201
00203 typedef boost::multi_index_container<
00204 ChamberCounterKeyType,
00205 boost::multi_index::indexed_by<
00206 boost::multi_index::ordered_unique<
00207 boost::multi_index::composite_key<
00208 ChamberCounterKeyType,
00209 boost::multi_index::member<ChamberCounterKeyType, HwId, &ChamberCounterKeyType::crateId>,
00210 boost::multi_index::member<ChamberCounterKeyType, HwId, &ChamberCounterKeyType::dmbId>
00211 >
00212 >
00213 >
00214 > ChamberMapCounterMapType;
00215
00220 class Configuration {
00221
00222 private:
00223
00224 unsigned short printStatsLocal;
00225
00227 std::vector<MOFilterItem> MOFilterItems;
00228
00230 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_DEFINE_MACRO, _, CONFIG_PARAMETERS_SEQ)
00231
00232
00236 void init() {
00238 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_DEFAULT_MACRO, _, CONFIG_PARAMETERS_SEQ)
00239 reset();
00240 }
00241
00242 public:
00243
00249 boost::function< bool (const HistoDef& histoT, MonitorObject*&) > fnGetHisto;
00250
00252 boost::function< bool (const HistoId id, MonitorObject*& mo) > fnGetCacheEMUHisto;
00253 boost::function< bool (const HistoId id, const HwId& id1, MonitorObject*& mo) > fnGetCacheFEDHisto;
00254 boost::function< bool (const HistoId id, const HwId& id1, MonitorObject*& mo) > fnGetCacheDDUHisto;
00255 boost::function< bool (const HistoId id, const HwId& id1, const HwId& id2, const HwId& id3, MonitorObject*& mo) > fnGetCacheCSCHisto;
00256 boost::function< bool (const HistoId id, MonitorObject*& mo) > fnGetCacheParHisto;
00257 boost::function< void (const HistoDef& histoT, MonitorObject*&) > fnPutHisto;
00258 boost::function< bool (unsigned int&, unsigned int&, unsigned int&) > fnNextBookedCSC;
00259 boost::function< bool (unsigned int&, unsigned int&) > fnIsBookedCSC;
00260 boost::function< bool (unsigned int&) > fnIsBookedDDU;
00261 boost::function< bool (unsigned int&) > fnIsBookedFED;
00262
00264 boost::function< MonitorObject* (const HistoBookRequest&) > fnBook;
00265
00267 boost::function< bool (const unsigned int, const unsigned int, CSCDetId&) > fnGetCSCDetId;
00268
00270 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_GETTER_MACRO, _, CONFIG_PARAMETERS_SEQ)
00271
00272
00273 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_SETTER_MACRO, _, CONFIG_PARAMETERS_SEQ)
00274
00278 Configuration() {
00279 init();
00280 printStatsLocal = 0;
00281 }
00282
00287 Configuration(const bool printStats) {
00288 init();
00289 if (printStats) {
00290 printStatsLocal = 1;
00291 } else {
00292 printStatsLocal = 2;
00293 }
00294 }
00295
00299 ~Configuration() {
00300 if ((PRINT_STATS_ON_EXIT && printStatsLocal == 0) || printStatsLocal == 1) {
00301 printStats();
00302 }
00303 }
00304
00305 #ifdef DQMLOCAL
00306
00312 void load(const std::string& configFile) {
00313 XMLPlatformUtils::Initialize();
00314
00315 {
00316 XercesDOMParser parser;
00317
00318 XMLFileErrorHandler eh;
00319 parser.setErrorHandler(&eh);
00320
00321 parser.parse(configFile.c_str());
00322 DOMDocument *doc = parser.getDocument();
00323 DOMNode *docNode = (DOMNode*) doc->getDocumentElement();
00324
00325 DOMNodeList *itemList = docNode->getChildNodes();
00326 for(uint32_t i = 0; i < itemList->getLength(); i++) {
00327 DOMNode* node = itemList->item(i);
00328 if (node->getNodeType() != DOMNode::ELEMENT_NODE) { continue; }
00329
00330 std::string nodeName = XMLString::transcode(node->getNodeName());
00331 std::string value = XMLString::transcode(node->getTextContent());
00332 std::istringstream stm(value);
00333
00334 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_LOADXML_MACRO, _, CONFIG_PARAMETERS_SEQ)
00335
00336 if (nodeName.compare("MO_FILTER") == 0) {
00337 DOMNodeList *filterList = node->getChildNodes();
00338 for(uint32_t j = 0; j < filterList->getLength(); j++) {
00339 DOMNode* filter = filterList->item(j);
00340 if (filter->getNodeType() != DOMNode::ELEMENT_NODE) { continue; }
00341 std::string filterName = XMLString::transcode(filter->getNodeName());
00342 std::string filterValue = XMLString::transcode(filter->getTextContent());
00343 MOFilterItems.insert(MOFilterItems.end(), MOFilterItem(filterValue, (filterName.compare("INCLUDE") == 0)));
00344 }
00345 }
00346
00347 }
00348 }
00349
00350 XMLPlatformUtils::Terminate();
00351
00352 }
00353
00359 static void printXML(const Configuration& config) {
00360 XMLPlatformUtils::Initialize();
00361
00362 DOMImplementation* domImpl = DOMImplementationRegistry::getDOMImplementation(XERCES_TRANSCODE("core"));
00363 DOMDocument *doc = domImpl->createDocument(0, XERCES_TRANSCODE("processor_configuration"), 0);
00364 DOMElement* rootElem = doc->getDocumentElement();
00365
00366 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_PRINTXML_MACRO, _, CONFIG_PARAMETERS_SEQ)
00367
00368 DOMWriter *ser = domImpl->createDOMWriter();
00369 if (ser->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true)) {
00370 ser->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
00371 }
00372 XMLFileErrorHandler eh;
00373 ser->setErrorHandler((DOMErrorHandler*) &eh);
00374 ser->writeNode(new StdOutFormatTarget(), *doc);
00375
00376 doc->release();
00377 XMLPlatformUtils::Terminate();
00378 }
00379
00380 #endif
00381
00382 #ifdef DQMGLOBAL
00383
00389 void load(const edm::ParameterSet& ps) {
00390 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_LOADPS_MACRO, _, CONFIG_PARAMETERS_SEQ)
00391 std::vector<std::string> moFilter = ps.getUntrackedParameter<std::vector<std::string> >("MO_FILTER");
00392 for (std::vector<std::string>::iterator it = moFilter.begin(); it != moFilter.end(); it++) {
00393 std::string f = *it;
00394 if (!Utility::regexMatch("^[-+]/.*/$", f)) {
00395 LOG_WARN << "MO_FILTER item " << f << " does not recognized to be a valid one. Skipping...";
00396 continue;
00397 }
00398 bool include = Utility::regexMatch("^[+]", f);
00399 Utility::regexReplace("^./(.*)/$", f, "$1");
00400 MOFilterItems.insert(MOFilterItems.end(), MOFilterItem(f, include));
00401 }
00402 }
00403
00404 #endif
00405
00410 private:
00411
00413 boost::timer globalTimer;
00414
00416 boost::timer eventTimer;
00417
00419 boost::timer fraTimer;
00420
00422 boost::timer effTimer;
00423
00425 double eventTimeSum;
00426
00428 double fraTimeSum;
00429
00431 double effTimeSum;
00432
00433 public:
00434
00436 #define STATFIELD(caption, value, units) \
00437 logger << std::setfill(' '); \
00438 logger << std::setiosflags(std::ios::right) << std::setw(25) << caption << " : "; \
00439 logger << std::setiosflags(std::ios::right) << std::setw(12); \
00440 if (((double) value) < 0) { \
00441 logger << "NA"; \
00442 } else { \
00443 logger << value; \
00444 } \
00445 logger << std::setiosflags(std::ios::left) << std::setw(2) << units; \
00446 logger << std::endl;
00447
00449 #define SEPFIELD \
00450 logger << std::setfill('-'); \
00451 logger << std::setw(25) << ""; \
00452 logger << std::setw(10) << ""; \
00453 logger << std::setw(2) << ""; \
00454 logger << std::endl;
00455
00460 void printStats() {
00461
00462 double allTime = globalTimer.elapsed();
00463 LogInfo logger;
00464 logger << std::endl;
00465
00466 STATFIELD("Events processed", nEvents, "")
00467 STATFIELD("Bad events", nEventsBad, "")
00468 STATFIELD("Good events", nEventsGood, "")
00469 STATFIELD("CSC DCC events", nEventsCSC, "")
00470 STATFIELD("Unpacked CSCs", nUnpackedCSC, "")
00471
00472 SEPFIELD
00473
00474 STATFIELD("All event time", eventTimeSum, "s")
00475 double eventTimeAverage = (nEvents > 0 ? eventTimeSum / nEvents : -1.0);
00476 STATFIELD("Avg. event time", eventTimeAverage, "s")
00477 double eventRateAverage = (eventTimeSum > 0 ? nEvents / eventTimeSum : -1.0);
00478 STATFIELD("Avg. event rate", eventRateAverage, "Hz")
00479 double chamberRateAverage = (eventTimeSum > 0 ? nUnpackedCSC / eventTimeSum : -1.0);
00480 STATFIELD("Avg. chamber rate", chamberRateAverage, "Hz")
00481
00482 SEPFIELD
00483
00484 STATFIELD("All fra update time", fraTimeSum, "s")
00485 STATFIELD("All fra update count", fraCount, "")
00486 double fraTimeAverage = (fraCount > 0 ? fraTimeSum / fraCount : -1.0);
00487 STATFIELD("Avg. fra update time", fraTimeAverage, "s")
00488
00489 SEPFIELD
00490
00491 STATFIELD("All eff update time", effTimeSum, "s")
00492 STATFIELD("All eff update count", effCount, "")
00493 double effTimeAverage = (effCount > 0 ? effTimeSum / effCount : -1.0);
00494 STATFIELD("Avg. eff update time", effTimeAverage, "s")
00495
00496 SEPFIELD
00497
00498 STATFIELD("All time", allTime, "s")
00499 double allTimeAverage = (nEvents > 0 ? allTime / nEvents : -1.0);
00500 STATFIELD("Avg. event all time", allTimeAverage, "s")
00501 double allRateAverage = (allTime > 0 ? nEvents / allTime : -1.0);
00502 STATFIELD("Avg. event all rate", allRateAverage, "Hz")
00503 double chamberAllRateAverage = (allTime > 0 ? nUnpackedCSC / allTime : -1.0);
00504 STATFIELD("Avg. chamber all rate", chamberAllRateAverage, "Hz")
00505
00506 }
00507
00508 #undef STATFIELD
00509 #undef SEPFIELD
00510
00516 void eventProcessTimer(const bool start) {
00517 if (start) {
00518 eventTimer.restart();
00519 } else {
00520 eventTimeSum += eventTimer.elapsed();
00521 }
00522 }
00523
00529 void updateFraTimer(const bool start) {
00530 if (start) {
00531 fraTimer.restart();
00532 } else {
00533 fraTimeSum += fraTimer.elapsed();
00534 fraCount++;
00535 }
00536 }
00537
00543 void updateEffTimer(const bool start) {
00544 if (start) {
00545 effTimer.restart();
00546 } else {
00547 effTimeSum += effTimer.elapsed();
00548 effCount++;
00549 }
00550 }
00551
00557 const bool needBookMO(const std::string name) const {
00558 bool result = true;
00559 for (unsigned int i = 0; i < MOFilterItems.size(); i++) {
00560 const MOFilterItem* filter = &MOFilterItems.at(i);
00561 if (Utility::regexMatch(filter->pattern, name)) result = filter->include;
00562 }
00563 return result;
00564 }
00565
00570 public:
00571
00576 void reset() {
00577 nEvents = 0;
00578 nEventsBad = 0;
00579 nEventsGood = 0;
00580 nEventsCSC = 0;
00581 nUnpackedCSC = 0;
00582 fraCount = 0;
00583 effCount = 0;
00584 eventTimeSum = 0.0;
00585 fraTimeSum = 0.0;
00586 effTimeSum = 0.0;
00587 }
00588
00593 const unsigned long getNEvents() const { return nEvents; }
00594 const unsigned long getNEventsBad() const { return nEventsBad; }
00595 const unsigned long getNEventsGood() const { return nEventsGood; }
00596 const unsigned long getNEventsCSC() const { return nEventsCSC; }
00597 const unsigned long getNUnpackedCSC() const { return nUnpackedCSC; }
00598
00603 void incNEvents() {
00604 nEvents++;
00605 if (getEVENTS_ECHO() > 0) {
00606 if (getNEvents() % getEVENTS_ECHO() == 0) {
00607 LOG_INFO << "(echo) Events processed: " << std::setw(12) << getNEvents();
00608 }
00609 }
00610 }
00611 void incNEventsBad() { nEventsBad++; }
00612 void incNEventsGood() { nEventsGood++; }
00613 void incNEventsCSC() { nEventsCSC++; }
00614 void incNUnpackedCSC() { nUnpackedCSC++; }
00615
00623 void incChamberCounter(const ChamberCounterType counter, const HwId crateId, const HwId dmbId) {
00624 setChamberCounterValue(counter, crateId, dmbId, getChamberCounterValue(counter, crateId, dmbId) + 1);
00625 }
00626
00635 void setChamberCounterValue(const ChamberCounterType counter, const HwId crateId, const HwId dmbId, const uint32_t value) {
00636 ChamberMapCounterMapType::iterator it = chamberCounters.find(boost::make_tuple(crateId, dmbId));
00637 if (it == chamberCounters.end()) {
00638 it = chamberCounters.insert(chamberCounters.end(), ChamberCounterKeyType(crateId, dmbId, ChamberCounterMapType()));
00639 }
00640 ChamberCounterMapType* cs = const_cast<ChamberCounterMapType*>(&it->counters);
00641 ChamberCounterMapType::iterator itc = cs->find(counter);
00642 if (itc == cs->end()) {
00643 cs->insert(std::make_pair(counter, value));
00644 } else {
00645 itc->second = value;
00646 }
00647 }
00648
00657 void copyChamberCounterValue(const ChamberCounterType counter_from, const ChamberCounterType counter_to, const HwId crateId, const HwId dmbId) {
00658 setChamberCounterValue(counter_from, crateId, dmbId, getChamberCounterValue(counter_from, crateId, dmbId));
00659 }
00660
00668 const uint32_t getChamberCounterValue(const ChamberCounterType counter, const HwId crateId, const HwId dmbId) const {
00669 ChamberMapCounterMapType::iterator it = chamberCounters.find(boost::make_tuple(crateId, dmbId));
00670 if (it == chamberCounters.end()) return 0;
00671 ChamberCounterMapType::const_iterator itc = it->counters.find(counter);
00672 if (itc == it->counters.end()) return 0;
00673 return itc->second;
00674 }
00675
00676 private:
00677
00683 unsigned long nEvents;
00684
00686 unsigned long nEventsBad;
00687
00689 unsigned long nEventsGood;
00690
00692 unsigned long nEventsCSC;
00693
00695 unsigned long nUnpackedCSC;
00696
00698 unsigned long fraCount;
00699
00701 unsigned long effCount;
00702
00704 ChamberMapCounterMapType chamberCounters;
00705
00706 };
00707
00708 }
00709
00710 #undef CONFIG_PARAMETERS_SEQ_LEN
00711 #undef CONFIG_PARAMETERS_SEQ
00712 #undef CONFIG_PARAMETER_DEFINE_MACRO
00713 #undef CONFIG_PARAMETER_DEFAULT_MACRO
00714 #undef CONFIG_PARAMETER_GETTER_MACRO
00715 #undef CONFIG_PARAMETER_SETTER_MACRO
00716 #undef CONFIG_PARAMETER_LOADPS_MACRO
00717 #undef CONFIG_PARAMETER_LOADXML_MACRO
00718 #undef CONFIG_PARAMETER_PRINTXML_MACRO
00719
00720 #endif