Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-06 04:00:44

0001 #include <iomanip>
0002 #include <ctime>
0003 
0004 #include "DataFormats/OnlineMetaData/interface/DCSRecord.h"
0005 #include "DataFormats/OnlineMetaData/interface/OnlineMetaDataRaw.h"
0006 
0007 const DCSRecord::ParitionNames DCSRecord::partitionNames_ = {
0008     {"EBp",  "EBm",    "EEp", "EEm",    "HBHEa", "HBHEb", "HBHEc", "HF",   "HO",   "RPC", "DT0", "DTp",  "DTm", "CSCp",
0009      "CSCm", "CASTOR", "ZDC", "TIBTID", "TOB",   "TECp",  "TECm",  "BPIX", "FPIX", "ESp", "ESm", "GEMp", "GEMm"}};
0010 
0011 DCSRecord::DCSRecord() : timestamp_(edm::Timestamp::invalidTimestamp()), magnetCurrent_(-1) {}
0012 
0013 DCSRecord::DCSRecord(const online::DCS_v1& dcs) {
0014   // DIP timestamp is in milliseconds
0015   const uint64_t seconds = dcs.timestamp / 1000;
0016   const uint32_t microseconds = (dcs.timestamp % 1000) * 1000;
0017   timestamp_ = edm::Timestamp((seconds << 32) | microseconds);
0018   highVoltageReady_ = dcs.highVoltageReady;
0019   //bit always valid for V1
0020   highVoltageValid_ = 0xffffffff;
0021   magnetCurrent_ = dcs.magnetCurrent;
0022 }
0023 
0024 DCSRecord::DCSRecord(const online::DCS_v2& dcs) {
0025   // DIP timestamp is in milliseconds
0026   const uint64_t seconds = dcs.timestamp / 1000;
0027   const uint32_t microseconds = (dcs.timestamp % 1000) * 1000;
0028   timestamp_ = edm::Timestamp((seconds << 32) | microseconds);
0029   highVoltageReady_ = dcs.highVoltageReady;
0030   highVoltageValid_ = dcs.highVoltageValid;
0031   magnetCurrent_ = dcs.magnetCurrent;
0032 }
0033 
0034 DCSRecord::~DCSRecord() {}
0035 
0036 std::ostream& operator<<(std::ostream& s, const DCSRecord& dcs) {
0037   const time_t ts = dcs.timestamp().unixTime();
0038 
0039   s << "timeStamp:            " << asctime(localtime(&ts));
0040 
0041   std::streamsize ss = s.precision();
0042   s.setf(std::ios::fixed);
0043   s.precision(3);
0044   s << "Magnet current (A):   " << std::fixed << std::setprecision(3) << dcs.magnetCurrent() << std::endl;
0045   s.unsetf(std::ios::fixed);
0046   s.precision(ss);
0047 
0048   s << "HV state per partition:" << std::endl;
0049 
0050   for (unsigned int i = 0; i < DCSRecord::Partition::Last; ++i) {
0051     s << "   " << std::setw(7) << std::left << dcs.partitionName(i) << ": "
0052       << (!dcs.highVoltageValid(i) ? "N/A" : (dcs.highVoltageReady(i) ? "READY" : "OFF")) << std::endl;
0053   }
0054 
0055   return s;
0056 }