CMS 3D CMS Logo

BeamSpotOnline.cc
Go to the documentation of this file.
1 /*
2  * File: DataFormats/Scalers/src/BeamSpotOnline.cc (W.Badgett)
3  */
4 
7 #include <cstdio>
8 #include <ostream>
9 
11  : trigType_(0),
12  eventID_(0),
13  sourceID_(0),
14  bunchNumber_(0),
15  version_(0),
16  collectionTime_(0, 0),
17  x_((float)0.0),
18  y_((float)0.0),
19  z_((float)0.0),
20  dxdz_((float)0.0),
21  dydz_((float)0.0),
22  err_x_((float)0.0),
23  err_y_((float)0.0),
24  err_z_((float)0.0),
25  err_dxdz_((float)0.0),
26  err_dydz_((float)0.0),
27  width_x_((float)0.0),
28  width_y_((float)0.0),
29  sigma_z_((float)0.0),
30  err_width_x_((float)0.0),
31  err_width_y_((float)0.0),
32  err_sigma_z_((float)0.0) {}
33 
34 BeamSpotOnline::BeamSpotOnline(const unsigned char* rawData) {
36 
37  struct ScalersEventRecordRaw_v4 const* raw = reinterpret_cast<struct ScalersEventRecordRaw_v4 const*>(rawData);
38  trigType_ = (raw->header >> 56) & 0xFULL;
39  eventID_ = (raw->header >> 32) & 0x00FFFFFFULL;
40  sourceID_ = (raw->header >> 8) & 0x00000FFFULL;
41  bunchNumber_ = (raw->header >> 20) & 0xFFFULL;
42 
43  version_ = raw->version;
44  if (version_ >= 4) {
47  x_ = raw->beamSpotOnline.x;
48  y_ = raw->beamSpotOnline.y;
49  z_ = raw->beamSpotOnline.z;
50  dxdz_ = raw->beamSpotOnline.dxdz;
51  dydz_ = raw->beamSpotOnline.dydz;
63  }
64 }
65 
67 
69 std::ostream& operator<<(std::ostream& s, const BeamSpotOnline& c) {
70  char zeit[128];
71  constexpr size_t kLineBufferSize = 157;
72  char line[kLineBufferSize];
73  struct tm* hora;
74 
75  s << "BeamSpotOnline Version: " << c.version() << " SourceID: " << c.sourceID() << std::endl;
76 
77  timespec ts = c.collectionTime();
78  hora = gmtime(&ts.tv_sec);
79  strftime(zeit, sizeof(zeit), "%Y.%m.%d %H:%M:%S", hora);
80  snprintf(line, kLineBufferSize, " CollectionTime: %s.%9.9d", zeit, (int)ts.tv_nsec);
81  s << line << std::endl;
82 
83  snprintf(line,
84  kLineBufferSize,
85  " TrigType: %d EventID: %d BunchNumber: %d",
86  c.trigType(),
87  c.eventID(),
88  c.bunchNumber());
89  s << line << std::endl;
90 
91  snprintf(
92  line, kLineBufferSize, " x: %e +/- %e width: %e +/- %e", c.x(), c.err_x(), c.width_x(), c.err_width_x());
93  s << line << std::endl;
94 
95  snprintf(
96  line, kLineBufferSize, " y: %e +/- %e width: %e +/- %e", c.y(), c.err_y(), c.width_y(), c.err_width_y());
97  s << line << std::endl;
98 
99  snprintf(
100  line, kLineBufferSize, " z: %e +/- %e sigma: %e +/- %e", c.z(), c.err_z(), c.sigma_z(), c.err_sigma_z());
101  s << line << std::endl;
102 
103  snprintf(
104  line, kLineBufferSize, " dxdy: %e +/- %e dydz: %e +/- %e", c.dxdz(), c.err_dxdz(), c.dydz(), c.err_dydz());
105  s << line << std::endl;
106  return s;
107 }
virtual ~BeamSpotOnline()
unsigned int eventID_
void set_tv_nsec(long value)
Definition: TimeSpec.h:19
unsigned int collectionTime_nsec
Definition: ScalersRaw.h:154
unsigned int collectionTime_sec
Definition: ScalersRaw.h:153
struct BeamSpotOnlineRaw_v4 beamSpotOnline
Definition: ScalersRaw.h:215
TimeSpec collectionTime_
unsigned long long header
Definition: ScalersRaw.h:211
void set_tv_sec(long value)
Definition: TimeSpec.h:18
std::ostream & operator<<(std::ostream &s, const BeamSpotOnline &c)
Pretty-print operator for BeamSpotOnline.
unsigned int sourceID_
unsigned int trigType_
unsigned int bunchNumber_