CMS 3D CMS Logo

TrackletConfigBuilder.h
Go to the documentation of this file.
1 //
2 // Class to build the configuration for the tracklet based track finding
3 //
4 //
5 //
6 #ifndef L1Trigger_TrackFindingTracklet_interface_TrackletConfigBuilder_h
7 #define L1Trigger_TrackFindingTracklet_interface_TrackletConfigBuilder_h
8 
10 
11 #include <vector>
12 #include <list>
13 #include <utility>
14 #include <set>
15 #include <iostream>
16 #include <fstream>
17 #include <cstdlib>
18 
19 namespace tt {
20  class Setup;
21 }
22 
23 namespace trklet {
24 
26  public:
27  //Builds the configuration for the tracklet based track finding
28  TrackletConfigBuilder(const Settings& settings, const tt::Setup* setup = nullptr);
29 
30  //This method writes out the configuration as files
31  void writeAll(std::ostream& wires, std::ostream& memories, std::ostream& modules);
32 
33  //
34  // The next group of fcn formats a string to write out names of different
35  // memories and processing modules
36  //
37 
38  //Seed string, eg. L1L2
39  std::string iSeedStr(unsigned int iSeed) const;
40 
41  //Return unsigned as string
42  static std::string numStr(unsigned int i);
43 
44  //Return iTC as string - ie A, B, C, etc
45  std::string iTCStr(unsigned int iTC) const;
46 
47  //The region string A, B, C etc for layers and disks; X, Y, Z etc for overlap
48  std::string iRegStr(unsigned int iReg, unsigned int iSeed) const;
49 
50  //TC Name
51  std::string TCName(unsigned int iSeed, unsigned int iTC) const;
52 
53  //Name of layer or disk, e.g. L1 or D1
54  static std::string LayerName(unsigned int ilayer);
55 
56  //Tracklet projection name
57  std::string TPROJName(unsigned int iSeed, unsigned int iTC, unsigned int ilayer, unsigned int ireg) const;
58 
59  //Projection router name
60  std::string PRName(unsigned int ilayer, unsigned int ireg) const;
61 
62  private:
63  //
64  // Method to initialize the regions and VM in each layer
65  //
66  void initGeom();
67 
68  //
69  // Builds the list of TE for each seeding combination
70  //
71  void buildTE();
72 
73  //
74  // Builds the lists of TC for each seeding combination
75  //
76  void buildTC();
77 
78  //
79  // Finds the projections needed for each seeding combination
80  //
81  void buildProjections();
82 
83 #ifdef CMSSW_GIT_HASH
84  // Calculate phi range of modules read by each DTC.
85  void setDTCphirange(const tt::Setup* setup);
86 
87  // Write DTC phi ranges to dtcphirange.txt for stand-alone emulation.
88  void writeDTCphirange() const;
89 #else
90  // Set phi ranges after reading them from dtcphirange.txt (stand-alone emulation)
91  void setDTCphirange(const tt::Setup* setup = nullptr);
92 #endif
93 
94  //
95  // Helper function to determine if a pair of VM memories form valid TE
96  //
97  bool validTEPair(unsigned int iseed, unsigned int iTE1, unsigned int iTE2);
98 
99  //
100  // Helper fcn. to get the layers/disks for a seed
101  //
102  std::pair<unsigned int, unsigned int> seedLayers(unsigned int iSeed);
103 
104  //
105  // Helper fcn to get the radii of the two layers in a seed
106  //
107  std::pair<double, double> seedRadii(unsigned int iseed);
108 
109  //
110  // Helper fcn to return the phi range of a projection of a tracklet from a TC
111  //
112  std::pair<double, double> seedPhiRange(double rproj, unsigned int iSeed, unsigned int iTC);
113 
114  //
115  // Helper function to calculate the phi position of a seed at radius r that is formed
116  // by two stubs at (r1,phi1) and (r2, phi2)
117  //
118  double phi(double r1, double phi1, double r2, double phi2, double r);
119 
120  //
121  // Helper function to calculate rinv for two stubs at (r1,phi1) and (r2,phi2)
122  //
123  double rinv(double r1, double phi1, double r2, double phi2);
124 
125  //StubPair Name
126  std::string SPName(unsigned int l1,
127  unsigned int ireg1,
128  unsigned int ivm1,
129  unsigned int l2,
130  unsigned int ireg2,
131  unsigned int ivm2,
132  unsigned int iseed) const;
133 
134  //StubPair displaced name
135  std::string SPDName(unsigned int l1,
136  unsigned int ireg1,
137  unsigned int ivm1,
138  unsigned int l2,
139  unsigned int ireg2,
140  unsigned int ivm2,
141  unsigned int l3,
142  unsigned int ireg3,
143  unsigned int ivm3,
144  unsigned int iseed) const;
145 
146  //Stub Triplet name
147  std::string STName(unsigned int l1,
148  unsigned int ireg1,
149  unsigned int l2,
150  unsigned int ireg2,
151  unsigned int l3,
152  unsigned int ireg3,
153  unsigned int iseed,
154  unsigned int count) const;
155 
156  //TrackletEngine name
157  std::string TEName(unsigned int l1,
158  unsigned int ireg1,
159  unsigned int ivm1,
160  unsigned int l2,
161  unsigned int ireg2,
162  unsigned int ivm2,
163  unsigned int iseed) const;
164 
165  //Triplet engine name
166  std::string TREName(unsigned int l1,
167  unsigned int ireg1,
168  unsigned int l2,
169  unsigned int ireg2,
170  unsigned int iseed,
171  unsigned int count) const;
172 
173  //TrackletEngine displaced name
174  std::string TEDName(unsigned int l1,
175  unsigned int ireg1,
176  unsigned int ivm1,
177  unsigned int l2,
178  unsigned int ireg2,
179  unsigned int ivm2,
180  unsigned int iseed) const;
181 
182  //Tracklet parameter memory name
183  std::string TParName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc) const;
184 
185  //TrackletCalculator displaced name
186  std::string TCDName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc) const;
187 
188  //TrackletProjection name
189  std::string TPROJName(unsigned int l1,
190  unsigned int l2,
191  unsigned int l3,
192  unsigned int itc,
193  unsigned int projlay,
194  unsigned int projreg) const;
195 
196  //FitTrack module name
197  std::string FTName(unsigned int l1, unsigned int l2, unsigned int l3) const;
198 
199  //
200  // This group of methods are used to print out the configuration as a file
201  //
202  void writeProjectionMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
203 
204  void writeSPMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
205 
206  void writeSPDMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
207 
208  void writeAPMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
209 
210  void writeCMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
211 
212  void writeVMPROJMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
213 
214  void writeFMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
215 
216  void writeASMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
217 
218  void writeVMSMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
219 
220  void writeTPARMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
221 
222  void writeTFMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
223 
224  void writeCTMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
225 
226  void writeILMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
227 
228  //
229  //--- Store constants extracted from Settings
230  //
231 
232  unsigned int NSector_; //Number of sectors
233  double rcrit_; //critical radius that defines the sector
234 
235  bool combinedmodules_; //if true write configuration for combined modules
236 
237  bool extended_; //if true write configuration for extended configuration
238 
239  double rinvmax_; //Max value for valid rinv
240  double rmaxdisk_; //Maximim disk radius
241  double zlength_; //Maximim (abslute) z-positon in barrel
242  double rmean_[N_LAYER]; //Mean layer radius
243  double zmean_[N_DISK]; //Mean disk z-position
244 
245  double dphisectorHG_; //Full sector width
246 
247  unsigned int NTC_[N_SEED_PROMPT]; //Number of TC per seeding combination
248 
249  unsigned int NRegions_[N_LAYER + N_DISK]; //Regions (all stubs memories 6 layers +5 disks
250  unsigned int NVMME_[N_LAYER + N_DISK]; //Number of MEs (all stubs memories 6 layers +5 disks
251  std::pair<unsigned int, unsigned int> NVMTE_[N_SEED_PROMPT]; //number of TEs for each seeding combination
252 
253  //Min and max phi for a phi region (e.g. all stubs)
254  std::vector<std::pair<double, double> > allStubs_[N_LAYER + N_DISK];
255 
256  //Min and max phi for VM bin
257  std::vector<std::pair<double, double> > VMStubsME_[N_LAYER + N_DISK];
258 
259  //Phi ranges for the stubs in the VM bins used in the pair in th TE
260  std::pair<std::vector<std::pair<double, double> >, std::vector<std::pair<double, double> > >
262 
263  // VM bin in inner/outer seeding layer of each TE.
264  std::vector<std::pair<unsigned int, unsigned int> > TE_[N_SEED_PROMPT];
265 
266  //The ID of all TE that send data to TCs for each seeding combination
267  std::vector<std::vector<unsigned int> > TC_[N_SEED_PROMPT];
268 
269  //The projections to each layer/disk from a seed and TC
270  std::vector<std::vector<std::pair<unsigned int, unsigned int> > > projections_[N_LAYER + N_DISK];
271 
272  //Which matches are used for each seeding layer
273  // L1 L2 L3 L4 L5 L6 D1 D2 D3 D4 D5
274  int matchport_[N_SEED_PROMPT][N_LAYER + N_DISK] = {{-1, -1, 1, 2, 3, 4, 4, 3, 2, 1, -1}, //L1L2
275  {1, -1, -1, 2, 3, -1, 4, 3, 2, 1, -1}, //L2L3
276  {1, 2, -1, -1, 3, 4, 4, 3, -1, -1, -1}, //L3L4
277  {1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1}, //L5L6
278  {1, 2, -1, -1, -1, -1, -1, -1, 2, 3, 4}, //D1D2
279  {1, -1, -1, -1, -1, -1, 2, 3, -1, -1, 4}, //D3D4
280  {-1, -1, -1, -1, -1, -1, -1, 1, 2, 3, 4}, //L1D1
281  {1, -1, -1, -1, -1, -1, -1, 2, 3, 4, -1}}; //L2D1
282 
283  struct DTCinfo {
285  int layer;
286  float phimin;
287  float phimax;
288  };
289  std::list<DTCinfo> vecDTCinfo_;
290 
291  //Settings
293  };
294 } // namespace trklet
295 #endif
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]
constexpr int N_DISK
Definition: Settings.h:22
static std::string numStr(unsigned int i)
TrackletConfigBuilder(const Settings &settings, const tt::Setup *setup=nullptr)
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)
static std::string LayerName(unsigned int ilayer)
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
std::string PRName(unsigned int ilayer, unsigned int ireg) const
Definition: TTTypes.h:54
unsigned int NTC_[N_SEED_PROMPT]
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
std::string TCName(unsigned int iSeed, unsigned int iTC) const
std::vector< std::vector< unsigned int > > TC_[N_SEED_PROMPT]
void writeSPMemories(std::ostream &os, std::ostream &memories, std::ostream &modules)
std::pair< std::vector< std::pair< double, double > >, std::vector< std::pair< double, double > > > VMStubsTE_[N_SEED_PROMPT]
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 NVMME_[N_LAYER+N_DISK]
double rinv(double r1, double phi1, double r2, double phi2)
int iseed
Definition: AMPTWrapper.h:134
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)
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)
constexpr unsigned int N_SEED_PROMPT
Definition: Settings.h:25
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:21