CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  char line[128];
79  struct tm * hora;
80 
81  s << "BeamSpotOnline Version: " << c.version() <<
82  " SourceID: "<< c.sourceID() << std::endl;
83 
84  timespec ts = c.collectionTime();
85  hora = gmtime(&ts.tv_sec);
86  strftime(zeit, sizeof(zeit), "%Y.%m.%d %H:%M:%S", hora);
87  sprintf(line, " CollectionTime: %s.%9.9d", zeit,
88  (int)ts.tv_nsec);
89  s << line << std::endl;
90 
91  sprintf(line, " TrigType: %d EventID: %d BunchNumber: %d",
92  c.trigType(), c.eventID(), c.bunchNumber());
93  s << line << std::endl;
94 
95  sprintf(line," x: %e +/- %e width: %e +/- %e",
96  c.x(), c.err_x(), c.width_x(), c.err_width_x());
97  s << line << std::endl;
98 
99  sprintf(line," y: %e +/- %e width: %e +/- %e",
100  c.y(), c.err_y(), c.width_y(), c.err_width_y());
101  s << line << std::endl;
102 
103  sprintf(line," z: %e +/- %e sigma: %e +/- %e",
104  c.z(), c.err_z(), c.sigma_z(), c.err_sigma_z());
105  s << line << std::endl;
106 
107  sprintf(line," dxdy: %e +/- %e dydz: %e +/- %e",
108  c.dxdz(), c.err_dxdz(), c.dydz(), c.err_dydz());
109  s << line << std::endl;
110  return s;
111 }
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
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
struct BeamSpotOnlineRaw_v4 beamSpotOnline
Definition: ScalersRaw.h:226
TimeSpec collectionTime_
float width_y() const
float err_width_y() const
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
unsigned int trigType() const
float err_sigma_z() const
unsigned int sourceID_
unsigned int trigType_
unsigned int bunchNumber_