CMS 3D CMS Logo

TrackletConfigBuilder.cc
Go to the documentation of this file.
1 #include <vector>
2 #include <utility>
3 #include <set>
4 #include <cmath>
5 #include <iostream>
6 #include <fstream>
7 #include <sstream>
8 #include <cstdlib>
9 #include <cassert>
10 #include <mutex>
11 
14 #ifdef CMSSW_GIT_HASH
17 #endif
18 
19 using namespace std;
20 using namespace trklet;
21 
22 TrackletConfigBuilder::TrackletConfigBuilder(const Settings& settings, const tt::Setup* setup) : settings_(settings) {
24  rcrit_ = settings.rcrit();
25 
26  combinedmodules_ = settings.combined();
27 
28  extended_ = settings.extended();
29 
30  rinvmax_ = settings.rinvmax();
31 
32  rmaxdisk_ = settings.rmaxdisk();
33  zlength_ = settings.zlength();
34 
35  for (int i = 0; i < N_LAYER; i++) {
36  rmean_[i] = settings.rmean(i);
37  }
38 
39  for (int i = 0; i < N_DISK; i++) {
40  zmean_[i] = settings.zmean(i);
41  }
42 
43  dphisectorHG_ = settings.dphisectorHG();
44 
45  for (int layerdisk = 0; layerdisk < N_LAYER + N_DISK; layerdisk++) {
46  NRegions_[layerdisk] = settings.nallstubs(layerdisk);
47  NVMME_[layerdisk] = settings.nvmme(layerdisk);
48  }
49 
50  for (unsigned int iseed = 0; iseed < N_SEED_PROMPT; iseed++) {
51  NVMTE_[iseed] = std::pair<unsigned int, unsigned int>(settings.nvmte(0, iseed), settings.nvmte(1, iseed));
52  NTC_[iseed] = settings.NTC(iseed);
53  }
54 
55  initGeom();
56 
57  buildTE();
58 
59  buildTC();
60 
62 
64 
65  if (settings_.writeConfig()) {
66  static std::once_flag runOnce; // Only one thread should call this.
67  std::call_once(runOnce, &TrackletConfigBuilder::writeDTCphirange, this);
68  }
69 }
70 
71 //--- Calculate phi range of modules read by each DTC.
72 
73 #ifdef CMSSW_GIT_HASH
74 
76  list<DTCinfo> vecDTCinfo_unsorted;
77 
78  // Loop over DTCs in this tracker nonant.
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;
83 
84  // Loop over all tracker nonants, taking worst case not all identical.
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);
88  for (const tt::SensorModule* sm : dtcModules) {
89  // Convert layer number to Hybrid convention.
90  int layer = sm->layerId(); // Barrel = 1-6, Endcap = 11-15;
91  if (sm->barrel()) {
92  layer--; // Barrel 0-5
93  } else {
94  const int endcapOffsetHybrid = 5;
95  layer -= endcapOffsetHybrid; // Layer 6-19
96  }
97  // Inner radius of module.
98  float r = sm->r() - 0.5 * sm->numColumns() * sm->pitchCol() * fabs(sm->sinTilt());
99  // phi with respect to tracker nonant centre.
100  float phiMin = sm->phi() - 0.5 * sm->numRows() * sm->pitchRow() / r;
101  float phiMax = sm->phi() + 0.5 * sm->numRows() * sm->pitchRow() / r;
102  // Hybrid measures phi w.r.t. lower edge of tracker nonant.
103  const float phiOffsetHybrid = 0.5 * dphisectorHG_;
104  phiMin += phiOffsetHybrid;
105  phiMax += phiOffsetHybrid;
106  if (dtcPhiRange.find(layer) == dtcPhiRange.end()) {
107  dtcPhiRange[layer] = {phiMin, phiMax};
108  } else {
109  dtcPhiRange.at(layer).first = std::min(phiMin, dtcPhiRange.at(layer).first);
110  dtcPhiRange.at(layer).second = std::max(phiMax, dtcPhiRange.at(layer).second);
111  }
112  }
113  }
114  for (const auto& p : dtcPhiRange) {
115  const unsigned int numSlots = setup->numATCASlots();
116  std::string dtcName = settings_.slotToDTCname(dtcId % numSlots);
117  if (dtcId >= numSlots)
118  dtcName = "neg" + dtcName;
119  DTCinfo info;
120  info.name = dtcName;
121  info.layer = p.first;
122  info.phimin = p.second.first;
123  info.phimax = p.second.second;
124  vecDTCinfo_unsorted.push_back(info);
125  }
126  }
127 
128  // Put DTCinfo vector in traditional order (PS first). (Needed?)
129  for (const DTCinfo& info : vecDTCinfo_unsorted) {
130  string dtcname = info.name;
131  if (dtcname.find("PS") != std::string::npos) {
132  vecDTCinfo_.push_back(info);
133  }
134  }
135  for (const DTCinfo& info : vecDTCinfo_unsorted) {
136  string dtcname = info.name;
137  if (dtcname.find("PS") == std::string::npos) {
138  vecDTCinfo_.push_back(info);
139  }
140  }
141 }
142 
143 //--- Write DTC phi ranges to file to support stand-alone emulation.
144 //--- (Only needed to support stand-alone emulation)
145 
146 void TrackletConfigBuilder::writeDTCphirange() const {
147  bool first = true;
148  for (const DTCinfo& info : vecDTCinfo_) {
149  string dirName = settings_.tablePath();
150  string fileName = dirName + "../dtcphirange.dat";
151  std::ofstream out;
152  openfile(out, first, dirName, fileName, __FILE__, __LINE__);
153  if (first) {
154  out << "// layer & phi ranges of modules read by each DTC" << endl;
155  out << "// (Used by stand-alone emulation)" << endl;
156  }
157  out << info.name << " " << info.layer << " " << info.phimin << " " << info.phimax << endl;
158  out.close();
159  first = false;
160  }
161 }
162 
163 #else
164 
165 //--- Set DTC phi ranges from .txt file (stand-alone operation only)
166 
168  // This file previously written by writeDTCphirange().
169  const string fname = "../data/dtcphirange.txt";
170  if (vecDTCinfo_.empty()) { // Only run once per thread.
171  std::ifstream str_dtc;
172  str_dtc.open(fname);
173  assert(str_dtc.good());
174  string line;
175  while (ifstream, getline(line)) {
176  std::istringstream iss(line);
177  DTCinfo info;
178  iss >> info.name >> info.layer >> info.phimin >> info.phimax;
179  vecDTCinfo_.push_back(info);
180  }
181  str_dtc.close();
182  }
183 }
184 
185 #endif
186 
187 //--- Helper fcn. to get the layers/disks for a seed
188 
189 std::pair<unsigned int, unsigned int> TrackletConfigBuilder::seedLayers(unsigned int iSeed) {
190  return std::pair<unsigned int, unsigned int>(settings_.seedlayers(0, iSeed), settings_.seedlayers(1, iSeed));
191 }
192 
193 //--- Method to initialize the regions and VM in each layer
194 
196  for (unsigned int ilayer = 0; ilayer < N_LAYER + N_DISK; ilayer++) {
197  double dphi = dphisectorHG_ / NRegions_[ilayer];
198  for (unsigned int iReg = 0; iReg < NRegions_[ilayer]; iReg++) {
199  std::vector<std::pair<unsigned int, unsigned int> > emptyVec;
200  projections_[ilayer].push_back(emptyVec);
201  // FIX: sector doesn't have hourglass shape
202  double phimin = dphi * iReg;
203  double phimax = phimin + dphi;
204  std::pair<double, double> tmp(phimin, phimax);
205  allStubs_[ilayer].push_back(tmp);
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);
211  VMStubsME_[ilayer].push_back(tmp);
212  }
213  }
214  }
215  for (unsigned int iseed = 0; iseed < N_SEED_PROMPT; iseed++) {
216  unsigned int l1 = seedLayers(iseed).first;
217  unsigned int l2 = seedLayers(iseed).second;
218  unsigned int nVM1 = NVMTE_[iseed].first;
219  unsigned int nVM2 = NVMTE_[iseed].second;
220  double dphiVM = dphisectorHG_ / (nVM1 * NRegions_[l1]);
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);
225  VMStubsTE_[iseed].first.push_back(tmp);
226  }
227  dphiVM = dphisectorHG_ / (nVM2 * NRegions_[l2]);
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);
232  VMStubsTE_[iseed].second.push_back(tmp);
233  }
234  }
235 }
236 
237 //--- Helper fcn to get the radii of the two layers in a seed
238 
239 std::pair<double, double> TrackletConfigBuilder::seedRadii(unsigned int iseed) {
240  std::pair<unsigned int, unsigned int> seedlayers = seedLayers(iseed);
241 
242  unsigned int l1 = seedlayers.first;
243  unsigned int l2 = seedlayers.second;
244 
245  double r1, r2;
246 
247  if (iseed < 4) { //barrel seeding
248  r1 = rmean_[l1];
249  r2 = rmean_[l2];
250  } else if (iseed < 6) { //disk seeding
251  r1 = rmean_[0] + 40.0; //FIX: Somewhat of a hack - but allows finding all the regions
252  //when projecting to L1
253  r2 = r1 * zmean_[l2 - 6] / zmean_[l1 - 6];
254  } else { //overlap seeding
255  r1 = rmean_[l1];
256  r2 = r1 * zmean_[l2 - 6] / zlength_;
257  }
258 
259  return std::pair<double, double>(r1, r2);
260 }
261 
262 //--- Helper function to determine if a pair of VM memories form valid TE
263 
264 bool TrackletConfigBuilder::validTEPair(unsigned int iseed, unsigned int iTE1, unsigned int iTE2) {
265  double rinvmin = 999.9;
266  double rinvmax = -999.9;
267 
268  double phi1[2] = {VMStubsTE_[iseed].first[iTE1].first, VMStubsTE_[iseed].first[iTE1].second};
269  double phi2[2] = {VMStubsTE_[iseed].second[iTE2].first, VMStubsTE_[iseed].second[iTE2].second};
270 
271  std::pair<double, double> seedradii = seedRadii(iseed);
272 
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]);
276  if (arinv < rinvmin)
277  rinvmin = arinv;
278  if (arinv > rinvmax)
279  rinvmax = arinv;
280  }
281  }
282 
283  if (rinvmin > rinvmax_)
284  return false;
285  if (rinvmax < -rinvmax_)
286  return false;
287 
288  return true;
289 }
290 
291 //--- Builds the list of TE for each seeding combination
292 
294  for (unsigned int iseed = 0; iseed < N_SEED_PROMPT; iseed++) {
295  for (unsigned int i1 = 0; i1 < VMStubsTE_[iseed].first.size(); i1++) {
296  for (unsigned int i2 = 0; i2 < VMStubsTE_[iseed].second.size(); i2++) {
297  if (validTEPair(iseed, i1, i2)) {
298  std::pair<unsigned int, unsigned int> tmp(i1, i2);
299  // Contains pairs of indices of all valid VM pairs in seeding layers
300  TE_[iseed].push_back(tmp);
301  }
302  }
303  }
304  }
305 }
306 
307 //--- Builds the lists of TC for each seeding combination
308 
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];
314 
315  //Very naive method to group TEs in TC
316 
317  double invnTC = nTC * (1.0 / TEs.size());
318 
319  for (unsigned int iTE = 0; iTE < TEs.size(); iTE++) {
320  int iTC = invnTC * iTE;
321  assert(iTC < (int)nTC);
322  if (iTC >= (int)TCs.size()) {
323  std::vector<unsigned int> tmp;
324  tmp.push_back(iTE);
325  TCs.push_back(tmp);
326  } else {
327  TCs[iTC].push_back(iTE);
328  }
329  }
330  }
331 }
332 
333 //--- Helper fcn to return the phi range of a projection of a tracklet from a TC
334 
335 std::pair<double, double> TrackletConfigBuilder::seedPhiRange(double rproj, unsigned int iSeed, unsigned int iTC) {
336  std::vector<std::vector<unsigned int> >& TCs = TC_[iSeed];
337 
338  std::pair<double, double> seedradii = seedRadii(iSeed);
339 
340  double phimin = 999.0;
341  double phimax = -999.0;
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;
346  double phi1[2] = {VMStubsTE_[iSeed].first[l1TE].first, VMStubsTE_[iSeed].first[l1TE].second};
347  double phi2[2] = {VMStubsTE_[iSeed].second[l2TE].first, VMStubsTE_[iSeed].second[l2TE].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);
351  if (aphi < phimin)
352  phimin = aphi;
353  if (aphi > phimax)
354  phimax = aphi;
355  }
356  }
357  }
358  return std::pair<double, double>(phimin, phimax);
359 }
360 
361 //--- Finds the projections needed for each seeding combination
362 
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"};
378 
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"};
390 
391  for (unsigned int iseed = 0; iseed < N_SEED_PROMPT; iseed++) {
392  std::vector<std::vector<unsigned int> >& TCs = TC_[iseed];
393 
394  for (unsigned int ilayer = 0; ilayer < N_LAYER + N_DISK; ilayer++) {
395  if (matchport_[iseed][ilayer] == -1)
396  continue;
397  for (unsigned int iReg = 0; iReg < NRegions_[ilayer]; iReg++) {
398  for (unsigned int iTC = 0; iTC < TCs.size(); iTC++) {
399  double rproj = rmaxdisk_;
400  if (ilayer < 6)
401  rproj = rmean_[ilayer];
402  std::pair<double, double> phiRange = seedPhiRange(rproj, iseed, 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); //seedindex and TC
405  string projName = TPROJName(iseed, iTC, ilayer, iReg);
406  if (combinedmodules_) {
407  if (emptyProjCombined.find(projName) == emptyProjCombined.end()) {
408  projections_[ilayer][iReg].push_back(tmp);
409  }
410  } else {
411  if (emptyProjStandard.find(projName) == emptyProjStandard.end()) {
412  projections_[ilayer][iReg].push_back(tmp);
413  }
414  }
415  }
416  }
417  }
418  }
419  }
420 }
421 
422 //--- Helper function to calculate the phi position of a seed at radius r that is formed
423 //--- by two stubs at (r1,phi1) and (r2, phi2)
424 
425 double TrackletConfigBuilder::phi(double r1, double phi1, double r2, double phi2, double r) {
426  double rhoinv = rinv(r1, phi1, r2, phi2);
427  if (std::abs(rhoinv) > rinvmax_) {
428  rhoinv = rinvmax_ * rhoinv / std::abs(rhoinv);
429  }
430  return phi1 + asin(0.5 * r * rhoinv) - asin(0.5 * r1 * rhoinv);
431 }
432 
433 //--- Helper function to calculate rinv for two stubs at (r1,phi1) and (r2,phi2)
434 
435 double TrackletConfigBuilder::rinv(double r1, double phi1, double r2, double phi2) {
436  double deltaphi = phi1 - phi2;
437  return 2 * sin(deltaphi) / sqrt(r2 * r2 + r1 * r1 - 2 * r1 * r2 * cos(deltaphi));
438 }
439 
440 std::string TrackletConfigBuilder::iSeedStr(unsigned int iSeed) const {
441  static std::string name[8] = {"L1L2", "L2L3", "L3L4", "L5L6", "D1D2", "D3D4", "L1D1", "L2D1"};
442 
443  assert(iSeed < 8);
444  return name[iSeed];
445 }
446 
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"};
451  assert(i < 32);
452  return num[i];
453 }
454 
456  static std::string name[12] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"};
457 
458  assert(iTC < 12);
459  return name[iTC];
460 }
461 
462 std::string TrackletConfigBuilder::iRegStr(unsigned int iReg, unsigned int iSeed) const {
463  static std::string name[8] = {"A", "B", "C", "D", "E", "F", "G", "H"};
464 
465  static std::string nameOverlap[8] = {"X", "Y", "Z", "W", "Q", "R", "S", "T"};
466 
467  static std::string nameL2L3[4] = {"I", "J", "K", "L"};
468 
469  if (iSeed == Seed::L2L3) {
470  assert(iReg < 4);
471  return nameL2L3[iReg];
472  }
473  if (iSeed == Seed::L1D1 || iSeed == Seed::L2D1) {
474  assert(iReg < 8);
475  return nameOverlap[iReg];
476  }
477  assert(iReg < 8);
478  return name[iReg];
479 }
480 
481 std::string TrackletConfigBuilder::TCName(unsigned int iSeed, unsigned int iTC) const {
482  if (combinedmodules_) {
483  return "TP_" + iSeedStr(iSeed) + iTCStr(iTC);
484  } else {
485  return "TC_" + iSeedStr(iSeed) + iTCStr(iTC);
486  }
487 }
488 
490  return ilayer < 6 ? ("L" + numStr(ilayer)) : ("D" + numStr(ilayer - 6));
491 }
492 
494  unsigned int iTC,
495  unsigned int ilayer,
496  unsigned int ireg) const {
497  return "TPROJ_" + iSeedStr(iSeed) + iTCStr(iTC) + "_" + LayerName(ilayer) + "PHI" + iTCStr(ireg);
498 }
499 
500 std::string TrackletConfigBuilder::PRName(unsigned int ilayer, unsigned int ireg) const {
501  if (combinedmodules_) {
502  return "MP_" + LayerName(ilayer) + "PHI" + iTCStr(ireg);
503  } else {
504  return "PR_" + LayerName(ilayer) + "PHI" + iTCStr(ireg);
505  }
506 }
507 
508 void TrackletConfigBuilder::writeProjectionMemories(std::ostream& os, std::ostream& memories, std::ostream&) {
509  // Each TC (e.g. TC_L1L2D) writes a projection memory (TPROJ) for each layer the seed projects to,
510  // with name indicating the TC and which layer & phi region it projects to (e.g. TPROJ_L1L2D_L3PHIA).
511  //
512  // Each PR (e.g. PR_L3PHIA) reads all TPROJ memories for the given layer & phi region.
513 
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;
519 
520  memories << "TrackletProjections: " + TPROJName(iSeed, iTC, ilayer, ireg) + " [54]" << std::endl;
521 
522  os << TPROJName(iSeed, iTC, ilayer, ireg) << " input=> " << TCName(iSeed, iTC) << ".projout"
523  << LayerName(ilayer) << "PHI" << iTCStr(ireg) << " output=> " << PRName(ilayer, ireg) << ".projin"
524  << std::endl;
525  }
526  }
527  }
528 }
529 
531  unsigned int ireg1,
532  unsigned int ivm1,
533  unsigned int l2,
534  unsigned int ireg2,
535  unsigned int ivm2,
536  unsigned int iseed) const {
537  return "SP_" + LayerName(l1) + "PHI" + iRegStr(ireg1, iseed) + numStr(ivm1) + "_" + LayerName(l2) + "PHI" +
538  iRegStr(ireg2, iseed) + numStr(ivm2);
539 }
540 
542  unsigned int ireg1,
543  unsigned int ivm1,
544  unsigned int l2,
545  unsigned int ireg2,
546  unsigned int ivm2,
547  unsigned int l3,
548  unsigned int ireg3,
549  unsigned int ivm3,
550  unsigned int iseed) const {
551  return "SPD_" + LayerName(l1) + "PHI" + iRegStr(ireg1, iseed) + numStr(ivm1) + "_" + LayerName(l2) + "PHI" +
552  iRegStr(ireg2, iseed) + numStr(ivm2) + "_" + LayerName(l3) + "PHI" + iRegStr(ireg3, iseed) + numStr(ivm3);
553 }
554 
556  unsigned int ireg1,
557  unsigned int ivm1,
558  unsigned int l2,
559  unsigned int ireg2,
560  unsigned int ivm2,
561  unsigned int iseed) const {
562  return "TE_" + LayerName(l1) + "PHI" + iRegStr(ireg1, iseed) + numStr(ivm1) + "_" + LayerName(l2) + "PHI" +
563  iRegStr(ireg2, iseed) + numStr(ivm2);
564 }
565 
567  unsigned int ireg1,
568  unsigned int ivm1,
569  unsigned int l2,
570  unsigned int ireg2,
571  unsigned int ivm2,
572  unsigned int iseed) const {
573  return "TED_" + LayerName(l1) + "PHI" + iRegStr(ireg1, iseed) + numStr(ivm1) + "_" + LayerName(l2) + "PHI" +
574  iRegStr(ireg2, iseed) + numStr(ivm2);
575 }
576 
577 std::string TrackletConfigBuilder::TParName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc) const {
578  return "TPAR_" + LayerName(l1) + LayerName(l2) + LayerName(l3) + iTCStr(itc);
579 }
580 
581 std::string TrackletConfigBuilder::TCDName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc) const {
582  return "TCD_" + LayerName(l1) + LayerName(l2) + LayerName(l3) + iTCStr(itc);
583 }
584 
586  unsigned int l2,
587  unsigned int l3,
588  unsigned int itc,
589  unsigned int projlayer,
590  unsigned int projreg) const {
591  return "TPROJ_" + LayerName(l1) + LayerName(l2) + LayerName(l3) + iTCStr(itc) + "_" + LayerName(projlayer) + "PHI" +
592  iTCStr(projreg);
593 }
594 
595 std::string TrackletConfigBuilder::FTName(unsigned int l1, unsigned int l2, unsigned int l3) const {
596  return "FT_" + LayerName(l1) + LayerName(l2) + LayerName(l3);
597 }
598 
600  unsigned int ireg1,
601  unsigned int l2,
602  unsigned int ireg2,
603  unsigned int iseed,
604  unsigned int count) const {
605  return "TRE_" + LayerName(l1) + iRegStr(ireg1, iseed) + LayerName(l2) + iRegStr(ireg2, iseed) + "_" + numStr(count);
606 }
607 
609  unsigned int ireg1,
610  unsigned int l2,
611  unsigned int ireg2,
612  unsigned int l3,
613  unsigned int ireg3,
614  unsigned int iseed,
615  unsigned int count) const {
616  return "ST_" + LayerName(l1) + iRegStr(ireg1, iseed) + LayerName(l2) + iRegStr(ireg2, iseed) + "_" + LayerName(l3) +
617  iRegStr(ireg3, iseed) + "_" + numStr(count);
618 }
619 
620 void TrackletConfigBuilder::writeSPMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) {
621  // Each TE reads one VM in two seed layers, finds stub pairs & writes to a StubPair ("SP") memory.
622  //
623  // Each TC reads several StubPair (SP) memories, each containing a pair of VMs of two seeding layers.
624  // Several TC are created for each layer pair, and the SP distributed between them.
625  // If TC name is TC_L1L2C, "C" indicates this is the 3rd TC in L1L2.
626 
627  if (combinedmodules_)
628  return;
629 
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];
634 
635  unsigned int TE1 = TE_[iSeed][theTE].first;
636  unsigned int TE2 = TE_[iSeed][theTE].second;
637 
638  unsigned int l1 = seedLayers(iSeed).first;
639  unsigned int l2 = seedLayers(iSeed).second;
640 
641  memories << "StubPairs: "
642  << SPName(l1, TE1 / NVMTE_[iSeed].first, TE1, l2, TE2 / NVMTE_[iSeed].second, TE2, iSeed) << " [12]"
643  << std::endl;
644  modules << "TrackletEngine: "
645  << TEName(l1, TE1 / NVMTE_[iSeed].first, TE1, l2, TE2 / NVMTE_[iSeed].second, TE2, iSeed) << std::endl;
646 
647  os << SPName(l1, TE1 / NVMTE_[iSeed].first, TE1, l2, TE2 / NVMTE_[iSeed].second, TE2, iSeed) << " input=> "
648  << TEName(l1, TE1 / NVMTE_[iSeed].first, TE1, l2, TE2 / NVMTE_[iSeed].second, TE2, iSeed)
649  << ".stubpairout output=> " << TCName(iSeed, iTC) << ".stubpairin" << std::endl;
650  }
651  }
652  }
653 }
654 
655 void TrackletConfigBuilder::writeSPDMemories(std::ostream& wires, std::ostream& memories, std::ostream& modules) {
656  // Similar to writeSPMemories, but for displaced (=extended) tracking,
657  // with seeds based on triplets of layers.
658 
659  if (!extended_)
660  return;
661 
662  vector<string> stubTriplets[N_SEED];
663 
664  for (unsigned int iSeed = N_SEED_PROMPT; iSeed < N_SEED; iSeed++) {
665  int layerdisk1 = settings_.seedlayers(0, iSeed);
666  int layerdisk2 = settings_.seedlayers(1, iSeed);
667  int layerdisk3 = settings_.seedlayers(2, iSeed);
668 
669  unsigned int nallstub1 = settings_.nallstubs(layerdisk1);
670  unsigned int nallstub2 = settings_.nallstubs(layerdisk2);
671  unsigned int nallstub3 = settings_.nallstubs(layerdisk3);
672 
673  unsigned int nvm1 = settings_.nvmte(0, iSeed);
674  unsigned int nvm2 = settings_.nvmte(1, iSeed);
675  unsigned int nvm3 = settings_.nvmte(2, iSeed);
676 
677  int count = 0;
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++) {
681  count++;
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));
685  }
686  }
687  }
688 
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++) {
693  int count = 0;
694 
695  modules << "TrackletEngineDisplaced: "
696  << TEDName(layerdisk1, ireg1, ireg1 * nvm1 + ivm1, layerdisk2, ireg2, ireg2 * nvm2 + ivm2, iSeed)
697  << std::endl;
698 
699  for (unsigned int ireg3 = 0; ireg3 < nallstub3; ireg3++) {
700  for (unsigned int ivm3 = 0; ivm3 < nvm3; ivm3++) {
701  count++;
702 
703  memories << "StubPairsDisplaced: "
704  << SPDName(layerdisk1,
705  ireg1,
706  ireg1 * nvm1 + ivm1,
707  layerdisk2,
708  ireg2,
709  ireg2 * nvm2 + ivm2,
710  layerdisk3,
711  ireg3,
712  ireg3 * nvm3 + ivm3,
713  iSeed)
714  << " [12]" << std::endl;
715 
716  modules << "TripletEngine: " << TREName(layerdisk1, ireg1, layerdisk2, ireg2, iSeed, count)
717  << std::endl;
718 
719  wires << SPDName(layerdisk1,
720  ireg1,
721  ireg1 * nvm1 + ivm1,
722  layerdisk2,
723  ireg2,
724  ireg2 * nvm2 + ivm2,
725  layerdisk3,
726  ireg3,
727  ireg3 * nvm3 + ivm3,
728  iSeed)
729  << " input=> "
730  << TEDName(layerdisk1, ireg1, ireg1 * nvm1 + ivm1, layerdisk2, ireg2, ireg2 * nvm2 + ivm2, iSeed)
731  << ".stubpairout output=> " << TREName(layerdisk1, ireg1, layerdisk2, ireg2, iSeed, count)
732  << ".stubpair"
733  << "1"
734  << "in" << std::endl;
735  }
736  }
737  }
738  }
739  }
740  }
741 
742  unsigned int nTC = 10;
743  for (unsigned int itc = 0; itc < nTC; itc++) {
744  for (int iproj = 0; iproj < 4; iproj++) {
745  int ilay = settings_.projlayers(iSeed, iproj);
746  if (ilay > 0) {
747  unsigned int nallstub = settings_.nallstubs(ilay - 1);
748  for (unsigned int ireg = 0; ireg < nallstub; ireg++) {
749  memories << "TrackletProjections: " << TPROJName(layerdisk1, layerdisk2, layerdisk3, itc, ilay - 1, ireg)
750  << " [54]" << std::endl;
751  }
752  }
753 
754  int idisk = settings_.projdisks(iSeed, iproj);
755  if (idisk > 0) {
756  unsigned int nallstub = settings_.nallstubs(idisk + 5);
757  for (unsigned int ireg = 0; ireg < nallstub; ireg++) {
758  memories << "TrackletProjections: " << TPROJName(layerdisk1, layerdisk2, layerdisk3, itc, idisk + 5, ireg)
759  << " [54]" << std::endl;
760 
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;
765  }
766  }
767  }
768 
769  memories << "TrackletParameters: " << TParName(layerdisk1, layerdisk2, layerdisk3, itc) << " [56]" << std::endl;
770 
771  modules << "TrackletCalculatorDisplaced: " << TCDName(layerdisk1, layerdisk2, layerdisk3, itc) << std::endl;
772  }
773 
774  unsigned int nST = stubTriplets[iSeed].size();
775  for (unsigned int iST = 0; iST < nST; iST++) {
776  unsigned int iTC = (iST * nTC) / nST;
777  assert(iTC < nTC);
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"
787  << std::endl;
788  }
789 
790  modules << "FitTrack: " << FTName(layerdisk1, layerdisk2, layerdisk3) << std::endl;
791  }
792 }
793 
794 void TrackletConfigBuilder::writeAPMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) {
795  // The AllProjection memories (e.g. AP_L2PHIA) contain the intercept point of the projection to
796  // a layer. Each is written by one PR module of similar name (e.g. PR_L2PHIA), and read by
797  // a MC (e.g. MC_L2PHIA).
798 
799  if (combinedmodules_)
800  return;
801 
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;
805  modules << "ProjectionRouter: PR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
806 
807  os << "AP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << " input=> PR_" << LayerName(ilayer) << "PHI"
808  << iTCStr(iReg) << ".allprojout output=> MC_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allprojin"
809  << std::endl;
810  }
811  }
812 }
813 
814 void TrackletConfigBuilder::writeCMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) {
815  // The CandidateMatch memory (e.g. CM_L1PHIA1) are each written by ME module of similar name
816  // (e.g. ME_L1PHIA1) and contain indices of matching (tracklet projections,stubs) in the specified
817  // VM region.
818  // All CM memories in a given phi region (e.g. L1PHIA) are read by a MC module (e.g. MC_L1PHIA) that
819  // does more precise matching.
820 
821  if (combinedmodules_)
822  return;
823 
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;
828  modules << "MatchEngine: ME_" << LayerName(ilayer) << "PHI" << iTCStr(iME / NVMME_[ilayer]) << iME + 1
829  << std::endl;
830 
831  os << "CM_" << LayerName(ilayer) << "PHI" << iTCStr(iME / NVMME_[ilayer]) << iME + 1 << " input=> ME_"
832  << LayerName(ilayer) << "PHI" << iTCStr(iME / NVMME_[ilayer]) << iME + 1 << ".matchout output=> MC_"
833  << LayerName(ilayer) << "PHI" << iTCStr(iME / NVMME_[ilayer]) << ".matchin" << std::endl;
834  }
835  }
836 }
837 
838 void TrackletConfigBuilder::writeVMPROJMemories(std::ostream& os, std::ostream& memories, std::ostream&) {
839  // The VMPROJ memories (e.g. VMPROJ_L2PHIA1) written by a PR module each correspond to projections to
840  // a single VM region in a layer. Each is filled by the PR using all projections (TPROJ) to this VM
841  // from different seeding layers.
842  //
843  // Each VMPROJ memory is read by a ME module, which matches the projection to stubs.
844 
845  if (combinedmodules_)
846  return;
847 
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;
852 
853  os << "VMPROJ_" << LayerName(ilayer) << "PHI" << iTCStr(iME / NVMME_[ilayer]) << iME + 1 << " input=> PR_"
854  << LayerName(ilayer) << "PHI" << iTCStr(iME / NVMME_[ilayer]) << ".vmprojout"
855  << "PHI" << iTCStr(iME / NVMME_[ilayer]) << iME + 1 << " output=> ME_" << LayerName(ilayer) << "PHI"
856  << iTCStr(iME / NVMME_[ilayer]) << iME + 1 << ".vmprojin" << std::endl;
857  }
858  }
859 }
860 
861 void TrackletConfigBuilder::writeFMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) {
862  // All FullMatch (e.g. FM_L2L3_L1PHIA) memories corresponding to a matches between stubs & tracklets
863  // in a given region (e.g. L1PHIA) from all seeding layers, are written by a MC module (e.g. MC_L1PHIA).
864  //
865  // All FullMatch memories corresponding to a given seed pair are read by the TrackBuilder (e.g. FT_L1L2),
866  // which checks if the track has stubs in enough layers.
867 
868  if (combinedmodules_) {
869  for (unsigned int ilayer = 0; ilayer < N_LAYER + N_DISK; ilayer++) {
870  for (unsigned int iReg = 0; iReg < NRegions_[ilayer]; iReg++) {
871  modules << "MatchProcessor: MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
872  for (unsigned int iSeed = 0; iSeed < N_SEED_PROMPT; iSeed++) {
873  if (matchport_[iSeed][ilayer] == -1)
874  continue;
875  memories << "FullMatch: FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg)
876  << " [36]" << std::endl;
877  os << "FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << " input=> MP_"
878  << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".matchout1 output=> FT_" << iSeedStr(iSeed)
879  << ".fullmatch" << matchport_[iSeed][ilayer] << "in" << iReg + 1 << std::endl;
880  }
881  }
882  }
883  } else {
884  for (unsigned int ilayer = 0; ilayer < N_LAYER + N_DISK; ilayer++) {
885  for (unsigned int iReg = 0; iReg < NRegions_[ilayer]; iReg++) {
886  modules << "MatchCalculator: MC_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
887  for (unsigned int iSeed = 0; iSeed < N_SEED_PROMPT; iSeed++) {
888  if (matchport_[iSeed][ilayer] == -1)
889  continue;
890  memories << "FullMatch: FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg)
891  << " [36]" << std::endl;
892  os << "FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << " input=> MC_"
893  << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".matchout1 output=> FT_" << iSeedStr(iSeed)
894  << ".fullmatch" << matchport_[iSeed][ilayer] << "in" << iReg + 1 << std::endl;
895  }
896  }
897  }
898  }
899 }
900 
901 void TrackletConfigBuilder::writeASMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) {
902  // Each VMR writes AllStub memories (AS) for a single phi region (e.g. PHIC),
903  // merging data from all DTCs related to this phi region. It does so by merging data from
904  // the IL memories written by all IRs for this phi region. The wiring map lists all
905  // IL memories that feed (">") into a single VMR ("VMR_L1PHIC") that writes to the
906  // an AS memory ("AS_L1PHIC").
907  // Multiple copies of each AS memory exist where several modules in chain want to read it.
908 
909  if (combinedmodules_) {
910  //First write AS memories used by MatchProcessor
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;
915  if (combinedmodules_) {
916  modules << "VMRouterCM: VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
917  } else {
918  modules << "VMRouter: VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
919  }
920  os << "AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
921  << " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubout output=> MP_"
922  << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubin" << std::endl;
923  }
924  }
925 
926  //Next write AS memories used by TrackletProcessor
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++) {
930  unsigned int l1 = seedLayers(iSeed).first;
931  unsigned int l2 = seedLayers(iSeed).second;
932 
933  if (ilayer != l1 && ilayer != l2)
934  continue;
935 
936  bool inner = ilayer == l1;
937 
938  for (unsigned int iTC = 0; iTC < TC_[iSeed].size(); iTC++) {
939  int nTCReg = TC_[iSeed].size() / NRegions_[l2];
940 
941  int iTCReg = iTC / nTCReg;
942 
943  int jTCReg = iTC % nTCReg;
944 
945  if (ilayer == l2) {
946  if (iTCReg != iReg)
947  continue;
948  }
949 
950  string ext = "";
951 
952  if (ilayer == l1) {
953  int ratio = NRegions_[l1] / NRegions_[l2];
954  int min = iTCReg * ratio - 1 + jTCReg;
955  int max = (iTCReg + 1) * ratio - (nTCReg - jTCReg - 1);
956  if ((int)iReg < min || (int)iReg > max)
957  continue;
958 
959  if (max - min >= 2) {
960  ext = "M";
961  if (iReg == min)
962  ext = "R";
963  if (iReg == max)
964  ext = "L";
965  }
966 
967  if (max - min == 1) {
968  if (nTCReg == 2) {
969  assert(0);
970  if (jTCReg == 0) {
971  if (iReg == min)
972  ext = "R";
973  if (iReg == max)
974  ext = "B";
975  }
976  if (jTCReg == 1) {
977  if (iReg == min)
978  ext = "A";
979  if (iReg == max)
980  ext = "L";
981  }
982  }
983  if (nTCReg == 3) {
984  if (jTCReg == 0) {
985  if (iReg == min)
986  ext = "A";
987  if (iReg == max)
988  ext = "F";
989  }
990  if (jTCReg == 1) {
991  if (iReg == min)
992  ext = "E";
993  if (iReg == max)
994  ext = "D";
995  }
996  if (jTCReg == 2) {
997  if (iReg == min)
998  ext = "C";
999  if (iReg == max)
1000  ext = "B";
1001  }
1002  }
1003  }
1004  assert(!ext.empty());
1005  }
1006 
1007  if (ext.empty()) {
1008  ext = "_" + LayerName(l1) + iTCStr(iTC);
1009  }
1010 
1011  if (iSeed < 4) { //Barrel seeding
1012  ext = "_B" + ext;
1013  } else if (iSeed > 5) {
1014  ext = "_O" + ext;
1015  } else {
1016  ext = "_D" + ext;
1017  }
1018 
1019  if (inner) {
1020  memories << "AllInnerStubs: ";
1021  } else {
1022  memories << "AllStubs: ";
1023  }
1024  memories << "AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ext << " [42]" << std::endl;
1025  os << "AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ext << " input=> VMR_" << LayerName(ilayer)
1026  << "PHI" << iTCStr(iReg) << ".all" << (inner ? "inner" : "") << "stubout output=> TP_" << iSeedStr(iSeed)
1027  << iTCStr(iTC);
1028  if (inner) {
1029  os << ".innerallstubin" << std::endl;
1030  } else {
1031  os << ".outerallstubin" << std::endl;
1032  }
1033  }
1034  }
1035  }
1036  }
1037 
1038  } else {
1039  //First write AS memories used by MatchCalculator
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;
1044  if (combinedmodules_) {
1045  modules << "VMRouterCM: VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
1046  } else {
1047  modules << "VMRouter: VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
1048  }
1049  os << "AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
1050  << " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubout output=> MC_"
1051  << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubin" << std::endl;
1052  }
1053  }
1054 
1055  //Next write AS memories used by TrackletCalculator
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;
1059 
1060  for (unsigned int iSeed = 0; iSeed < N_SEED_PROMPT; iSeed++) {
1061  unsigned int l1 = seedLayers(iSeed).first;
1062  unsigned int l2 = seedLayers(iSeed).second;
1063 
1064  if (ilayer != l1 && ilayer != l2)
1065  continue;
1066 
1067  for (unsigned int iTC = 0; iTC < TC_[iSeed].size(); iTC++) {
1068  bool used = false;
1069  // Each TC processes data from several TEs.
1070  for (unsigned int iTE = 0; iTE < TC_[iSeed][iTC].size(); iTE++) {
1071  unsigned int theTE = TC_[iSeed][iTC][iTE];
1072 
1073  unsigned int TE1 = TE_[iSeed][theTE].first; // VM in inner/outer layer of this TE.
1074  unsigned int TE2 = TE_[iSeed][theTE].second;
1075 
1076  if (l1 == ilayer && iReg == TE1 / NVMTE_[iSeed].first)
1077  used = true;
1078  if (l2 == ilayer && iReg == TE2 / NVMTE_[iSeed].second)
1079  used = true;
1080  }
1081 
1082  if (used) {
1083  nmem++; // Another copy of memory
1084  memories << "AllStubs: AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n" << nmem << " [42]"
1085  << std::endl;
1086  os << "AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n" << nmem << " input=> VMR_"
1087  << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubout output=> TC_" << iSeedStr(iSeed)
1088  << iTCStr(iTC);
1089  if (ilayer == l1) {
1090  os << ".innerallstubin" << std::endl;
1091  } else {
1092  os << ".outerallstubin" << std::endl;
1093  }
1094  }
1095  }
1096  }
1097  }
1098  }
1099  }
1100 }
1101 
1102 void TrackletConfigBuilder::writeVMSMemories(std::ostream& os, std::ostream& memories, std::ostream&) {
1103  // Each VMR writes to Virtual Module memories ("VMS") to be used later by the ME or TE etc.
1104  // Memory VMSTE_L1PHIC9-12 is the memory for small phi region C in L1 for the TE module.
1105  // Numbers 9-12 correspond to the 4 VMs in this phi region.
1106  //
1107  // Each TE reads one VMS memory in each seeding layer.
1108 
1109  if (combinedmodules_) {
1110  //First write VMS memories used by MatchProcessor
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;
1114  os << "VMSME_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
1115  << " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstuboutPHI" << iTCStr(iReg)
1116  << " output=> MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstubin" << std::endl;
1117  }
1118  }
1119 
1120  //Next write VMS memories used by TrackletProcessor
1121  for (unsigned int iSeed = 0; iSeed < N_SEED_PROMPT; iSeed++) {
1122  //FIXME - code could be cleaner
1123  unsigned int l1 = seedLayers(iSeed).first;
1124  unsigned int l2 = seedLayers(iSeed).second;
1125 
1126  unsigned int ilayer = seedLayers(iSeed).second;
1127 
1128  //for(unsigned int iReg=0;iReg<NRegions_[ilayer];iReg++){
1129 
1130  unsigned int nTCReg = TC_[iSeed].size() / NRegions_[l2];
1131 
1132  for (unsigned int iReg = 0; iReg < NRegions_[l2]; iReg++) {
1133  unsigned int nmem = 0;
1134  //Hack since we use same module twice
1135  if (iSeed == Seed::L2D1) {
1136  nmem = 2;
1137  }
1138 
1139  for (unsigned iTC = 0; iTC < nTCReg; iTC++) {
1140  nmem++;
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_"
1145  << LayerName(l1) << LayerName(l2) << iTCStr(iReg * nTCReg + iTC) << ".outervmstubin" << std::endl;
1146  }
1147  }
1148  }
1149 
1150  } else {
1151  //First write VMS memories used by MatchEngine
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]"
1156  << std::endl;
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"
1160  << std::endl;
1161  }
1162  }
1163 
1164  // Next write VMS memories used by TrackletEngine
1165  // Each TE processes one VM region in inner + outer seeding layers, and needs its own copy of input memories.
1166  for (unsigned int iSeed = 0; iSeed < N_SEED_PROMPT; iSeed++) {
1167  for (unsigned int innerouterseed = 0; innerouterseed < 2; innerouterseed++) {
1168  //FIXME - code could be cleaner
1169  unsigned int l1 = seedLayers(iSeed).first;
1170  unsigned int l2 = seedLayers(iSeed).second;
1171 
1172  unsigned int NVMTE1 = NVMTE_[iSeed].first;
1173  unsigned int NVMTE2 = NVMTE_[iSeed].second;
1174 
1175  unsigned int ilayer = l1;
1176  unsigned int NVMTE = NVMTE1;
1177  if (innerouterseed == 1) {
1178  ilayer = l2;
1179  NVMTE = NVMTE2;
1180  }
1181 
1182  for (unsigned int iVMTE = 0; iVMTE < NVMTE * NRegions_[ilayer]; iVMTE++) {
1183  unsigned int iReg = iVMTE / NVMTE;
1184 
1185  unsigned int nmem = 0;
1186 
1187  if (iSeed == Seed::L2D1) {
1188  nmem = 4;
1189  }
1190 
1191  for (unsigned int iTE = 0; iTE < TE_[iSeed].size(); iTE++) {
1192  unsigned int TE1 = TE_[iSeed][iTE].first; // VM region in inner/outer layer of this TE
1193  unsigned int TE2 = TE_[iSeed][iTE].second;
1194 
1195  bool used = false;
1196 
1197  if (innerouterseed == 0 && iVMTE == TE1)
1198  used = true;
1199  if (innerouterseed == 1 && iVMTE == TE2)
1200  used = true;
1201 
1202  if (!used)
1203  continue;
1204 
1205  string inorout = "I";
1206  if (innerouterseed == 1)
1207  inorout = "O";
1208 
1209  nmem++; // Add another copy of memory.
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;
1219  } else {
1220  os << ".outervmstubin" << std::endl;
1221  }
1222  }
1223  }
1224  }
1225  }
1226  }
1227 }
1228 
1229 void TrackletConfigBuilder::writeTPARMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) {
1230  // Each TC module (e.g. TC_L1L2A) stores helix params in a single TPAR memory of similar name
1231  // (e.g. TPAR_L1L2A). The TPAR is subsequently read by the TrackBuilder (FT).
1232 
1233  if (combinedmodules_) {
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;
1237  modules << "TrackletProcessor: TP_" << iSeedStr(iSeed) << iTCStr(iTP) << std::endl;
1238  os << "TPAR_" << iSeedStr(iSeed) << iTCStr(iTP) << " input=> TP_" << iSeedStr(iSeed) << iTCStr(iTP)
1239  << ".trackpar output=> FT_" << iSeedStr(iSeed) << ".tparin" << std::endl;
1240  }
1241  }
1242  } else {
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;
1246  modules << "TrackletCalculator: TC_" << iSeedStr(iSeed) << iTCStr(iTC) << std::endl;
1247  os << "TPAR_" << iSeedStr(iSeed) << iTCStr(iTC) << " input=> TC_" << iSeedStr(iSeed) << iTCStr(iTC)
1248  << ".trackpar output=> FT_" << iSeedStr(iSeed) << ".tparin" << std::endl;
1249  }
1250  }
1251  }
1252 }
1253 
1254 void TrackletConfigBuilder::writeTFMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) {
1255  for (unsigned int iSeed = 0; iSeed < N_SEED_PROMPT; iSeed++) {
1256  memories << "TrackFit: TF_" << iSeedStr(iSeed) << " [126]" << std::endl;
1257  modules << "FitTrack: FT_" << iSeedStr(iSeed) << std::endl;
1258  os << "TF_" << iSeedStr(iSeed) << " input=> FT_" << iSeedStr(iSeed) << ".trackout output=> PD.trackin" << std::endl;
1259  }
1260 }
1261 
1262 void TrackletConfigBuilder::writeCTMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) {
1263  modules << "PurgeDuplicate: PD" << std::endl;
1264 
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;
1268  }
1269 }
1270 
1271 void TrackletConfigBuilder::writeILMemories(std::ostream& os, std::ostream& memories, std::ostream& modules) {
1272  // Each Input Router (IR) reads stubs from one DTC (e.g. PS10G_1) & sends them
1273  // to 4-8 InputLink (IL) memories (labelled PHIA-PHIH), each corresponding to a small
1274  // phi region of a nonant, for each tracklet layer (L1-L6 or D1-D5) that the DTC
1275  // reads. The InputLink memories have names such as IL_L1PHIC_PS10G_1 to reflect this.
1276 
1277  string olddtc = "";
1278  for (const DTCinfo& info : vecDTCinfo_) {
1279  string dtcname = info.name;
1280  if (olddtc != dtcname) {
1281  // Write one entry per DTC, with each DTC connected to one IR.
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;
1290  }
1291  olddtc = dtcname;
1292  }
1293 
1294  for (const DTCinfo& info : vecDTCinfo_) {
1295  string dtcname = info.name;
1296  int layerdisk = info.layer;
1297 
1298  for (unsigned int iReg = 0; iReg < NRegions_[layerdisk]; iReg++) {
1299  //--- Ian Tomalin's proposed bug fix
1300  double phiminDTC_A = info.phimin - M_PI / N_SECTOR; // Phi range of each DTC.
1301  double phimaxDTC_A = info.phimax - M_PI / N_SECTOR;
1302  double phiminDTC_B = info.phimin + M_PI / N_SECTOR; // Phi range of each DTC.
1303  double phimaxDTC_B = info.phimax + M_PI / N_SECTOR;
1304  if (allStubs_[layerdisk][iReg].second > phiminDTC_A && allStubs_[layerdisk][iReg].first < phimaxDTC_A) {
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;
1310  }
1311  if (allStubs_[layerdisk][iReg].second > phiminDTC_B && allStubs_[layerdisk][iReg].first < phimaxDTC_B) {
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;
1317  }
1318  //--- Original (buggy) code
1319  /*
1320  double phiminDTC = info.phimin; // Phi range of each DTC.
1321  double phimaxDTC = info.phimax;
1322 
1323  if (allStubs_[layerdisk][iReg].first > phimaxDTC && allStubs_[layerdisk][iReg].second < phiminDTC)
1324  continue;
1325 
1326  // Phi region range must be entirely contained in this DTC to keep this connection.
1327  if (allStubs_[layerdisk][iReg].second < phimaxDTC) {
1328  memories << "InputLink: IL_" << LayerName(layerdisk) << "PHI" << iTCStr(iReg) << "_" << dtcname << "_A"
1329  << " [36]" << std::endl;
1330  os << "IL_" << LayerName(layerdisk) << "PHI" << iTCStr(iReg) << "_" << dtcname << "_A"
1331  << " input=> IR_" << dtcname << "_A.stubout output=> VMR_" << LayerName(layerdisk) << "PHI"
1332  << iTCStr(iReg) << ".stubin" << std::endl;
1333  }
1334 
1335  if (allStubs_[layerdisk][iReg].first > phiminDTC) {
1336  memories << "InputLink: IL_" << LayerName(layerdisk) << "PHI" << iTCStr(iReg) << "_" << dtcname << "_B"
1337  << " [36]" << std::endl;
1338  os << "IL_" << LayerName(layerdisk) << "PHI" << iTCStr(iReg) << "_" << dtcname << "_B"
1339  << " input=> IR_" << dtcname << "_B.stubout output=> VMR_" << LayerName(layerdisk) << "PHI"
1340  << iTCStr(iReg) << ".stubin" << std::endl;
1341  }
1342 */
1343  }
1344  }
1345 }
1346 
1347 //--- Fill streams used to write wiring map to file
1348 
1349 void TrackletConfigBuilder::writeAll(std::ostream& wires, std::ostream& memories, std::ostream& modules) {
1350  writeILMemories(wires, memories, modules);
1351  writeASMemories(wires, memories, modules);
1352  writeVMSMemories(wires, memories, modules);
1353  writeSPMemories(wires, memories, modules);
1354  writeSPDMemories(wires, memories, modules);
1356  writeTPARMemories(wires, memories, modules);
1357  writeVMPROJMemories(wires, memories, modules);
1358  writeAPMemories(wires, memories, modules);
1359  writeCMMemories(wires, memories, modules);
1360  writeFMMemories(wires, memories, modules);
1361  writeTFMemories(wires, memories, modules);
1362  writeCTMemories(wires, memories, modules);
1363 }
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]
static const TGPicture * info(bool iBackgroundIsBlack)
constexpr int N_DISK
Definition: Settings.h:26
unsigned int NTC(int seed) const
Definition: Settings.h:160
unsigned int seedlayers(int inner, int seed) const
Definition: Settings.h:152
static std::string numStr(unsigned int i)
constexpr unsigned int N_SEED
Definition: Settings.h:28
bool combined() const
Definition: Settings.h:268
Class to process and provide run-time constants used by Track Trigger emulators.
Definition: Setup.h:44
void writeAll(std::ostream &wires, std::ostream &memories, std::ostream &modules)
double dphisectorHG() const
Definition: Settings.h:314
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static std::string LayerName(unsigned int ilayer)
std::string slotToDTCname(unsigned int slot) const
Definition: Settings.h:456
double zlength() const
Definition: Settings.h:131
double rinvmax() const
Definition: Settings.h:224
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
assert(be >=bs)
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
Definition: Settings.h:162
std::string PRName(unsigned int ilayer, unsigned int ireg) const
std::string tablePath() const
Definition: Settings.h:203
unsigned int NTC_[N_SEED_PROMPT]
double rmean(unsigned int iLayer) const
Definition: Settings.h:171
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
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
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)
Definition: Abs.h:22
unsigned int projdisks(unsigned int iSeed, unsigned int i) const
Definition: Settings.h:163
void writeSPMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
double zmean(unsigned int iDisk) const
Definition: Settings.h:174
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
Definition: Settings.h:108
#define M_PI
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
Definition: Settings.h:114
constexpr unsigned int N_SECTOR
Definition: Settings.h:23
unsigned int NVMME_[N_LAYER+N_DISK]
double rinv(double r1, double phi1, double r2, double phi2)
int iseed
Definition: AMPTWrapper.h:134
double rmaxdisk() const
Definition: Settings.h:132
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)
bool writeConfig() const
Definition: Settings.h:200
string fname
main script
bool extended() const
Definition: Settings.h:266
unsigned int nvmme(unsigned int layerdisk) const
Definition: Settings.h:111
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
Definition: memstream.h:15
tmp
align.sh
Definition: createJobs.py:716
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)
Definition: Util.h:154
constexpr unsigned int N_SEED_PROMPT
Definition: Settings.h:29
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]
constexpr int N_LAYER
Definition: Settings.h:25
double rcrit() const
Definition: Settings.h:321