Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DATAFORMATS_TCDS_TCDSRECORD_H
0002 #define DATAFORMATS_TCDS_TCDSRECORD_H
0003 
0004 //---------------------------------------------------------------------------
0005 //!  \class TCDSRecord
0006 //!  \brief Class to contain information from TCDS FED
0007 //!
0008 //!  \author Remi Mommsen - Fermilab
0009 //---------------------------------------------------------------------------
0010 
0011 #include <bitset>
0012 #include <ostream>
0013 #include <cstdint>
0014 #include <vector>
0015 
0016 #include "DataFormats/TCDS/interface/BSTRecord.h"
0017 #include "DataFormats/TCDS/interface/L1aInfo.h"
0018 
0019 class TCDSRecord {
0020 public:
0021   enum BGo {
0022     LumiNibble = 0,
0023     BC0 = 1,
0024     TestEnable = 2,
0025     PrivateGap = 3,
0026     PrivateOrbit = 4,
0027     Resync = 5,
0028     HardReset = 6,
0029     EC0 = 7,
0030     OC0 = 8,
0031     Start = 9,
0032     Stop = 10,
0033     StartOfGap = 11,
0034     WarningTestEnable = 13
0035   };
0036 
0037   enum BSTstatus {
0038     Unknown = 0x00000000,
0039     Reset = 0x0000dead,
0040     Unlocked = 0xfa11010c,
0041     NoData = 0xfa110acc,
0042     Okay = 0x0000bea0
0043   };
0044 
0045   TCDSRecord();
0046   TCDSRecord(const unsigned char* rawData);
0047   virtual ~TCDSRecord();
0048 
0049   // MAC address of the CPM
0050   uint64_t getMacAddress() const { return macAddress_; }
0051 
0052   // Software version of TCDS s/w
0053   uint32_t getSwVersion() const { return swVersion_; }
0054 
0055   // Firmware version of the CPM
0056   uint32_t getFwVersion() const { return fwVersion_; }
0057 
0058   // Version of the TCDS record
0059   uint32_t getRecordVersion() const { return recordVersion_; }
0060 
0061   // Run number
0062   uint32_t getRunNumber() const { return runNumber_; }
0063 
0064   // Lumi section number
0065   uint32_t getLumiSection() const { return lumiSection_; }
0066 
0067   // Lumi nibble number
0068   uint32_t getNibble() const { return nibble_; }
0069 
0070   // Number of nibbles per lumi section
0071   uint16_t getNibblesPerLumiSection() const { return nibblesPerLumiSection_; }
0072 
0073   // The event type corresponding to edm::EventAuxiliary::ExperimentType
0074   uint16_t getEventType() const { return eventType_; }
0075 
0076   // The trigger word contains sixteen boolean flags corresponding to the sixteen trigger types
0077   // (see https://twiki.cern.ch/twiki/bin/view/CMS/TcdsEventRecord#TCDS_Event_Trigger_Type_Definiti)
0078   // If a given trigger type fired for this event, the corresponding flag will be true.
0079   uint16_t getTriggerTypeFlags() const { return triggerTypeFlags_; }
0080 
0081   // Input state at Triggered BX +/- 3, currently zeros
0082   uint16_t getInputs() const { return inputs_; }
0083 
0084   // Bunch-crossing identified
0085   uint16_t getBXID() const { return bxid_; }
0086 
0087   // Orbit number
0088   uint64_t getOrbitNr() const { return orbitNr_; }
0089 
0090   // Number of triggers since last EC0
0091   uint64_t getTriggerCount() const { return triggerCount_; }
0092 
0093   // Number of events since start of the run (last OC0)
0094   uint64_t getEventNumber() const { return eventNumber_; }
0095 
0096   // BST reception status corresponding to TCDSRecord::BSTstatus
0097   uint32_t getBstReceptionStatus() const { return bstReceptionStatus_; }
0098 
0099   // The BST message as received from the LHC
0100   const BSTRecord& getBST() const { return bst_; }
0101 
0102   // Source FED ID
0103   uint16_t getSourceID() const { return sourceid_; }
0104 
0105   // List of active paritions, currently not implemented
0106   typedef std::bitset<96> ActivePartitions;
0107   ActivePartitions getActivePartitions() const { return activePartitions_; }
0108 
0109   // History of recent L1 accepts
0110   typedef std::vector<L1aInfo> L1aHistory;
0111   const L1aHistory& getFullL1aHistory() const { return l1aHistory_; }
0112   const L1aInfo& getL1aHistoryEntry(const uint8_t entry) const { return l1aHistory_.at(entry); }
0113 
0114   // Orbit number when the given Bgo was sent last
0115   uint32_t getOrbitOfLastBgo(const uint16_t bgo) const { return lastBgos_.at(bgo); }
0116 
0117   // Orbit number of last OC0
0118   uint32_t getLastOrbitCounter0() const { return lastBgos_.at(BGo::OC0); }
0119 
0120   // Orbit number of last Test Enable
0121   uint32_t getLastTestEnable() const { return lastBgos_.at(BGo::TestEnable); }
0122 
0123   // Orbit number of last Resync
0124   uint32_t getLastResync() const { return lastBgos_.at(BGo::Resync); }
0125 
0126   // Orbit number of last Start
0127   uint32_t getLastStart() const { return lastBgos_.at(BGo::Start); }
0128 
0129   // Orbit number of last EC0
0130   uint32_t getLastEventCounter0() const { return lastBgos_.at(BGo::EC0); }
0131 
0132   // Orbit number of last Hard Reset
0133   uint32_t getLastHardReset() const { return lastBgos_.at(BGo::HardReset); }
0134 
0135 private:
0136   uint64_t orbitNr_;
0137   uint64_t triggerCount_;
0138   uint64_t eventNumber_;
0139   uint64_t macAddress_;
0140   uint32_t swVersion_;
0141   uint32_t fwVersion_;
0142   uint32_t recordVersion_;
0143   uint32_t runNumber_;
0144   uint32_t bstReceptionStatus_;
0145   uint32_t nibble_;
0146   uint32_t lumiSection_;
0147   uint16_t nibblesPerLumiSection_;
0148   uint16_t eventType_;
0149   uint16_t triggerTypeFlags_;
0150   uint16_t inputs_;
0151   uint16_t bxid_;
0152   uint16_t sourceid_;
0153 
0154   ActivePartitions activePartitions_;
0155   L1aHistory l1aHistory_;
0156 
0157   BSTRecord bst_;
0158 
0159   std::vector<uint32_t> lastBgos_;
0160 };
0161 
0162 /// Pretty-print operator for TCDSRecord
0163 std::ostream& operator<<(std::ostream&, const TCDSRecord&);
0164 
0165 #endif  // DATAFORMATS_TCDS_TCDSRECORD_H