Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:08

0001 #include "DataFormats/RPCDigi/interface/RPCRawDataCounts.h"
0002 #include "DataFormats/RPCDigi/interface/ReadoutError.h"
0003 #include "DataFormats/RPCDigi/interface/DataRecord.h"
0004 #include "DataFormats/RPCDigi/interface/RecordSLD.h"
0005 #include "DataFormats/RPCDigi/interface/ErrorRDDM.h"
0006 #include "DataFormats/RPCDigi/interface/ErrorRDM.h"
0007 #include "DataFormats/RPCDigi/interface/ErrorRCDM.h"
0008 #include "DataFormats/RPCDigi/interface/ReadoutError.h"
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 
0011 #include <vector>
0012 #include <sstream>
0013 
0014 using namespace rpcrawtodigi;
0015 using namespace std;
0016 
0017 typedef std::map<std::pair<int, int>, int>::const_iterator IT;
0018 
0019 int RPCRawDataCounts::fedBxRecords(int fedId) const {
0020   int type = DataRecord::StartOfBXData;
0021   IT im = theRecordTypes.find(make_pair(fedId, type));
0022   return (im == theRecordTypes.end()) ? 0 : im->second;
0023 }
0024 
0025 int RPCRawDataCounts::fedFormatErrors(int fedId) const {
0026   for (IT im = theReadoutErrors.begin(); im != theReadoutErrors.end(); ++im) {
0027     if (im->first.first != fedId)
0028       continue;
0029     if (im->first.second > ReadoutError::NoProblem && im->first.second <= ReadoutError::InconsistentDataSize)
0030       return 1;
0031   }
0032   return 0;
0033 }
0034 
0035 int RPCRawDataCounts::fedErrorRecords(int fedId) const {
0036   for (IT im = theRecordTypes.begin(); im != theRecordTypes.end(); ++im) {
0037     if (im->first.first != fedId)
0038       continue;
0039     if (im->first.second > DataRecord::Empty)
0040       return 1;
0041   }
0042   return 0;
0043 }
0044 
0045 void RPCRawDataCounts::addDccRecord(int fed, const rpcrawtodigi::DataRecord& record, int weight) {
0046   DataRecord::DataRecordType type = record.type();
0047   switch (type) {
0048     case (DataRecord::StartOfTbLinkInputNumberData): {
0049       theGoodEvents[make_pair(fed, RecordSLD(record).rmb())] += weight;
0050       break;
0051     }
0052     case (DataRecord::RDDM): {
0053       theBadEvents[make_pair(fed, ErrorRDDM(record).rmb())] += weight;
0054       break;
0055     }
0056     case (DataRecord::RDM): {
0057       theBadEvents[make_pair(fed, ErrorRDM(record).rmb())] += weight;
0058       break;
0059     }
0060     case (DataRecord::RCDM): {
0061       theBadEvents[make_pair(fed, ErrorRCDM(record).rmb())] += weight;
0062       break;
0063     }
0064     default: {
0065     }
0066   }
0067 
0068   theRecordTypes[make_pair(fed, type)] += weight;
0069 }
0070 
0071 void RPCRawDataCounts::addReadoutError(int fed, const rpcrawtodigi::ReadoutError& e, int weight) {
0072   theReadoutErrors[make_pair(fed, e.rawCode())] += weight;
0073 }
0074 
0075 void RPCRawDataCounts::operator+=(const RPCRawDataCounts& o) {
0076   for (IT irt = o.theRecordTypes.begin(); irt != o.theRecordTypes.end(); ++irt) {
0077     theRecordTypes[make_pair(irt->first.first, irt->first.second)] += irt->second;
0078   }
0079 
0080   for (IT ire = o.theReadoutErrors.begin(); ire != o.theReadoutErrors.end(); ++ire) {
0081     theReadoutErrors[make_pair(ire->first.first, ire->first.second)] += ire->second;
0082   }
0083 
0084   for (IT ire = o.theGoodEvents.begin(); ire != o.theGoodEvents.end(); ++ire) {
0085     theGoodEvents[make_pair(ire->first.first, ire->first.second)] += ire->second;
0086   }
0087 
0088   for (IT ire = o.theBadEvents.begin(); ire != o.theBadEvents.end(); ++ire) {
0089     theBadEvents[make_pair(ire->first.first, ire->first.second)] += ire->second;
0090   }
0091 }
0092 
0093 std::string RPCRawDataCounts::print() const {
0094   std::ostringstream str;
0095   for (IT irt = theRecordTypes.begin(); irt != theRecordTypes.end(); ++irt) {
0096     str << "RECORD (" << irt->first.first << "," << irt->first.second << ")" << irt->second;
0097   }
0098   for (IT ire = theReadoutErrors.begin(); ire != theReadoutErrors.end(); ++ire) {
0099     str << "ERROR(" << ire->first.first << "," << ire->first.second << ")=" << ire->second << endl;
0100   }
0101   return str.str();
0102 }