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),head_(buf)
9 {
10  if (protocolVersion() == 2) {
11  std::cout << "Protocol Version 2 encountered" << std::endl;
12  release_start_ = buf_ + sizeof(InitHeader) - (sizeof(uint32)*2);
13  // Minus the size for Init and Event Header size fileds
14  // in the InitHeader
15  } else { //For version 3
16  release_start_ = buf_ + sizeof(InitHeader);
17  }
19  release_start_ += sizeof(uint8);
21 
22  //Lets get Process Name from right after Release Name
23  if (protocolVersion() > 3) {
24  //std::cout << "Protocol Version > 3 encountered" << std::endl;
26  processName_start_ = (uint8*)(pos + sizeof(uint8));
28 
29  // Output Module Label
30  if (protocolVersion() > 4) {
32  outputModuleLabel_start_ = (uint8*)(pos + sizeof(uint8));
34 
35  // Output Module Id
36  if (protocolVersion() > 5) {
38  pos += sizeof(char_uint32);
39  }
40  }
41  }
42 
43 
46  hlt_trig_start_ += sizeof(char_uint32);
48  hlt_trig_start_ += sizeof(char_uint32);
50 
51  if (protocolVersion() > 4) {
54  hlt_select_start_ += sizeof(char_uint32);
56  hlt_select_start_ += sizeof(char_uint32);
58  }
59 
62  l1_trig_start_ += sizeof(char_uint32);
64  l1_trig_start_ += sizeof(char_uint32);
66 
67  if (protocolVersion() > 7) {
69  host_name_start_ = pos + sizeof(uint32);
71  host_name_start_ += sizeof(uint8);
73  }
74 
75  desc_start_ = pos;
77  desc_start_ += sizeof(char_uint32);
78 }
79 
81 {
82  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
83  return convert32(h->run_);
84 }
85 
87 {
88  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
89  return h->version_.protocol_;
90 }
91 
92 void InitMsgView::pset(uint8* put_here) const
93 {
94  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
95  memcpy(put_here,h->version_.pset_id_,sizeof(h->version_.pset_id_));
96 }
97 
98 std::string InitMsgView::releaseTag() const
99 {
100  return std::string(reinterpret_cast<char *>(release_start_),release_len_);
101 }
102 
103 std::string InitMsgView::processName() const
104 {
105  if (protocolVersion() < 4)
106  throw cms::Exception("Invalid Message Version", "InitMsgView")
107  << "Process Name is only supported in Protocol Version 4 and above" << ".\n";
108 
109  return std::string(reinterpret_cast<char *>(processName_start_),processName_len_);
110 }
111 
113 {
114  if (protocolVersion() < 5)
115  throw cms::Exception("Invalid Message Version", "InitMsgView")
116  << "Output Module Label is only supported in Protocol Version 5 and above" << ".\n";
117 
118  return std::string(reinterpret_cast<char *>(outputModuleLabel_start_),outputModuleLabel_len_);
119 }
120 
121 
122 void InitMsgView::hltTriggerNames(Strings& save_here) const
123 {
125 }
126 
128 {
129  if (protocolVersion() < 5)
130  throw cms::Exception("Invalid Message Version", "InitMsgView")
131  << "HLT trigger selections are only supported in Protocol Version 5 and above" << ".\n";
132 
134 }
135 
136 void InitMsgView::l1TriggerNames(Strings& save_here) const
137 {
139 }
140 
142 {
143  if (protocolVersion() == 2) {
146  uint32 hlt_sz = get_hlt_bit_cnt();
147  if (hlt_sz != 0 ) hlt_sz = 1+ ((hlt_sz-1)/4);
148 
149  uint32 l1_sz = get_l1_bit_cnt();
150  if (l1_sz != 0) l1_sz = 1 + ((l1_sz-1)/8);
151 
152  return 1 + (4*8) + hlt_sz+l1_sz;
153  }
154 
155  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
156  return convert32(h->event_header_size_);
157 }
158 
159 /***
160 uint32 InitMsgView::initHeaderSize() const
161 {
162  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
163  return convert32(h->init_header_size_);
164 } **/
165 
166 std::string InitMsgView::hostName() const
167 {
168  //return std::string(reinterpret_cast<char *>(host_name_start_),host_name_len_);
169  std::string host_name(reinterpret_cast<char *>(host_name_start_),host_name_len_);
170  size_t found = host_name.find('\0');
171  if(found != std::string::npos) {
172  return std::string(host_name, 0, found);
173  } else {
174  return host_name;
175  }
176 }
std::vector< std::string > Strings
Definition: MsgTools.h:18
boost::shared_array< char > buf_
char_uint32 event_header_size_
Definition: InitMessage.h:56
uint32 hlt_select_count_
Definition: InitMessage.h:111
uint8 protocol_
Definition: InitMessage.h:37
void hltTriggerNames(Strings &save_here) const
Definition: InitMessage.cc:122
uint32 release_len_
Definition: InitMessage.h:98
uint8 * desc_start_
Definition: InitMessage.h:122
uint32 hlt_trig_len_
Definition: InitMessage.h:109
std::string releaseTag() const
Definition: InitMessage.cc:98
uint32 desc_len_
Definition: InitMessage.h:123
InitMsgView(void *buf)
Definition: InitMessage.cc:7
unsigned char pset_id_[16]
Definition: InitMessage.h:38
uint32 l1_trig_len_
Definition: InitMessage.h:115
std::string hostName() const
Definition: InitMessage.cc:166
uint8 * l1_trig_start_
Definition: InitMessage.h:113
Version version_
Definition: InitMessage.h:53
uint32 outputModuleLabel_len_
Definition: InitMessage.h:104
uint8 * outputModuleLabel_start_
Definition: InitMessage.h:103
void l1TriggerNames(Strings &save_here) const
Definition: InitMessage.cc:136
uint8 * release_start_
Definition: InitMessage.h:97
unsigned int uint32
Definition: MsgTools.h:13
uint32 host_name_len_
Definition: InitMessage.h:118
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:16
uint32 processName_len_
Definition: InitMessage.h:101
uint32 protocolVersion() const
Definition: InitMessage.cc:86
std::string outputModuleLabel() const
Definition: InitMessage.cc:112
uint32 outputModuleId_
Definition: InitMessage.h:105
uint32 eventHeaderSize() const
Definition: InitMessage.cc:141
uint8 * hlt_trig_start_
Definition: InitMessage.h:107
char_uint32 run_
Definition: InitMessage.h:54
uint8 * host_name_start_
Definition: InitMessage.h:117
uint8 * hlt_select_start_
Definition: InitMessage.h:110
uint32 convert32(char_uint32 v)
Definition: MsgTools.h:30
unsigned char uint8
Definition: MsgTools.h:11
uint8 * buf_
Definition: InitMessage.h:94
std::string processName() const
Definition: InitMessage.cc:103
uint32 get_hlt_bit_cnt() const
Definition: InitMessage.h:81
uint32 run() const
Definition: InitMessage.cc:80
tuple cout
Definition: gather_cfg.py:41
uint32 adler32_chksum_
Definition: InitMessage.h:116
uint32 hlt_trig_count_
Definition: InitMessage.h:108
void getNames(uint8 *from, uint32 from_len, Strings &to)
Definition: MsgTools.h:91
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
uint32 get_l1_bit_cnt() const
Definition: InitMessage.h:82
uint8 * processName_start_
Definition: InitMessage.h:100
uint32 l1_trig_count_
Definition: InitMessage.h:114
void hltTriggerSelections(Strings &save_here) const
Definition: InitMessage.cc:127
void pset(uint8 *put_here) const
Definition: InitMessage.cc:92
uint32 hlt_select_len_
Definition: InitMessage.h:112