Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-06 02:53:44

0001 #ifndef L1TMTFOverlapParams_h
0002 #define L1TMTFOverlapParams_h
0003 
0004 #include <memory>
0005 #include <iostream>
0006 #include <vector>
0007 #include <cmath>
0008 
0009 #include "CondFormats/Serialization/interface/Serializable.h"
0010 #include "CondFormats/L1TObjects/interface/LUT.h"
0011 
0012 ///////////////////////////////////////
0013 ///////////////////////////////////////
0014 class L1TMuonOverlapParams {
0015 public:
0016   class Node {
0017   public:
0018     std::string type_;
0019     unsigned version_;
0020     l1t::LUT LUT_;
0021     std::vector<double> dparams_;
0022     std::vector<unsigned> uparams_;
0023     std::vector<int> iparams_;
0024     std::vector<std::string> sparams_;
0025     Node() {
0026       type_ = "unspecified";
0027       version_ = 0;
0028     }
0029     COND_SERIALIZABLE;
0030   };
0031 
0032   class LayerMapNode {
0033   public:
0034     ///short layer number used within OMTF emulator
0035     unsigned int hwNumber;
0036 
0037     ///logic numer of the layer
0038     unsigned int logicNumber;
0039 
0040     ///Is this a bending layers?
0041     bool bendingLayer;
0042 
0043     ///Login number of layer to which this layer is tied.
0044     ///I.e both layers have to fire to account a hit
0045     unsigned int connectedToLayer;
0046 
0047     LayerMapNode(void) : hwNumber(0), logicNumber(0), bendingLayer(false), connectedToLayer(0) {}
0048 
0049     COND_SERIALIZABLE;
0050   };
0051 
0052   class RefLayerMapNode {
0053   public:
0054     ///Reference layer number
0055     unsigned int refLayer;
0056 
0057     ///Corresponding logical layer number
0058     unsigned int logicNumber;
0059 
0060     RefLayerMapNode(void) : refLayer(0), logicNumber(0) {}
0061 
0062     COND_SERIALIZABLE;
0063   };
0064 
0065   class RefHitNode {
0066   public:
0067     unsigned int iInput;
0068     int iPhiMin, iPhiMax;
0069     unsigned int iRefHit;
0070     unsigned int iRefLayer;
0071     unsigned int iRegion;
0072 
0073     RefHitNode(void) : iInput(0), iPhiMin(0), iPhiMax(0), iRefHit(0), iRefLayer(0), iRegion(0) {}
0074 
0075     COND_SERIALIZABLE;
0076   };
0077 
0078   class LayerInputNode {
0079   public:
0080     unsigned int iFirstInput;
0081     unsigned int iLayer;
0082     unsigned int nInputs;
0083 
0084     LayerInputNode(void) : iFirstInput(0), iLayer(0), nInputs(0) {}
0085 
0086     COND_SERIALIZABLE;
0087   };
0088 
0089   enum { Version = 1 };
0090 
0091   // DO NOT ADD ENTRIES ANYWHERE BUT DIRECTLY BEFORE "NUM_OMTFPARAMNODES"
0092   enum {
0093     CHARGE = 0,
0094     ETA = 1,
0095     PT = 2,
0096     PDF = 3,
0097     MEANDISTPHI = 4,
0098     GENERAL = 5,
0099     SECTORS_START = 6,
0100     SECTORS_END = 7,
0101     DIST_PHI_SHIFT = 8,
0102     NUM_OMTFPARAMNODES = 9
0103   };
0104 
0105   // General configuration parameters indexes
0106   enum {
0107     GENERAL_ADDRBITS = 0,
0108     GENERAL_VALBITS = 1,
0109     GENERAL_HITSPERLAYER = 2,
0110     GENERAL_PHIBITS = 3,
0111     GENERAL_PHIBINS = 4,
0112     GENERAL_NREFHITS = 5,
0113     GENERAL_NTESTREFHITS = 6,
0114     GENERAL_NPROCESSORS = 7,
0115     GENERAL_NLOGIC_REGIONS = 8,
0116     GENERAL_NINPUTS = 9,
0117     GENERAL_NLAYERS = 10,
0118     GENERAL_NREFLAYERS = 11,
0119     GENERAL_NGOLDENPATTERNS = 12,
0120     GENERAL_NCONFIG = 13
0121   };
0122 
0123   L1TMuonOverlapParams() {
0124     fwVersion_ = Version;
0125     pnodes_.resize(NUM_OMTFPARAMNODES);
0126   }
0127   ~L1TMuonOverlapParams() {}
0128 
0129   // Firmware version
0130   unsigned fwVersion() const { return fwVersion_; }
0131   void setFwVersion(unsigned fwVersion) { fwVersion_ = fwVersion; }
0132 
0133   ///General definitions
0134   const std::vector<int> *generalParams() const { return &pnodes_[GENERAL].iparams_; }
0135   void setGeneralParams(const std::vector<int> &paramsVec) {
0136     pnodes_[GENERAL].type_ = "INT";
0137     pnodes_[GENERAL].iparams_ = paramsVec;
0138   }
0139 
0140   ///Access to specific general settings.
0141   int nPdfAddrBits() const { return pnodes_[GENERAL].iparams_[GENERAL_ADDRBITS]; };
0142 
0143   int nPdfValBits() const { return pnodes_[GENERAL].iparams_[GENERAL_VALBITS]; };
0144 
0145   int nHitsPerLayer() const { return pnodes_[GENERAL].iparams_[GENERAL_HITSPERLAYER]; };
0146 
0147   int nPhiBits() const { return pnodes_[GENERAL].iparams_[GENERAL_PHIBITS]; };
0148 
0149   int nPhiBins() const { return pnodes_[GENERAL].iparams_[GENERAL_PHIBINS]; };
0150 
0151   int nRefHits() const { return pnodes_[GENERAL].iparams_[GENERAL_NREFHITS]; };
0152 
0153   int nTestRefHits() const { return pnodes_[GENERAL].iparams_[GENERAL_NTESTREFHITS]; };
0154 
0155   int nProcessors() const { return pnodes_[GENERAL].iparams_[GENERAL_NPROCESSORS]; };
0156 
0157   int nLogicRegions() const { return pnodes_[GENERAL].iparams_[GENERAL_NLOGIC_REGIONS]; };
0158 
0159   int nInputs() const { return pnodes_[GENERAL].iparams_[GENERAL_NINPUTS]; };
0160 
0161   int nLayers() const { return pnodes_[GENERAL].iparams_[GENERAL_NLAYERS]; };
0162 
0163   int nRefLayers() const { return pnodes_[GENERAL].iparams_[GENERAL_NREFLAYERS]; };
0164 
0165   int nGoldenPatterns() const { return pnodes_[GENERAL].iparams_[GENERAL_NGOLDENPATTERNS]; };
0166 
0167   ///Connections definitions
0168   void setLayerMap(const std::vector<LayerMapNode> &aVector) { layerMap_ = aVector; }
0169 
0170   void setRefLayerMap(const std::vector<RefLayerMapNode> &aVector) { refLayerMap_ = aVector; }
0171 
0172   void setRefHitMap(const std::vector<RefHitNode> &aVector) { refHitMap_ = aVector; };
0173 
0174   void setGlobalPhiStartMap(const std::vector<int> &aVector) { globalPhiStart_ = aVector; };
0175 
0176   void setLayerInputMap(const std::vector<LayerInputNode> &aVector) { layerInputMap_ = aVector; };
0177 
0178   void setConnectedSectorsStart(const std::vector<int> &aVector) {
0179     pnodes_[SECTORS_START].type_ = "INT";
0180     pnodes_[SECTORS_START].iparams_ = aVector;
0181   };
0182 
0183   void setConnectedSectorsEnd(const std::vector<int> &aVector) {
0184     pnodes_[SECTORS_END].type_ = "INT";
0185     pnodes_[SECTORS_END].iparams_ = aVector;
0186   };
0187 
0188   const std::vector<LayerMapNode> *layerMap() const { return &layerMap_; };
0189 
0190   const std::vector<RefLayerMapNode> *refLayerMap() const { return &refLayerMap_; };
0191 
0192   const std::vector<RefHitNode> *refHitMap() const { return &refHitMap_; };
0193 
0194   const std::vector<int> *globalPhiStartMap() const { return &globalPhiStart_; };
0195 
0196   const std::vector<LayerInputNode> *layerInputMap() const { return &layerInputMap_; };
0197 
0198   const std::vector<int> *connectedSectorsStart() const { return &pnodes_[SECTORS_START].iparams_; };
0199 
0200   const std::vector<int> *connectedSectorsEnd() const { return &pnodes_[SECTORS_END].iparams_; };
0201 
0202   ///Golden Patterns definitions
0203   const l1t::LUT *chargeLUT() const { return &pnodes_[CHARGE].LUT_; }
0204   const l1t::LUT *etaLUT() const { return &pnodes_[ETA].LUT_; }
0205   const l1t::LUT *ptLUT() const { return &pnodes_[PT].LUT_; }
0206   const l1t::LUT *pdfLUT() const { return &pnodes_[PDF].LUT_; }
0207   const l1t::LUT *meanDistPhiLUT() const { return &pnodes_[MEANDISTPHI].LUT_; }
0208 
0209   /**
0210    * return nullptr if the DistPhiShiftLUT is not available in the given L1TMuonOverlapParamsRcd,
0211    * which is the case for the fwVersion <= 0x6
0212    */
0213   const l1t::LUT *distPhiShiftLUT() const {
0214     if (pnodes_.size() >= (DIST_PHI_SHIFT + 1))
0215       return &pnodes_[DIST_PHI_SHIFT].LUT_;
0216     else
0217       return nullptr;
0218   }
0219 
0220   void setChargeLUT(const l1t::LUT &lut) {
0221     pnodes_[CHARGE].type_ = "LUT";
0222     pnodes_[CHARGE].LUT_ = lut;
0223   }
0224   void setEtaLUT(const l1t::LUT &lut) {
0225     pnodes_[ETA].type_ = "LUT";
0226     pnodes_[ETA].LUT_ = lut;
0227   }
0228   void setPtLUT(const l1t::LUT &lut) {
0229     pnodes_[PT].type_ = "LUT";
0230     pnodes_[PT].LUT_ = lut;
0231   }
0232   void setPdfLUT(const l1t::LUT &lut) {
0233     pnodes_[PDF].type_ = "LUT";
0234     pnodes_[PDF].LUT_ = lut;
0235   }
0236   void setMeanDistPhiLUT(const l1t::LUT &lut) {
0237     pnodes_[MEANDISTPHI].type_ = "LUT";
0238     pnodes_[MEANDISTPHI].LUT_ = lut;
0239   }
0240   void setDistPhiShiftLUT(const l1t::LUT &lut) {
0241     pnodes_[DIST_PHI_SHIFT].type_ = "LUT";
0242     pnodes_[DIST_PHI_SHIFT].LUT_ = lut;
0243   }
0244 
0245 private:
0246   ///Version of firmware configuration
0247   unsigned fwVersion_;
0248 
0249   ///vector of LUT like parameters
0250   std::vector<Node> pnodes_;
0251 
0252   ///Vector of structs representing definitions of measurement layers.
0253   std::vector<LayerMapNode> layerMap_;
0254 
0255   ///Vector of structs representing definitins of reference layers
0256   ///in terms of logic measurement layers numbers.
0257   std::vector<RefLayerMapNode> refLayerMap_;
0258 
0259   ///Vector of RefHitNode defining assignenemt of
0260   ///reference hits to logical regions.
0261   ///definitions for all processor are serialized in a single vector.
0262   std::vector<RefHitNode> refHitMap_;
0263 
0264   ///Vector of global phi of processor beggining in each reference layer.
0265   ///All processors are serialized in a single vector.
0266   std::vector<int> globalPhiStart_;
0267 
0268   ///Vector of all definitions of input ranges for given
0269   ///logic region.
0270   ///All processors and all regions are serialized in a single vector.
0271   std::vector<LayerInputNode> layerInputMap_;
0272 
0273   COND_SERIALIZABLE;
0274 };
0275 #endif