Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:56

0001 //////////////////////////////////////////////////////////////////
0002 // TrackletLUT
0003 // This class writes out the variuos look up tables
0004 // for all modules.
0005 //////////////////////////////////////////////////////////////////
0006 //
0007 // This class has methods to build the LUT (LookUp Tables) used by the track finding
0008 // It also provides a method to write out the file for use by the firmware implementation
0009 //
0010 //
0011 #ifndef L1Trigger_TrackFindingTracklet_interface_TrackletLUT_h
0012 #define L1Trigger_TrackFindingTracklet_interface_TrackletLUT_h
0013 
0014 #include <string>
0015 #include <vector>
0016 #include <string>
0017 
0018 #include "L1Trigger/TrackTrigger/interface/Setup.h"
0019 
0020 class Setup;
0021 
0022 namespace trklet {
0023 
0024   class Settings;
0025 
0026   class TrackletLUT {
0027   public:
0028     TrackletLUT(const Settings& settings);
0029 
0030     TrackletLUT& operator=(const TrackletLUT& other) {
0031       name_ = other.name_;
0032       table_ = other.table_;
0033       nbits_ = other.nbits_;
0034       positive_ = other.positive_;
0035 
0036       return *this;
0037     }
0038 
0039     ~TrackletLUT() = default;
0040 
0041     enum MatchType {
0042       barrelphi,   // write LUT for barrel phi
0043       barrelz,     // write LUT for barrel z
0044       disk2Sphi,   // write LUT for disk 2S phi
0045       disk2Sr,     // write LUT for disk 2S r
0046       diskPSphi,   // write LUT for disk PS phi
0047       diskPSr,     // write LUT for disk PS r
0048       alphainner,  // write alpha corrections LUT for 2S (inner)
0049       alphaouter,  // write alpha corrections LUT for 2S (outer)
0050       rSSinner,    // write r LUT for 2S (inner)
0051       rSSouter     // write r LUT for 2S (inner)
0052     };
0053 
0054     //region only used for name - should be removed
0055     void initmatchcut(unsigned int layerdisk, MatchType type, unsigned int region);
0056 
0057     //Builds LUT that for each TP returns if the phi differences between inner and outer
0058     //stub is consistent with the pT cut and the stub pair should be kept.
0059     void initTPlut(bool fillInner,
0060                    unsigned int iSeed,
0061                    unsigned int layerdisk1,
0062                    unsigned int layerdisk2,
0063                    unsigned int nbitsfinephidiff,
0064                    unsigned int iTP);
0065 
0066     //Builds a lut for the TP ro decide if the region should be used. This is used in the
0067     //first stage of the TP to decide which regions in the outer layer an inner stub needs
0068     //to be combined with
0069     void initTPregionlut(unsigned int iSeed,
0070                          unsigned int layerdisk1,
0071                          unsigned int layerdisk2,
0072                          unsigned int iAllStub,
0073                          unsigned int nbitsfinephidiff,
0074                          unsigned int nbitsfinephi,
0075                          const TrackletLUT& tplutinner,
0076                          unsigned int iTP);
0077 
0078     //Stub pt consistency for tracklet engine
0079     void initteptlut(bool fillInner,
0080                      bool fillTEMem,
0081                      unsigned int iSeed,
0082                      unsigned int layerdisk1,
0083                      unsigned int layerdisk2,
0084                      unsigned int innerphibits,
0085                      unsigned int outerphibits,
0086                      double innerphimin,
0087                      double innerphimax,
0088                      double outerphimin,
0089                      double outerphimax,
0090                      const std::string& innermem,
0091                      const std::string& outermem);
0092 
0093     //This LUT uses the phi derivative known in the projection to calculate the corresponding bend
0094     void initProjectionBend(double k_phider, unsigned int idisk, unsigned int nrbits, unsigned int nphiderbits);
0095 
0096     //This LUT implements consistence check for match engine to check that stub bend is consistent with projection
0097     void initBendMatch(unsigned int layerdisk);
0098 
0099     void initProjectionDiskRadius(int nrbits);
0100 
0101     enum VMRTableType { me, disk, inner, inneroverlap, innerthird };
0102 
0103     //In the VMR we used the position of the stub (r, z) to calculate the bin and fine rz position the stub has
0104     //region only used for name - should be removed
0105     void initVMRTable(unsigned int layerdisk, VMRTableType type, int region = -1);
0106 
0107     //Used in barrel to calculate the phi position of a stub at the nominal radis of the layer based on the stub radial
0108     //psotion and bend
0109     void initPhiCorrTable(unsigned int layerdisk, unsigned int rbits);
0110 
0111     //writes out the LUT in standared format for firmware
0112     void writeTable() const;
0113 
0114     //Evaluate the LUT
0115     int lookup(unsigned int index) const;
0116 
0117     unsigned int size() const { return table_.size(); }
0118 
0119   private:
0120     const Settings& settings_;
0121     const tt::Setup* setup_;
0122 
0123     //Determine bend/bend cuts in LUT regions
0124     std::vector<const tt::SensorModule*> getSensorModules(unsigned int layerdisk,
0125                                                           bool isPS,
0126                                                           std::array<double, 2> tan_range = {{-1, -1}},
0127                                                           unsigned int nzbins = 1,
0128                                                           unsigned int zbin = 0);
0129 
0130     std::array<double, 2> getTanRange(const std::vector<const tt::SensorModule*>& sensorModules);
0131 
0132     std::vector<std::array<double, 2>> getBendCut(unsigned int layerdisk,
0133                                                   const std::vector<const tt::SensorModule*>& sensorModules,
0134                                                   bool isPS,
0135                                                   double FEbendcut = 0);
0136 
0137     int getphiCorrValue(
0138         unsigned int layerdisk, double bend, unsigned int irbin, double rmean, double dr, double drmax) const;
0139 
0140     int getVMRLookup(unsigned int layerdisk, double z, double r, double dz, double dr, int iseed = -1) const;
0141 
0142     std::string name_;
0143 
0144     std::vector<int> table_;
0145 
0146     unsigned int nbits_;
0147 
0148     bool positive_;
0149   };
0150 };  // namespace trklet
0151 #endif