CMS 3D CMS Logo

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_(nullptr),
11  release_len_(0),
12  processName_start_(nullptr),
13  processName_len_(0),
14  outputModuleLabel_start_(nullptr),
15  outputModuleLabel_len_(0),
16  outputModuleId_(0),
17  hlt_trig_start_(nullptr),
18  hlt_trig_count_(0),
19  hlt_trig_len_(0),
20  hlt_select_start_(nullptr),
21  hlt_select_count_(0),
22  hlt_select_len_(0),
23  l1_trig_start_(nullptr),
24  l1_trig_count_(0),
25  l1_trig_len_(0),
26  adler32_chksum_(0),
27  host_name_start_(nullptr),
28  host_name_len_(0),
29  desc_start_(nullptr),
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;
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 
66  hlt_trig_start_ += sizeof(char_uint32);
68  hlt_trig_start_ += sizeof(char_uint32);
70 
71  if (protocolVersion() > 4) {
74  hlt_select_start_ += sizeof(char_uint32);
76  hlt_select_start_ += sizeof(char_uint32);
78  }
79 
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) {
94  host_name_start_ += sizeof(uint8);
96  }
97  }
98 
99  desc_start_ = pos;
101  desc_start_ += sizeof(char_uint32);
102 }
103 
105  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
106  return convert32(h->run_);
107 }
108 
110  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
111  return h->version_.protocol_;
112 }
113 
114 void InitMsgView::pset(uint8* put_here) const {
115  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
116  memcpy(put_here, h->version_.pset_id_, sizeof(h->version_.pset_id_));
117 }
118 
120  return std::string(reinterpret_cast<char*>(release_start_), release_len_);
121 }
122 
124  if (protocolVersion() < 4)
125  throw cms::Exception("Invalid Message Version", "InitMsgView")
126  << "Process Name is only supported in Protocol Version 4 and above"
127  << ".\n";
128 
129  return std::string(reinterpret_cast<char*>(processName_start_), processName_len_);
130 }
131 
133  if (protocolVersion() < 5)
134  throw cms::Exception("Invalid Message Version", "InitMsgView")
135  << "Output Module Label is only supported in Protocol Version 5 and above"
136  << ".\n";
137 
138  return std::string(reinterpret_cast<char*>(outputModuleLabel_start_), outputModuleLabel_len_);
139 }
140 
141 void InitMsgView::hltTriggerNames(Strings& save_here) const {
143 }
144 
146  if (protocolVersion() < 5)
147  throw cms::Exception("Invalid Message Version", "InitMsgView")
148  << "HLT trigger selections are only supported in Protocol Version 5 and above"
149  << ".\n";
150 
152 }
153 
154 void InitMsgView::l1TriggerNames(Strings& save_here) const {
156 }
157 
159  if (protocolVersion() == 2) {
162  uint32 hlt_sz = get_hlt_bit_cnt();
163  if (hlt_sz != 0)
164  hlt_sz = 1 + ((hlt_sz - 1) / 4);
165 
166  uint32 l1_sz = get_l1_bit_cnt();
167  if (l1_sz != 0)
168  l1_sz = 1 + ((l1_sz - 1) / 8);
169 
170  return 1 + (4 * 8) + hlt_sz + l1_sz;
171  }
172 
173  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
174  return convert32(h->event_header_size_);
175 }
176 
177 /***
178 uint32 InitMsgView::initHeaderSize() const
179 {
180  InitHeader* h = reinterpret_cast<InitHeader*>(buf_);
181  return convert32(h->init_header_size_);
182 } **/
183 
185  if (host_name_start_) {
186  std::string host_name(reinterpret_cast<char*>(host_name_start_), host_name_len_);
187  size_t found = host_name.find('\0');
188  if (found != std::string::npos) {
189  return std::string(host_name, 0, found);
190  } else {
191  return host_name;
192  }
193  } else {
194  return "n/a";
195  }
196 }
InitMsgView::get_l1_bit_cnt
uint32 get_l1_bit_cnt() const
Definition: InitMessage.h:82
InitMsgView::adler32_chksum_
uint32 adler32_chksum_
Definition: InitMessage.h:116
InitMsgView::protocolVersion
uint32 protocolVersion() const
Definition: InitMessage.cc:109
InitMsgView::releaseTag
std::string releaseTag() const
Definition: InitMessage.cc:119
uint8
unsigned char uint8
Definition: MsgTools.h:11
InitMsgView::get_hlt_bit_cnt
uint32 get_hlt_bit_cnt() const
Definition: InitMessage.h:81
InitMsgView::processName
std::string processName() const
Definition: InitMessage.cc:123
gather_cfg.cout
cout
Definition: gather_cfg.py:144
pos
Definition: PixelAliasList.h:18
InitMsgView::hlt_trig_len_
uint32 hlt_trig_len_
Definition: InitMessage.h:109
char_uint32
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:16
InitMessage.h
InitMsgView::hlt_select_count_
uint32 hlt_select_count_
Definition: InitMessage.h:111
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
Strings
std::vector< std::string > Strings
Definition: MsgTools.h:18
InitMsgView::run
uint32 run() const
Definition: InitMessage.cc:104
uint32
unsigned int uint32
Definition: MsgTools.h:13
InitMsgView::l1TriggerNames
void l1TriggerNames(Strings &save_here) const
Definition: InitMessage.cc:154
InitMsgView::hostName
std::string hostName() const
Definition: InitMessage.cc:183
InitMsgView::InitMsgView
InitMsgView(void *buf)
Definition: InitMessage.cc:7
InitHeader
Definition: InitMessage.h:46
convert32
uint32 convert32(char_uint32 v)
Definition: MsgTools.h:28
InitMsgView::l1_trig_len_
uint32 l1_trig_len_
Definition: InitMessage.h:115
h
InitMsgView::processName_len_
uint32 processName_len_
Definition: InitMessage.h:101
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InitMsgView::release_len_
uint32 release_len_
Definition: InitMessage.h:98
InitMsgView::desc_start_
uint8 * desc_start_
Definition: InitMessage.h:122
InitMsgView::desc_len_
uint32 desc_len_
Definition: InitMessage.h:123
InitMsgView::outputModuleLabel_len_
uint32 outputModuleLabel_len_
Definition: InitMessage.h:104
InitMsgView::outputModuleId_
uint32 outputModuleId_
Definition: InitMessage.h:105
InitMsgView::release_start_
uint8 * release_start_
Definition: InitMessage.h:97
InitMsgView::host_name_len_
uint32 host_name_len_
Definition: InitMessage.h:118
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
InitMsgView::l1_trig_start_
uint8 * l1_trig_start_
Definition: InitMessage.h:113
InitMsgView::hltTriggerSelections
void hltTriggerSelections(Strings &save_here) const
Definition: InitMessage.cc:145
InitMsgView::outputModuleLabel_start_
uint8 * outputModuleLabel_start_
Definition: InitMessage.h:103
Exception
Definition: hltDiff.cc:246
InitMsgView::hlt_select_start_
uint8 * hlt_select_start_
Definition: InitMessage.h:110
InitMsgView::eventHeaderSize
uint32 eventHeaderSize() const
Definition: InitMessage.cc:158
Exception.h
InitMsgView::hltTriggerNames
void hltTriggerNames(Strings &save_here) const
Definition: InitMessage.cc:141
InitMsgView::hlt_select_len_
uint32 hlt_select_len_
Definition: InitMessage.h:112
InitMsgView::hlt_trig_start_
uint8 * hlt_trig_start_
Definition: InitMessage.h:107
InitMsgView::buf_
uint8 * buf_
Definition: InitMessage.h:94
InitMsgView::outputModuleLabel
std::string outputModuleLabel() const
Definition: InitMessage.cc:132
MsgTools::getNames
void getNames(uint8 *from, uint32 from_len, Strings &to)
Definition: MsgTools.h:85
InitMsgView::processName_start_
uint8 * processName_start_
Definition: InitMessage.h:100
InitMsgView::host_name_start_
uint8 * host_name_start_
Definition: InitMessage.h:117
InitMsgView::l1_trig_count_
uint32 l1_trig_count_
Definition: InitMessage.h:114
InitMsgView::pset
void pset(uint8 *put_here) const
Definition: InitMessage.cc:114
InitMsgView::hlt_trig_count_
uint32 hlt_trig_count_
Definition: InitMessage.h:108