CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQMEventMsgData.cc
Go to the documentation of this file.
1 // $Id: DQMEventMsgData.cc,v 1.12 2011/03/28 13:49:04 mommsen Exp $
3 
5 
7 
8 namespace stor
9 {
10 
11  namespace detail
12  {
13 
14  DQMEventMsgData::DQMEventMsgData(toolbox::mem::Reference* pRef) :
15  ChainData(I2O_SM_DQM, Header::DQM_EVENT),
16  headerFieldsCached_(false)
17  {
18  addFirstFragment(pRef);
20  }
21 
22  inline size_t DQMEventMsgData::do_i2oFrameSize() const
23  {
24  return sizeof(I2O_SM_DQM_MESSAGE_FRAME);
25  }
26 
28  {
29  if( !headerOkay() )
30  {
31  std::stringstream msg;
32  msg << "A top folder name can not be determined from a ";
33  msg << "faulty or incomplete DQM event message.";
34  XCEPT_RAISE( stor::exception::IncompleteDQMEventMessage, msg.str() );
35  }
36 
38  return topFolderName_;
39  }
40 
42  {
43  if( !headerOkay() )
44  {
45  std::stringstream msg;
46  msg << "An adler32 checksum can not be determined from a ";
47  msg << "faulty or incomplete DQM event message.";
48  XCEPT_RAISE( stor::exception::IncompleteDQMEventMessage, msg.str() );
49  }
50 
52  return adler32_;
53  }
54 
56  {
57  if( !headerOkay() )
58  {
59  std::stringstream msg;
60  msg << "The DQM key can not be determined from a ";
61  msg << "faulty or incomplete DQM event message.";
62  XCEPT_RAISE( stor::exception::IncompleteDQMEventMessage, msg.str() );
63  }
64 
66  return dqmKey_;
67  }
68 
70  {
71 
72  if( !headerOkay() )
73  {
74  std::stringstream msg;
75  msg << "The run number can not be determined from a ";
76  msg << "faulty or incomplete DQM event message.";
77  XCEPT_RAISE( stor::exception::IncompleteDQMEventMessage, msg.str() );
78  }
79 
81  return dqmKey_.runNumber;
82  }
83 
85  {
86 
87  if( !headerOkay() )
88  {
89  std::stringstream msg;
90  msg << "The lumi section can not be determined from a ";
91  msg << "faulty or incomplete DQM event message.";
92  XCEPT_RAISE( stor::exception::IncompleteDQMEventMessage, msg.str() );
93  }
94 
96  return dqmKey_.lumiSection;
97  }
98 
100  {
101  if ( headerOkay() && do_runNumber() != runNumber )
102  {
103  std::ostringstream errorMsg;
104  errorMsg << "Run number " << do_runNumber()
105  << " of DQM event for LS " << do_lumiSection() <<
106  " received from " << hltURL() <<
107  " (FU process id " << fuProcessId() << ")" <<
108  " does not match the run number " << runNumber <<
109  " used to configure the StorageManager.";
110  XCEPT_RAISE(stor::exception::RunNumberMismatch, errorMsg.str());
111  }
112  }
113 
114  unsigned long DQMEventMsgData::do_headerSize() const
115  {
116  if ( !headerOkay() )
117  {
118  return 0;
119  }
120 
122  return headerSize_;
123  }
124 
125  unsigned char* DQMEventMsgData::do_headerLocation() const
126  {
127  if ( !headerOkay() )
128  {
129  return 0;
130  }
131 
133  return headerLocation_;
134  }
135 
136  inline unsigned char*
137  DQMEventMsgData::do_fragmentLocation(unsigned char* dataLoc) const
138  {
139  if ( parsable() )
140  {
141  I2O_SM_DQM_MESSAGE_FRAME *smMsg =
142  (I2O_SM_DQM_MESSAGE_FRAME*) dataLoc;
143  return (unsigned char*) smMsg->dataPtr();
144  }
145  else
146  {
147  return dataLoc;
148  }
149  }
150 
152  {
153  if ( parsable() )
154  {
155  I2O_SM_DQM_MESSAGE_FRAME *smMsg =
156  (I2O_SM_DQM_MESSAGE_FRAME*) ref_->getDataLocation();
158  fragKey_.run_ = smMsg->runID;
160  fragKey_.secondaryId_ = smMsg->folderID;
163  rbBufferId_ = smMsg->rbBufferID;
164  hltLocalId_ = smMsg->hltLocalId;
165  hltInstance_ = smMsg->hltInstance;
166  hltTid_ = smMsg->hltTid;
167  fuProcessId_ = smMsg->fuProcID;
168  fuGuid_ = smMsg->fuGUID;
169  }
170  }
171 
172  // Adapted from InitMsgData::cacheHeaderFields
174  {
175 
176  unsigned char* firstFragLoc = dataLocation(0);
177 
178  boost::shared_ptr<DQMEventMsgView> msgView;
179  if (fragmentCount_ == 1)
180  {
181  msgView.reset(new DQMEventMsgView(firstFragLoc));
182  }
183  else
184  {
186  msgView.reset(new DQMEventMsgView(&headerCopy_[0]));
187  }
188 
189  headerSize_ = msgView->headerSize()
190  + sizeof(uint32_t); // in contrast to other message types,
191  // DQM messages do not contain the data
192  // length entry (uint32_t) in headerSize()
193  headerLocation_ = msgView->startAddress();
194  topFolderName_ = msgView->topFolderName();
195  adler32_ = msgView->adler32_chksum();
196 
197  dqmKey_.runNumber = msgView->runNumber();
198  dqmKey_.lumiSection = msgView->lumiSection();
199  dqmKey_.topLevelFolderName = msgView->topFolderName();
200 
201  headerFieldsCached_ = true;
202 
203  #ifdef STOR_DEBUG_WRONG_ADLER
204  double r = rand()/static_cast<double>(RAND_MAX);
205  if (r < 0.01)
206  {
207  std::cout << "Simulating corrupt Adler calculation" << std::endl;
208  headerSize_ += 3;
209  }
210  else if (r < 0.02)
211  {
212  std::cout << "Simulating corrupt Adler entry" << std::endl;
213  adler32_ += r*10000;
214  }
215  #endif // STOR_DEBUG_WRONG_ADLER
216  }
217 
218  } // namespace detail
219 
220 } // namespace stor
221 
222 
uint32 originatorPid_
Definition: FragKey.h:39
unsigned char * dataLocation(int fragmentIndex) const
Definition: ChainData.cc:449
unsigned char * do_headerLocation() const
_I2O_SM_DQM_MESSAGE_FRAME I2O_SM_DQM_MESSAGE_FRAME
uint32_t do_adler32Checksum() const
#define I2O_SM_DQM
Definition: i2oEvfMsgs.h:25
unsigned int rbBufferId_
Definition: ChainData.h:164
toolbox::mem::Reference * ref_
Definition: ChainData.h:154
unsigned int fuProcessId() const
Definition: ChainData.h:82
unsigned int hltTid_
Definition: ChainData.h:167
unsigned char * headerLocation_
Definition: ChainData.h:359
unsigned char * do_fragmentLocation(unsigned char *dataLoc) const
uint32 event_
Definition: FragKey.h:34
std::string hltURL() const
Definition: ChainData.cc:542
void addFirstFragment(toolbox::mem::Reference *)
Definition: ChainData.cc:115
bool parsable() const
Definition: ChainData.cc:103
uint32 originatorGuid_
Definition: FragKey.h:40
uint32_t do_lumiSection() const
unsigned int copyFragmentsIntoBuffer(std::vector< unsigned char > &buff) const
Definition: ChainData.cc:489
std::string topLevelFolderName
Definition: DQMKey.h:25
std::string do_topFolderName() const
unsigned int hltLocalId_
Definition: ChainData.h:165
std::vector< unsigned char > headerCopy_
Definition: ChainData.h:357
uint8 code_
Definition: FragKey.h:32
uint32 run_
Definition: FragKey.h:33
unsigned int fuProcessId_
Definition: ChainData.h:168
unsigned long do_headerSize() const
unsigned int fragmentCount_
Definition: ChainData.h:162
uint32_t runNumber
Definition: DQMKey.h:23
unsigned int fuGuid_
Definition: ChainData.h:169
uint32 secondaryId_
Definition: FragKey.h:38
void do_assertRunNumber(uint32_t runNumber)
unsigned int messageCode_
Definition: ChainData.h:159
Signal rand(Signal arg)
Definition: vlib.cc:442
tuple cout
Definition: gather_cfg.py:121
bool headerOkay() const
Definition: ChainData.cc:110
uint32_t lumiSection
Definition: DQMKey.h:24
char * dataPtr() const
Definition: i2oEvfMsgs.h:137
unsigned int hltInstance_
Definition: ChainData.h:166
DQMEventMsgData(toolbox::mem::Reference *pRef)