Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:12

0001 #include <iomanip>
0002 #include <ostream>
0003 #include "EventFilter/Phase2TrackerRawToDigi/interface/Phase2TrackerFEDDAQHeader.h"
0004 
0005 namespace Phase2Tracker {
0006 
0007   std::ostream& operator<<(std::ostream& os, const FEDDAQEventType& value) {
0008     switch (value) {
0009       case DAQ_EVENT_TYPE_PHYSICS:
0010         os << "Physics trigger";
0011         break;
0012       case DAQ_EVENT_TYPE_CALIBRATION:
0013         os << "Calibration trigger";
0014         break;
0015       case DAQ_EVENT_TYPE_TEST:
0016         os << "Test trigger";
0017         break;
0018       case DAQ_EVENT_TYPE_TECHNICAL:
0019         os << "Technical trigger";
0020         break;
0021       case DAQ_EVENT_TYPE_SIMULATED:
0022         os << "Simulated event";
0023         break;
0024       case DAQ_EVENT_TYPE_TRACED:
0025         os << "Traced event";
0026         break;
0027       case DAQ_EVENT_TYPE_ERROR:
0028         os << "Error";
0029         break;
0030       case DAQ_EVENT_TYPE_INVALID:
0031         os << "Unknown";
0032         break;
0033       default:
0034         os << "Unrecognized";
0035         os << " (";
0036         printHexValue(value, os);
0037         os << ")";
0038         break;
0039     }
0040     return os;
0041   }
0042 
0043   FEDDAQEventType FEDDAQHeader::eventType() const {
0044     switch (eventTypeNibble()) {
0045       case DAQ_EVENT_TYPE_PHYSICS:
0046       case DAQ_EVENT_TYPE_CALIBRATION:
0047       case DAQ_EVENT_TYPE_TEST:
0048       case DAQ_EVENT_TYPE_TECHNICAL:
0049       case DAQ_EVENT_TYPE_SIMULATED:
0050       case DAQ_EVENT_TYPE_TRACED:
0051       case DAQ_EVENT_TYPE_ERROR:
0052         return FEDDAQEventType(eventTypeNibble());
0053       default:
0054         return DAQ_EVENT_TYPE_INVALID;
0055     }
0056   }
0057 
0058   void FEDDAQHeader::setEventType(const FEDDAQEventType evtType) { header_[7] = ((header_[7] & 0xF0) | evtType); }
0059 
0060   void FEDDAQHeader::setL1ID(const uint32_t l1ID) {
0061     header_[4] = (l1ID & 0x000000FF);
0062     header_[5] = ((l1ID & 0x0000FF00) >> 8);
0063     header_[6] = ((l1ID & 0x00FF0000) >> 16);
0064   }
0065 
0066   void FEDDAQHeader::setBXID(const uint16_t bxID) {
0067     header_[3] = ((bxID & 0x0FF0) >> 4);
0068     header_[2] = ((header_[2] & 0x0F) | ((bxID & 0x000F) << 4));
0069   }
0070 
0071   void FEDDAQHeader::setSourceID(const uint16_t sourceID) {
0072     header_[2] = ((header_[2] & 0xF0) | ((sourceID & 0x0F00) >> 8));
0073     header_[1] = (sourceID & 0x00FF);
0074   }
0075 
0076   FEDDAQHeader::FEDDAQHeader(const uint32_t l1ID,
0077                              const uint16_t bxID,
0078                              const uint16_t sourceID,
0079                              const FEDDAQEventType evtType) {
0080     //clear everything (FOV,H,x,$ all set to 0)
0081     memset(header_, 0x0, 8);
0082     //set the BoE nibble to indicate this is the last fragment
0083     header_[7] = 0x50;
0084     //set variable fields vith values supplied
0085     setEventType(evtType);
0086     setL1ID(l1ID);
0087     setBXID(bxID);
0088     setSourceID(sourceID);
0089   }
0090 
0091 }  // namespace Phase2Tracker