Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef OMTF_OMTFConfiguration_H
0002 #define OMTF_OMTFConfiguration_H
0003 
0004 #include <map>
0005 #include <set>
0006 #include <vector>
0007 #include <ostream>
0008 #include <memory>
0009 
0010 #include "CondFormats/L1TObjects/interface/L1TMuonOverlapParams.h"
0011 
0012 namespace edm {
0013   class ParameterSet;
0014 }
0015 
0016 class RefHitDef {
0017 public:
0018   //FIXME: default values should be sonnected to configuration values
0019   RefHitDef(unsigned int aInput = 15,
0020             int aPhiMin = 5760,
0021             int aPhiMax = 5760,
0022             unsigned int aRegion = 99,
0023             unsigned int aRefLayer = 99);
0024 
0025 public:
0026   bool fitsRange(int iPhi) const;
0027 
0028   ///Hit input number within a cone
0029   unsigned int iInput;
0030 
0031   ///Region number assigned to this referecne hit
0032   unsigned int iRegion;
0033 
0034   ///Reference layer logic number (0-7)
0035   unsigned int iRefLayer;
0036 
0037   ///Local to processor phi range.
0038   ///Hit has to fit into this range to be assigned to this iRegion;
0039   std::pair<int, int> range;
0040 
0041   friend std::ostream& operator<<(std::ostream& out, const RefHitDef& aRefHitDef);
0042 };
0043 
0044 class OMTFConfiguration {
0045 public:
0046   typedef std::vector<std::pair<unsigned int, unsigned int> > vector1D_pair;
0047   typedef std::vector<vector1D_pair> vector2D_pair;
0048   typedef std::vector<vector2D_pair> vector3D_pair;
0049 
0050   typedef std::vector<int> vector1D;
0051   typedef std::vector<vector1D> vector2D;
0052   typedef std::vector<vector2D> vector3D;
0053   typedef std::vector<vector3D> vector4D;
0054 
0055   OMTFConfiguration() { ; };
0056 
0057   void configure(const L1TMuonOverlapParams* omtfParams);
0058 
0059   void initCounterMatrices();
0060 
0061   ///Find logic region number using first input number
0062   ///and then local phi value. The input and phi
0063   ///ranges are taken from DB.
0064   unsigned int getRegionNumberFromMap(unsigned int iInput, unsigned int iRefLayer, int iPhi) const;
0065 
0066   ///Check if given referecne hit is
0067   ///in phi range for some logic cone.
0068   ///Care is needed arounf +Pi and +2Pi points
0069   bool isInRegionRange(int iPhiStart, unsigned int coneSize, int iPhi) const;
0070 
0071   ///Return global phi for beggining of given processor
0072   ///Uses minim phi over all reference layers.
0073   int globalPhiStart(unsigned int iProcessor) const;
0074 
0075   ///Return layer number encoding subsystem, and
0076   ///station number in a simple formula:
0077   /// aLayer+100*detId.subdetId()
0078   ///where aLayer is a layer number counting from vertex
0079   uint32_t getLayerNumber(uint32_t rawId) const;
0080 
0081   unsigned int fwVersion() const { return (rawParams.fwVersion() >> 16) & 0xFFFF; };
0082   unsigned int patternsVersion() const { return rawParams.fwVersion() & 0xFFFF; };
0083 
0084   const L1TMuonOverlapParams* getRawParams() const { return &rawParams; };
0085 
0086   float minPdfVal() const { return 0.001; };
0087   unsigned int nLayers() const { return rawParams.nLayers(); };
0088   unsigned int nHitsPerLayer() const { return rawParams.nHitsPerLayer(); };
0089   unsigned int nRefLayers() const { return rawParams.nRefLayers(); };
0090   unsigned int nPhiBits() const { return rawParams.nPhiBits(); };
0091   unsigned int nPdfAddrBits() const { return rawParams.nPdfAddrBits(); };
0092   unsigned int nPdfValBits() const { return rawParams.nPdfValBits(); };
0093   unsigned int nPhiBins() const { return rawParams.nPhiBins(); };
0094   unsigned int nRefHits() const { return rawParams.nRefHits(); };
0095   unsigned int nTestRefHits() const { return rawParams.nTestRefHits(); };
0096   unsigned int nProcessors() const { return rawParams.nProcessors(); };
0097   unsigned int nLogicRegions() const { return rawParams.nLogicRegions(); };
0098   unsigned int nInputs() const { return rawParams.nInputs(); };
0099   unsigned int nGoldenPatterns() const { return rawParams.nGoldenPatterns(); };
0100 
0101   const std::map<int, int>& getHwToLogicLayer() const { return hwToLogicLayer; }
0102   const std::map<int, int>& getLogicToHwLayer() const { return logicToHwLayer; }
0103   const std::map<int, int>& getLogicToLogic() const { return logicToLogic; }
0104   const std::set<int>& getBendingLayers() const { return bendingLayers; }
0105   const std::vector<int>& getRefToLogicNumber() const { return refToLogicNumber; }
0106 
0107   const std::vector<unsigned int>& getBarrelMin() const { return barrelMin; }
0108   const std::vector<unsigned int>& getBarrelMax() const { return barrelMax; }
0109   const std::vector<unsigned int>& getEndcap10DegMin() const { return endcap10DegMin; }
0110   const std::vector<unsigned int>& getEndcap10DegMax() const { return endcap10DegMax; }
0111   const std::vector<unsigned int>& getEndcap20DegMin() const { return endcap20DegMin; }
0112   const std::vector<unsigned int>& getEndcap20DegMax() const { return endcap20DegMax; }
0113 
0114   const std::vector<std::vector<int> >& getProcessorPhiVsRefLayer() const { return processorPhiVsRefLayer; }
0115   const std::vector<std::vector<std::vector<std::pair<int, int> > > >& getRegionPhisVsRefLayerVsInput() const {
0116     return regionPhisVsRefLayerVsInput;
0117   }
0118   const std::vector<std::vector<RefHitDef> >& getRefHitsDefs() const { return refHitsDefs; }
0119 
0120   const vector3D_pair& getConnections() const { return connections; };
0121 
0122   vector4D& getMeasurements4D() { return measurements4D; }
0123   vector4D& getMeasurements4Dref() { return measurements4Dref; }
0124 
0125   const vector4D& getMeasurements4D() const { return measurements4D; }
0126   const vector4D& getMeasurements4Dref() const { return measurements4Dref; }
0127 
0128   friend std::ostream& operator<<(std::ostream& out, const OMTFConfiguration& aConfig);
0129 
0130 private:
0131   L1TMuonOverlapParams rawParams;
0132 
0133   std::map<int, int> hwToLogicLayer;
0134   std::map<int, int> logicToHwLayer;
0135   std::map<int, int> logicToLogic;
0136   std::set<int> bendingLayers;
0137   std::vector<int> refToLogicNumber;
0138 
0139   ///Starting and final sectors connected to
0140   ///processors.
0141   ///Index: processor number
0142   std::vector<unsigned int> barrelMin;
0143   std::vector<unsigned int> barrelMax;
0144   std::vector<unsigned int> endcap10DegMin;
0145   std::vector<unsigned int> endcap10DegMax;
0146   std::vector<unsigned int> endcap20DegMin;
0147   std::vector<unsigned int> endcap20DegMax;
0148 
0149   ///Starting iPhi for each processor and each referecne layer
0150   ///Global phi scale is used
0151   ///First index: processor number
0152   ///Second index: referecne layer number
0153   std::vector<std::vector<int> > processorPhiVsRefLayer;
0154 
0155   ///Begin and end local phi for each logis region
0156   ///First index: input number
0157   ///Second index: reference layer number
0158   ///Third index: region
0159   ///pair.first: starting phi of region (inclusive)
0160   ///pair.second: ending phi of region (inclusive)
0161   std::vector<std::vector<std::vector<std::pair<int, int> > > > regionPhisVsRefLayerVsInput;
0162 
0163   ///Vector with definitions of reference hits
0164   ///Vector has fixed size of nRefHits
0165   ///Order of elements defines priority order
0166   ///First index: processor number (0-5)
0167   ///Second index: ref hit number (0-127)
0168   std::vector<std::vector<RefHitDef> > refHitsDefs;
0169 
0170   ///Map of connections
0171   vector3D_pair connections;
0172 
0173   ///4D matrices used during creation of the connections tables.
0174   vector4D measurements4D;
0175   vector4D measurements4Dref;
0176 };
0177 
0178 #endif