CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQMEventMessage.cc
Go to the documentation of this file.
1 
10 
11 #define MAX_STRING_SIZE 10000
12 
17  buf_((uint8*)buf),head_(buf)
18 {
19  uint8* bufPtr;
20  uint32 len;
21 
22  // verify that the buffer actually contains a DQM Event message
23  if (this->code() != Header::DQM_EVENT)
24  {
25  throw cms::Exception("MessageDecoding", "DQMEventMsgView")
26  << "Invalid DQM Event message code (" << this->code()
27  << "). Should be " << Header::DQM_EVENT << "\n";
28  }
29 
30  // verify that the message has a protocol that we support
31  if (this->protocolVersion() != 3)
32  {
33  throw cms::Exception("MessageDecoding", "DQMEventMsgView")
34  << "Unsupport protocol version (" << this->protocolVersion() << ").\n";
35  }
36 
37  // set our buffer pointer to just beyond the fixed header data
38  bufPtr = buf_ + sizeof(DQMEventHeader);
39 
40  // determine the release tag
41  len = convert32(bufPtr);
42  bufPtr += sizeof(uint32);
43  if (len <= MAX_STRING_SIZE) // prevent something totally crazy // len >= 0, since len is unsigned.
44  {
45  releaseTag_.append((char *) bufPtr, len);
46  }
47  bufPtr += len;
48 
49  // determine the top-level folder name
50  len = convert32(bufPtr);
51  bufPtr += sizeof(uint32);
52  if (len <= MAX_STRING_SIZE) // prevent something totally crazy // len >= 0, since len is unsigned.
53  {
54  folderName_.append((char *) bufPtr, len);
55  }
56  bufPtr += len;
57 
58  // determine the number of subfolders
59  subFolderCount_ = convert32(bufPtr);
60  bufPtr += sizeof(uint32);
61 
62  // loop over the subfolders to extract relevant quantities
63  nameListPtr_.reset(new std::vector<std::string>());
64  for (int idx = 0; idx < (int) subFolderCount_; idx++)
65  {
66  // number of MEs in subfolder
67  uint32 meCount = convert32(bufPtr);
68  bufPtr += sizeof(uint32);
69  meCountList_.push_back(meCount);
70 
71  // subfolder name
72  std::string subFolderName = "Subfolder " + idx;
73  uint32 nameLen = convert32(bufPtr);
74  bufPtr += sizeof(uint32);
75  if (nameLen <= MAX_STRING_SIZE) // prevent something totally crazy // nameLen >= 0, since nameLen is unsigned.
76  {
77  subFolderName.clear();
78  subFolderName.append((char *) bufPtr, nameLen);
79  }
80  bufPtr += nameLen;
81  nameListPtr_->push_back(subFolderName);
83  }
84  adler32_chksum_ = convert32(bufPtr);
85  bufPtr += sizeof(uint32);
86 
87  host_name_len_ = *bufPtr;
88  bufPtr += sizeof(uint8);
89  host_name_start_ = bufPtr;
90  bufPtr += host_name_len_;
91 
92  // determine the event length and address
93  eventLen_ = convert32(bufPtr);
94  bufPtr += sizeof(uint32);
95  eventAddr_ = bufPtr;
96 
97  // check that the event data doesn't extend beyond the reported
98  // size of the message
99  if ((this->headerSize() + this->eventLength()) > this->size())
100  {
101  throw cms::Exception("MessageDecoding", "DQMEventMsgView")
102  << "Inconsistent data sizes. The size of the header ("
103  << this->headerSize() << ") and the data (" << this->eventLength()
104  << ") exceed the size of the message (" << this->size() << ").\n";
105  }
106 }
107 
111 boost::shared_ptr< std::vector<std::string> >
113 {
114  return nameListPtr_;
115 }
116 
120 std::string DQMEventMsgView::subFolderName(uint32 const subFolderIndex) const
121 {
122  // catch attempts to access an invalid entry
123  if (subFolderIndex >= subFolderCount_)
124  {
125  throw cms::Exception("MessageDecoding", "DQMEventMsgView")
126  << "Invalid subfolder index (" << subFolderIndex << ") - "
127  << "the number of subfolders is " << subFolderCount_ << ".\n";
128  }
129 
130  return (*nameListPtr_)[subFolderIndex];
131 }
132 
136 uint32 DQMEventMsgView::meCount(std::string const& subFolderName) const
137 {
138  // lookup the index of the specified subfolder
139  std::map<std::string, uint32>::const_iterator subFolderIter;
140  subFolderIter = subFolderIndexTable_.find(subFolderName);
141 
142  // throw an exception if the name was not found
143  if (subFolderIter == subFolderIndexTable_.end())
144  {
145  throw cms::Exception("MessageDecoding", "DQMEventMsgView")
146  << "Unable to find the subfolder index for \""
147  << subFolderName << "\".\n";
148  }
149 
150  // fetch the count by index
151  return this->meCount(subFolderIter->second);
152 }
153 
158 uint32 DQMEventMsgView::meCount(uint32 const subFolderIndex) const
159 {
160  // catch attempts to access an invalid entry
161  if (subFolderIndex >= subFolderCount_)
162  {
163  throw cms::Exception("MessageDecoding", "DQMEventMsgView")
164  << "Invalid subfolder index (" << subFolderIndex << ") - "
165  << "the number of subfolders is " << subFolderCount_ << ".\n";
166  }
167 
168  return meCountList_[subFolderIndex];
169 }
170 
175 {
177  return convert32(h->protocolVersion_);
178 }
179 
184 {
186  return convert32(h->headerSize_);
187 }
188 
193 {
195  return convert32(h->runNumber_);
196 }
197 
202 {
204  return convert32(h->eventNumber_);
205 }
206 
211 {
213  return convert32(h->lumiSection_);
214 }
215 
220 {
222  return convert32(h->updateNumber_);
223 }
224 
229 {
231  return convert32(h->compressionFlag_);
232 }
233 
238 {
240  return convert32(h->fuProcessId_);
241 }
242 
247 {
249  return convert32(h->fuGuid_);
250 }
251 
256 {
258  return convert32(h->mergeCount_);
259 }
260 
261 //uint64 DQMEventMsgView::timeStamp() const
263 {
265  return edm::Timestamp(convert64(h->timeStamp_));
266 }
267 
268 std::string DQMEventMsgView::hostName() const
269 {
270  return std::string(reinterpret_cast<char *>(host_name_start_),host_name_len_);
271 }
272 
char_uint32 lumiSection_
char_uint32 protocolVersion_
uint64 convert64(char_uint64 v)
Definition: MsgTools.h:21
#define MAX_STRING_SIZE
char_uint64 timeStamp_
boost::shared_array< char > buf_
char_uint32 headerSize_
uint32 protocolVersion() const
uint32 eventNumberAtUpdate() const
char_uint32 updateNumber_
char_uint32 mergeCount_
uint8 * host_name_start_
uint32 updateNumber() const
uint32 meCount(std::string const &subFolderName) const
uint32 headerSize() const
std::map< std::string, uint32 > subFolderIndexTable_
uint32 eventLength() const
uint32 fuGuid() const
char_uint32 fuGuid_
std::string releaseTag_
DQMEventMsgView(void *buf)
std::string subFolderName(uint32 const subFolderIndex) const
boost::shared_ptr< std::vector< std::string > > nameListPtr_
uint32 compressionFlag() const
std::string folderName_
unsigned int uint32
Definition: MsgTools.h:13
char_uint32 eventNumber_
char_uint32 fuProcessId_
std::vector< uint32 > meCountList_
char_uint32 compressionFlag_
uint32 convert32(char_uint32 v)
Definition: MsgTools.h:30
unsigned char uint8
Definition: MsgTools.h:11
uint32 lumiSection() const
boost::shared_ptr< std::vector< std::string > > subFolderNames() const
uint32 code() const
char_uint32 runNumber_
uint32 fuProcessId() const
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 hostName() const
uint32 size() const
uint32 runNumber() const
edm::Timestamp timeStamp() const
uint32 mergeCount() const