CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ErrorEventData.cc
Go to the documentation of this file.
1 // $Id: ErrorEventData.cc,v 1.7 2011/03/07 15:31:32 mommsen Exp $
3 
5 
7 
8 namespace stor
9 {
10 
11  namespace detail
12  {
13 
14  ErrorEventMsgData::ErrorEventMsgData(toolbox::mem::Reference* pRef) :
15  ChainData(I2O_SM_ERROR, Header::ERROR_EVENT),
16  headerFieldsCached_(false)
17  {
18  addFirstFragment(pRef);
20  }
21 
22  inline size_t ErrorEventMsgData::do_i2oFrameSize() const
23  {
24  return sizeof(I2O_SM_DATA_MESSAGE_FRAME);
25  }
26 
27  unsigned long ErrorEventMsgData::do_headerSize() const
28  {
29  if ( !headerOkay() )
30  {
31  return 0;
32  }
33 
35  return headerSize_;
36  }
37 
38  unsigned char* ErrorEventMsgData::do_headerLocation() const
39  {
40  if ( !headerOkay() )
41  {
42  return 0;
43  }
44 
46  return headerLocation_;
47  }
48 
49  inline unsigned char*
50  ErrorEventMsgData::do_fragmentLocation(unsigned char* dataLoc) const
51  {
52  if ( parsable() )
53  {
55  (I2O_SM_DATA_MESSAGE_FRAME*) dataLoc;
56  return (unsigned char*) smMsg->dataPtr();
57  }
58  else
59  {
60  return dataLoc;
61  }
62  }
63 
64  void
66  {
67  if ( headerOkay() && do_runNumber() != runNumber )
68  {
69  std::ostringstream errorMsg;
70  errorMsg << "Run number " << do_runNumber()
71  << " of error event " << do_eventNumber() <<
72  " received from " << hltURL() <<
73  " (FU process id " << fuProcessId() << ")" <<
74  " does not match the run number " << runNumber <<
75  " used to configure the StorageManager." <<
76  " Enforce usage of configured run number.";
78  XCEPT_RAISE(stor::exception::RunNumberMismatch, errorMsg.str());
79  }
80  }
81 
83  {
84  if ( !headerOkay() )
85  {
86  std::stringstream msg;
87  msg << "A run number can not be determined from a ";
88  msg << "faulty or incomplete ErrorEvent message.";
89  XCEPT_RAISE(stor::exception::IncompleteEventMessage, msg.str());
90  }
91 
93  return runNumber_;
94  }
95 
97  {
98  if ( !headerOkay() )
99  {
100  std::stringstream msg;
101  msg << "A luminosity section can not be determined from a ";
102  msg << "faulty or incomplete ErrorEvent message.";
103  XCEPT_RAISE(stor::exception::IncompleteEventMessage, msg.str());
104  }
105 
107  return lumiSection_;
108  }
109 
111  {
112  if ( !headerOkay() )
113  {
114  std::stringstream msg;
115  msg << "An event number can not be determined from a ";
116  msg << "faulty or incomplete ErrorEvent message.";
117  XCEPT_RAISE(stor::exception::IncompleteEventMessage, msg.str());
118  }
119 
121  return eventNumber_;
122  }
123 
125  {
126  if ( parsable() )
127  {
129  (I2O_SM_DATA_MESSAGE_FRAME*) ref_->getDataLocation();
131  fragKey_.run_ = smMsg->runID;
132  fragKey_.event_ = smMsg->eventID;
133  fragKey_.secondaryId_ = smMsg->outModID;
136  rbBufferId_ = smMsg->rbBufferID;
137  hltLocalId_ = smMsg->hltLocalId;
138  hltInstance_ = smMsg->hltInstance;
139  hltTid_ = smMsg->hltTid;
140  fuProcessId_ = smMsg->fuProcID;
141  fuGuid_ = smMsg->fuGUID;
142  }
143  }
144 
146  {
147  unsigned char* firstFragLoc = dataLocation(0);
148  unsigned long firstFragSize = dataSize(0);
149  bool useFirstFrag = false;
150 
151  // if there is only one fragment, use it
152  if (fragmentCount_ == 1)
153  {
154  useFirstFrag = true;
155  }
156  // otherwise, check if the first fragment is large enough to hold
157  // the full Event message header (FRD events have fixed header
158  // size, so the check is easy)
159  else if (firstFragSize > sizeof(FRDEventHeader_V2))
160  {
161  useFirstFrag = true;
162  }
163 
164  boost::shared_ptr<FRDEventMsgView> msgView;
165  if (useFirstFrag)
166  {
167  msgView.reset(new FRDEventMsgView(firstFragLoc));
168  }
169  else
170  {
172  msgView.reset(new FRDEventMsgView(&headerCopy_[0]));
173  }
174 
175  headerSize_ = sizeof(FRDEventHeader_V2);
176  headerLocation_ = msgView->startAddress();
177 
178  runNumber_ = msgView->run();
179  lumiSection_ = msgView->lumi();
180  eventNumber_ = msgView->event();
181 
182  headerFieldsCached_ = true;
183  }
184 
185  } // namespace detail
186 
187 } // namespace stor
188 
189 
uint32 originatorPid_
Definition: FragKey.h:39
unsigned char * dataLocation(int fragmentIndex) const
Definition: ChainData.cc:449
#define I2O_SM_ERROR
Definition: i2oEvfMsgs.h:23
uint32_t runNumber() const
Definition: ChainData.cc:632
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
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
unsigned long do_headerSize() const
unsigned char * do_fragmentLocation(unsigned char *dataLoc) const
unsigned int copyFragmentsIntoBuffer(std::vector< unsigned char > &buff) const
Definition: ChainData.cc:489
unsigned char * do_headerLocation() const
unsigned int hltLocalId_
Definition: ChainData.h:165
void do_assertRunNumber(uint32_t runNumber)
uint8 code_
Definition: FragKey.h:32
unsigned char * headerLocation_
Definition: ChainData.h:398
uint32 run_
Definition: FragKey.h:33
unsigned int fuProcessId_
Definition: ChainData.h:168
unsigned int fragmentCount_
Definition: ChainData.h:162
ErrorEventMsgData(toolbox::mem::Reference *pRef)
unsigned long dataSize(int fragmentIndex) const
Definition: ChainData.cc:426
unsigned int fuGuid_
Definition: ChainData.h:169
uint32 secondaryId_
Definition: FragKey.h:38
char * dataPtr() const
Definition: i2oEvfMsgs.h:108
std::vector< unsigned char > headerCopy_
Definition: ChainData.h:396
_I2O_SM_DATA_MESSAGE_FRAME I2O_SM_DATA_MESSAGE_FRAME
unsigned int messageCode_
Definition: ChainData.h:159
bool headerOkay() const
Definition: ChainData.cc:110
unsigned int hltInstance_
Definition: ChainData.h:166