Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DATAFORMATS_ONLINEMETADATA_CTPPSRECORD_H
0002 #define DATAFORMATS_ONLINEMETADATA_CTPPSRECORD_H
0003 
0004 //---------------------------------------------------------------------------
0005 //!  \class CTPPSRecord
0006 //!  \brief Class to contain CTPPS information from soft FED 1022
0007 //!
0008 //!  \author Remi Mommsen - Fermilab
0009 //---------------------------------------------------------------------------
0010 
0011 #include <array>
0012 #include <bitset>
0013 #include <cstdint>
0014 #include <ostream>
0015 #include <string>
0016 
0017 #include "DataFormats/OnlineMetaData/interface/OnlineMetaDataRaw.h"
0018 #include "DataFormats/Provenance/interface/Timestamp.h"
0019 
0020 class CTPPSRecord {
0021 public:
0022   enum RomanPot {
0023     RP_45_210_FR_BT,
0024     RP_45_210_FR_HR,
0025     RP_45_210_FR_TP,
0026     RP_45_220_C1,
0027     RP_45_220_FR_BT,
0028     RP_45_220_FR_HR,
0029     RP_45_220_FR_TP,
0030     RP_45_220_NR_BT,
0031     RP_45_220_NR_TP,
0032     RP_56_210_FR_BT,
0033     RP_56_210_FR_HR,
0034     RP_56_210_FR_TP,
0035     RP_56_220_C1,
0036     RP_56_220_FR_BT,
0037     RP_56_220_FR_HR,
0038     RP_56_220_FR_TP,
0039     RP_56_220_NR_BT,
0040     RP_56_220_NR_TP,
0041     Last
0042   };
0043 
0044   enum Status { unused, bad, warning, ok };
0045 
0046   CTPPSRecord();
0047   explicit CTPPSRecord(const online::CTPPS_v1&);
0048   virtual ~CTPPSRecord();
0049 
0050   /// Return the time of the last change
0051   const edm::Timestamp& timestamp() const { return timestamp_; }
0052 
0053   /// Get the names of all roman pots
0054   typedef std::array<std::string, Last> RomanPotNames;
0055   const RomanPotNames& romanPotNames() const { return romanPotNames_; }
0056 
0057   /// Return the name of the roman pot
0058   const std::string& romanPotName(const uint8_t rp) const { return romanPotNames_.at(rp); }
0059 
0060   /// Return the status of the given roman pot
0061   Status status(const uint8_t rp) const { return Status((status_ >> (rp * 2)) & 0x3); }
0062 
0063   /// Return the status as string
0064   const std::string& statusName(const uint8_t rp) const { return statusNames_.at(status(rp)); }
0065 
0066 private:
0067   edm::Timestamp timestamp_;
0068   uint64_t status_;
0069   static const std::array<std::string, 4> statusNames_;
0070   static const RomanPotNames romanPotNames_;
0071 };
0072 
0073 /// Pretty-print operator for CTPPSRecord
0074 std::ostream& operator<<(std::ostream&, const CTPPSRecord&);
0075 
0076 #endif  // DATAFORMATS_ONLINEMETADATA_CTPPSRECORD_H