Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:10

0001 /** \file
0002  * 
0003  *
0004  * \author N.Terentiev, CMU
0005  */
0006 #include "DataFormats/CSCDigi/interface/CSCCFEBStatusDigi.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include <iostream>
0009 #include <cstdint>
0010 
0011 /// Shift and select
0012 int CSCCFEBStatusDigi::ShiftSel(int nmb, int nshift, int nsel) const {
0013   int tmp = nmb;
0014   tmp = tmp >> nshift;
0015   return tmp = tmp & nsel;
0016 }
0017 /// Get SCA Full Condition
0018 std::vector<uint16_t> CSCCFEBStatusDigi::getSCAFullCond() const {
0019   /*    std::vector<int> vec(4,0);
0020     vec[0]=ShiftSel(SCAFullCond_,0,15);  // 4-bit FIFO1 word count
0021     vec[1]=ShiftSel(SCAFullCond_,4,15);  // 4-bit Block Number if Error Code=1
0022                                          // (CFEB: SCA Capacitors Full)
0023                                          // 4-bit FIFO3 word count if Error Code=2
0024                                          // (CFEB: FPGA FIFO full)
0025     vec[2]=ShiftSel(SCAFullCond_,9,7);   // Error Code
0026     vec[3]=ShiftSel(SCAFullCond_,12,15); // DDU Code, should be 0xB
0027     return vec;*/
0028   return bWords_;
0029 }
0030 /// Get TS_FLAG bit from SCA Controller data  per each time slice
0031 std::vector<int> CSCCFEBStatusDigi::getTS_FLAG() const {
0032   std::vector<int> vec(contrWords_.size(), 0);
0033   int nmb;
0034   for (unsigned int i = 0; i < vec.size(); i++) {
0035     nmb = contrWords_[i];
0036     vec[i] = ShiftSel(nmb, 15, 1);
0037   }
0038   return vec;
0039 }
0040 
0041 /// Get SCA_FULL bit from SCA Controller data  per each time slice
0042 std::vector<int> CSCCFEBStatusDigi::getSCA_FULL() const {
0043   std::vector<int> vec(contrWords_.size(), 0);
0044   int nmb;
0045   for (unsigned int i = 0; i < vec.size(); i++) {
0046     nmb = contrWords_[i];
0047     vec[i] = ShiftSel(nmb, 14, 1);
0048   }
0049   return vec;
0050 }
0051 
0052 /// Get LCT_PHASE bit from SCA Controller data  per each time slice
0053 std::vector<int> CSCCFEBStatusDigi::getLCT_PHASE() const {
0054   std::vector<int> vec(contrWords_.size(), 0);
0055   int nmb;
0056   for (unsigned int i = 0; i < vec.size(); i++) {
0057     nmb = contrWords_[i];
0058     vec[i] = ShiftSel(nmb, 13, 1);
0059   }
0060   return vec;
0061 }
0062 
0063 /// Get L1A_PHASE bit from SCA Controller data  per each time slice
0064 std::vector<int> CSCCFEBStatusDigi::getL1A_PHASE() const {
0065   std::vector<int> vec(contrWords_.size(), 0);
0066   int nmb;
0067   for (unsigned int i = 0; i < vec.size(); i++) {
0068     nmb = contrWords_[i];
0069     vec[i] = ShiftSel(nmb, 12, 1);
0070   }
0071   return vec;
0072 }
0073 
0074 /// Get SCA_BLK 4 bit word from SCA Controller data  per each time slice
0075 std::vector<int> CSCCFEBStatusDigi::getSCA_BLK() const {
0076   std::vector<int> vec(contrWords_.size(), 0);
0077   int nmb;
0078   for (unsigned int i = 0; i < vec.size(); i++) {
0079     nmb = contrWords_[i];
0080     vec[i] = ShiftSel(nmb, 8, 15);
0081   }
0082   return vec;
0083 }
0084 
0085 /// Get TRIG_TIME 8 bit word from SCA Controller data  per each time  slice
0086 std::vector<int> CSCCFEBStatusDigi::getTRIG_TIME() const {
0087   std::vector<int> vec(contrWords_.size(), 0);
0088   int nmb;
0089   for (unsigned int i = 0; i < vec.size(); i++) {
0090     nmb = contrWords_[i];
0091     vec[i] = ShiftSel(nmb, 0, 255);
0092   }
0093   return vec;
0094 }
0095 
0096 /// Debug
0097 void CSCCFEBStatusDigi::print() const {
0098   edm::LogVerbatim("CSCDigi") << "CSC CFEB # : " << getCFEBNmb();
0099 
0100   std::ostringstream ost;
0101   ost << " SCAFullCond: ";
0102   if (!getSCAFullCond().empty()) {
0103     for (size_t i = 0; i < 4; ++i) {
0104       ost << " " << (getSCAFullCond())[i];
0105     }
0106   } else {
0107     ost << " "
0108         << "BWORD is not valid";
0109   }
0110   edm::LogVerbatim("CSCDigi") << ost.str();
0111 
0112   ost.clear();
0113   ost << " CRC: ";
0114   for (size_t i = 0; i < getCRC().size(); ++i) {
0115     ost << " " << (getCRC())[i];
0116   }
0117   edm::LogVerbatim("CSCDigi") << ost.str();
0118 
0119   ost.clear();
0120   ost << " TS_FLAG: ";
0121   for (size_t i = 0; i < getTS_FLAG().size(); ++i) {
0122     ost << " " << (getTS_FLAG())[i];
0123   }
0124   edm::LogVerbatim("CSCDigi") << ost.str();
0125 
0126   ost.clear();
0127   ost << " SCA_FULL: ";
0128   for (size_t i = 0; i < getSCA_FULL().size(); ++i) {
0129     ost << " " << (getSCA_FULL())[i];
0130   }
0131   edm::LogVerbatim("CSCDigi") << ost.str();
0132 
0133   ost.clear();
0134   ost << " LCT_PHASE: ";
0135   for (size_t i = 0; i < getLCT_PHASE().size(); ++i) {
0136     ost << " " << (getLCT_PHASE())[i];
0137   }
0138   edm::LogVerbatim("CSCDigi") << ost.str();
0139 
0140   ost.clear();
0141   ost << " L1A_PHASE: ";
0142   for (size_t i = 0; i < getL1A_PHASE().size(); ++i) {
0143     ost << " " << (getL1A_PHASE())[i];
0144   }
0145   edm::LogVerbatim("CSCDigi") << ost.str();
0146 
0147   ost.clear();
0148   ost << " SCA_BLK: ";
0149   for (size_t i = 0; i < getSCA_BLK().size(); ++i) {
0150     ost << " " << (getSCA_BLK())[i];
0151   }
0152   edm::LogVerbatim("CSCDigi") << ost.str();
0153 
0154   ost.clear();
0155   ost << " TRIG_TIME: ";
0156   for (size_t i = 0; i < getTRIG_TIME().size(); ++i) {
0157     ost << " " << (getTRIG_TIME())[i];
0158   }
0159   edm::LogVerbatim("CSCDigi") << ost.str();
0160 }
0161 
0162 std::ostream& operator<<(std::ostream& o, const CSCCFEBStatusDigi& digi) {
0163   o << " " << digi.getCFEBNmb() << "\n";
0164   for (size_t i = 0; i < 4; ++i) {
0165     o << " " << (digi.getSCAFullCond())[i];
0166   }
0167   o << "\n";
0168   for (size_t i = 0; i < digi.getCRC().size(); ++i) {
0169     o << " " << (digi.getCRC())[i];
0170   }
0171   o << "\n";
0172   for (size_t i = 0; i < digi.getTS_FLAG().size(); ++i) {
0173     o << " " << (digi.getTS_FLAG())[i];
0174   }
0175   o << "\n";
0176   for (size_t i = 0; i < digi.getSCA_FULL().size(); ++i) {
0177     o << " " << (digi.getSCA_FULL())[i];
0178   }
0179   o << "\n";
0180   for (size_t i = 0; i < digi.getLCT_PHASE().size(); ++i) {
0181     o << " " << (digi.getLCT_PHASE())[i];
0182   }
0183   o << "\n";
0184   for (size_t i = 0; i < digi.getL1A_PHASE().size(); ++i) {
0185     o << " " << (digi.getL1A_PHASE())[i];
0186   }
0187   o << "\n";
0188   for (size_t i = 0; i < digi.getSCA_BLK().size(); ++i) {
0189     o << " " << (digi.getSCA_BLK())[i];
0190   }
0191   o << "\n";
0192   for (size_t i = 0; i < digi.getTRIG_TIME().size(); ++i) {
0193     o << " " << (digi.getTRIG_TIME())[i];
0194   }
0195   o << "\n";
0196 
0197   return o;
0198 }