13#define TRG_SHORT_NAMES
21#include "trg/trg/Utilities.h"
27#define NAME "TRGCDCTRGPackerTB"
28#define VERSION "version 0.00"
29#define ENV_PATH "BELLE2_LOCAL_DIR"
31#define NOT_CONNECTED 99999
34main(
int argc,
char* argv[])
37 cout << NAME <<
" ... " << VERSION << endl;
38 const string tab =
" ";
42 cout << NAME <<
" !!! two arguments necessary" << endl
43 << tab <<
" 1 : input data file" << endl;
55 const string inname = argv[1];
56 const string outname = string(argv[1]) +
".out";
57 cout << tab <<
"input data : " << inname << endl;
58 cout << tab <<
"output data : " << outname << endl;
61 ifstream infile(inname.c_str(), ios::in);
63 cout << NAME <<
" !!! can not open file" << endl
64 <<
" " << inname << endl;
71 multimap<unsigned, unsigned> signals;
72 while (! infile.eof()) {
73 infile.getline(b, 800);
82 for (
unsigned i = 0; i < 2; i++) {
83 string car = TRGUtil::carstring(l);
84 l = TRGUtil::cdrstring(l);
92 id = atoi(car.c_str());
94 pos = atoi(car.c_str());
102 signals.insert(pair<unsigned, unsigned>(
id, pos));
107 <<
" " << pos << endl;
115 memset(bm, 0,
sizeof(
unsigned) * 48);
116 for (map<unsigned, unsigned>::iterator i = signals.begin();
120 bm[i->first] |= (1 << i->second);
123 cout << i->first <<
" -> " << i->second << endl;
127 ofstream outfile(outname.c_str(), ios::out);
128 if (outfile.fail()) {
129 cout << NAME <<
" !!! can not open file" << endl
130 <<
" " << outname << endl;
135 outfile <<
"Input signal bit map" << endl;
136 for (
unsigned i = 0; i < 48; i++) {
138 outfile << i <<
" : ";
140 outfile << bm[i] <<
" : ";
141 for (
unsigned j = 0; j < 32; j++) {
142 if (j && ((j % 4) == 0))
144 unsigned x = ((bm[i] >> (31 - j)) & 1);
154 outfile <<
"Hit pattern in 16ns" << endl;
156 <<
"7654321_987654321_987654321_987654321_9876543210" << endl;
157 unsigned long long hitptn[2];
158 memset(hitptn, 0,
sizeof(
unsigned long long) * 2);
159 for (
unsigned i = 0; i < 2; i++) {
160 for (
unsigned j = 0; j < 48; j++) {
161 bool hit = (bm[j] >> (i * 16)) & 0xffff;
163 hitptn[i] |= ((
unsigned long long) 1 << j);
168 outfile << i <<
" : ";
170 outfile << hex << hitptn[i] <<
" : ";
171 for (
unsigned k = 0; k < 48; k++) {
172 unsigned x = ((hitptn[i] >> (47 - k)) & 1);
182 outfile <<
"Fine timing of central cells in 16ns" << endl;
183 unsigned fineTiming[2][48];
184 memset(fineTiming, 0,
sizeof(
unsigned) * 2 * 48);
185 for (
unsigned i = 0; i < 2; i++) {
186 outfile << i <<
" : ";
187 for (
unsigned j = 0; j < 48; j++) {
188 unsigned timing = (bm[j] >> (i * 16)) & 0xffff;
189 fineTiming[i][j] = timing;
191 outfile << hex << fineTiming[i][j];
193 outfile << endl <<
" ";
205 cout << NAME <<
" ... terminated" << endl;
Abstract base class for different kinds of events.