CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQMEventMsgBuilder.cc
Go to the documentation of this file.
1 
11 #include <cassert>
12 #include <cstring>
13 
14 
21  //uint64 timeStamp,
22  uint32 lumiSection, uint32 updateNumber,
23  uint32 adler_chksum,
24  const char* host_name,
25  std::string const& releaseTag,
26  std::string const& topFolderName,
27  DQMEvent::TObjectTable monitorElementsBySubFolder):
28  buf_((uint8*)buf),bufSize_(bufSize)
29 {
30  DQMEventHeader* evtHdr;
31  uint8* bufPtr;
32  uint32 len;
33  uint32 protocolVersion = 3;
34 
35  // fill in event header information
36  bufPtr = buf_ + sizeof(DQMEventHeader);
37  if (((uint32) (bufPtr - buf_)) > bufSize_)
38  {
39  throw cms::Exception("MessageBuilding", "DQMEventMsgBuilder")
40  << "Input buffer size is too small for required header "
41  << "information. Size = " << bufSize_
42  << ", necessary size is >= "
43  << ((uint32) (bufPtr - buf_)) << ".\n";
44  }
45 
46  evtHdr = (DQMEventHeader*) buf_;
47  convert(protocolVersion, evtHdr->protocolVersion_);
48  convert(run, evtHdr->runNumber_);
49  convert(event, evtHdr->eventNumber_);
50 
51  convert(timeStamp.value(), evtHdr->timeStamp_);
52 
53  convert(lumiSection, evtHdr->lumiSection_);
54  convert(updateNumber, evtHdr->updateNumber_);
55 
56  // copy the release tag into the message
57  len = releaseTag.length();
58  if (((uint32) (bufPtr + len + sizeof(uint32) - buf_)) > bufSize_)
59  {
60  throw cms::Exception("MessageBuilding", "DQMEventMsgBuilder")
61  << "Input buffer size is too small for required header "
62  << "information. Size = " << bufSize_
63  << ", necessary size is >= "
64  << ((uint32) (bufPtr + len + sizeof(uint32) - buf_)) << ".\n";
65  }
66  convert(len, bufPtr);
67  bufPtr += sizeof(uint32);
68  releaseTag.copy((char*) bufPtr, len);
69  bufPtr += len;
70 
71  // copy the top folder name into the message
72  len = topFolderName.length();
73  if (((uint32) (bufPtr + len + sizeof(uint32) - buf_)) > bufSize_)
74  {
75  throw cms::Exception("MessageBuilding", "DQMEventMsgBuilder")
76  << "Input buffer size is too small for required header "
77  << "information. Size = " << bufSize_
78  << ", necessary size is >= "
79  << ((uint32) (bufPtr + len + sizeof(uint32) - buf_)) << ".\n";
80  }
81  convert(len, bufPtr);
82  bufPtr += sizeof(uint32);
83  topFolderName.copy((char*) bufPtr, len);
84  bufPtr += len;
85 
86  // copy the subfolder count into the message
87  convert(static_cast<uint32>(monitorElementsBySubFolder.size()), bufPtr);
88  bufPtr += sizeof(uint32);
89 
90  // copy the ME count and name for each subfolder into the message
91  DQMEvent::TObjectTable::const_iterator sfIter;
92  for (sfIter = monitorElementsBySubFolder.begin();
93  sfIter != monitorElementsBySubFolder.end(); sfIter++)
94  {
95  std::string subFolderName = sfIter->first;
96  std::vector<TObject *> toList = sfIter->second;
97 
98  convert(static_cast<uint32>(toList.size()), bufPtr);
99  bufPtr += sizeof(uint32);
100 
101  len = subFolderName.length();
102  convert(len, bufPtr);
103  bufPtr += sizeof(uint32);
104  subFolderName.copy((char*) bufPtr, len);
105  bufPtr += len;
106  }
107  // adler32 check sum of data blob
108  convert(adler_chksum, bufPtr);
109  bufPtr += sizeof(uint32);
110 
111  // put host name (Length and then Name) right after check sum
112  uint32 host_name_len = strlen(host_name);
113  assert(host_name_len < 0x00ff);
114  //Put host_name_len
115  *bufPtr++ = host_name_len;
116  //Put host_name
117  memcpy(bufPtr,host_name,host_name_len);
118  bufPtr += host_name_len;
119 
120  // set the header size and the event address, taking into account the
121  // size of the event length field
122  if (((uint32) (bufPtr + sizeof(uint32) - buf_)) > bufSize_)
123  {
124  throw cms::Exception("MessageBuilding", "DQMEventMsgBuilder")
125  << "Input buffer size is too small for required header "
126  << "information. Size = " << bufSize_
127  << ", necessary size is >= "
128  << ((uint32) (bufPtr + sizeof(uint32) - buf_)) << ".\n";
129  }
130  convert(((uint32) (bufPtr - buf_)), evtHdr->headerSize_);
131  bufPtr += sizeof(uint32);
132  eventAddr_ = bufPtr;
133 
134  // set the event length to 0 initially. (The setEventLength method
135  // sets the message code and message size for us. It shouldn't be called
136  // until *after* the event address is set.)
137  setEventLength(0);
138 
139  // initialize the compression flag to zero
141 
142  // initialize the filter unit process ID to zero
143  setFUProcessId(0);
144 
145  // initialize the filter unit GUID to zero
146  setFUGuid(0);
147 
148  // initialize the merge count to zero
149  setMergeCount(0);
150 }
151 
158 {
159  if (((uint32) (eventAddr_ + len - buf_)) > bufSize_)
160  {
161  throw cms::Exception("MessageBuilding", "DQMEventMsgBuilder")
162  << "Event data overflows buffer. Buffer size = " << bufSize_
163  << ", header size = " << this->headerSize()
164  << ", event size = " << len << ".\n";
165  }
166  convert(len, eventAddr_ - sizeof(char_uint32));
167  DQMEventHeader* evtHdr = (DQMEventHeader*) buf_;
168  new (&evtHdr->header_) Header(Header::DQM_EVENT, (eventAddr_ - buf_ + len));
169 }
170 
175 {
176  DQMEventHeader* evtHdr = (DQMEventHeader*) buf_;
177  convert(value, evtHdr->compressionFlag_);
178 }
179 
184 {
185  DQMEventHeader* evtHdr = (DQMEventHeader*) buf_;
186  convert(value, evtHdr->fuProcessId_);
187 }
188 
193 {
194  DQMEventHeader* evtHdr = (DQMEventHeader*) buf_;
195  convert(value, evtHdr->fuGuid_);
196 }
197 
202 {
203  DQMEventHeader* evtHdr = (DQMEventHeader*) buf_;
204  convert(value, evtHdr->mergeCount_);
205 }
206 
211 {
212  HeaderView v(buf_);
213  return v.size();
214 }
215 
216 
217 
char_uint32 lumiSection_
char_uint32 protocolVersion_
char_uint64 timeStamp_
DQMEventMsgBuilder(void *buf, uint32 bufSize, uint32 run, uint32 event, edm::Timestamp timeStamp, uint32 lumiSection, uint32 updateNumber, uint32 adler32_chksum, const char *host_name, std::string const &releaseTag, std::string const &topFolderName, DQMEvent::TObjectTable monitorElementsBySubFolder)
char_uint32 headerSize_
char_uint32 updateNumber_
char_uint32 mergeCount_
static int const bufSize
Definition: Guid.cc:24
void convert(uint32 i, char_uint32 v)
Definition: MsgTools.h:46
char_uint32 fuGuid_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
unsigned int uint32
Definition: MsgTools.h:13
unsigned char char_uint32[sizeof(uint32)]
Definition: MsgTools.h:16
char_uint32 eventNumber_
char_uint32 fuProcessId_
TimeValue_t value() const
Definition: Timestamp.cc:72
void setCompressionFlag(uint32)
uint32 size() const
Definition: MsgHeader.h:35
void setEventLength(uint32 len)
char_uint32 compressionFlag_
unsigned char uint8
Definition: MsgTools.h:11
char_uint32 runNumber_
std::map< std::string, std::vector< TObject * > > TObjectTable
mathSSE::Vec4< T > v
std::string timeStamp(TimePoint_t)
Definition: Utils.cc:23
uint32 headerSize() const