CMS 3D CMS Logo

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