 |
Belle II Software
release-05-02-19
|
15 #include "trg/trg/Utilities.h"
16 #include "trg/trg/BitStream.h"
26 TRGBitStream::TRGBitStream() :
43 _name(
"CopyOf" + a._name),
48 for (
unsigned i = 0; i < a._stream.size(); i++)
49 _stream.push_back(
new unsigned(* a._stream[i]));
60 unsigned sz4 = sz / 4;
61 for (
unsigned i = 0; i < sz4; i++) {
63 unsigned j = * (
unsigned*)(& (
c[i * 4]));
64 _stream.push_back(
new unsigned(j));
68 for (
unsigned i = 0; i < sz % 4; i++)
69 j |= (
c[sz4 + i] << i * 8);
70 _stream.push_back(
new unsigned(j));
76 for (
unsigned i = 0; i <
_stream.size(); i++)
82 const string& pre)
const
85 const string tab =
" ";
87 cout << pre <<
_name <<
":size=" << dec <<
_size << endl;
88 for (
unsigned i = 0; i <
_stream.size(); i++) {
91 const unsigned last =
_size % (
sizeof(unsigned) * 8);
107 cout <<
"TRGBitStream::append !!! stream is full :current size="
113 const unsigned storageSize =
sizeof(unsigned) * 8 *
_stream.size();
116 if (
_size <= storageSize) {
118 const unsigned position =
_size % (
sizeof(unsigned) * 8) - 1;
119 unsigned& last = *
_stream.back();
120 last |= (1 << position);
124 _stream.push_back(
new unsigned(1));
126 _stream.push_back(
new unsigned(0));
132 int initialClockPosition,
133 vector<TRGBitStream*> stream)
139 if (stream.size() == 0) {
140 cout <<
" !!! TRGBitStream::TRGBitStream2TRGSignal: given stream "
141 <<
"has no data" << endl;
146 const unsigned bs = stream[0]->size();
147 const unsigned cs = stream.size();
150 vector<TRGSignal*> s;
151 for (
unsigned i = 0; i < bs; i++)
155 for (
unsigned i = 0; i < cs; i++) {
158 for (
unsigned j = 0; j < bs; j++) {
159 if (stream[i]->
bit(j)) {
160 TRGTime r(
int(initialClockPosition + i),
true, clock);
162 f.shift(1).reverse();
169 for (
unsigned i = 0; i < s.size(); i++)
A class to represent a digitized signal. Unit is nano second.
static std::string streamDisplay(unsigned)
Dumps bit stream in string.
static std::vector< TRGSignal > TRGBitStream2TRGSignal(const TRGClock &clock, int initialClockPosition, std::vector< TRGBitStream * > stream)
Make trigger signals from bit stream.
unsigned _size
Bit stream size.
A class to represent a bit stream.
void dump(const std::string &message="", const std::string &pre="") const
dumps contents. "message" is to select information to dump. "pre" will be printed in head of each lin...
char c(unsigned positionInChar) const
returns a pointer to char's.
Abstract base class for different kinds of events.
bool bit(unsigned positionInBit) const
returns true if given position is active.
TRGBitStream()
Default constructor.
virtual ~TRGBitStream()
Destructor.
void append(bool)
appends a bit to a stream.
unsigned _sizeMax
Bit stream max size.
std::vector< unsigned * > _stream
Bit stream storage.
A class to represent a signal timing in the trigger system.
A class to represent a digitized signal. Unit is nano second.