Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef DATAFORMATS_ONLINEMETADATA_DCSRECORD_H
0002 #define DATAFORMATS_ONLINEMETADATA_DCSRECORD_H
0003 
0004 //---------------------------------------------------------------------------
0005 //!  \class DCSRecord
0006 //!  \brief Class to contain DCS 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 DCSRecord {
0021 public:
0022   // Adding new partitions requires to add a new bitset definition with
0023   // the correct dimension to DataFormats/StdDictionaries/src/classes_def_others.xml
0024   enum Partition {
0025     EBp,
0026     EBm,
0027     EEp,
0028     EEm,
0029     HBHEa,
0030     HBHEb,
0031     HBHEc,
0032     HF,
0033     HO,
0034     RPC,
0035     DT0,
0036     DTp,
0037     DTm,
0038     CSCp,
0039     CSCm,
0040     CASTOR,
0041     ZDC,
0042     TIBTID,
0043     TOB,
0044     TECp,
0045     TECm,
0046     BPIX,
0047     FPIX,
0048     ESp,
0049     ESm,
0050     GEMp,
0051     GEMm,
0052     Last
0053   };
0054 
0055   DCSRecord();
0056   explicit DCSRecord(const online::DCS_v1&);
0057   explicit DCSRecord(const online::DCS_v2&);
0058   virtual ~DCSRecord();
0059 
0060   /// Return the time of the last change
0061   const edm::Timestamp& timestamp() const { return timestamp_; }
0062 
0063   /// Get the names of all high-voltage partitions
0064   typedef std::array<std::string, Last> ParitionNames;
0065   const ParitionNames& paritionNames() const { return partitionNames_; }
0066 
0067   /// Return the name of the high voltage of the given parition
0068   const std::string& partitionName(const uint8_t partitionNumber) const { return partitionNames_.at(partitionNumber); }
0069 
0070   /// Return true if the high voltage of the given parition is ready
0071   bool highVoltageReady(const uint8_t partitionNumber) const { return highVoltageReady_.test(partitionNumber); }
0072 
0073   /// Return true if the high voltage bit of the given partition is valid
0074   bool highVoltageValid(const uint8_t partitionNumber) const { return highVoltageValid_.test(partitionNumber); }
0075 
0076   /// Return the current of the CMS magnet in A
0077   float magnetCurrent() const { return magnetCurrent_; }
0078 
0079   /// Return the magnetic field of the CMS magnet in T
0080   /// The precision is 0.6 to 1.8 mT in the range of a current from 9500 to 18164 A (from Vyacheslav.Klyukhin@cern.ch)
0081   float magneticField() const { return (0.0002067 * magnetCurrent_ + 0.0557973); }
0082 
0083 private:
0084   edm::Timestamp timestamp_;
0085   std::bitset<Partition::Last> highVoltageReady_;
0086   std::bitset<Partition::Last> highVoltageValid_;
0087   float magnetCurrent_;
0088   static const ParitionNames partitionNames_;
0089 };
0090 
0091 /// Pretty-print operator for DCSRecord
0092 std::ostream& operator<<(std::ostream&, const DCSRecord&);
0093 
0094 #endif  // DATAFORMATS_ONLINEMETADATA_DCSRECORD_H