Belle II Software  release-05-01-25
ONSENBinData.cc
1 #include "daq/storage/ONSENBinData.h"
2 
3 #include <arpa/inet.h>
4 
5 using namespace Belle2;
6 
7 ONSENBinData::ONSENBinData(void* buf) : BinData(buf)
8 {
9 
10 }
11 
12 ONSENBinData::~ONSENBinData() throw()
13 {
14 
15 }
16 
17 unsigned int ONSENBinData::getTrigger() const
18 {
19  return (ntohs(m_start_frame->trigger_hi) << 16)
20  + ntohs(m_start_frame->trigger_lo);
21 }
22 
23 unsigned int ONSENBinData::getTimetag() const
24 {
25  uint64_t retval =
26  ((uint64_t)ntohs(m_start_frame->time_tag_hi) << 32)
27  | ((uint64_t)ntohs(m_start_frame->time_tag_mid) << 16)
28  | (uint64_t)ntohs(m_start_frame->time_tag_lo_and_type);
29  return (retval >> 4);
30 }
31 
32 unsigned int ONSENBinData::getEventNumber() const
33 {
34  unsigned int nframe = getFrameNumber();
35  if (nframe > MAX_PXD_FRAMES) return 0;
36  m_start_frame = (sose_frame_t*)(m_body + nframe + 2);
37  return getTrigger();
38 }
39 
40 unsigned int ONSENBinData::getTriggerType() const
41 {
42  return (ntohs(m_start_frame->time_tag_lo_and_type) & 0xF);
43 }
44 
45 unsigned int ONSENBinData::getFrameNumber() const
46 {
47  return ntohl(m_body[1]);
48 }
49 
50 unsigned int ONSENBinData::getFrameByteSize() const
51 {
52  const unsigned int nframe = getFrameNumber();
53  unsigned int nbyte = 0;
54  for (unsigned int i = 0; i < nframe; i++) {
55  nbyte += ntohl(m_body[2 + i]);
56  }
57  if (m_body[2 + nframe] != ntohs(0x3000)) {
58  return nbyte - 8;
59  } else {
60  return nbyte;
61  }
62 }
63 
64 unsigned int ONSENBinData::getONSENMagic() const
65 {
66  return ntohl(m_body[0]);
67 }
68 
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::BinData
Definition: BinData.h:26