10#include "trg/trg/Utilities.h"
11#include "trg/trg/BitStream.h"
38 _name(
"CopyOf" + a._name),
43 for (
unsigned i = 0; i < a._stream.size(); i++)
44 _stream.push_back(
new unsigned(* a._stream[i]));
55 unsigned sz4 = sz / 4;
56 for (
unsigned i = 0; i < sz4; i++) {
58 unsigned j = * (
unsigned*)(& (
c[i * 4]));
59 _stream.push_back(
new unsigned(j));
63 for (
unsigned i = 0; i < sz % 4; i++)
64 j |= (
c[sz4 + i] << i * 8);
65 _stream.push_back(
new unsigned(j));
71 for (
unsigned i = 0; i <
_stream.size(); i++)
77 const string& pre)
const
80 const string tab =
" ";
82 cout << pre <<
_name <<
":size=" << dec <<
_size << endl;
83 for (
unsigned i = 0; i <
_stream.size(); i++) {
86 const unsigned last =
_size % (
sizeof(unsigned) * 8);
102 cout <<
"TRGBitStream::append !!! stream is full :current size="
108 const unsigned storageSize =
sizeof(unsigned) * 8 *
_stream.size();
111 if (
_size <= storageSize) {
120 _stream.push_back(
new unsigned(1));
122 _stream.push_back(
new unsigned(0));
128 int initialClockPosition,
129 vector<TRGBitStream*> stream)
135 if (stream.size() == 0) {
136 cout <<
" !!! TRGBitStream::TRGBitStream2TRGSignal: given stream "
137 <<
"has no data" << endl;
142 const unsigned bs = stream[0]->size();
143 const unsigned cs = stream.size();
146 vector<TRGSignal*> s;
147 for (
unsigned i = 0; i < bs; i++)
151 for (
unsigned i = 0; i < cs; i++) {
154 for (
unsigned j = 0; j < bs; j++) {
155 if (stream[i]->
bit(j)) {
156 TRGTime r(
int(initialClockPosition + i),
true, clock);
158 f.shift(1).reverse();
165 for (
unsigned i = 0; i < s.size(); i++)
A class to represent a bit stream.
unsigned _size
Bit stream size.
unsigned _sizeMax
Bit stream max size.
std::vector< unsigned * > _stream
Bit stream storage.
A class to represent a digitized signal. Unit is nano second.
A class to represent a digitized signal. Unit is nano second.
A class to represent a signal timing in the trigger system.
bool bit(unsigned positionInBit) const
returns true if given position is active.
TRGBitStream()
Default constructor.
virtual ~TRGBitStream()
Destructor.
static std::vector< TRGSignal > TRGBitStream2TRGSignal(const TRGClock &clock, int initialClockPosition, std::vector< TRGBitStream * > stream)
Make trigger signals from bit stream.
char c(unsigned positionInChar) const
returns a pointer to char's.
static std::string streamDisplay(unsigned)
Dumps bit stream in string.
void append(bool)
appends a bit to a 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...
Abstract base class for different kinds of events.