18 MatchEngine::MatchEngine(
string name,
Settings const& settings,
Globals* global,
unsigned int iSector)
22 string subname =
name.substr(3, 2);
23 if (subname.substr(0, 1) ==
"L")
24 layer_ = stoi(subname.substr(1, 1));
25 else if (subname.substr(0, 1) ==
"D")
26 disk_ = stoi(subname.substr(1, 1));
28 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" " <<
name <<
" subname = " << subname <<
" "
42 unsigned int nbits = 3;
46 for (
unsigned int irinv = 0; irinv < 32; irinv++) {
52 for (
unsigned int ibend = 0; ibend < (
unsigned int)(1 <<
nbits); ibend++) {
63 throw cms::Exception(
"BadDir") << __FILE__ <<
" " << __LINE__ <<
" could not create directory "
68 string fname =
"METable_L";
73 ofstream
out(full_fname);
75 throw cms::Exception(
"BadFile") << __FILE__ <<
" " << __LINE__ <<
" could not create file " << full_fname;
78 for (
unsigned int i = 0;
i <
table_.size();
i++) {
90 for (
unsigned int iprojbend = 0; iprojbend < 32; iprojbend++) {
91 double projbend = 0.5 * (iprojbend - 15.0);
92 for (
unsigned int ibend = 0; ibend < 8; ibend++) {
97 for (
unsigned int ibend = 0; ibend < 16; ibend++) {
111 if (
output ==
"matchout") {
112 auto*
tmp = dynamic_cast<CandidateMatchMemory*>(
memory);
117 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find output: " <<
output;
125 if (
input ==
"vmstubin") {
126 auto*
tmp = dynamic_cast<VMStubsMEMemory*>(
memory);
131 if (
input ==
"vmprojin") {
132 auto*
tmp = dynamic_cast<VMProjectionsMemory*>(
memory);
137 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find input: " <<
input;
141 unsigned int countall = 0;
142 unsigned int countpass = 0;
144 constexpr
unsigned int kNBitsBuffer = 3;
148 std::pair<int, int> projbuffer[1 << kNBitsBuffer];
153 bool moreproj = iproj < nproj;
158 int projfinerzadj = 0;
159 unsigned int projfinephi = 0;
163 bool isPSseed =
false;
173 int writeindexplus = (writeindex + 1) % (1 << kNBitsBuffer);
174 int writeindexplusplus = (writeindex + 2) % (1 << kNBitsBuffer);
178 bool bufferfull = (writeindexplus == readindex) || (writeindexplusplus == readindex);
181 bool buffernotempty = (writeindex != readindex);
187 if ((!moreproj) && (!buffernotempty))
190 if (moreproj && (!bufferfull)) {
193 int iprojtmp = iproj;
196 moreproj = iproj < nproj;
199 unsigned int rzlast = rzfirst;
207 bool savefirst = nstubfirst != 0;
208 bool savelast =
second && (nstublast != 0);
210 int writeindextmp = writeindex;
211 int writeindextmpplus = (writeindex + 1) % (1 << kNBitsBuffer);
213 if (savefirst && savelast) {
214 writeindex = writeindexplusplus;
215 }
else if (savefirst || savelast) {
216 writeindex = writeindexplus;
220 std::pair<int, int>
tmp(iprojtmp, rzfirst);
221 projbuffer[writeindextmp] =
tmp;
224 std::pair<int, int>
tmp(iprojtmp, rzlast + 100);
226 projbuffer[writeindextmpplus] =
tmp;
228 projbuffer[writeindextmp] =
tmp;
235 if (buffernotempty) {
236 int istubtmp = istub;
240 projindex = projbuffer[readindex].first;
241 rzbin = projbuffer[readindex].second;
259 ? (16 + (((-2) *
proj->fpgaphiprojder(
layer_).value()) >> (
proj->fpgaphiprojder(
layer_).nbits() - 4)))
270 isPSseed =
proj->PSseed() == 1;
274 projfinerzadj = projfinerz - 8;
276 projfinerzadj = projfinerz;
280 readindex = (readindex + 1) % (1 << kNBitsBuffer);
286 if (istub + 1 >= nstubs) {
288 readindex = (readindex + 1) % (1 << kNBitsBuffer);
301 int nbits = isPSmodule ? 3 : 4;
305 bool passphi = (
abs(deltaphi) < 3) || (
abs(deltaphi) > 5);
310 int idrz = stubfinerz - projfinerzadj;
315 passz = idrz >= -2 && idrz <= 2;
317 passz = idrz >= -5 && idrz <= 5;
321 passz = idrz >= -1 && idrz <= 1;
323 passz = idrz >= -5 && idrz <= 5;
328 if (passz && passphi) {
333 ofstream
fout(
"seeds.txt", ofstream::app);
334 fout << __FILE__ <<
":" << __LINE__ <<
" " <<
name_ <<
"_" <<
iSector_ <<
" " <<
proj->getISeed() << endl;