Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-07 22:33:29

0001 //
0002 // Class to build the configuration for the tracklet based track finding
0003 //
0004 //
0005 //
0006 #ifndef L1Trigger_TrackFindingTracklet_interface_TrackletConfigBuilder_h
0007 #define L1Trigger_TrackFindingTracklet_interface_TrackletConfigBuilder_h
0008 
0009 #include "L1Trigger/TrackFindingTracklet/interface/Settings.h"
0010 
0011 #include <vector>
0012 #include <utility>
0013 #include <set>
0014 #include <iostream>
0015 #include <fstream>
0016 #include <cstdlib>
0017 
0018 namespace trklet {
0019 
0020   class TrackletConfigBuilder {
0021   public:
0022     //Builds the configuration for the tracklet based track finding
0023     TrackletConfigBuilder(const Settings& settings);
0024 
0025     //This method writes out the configuration as files
0026     void writeAll(std::ostream& wires, std::ostream& memories, std::ostream& modules);
0027 
0028     //
0029     // The next group of fcn formats a string to write out names of different
0030     // memories and processing modules
0031     //
0032 
0033     //Seed string, eg. L1L2
0034     std::string iSeedStr(unsigned int iSeed);
0035 
0036     //Return unsigned as string
0037     static std::string numStr(unsigned int i);
0038 
0039     //Retunr iTC as string - ie A, B, C, etc
0040     std::string iTCStr(unsigned int iTC);
0041 
0042     //The region string A, B, C etc for layers and disks; X, Y, Z etc for overlap
0043     std::string iRegStr(unsigned int iReg, unsigned int iSeed);
0044 
0045     //TC Name
0046     std::string TCName(unsigned int iSeed, unsigned int iTC);
0047 
0048     //Name of layer or disk, e.g. L1 or D1
0049     static std::string LayerName(unsigned int ilayer);
0050 
0051     //Tracklet projection name
0052     std::string TPROJName(unsigned int iSeed, unsigned int iTC, unsigned int ilayer, unsigned int ireg);
0053 
0054     //Projection router name
0055     std::string PRName(unsigned int ilayer, unsigned int ireg);
0056 
0057   private:
0058     //
0059     // Method to initialize the regions and VM in each layer
0060     //
0061     void initGeom();
0062 
0063     //
0064     // Builds the list of TE for each seeding combination
0065     //
0066     void buildTE();
0067 
0068     //
0069     // Builds the lists of TC for each seeding combination
0070     //
0071     void buildTC();
0072 
0073     //
0074     // Finds the projections needed for each seeding combination
0075     //
0076     void buildProjections();
0077 
0078     //
0079     // Helper function to determine if a pair of VM memories form valid TE
0080     //
0081     bool validTEPair(unsigned int iseed, unsigned int iTE1, unsigned int iTE2);
0082 
0083     //
0084     // Helper fcn. to get the layers/disks for a seed
0085     //
0086     std::pair<unsigned int, unsigned int> seedLayers(unsigned int iSeed);
0087 
0088     //
0089     // Helper fcn to get the radii of the two layers in a seed
0090     //
0091     std::pair<double, double> seedRadii(unsigned int iseed);
0092 
0093     //
0094     // Helper fcn to return the phi range of a projection of a tracklet from a TC
0095     //
0096     std::pair<double, double> seedPhiRange(double rproj, unsigned int iSeed, unsigned int iTC);
0097 
0098     //
0099     // Helper function to calculate the phi position of a seed at radius r that is formed
0100     // by two stubs at (r1,phi1) and (r2, phi2)
0101     //
0102     double phi(double r1, double phi1, double r2, double phi2, double r);
0103 
0104     //
0105     // Helper function to calculate rinv for two stubs at (r1,phi1) and (r2,phi2)
0106     //
0107     double rinv(double r1, double phi1, double r2, double phi2);
0108 
0109     //StubPair Name
0110     std::string SPName(unsigned int l1,
0111                        unsigned int ireg1,
0112                        unsigned int ivm1,
0113                        unsigned int l2,
0114                        unsigned int ireg2,
0115                        unsigned int ivm2,
0116                        unsigned int iseed);
0117 
0118     //StubPaur displaced name
0119     std::string SPDName(unsigned int l1,
0120                         unsigned int ireg1,
0121                         unsigned int ivm1,
0122                         unsigned int l2,
0123                         unsigned int ireg2,
0124                         unsigned int ivm2,
0125                         unsigned int l3,
0126                         unsigned int ireg3,
0127                         unsigned int ivm3,
0128                         unsigned int iseed);
0129 
0130     //Stub Triplet name
0131     std::string STName(unsigned int l1,
0132                        unsigned int ireg1,
0133                        unsigned int l2,
0134                        unsigned int ireg2,
0135                        unsigned int l3,
0136                        unsigned int ireg3,
0137                        unsigned int iseed,
0138                        unsigned int count);
0139 
0140     //TrackletEngine name
0141     std::string TEName(unsigned int l1,
0142                        unsigned int ireg1,
0143                        unsigned int ivm1,
0144                        unsigned int l2,
0145                        unsigned int ireg2,
0146                        unsigned int ivm2,
0147                        unsigned int iseed);
0148 
0149     //Triplet engine name
0150     std::string TREName(unsigned int l1,
0151                         unsigned int ireg1,
0152                         unsigned int l2,
0153                         unsigned int ireg2,
0154                         unsigned int iseed,
0155                         unsigned int count);
0156 
0157     //TrackletEngine displaced name
0158     std::string TEDName(unsigned int l1,
0159                         unsigned int ireg1,
0160                         unsigned int ivm1,
0161                         unsigned int l2,
0162                         unsigned int ireg2,
0163                         unsigned int ivm2,
0164                         unsigned int iseed);
0165 
0166     //Tracklet parameter memory name
0167     std::string TParName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc);
0168 
0169     //TrackletCalculator displaced name
0170     std::string TCDName(unsigned int l1, unsigned int l2, unsigned int l3, unsigned int itc);
0171 
0172     //TrackletProjection name
0173     std::string TPROJName(unsigned int l1,
0174                           unsigned int l2,
0175                           unsigned int l3,
0176                           unsigned int itc,
0177                           unsigned int projlay,
0178                           unsigned int projreg);
0179 
0180     //FitTrack module name
0181     std::string FTName(unsigned int l1, unsigned int l2, unsigned int l3);
0182 
0183     //TrackletCalculator name
0184     std::string TCNAme(unsigned int iseed, unsigned int iTC);
0185 
0186     //
0187     // This group of methods are used to print out the configuration as a file
0188     //
0189     void writeProjectionMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0190 
0191     void writeSPMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0192 
0193     void writeSPDMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0194 
0195     void writeAPMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0196 
0197     void writeCMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0198 
0199     void writeVMPROJMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0200 
0201     void writeFMMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0202 
0203     void writeASMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0204 
0205     void writeVMSMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0206 
0207     void writeTPARMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0208 
0209     void writeTFMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0210 
0211     void writeCTMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0212 
0213     void writeILMemories(std::ostream& os, std::ostream& memories, std::ostream& modules);
0214 
0215     //
0216     // Store constants extracted from Settings
0217     //
0218     unsigned int NSector_;  //Number of sectors
0219     double rcrit_;          //critical radius that defines the sector
0220 
0221     bool combinedmodules_;  //if true write configuration for combined modules
0222 
0223     bool extended_;  //if true write configuration for extended configuration
0224 
0225     double rinvmax_;         //Max value for valid rinv
0226     double rmaxdisk_;        //Maximim disk radius
0227     double zlength_;         //Maximim (abslute) z-positon in barrel
0228     double rmean_[N_LAYER];  //Mean layer radius
0229     double zmean_[N_DISK];   //Mean disk z-position
0230 
0231     double dphisectorHG_;  //Full sector width
0232 
0233     unsigned int NTC_[N_SEED_PROMPT];  //Number of TC per seeding combination
0234 
0235     unsigned int NRegions_[N_LAYER + N_DISK];                     //Regions (all stubs memories 6 layers +5 disks
0236     unsigned int NVMME_[N_LAYER + N_DISK];                        //Number of MEs (all stubs memories 6 layers +5 disks
0237     std::pair<unsigned int, unsigned int> NVMTE_[N_SEED_PROMPT];  //number of TEs for each seeding combination
0238 
0239     //Min and max phi for a phi region (e.g. all stubs)
0240     std::vector<std::pair<double, double> > allStubs_[N_LAYER + N_DISK];
0241 
0242     //Min and max phi for VM bin
0243     std::vector<std::pair<double, double> > VMStubsME_[N_LAYER + N_DISK];
0244 
0245     //Phi ranges for the stubs in the VM bins used in the pair in th TE
0246     std::pair<std::vector<std::pair<double, double> >, std::vector<std::pair<double, double> > >
0247         VMStubsTE_[N_SEED_PROMPT];
0248 
0249     //List of the TEs and the VM bins for each TE
0250     std::vector<std::pair<unsigned int, unsigned int> > TE_[N_SEED_PROMPT];
0251 
0252     //The TCs for each seeding combination
0253     std::vector<std::vector<unsigned int> > TC_[N_SEED_PROMPT];
0254 
0255     //The projections to each layer/disk from a seed and TC
0256     std::vector<std::vector<std::pair<unsigned int, unsigned int> > > projections_[N_LAYER + N_DISK];
0257 
0258     //Which matches are used for each seeding layer
0259     //                                                L1 L2 L3 L4 L5 L6 D1 D2 D3 D4 D5
0260     int matchport_[N_SEED_PROMPT][N_LAYER + N_DISK] = {{-1, -1, 1, 2, 3, 4, 4, 3, 2, 1, -1},       //L1L2
0261                                                        {1, -1, -1, 2, 3, -1, 4, 3, 2, 1, -1},      //L2L3
0262                                                        {1, 2, -1, -1, 3, 4, 4, 3, -1, -1, -1},     //L3L4
0263                                                        {1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1},   //L5L6
0264                                                        {1, 2, -1, -1, -1, -1, -1, -1, 2, 3, 4},    //D1D2
0265                                                        {1, -1, -1, -1, -1, -1, 2, 3, -1, -1, 4},   //D3D4
0266                                                        {-1, -1, -1, -1, -1, -1, -1, 1, 2, 3, 4},   //L1D1
0267                                                        {1, -1, -1, -1, -1, -1, -1, 2, 3, 4, -1}};  //L2D1
0268 
0269     //Settings
0270     const Settings& settings_;
0271   };
0272 }  // namespace trklet
0273 #endif