22 TrackletConfigBuilder::TrackletConfigBuilder(
const Settings& settings,
const tt::Setup*
setup) : settings_(settings) {
45 for (
int layerdisk = 0; layerdisk <
N_LAYER +
N_DISK; layerdisk++) {
66 static std::once_flag runOnce;
67 std::call_once(runOnce, &TrackletConfigBuilder::writeDTCphirange,
this);
76 list<DTCinfo> vecDTCinfo_unsorted;
79 unsigned int numDTCsPerSector =
setup->numDTCsPerRegion();
80 for (
unsigned int dtcId = 0; dtcId < numDTCsPerSector; dtcId++) {
81 typedef std::pair<float, float> PhiRange;
82 std::map<int, PhiRange> dtcPhiRange;
85 for (
unsigned int iSector = 0; iSector <
N_SECTOR; iSector++) {
86 unsigned int dtcId_regI = iSector * numDTCsPerSector + dtcId;
87 const std::vector<tt::SensorModule*>& dtcModules =
setup->dtcModules(dtcId_regI);
90 int layer =
sm->layerId();
94 const int endcapOffsetHybrid = 5;
95 layer -= endcapOffsetHybrid;
98 float r =
sm->r() - 0.5 *
sm->numColumns() *
sm->pitchCol() * fabs(
sm->sinTilt());
100 float phiMin =
sm->phi() - 0.5 *
sm->numRows() *
sm->pitchRow() /
r;
101 float phiMax =
sm->phi() + 0.5 *
sm->numRows() *
sm->pitchRow() /
r;
104 phiMin += phiOffsetHybrid;
105 phiMax += phiOffsetHybrid;
106 if (dtcPhiRange.find(layer) == dtcPhiRange.end()) {
109 dtcPhiRange.at(layer).first =
std::min(
phiMin, dtcPhiRange.at(layer).first);
110 dtcPhiRange.at(layer).second =
std::max(
phiMax, dtcPhiRange.at(layer).second);
114 for (
const auto&
p : dtcPhiRange) {
115 const unsigned int numSlots =
setup->numATCASlots();
117 if (dtcId >= numSlots)
118 dtcName =
"neg" + dtcName;
121 info.layer =
p.first;
122 info.phimin =
p.second.first;
123 info.phimax =
p.second.second;
124 vecDTCinfo_unsorted.push_back(
info);
129 for (
const DTCinfo&
info : vecDTCinfo_unsorted) {
130 string dtcname =
info.name;
131 if (dtcname.find(
"PS") != std::string::npos) {
135 for (
const DTCinfo&
info : vecDTCinfo_unsorted) {
136 string dtcname =
info.name;
137 if (dtcname.find(
"PS") == std::string::npos) {
146 void TrackletConfigBuilder::writeDTCphirange()
const {
154 out <<
"// layer & phi ranges of modules read by each DTC" << endl;
155 out <<
"// (Used by stand-alone emulation)" << endl;
169 const string fname =
"../data/dtcphirange.txt";
171 std::ifstream str_dtc;
175 while (ifstream, getline(
line)) {
176 std::istringstream iss(
line);
196 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
198 for (
unsigned int iReg = 0; iReg <
NRegions_[ilayer]; iReg++) {
199 std::vector<std::pair<unsigned int, unsigned int> > emptyVec;
202 double phimin = dphi * iReg;
206 double dphiVM = dphi /
NVMME_[ilayer];
207 for (
unsigned int iVM = 0; iVM <
NVMME_[ilayer]; iVM++) {
208 double phivmmin =
phimin + iVM * dphiVM;
209 double phivmmax = phivmmin + dphiVM;
210 std::pair<double, double>
tmp(phivmmin, phivmmax);
221 for (
unsigned int iVM = 0; iVM < nVM1 *
NRegions_[l1]; iVM++) {
222 double phivmmin = iVM * dphiVM;
223 double phivmmax = phivmmin + dphiVM;
224 std::pair<double, double>
tmp(phivmmin, phivmmax);
228 for (
unsigned int iVM = 0; iVM < nVM2 *
NRegions_[l2]; iVM++) {
229 double phivmmin = iVM * dphiVM;
230 double phivmmax = phivmmin + dphiVM;
231 std::pair<double, double>
tmp(phivmmin, phivmmax);
242 unsigned int l1 = seedlayers.first;
243 unsigned int l2 = seedlayers.second;
250 }
else if (
iseed < 6) {
259 return std::pair<double, double>(r1,
r2);
265 double rinvmin = 999.9;
266 double rinvmax = -999.9;
273 for (
unsigned int i1 = 0;
i1 < 2;
i1++) {
274 for (
unsigned int i2 = 0;
i2 < 2;
i2++) {
275 double arinv =
rinv(seedradii.first, phi1[
i1], seedradii.second, phi2[
i2]);
298 std::pair<unsigned int, unsigned int>
tmp(
i1,
i2);
310 for (
unsigned int iSeed = 0; iSeed <
N_SEED_PROMPT; iSeed++) {
311 unsigned int nTC =
NTC_[iSeed];
312 std::vector<std::pair<unsigned int, unsigned int> >& TEs =
TE_[iSeed];
313 std::vector<std::vector<unsigned int> >& TCs =
TC_[iSeed];
317 double invnTC = nTC * (1.0 / TEs.size());
319 for (
unsigned int iTE = 0; iTE < TEs.size(); iTE++) {
320 int iTC = invnTC * iTE;
322 if (iTC >= (
int)TCs.size()) {
323 std::vector<unsigned int>
tmp;
327 TCs[iTC].push_back(iTE);
336 std::vector<std::vector<unsigned int> >& TCs =
TC_[iSeed];
338 std::pair<double, double> seedradii =
seedRadii(iSeed);
342 for (
unsigned int iTE = 0; iTE < TCs[iTC].size(); iTE++) {
343 unsigned int theTE = TCs[iTC][iTE];
344 unsigned int l1TE =
TE_[iSeed][theTE].first;
345 unsigned int l2TE =
TE_[iSeed][theTE].second;
348 for (
unsigned int i1 = 0;
i1 < 2;
i1++) {
349 for (
unsigned int i2 = 0;
i2 < 2;
i2++) {
350 double aphi =
phi(seedradii.first, phi1[
i1], seedradii.second, phi2[
i2], rproj);
364 set<string> emptyProjStandard = {
365 "TPROJ_L1L2H_L3PHIB",
"TPROJ_L1L2E_L3PHIC",
"TPROJ_L1L2K_L3PHIC",
"TPROJ_L1L2H_L3PHID",
"TPROJ_L1L2F_L5PHIA",
366 "TPROJ_L1L2G_L5PHID",
"TPROJ_L1L2A_L6PHIA",
"TPROJ_L1L2J_L6PHIB",
"TPROJ_L1L2C_L6PHIC",
"TPROJ_L1L2L_L6PHID",
367 "TPROJ_L3L4D_D1PHIB",
"TPROJ_L2L3A_D1PHIC",
"TPROJ_L3L4A_D1PHIC",
"TPROJ_L1L2G_D2PHIA",
"TPROJ_L1D1D_D2PHIA",
368 "TPROJ_L1D1E_D2PHIA",
"TPROJ_L1L2J_D2PHIB",
"TPROJ_L3L4D_D2PHIB",
"TPROJ_L1D1A_D2PHIB",
"TPROJ_L1D1F_D2PHIB",
369 "TPROJ_L1D1G_D2PHIB",
"TPROJ_L1L2C_D2PHIC",
"TPROJ_L2L3A_D2PHIC",
"TPROJ_L3L4A_D2PHIC",
"TPROJ_L1D1B_D2PHIC",
370 "TPROJ_L1D1C_D2PHIC",
"TPROJ_L1D1H_D2PHIC",
"TPROJ_L2D1A_D2PHIC",
"TPROJ_L1L2F_D2PHID",
"TPROJ_L1D1D_D2PHID",
371 "TPROJ_L1D1E_D2PHID",
"TPROJ_L1L2G_D3PHIA",
"TPROJ_L1D1D_D3PHIA",
"TPROJ_L1D1E_D3PHIA",
"TPROJ_L1L2J_D3PHIB",
372 "TPROJ_L1D1A_D3PHIB",
"TPROJ_L1D1F_D3PHIB",
"TPROJ_L1D1G_D3PHIB",
"TPROJ_L1L2C_D3PHIC",
"TPROJ_L2L3A_D3PHIC",
373 "TPROJ_L1D1B_D3PHIC",
"TPROJ_L1D1C_D3PHIC",
"TPROJ_L1D1H_D3PHIC",
"TPROJ_L2D1A_D3PHIC",
"TPROJ_L1L2F_D3PHID",
374 "TPROJ_L1D1D_D3PHID",
"TPROJ_L1D1E_D3PHID",
"TPROJ_L1L2G_D4PHIA",
"TPROJ_L1D1D_D4PHIA",
"TPROJ_L1D1E_D4PHIA",
375 "TPROJ_L1L2J_D4PHIB",
"TPROJ_L1D1G_D4PHIB",
"TPROJ_L1L2C_D4PHIC",
"TPROJ_L2L3A_D4PHIC",
"TPROJ_L1D1B_D4PHIC",
376 "TPROJ_L2D1A_D4PHIC",
"TPROJ_L1L2F_D4PHID",
"TPROJ_L1D1D_D4PHID",
"TPROJ_L1D1E_D5PHIA",
"TPROJ_L1D1G_D5PHIB",
377 "TPROJ_L1D1B_D5PHIC",
"TPROJ_L1D1D_D5PHID"};
379 set<string> emptyProjCombined = {
380 "TPROJ_L1L2J_L6PHIB",
"TPROJ_L1L2C_L6PHIC",
"TPROJ_L1L2G_D1PHIA",
"TPROJ_L1L2J_D1PHIB",
"TPROJ_L2L3D_D1PHIB",
381 "TPROJ_L3L4D_D1PHIB",
"TPROJ_L1L2C_D1PHIC",
"TPROJ_L2L3A_D1PHIC",
"TPROJ_L3L4A_D1PHIC",
"TPROJ_L1L2F_D1PHID",
382 "TPROJ_L1L2G_D2PHIA",
"TPROJ_L1D1E_D2PHIA",
"TPROJ_L1L2J_D2PHIB",
"TPROJ_L2L3D_D2PHIB",
"TPROJ_L3L4D_D2PHIB",
383 "TPROJ_L1D1G_D2PHIB",
"TPROJ_L1L2C_D2PHIC",
"TPROJ_L2L3A_D2PHIC",
"TPROJ_L3L4A_D2PHIC",
"TPROJ_L1D1B_D2PHIC",
384 "TPROJ_L2D1A_D2PHIC",
"TPROJ_L1L2F_D2PHID",
"TPROJ_L1D1D_D2PHID",
"TPROJ_L1L2G_D3PHIA",
"TPROJ_L1D1E_D3PHIA",
385 "TPROJ_L1L2J_D3PHIB",
"TPROJ_L2L3D_D3PHIB",
"TPROJ_L1D1G_D3PHIB",
"TPROJ_L1L2C_D3PHIC",
"TPROJ_L2L3A_D3PHIC",
386 "TPROJ_L1D1B_D3PHIC",
"TPROJ_L2D1A_D3PHIC",
"TPROJ_L1L2F_D3PHID",
"TPROJ_L1D1D_D3PHID",
"TPROJ_L1L2G_D4PHIA",
387 "TPROJ_L1D1E_D4PHIA",
"TPROJ_L1L2J_D4PHIB",
"TPROJ_L2L3D_D4PHIB",
"TPROJ_L1D1G_D4PHIB",
"TPROJ_L1L2C_D4PHIC",
388 "TPROJ_L2L3A_D4PHIC",
"TPROJ_L1D1B_D4PHIC",
"TPROJ_L2D1A_D4PHIC",
"TPROJ_L1L2F_D4PHID",
"TPROJ_L1D1D_D4PHID",
389 "TPROJ_L1D1E_D5PHIA",
"TPROJ_L1D1G_D5PHIB",
"TPROJ_L1D1B_D5PHIC",
"TPROJ_L1D1D_D5PHID"};
392 std::vector<std::vector<unsigned int> >& TCs =
TC_[
iseed];
394 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
397 for (
unsigned int iReg = 0; iReg <
NRegions_[ilayer]; iReg++) {
398 for (
unsigned int iTC = 0; iTC < TCs.size(); iTC++) {
403 if (phiRange.first <
allStubs_[ilayer][iReg].second && phiRange.second >
allStubs_[ilayer][iReg].first) {
404 std::pair<unsigned int, unsigned int>
tmp(
iseed, iTC);
407 if (emptyProjCombined.find(projName) == emptyProjCombined.end()) {
411 if (emptyProjStandard.find(projName) == emptyProjStandard.end()) {
426 double rhoinv =
rinv(r1, phi1,
r2, phi2);
430 return phi1 + asin(0.5 * r * rhoinv) - asin(0.5 * r1 * rhoinv);
436 double deltaphi = phi1 - phi2;
437 return 2 *
sin(deltaphi) /
sqrt(
r2 *
r2 + r1 * r1 - 2 * r1 *
r2 *
cos(deltaphi));
441 static std::string name[8] = {
"L1L2",
"L2L3",
"L3L4",
"L5L6",
"D1D2",
"D3D4",
"L1D1",
"L2D1"};
448 static std::string num[32] = {
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
449 "12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
450 "23",
"24",
"25",
"26",
"27",
"28",
"29",
"30",
"31",
"32"};
456 static std::string name[12] = {
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L"};
465 static std::string nameOverlap[8] = {
"X",
"Y",
"Z",
"W",
"Q",
"R",
"S",
"T"};
467 static std::string nameL2L3[4] = {
"I",
"J",
"K",
"L"};
471 return nameL2L3[iReg];
475 return nameOverlap[iReg];
490 return ilayer < 6 ? (
"L" +
numStr(ilayer)) : (
"D" +
numStr(ilayer - 6));
496 unsigned int ireg)
const {
514 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
515 for (
unsigned int ireg = 0; ireg <
projections_[ilayer].size(); ireg++) {
516 for (
unsigned int imem = 0; imem <
projections_[ilayer][ireg].size(); imem++) {
517 unsigned int iSeed =
projections_[ilayer][ireg][imem].first;
518 unsigned int iTC =
projections_[ilayer][ireg][imem].second;
520 memories <<
"TrackletProjections: " +
TPROJName(iSeed, iTC, ilayer, ireg) +
" [54]" << std::endl;
522 os <<
TPROJName(iSeed, iTC, ilayer, ireg) <<
" input=> " <<
TCName(iSeed, iTC) <<
".projout" 536 unsigned int iseed)
const {
550 unsigned int iseed)
const {
561 unsigned int iseed)
const {
572 unsigned int iseed)
const {
589 unsigned int projlayer,
590 unsigned int projreg)
const {
604 unsigned int count)
const {
615 unsigned int count)
const {
630 for (
unsigned int iSeed = 0; iSeed <
N_SEED_PROMPT; iSeed++) {
631 for (
unsigned int iTC = 0; iTC <
TC_[iSeed].size(); iTC++) {
632 for (
unsigned int iTE = 0; iTE <
TC_[iSeed][iTC].size(); iTE++) {
633 unsigned int theTE =
TC_[iSeed][iTC][iTE];
635 unsigned int TE1 =
TE_[iSeed][theTE].first;
636 unsigned int TE2 =
TE_[iSeed][theTE].second;
641 memories <<
"StubPairs: " 649 <<
".stubpairout output=> " <<
TCName(iSeed, iTC) <<
".stubpairin" << std::endl;
662 vector<string> stubTriplets[
N_SEED];
678 for (
unsigned int ireg1 = 0; ireg1 < nallstub1; ireg1++) {
679 for (
unsigned int ireg2 = 0; ireg2 < nallstub2; ireg2++) {
680 for (
unsigned int ireg3 = 0; ireg3 < nallstub3; ireg3++) {
682 memories <<
"StubTriplets: " <<
STName(layerdisk1, ireg1, layerdisk2, ireg2, layerdisk3, ireg3, iSeed,
count)
683 <<
" [18]" << std::endl;
684 stubTriplets[iSeed].push_back(
STName(layerdisk1, ireg1, layerdisk2, ireg2, layerdisk3, ireg3, iSeed,
count));
689 for (
unsigned int ireg1 = 0; ireg1 < nallstub1; ireg1++) {
690 for (
unsigned int ivm1 = 0; ivm1 < nvm1; ivm1++) {
691 for (
unsigned int ireg2 = 0; ireg2 < nallstub2; ireg2++) {
692 for (
unsigned int ivm2 = 0; ivm2 < nvm2; ivm2++) {
695 modules <<
"TrackletEngineDisplaced: " 696 <<
TEDName(layerdisk1, ireg1, ireg1 * nvm1 + ivm1, layerdisk2, ireg2, ireg2 * nvm2 + ivm2, iSeed)
699 for (
unsigned int ireg3 = 0; ireg3 < nallstub3; ireg3++) {
700 for (
unsigned int ivm3 = 0; ivm3 < nvm3; ivm3++) {
703 memories <<
"StubPairsDisplaced: " 714 <<
" [12]" << std::endl;
716 modules <<
"TripletEngine: " <<
TREName(layerdisk1, ireg1, layerdisk2, ireg2, iSeed,
count)
730 <<
TEDName(layerdisk1, ireg1, ireg1 * nvm1 + ivm1, layerdisk2, ireg2, ireg2 * nvm2 + ivm2, iSeed)
731 <<
".stubpairout output=> " <<
TREName(layerdisk1, ireg1, layerdisk2, ireg2, iSeed,
count)
734 <<
"in" << std::endl;
742 unsigned int nTC = 10;
743 for (
unsigned int itc = 0; itc < nTC; itc++) {
744 for (
int iproj = 0; iproj < 4; iproj++) {
748 for (
unsigned int ireg = 0; ireg < nallstub; ireg++) {
749 memories <<
"TrackletProjections: " <<
TPROJName(layerdisk1, layerdisk2, layerdisk3, itc, ilay - 1, ireg)
750 <<
" [54]" << std::endl;
757 for (
unsigned int ireg = 0; ireg < nallstub; ireg++) {
758 memories <<
"TrackletProjections: " <<
TPROJName(layerdisk1, layerdisk2, layerdisk3, itc, idisk + 5, ireg)
759 <<
" [54]" << std::endl;
761 wires <<
TPROJName(layerdisk1, layerdisk2, layerdisk3, itc, idisk + 5, ireg) <<
" input=> " 762 <<
TCDName(layerdisk1, layerdisk2, layerdisk3, itc) <<
".projout" <<
LayerName(idisk + 1) <<
"PHI" 763 <<
iTCStr(ireg) <<
" output=> " 764 <<
"PR_" <<
LayerName(idisk + 1) <<
"PHI" <<
iTCStr(ireg) <<
".projin" << std::endl;
769 memories <<
"TrackletParameters: " <<
TParName(layerdisk1, layerdisk2, layerdisk3, itc) <<
" [56]" << std::endl;
771 modules <<
"TrackletCalculatorDisplaced: " <<
TCDName(layerdisk1, layerdisk2, layerdisk3, itc) << std::endl;
774 unsigned int nST = stubTriplets[iSeed].size();
775 for (
unsigned int iST = 0; iST < nST; iST++) {
776 unsigned int iTC = (iST * nTC) / nST;
778 string stname = stubTriplets[iSeed][iST];
779 string trename =
"TRE_" + stname.substr(3, 6) +
"_";
780 unsigned int stlen = stname.size();
781 if (stname[stlen - 2] ==
'_')
782 trename += stname.substr(stlen - 1, 1);
783 if (stname[stlen - 3] ==
'_')
784 trename += stname.substr(stlen - 2, 2);
785 wires << stname <<
" input=> " << trename <<
".stubtripout output=> " 786 <<
TCDName(layerdisk1, layerdisk2, layerdisk3, iTC) <<
".stubtriplet" << ((iST * nTC) % nST) <<
"in" 790 modules <<
"FitTrack: " <<
FTName(layerdisk1, layerdisk2, layerdisk3) << std::endl;
802 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
803 for (
unsigned int iReg = 0; iReg <
NRegions_[ilayer]; iReg++) {
804 memories <<
"AllProj: AP_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
" [56]" << std::endl;
808 <<
iTCStr(iReg) <<
".allprojout output=> MC_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
".allprojin" 824 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
825 for (
unsigned int iME = 0; iME <
NVMME_[ilayer] *
NRegions_[ilayer]; iME++) {
826 memories <<
"CandidateMatch: CM_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iME /
NVMME_[ilayer]) << iME + 1
827 <<
" [12]" << std::endl;
831 os <<
"CM_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iME /
NVMME_[ilayer]) << iME + 1 <<
" input=> ME_" 848 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
849 for (
unsigned int iME = 0; iME <
NVMME_[ilayer] *
NRegions_[ilayer]; iME++) {
850 memories <<
"VMProjections: VMPROJ_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iME /
NVMME_[ilayer]) << iME + 1
851 <<
" [13]" << std::endl;
853 os <<
"VMPROJ_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iME /
NVMME_[ilayer]) << iME + 1 <<
" input=> PR_" 856 <<
iTCStr(iME /
NVMME_[ilayer]) << iME + 1 <<
".vmprojin" << std::endl;
869 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
870 for (
unsigned int iReg = 0; iReg <
NRegions_[ilayer]; iReg++) {
872 for (
unsigned int iSeed = 0; iSeed <
N_SEED_PROMPT; iSeed++) {
876 <<
" [36]" << std::endl;
879 <<
".fullmatch" <<
matchport_[iSeed][ilayer] <<
"in" << iReg + 1 << std::endl;
884 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
885 for (
unsigned int iReg = 0; iReg <
NRegions_[ilayer]; iReg++) {
887 for (
unsigned int iSeed = 0; iSeed <
N_SEED_PROMPT; iSeed++) {
891 <<
" [36]" << std::endl;
894 <<
".fullmatch" <<
matchport_[iSeed][ilayer] <<
"in" << iReg + 1 << std::endl;
911 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
912 for (
unsigned int iReg = 0; iReg <
NRegions_[ilayer]; iReg++) {
913 memories <<
"AllStubs: AS_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
"n1" 914 <<
" [42]" << std::endl;
921 <<
" input=> VMR_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
".allstubout output=> MP_" 922 <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
".allstubin" << std::endl;
927 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
928 for (
int iReg = 0; iReg < (
int)
NRegions_[ilayer]; iReg++) {
929 for (
unsigned int iSeed = 0; iSeed <
N_SEED_PROMPT; iSeed++) {
933 if (ilayer != l1 && ilayer != l2)
936 bool inner = ilayer == l1;
938 for (
unsigned int iTC = 0; iTC <
TC_[iSeed].size(); iTC++) {
941 int iTCReg = iTC / nTCReg;
943 int jTCReg = iTC % nTCReg;
954 int min = iTCReg *
ratio - 1 + jTCReg;
955 int max = (iTCReg + 1) *
ratio - (nTCReg - jTCReg - 1);
956 if ((
int)iReg < min || (int)iReg >
max)
1013 }
else if (iSeed > 5) {
1020 memories <<
"AllInnerStubs: ";
1022 memories <<
"AllStubs: ";
1024 memories <<
"AS_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
ext <<
" [42]" << std::endl;
1026 <<
"PHI" <<
iTCStr(iReg) <<
".all" << (
inner ?
"inner" :
"") <<
"stubout output=> TP_" <<
iSeedStr(iSeed)
1029 os <<
".innerallstubin" << std::endl;
1031 os <<
".outerallstubin" << std::endl;
1040 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
1041 for (
unsigned int iReg = 0; iReg <
NRegions_[ilayer]; iReg++) {
1042 memories <<
"AllStubs: AS_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
"n1" 1043 <<
" [42]" << std::endl;
1050 <<
" input=> VMR_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
".allstubout output=> MC_" 1051 <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
".allstubin" << std::endl;
1056 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
1057 for (
unsigned int iReg = 0; iReg <
NRegions_[ilayer]; iReg++) {
1058 unsigned int nmem = 1;
1060 for (
unsigned int iSeed = 0; iSeed <
N_SEED_PROMPT; iSeed++) {
1064 if (ilayer != l1 && ilayer != l2)
1067 for (
unsigned int iTC = 0; iTC <
TC_[iSeed].size(); iTC++) {
1070 for (
unsigned int iTE = 0; iTE <
TC_[iSeed][iTC].size(); iTE++) {
1071 unsigned int theTE =
TC_[iSeed][iTC][iTE];
1073 unsigned int TE1 =
TE_[iSeed][theTE].first;
1074 unsigned int TE2 =
TE_[iSeed][theTE].second;
1076 if (l1 == ilayer && iReg == TE1 /
NVMTE_[iSeed].
first)
1078 if (l2 == ilayer && iReg == TE2 /
NVMTE_[iSeed].
second)
1084 memories <<
"AllStubs: AS_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
"n" << nmem <<
" [42]" 1086 os <<
"AS_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
"n" << nmem <<
" input=> VMR_" 1090 os <<
".innerallstubin" << std::endl;
1092 os <<
".outerallstubin" << std::endl;
1111 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
1112 for (
unsigned int iReg = 0; iReg <
NRegions_[ilayer]; iReg++) {
1113 memories <<
"VMStubsME: VMSME_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
"n1 [18]" << std::endl;
1116 <<
" output=> MP_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
".vmstubin" << std::endl;
1121 for (
unsigned int iSeed = 0; iSeed <
N_SEED_PROMPT; iSeed++) {
1126 unsigned int ilayer =
seedLayers(iSeed).second;
1130 unsigned int nTCReg =
TC_[iSeed].size() /
NRegions_[l2];
1132 for (
unsigned int iReg = 0; iReg <
NRegions_[l2]; iReg++) {
1133 unsigned int nmem = 0;
1139 for (
unsigned iTC = 0; iTC < nTCReg; iTC++) {
1141 memories <<
"VMStubsTE: VMSTE_" <<
LayerName(ilayer) <<
"PHI" <<
iRegStr(iReg, iSeed) <<
"n" << nmem
1142 <<
" [18]" << std::endl;
1143 os <<
"VMSTE_" <<
LayerName(ilayer) <<
"PHI" <<
iRegStr(iReg, iSeed) <<
"n" << nmem <<
" input=> VMR_" 1144 <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
".vmstubout_seed_" << iSeed <<
" output=> TP_" 1152 for (
unsigned int ilayer = 0; ilayer <
N_LAYER +
N_DISK; ilayer++) {
1153 for (
unsigned int iVMME = 0; iVMME <
NVMME_[ilayer] *
NRegions_[ilayer]; iVMME++) {
1154 unsigned int iReg = iVMME /
NVMME_[ilayer];
1155 memories <<
"VMStubsME: VMSME_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) << iVMME + 1 <<
"n1 [18]" 1157 os <<
"VMSME_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) << iVMME + 1 <<
"n1" 1158 <<
" input=> VMR_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
".vmstuboutMEPHI" <<
iTCStr(iReg)
1159 << iVMME + 1 <<
" output=> ME_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) << iVMME + 1 <<
".vmstubin" 1166 for (
unsigned int iSeed = 0; iSeed <
N_SEED_PROMPT; iSeed++) {
1167 for (
unsigned int innerouterseed = 0; innerouterseed < 2; innerouterseed++) {
1172 unsigned int NVMTE1 =
NVMTE_[iSeed].first;
1173 unsigned int NVMTE2 =
NVMTE_[iSeed].second;
1175 unsigned int ilayer = l1;
1176 unsigned int NVMTE = NVMTE1;
1177 if (innerouterseed == 1) {
1182 for (
unsigned int iVMTE = 0; iVMTE < NVMTE *
NRegions_[ilayer]; iVMTE++) {
1183 unsigned int iReg = iVMTE / NVMTE;
1185 unsigned int nmem = 0;
1191 for (
unsigned int iTE = 0; iTE <
TE_[iSeed].size(); iTE++) {
1192 unsigned int TE1 =
TE_[iSeed][iTE].first;
1193 unsigned int TE2 =
TE_[iSeed][iTE].second;
1197 if (innerouterseed == 0 && iVMTE == TE1)
1199 if (innerouterseed == 1 && iVMTE == TE2)
1205 string inorout =
"I";
1206 if (innerouterseed == 1)
1210 memories <<
"VMStubsTE: VMSTE_" <<
LayerName(ilayer) <<
"PHI" <<
iRegStr(iReg, iSeed) << iVMTE + 1 <<
"n" 1211 << nmem <<
" [18]" << std::endl;
1212 os <<
"VMSTE_" <<
LayerName(ilayer) <<
"PHI" <<
iRegStr(iReg, iSeed) << iVMTE + 1 <<
"n" << nmem
1213 <<
" input=> VMR_" <<
LayerName(ilayer) <<
"PHI" <<
iTCStr(iReg) <<
".vmstuboutTE" << inorout <<
"PHI" 1214 <<
iRegStr(iReg, iSeed) << iVMTE + 1 <<
" output=> TE_" <<
LayerName(l1) <<
"PHI" 1215 <<
iRegStr(TE1 / NVMTE1, iSeed) << TE1 + 1 <<
"_" <<
LayerName(l2) <<
"PHI" 1216 <<
iRegStr(TE2 / NVMTE2, iSeed) << TE2 + 1;
1217 if (innerouterseed == 0) {
1218 os <<
".innervmstubin" << std::endl;
1220 os <<
".outervmstubin" << std::endl;
1234 for (
unsigned int iSeed = 0; iSeed <
N_SEED_PROMPT; iSeed++) {
1235 for (
unsigned int iTP = 0; iTP <
TC_[iSeed].size(); iTP++) {
1236 memories <<
"TrackletParameters: TPAR_" <<
iSeedStr(iSeed) <<
iTCStr(iTP) <<
" [56]" << std::endl;
1239 <<
".trackpar output=> FT_" <<
iSeedStr(iSeed) <<
".tparin" << std::endl;
1243 for (
unsigned int iSeed = 0; iSeed <
N_SEED_PROMPT; iSeed++) {
1244 for (
unsigned int iTC = 0; iTC <
TC_[iSeed].size(); iTC++) {
1245 memories <<
"TrackletParameters: TPAR_" <<
iSeedStr(iSeed) <<
iTCStr(iTC) <<
" [56]" << std::endl;
1248 <<
".trackpar output=> FT_" <<
iSeedStr(iSeed) <<
".tparin" << std::endl;
1255 for (
unsigned int iSeed = 0; iSeed <
N_SEED_PROMPT; iSeed++) {
1256 memories <<
"TrackFit: TF_" <<
iSeedStr(iSeed) <<
" [126]" << std::endl;
1258 os <<
"TF_" <<
iSeedStr(iSeed) <<
" input=> FT_" <<
iSeedStr(iSeed) <<
".trackout output=> PD.trackin" << std::endl;
1263 modules <<
"PurgeDuplicate: PD" << std::endl;
1265 for (
unsigned int iSeed = 0; iSeed <
N_SEED_PROMPT; iSeed++) {
1266 memories <<
"CleanTrack: CT_" <<
iSeedStr(iSeed) <<
" [126]" << std::endl;
1267 os <<
"CT_" <<
iSeedStr(iSeed) <<
" input=> PD.trackout output=>" << std::endl;
1279 string dtcname =
info.name;
1280 if (olddtc != dtcname) {
1282 modules <<
"InputRouter: IR_" << dtcname <<
"_A" << std::endl;
1283 modules <<
"InputRouter: IR_" << dtcname <<
"_B" << std::endl;
1284 memories <<
"DTCLink: DL_" << dtcname <<
"_A [36]" << std::endl;
1285 memories <<
"DTCLink: DL_" << dtcname <<
"_B [36]" << std::endl;
1286 os <<
"DL_" << dtcname <<
"_A" 1287 <<
" input=> output=> IR_" << dtcname <<
"_A.stubin" << std::endl;
1288 os <<
"DL_" << dtcname <<
"_B" 1289 <<
" input=> output=> IR_" << dtcname <<
"_B.stubin" << std::endl;
1295 string dtcname =
info.name;
1296 int layerdisk =
info.layer;
1298 for (
unsigned int iReg = 0; iReg <
NRegions_[layerdisk]; iReg++) {
1305 memories <<
"InputLink: IL_" <<
LayerName(layerdisk) <<
"PHI" <<
iTCStr(iReg) <<
"_" << dtcname <<
"_A" 1306 <<
" [36]" << std::endl;
1307 os <<
"IL_" <<
LayerName(layerdisk) <<
"PHI" <<
iTCStr(iReg) <<
"_" << dtcname <<
"_A" 1308 <<
" input=> IR_" << dtcname <<
"_A.stubout output=> VMR_" <<
LayerName(layerdisk) <<
"PHI" <<
iTCStr(iReg)
1309 <<
".stubin" << std::endl;
1312 memories <<
"InputLink: IL_" <<
LayerName(layerdisk) <<
"PHI" <<
iTCStr(iReg) <<
"_" << dtcname <<
"_B" 1313 <<
" [36]" << std::endl;
1314 os <<
"IL_" <<
LayerName(layerdisk) <<
"PHI" <<
iTCStr(iReg) <<
"_" << dtcname <<
"_B" 1315 <<
" input=> IR_" << dtcname <<
"_B.stubout output=> VMR_" <<
LayerName(layerdisk) <<
"PHI" <<
iTCStr(iReg)
1316 <<
".stubin" << std::endl;
void writeProjectionMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > projections_[N_LAYER+N_DISK]
unsigned int NTC(int seed) const
std::list< DTCinfo > vecDTCinfo_
unsigned int seedlayers(int inner, int seed) const
static std::string numStr(unsigned int i)
constexpr unsigned int N_SEED
Class to process and provide run-time constants used by Track Trigger emulators.
void writeAll(std::ostream &wires, std::ostream &memories, std::ostream &modules)
double dphisectorHG() const
Sin< T >::type sin(const T &t)
static std::string LayerName(unsigned int ilayer)
std::string slotToDTCname(unsigned int slot) const
void writeASMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
void writeILMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
void writeFMMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
std::vector< std::pair< double, double > > VMStubsME_[N_LAYER+N_DISK]
std::vector< std::pair< unsigned int, unsigned int > > TE_[N_SEED_PROMPT]
std::string TREName(unsigned int l1, unsigned int ireg1, unsigned int l2, unsigned int ireg2, unsigned int iseed, unsigned int count) const
std::string iRegStr(unsigned int iReg, unsigned int iSeed) const
std::string FTName(unsigned int l1, unsigned int l2, unsigned int l3) const
void setDTCphirange(const tt::Setup *setup=nullptr)
std::string TEDName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, unsigned int l2, unsigned int ireg2, unsigned int ivm2, unsigned int iseed) const
U second(std::pair< T, U > const &p)
unsigned int projlayers(unsigned int iSeed, unsigned int i) const
std::string PRName(unsigned int ilayer, unsigned int ireg) const
std::string tablePath() const
unsigned int NTC_[N_SEED_PROMPT]
double rmean(unsigned int iLayer) const
std::string iSeedStr(unsigned int iSeed) const
void writeTPARMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
std::string iTCStr(unsigned int iTC) const
Cos< T >::type cos(const T &t)
std::string TCName(unsigned int iSeed, unsigned int iTC) const
std::vector< std::vector< unsigned int > > TC_[N_SEED_PROMPT]
Abs< T >::type abs(const T &t)
unsigned int projdisks(unsigned int iSeed, unsigned int i) const
const Settings & settings_
void writeSPMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
double zmean(unsigned int iDisk) const
std::pair< std::vector< std::pair< double, double > >, std::vector< std::pair< double, double > > > VMStubsTE_[N_SEED_PROMPT]
unsigned int nvmte(unsigned int inner, unsigned int iSeed) const
std::string STName(unsigned int l1, unsigned int ireg1, unsigned int l2, unsigned int ireg2, unsigned int l3, unsigned int ireg3, unsigned int iseed, unsigned int count) const
unsigned int nallstubs(unsigned int layerdisk) const
constexpr unsigned int N_SECTOR
unsigned int NVMME_[N_LAYER+N_DISK]
double rinv(double r1, double phi1, double r2, double phi2)
std::pair< double, double > seedRadii(unsigned int iseed)
void writeCMMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
unsigned int NRegions_[N_LAYER+N_DISK]
bool validTEPair(unsigned int iseed, unsigned int iTE1, unsigned int iTE2)
void writeVMPROJMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
void writeTFMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
unsigned int nvmme(unsigned int layerdisk) const
ALPAKA_FN_ACC int sm(int ieta, int iphi)
std::vector< std::pair< double, double > > allStubs_[N_LAYER+N_DISK]
std::string TCDName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc) const
void writeCTMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
std::pair< unsigned int, unsigned int > seedLayers(unsigned int iSeed)
int matchport_[N_SEED_PROMPT][N_LAYER+N_DISK]
std::string TPROJName(unsigned int iSeed, unsigned int iTC, unsigned int ilayer, unsigned int ireg) const
std::string TEName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, unsigned int l2, unsigned int ireg2, unsigned int ivm2, unsigned int iseed) const
std::pair< double, double > seedPhiRange(double rproj, unsigned int iSeed, unsigned int iTC)
std::string SPDName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, unsigned int l2, unsigned int ireg2, unsigned int ivm2, unsigned int l3, unsigned int ireg3, unsigned int ivm3, unsigned int iseed) const
std::string TParName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc) const
void writeAPMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
void writeSPDMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
void writeVMSMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
double phi(double r1, double phi1, double r2, double phi2, double r)
std::ofstream openfile(const std::string &dir, const std::string &fname, const char *file, int line)
constexpr unsigned int N_SEED_PROMPT
std::string SPName(unsigned int l1, unsigned int ireg1, unsigned int ivm1, unsigned int l2, unsigned int ireg2, unsigned int ivm2, unsigned int iseed) const
std::pair< unsigned int, unsigned int > NVMTE_[N_SEED_PROMPT]