Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-06 02:54:06

0001 #ifndef L1T_OmtfP1_GoldenPatternBase_H
0002 #define L1T_OmtfP1_GoldenPatternBase_H
0003 
0004 #include "boost/multi_array.hpp"
0005 #include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStub.h"
0006 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternResult.h"
0007 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h"
0008 #include <ostream>
0009 #include <vector>
0010 
0011 //////////////////////////////////
0012 // Key
0013 //////////////////////////////////
0014 struct Key {
0015   Key(int iEta = 99, unsigned int iPt = 0, int iCharge = 0, unsigned int iNumber = 999)
0016       : theEtaCode(iEta), thePt(iPt), theCharge(iCharge), theNumber(iNumber) {}
0017 
0018   Key(int iEta, unsigned int iPt, int iCharge, unsigned int iNumber, unsigned int group, unsigned int indexInGroup)
0019       : theEtaCode(iEta),
0020         thePt(iPt),
0021         theCharge(iCharge),
0022         theNumber(iNumber),
0023         theGroup(group),
0024         theIndexInGroup(indexInGroup) {}
0025 
0026   inline bool operator<(const Key& o) const { return (theNumber < o.theNumber); }
0027 
0028   bool operator==(const Key& o) const {
0029     return theEtaCode == o.theEtaCode && thePt == o.thePt && theCharge == o.theCharge && theNumber == o.theNumber;
0030   }
0031 
0032   friend std::ostream& operator<<(std::ostream& out, const Key& o);
0033 
0034   unsigned int number() const { return theNumber; }
0035 
0036   int theEtaCode;
0037 
0038   //hardware pt, ptInGeV = (thePt-1) * 0.5GeV, where ptInGeV denotes the lover edge of the pt range cover by this pattern
0039   unsigned int thePt;
0040 
0041   int theCharge;
0042   unsigned int theNumber;
0043 
0044   //the index of the patterns group, up to 4 patterns can be grouped together, they have then the same MeanDistPhi and DistPhiBitShift
0045   unsigned int theGroup = 0;
0046 
0047   unsigned int theIndexInGroup = 1;  //starts from 1, as in xml
0048 
0049   void setPt(int pt) { thePt = pt; }
0050 
0051   void setGroup(int group) { theGroup = group; }
0052 
0053   void setIndexInGroup(unsigned int indexInGroup) { theIndexInGroup = indexInGroup; }
0054 
0055   unsigned int getHwPatternNumber() const { return theGroup * 4 + theIndexInGroup - 1; }
0056 };
0057 //////////////////////////////////
0058 // Golden Pattern
0059 //////////////////////////////////
0060 
0061 class GoldenPatternBase {
0062 public:
0063   typedef std::vector<int> vector1D;
0064 
0065   typedef boost::multi_array<GoldenPatternResult, 2> resultsArrayType;
0066   //
0067   // IGoldenPatterns methods
0068   //
0069   GoldenPatternBase(const Key& aKey);
0070 
0071   GoldenPatternBase(const Key& aKey, const OMTFConfiguration* omtfConfig);
0072 
0073   virtual ~GoldenPatternBase() {}
0074 
0075   virtual void setConfig(const OMTFConfiguration* omtfConfig);
0076 
0077   const OMTFConfiguration* getConfig() const { return myOmtfConfig; }
0078 
0079   virtual Key& key() { return theKey; }
0080 
0081   virtual int meanDistPhiValue(unsigned int iLayer, unsigned int iRefLayer, int refLayerPhiB = 0) const = 0;
0082 
0083   virtual PdfValueType pdfValue(unsigned int iLayer,
0084                                 unsigned int iRefLayer,
0085                                 unsigned int iBin,
0086                                 int refLayerPhiB = 0) const = 0;
0087 
0088   virtual void setMeanDistPhiValue(int value,
0089                                    unsigned int iLayer,
0090                                    unsigned int iRefLayer,
0091                                    unsigned int paramIndex = 0) = 0;
0092 
0093   virtual void setPdfValue(
0094       PdfValueType value, unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin, int refLayerPhiB = 0) = 0;
0095 
0096   virtual int getDistPhiBitShift(unsigned int iLayer, unsigned int iRefLayer) const = 0;
0097 
0098   virtual void setDistPhiBitShift(int value, unsigned int iLayer, unsigned int iRefLayer) = 0;
0099 
0100   ///Process single measurement layer with a single ref layer
0101   ///Method should be thread safe
0102   virtual StubResult process1Layer1RefLayer(unsigned int iRefLayer,
0103                                             unsigned int iLayer,
0104                                             MuonStubPtrs1D layerStubs,
0105                                             const MuonStubPtr refStub);
0106 
0107   ///Propagate phi from given reference layer to MB2 or ME2
0108   ///ME2 is used if eta of reference hit is larger than 1.1
0109   ///expressed in integer MicroGMT scale: 1.1/2.61*240 = 101
0110   virtual int propagateRefPhi(int phiRef, int etaRef, unsigned int iRefLayer) = 0;
0111 
0112   resultsArrayType& getResults() { return results; }
0113 
0114   ///last step of the event processing, before sorting and ghost busting
0115   virtual void finalise(unsigned int procIndx);
0116 
0117 protected:
0118   ///Pattern kinematic identification (iEta,iPt,iCharge)
0119   Key theKey;
0120 
0121   const OMTFConfiguration* myOmtfConfig;
0122 
0123   resultsArrayType results;
0124 };
0125 
0126 template <class GoldenPatternType>
0127 using GoldenPatternVec = std::vector<std::unique_ptr<GoldenPatternType> >;
0128 //////////////////////////////////
0129 //////////////////////////////////
0130 #endif