19 TrackletProcessor::TrackletProcessor(
string name,
Settings const& settings,
Globals* globals,
unsigned int iSector)
23 for (
unsigned int ilayer = 0; ilayer <
N_LAYER; ilayer++) {
28 for (
unsigned int idisk = 0; idisk <
N_DISK; idisk++) {
58 outputProj = dynamic_cast<TrackletProjectionsMemory*>(
memory);
59 assert(outputProj !=
nullptr);
67 if (
output ==
"trackpar") {
68 auto*
tmp = dynamic_cast<TrackletParametersMemory*>(
memory);
74 if (
output.substr(0, 7) ==
"projout") {
76 auto*
tmp = dynamic_cast<TrackletProjectionsMemory*>(
memory);
79 unsigned int layerdisk =
output[8] -
'1';
80 unsigned int phiregion =
output[12] -
'A';
101 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" Could not find output : " <<
output;
110 if (
input ==
"outervmstubin") {
111 auto*
tmp = dynamic_cast<VMStubsTEMemory*>(
memory);
118 if (
tmp->getName()[11] ==
'X')
120 if (
tmp->getName()[11] ==
'Y')
122 if (
tmp->getName()[11] ==
'Z')
124 if (
tmp->getName()[11] ==
'W')
143 if (
input ==
"innerallstubin") {
144 auto*
tmp = dynamic_cast<AllStubsMemory*>(
memory);
155 tedatabuffertmp.
reset();
163 if (
input ==
"outerallstubin") {
164 auto*
tmp = dynamic_cast<AllStubsMemory*>(
memory);
169 throw cms::Exception(
"BadConfig") << __FILE__ <<
" " << __LINE__ <<
" Could not find input : " <<
input;
182 unsigned int countall = 0;
183 unsigned int countsel = 0;
185 unsigned int countteall = 0;
186 unsigned int stubpairs = 0;
188 unsigned int ntedata = 0;
190 unsigned int ninnerstubs = 0;
196 std::get<0>(tebuffer).reset();
197 std::get<1>(tebuffer) = 0;
198 std::get<2>(tebuffer) = std::get<3>(tebuffer);
209 unsigned int& istub = std::get<1>(tebuffer);
210 unsigned int& imem = std::get<2>(tebuffer);
211 unsigned int imemend = std::get<4>(tebuffer);
213 if ((!tedatabuffer.
full()) && imem < imemend && istub <
innerallstubs_[imem]->nStubs()) {
218 bool negdisk = (stub->
disk().
value() < 0);
232 indexr = stub->
r().
value();
250 FPGAWord lookupbits(lutval, lutwidth,
true, __LINE__, __FILE__);
252 int rzfinebinfirst = lookupbits.
bits(0, 3);
255 int rzdiffmax = lookupbits.
bits(lookupbits.
nbits() - 3, 3);
264 unsigned int useregindex = (innerfinephi << innerbend.
nbits()) + innerbend.
value();
267 int ir = ((
start & 3) << 1) + (rzfinebinfirst >> 2);
268 useregindex = (useregindex << 3) + ir;
272 vector<bool> usereg =
useregion_[useregindex];
283 assert(ireg < usereg.size());
287 for (
int ibin =
start; ibin <=
last; ibin++) {
295 tedata.
regions_.emplace_back(tuple<int, int, int>(ibin -
start, ireg, nstubs));
296 countteall += nstubs;
304 tedatabuffer.
store(tedata);
315 bool tedatabuffersdone =
true;
318 tedatabuffersdone &= tedatabuffer.
empty();
319 tedatabuffersdone &= (std::get<2>(tebuffer) == std::get<4>(tebuffer));
320 if (!tedatabuffer.
empty()) {
322 if (teunit.empty() && teunit.idle()) {
323 teunit.init(tedatabuffer.
read());
330 bool teunitsdone =
true;
333 if (!teunit.idle()) {
337 if (!teunit.empty()) {
343 if (teunitptr !=
nullptr) {
344 auto stubpair = teunitptr->
read();
352 const Stub* innerFPGAStub = stubpair.first;
355 const Stub* outerFPGAStub = stubpair.second;
394 if (teunitsdone && tedatabuffersdone) {
401 ofstream outstubptinnercut;
402 outstubptinnercut.open(
getName() +
"_stubptinnercut.tab");
403 outstubptinnercut <<
"{" << endl;
409 outstubptinnercut << endl <<
"};" << endl;
410 outstubptinnercut.close();
412 ofstream outstubptoutercut;
413 outstubptoutercut.open(
getName() +
"_stubptoutercut.tab");
414 outstubptoutercut <<
"{" << endl;
420 outstubptoutercut << endl <<
"};" << endl;
421 outstubptoutercut.close();
452 int nbins = 2.0 * (dphimax / dfinephi + 1.0);
463 int outerrbins = (1 << outerrbits);
468 unsigned int nbendbitsinner = 3;
469 unsigned int nbendbitsouter = 3;
479 for (
int iphibin = 0; iphibin < nbinsfinephidiff; iphibin++) {
480 int iphidiff = iphibin;
481 if (iphibin >= nbinsfinephidiff / 2) {
482 iphidiff = iphibin - nbinsfinephidiff;
485 dphi[0] = (iphidiff - 1.5) * dfinephi;
486 dphi[1] = (iphidiff + 1.5) * dfinephi;
487 for (
int irouterbin = 0; irouterbin < outerrbins; irouterbin++) {
498 double bendinnermin = 20.0;
499 double bendinnermax = -20.0;
500 double bendoutermin = 20.0;
501 double bendoutermax = -20.0;
502 double rinvmin = 1.0;
503 for (
int i2 = 0;
i2 < 2;
i2++) {
504 for (
int i3 = 0;
i3 < 2;
i3++) {
511 double rinv1 =
rinv(0.0, dphi[
i2], rinner, router[
i3]);
515 double abendinner = -
bend(rinner, rinv1, pitchinner);
516 double abendouter = -
bend(router[
i3], rinv1, pitchouter);
517 if (abendinner < bendinnermin)
518 bendinnermin = abendinner;
519 if (abendinner > bendinnermax)
520 bendinnermax = abendinner;
521 if (abendouter < bendoutermin)
522 bendoutermin = abendouter;
523 if (abendouter > bendoutermax)
524 bendoutermax = abendouter;
533 for (
int ibend = 0; ibend < (1 << nbendbitsinner); ibend++) {
541 for (
int ibend = 0; ibend < (1 << nbendbitsouter); ibend++) {
557 for (
int innerfinephi = 0; innerfinephi < (1 <<
nbitsfinephi_); innerfinephi++) {
558 for (
int innerbend = 0; innerbend < (1 << nbendbitsinner); innerbend++) {
559 for (
int ir = 0; ir < (1 << nirbits); ir++) {
567 int idphi = outerfinephi - innerfinephi;
573 idphi1 = (idphi << 3) + ir;
574 int ptinnerindexnew = (idphi1 << nbendbitsinner) + innerbend;
579 usereg.push_back(
match);