14 #define TRG_SHORT_NAMES
20 #include "trg/trg/Utilities.h"
26 #define NAME "TRGCDCHoughMapConverter"
27 #define VERSION "version 0.00[2015/07/23]"
30 main(
int argc,
char* argv[])
33 cout << NAME <<
" ... " << VERSION << endl;
34 const string tab =
" ";
38 cout << NAME <<
" !!! two arguments necessary" << endl
39 << tab <<
" 1 : input mapping file name" << endl
40 << tab <<
" 2 : output mapping file name" << endl;
45 string ts0 = TRGUtil::dateStringF();
49 const string iname = argv[1];
52 const string oname = argv[2];
54 cout <<
" input mapping file : " << iname << endl;
55 cout <<
" output mapping file : " << oname << endl;
58 ifstream ifile(iname.c_str(), ios::in);
60 cout << NAME <<
" !!! can not open file" << endl
61 <<
" " << iname << endl;
66 ofstream ofile(oname.c_str(), ios::out);
68 cout << NAME <<
" !!! can not open file" << endl
69 <<
" " << oname << endl;
75 vector<unsigned> tsf2h[9][400];
76 while (! ifile.eof()) {
77 ifile.getline(b, 800);
80 if (b[0] ==
'#')
continue;
82 const unsigned hx = stoi(TRGUtil::carstring(l));
83 l = TRGUtil::cdrstring(l);
84 const unsigned hy = stoi(TRGUtil::carstring(l));
85 l = TRGUtil::cdrstring(l);
87 const unsigned hcid = hy * 1000 + hx;
90 const unsigned tsl = stoi(TRGUtil::carstring(l));
91 l = TRGUtil::cdrstring(l);
92 const unsigned tsi = stoi(TRGUtil::carstring(l));
93 l = TRGUtil::cdrstring(l);
94 tsf2h[tsl][tsi].push_back(hcid);
96 if (l.size() == 0)
break;
102 for (
unsigned tsl = 0; tsl < 9; tsl += 2) {
103 for (
unsigned tsi = 0; tsi < 400; tsi++) {
105 if (tsf2h[tsl][tsi].size() == 0)
continue;
109 for (
unsigned k = 0; k < tsf2h[tsl][tsi].size(); k++) {
110 const unsigned hcid = tsf2h[tsl][tsi][k];
111 const unsigned y = hcid / 1000;
112 if (y < miny) miny = y;
117 cout <<
"tsf " << tsl <<
" " << tsi <<
" x=";
119 for (
unsigned k = 0; k < tsf2h[tsl][tsi].size(); k++) {
120 const unsigned hcid = tsf2h[tsl][tsi][k];
121 const unsigned y = hcid / 1000;
122 if (y != miny)
continue;
123 const unsigned x = hcid % 1000;
132 ofile <<
"# This file is generated by " << NAME <<
"[" << VERSION <<
"]"
134 ofile <<
"# Source file is " << iname << endl;
135 ofile <<
"# " << ts0 << endl;
136 ofile <<
"#" << endl;
137 for (
unsigned j = 1; j < 17; j++) {
138 for (
unsigned i = 0; i < 160; i++) {
139 const unsigned hcid = j * 1000 + i;
140 ofile << i <<
" " << j;
142 for (
unsigned tsl = 0; tsl < 9; tsl += 2) {
143 for (
unsigned tsi = 0; tsi < 400; tsi++) {
144 for (
unsigned k = 0; k < tsf2h[tsl][tsi].size(); k++) {
145 if (tsf2h[tsl][tsi][k] == hcid)
146 ofile <<
" " << tsl <<
" " << tsi;