CMS 3D CMS Logo

DcsStatus.cc
Go to the documentation of this file.
1 /*
2  * File: DataFormats/Scalers/src/DcsStatus.cc (W.Badgett)
3  */
4 
7 #include <cstdio>
8 #include <ostream>
9 
10 const int DcsStatus::partitionList[DcsStatus::nPartitions] = {EBp, EBm, EEp, EEm, HBHEa, HBHEb, HBHEc, HF, HO,
11  RPC, DT0, DTp, DTm, CSCp, CSCm, CASTOR, ZDC, TIBTID,
12  TOB, TECp, TECm, BPIX, FPIX, ESp, ESm};
13 
15  "EBp", "EBm", "EEp", "EEm", "HBHEa", "HBHEb", "HBHEc", "HF", "HO", "RPC", "DT0", "DTp", "DTm",
16  "CSCp", "CSCm", "CASTOR", "ZDC", "TIBTID", "TOB", "TECp", "TECm", "BPIX", "FPIX", "ESp", "ESm"};
17 
19  : trigType_(0),
20  eventID_(0),
21  sourceID_(0),
22  bunchNumber_(0),
23  version_(0),
24  collectionTime_(0, 0),
25  ready_(0),
26  magnetCurrent_((float)0.0),
27  magnetTemperature_((float)0.0) {}
28 
29 DcsStatus::DcsStatus(const unsigned char* rawData) {
30  DcsStatus();
31 
32  struct ScalersEventRecordRaw_v4 const* raw = reinterpret_cast<struct ScalersEventRecordRaw_v4 const*>(rawData);
33  trigType_ = (raw->header >> 56) & 0xFULL;
34  eventID_ = (raw->header >> 32) & 0x00FFFFFFULL;
35  sourceID_ = (raw->header >> 8) & 0x00000FFFULL;
36  bunchNumber_ = (raw->header >> 20) & 0xFFFULL;
37 
38  version_ = raw->version;
39  if (version_ >= 4) {
40  collectionTime_.set_tv_sec(static_cast<long>(raw->dcsStatus.collectionTime_sec));
42  ready_ = raw->dcsStatus.ready;
45  }
46 }
47 
49 
51 std::ostream& operator<<(std::ostream& s, const DcsStatus& c) {
52  constexpr size_t kZeitBufferSize = 128;
53  char zeit[kZeitBufferSize];
54  constexpr size_t kLineBufferSize = 157;
55  char line[kLineBufferSize];
56  struct tm* hora;
57 
58  s << "DcsStatus Version: " << c.version() << " SourceID: " << c.sourceID() << std::endl;
59 
60  timespec ts = c.collectionTime();
61  hora = gmtime(&ts.tv_sec);
62  strftime(zeit, kZeitBufferSize, "%Y.%m.%d %H:%M:%S", hora);
63  snprintf(line, kLineBufferSize, " CollectionTime: %s.%9.9d", zeit, (int)ts.tv_nsec);
64  s << line << std::endl;
65 
66  snprintf(line,
67  kLineBufferSize,
68  " TrigType: %d EventID: %d BunchNumber: %d",
69  c.trigType(),
70  c.eventID(),
71  c.bunchNumber());
72  s << line << std::endl;
73 
74  snprintf(
75  line, kLineBufferSize, " MagnetCurrent: %e MagnetTemperature: %e", c.magnetCurrent(), c.magnetTemperature());
76  s << line << std::endl;
77 
78  snprintf(line, kLineBufferSize, " Ready: %d 0x%8.8X", c.ready(), c.ready());
79  s << line << std::endl;
80 
81  for (int i = 0; i < DcsStatus::nPartitions; i++) {
82  if (c.ready(DcsStatus::partitionList[i])) {
83  snprintf(line, kLineBufferSize, " %2d %6s: READY", i, DcsStatus::partitionName[i]);
84  } else {
85  snprintf(line, kLineBufferSize, " %2d %6s: NOT READY", i, DcsStatus::partitionName[i]);
86  }
87  s << line << std::endl;
88  }
89  return s;
90 }
unsigned int bunchNumber_
Definition: DcsStatus.h:97
void set_tv_nsec(long value)
Definition: TimeSpec.h:19
virtual ~DcsStatus()
Definition: DcsStatus.cc:48
unsigned int eventID_
Definition: DcsStatus.h:95
unsigned long long header
Definition: ScalersRaw.h:211
int version_
Definition: DcsStatus.h:99
unsigned int ready
Definition: ScalersRaw.h:176
unsigned int collectionTime_sec
Definition: ScalersRaw.h:174
static const char *const partitionName[]
Definition: DcsStatus.h:31
#define BPIX
unsigned int trigType_
Definition: DcsStatus.h:94
unsigned int ready_
Definition: DcsStatus.h:102
TimeSpec collectionTime_
Definition: DcsStatus.h:101
unsigned int sourceID_
Definition: DcsStatus.h:96
float magnetCurrent
Definition: ScalersRaw.h:177
unsigned int collectionTime_nsec
Definition: ScalersRaw.h:175
void set_tv_sec(long value)
Definition: TimeSpec.h:18
float magnetTemperature_
Definition: DcsStatus.h:104
struct DcsStatusRaw_v4 dcsStatus
Definition: ScalersRaw.h:216
float magnetTemperature
Definition: ScalersRaw.h:178
std::ostream & operator<<(std::ostream &s, const DcsStatus &c)
Pretty-print operator for DcsStatus.
Definition: DcsStatus.cc:51
float magnetCurrent_
Definition: DcsStatus.h:103
static const int partitionList[]
Definition: DcsStatus.h:30