CMS 3D CMS Logo

FRDEventMessage.cc
Go to the documentation of this file.
1 
14 
15 using namespace edm::streamer;
16 
21  : buf_((uint8*)buf),
22  payload_(nullptr),
23  size_(0),
24  version_(0),
25  flags_(0),
26  run_(0),
27  lumi_(0),
28  event_(0),
29  eventSize_(0),
30  paddingSize_(0),
31  adler32_(0),
32  crc32c_(0) {
33  uint32* bufPtr = static_cast<uint32*>(buf);
34 
35  // In version one of the format, there was no version number in the data,
36  // and the run number (32-bit) appeared first.
37  // This format is no longer supported
38  version_ = *(uint16*)bufPtr;
39 
40  if (version_ < 2 || version_ > 6) {
41  throw cms::Exception("FRDEventMsgView") << "FRD version " << version_ << " is not supported";
42  }
43 
44  // Version 6 repurposes unused high 16-bits of 32-bit version
45  // assuming we no longer need version 1 support
46  flags_ = *((uint16*)bufPtr + 1);
47 
48  if (version_ < 6 && flags_) {
49  throw cms::Exception("FRDEventMsgView") << "FRD flags can not be used in version " << version_;
50  }
51 
52  size_ = sizeof(uint32);
53  ++bufPtr;
54 
55  // run number
56  run_ = *bufPtr;
57  size_ += sizeof(uint32);
58  ++bufPtr;
59 
60  // lumi number
61  if (version_ >= 2) {
62  lumi_ = *bufPtr;
63  size_ += sizeof(uint32);
64  ++bufPtr;
65  }
66 
67  // event number
68  if (version_ == 4) {
69  uint64 eventLow = *bufPtr;
70  size_ += sizeof(uint32);
71  ++bufPtr;
72 
73  uint64 eventHigh = *bufPtr;
74  size_ += sizeof(uint32);
75  ++bufPtr;
76 
77  event_ = (eventHigh << 32) | eventLow;
78 
79  } else {
80  event_ = *bufPtr;
81  size_ += sizeof(uint32);
82  ++bufPtr;
83  }
84 
85  if (version_ >= 3) {
86  // event size
87  eventSize_ = *bufPtr;
88  size_ += sizeof(uint32) + eventSize_;
89  ++bufPtr;
90 
91  if (version_ >= 5) {
92  crc32c_ = *bufPtr;
93  size_ += sizeof(uint32);
94  ++bufPtr;
95  } else {
96  // padding size up to V4
97  paddingSize_ = *bufPtr;
98  size_ += sizeof(uint32) + paddingSize_;
99  ++bufPtr;
100 
101  adler32_ = *bufPtr;
102  size_ += sizeof(uint32);
103  ++bufPtr;
104  }
105  } else {
106  for (int idx = 0; idx < 1024; idx++) {
107  size_ += sizeof(uint32); // FED N size
108  size_ += *bufPtr; // FED N data
109  eventSize_ += *bufPtr;
110  ++bufPtr;
111  }
112  }
113 
114  payload_ = (void*)bufPtr;
115 }
unsigned char uint8
Definition: MsgTools.h:12
unsigned long long uint64
Definition: MsgTools.h:15
unsigned short uint16
Definition: MsgTools.h:13
unsigned int uint32
Definition: MsgTools.h:14