Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:49

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_HR,
0032     RP_45_220_NR_TP,
0033     RP_56_210_FR_BT,
0034     RP_56_210_FR_HR,
0035     RP_56_210_FR_TP,
0036     RP_56_220_C1,
0037     RP_56_220_FR_BT,
0038     RP_56_220_FR_HR,
0039     RP_56_220_FR_TP,
0040     RP_56_220_NR_BT,
0041     RP_56_220_NR_HR,
0042     RP_56_220_NR_TP,
0043     Last
0044   };
0045 
0046   enum Status { unused, bad, warning, ok };
0047 
0048   CTPPSRecord();
0049   explicit CTPPSRecord(const online::CTPPS_v1&);
0050   virtual ~CTPPSRecord();
0051 
0052   /// Return the time of the last change
0053   const edm::Timestamp& timestamp() const { return timestamp_; }
0054 
0055   /// Get the names of all roman pots
0056   typedef std::array<std::string, Last> RomanPotNames;
0057   const RomanPotNames& romanPotNames() const { return romanPotNames_; }
0058 
0059   /// Return the name of the roman pot
0060   const std::string& romanPotName(const uint8_t rp) const { return romanPotNames_.at(rp); }
0061 
0062   /// Return the status of the given roman pot
0063   Status status(const uint8_t rp) const { return Status((status_ >> (rp * 2)) & 0x3); }
0064 
0065   /// Return the status as string
0066   const std::string& statusName(const uint8_t rp) const { return statusNames_.at(status(rp)); }
0067 
0068 private:
0069   edm::Timestamp timestamp_;
0070   uint64_t status_;
0071   static const std::array<std::string, 4> statusNames_;
0072   static const RomanPotNames romanPotNames_;
0073 };
0074 
0075 /// Pretty-print operator for CTPPSRecord
0076 std::ostream& operator<<(std::ostream&, const CTPPSRecord&);
0077 
0078 #endif  // DATAFORMATS_ONLINEMETADATA_CTPPSRECORD_H