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 \
00109 \
00110
00111
00116 #define CONFIG_PARAMETER_DEFINE_MACRO(r, data, i, elem) \
00117 BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 0, elem) BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem);
00118
00120 #define CONFIG_PARAMETER_DEFAULT_MACRO(r, data, i, elem) \
00121 BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem) = BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 2, elem);
00122
00124 #define CONFIG_PARAMETER_GETTER_MACRO(r, data, i, elem) \
00125 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 { \
00126 return BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem); \
00127 }
00128
00130 #define CONFIG_PARAMETER_SETTER_MACRO(r, data, i, elem) \
00131 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) { \
00132 BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem) = p; \
00133 }
00134
00135 #ifdef DQMGLOBAL
00136
00138 #define CONFIG_PARAMETER_LOADPS_MACRO(r, data, i, elem) \
00139 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)));
00140
00141 #endif
00142
00143 #ifdef DQMLOCAL
00144
00146 #define CONFIG_PARAMETER_LOADXML_MACRO(r, data, i, elem) \
00147 if (nodeName.compare(BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem))) == 0) { \
00148 stm >> BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem); \
00149 continue; \
00150 }
00151
00153 #define CONFIG_PARAMETER_PRINTXML_MACRO(r, data, i, elem) \
00154 { \
00155 DOMComment* comment = doc->createComment(XERCES_TRANSCODE(BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 3, elem))); \
00156 DOMElement* el = doc->createElement(XERCES_TRANSCODE(BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem)))); \
00157 std::string value = toString(config.BOOST_PP_CAT(get, BOOST_PP_TUPLE_ELEM(CONFIG_PARAMETERS_SEQ_LEN, 1, elem))()); \
00158 DOMText* tdata = doc->createTextNode(XERCES_TRANSCODE(value.c_str())); \
00159 el->appendChild(tdata); \
00160 rootElem->appendChild(comment); \
00161 rootElem->appendChild(el); \
00162 }
00163
00164 #endif
00165
00166 namespace cscdqm {
00167
00169 struct MOFilterItem {
00171 TPRegexp pattern;
00173 bool include;
00175 MOFilterItem(const std::string pattern_, const bool include_) :
00176 pattern(pattern_.c_str()), include(include_) { }
00177 };
00178
00180 enum ChamberCounterType {
00181 DMB_EVENTS,
00182 BAD_EVENTS,
00183 DMB_TRIGGERS,
00184 ALCT_TRIGGERS,
00185 CLCT_TRIGGERS,
00186 CFEB_TRIGGERS,
00187 EVENT_DISPLAY_PLOT
00188 };
00189
00191 typedef std::map<ChamberCounterType, uint32_t> ChamberCounterMapType;
00192
00194 struct ChamberCounterKeyType {
00195 HwId crateId;
00196 HwId dmbId;
00197 ChamberCounterMapType counters;
00198 ChamberCounterKeyType(const HwId& crateId_, const HwId& dmbId_, const ChamberCounterMapType& c_) : crateId(crateId_), dmbId(dmbId_), counters(c_) { }
00199 };
00200
00202 typedef boost::multi_index_container<
00203 ChamberCounterKeyType,
00204 boost::multi_index::indexed_by<
00205 boost::multi_index::ordered_unique<
00206 boost::multi_index::composite_key<
00207 ChamberCounterKeyType,
00208 boost::multi_index::member<ChamberCounterKeyType, HwId, &ChamberCounterKeyType::crateId>,
00209 boost::multi_index::member<ChamberCounterKeyType, HwId, &ChamberCounterKeyType::dmbId>
00210 >
00211 >
00212 >
00213 > ChamberMapCounterMapType;
00214
00219 class Configuration {
00220
00221 private:
00222
00223 unsigned short printStatsLocal;
00224
00226 std::vector<MOFilterItem> MOFilterItems;
00227
00229 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_DEFINE_MACRO, _, CONFIG_PARAMETERS_SEQ)
00230
00231
00235 void init() {
00237 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_DEFAULT_MACRO, _, CONFIG_PARAMETERS_SEQ)
00238 reset();
00239 }
00240
00241 public:
00242
00248 boost::function< bool (const HistoDef& histoT, MonitorObject*&) > fnGetHisto;
00249
00251 boost::function< bool (const HistoId id, MonitorObject*& mo) > fnGetCacheEMUHisto;
00252 boost::function< bool (const HistoId id, const HwId& id1, MonitorObject*& mo) > fnGetCacheDDUHisto;
00253 boost::function< bool (const HistoId id, const HwId& id1, const HwId& id2, const HwId& id3, MonitorObject*& mo) > fnGetCacheCSCHisto;
00254 boost::function< bool (const HistoId id, MonitorObject*& mo) > fnGetCacheParHisto;
00255 boost::function< void (const HistoDef& histoT, MonitorObject*&) > fnPutHisto;
00256 boost::function< bool (unsigned int&, unsigned int&, unsigned int&) > fnNextBookedCSC;
00257 boost::function< bool (unsigned int&, unsigned int&) > fnIsBookedCSC;
00258 boost::function< bool (unsigned int&) > fnIsBookedDDU;
00259
00261 boost::function< MonitorObject* (const HistoBookRequest&) > fnBook;
00262
00264 boost::function< bool (const unsigned int, const unsigned int, CSCDetId&) > fnGetCSCDetId;
00265
00267 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_GETTER_MACRO, _, CONFIG_PARAMETERS_SEQ)
00268
00269
00270 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_SETTER_MACRO, _, CONFIG_PARAMETERS_SEQ)
00271
00275 Configuration() {
00276 init();
00277 printStatsLocal = 0;
00278 }
00279
00284 Configuration(const bool printStats) {
00285 init();
00286 if (printStats) {
00287 printStatsLocal = 1;
00288 } else {
00289 printStatsLocal = 2;
00290 }
00291 }
00292
00296 ~Configuration() {
00297 if ((PRINT_STATS_ON_EXIT && printStatsLocal == 0) || printStatsLocal == 1) {
00298 printStats();
00299 }
00300 }
00301
00302 #ifdef DQMLOCAL
00303
00309 void load(const std::string& configFile) {
00310 XMLPlatformUtils::Initialize();
00311
00312 {
00313 XercesDOMParser parser;
00314
00315 XMLFileErrorHandler eh;
00316 parser.setErrorHandler(&eh);
00317
00318 parser.parse(configFile.c_str());
00319 DOMDocument *doc = parser.getDocument();
00320 DOMNode *docNode = (DOMNode*) doc->getDocumentElement();
00321
00322 DOMNodeList *itemList = docNode->getChildNodes();
00323 for(uint32_t i = 0; i < itemList->getLength(); i++) {
00324 DOMNode* node = itemList->item(i);
00325 if (node->getNodeType() != DOMNode::ELEMENT_NODE) { continue; }
00326
00327 std::string nodeName = XMLString::transcode(node->getNodeName());
00328 std::string value = XMLString::transcode(node->getTextContent());
00329 std::istringstream stm(value);
00330
00331 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_LOADXML_MACRO, _, CONFIG_PARAMETERS_SEQ)
00332
00333 if (nodeName.compare("MO_FILTER") == 0) {
00334 DOMNodeList *filterList = node->getChildNodes();
00335 for(uint32_t j = 0; j < filterList->getLength(); j++) {
00336 DOMNode* filter = filterList->item(j);
00337 if (filter->getNodeType() != DOMNode::ELEMENT_NODE) { continue; }
00338 std::string filterName = XMLString::transcode(filter->getNodeName());
00339 std::string filterValue = XMLString::transcode(filter->getTextContent());
00340 MOFilterItems.insert(MOFilterItems.end(), MOFilterItem(filterValue, (filterName.compare("INCLUDE") == 0)));
00341 }
00342 }
00343
00344 }
00345 }
00346
00347 XMLPlatformUtils::Terminate();
00348
00349 }
00350
00356 static void printXML(const Configuration& config) {
00357 XMLPlatformUtils::Initialize();
00358
00359 DOMImplementation* domImpl = DOMImplementationRegistry::getDOMImplementation(XERCES_TRANSCODE("core"));
00360 DOMDocument *doc = domImpl->createDocument(0, XERCES_TRANSCODE("processor_configuration"), 0);
00361 DOMElement* rootElem = doc->getDocumentElement();
00362
00363 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_PRINTXML_MACRO, _, CONFIG_PARAMETERS_SEQ)
00364
00365 DOMWriter *ser = domImpl->createDOMWriter();
00366 if (ser->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true)) {
00367 ser->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
00368 }
00369 XMLFileErrorHandler eh;
00370 ser->setErrorHandler((DOMErrorHandler*) &eh);
00371 ser->writeNode(new StdOutFormatTarget(), *doc);
00372
00373 doc->release();
00374 XMLPlatformUtils::Terminate();
00375 }
00376
00377 #endif
00378
00379 #ifdef DQMGLOBAL
00380
00386 void load(const edm::ParameterSet& ps) {
00387 BOOST_PP_SEQ_FOR_EACH_I(CONFIG_PARAMETER_LOADPS_MACRO, _, CONFIG_PARAMETERS_SEQ)
00388 std::vector<std::string> moFilter = ps.getUntrackedParameter<std::vector<std::string> >("MO_FILTER");
00389 for (std::vector<std::string>::iterator it = moFilter.begin(); it != moFilter.end(); it++) {
00390 std::string f = *it;
00391 if (!Utility::regexMatch("^[-+]/.*/$", f)) {
00392 LOG_WARN << "MO_FILTER item " << f << " does not recognized to be a valid one. Skipping...";
00393 continue;
00394 }
00395 bool include = Utility::regexMatch("^[+]", f);
00396 Utility::regexReplace("^./(.*)/$", f, "$1");
00397 MOFilterItems.insert(MOFilterItems.end(), MOFilterItem(f, include));
00398 }
00399 }
00400
00401 #endif
00402
00407 private:
00408
00410 boost::timer globalTimer;
00411
00413 boost::timer eventTimer;
00414
00416 boost::timer fraTimer;
00417
00419 boost::timer effTimer;
00420
00422 double eventTimeSum;
00423
00425 double fraTimeSum;
00426
00428 double effTimeSum;
00429
00430 public:
00431
00433 #define STATFIELD(caption, value, units) \
00434 logger << std::setfill(' '); \
00435 logger << std::setiosflags(std::ios::right) << std::setw(25) << caption << " : "; \
00436 logger << std::setiosflags(std::ios::right) << std::setw(12); \
00437 if (((double) value) < 0) { \
00438 logger << "NA"; \
00439 } else { \
00440 logger << value; \
00441 } \
00442 logger << std::setiosflags(std::ios::left) << std::setw(2) << units; \
00443 logger << std::endl;
00444
00446 #define SEPFIELD \
00447 logger << std::setfill('-'); \
00448 logger << std::setw(25) << ""; \
00449 logger << std::setw(10) << ""; \
00450 logger << std::setw(2) << ""; \
00451 logger << std::endl;
00452
00457 void printStats() {
00458
00459 double allTime = globalTimer.elapsed();
00460 LogInfo logger;
00461 logger << std::endl;
00462
00463 STATFIELD("Events processed", nEvents, "")
00464 STATFIELD("Bad events", nEventsBad, "")
00465 STATFIELD("Good events", nEventsGood, "")
00466 STATFIELD("CSC DCC events", nEventsCSC, "")
00467 STATFIELD("Unpacked CSCs", nUnpackedCSC, "")
00468
00469 SEPFIELD
00470
00471 STATFIELD("All event time", eventTimeSum, "s")
00472 double eventTimeAverage = (nEvents > 0 ? eventTimeSum / nEvents : -1.0);
00473 STATFIELD("Avg. event time", eventTimeAverage, "s")
00474 double eventRateAverage = (eventTimeSum > 0 ? nEvents / eventTimeSum : -1.0);
00475 STATFIELD("Avg. event rate", eventRateAverage, "Hz")
00476 double chamberRateAverage = (eventTimeSum > 0 ? nUnpackedCSC / eventTimeSum : -1.0);
00477 STATFIELD("Avg. chamber rate", chamberRateAverage, "Hz")
00478
00479 SEPFIELD
00480
00481 STATFIELD("All fra update time", fraTimeSum, "s")
00482 STATFIELD("All fra update count", fraCount, "")
00483 double fraTimeAverage = (fraCount > 0 ? fraTimeSum / fraCount : -1.0);
00484 STATFIELD("Avg. fra update time", fraTimeAverage, "s")
00485
00486 SEPFIELD
00487
00488 STATFIELD("All eff update time", effTimeSum, "s")
00489 STATFIELD("All eff update count", effCount, "")
00490 double effTimeAverage = (effCount > 0 ? effTimeSum / effCount : -1.0);
00491 STATFIELD("Avg. eff update time", effTimeAverage, "s")
00492
00493 SEPFIELD
00494
00495 STATFIELD("All time", allTime, "s")
00496 double allTimeAverage = (nEvents > 0 ? allTime / nEvents : -1.0);
00497 STATFIELD("Avg. event all time", allTimeAverage, "s")
00498 double allRateAverage = (allTime > 0 ? nEvents / allTime : -1.0);
00499 STATFIELD("Avg. event all rate", allRateAverage, "Hz")
00500 double chamberAllRateAverage = (allTime > 0 ? nUnpackedCSC / allTime : -1.0);
00501 STATFIELD("Avg. chamber all rate", chamberAllRateAverage, "Hz")
00502
00503 }
00504
00505 #undef STATFIELD
00506 #undef SEPFIELD
00507
00513 void eventProcessTimer(const bool start) {
00514 if (start) {
00515 eventTimer.restart();
00516 } else {
00517 eventTimeSum += eventTimer.elapsed();
00518 }
00519 }
00520
00526 void updateFraTimer(const bool start) {
00527 if (start) {
00528 fraTimer.restart();
00529 } else {
00530 fraTimeSum += fraTimer.elapsed();
00531 fraCount++;
00532 }
00533 }
00534
00540 void updateEffTimer(const bool start) {
00541 if (start) {
00542 effTimer.restart();
00543 } else {
00544 effTimeSum += effTimer.elapsed();
00545 effCount++;
00546 }
00547 }
00548
00554 const bool needBookMO(const std::string name) const {
00555 bool result = true;
00556 for (unsigned int i = 0; i < MOFilterItems.size(); i++) {
00557 const MOFilterItem* filter = &MOFilterItems.at(i);
00558 if (Utility::regexMatch(filter->pattern, name)) result = filter->include;
00559 }
00560 return result;
00561 }
00562
00567 public:
00568
00573 void reset() {
00574 nEvents = 0;
00575 nEventsBad = 0;
00576 nEventsGood = 0;
00577 nEventsCSC = 0;
00578 nUnpackedCSC = 0;
00579 fraCount = 0;
00580 effCount = 0;
00581 eventTimeSum = 0.0;
00582 fraTimeSum = 0.0;
00583 effTimeSum = 0.0;
00584 }
00585
00590 const unsigned long getNEvents() const { return nEvents; }
00591 const unsigned long getNEventsBad() const { return nEventsBad; }
00592 const unsigned long getNEventsGood() const { return nEventsGood; }
00593 const unsigned long getNEventsCSC() const { return nEventsCSC; }
00594 const unsigned long getNUnpackedCSC() const { return nUnpackedCSC; }
00595
00600 void incNEvents() {
00601 nEvents++;
00602 if (getEVENTS_ECHO() > 0) {
00603 if (getNEvents() % getEVENTS_ECHO() == 0) {
00604 LOG_INFO << "(echo) Events processed: " << std::setw(12) << getNEvents();
00605 }
00606 }
00607 }
00608 void incNEventsBad() { nEventsBad++; }
00609 void incNEventsGood() { nEventsGood++; }
00610 void incNEventsCSC() { nEventsCSC++; }
00611 void incNUnpackedCSC() { nUnpackedCSC++; }
00612
00620 void incChamberCounter(const ChamberCounterType counter, const HwId crateId, const HwId dmbId) {
00621 setChamberCounterValue(counter, crateId, dmbId, getChamberCounterValue(counter, crateId, dmbId) + 1);
00622 }
00623
00632 void setChamberCounterValue(const ChamberCounterType counter, const HwId crateId, const HwId dmbId, const uint32_t value) {
00633 ChamberMapCounterMapType::iterator it = chamberCounters.find(boost::make_tuple(crateId, dmbId));
00634 if (it == chamberCounters.end()) {
00635 it = chamberCounters.insert(chamberCounters.end(), ChamberCounterKeyType(crateId, dmbId, ChamberCounterMapType()));
00636 }
00637 ChamberCounterMapType* cs = const_cast<ChamberCounterMapType*>(&it->counters);
00638 ChamberCounterMapType::iterator itc = cs->find(counter);
00639 if (itc == cs->end()) {
00640 cs->insert(std::make_pair(counter, value));
00641 } else {
00642 itc->second = value;
00643 }
00644 }
00645
00654 void copyChamberCounterValue(const ChamberCounterType counter_from, const ChamberCounterType counter_to, const HwId crateId, const HwId dmbId) {
00655 setChamberCounterValue(counter_from, crateId, dmbId, getChamberCounterValue(counter_from, crateId, dmbId));
00656 }
00657
00665 const uint32_t getChamberCounterValue(const ChamberCounterType counter, const HwId crateId, const HwId dmbId) const {
00666 ChamberMapCounterMapType::iterator it = chamberCounters.find(boost::make_tuple(crateId, dmbId));
00667 if (it == chamberCounters.end()) return 0;
00668 ChamberCounterMapType::const_iterator itc = it->counters.find(counter);
00669 if (itc == it->counters.end()) return 0;
00670 return itc->second;
00671 }
00672
00673 private:
00674
00680 unsigned long nEvents;
00681
00683 unsigned long nEventsBad;
00684
00686 unsigned long nEventsGood;
00687
00689 unsigned long nEventsCSC;
00690
00692 unsigned long nUnpackedCSC;
00693
00695 unsigned long fraCount;
00696
00698 unsigned long effCount;
00699
00701 ChamberMapCounterMapType chamberCounters;
00702
00703 };
00704
00705 }
00706
00707 #undef CONFIG_PARAMETERS_SEQ_LEN
00708 #undef CONFIG_PARAMETERS_SEQ
00709 #undef CONFIG_PARAMETER_DEFINE_MACRO
00710 #undef CONFIG_PARAMETER_DEFAULT_MACRO
00711 #undef CONFIG_PARAMETER_GETTER_MACRO
00712 #undef CONFIG_PARAMETER_SETTER_MACRO
00713 #undef CONFIG_PARAMETER_LOADPS_MACRO
00714 #undef CONFIG_PARAMETER_LOADXML_MACRO
00715 #undef CONFIG_PARAMETER_PRINTXML_MACRO
00716
00717 #endif