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::stringstream s;
73  s.str("Subfolder ");
74  s<<idx;
75  std::string subFolderName = s.str();
76  uint32 nameLen = convert32(bufPtr);
77  bufPtr += sizeof(uint32);
78  if (nameLen <= MAX_STRING_SIZE) // prevent something totally crazy // nameLen >= 0, since nameLen is unsigned.
79  {
80  subFolderName.clear();
81  subFolderName.append((char *) bufPtr, nameLen);
82  }
83  bufPtr += nameLen;
84  nameListPtr_->push_back(subFolderName);
86  }
87  adler32_chksum_ = convert32(bufPtr);
88  bufPtr += sizeof(uint32);
89 
90  host_name_len_ = *bufPtr;
91  bufPtr += sizeof(uint8);
92  host_name_start_ = bufPtr;
93  bufPtr += host_name_len_;
94 
95  // determine the event length and address
96  eventLen_ = convert32(bufPtr);
97  bufPtr += sizeof(uint32);
98  eventAddr_ = bufPtr;
99 
100  // check that the event data doesn't extend beyond the reported
101  // size of the message
102  if ((this->headerSize() + this->eventLength()) > this->size())
103  {
104  throw cms::Exception("MessageDecoding", "DQMEventMsgView")
105  << "Inconsistent data sizes. The size of the header ("
106  << this->headerSize() << ") and the data (" << this->eventLength()
107  << ") exceed the size of the message (" << this->size() << ").\n";
108  }
109 }
110 
114 boost::shared_ptr< std::vector<std::string> >
116 {
117  return nameListPtr_;
118 }
119 
124 {
125  // catch attempts to access an invalid entry
126  if (subFolderIndex >= subFolderCount_)
127  {
128  throw cms::Exception("MessageDecoding", "DQMEventMsgView")
129  << "Invalid subfolder index (" << subFolderIndex << ") - "
130  << "the number of subfolders is " << subFolderCount_ << ".\n";
131  }
132 
133  return (*nameListPtr_)[subFolderIndex];
134 }
135 
139 uint32 DQMEventMsgView::meCount(std::string const& subFolderName) const
140 {
141  // lookup the index of the specified subfolder
142  std::map<std::string, uint32>::const_iterator subFolderIter;
143  subFolderIter = subFolderIndexTable_.find(subFolderName);
144 
145  // throw an exception if the name was not found
146  if (subFolderIter == subFolderIndexTable_.end())
147  {
148  throw cms::Exception("MessageDecoding", "DQMEventMsgView")
149  << "Unable to find the subfolder index for \""
150  << subFolderName << "\".\n";
151  }
152 
153  // fetch the count by index
154  return this->meCount(subFolderIter->second);
155 }
156 
161 uint32 DQMEventMsgView::meCount(uint32 const subFolderIndex) const
162 {
163  // catch attempts to access an invalid entry
164  if (subFolderIndex >= subFolderCount_)
165  {
166  throw cms::Exception("MessageDecoding", "DQMEventMsgView")
167  << "Invalid subfolder index (" << subFolderIndex << ") - "
168  << "the number of subfolders is " << subFolderCount_ << ".\n";
169  }
170 
171  return meCountList_[subFolderIndex];
172 }
173 
178 {
180  return convert32(h->protocolVersion_);
181 }
182 
187 {
189  return convert32(h->headerSize_);
190 }
191 
196 {
198  return convert32(h->runNumber_);
199 }
200 
205 {
207  return convert32(h->eventNumber_);
208 }
209 
214 {
216  return convert32(h->lumiSection_);
217 }
218 
223 {
225  return convert32(h->updateNumber_);
226 }
227 
232 {
234  return convert32(h->compressionFlag_);
235 }
236 
241 {
243  return convert32(h->fuProcessId_);
244 }
245 
250 {
252  return convert32(h->fuGuid_);
253 }
254 
259 {
261  return convert32(h->mergeCount_);
262 }
263 
264 //uint64 DQMEventMsgView::timeStamp() const
266 {
268  return edm::Timestamp(convert64(h->timeStamp_));
269 }
270 
272 {
273  return std::string(reinterpret_cast<char *>(host_name_start_),host_name_len_);
274 }
275 
char_uint32 lumiSection_
char_uint32 protocolVersion_
uint64 convert64(char_uint64 v)
Definition: MsgTools.h:21
#define MAX_STRING_SIZE
char_uint64 timeStamp_
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)
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 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_
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
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
std::string hostName() const
uint32 size() const
uint32 runNumber() const
edm::Timestamp timeStamp() const
uint32 mergeCount() const