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