Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:37:00

0001 #ifndef L1T_OmtfP1_GoldenPattern_H
0002 #define L1T_OmtfP1_GoldenPattern_H
0003 
0004 #include "boost/multi_array/base.hpp"
0005 #include "boost/multi_array.hpp"
0006 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternBase.h"
0007 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h"
0008 #include <ostream>
0009 #include <vector>
0010 
0011 //////////////////////////////////
0012 // Golden Pattern
0013 //////////////////////////////////
0014 
0015 class GoldenPattern : public GoldenPatternBase {
0016 public:
0017   typedef boost::multi_array<PdfValueType, 3> pdfArrayType;
0018   typedef boost::multi_array<short, 3> meanDistPhiArrayType;
0019   //
0020   // GoldenPatterns methods
0021   //
0022   GoldenPattern(const Key& aKey, unsigned int nLayers, unsigned int nRefLayers, unsigned int nPdfAddrBits)
0023       : GoldenPatternBase(aKey),
0024         pdfAllRef(boost::extents[nLayers][nRefLayers][1 << nPdfAddrBits]),
0025         meanDistPhi(boost::extents[nLayers][nRefLayers][2]),
0026         distPhiBitShift(boost::extents[nLayers][nRefLayers]) {
0027     reset();
0028   }
0029 
0030   GoldenPattern(const Key& aKey, const OMTFConfiguration* omtfConfig)
0031       : GoldenPatternBase(aKey, omtfConfig),
0032         pdfAllRef(boost::extents[omtfConfig->nLayers()][omtfConfig->nRefLayers()][omtfConfig->nPdfBins()]),
0033         meanDistPhi(boost::extents[omtfConfig->nLayers()][omtfConfig->nRefLayers()][2]),
0034         distPhiBitShift(boost::extents[omtfConfig->nLayers()][omtfConfig->nRefLayers()]) {
0035     reset();
0036   }
0037 
0038   ~GoldenPattern() override {}
0039 
0040   virtual void setMeanDistPhi(const meanDistPhiArrayType& aMeanDistPhi) { meanDistPhi = aMeanDistPhi; }
0041 
0042   virtual const meanDistPhiArrayType& getMeanDistPhi() const { return meanDistPhi; }
0043 
0044   virtual const pdfArrayType& getPdf() const { return pdfAllRef; }
0045 
0046   virtual void setPdf(pdfArrayType& aPdf) { pdfAllRef = aPdf; }
0047 
0048   int meanDistPhiValue(unsigned int iLayer, unsigned int iRefLayer, int refLayerPhiB = 0) const override;
0049 
0050   PdfValueType pdfValue(unsigned int iLayer,
0051                         unsigned int iRefLayer,
0052                         unsigned int iBin,
0053                         int refLayerPhiB = 0) const override {
0054     return pdfAllRef[iLayer][iRefLayer][iBin];
0055   }
0056 
0057   void setMeanDistPhiValue(int value,
0058                            unsigned int iLayer,
0059                            unsigned int iRefLayer,
0060                            unsigned int paramIndex = 0) override {
0061     meanDistPhi[iLayer][iRefLayer][paramIndex] = value;
0062   }
0063 
0064   void setPdfValue(PdfValueType value,
0065                    unsigned int iLayer,
0066                    unsigned int iRefLayer,
0067                    unsigned int iBin,
0068                    int refLayerPhiB = 0) override {
0069     pdfAllRef[iLayer][iRefLayer][iBin] = value;
0070   }
0071 
0072   int getDistPhiBitShift(unsigned int iLayer, unsigned int iRefLayer) const override {
0073     return distPhiBitShift[iLayer][iRefLayer];
0074   }
0075 
0076   void setDistPhiBitShift(int value, unsigned int iLayer, unsigned int iRefLayer) override {
0077     distPhiBitShift[iLayer][iRefLayer] = value;
0078   }
0079 
0080   friend std::ostream& operator<<(std::ostream& out, const GoldenPattern& aPattern);
0081 
0082   ///Reset contents of all data vectors, keeping the vectors size
0083   virtual void reset();
0084 
0085   ///Propagate phi from given reference layer to MB2 or ME2
0086   ///expressed in integer MicroGMT scale: 1.1/2.61*240 = 101
0087   int propagateRefPhi(int phiRef, int etaRef, unsigned int iRefLayer) override;
0088 
0089 protected:
0090   ///Distributions for all reference layers
0091   ///First index: measurement layer number
0092   ///Second index: refLayer number
0093   ///Third index: pdf bin number within layer
0094   pdfArrayType pdfAllRef;
0095 
0096   ///Mean positions in each layer
0097   ///First index: measurement layer number
0098   ///Second index: refLayer number
0099   ///Third index: index = 0 - a0, index = 1 - a1 for the linear fit meanDistPhi = a0 + a1 * phi_b
0100   meanDistPhiArrayType meanDistPhi;
0101 
0102   ///distPhi resolution can be reduced to reduce the number of bit on the LUT input
0103   ///distPhi = distPhi<<distPhiBitShift[layer][refLayer] (i.e. division by 2)
0104   ///First index: measurement layer number
0105   ///Second index: refLayer number
0106   boost::multi_array<short, 2> distPhiBitShift;
0107 };
0108 
0109 class GoldenPatternWithThresh : public GoldenPattern {
0110 private:
0111   std::vector<PdfValueType> thresholds;
0112 
0113 public:
0114   //
0115   // GoldenPatterns methods
0116   //
0117   GoldenPatternWithThresh(const Key& aKey, unsigned int nLayers, unsigned int nRefLayers, unsigned int nPdfAddrBits)
0118       : GoldenPattern(aKey, nLayers, nRefLayers, nPdfAddrBits), thresholds(nRefLayers, 0) {}
0119 
0120   GoldenPatternWithThresh(const Key& aKey, const OMTFConfiguration* omtfConfig)
0121       : GoldenPattern(aKey, omtfConfig), thresholds(myOmtfConfig->nRefLayers(), 0) {}
0122 
0123   ~GoldenPatternWithThresh() override {}
0124 
0125   PdfValueType getThreshold(unsigned int iRefLayer) const { return thresholds.at(iRefLayer); }
0126 
0127   void setThresholds(std::vector<PdfValueType>& tresholds) { this->thresholds = tresholds; }
0128 
0129   void setThreshold(unsigned int iRefLayer, PdfValueType treshold) { this->thresholds[iRefLayer] = treshold; }
0130 };
0131 //////////////////////////////////
0132 //////////////////////////////////
0133 #endif