Belle II Software  release-08-01-10
DataStorePackage.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #include "daq/storage/modules/DataStorePackage.h"
9 #include "daq/storage/ONSENBinData.h"
10 
11 #include <framework/logging/Logger.h>
12 
13 #include <framework/datastore/StoreArray.h>
14 #include <rawdata/dataobjects/RawPXD.h>
15 
16 #include <cstring>
17 
18 using namespace Belle2;
19 
20 bool DataStorePackage::restore()
21 {
22  static int count = 0;
23  //(m_sndhdrary.appendNew())->SetBuffer(m_data.getBuffer());
24  int nboard = m_data.getNBoard();
25  if (m_eb2 == 0 && nboard == 1) {
26  m_data_hlt.setBuffer(m_data.getBuffer());
27  } else if (m_eb2 > 0 || nboard > 1) {
28  m_data_hlt.setBuffer(m_data.getBody());
29  }
30 
31  if (m_data_hlt.getBuffer() == NULL || m_data_hlt.getTrailerMagic() != BinData::TRAILER_MAGIC) {
32  B2FATAL("Bad tarailer magic for HLT = " << m_data_hlt.getTrailerMagic()
33  << " count = " << count);
34  }
35  EvtMessage* msg = new EvtMessage((char*)m_data_hlt.getBody());
36  if (msg->type() == MSG_TERMINATE) {
37  B2INFO("Got Termination message");
38  delete msg;
39  return false;
40  }
41  //B2INFO("nbyte : " << m_data_hlt.getBody()[0]);
42  m_streamer->restoreDataStore(msg);
43  delete msg;
44  if (nboard > 1) {
45  unsigned int offset = m_data_hlt.getWordSize() + m_data.getHeaderWordSize();
46  for (int i = 0; i < nboard - 1; ++i) {
47  m_data_pxd.setBuffer(m_data.getBuffer() + offset);
48  offset += m_data_pxd.getWordSize();
49  if (m_data_pxd.getBody()[0] != ONSENBinData::MAGIC) {
50  B2FATAL("Bad ONSEN magic for PXD = " << m_data_pxd.getTrailerMagic());
51  return false;
52  } else if (m_data_pxd.getTrailerMagic() != BinData::TRAILER_MAGIC) {
53  B2FATAL("Bad tarailer magic for PXD = " << m_data_pxd.getTrailerMagic());
54  return false;
55  }
56  if (m_data_pxd.getBuffer() != NULL) {
57  m_rawpxdary.appendNew((int*)m_data_pxd.getBody(), m_data_pxd.getBodyByteSize());
58  //(m_sndhdrary.appendNew())->SetBuffer(m_data_pxd.getBuffer());
59  }
60  }
61  } else {
62  m_data_pxd.setBuffer(NULL);
63  }
64  return true;
65 }
66 
int restoreDataStore(EvtMessage *msg)
Restore DataStore objects from EvtMessage.
Class to manage streamed object.
Definition: EvtMessage.h:59
ERecordType type() const
Get record type.
Definition: EvtMessage.cc:114
Abstract base class for different kinds of events.