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 }
35 
36 BeamSpotOnline::BeamSpotOnline(const unsigned char * rawData)
37 {
39 
40  struct ScalersEventRecordRaw_v4 const* raw
41  = reinterpret_cast<struct ScalersEventRecordRaw_v4 const*>(rawData);
42  trigType_ = ( raw->header >> 56 ) & 0xFULL;
43  eventID_ = ( raw->header >> 32 ) & 0x00FFFFFFULL;
44  sourceID_ = ( raw->header >> 8 ) & 0x00000FFFULL;
45  bunchNumber_ = ( raw->header >> 20 ) & 0xFFFULL;
46 
47  version_ = raw->version;
48  if ( version_ >= 4 )
49  {
52  x_ = raw->beamSpotOnline.x;
53  y_ = raw->beamSpotOnline.y;
54  z_ = raw->beamSpotOnline.z;
55  dxdz_ = raw->beamSpotOnline.dxdz;
56  dydz_ = raw->beamSpotOnline.dydz;
68  }
69 }
70 
72 
73 
75 std::ostream& operator<<(std::ostream& s, const BeamSpotOnline& c)
76 {
77  char zeit[128];
78  constexpr size_t kLineBufferSize = 157;
79  char line[kLineBufferSize];
80  struct tm * hora;
81 
82  s << "BeamSpotOnline Version: " << c.version() <<
83  " SourceID: "<< c.sourceID() << std::endl;
84 
85  timespec ts = c.collectionTime();
86  hora = gmtime(&ts.tv_sec);
87  strftime(zeit, sizeof(zeit), "%Y.%m.%d %H:%M:%S", hora);
88  snprintf(line, kLineBufferSize,
89  " CollectionTime: %s.%9.9d", zeit,
90  (int)ts.tv_nsec);
91  s << line << std::endl;
92 
93  snprintf(line, kLineBufferSize,
94  " TrigType: %d EventID: %d BunchNumber: %d",
95  c.trigType(), c.eventID(), c.bunchNumber());
96  s << line << std::endl;
97 
98  snprintf(line, kLineBufferSize,
99  " x: %e +/- %e width: %e +/- %e",
100  c.x(), c.err_x(), c.width_x(), c.err_width_x());
101  s << line << std::endl;
102 
103  snprintf(line, kLineBufferSize,
104  " y: %e +/- %e width: %e +/- %e",
105  c.y(), c.err_y(), c.width_y(), c.err_width_y());
106  s << line << std::endl;
107 
108  snprintf(line, kLineBufferSize,
109  " z: %e +/- %e sigma: %e +/- %e",
110  c.z(), c.err_z(), c.sigma_z(), c.err_sigma_z());
111  s << line << std::endl;
112 
113  snprintf(line, kLineBufferSize,
114  " dxdy: %e +/- %e dydz: %e +/- %e",
115  c.dxdz(), c.err_dxdz(), c.dydz(), c.err_dydz());
116  s << line << std::endl;
117  return s;
118 }
float err_y() const
float dxdz() const
virtual ~BeamSpotOnline()
unsigned int eventID_
float err_x() const
void set_tv_nsec(long value)
Definition: TimeSpec.h:27
float dydz() const
unsigned int collectionTime_nsec
Definition: ScalersRaw.h:160
float sigma_z() const
float y() const
float x() const
float err_dydz() const
unsigned int collectionTime_sec
Definition: ScalersRaw.h:159
float z() const
struct BeamSpotOnlineRaw_v4 beamSpotOnline
Definition: ScalersRaw.h:226
TimeSpec collectionTime_
float width_y() const
float err_width_y() const
#define constexpr
unsigned long long header
Definition: ScalersRaw.h:222
unsigned int sourceID() const
unsigned int bunchNumber() const
int version() const
float err_dxdz() const
float err_width_x() const
float err_z() const
timespec collectionTime() const
unsigned int eventID() const
float width_x() const
void set_tv_sec(long value)
Definition: TimeSpec.h:26
std::ostream & operator<<(std::ostream &s, const BeamSpotOnline &c)
Pretty-print operator for BeamSpotOnline.
unsigned int trigType() const
float err_sigma_z() const
unsigned int sourceID_
unsigned int trigType_
unsigned int bunchNumber_