13#define TRG_SHORT_NAMES
20#include "trg/trg/Utilities.h"
26#define NAME "TRGCDCConfig"
27#define VERSION "version 0.01"
28#define ENV_PATH "BELLE2_LOCAL_DIR"
30#define NOT_CONNECTED 99999
33main(
int argc,
const char* argv[])
36 cout << NAME <<
" ... " << VERSION << endl;
37 const string tab =
" ";
41 cout << NAME <<
" !!! two arguments necessary" << endl
42 << tab <<
" 1 : CDCWireConfig data file" << endl
43 << tab <<
" 2 : Version for new config file" << endl;
48 string ts0 = TRGUtil::dateStringF();
49 string ts1 = TRGUtil::dateString();
52 const string version = argv[2];
55 const string outname =
"TRGCDCConfig_" + version +
"_" + ts0 +
".dat";
58 const string path = getenv(ENV_PATH);
59 const string inname = path +
"/data/trg/" + argv[1];
60 cout << tab <<
"CDC Wire Config : " << inname << endl;
61 cout << tab <<
"CDC Trigger Config : " << outname << endl;
64 ifstream infile(inname.c_str(), ios::in);
66 cout << NAME <<
" !!! can not open file" << endl
67 <<
" " << inname << endl;
77 string cdcVersion =
"";
87 while (! infile.eof()) {
88 infile.getline(b, 800);
92 for (
unsigned i = 0; i < 7; i++) {
93 string car = TRGUtil::carstring(l);
94 l = TRGUtil::cdrstring(l);
99 }
else if (car ==
"CDC") {
100 cdcVersion = string(b);
106 id[lines] = atoi(car.c_str());
110 sid[lines] = atoi(car.c_str());
112 nw[lines] = atoi(car.c_str());
114 lid[lines] = atoi(car.c_str());
116 asid[lines] = atoi(car.c_str());
118 assid[lines] = atoi(car.c_str());
128 <<
" " << type[lines]
132 <<
" " << asid[lines]
133 <<
" " << assid[lines]
141 ofstream outfile(outname.c_str(), ios::out);
142 if (outfile.fail()) {
143 cout << NAME <<
" !!! can not open file" << endl
144 <<
" " << outname << endl;
149 unsigned fidBase = 0;
150 vector<unsigned> front[N_FRONT];
153 unsigned midBase = 0;
154 vector<unsigned>
merge[N_FRONT];
157 outfile <<
"# Generated by " << NAME <<
" " << VERSION << endl;
158 outfile <<
"# " << ts1 << endl;
159 outfile <<
"#" << endl;
160 outfile << cdcVersion << endl;
161 outfile <<
"CDC Trigger Config Version " << version << endl;
162 outfile <<
"#" << endl;
163 outfile <<
"# note : id is id of a board. Therefore tsf id is same as "
164 <<
"super layer id" << endl;
165 outfile <<
"# note : id 99999 means no connection" << endl;
166 outfile <<
"#" << endl;
167 outfile <<
"# wire id | layer id | front id | merge id | tsf id" << endl;
169 for (
unsigned i = 0; i < lines; i++) {
172 const unsigned nFront = nw[i] / 16;
175 unsigned nMerge = nFront / 4;
182 for (
unsigned j = 0; j < nw[i]; j++) {
185 const unsigned wid = nWires + j;
188 const unsigned fid = j / 16 + fidBase;
189 front[fid].push_back(wid);
192 unsigned mid = j / 64 + midBase;
196 merge[mid].push_back(wid);
211 if (mid == NOT_CONNECTED)
212 outfile << NOT_CONNECTED;
220 if (front[fidBase].size() == 32)
223 if (front[fidBase].size() == 48)
228 if (
merge[midBase].size() == 384)
240 cout << NAME <<
" ... terminated" << endl;
std::vector< std::vector< double > > merge(std::vector< std::vector< std::vector< double > > > toMerge)
merge { vector<double> a, vector<double> b} into {a, b}
Abstract base class for different kinds of events.