14 #define TRG_SHORT_NAMES
22 #include "trg/trg/Utilities.h"
28 #define NAME "TRGCDCTRGPackerTB"
29 #define VERSION "version 0.00"
30 #define ENV_PATH "BELLE2_LOCAL_DIR"
32 #define NOT_CONNECTED 99999
35 main(
int argc,
char* argv[])
38 cout << NAME <<
" ... " << VERSION << endl;
39 const string tab =
" ";
43 cout << NAME <<
" !!! two arguments necessary" << endl
44 << tab <<
" 1 : input data file" << endl;
56 const string inname = argv[1];
57 const string outname = string(argv[1]) +
".out";
58 cout << tab <<
"input data : " << inname << endl;
59 cout << tab <<
"output data : " << outname << endl;
62 ifstream infile(inname.c_str(), ios::in);
64 cout << NAME <<
" !!! can not open file" << endl
65 <<
" " << inname << endl;
72 multimap<unsigned, unsigned> signals;
73 while (! infile.eof()) {
74 infile.getline(b, 800);
83 for (
unsigned i = 0; i < 2; i++) {
84 string car = TRGUtil::carstring(l);
85 l = TRGUtil::cdrstring(l);
93 id = atoi(car.c_str());
95 pos = atoi(car.c_str());
103 signals.insert(pair<unsigned, unsigned>(
id, pos));
108 <<
" " << pos << endl;
116 memset(bm, 0,
sizeof(
unsigned) * 48);
117 for (map<unsigned, unsigned>::iterator i = signals.begin();
121 bm[i->first] |= (1 << i->second);
124 cout << i->first <<
" -> " << i->second << endl;
128 ofstream outfile(outname.c_str(), ios::out);
129 if (outfile.fail()) {
130 cout << NAME <<
" !!! can not open file" << endl
131 <<
" " << outname << endl;
136 outfile <<
"Input signal bit map" << endl;
137 for (
unsigned i = 0; i < 48; i++) {
139 outfile << i <<
" : ";
141 outfile << bm[i] <<
" : ";
142 for (
unsigned j = 0; j < 32; j++) {
143 if (j && ((j % 4) == 0))
145 unsigned x = ((bm[i] >> (31 - j)) & 1);
155 outfile <<
"Hit pattern in 16ns" << endl;
157 <<
"7654321_987654321_987654321_987654321_9876543210" << endl;
158 unsigned long long hitptn[2];
159 memset(hitptn, 0,
sizeof(
unsigned long long) * 2);
160 for (
unsigned i = 0; i < 2; i++) {
161 for (
unsigned j = 0; j < 48; j++) {
162 bool hit = (bm[j] >> (i * 16)) & 0xffff;
164 hitptn[i] |= ((
unsigned long long) 1 << j);
169 outfile << i <<
" : ";
171 outfile << hex << hitptn[i] <<
" : ";
172 for (
unsigned k = 0; k < 48; k++) {
173 unsigned x = ((hitptn[i] >> (47 - k)) & 1);
183 outfile <<
"Fine timing of central cells in 16ns" << endl;
184 unsigned fineTiming[2][48];
185 memset(fineTiming, 0,
sizeof(
unsigned) * 2 * 48);
186 for (
unsigned i = 0; i < 2; i++) {
187 outfile << i <<
" : ";
188 for (
unsigned j = 0; j < 48; j++) {
189 unsigned timing = (bm[j] >> (i * 16)) & 0xffff;
190 fineTiming[i][j] = timing;
192 outfile << hex << fineTiming[i][j];
194 outfile << endl <<
" ";
206 cout << NAME <<
" ... terminated" << endl;