CMS 3D CMS Logo

InitMessage.cc
Go to the documentation of this file.
3 #include <iostream>
4 #include <iterator>
5 #include <cstring>
6 
7 using namespace edm::streamer;
8 
10  : buf_((uint8*)buf),
11  head_(buf),
12  release_start_(nullptr),
13  release_len_(0),
14  processName_start_(nullptr),
15  processName_len_(0),
16  outputModuleLabel_start_(nullptr),
17  outputModuleLabel_len_(0),
18  outputModuleId_(0),
19  hlt_trig_start_(nullptr),
20  hlt_trig_count_(0),
21  hlt_trig_len_(0),
22  hlt_select_start_(nullptr),
23  hlt_select_count_(0),
24  hlt_select_len_(0),
25  l1_trig_start_(nullptr),
26  l1_trig_count_(0),
27  l1_trig_len_(0),
28  adler32_chksum_(0),
29  host_name_start_(nullptr),
30  host_name_len_(0),
31  desc_start_(nullptr),
32  desc_len_(0) {
33  if (protocolVersion() == 2) {
34  std::cout << "Protocol Version 2 encountered" << std::endl;
35  release_start_ = buf_ + sizeof(InitHeader) - (sizeof(uint32) * 2);
36  // Minus the size for Init and Event Header size fileds
37  // in the InitHeader
38  } else { //For version 3
39  release_start_ = buf_ + sizeof(InitHeader);
40  }
42  release_start_ += sizeof(uint8);
44 
45  //Lets get Process Name from right after Release Name
46  if (protocolVersion() > 3) {
47  //std::cout << "Protocol Version > 3 encountered" << std::endl;
49  processName_start_ = (uint8*)(pos + sizeof(uint8));
51 
52  // Output Module Label
53  if (protocolVersion() > 4) {
55  outputModuleLabel_start_ = (uint8*)(pos + sizeof(uint8));
57 
58  // Output Module Id
59  if (protocolVersion() > 5) {
61  pos += sizeof(char_uint32);
62  }
63  }
64  }
65 
68  hlt_trig_start_ += sizeof(char_uint32);
70  hlt_trig_start_ += sizeof(char_uint32);
72 
73  if (protocolVersion() > 4) {
76  hlt_select_start_ += sizeof(char_uint32);
78  hlt_select_start_ += sizeof(char_uint32);
80  }
81 
84  l1_trig_start_ += sizeof(char_uint32);
86  l1_trig_start_ += sizeof(char_uint32);
88 
89  if (protocolVersion() > 7) {
91  pos += sizeof(uint32);
92 
93  if (protocolVersion() <= 9) {
96  host_name_start_ += sizeof(uint8);
98  }
99  }
100 
101  desc_start_ = pos;
103  desc_start_ += sizeof(char_uint32);
104 }
105 
107  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
108  return convert32(h->run_);
109 }
110 
112  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
113  return h->version_.protocol_;
114 }
115 
116 void InitMsgView::pset(uint8* put_here) const {
117  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
118  memcpy(put_here, h->version_.pset_id_, sizeof(h->version_.pset_id_));
119 }
120 
122  return std::string(reinterpret_cast<char*>(release_start_), release_len_);
123 }
124 
126  if (protocolVersion() < 4)
127  throw cms::Exception("Invalid Message Version", "InitMsgView")
128  << "Process Name is only supported in Protocol Version 4 and above"
129  << ".\n";
130 
131  return std::string(reinterpret_cast<char*>(processName_start_), processName_len_);
132 }
133 
135  if (protocolVersion() < 5)
136  throw cms::Exception("Invalid Message Version", "InitMsgView")
137  << "Output Module Label is only supported in Protocol Version 5 and above"
138  << ".\n";
139 
140  return std::string(reinterpret_cast<char*>(outputModuleLabel_start_), outputModuleLabel_len_);
141 }
142 
143 void InitMsgView::hltTriggerNames(Strings& save_here) const {
145 }
146 
148  if (protocolVersion() < 5)
149  throw cms::Exception("Invalid Message Version", "InitMsgView")
150  << "HLT trigger selections are only supported in Protocol Version 5 and above"
151  << ".\n";
152 
154 }
155 
156 void InitMsgView::l1TriggerNames(Strings& save_here) const {
158 }
159 
161  if (protocolVersion() == 2) {
164  uint32 hlt_sz = get_hlt_bit_cnt();
165  if (hlt_sz != 0)
166  hlt_sz = 1 + ((hlt_sz - 1) / 4);
167 
168  uint32 l1_sz = get_l1_bit_cnt();
169  if (l1_sz != 0)
170  l1_sz = 1 + ((l1_sz - 1) / 8);
171 
172  return 1 + (4 * 8) + hlt_sz + l1_sz;
173  }
174 
175  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
176  return convert32(h->event_header_size_);
177 }
178 
179 /***
180 uint32 InitMsgView::initHeaderSize() const
181 {
182  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
183  return convert32(h->init_header_size_);
184 } **/
185 
187  if (host_name_start_) {
188  std::string host_name(reinterpret_cast<char*>(host_name_start_), host_name_len_);
189  size_t found = host_name.find('\0');
190  if (found != std::string::npos) {
191  return std::string(host_name, 0, found);
192  } else {
193  return host_name;
194  }
195  } else {
196  return "n/a";
197  }
198 }
void hltTriggerNames(Strings &save_here) const
Definition: InitMessage.cc:143
uint32 convert32(char_uint32 v)
Definition: MsgTools.h:29
std::string releaseTag() const
Definition: InitMessage.cc:121
std::string hostName() const
Definition: InitMessage.cc:186
uint32 get_hlt_bit_cnt() const
Definition: InitMessage.h:82
void l1TriggerNames(Strings &save_here) const
Definition: InitMessage.cc:156
uint32 get_l1_bit_cnt() const
Definition: InitMessage.h:83
void pset(uint8 *put_here) const
Definition: InitMessage.cc:116
unsigned char uint8
Definition: MsgTools.h:12
uint32 protocolVersion() const
Definition: InitMessage.cc:111
std::string processName() const
Definition: InitMessage.cc:125
void getNames(uint8 *from, uint32 from_len, Strings &to)
Definition: MsgTools.h:86
void hltTriggerSelections(Strings &save_here) const
Definition: InitMessage.cc:147
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:17
std::vector< std::string > Strings
Definition: MsgTools.h:19
uint32 eventHeaderSize() const
Definition: InitMessage.cc:160
unsigned int uint32
Definition: MsgTools.h:14
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::string outputModuleLabel() const
Definition: InitMessage.cc:134