13#define TRGCDC_SHORT_NAMES
18#include "trg/cdc/modules/tsstream/TRGCDCTSStreamModule.h"
19#include "trg/trg/Debug.h"
20#include "trg/trg/BitStream.h"
21#include "trg/cdc/Wire.h"
22#include "trg/cdc/Segment.h"
23#include "trg/cdc/Layer.h"
39 return string(
"TRGCDCTSStreamModule 0.00");
46 _streamFilename(
"unknown"),
51 string desc =
"TRGCDCTSStreamModule(" +
version() +
")";
56 "TRGCDCTSStream debug level",
63 "The filename of bit stream",
67 cout <<
"TRGCDCTSStreamModule ... created" << endl;
77 cout <<
"TRGCDCTSStreamModule ... destructed " << endl;
84 cout <<
"TRGCDCTSStreamModule::initialize ... options" << endl;
92 unsigned val = TRGBSRecord_Comment;
93 _out->write((
char*) & val, 4);
94 const string cmt =
"test data ";
96 _out->write((
char*) & val, 4);
97 _out->write(cmt.c_str(), cmt.size());
110 const unsigned nWires = lyr->
nCells();
116 for (
unsigned i = 0; i < nWires; i++) {
117 const TCSegment& s = (TCSegment&) * (* lyr)[i];
118 _wires[l].push_back(s.wires()[5]);
123 unsigned val = TRGBSRecord_BeginRun;
124 _out->write((
char*) & val, 4);
126 _out->write((
char*) & val, 4);
130 cout <<
"TRGCDCTSStreamModule ... beginRun called. TRGCDC version="
143 unsigned val = TRGBSRecord_BeginEvent;
144 _out->write((
char*) & val, 4);
146 _out->write((
char*) & val, 4);
150 for (
unsigned c = 0; c < 100; c++) {
153 unsigned val = TRGBSRecord_Clock;
154 _out->write((
char*) & val, 4);
156 _out->write((
char*) & val, 4);
158 _out->write((
char*) & val, 4);
162 for (
unsigned l = 0; l < 9; l++) {
168 for (
unsigned i = 0; i <
_wires[l].size(); i++) {
170 bool hit = s.state(c);
175 unsigned val = TRGBSRecord_SegmentSL0;
177 _out->write((
char*) & val, 4);
179 _out->write((
char*) & val, 4);
180 for (
unsigned i = 0; i < stream.sizeInChar(); i++) {
181 char cs = stream.c(i);
182 _out->write(& cs, 1);
187 cout <<
"Super layer " << l <<
", clock " << c << endl;
194 unsigned val = TRGBSRecord_EndEvent;
195 _out->write((
char*) & val, 4);
197 _out->write((
char*) & val, 4);
206 unsigned val = TRGBSRecord_EndRun;
207 _out->write((
char*) & val, 4);
209 _out->write((
char*) & val, 4);
213 cout <<
"TRGCDCTSStreamModule ... endRun called " << endl;
225 cout <<
"TRGCDCTSStreamModule ... terminate called " << endl;
void setDescription(const std::string &description)
Sets the description of the module.
A class to represent a bit stream.
A class to represent a cell layer.
int _debugLevel
Debug level.
std::ofstream * _out
A pointer to an output file.
int _mode
Mode for streaming data.
std::string _streamFilename
The filename of bit stream.
std::vector< const TRGCDCWire * > _wires[9]
Storage for TS central wires.
TRGCDC * _cdc
A pointer to a TRGCDC;.
A class to represent a digitized signal. Unit is nano second.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
virtual void initialize() override
Initilizes TRGCDCTSStreamModule.
virtual void event() override
Called event by event.
virtual void endRun() override
Called when run ended.
virtual void terminate() override
Called when processing ended.
TRGCDCTSStreamModule()
Constructor.
virtual void beginRun() override
Called when new run started.
std::string version(void) const
returns version of TRGCDCTSStreamModule.
virtual ~TRGCDCTSStreamModule()
Destructor.
static std::string tab(void)
returns tab spaces.
unsigned nSegmentLayers(void) const
returns # of track segment layers.
static TRGCDC * getTRGCDC(void)
returns TRGCDC object.
const TRGCDCLayer * segmentLayer(unsigned id) const
returns a pointer to a track segment layer.
void dump(const std::string &message) const
dumps debug information.
static int level(void)
returns the debug level.
unsigned nCells(void) const
returns # of cells.
std::string version(void) const
returns version.
Abstract base class for different kinds of events.