16 MatchEngine::MatchEngine(
string name,
Settings const& settings,
Globals* global,
unsigned int iSector)
20 string subname =
name.substr(3, 2);
21 if (subname.substr(0, 1) ==
"L")
22 layer_ = stoi(subname.substr(1, 1));
23 else if (subname.substr(0, 1) ==
"D")
24 disk_ = stoi(subname.substr(1, 1));
26 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" " <<
name <<
" subname = " << subname <<
" "
30 unsigned int nbits = 3;
34 for (
unsigned int irinv = 0; irinv < 32; irinv++) {
40 for (
unsigned int ibend = 0; ibend < (
unsigned int)(1 <<
nbits); ibend++) {
50 string fname =
"METable_L";
55 for (
unsigned int i = 0;
i <
table_.size();
i++) {
67 for (
unsigned int iprojbend = 0; iprojbend < 32; iprojbend++) {
68 double projbend = 0.5 * (iprojbend - 15.0);
69 for (
unsigned int ibend = 0; ibend < 8; ibend++) {
74 for (
unsigned int ibend = 0; ibend < 16; ibend++) {
88 if (
output ==
"matchout") {
89 auto*
tmp = dynamic_cast<CandidateMatchMemory*>(
memory);
94 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find output: " <<
output;
102 if (
input ==
"vmstubin") {
103 auto*
tmp = dynamic_cast<VMStubsMEMemory*>(
memory);
108 if (
input ==
"vmprojin") {
109 auto*
tmp = dynamic_cast<VMProjectionsMemory*>(
memory);
114 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" could not find input: " <<
input;
120 unsigned int countall = 0;
121 unsigned int countpass = 0;
123 constexpr
unsigned int kNBitsBuffer = 3;
127 std::pair<int, int> projbuffer[1 << kNBitsBuffer];
132 bool moreproj = iproj < nproj;
137 int projfinerzadj = 0;
141 bool isPSseed =
false;
151 int writeindexplus = (writeindex + 1) % (1 << kNBitsBuffer);
152 int writeindexplusplus = (writeindex + 2) % (1 << kNBitsBuffer);
156 bool bufferfull = (writeindexplus == readindex) || (writeindexplusplus == readindex);
159 bool buffernotempty = (writeindex != readindex);
165 if ((!moreproj) && (!buffernotempty))
168 if (moreproj && (!bufferfull)) {
171 int iprojtmp = iproj;
174 moreproj = iproj < nproj;
177 unsigned int rzlast = rzfirst;
185 bool savefirst = nstubfirst != 0;
186 bool savelast =
second && (nstublast != 0);
188 int writeindextmp = writeindex;
189 int writeindextmpplus = (writeindex + 1) % (1 << kNBitsBuffer);
191 if (savefirst && savelast) {
192 writeindex = writeindexplusplus;
193 }
else if (savefirst || savelast) {
194 writeindex = writeindexplus;
198 std::pair<int, int>
tmp(iprojtmp, rzfirst);
199 projbuffer[writeindextmp] =
tmp;
202 std::pair<int, int>
tmp(iprojtmp, rzlast + 100);
204 projbuffer[writeindextmpplus] =
tmp;
206 projbuffer[writeindextmp] =
tmp;
213 if (buffernotempty) {
214 int istubtmp = istub;
218 projindex = projbuffer[readindex].first;
219 rzbin = projbuffer[readindex].second;
234 ? (16 + (((-2) *
proj->fpgaphiprojder(
layer_).value()) >> (
proj->fpgaphiprojder(
layer_).nbits() - 4)))
245 isPSseed =
proj->PSseed() == 1;
249 projfinerzadj = projfinerz - 8;
251 projfinerzadj = projfinerz;
255 readindex = (readindex + 1) % (1 << kNBitsBuffer);
261 if (istub + 1 >= nstubs) {
263 readindex = (readindex + 1) % (1 << kNBitsBuffer);
276 int nbits = isPSmodule ? 3 : 4;
283 int idrz = stubfinerz - projfinerzadj;
288 pass = idrz >= -2 && idrz <= 2;
290 pass = idrz >= -5 && idrz <= 5;
294 pass = idrz >= -1 && idrz <= 1;
296 pass = idrz >= -5 && idrz <= 5;
306 ofstream
fout(
"seeds.txt", ofstream::app);
307 fout << __FILE__ <<
":" << __LINE__ <<
" " <<
name_ <<
"_" <<
iSector_ <<
" " <<
proj->getISeed() << endl;