13 #define TRG_SHORT_NAMES
14 #define TRGCDC_SHORT_NAMES
19 #include "trg/trg/BitStream.h"
20 #include "trg/cdc/Wire.h"
22 #include "framework/gearbox/Gearbox.h"
23 #include "trg/cdc/DisplayRphi.h"
24 #include "trg/cdc/DisplayHough.h"
25 namespace Belle2_TRGCDC {
26 Belle2::TRGCDCDisplayRphi* D = 0;
33 using namespace Belle2_TRGCDC;
37 #define PROGRAM_NAME "TRGCDCTSStreamReader"
38 #define PROGRAM_VERSION "version 0.03"
39 #define ENV_PATH "BELLE2_LOCAL_DIR"
40 #define CONFIG "TRGCDCWireConfig_0_20101110_0836.dat"
43 main(
int argc,
char* argv[])
46 cout << PROGRAM_NAME <<
" ... " << PROGRAM_VERSION << endl;
47 const string tab =
" ";
51 cout << PROGRAM_NAME <<
" !!! one argument necessary" << endl
52 << tab <<
" 1 : Track Segment Stream data file" << endl;
57 const string inname = argv[1];
58 cout << tab <<
"Track Segment Stream : " << inname << endl;
61 ifstream infile(inname.c_str(), ios::in | ios::binary);
63 cout << PROGRAM_NAME <<
" !!! can not open file" << endl
64 <<
" " << inname << endl;
70 const string path = getenv(ENV_PATH);
71 std::vector<std::string> m_backends;
72 std::string m_filename = path +
"/data/geometry/Belle2.xml";
73 m_backends.push_back(
"file:");
74 Gearbox& gearbox = Gearbox::getInstance();
75 gearbox.setBackends(m_backends);
76 gearbox.open(m_filename);
79 const string cname = path +
"/data/trg/" + CONFIG;
81 TRGCDC* cdc = TRGCDC::getTRGCDC(cname);
82 const TRGClock& clock = cdc->systemClock();
85 unsigned LID[9] = {2, 10, 16, 22, 28, 34, 40, 46, 52};
94 vector<TRGBitStream*> bits[9];
95 vector<const TCWire*> wires;
98 while (! infile.eof()) {
102 infile.read((
char*) & rec, 4);
104 infile.read((
char*) & siz, 4);
106 cout <<
"... " << hex << rec <<
"," << dec << siz << endl;
111 case TRGBSRecord_Comment: {
112 unsigned csiz = siz / 8;
114 char* buf =
new char[csiz + 1];
115 infile.read(buf, csiz);
118 cout <<
"siz,csiz=" << siz <<
"," << csiz << endl;
121 cout <<
"Comment : " << buf << endl;
125 case TRGBSRecord_BeginRun:
127 cout <<
"BeginRun : " << siz << endl;
130 case TRGBSRecord_EndRun:
132 cout <<
"EndRun : " << siz << endl;
135 case TRGBSRecord_BeginEvent:
136 #ifdef TRGCDC_DISPLAY
138 D->beginningOfEvent();
140 for (
unsigned i = 0; i < 9; i++) {
141 for (
unsigned j = 0; j < bits[i].size(); j++)
145 for (
unsigned i = 0; i < clks.size(); i++)
150 cout <<
"BeginEvent : " << siz << endl;
153 case TRGBSRecord_EndEvent:
154 #ifdef TRGCDC_DISPLAY
155 for (
unsigned i = 0; i < 9; i++) {
156 vector<TRGSignal> t = TRGBitStream::TRGBitStream2TRGSignal(
160 for (
unsigned j = 0; j < t.size(); j++) {
162 wires.push_back(cdc->wire(LID[i], j));
165 D->area().append(wires);
171 cout <<
"EndEvent : " << siz << endl;
174 case TRGBSRecord_Clock: {
176 infile.read((
char*) & clk, 4);
177 clks.push_back(
new int(clk));
179 cout <<
"Clock : " << clk << endl;
183 case TRGBSRecord_SegmentSL0:
184 case TRGBSRecord_SegmentSL1:
185 case TRGBSRecord_SegmentSL2:
186 case TRGBSRecord_SegmentSL3:
187 case TRGBSRecord_SegmentSL4:
188 case TRGBSRecord_SegmentSL5:
189 case TRGBSRecord_SegmentSL6:
190 case TRGBSRecord_SegmentSL7:
191 case TRGBSRecord_SegmentSL8: {
192 unsigned superLayer = rec - TRGBSRecord_SegmentSL0;
193 unsigned csiz = siz / 8;
195 char* buf =
new char[csiz];
196 infile.read(buf, csiz);
198 bits[superLayer].push_back(bs);
205 cout << PROGRAM_NAME <<
" !!! unknown record found : "
206 <<
"record type = " << hex << rec << endl;
213 cout << PROGRAM_NAME <<
" ... terminated" << endl;
Singleton class responsible for loading detector parameters from an XML file.
A class to represent a bit stream.
The instance of TRGCDC is a singleton.
A class to represent a digitized signal. Unit is nano second.
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.
int main(int argc, char **argv)
Run all tests.