CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DataFormats/RPCDigi/src/RPCRawDataCounts.cc

Go to the documentation of this file.
00001 #include "DataFormats/RPCDigi/interface/RPCRawDataCounts.h"
00002 #include "DataFormats/RPCDigi/interface/ReadoutError.h"
00003 #include "DataFormats/RPCDigi/interface/DataRecord.h"
00004 #include "DataFormats/RPCDigi/interface/RecordSLD.h"
00005 #include "DataFormats/RPCDigi/interface/ErrorRDDM.h"
00006 #include "DataFormats/RPCDigi/interface/ErrorRDM.h"
00007 #include "DataFormats/RPCDigi/interface/ErrorRCDM.h"
00008 #include "DataFormats/RPCDigi/interface/ReadoutError.h"
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 
00011 #include <vector>
00012 #include <sstream>
00013 
00014 using namespace rpcrawtodigi;
00015 using namespace std;
00016 
00017 typedef std::map< std::pair<int,int>, int >::const_iterator IT;
00018 
00019 int RPCRawDataCounts::fedBxRecords(int fedId) const
00020 {
00021   int type= DataRecord::StartOfBXData;
00022   IT im = theRecordTypes.find(make_pair(fedId,type));
00023   return (im==theRecordTypes.end())? 0 : im->second;
00024 }
00025 
00026 int  RPCRawDataCounts::fedFormatErrors(int fedId) const
00027 {
00028   for (IT im=theReadoutErrors.begin(); im != theReadoutErrors.end(); ++im) {
00029     if (im->first.first != fedId) continue;
00030     if (im->first.second > ReadoutError::NoProblem && im->first.second <= ReadoutError::InconsistentDataSize) return 1; 
00031   }
00032   return 0;
00033 }
00034 
00035 int  RPCRawDataCounts::fedErrorRecords(int fedId) const
00036 {
00037   for (IT im=theRecordTypes.begin(); im != theRecordTypes.end(); ++im) {
00038     if (im->first.first != fedId) continue;
00039     if (im->first.second > DataRecord::Empty) return 1; 
00040   }
00041   return 0;
00042 }
00043 
00044 void RPCRawDataCounts::addDccRecord(int fed, const rpcrawtodigi::DataRecord & record, int weight)
00045 {
00046   DataRecord::DataRecordType type = record.type();
00047   switch (type) {
00048     case (DataRecord::StartOfTbLinkInputNumberData) : { theGoodEvents[make_pair(fed, RecordSLD(record).rmb())] += weight; break; }
00049     case (DataRecord::RDDM)                         : { theBadEvents[make_pair(fed,ErrorRDDM(record).rmb())]   += weight; break;}
00050     case (DataRecord::RDM)                          : { theBadEvents[make_pair(fed,ErrorRDM(record).rmb())]    += weight; break;}
00051     case (DataRecord::RCDM)                         : { theBadEvents[make_pair(fed,ErrorRCDM(record).rmb())]   += weight; break;}
00052     default : {}
00053   }
00054   
00055   theRecordTypes[ make_pair(fed,type) ] += weight;
00056 }
00057 
00058 
00059 
00060 
00061 
00062 void RPCRawDataCounts::addReadoutError(int fed, const rpcrawtodigi::ReadoutError & e, int weight)
00063 {
00064   theReadoutErrors[ make_pair(fed,e.rawCode()) ] +=  weight;
00065 }
00066 
00067 void RPCRawDataCounts::operator+= (const RPCRawDataCounts & o)
00068 {
00069 
00070   for (IT irt= o.theRecordTypes.begin(); irt != o.theRecordTypes.end(); ++irt) {
00071     theRecordTypes[ make_pair(irt->first.first,irt->first.second) ] += irt->second;
00072   }
00073 
00074   for (IT ire=o.theReadoutErrors.begin(); ire != o.theReadoutErrors.end();++ire) {
00075     theReadoutErrors[ make_pair(ire->first.first,ire->first.second) ] += ire->second;
00076   }
00077 
00078   for (IT ire=o.theGoodEvents.begin(); ire != o.theGoodEvents.end();++ire) {
00079     theGoodEvents[ make_pair(ire->first.first,ire->first.second) ] += ire->second;
00080   }
00081 
00082   for (IT ire=o.theBadEvents.begin(); ire != o.theBadEvents.end();++ire) {
00083     theBadEvents[ make_pair(ire->first.first,ire->first.second) ] += ire->second;
00084   }
00085 }
00086 
00087 std::string RPCRawDataCounts::print() const 
00088 {
00089   std::ostringstream str;
00090   for (IT irt=theRecordTypes.begin(); irt != theRecordTypes.end(); ++irt) {
00091     str << "RECORD ("<<irt->first.first<<","<<irt->first.second<<")"<<irt->second;
00092   }
00093   for (IT ire=theReadoutErrors.begin(); ire != theReadoutErrors.end();++ire) {
00094     str <<"ERROR("<<ire->first.first<<","<<ire->first.second<<")="<<ire->second<<endl;
00095   } 
00096   return str.str();
00097 }