Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:37

0001 #include "DataFormats/RPCDigi/interface/RecordCD.h"
0002 
0003 #include <vector>
0004 
0005 using namespace rpcrawtodigi;
0006 using namespace std;
0007 
0008 RecordCD::RecordCD(int lbInLink, int partitionNumber, int eod, int halfP, const std::vector<int>& packedStrips)
0009     : DataRecord(0) {
0010   theData = 0;
0011 
0012   theData |= (lbInLink << CHAMBER_SHIFT);
0013 
0014   theData |= (partitionNumber << PARTITION_NUMBER_SHIFT);
0015 
0016   theData |= (eod << EOD_SHIFT);
0017 
0018   theData |= (halfP << HALFP_SHIFT);
0019 
0020   int partitionData = 0;
0021   for (vector<int>::const_iterator iv = packedStrips.begin(); iv != packedStrips.end(); iv++) {
0022     int ibit = (partitionNumber) ? (*iv) % (partitionNumber * BITS_PER_PARTITION) : (*iv);
0023     partitionData |= (1 << ibit);
0024   }
0025   theData |= (partitionData << PARTITION_DATA_SHIFT);
0026 }
0027 
0028 int RecordCD::lbInLink() const { return (theData >> CHAMBER_SHIFT) & CHAMBER_MASK; }
0029 
0030 int RecordCD::partitionNumber() const { return (theData >> PARTITION_NUMBER_SHIFT) & PARTITION_NUMBER_MASK; }
0031 
0032 int RecordCD::eod() const { return (theData >> EOD_SHIFT) & EOD_MASK; }
0033 
0034 int RecordCD::halfP() const { return (theData >> HALFP_SHIFT) & HALFP_MASK; }
0035 
0036 int RecordCD::partitionData() const { return (theData >> PARTITION_DATA_SHIFT) & PARTITION_DATA_MASK; }
0037 
0038 std::vector<int> RecordCD::packedStrips() const {
0039   int partitionNumber = this->partitionNumber();
0040   int partitionData = this->partitionData();
0041   std::vector<int> strips;
0042   for (int ib = 0; ib < 8; ++ib) {
0043     if ((partitionData >> ib) & 1)
0044       strips.push_back(partitionNumber * BITS_PER_PARTITION + ib);
0045   }
0046   return strips;
0047 }
0048 
0049 std::string RecordCD::print() const {
0050   std::ostringstream str;
0051   str << " DATA";
0052   return str.str();
0053 }