Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef OMTF_GoldenPattern_H
0002 #define OMTF_GoldenPattern_H
0003 
0004 #include <vector>
0005 #include <ostream>
0006 
0007 #include "L1Trigger/L1TMuonOverlap/interface/OMTFinput.h"
0008 
0009 class OMTFConfigMaker;
0010 class OMTFProcessor;
0011 class OMTFConfiguration;
0012 //////////////////////////////////
0013 // Key
0014 //////////////////////////////////
0015 struct Key {
0016   Key(int iEta = 99, unsigned int iPt = 0, int iCharge = 0, unsigned int iNumber = 999)
0017       : theEtaCode(iEta), thePtCode(iPt), theCharge(iCharge), theNumber(iNumber) {}
0018 
0019   inline bool operator<(const Key &o) const { return (theNumber < o.theNumber); }
0020 
0021   bool operator==(const Key &o) const {
0022     return theEtaCode == o.theEtaCode && thePtCode == o.thePtCode && theCharge == o.theCharge &&
0023            theNumber == o.theNumber;
0024   }
0025 
0026   friend std::ostream &operator<<(std::ostream &out, const Key &o) {
0027     out << "Key_" << o.theNumber << ": (eta=" << o.theEtaCode << ", pt=" << o.thePtCode << ", charge=" << o.theCharge
0028         << ")";
0029     return out;
0030   }
0031 
0032   unsigned int number() const { return theNumber; }
0033 
0034   int theEtaCode;
0035   unsigned int thePtCode;
0036   int theCharge;
0037   unsigned int theNumber;
0038 };
0039 //////////////////////////////////
0040 // Golden Pattern
0041 //////////////////////////////////
0042 class OMTFinput;
0043 
0044 class GoldenPattern {
0045 public:
0046   typedef std::vector<int> vector1D;
0047   typedef std::vector<vector1D> vector2D;
0048   typedef std::vector<vector2D> vector3D;
0049   typedef std::pair<int, bool> layerResult;
0050 
0051   //
0052   // GoldenPatterns methods
0053   //
0054   GoldenPattern(const Key &aKey, const OMTFConfiguration *omtfConfig) : theKey(aKey), myOmtfConfig(omtfConfig) {}
0055 
0056   Key key() const { return theKey; }
0057 
0058   void setMeanDistPhi(const vector2D &aMeanDistPhi) { meanDistPhi = aMeanDistPhi; }
0059 
0060   const vector2D &getMeanDistPhi() const { return meanDistPhi; }
0061 
0062   const vector3D &getPdf() const { return pdfAllRef; }
0063 
0064   void setPdf(const vector3D &aPdf) { pdfAllRef = aPdf; }
0065 
0066   int meanDistPhiValue(unsigned int iLayer, unsigned int iRefLayer) const { return meanDistPhi[iLayer][iRefLayer]; }
0067 
0068   int pdfValue(unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin) const {
0069     return pdfAllRef[iLayer][iRefLayer][iBin];
0070   }
0071 
0072   ///Process single measurement layer with a single ref layer
0073   ///Method should be thread safe
0074   GoldenPattern::layerResult process1Layer1RefLayer(unsigned int iRefLayer,
0075                                                     unsigned int iLayer,
0076                                                     const int refPhi,
0077                                                     const OMTFinput::vector1D &layerHits);
0078 
0079   friend std::ostream &operator<<(std::ostream &out, const GoldenPattern &aPattern);
0080 
0081   ///Add a single count to the relevant pdf bin in three dimensions
0082   void addCount(unsigned int iRefLayer, unsigned int iLayer, const int refPhi, const OMTFinput::vector1D &layerHits);
0083 
0084   ///Reset contents of all data vectors, keeping the vectors size
0085   void reset();
0086 
0087   ///Normalise event counts in mean dist phi, and pdf vectors to get
0088   ///the real values of meand dist phi and probability.
0089   ///The pdf width is passed to this method, since the width stored in
0090   ///configuration is extended during the pattern making phase.
0091   void normalise(unsigned int nPdfAddrBits);
0092 
0093   ///Propagate phi from given reference layer to MB2 or ME2
0094   ///ME2 is used if eta of reference hit is larger than 1.1
0095   ///expressed in ingerer MicroGMT scale: 1.1/2.61*240 = 101
0096   int propagateRefPhi(int phiRef, int etaRef, unsigned int iRefLayer);
0097 
0098   ///Check if the GP has any counts in any of referecne layers;
0099   bool hasCounts();
0100 
0101 private:
0102   ///Pattern kinematical identification (iEta,iPt,iCharge)
0103   Key theKey;
0104 
0105   ///Distributions for all reference layers
0106   ///First index: measurement layer number
0107   ///Second index: refLayer number
0108   ///Third index: pdf bin number within layer
0109   vector3D pdfAllRef;
0110 
0111   ///Mean positions in each layer
0112   ///First index: measurement layer number
0113   ///Second index: refLayer number
0114   vector2D meanDistPhi;
0115 
0116   ///Vector holding number of counts.
0117   ///Used for making the patterns
0118   vector2D meanDistPhiCounts;
0119 
0120   const OMTFConfiguration *myOmtfConfig;
0121 };
0122 //////////////////////////////////
0123 //////////////////////////////////
0124 #endif