Belle II Software development
ROIpayload.h
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
9#pragma once
10
11#include <tracking/dataobjects/ROIrawID.h>
12#include "TObject.h"
13#include <stdint.h>
14#include <boost/endian/arithmetic.hpp>
15
16namespace Belle2 {
35 class ROIpayload : public TObject {
36 enum { OFFSET_MAGIC = 0, OFFSET_LENGTH = 1, OFFSET_HEADER = 2, OFFSET_TRIGNR = 3, OFFSET_RUNNR = 4, OFFSET_ROIS = 5};
37 enum { HEADER_SIZE_WO_LENGTH = 3, HEADER_SIZE_WITH_LENGTH = 5, HEADER_SIZE_WITH_LENGTH_AND_CRC = 6};
38
39 public:
41 using ubig32_t = boost::endian::big_uint32_t;
42
45 explicit ROIpayload(int rois = 0);
46
50 virtual ~ROIpayload() { delete[] m_rootdata; };
51
55 int* m_rootdata; //[m_length]
56
58 int m_index;
60 uint32_t* m_data32;
63
64 void setPayloadLength(int length);
65 void setPayloadLength();
66 void setHeader(bool Accepted, bool SendAll, bool SendROIs);
67 void setTriggerNumber(unsigned long int triggerNumber);
70 void setRunSubrunExpNumber(int run, int subrun, int exp);
72 // void addROIraw(ROIrawID roiraw);
73 void addROIraw(unsigned long int roiraw);
74 void setCRC();
77 int getLength() {return m_length;}
79 int* getRootdata() {return m_rootdata;} //[m_length]
80
81 void init(int length);
86 int getNrROIs() const
87 {
88 return (m_length - HEADER_SIZE_WITH_LENGTH_AND_CRC) / 2; // only minus checksum
89 }
90
95 int getDHHID(int j) const
96 {
97 if (j < 0 || j >= getNrROIs()) return -1;
98 return (((ubig32_t*)m_rootdata)[HEADER_SIZE_WITH_LENGTH + 2 * j] & 0x3F0) >> 4; // & 0x3F0
99 }
100
105 int getMinVid(int j) const
106 {
107 if (j < 0 || j >= getNrROIs()) return -1;
108 return ((((ubig32_t*)m_rootdata)[HEADER_SIZE_WITH_LENGTH + 2 * j] & 0xF) << 6) | ((((ubig32_t*)m_rootdata)[HEADER_SIZE_WITH_LENGTH +
109 2 * j + 1] & 0xFC000000) >> 26) ;
110 }
111
116 int getMaxVid(int j) const
117 {
118 if (j < 0 || j >= getNrROIs()) return -1;
119 return (((ubig32_t*)m_rootdata)[HEADER_SIZE_WITH_LENGTH + 2 * j + 1] & 0x3FF00) >> 8;
120 }
121
126 int getMinUid(int j) const
127 {
128 if (j < 0 || j >= getNrROIs()) return -1;
129 return (((ubig32_t*)m_rootdata)[HEADER_SIZE_WITH_LENGTH + 2 * j + 1] & 0x03FC0000) >> 18;
130 }
131
136 int getMaxUid(int j) const
137 {
138 if (j < 0 || j >= getNrROIs()) return -1;
139 return (((ubig32_t*)m_rootdata)[HEADER_SIZE_WITH_LENGTH + 2 * j + 1]) & 0xFF;
140 }
141
146 int getType(int j) const
147 {
148 if (j < 0 || j >= getNrROIs()) return -1;
149 return (((ubig32_t*)m_rootdata)[HEADER_SIZE_WITH_LENGTH + 2 * j] & 0x400) >> 10;
150 }
151
152 private:
154 ClassDef(ROIpayload, 2)
155 };
157}
ROIpayload TODO: Better explanation, Is there a reason to inherit from TObject and not Relationsobjec...
Definition: ROIpayload.h:35
int m_packetLengthByte
packet length in byte
Definition: ROIpayload.h:52
void addROIraw(unsigned long int roiraw)
add a ROIrawID
Definition: ROIpayload.cc:82
int getMinVid(int j) const
Return MinVid (Row 1) of ROI j.
Definition: ROIpayload.h:105
int m_length
packet length
Definition: ROIpayload.h:53
int getDHHID(int j) const
Return DHH ID of ROI j.
Definition: ROIpayload.h:95
int * getRootdata()
get pointer to the data packet
Definition: ROIpayload.h:79
void setCRC()
set CRC
Definition: ROIpayload.cc:92
void setHeader(bool Accepted, bool SendAll, bool SendROIs)
set header
Definition: ROIpayload.cc:58
uint32_t * m_data32
transient value
Definition: ROIpayload.h:60
void setRunSubrunExpNumber(int run, int subrun, int exp)
set run/ subrun/exp number
Definition: ROIpayload.cc:74
int getNrROIs() const
Get the nr of ROIs.
Definition: ROIpayload.h:86
int getMaxVid(int j) const
Return MaxVid (Row 2) of ROI j.
Definition: ROIpayload.h:116
virtual ~ROIpayload()
destructor.
Definition: ROIpayload.h:50
int getMinUid(int j) const
Return MinUid (Col 1) of ROI j.
Definition: ROIpayload.h:126
int * m_rootdata
pointer to data packet of m_length words
Definition: ROIpayload.h:55
int getType(int j) const
Return Type (Datcon or HLT) of ROI j.
Definition: ROIpayload.h:146
int getLength()
get packet length
Definition: ROIpayload.h:77
void setTriggerNumber(unsigned long int triggerNumber)
set trigger number
Definition: ROIpayload.cc:69
void setPayloadLength()
set payload length
Definition: ROIpayload.cc:44
int m_index
transient index
Definition: ROIpayload.h:58
int getPacketLengthByte()
get packet length in bytes
Definition: ROIpayload.h:76
int getMaxUid(int j) const
Return MaxUid (Col 2) of ROI j.
Definition: ROIpayload.h:136
boost::endian::big_uint32_t ubig32_t
Shorthand for 32-bit integer stored in big-endian format.
Definition: ROIpayload.h:41
ROIrawID::baseType * m_data64
transient value
Definition: ROIpayload.h:62
uint64_t baseType
base type
Definition: ROIrawID.h:28
Abstract base class for different kinds of events.