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 
11  EBp ,
12  EBm ,
13  EEp ,
14  EEm ,
15  HBHEa ,
16  HBHEb ,
17  HBHEc ,
18  HF ,
19  HO ,
20  RPC ,
21  DT0 ,
22  DTp ,
23  DTm ,
24  CSCp ,
25  CSCm ,
26  CASTOR ,
27  ZDC ,
28  TIBTID ,
29  TOB ,
30  TECp ,
31  TECm ,
32  BPIX ,
33  FPIX ,
34  ESp ,
35  ESm };
36 
38  "EBp" ,
39  "EBm" ,
40  "EEp" ,
41  "EEm" ,
42  "HBHEa" ,
43  "HBHEb" ,
44  "HBHEc" ,
45  "HF" ,
46  "HO" ,
47  "RPC" ,
48  "DT0" ,
49  "DTp" ,
50  "DTm" ,
51  "CSCp" ,
52  "CSCm" ,
53  "CASTOR" ,
54  "ZDC" ,
55  "TIBTID" ,
56  "TOB" ,
57  "TECp" ,
58  "TECm" ,
59  "BPIX" ,
60  "FPIX" ,
61  "ESp" ,
62  "ESm" };
63 
65  trigType_(0),
66  eventID_(0),
67  sourceID_(0),
68  bunchNumber_(0),
69  version_(0),
70  collectionTime_(0,0),
71  ready_(0),
72  magnetCurrent_((float)0.0),
73  magnetTemperature_((float)0.0)
74 {
75 }
76 
77 DcsStatus::DcsStatus(const unsigned char * rawData)
78 {
79  DcsStatus();
80 
81  struct ScalersEventRecordRaw_v4 const * raw
82  = reinterpret_cast<struct ScalersEventRecordRaw_v4 const *>(rawData);
83  trigType_ = ( raw->header >> 56 ) & 0xFULL;
84  eventID_ = ( raw->header >> 32 ) & 0x00FFFFFFULL;
85  sourceID_ = ( raw->header >> 8 ) & 0x00000FFFULL;
86  bunchNumber_ = ( raw->header >> 20 ) & 0xFFFULL;
87 
88  version_ = raw->version;
89  if ( version_ >= 4 )
90  {
91  collectionTime_.set_tv_sec(static_cast<long>(raw->dcsStatus.collectionTime_sec));
93  ready_ = raw->dcsStatus.ready;
96  }
97 }
98 
100 
101 
103 std::ostream& operator<<(std::ostream& s, const DcsStatus& c)
104 {
105  constexpr size_t kZeitBufferSize = 128;
106  char zeit[kZeitBufferSize];
107  constexpr size_t kLineBufferSize = 157;
108  char line[kLineBufferSize];
109  struct tm * hora;
110 
111  s << "DcsStatus Version: " << c.version() <<
112  " SourceID: "<< c.sourceID() << std::endl;
113 
114  timespec ts = c.collectionTime();
115  hora = gmtime(&ts.tv_sec);
116  strftime(zeit, kZeitBufferSize, "%Y.%m.%d %H:%M:%S", hora);
117  snprintf(line, kLineBufferSize, " CollectionTime: %s.%9.9d", zeit,
118  (int)ts.tv_nsec);
119  s << line << std::endl;
120 
121  snprintf(line, kLineBufferSize, " TrigType: %d EventID: %d BunchNumber: %d",
122  c.trigType(), c.eventID(), c.bunchNumber());
123  s << line << std::endl;
124 
125  snprintf(line, kLineBufferSize, " MagnetCurrent: %e MagnetTemperature: %e",
127  s << line << std::endl;
128 
129  snprintf(line,kLineBufferSize," Ready: %d 0x%8.8X", c.ready(), c.ready());
130  s << line << std::endl;
131 
132  for ( int i=0; i<DcsStatus::nPartitions; i++)
133  {
135  {
136  snprintf(line,kLineBufferSize," %2d %6s: READY", i, DcsStatus::partitionName[i]);
137  }
138  else
139  {
140  snprintf(line,kLineBufferSize," %2d %6s: NOT READY", i, DcsStatus::partitionName[i]);
141  }
142  s << line << std::endl;
143  }
144  return s;
145 }
unsigned int trigType() const
Definition: DcsStatus.h:76
timespec collectionTime() const
Definition: DcsStatus.h:82
unsigned int bunchNumber_
Definition: DcsStatus.h:103
void set_tv_nsec(long value)
Definition: TimeSpec.h:27
virtual ~DcsStatus()
Definition: DcsStatus.cc:99
unsigned int bunchNumber() const
Definition: DcsStatus.h:79
float magnetTemperature() const
Definition: DcsStatus.h:90
#define constexpr
unsigned int eventID_
Definition: DcsStatus.h:101
unsigned long long header
Definition: ScalersRaw.h:222
int version() const
Definition: DcsStatus.h:81
unsigned int ready() const
Definition: DcsStatus.h:84
int version_
Definition: DcsStatus.h:105
unsigned int sourceID() const
Definition: DcsStatus.h:78
unsigned int ready
Definition: ScalersRaw.h:183
unsigned int collectionTime_sec
Definition: ScalersRaw.h:181
static const char *const partitionName[]
Definition: DcsStatus.h:33
#define BPIX
unsigned int trigType_
Definition: DcsStatus.h:100
unsigned int ready_
Definition: DcsStatus.h:108
TimeSpec collectionTime_
Definition: DcsStatus.h:107
unsigned int sourceID_
Definition: DcsStatus.h:102
float magnetCurrent
Definition: ScalersRaw.h:184
unsigned int collectionTime_nsec
Definition: ScalersRaw.h:182
void set_tv_sec(long value)
Definition: TimeSpec.h:26
float magnetTemperature_
Definition: DcsStatus.h:110
struct DcsStatusRaw_v4 dcsStatus
Definition: ScalersRaw.h:227
float magnetTemperature
Definition: ScalersRaw.h:185
float magnetCurrent() const
Definition: DcsStatus.h:89
unsigned int eventID() const
Definition: DcsStatus.h:77
std::ostream & operator<<(std::ostream &s, const DcsStatus &c)
Pretty-print operator for DcsStatus.
Definition: DcsStatus.cc:103
float magnetCurrent_
Definition: DcsStatus.h:109
static const int partitionList[]
Definition: DcsStatus.h:32