File indexing completed on 2021-10-06 02:54:07
0001 #ifndef L1T_OmtfP1_OMTFConfiguration_H
0002 #define L1T_OmtfP1_OMTFConfiguration_H
0003
0004 #include <map>
0005 #include <set>
0006 #include <vector>
0007 #include <ostream>
0008 #include <memory>
0009
0010
0011 #include "boost/multi_array.hpp"
0012
0013 #include "L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h"
0014 #include "CondFormats/L1TObjects/interface/L1TMuonOverlapParams.h"
0015 #include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"
0016
0017
0018 typedef float PdfValueType;
0019
0020 namespace edm {
0021 class ParameterSet;
0022 }
0023
0024 class RefHitDef {
0025 public:
0026
0027 RefHitDef(unsigned int aInput = 15,
0028 int aPhiMin = 5760,
0029 int aPhiMax = 5760,
0030 unsigned int aRegion = 99,
0031 unsigned int aRefLayer = 99);
0032
0033 public:
0034 bool fitsRange(int iPhi) const;
0035
0036
0037 unsigned int iInput;
0038
0039
0040 unsigned int iRegion;
0041
0042
0043 unsigned int iRefLayer;
0044
0045
0046
0047 std::pair<int, int> range;
0048
0049 friend std::ostream& operator<<(std::ostream& out, const RefHitDef& aRefHitDef);
0050 };
0051
0052 class OMTFConfiguration : public ProcConfigurationBase {
0053 public:
0054 typedef std::vector<std::pair<unsigned int, unsigned int> > vector1D_pair;
0055 typedef std::vector<vector1D_pair> vector2D_pair;
0056 typedef std::vector<vector2D_pair> vector3D_pair;
0057
0058 typedef std::vector<int> vector1D;
0059 typedef std::vector<vector1D> vector2D;
0060 typedef std::vector<vector2D> vector3D;
0061 typedef std::vector<vector3D> vector4D;
0062
0063 OMTFConfiguration() { ; };
0064
0065 virtual void configure(const L1TMuonOverlapParams* omtfParams);
0066
0067 void initCounterMatrices();
0068
0069
0070
0071
0072 unsigned int getRegionNumberFromMap(unsigned int iInput, unsigned int iRefLayer, int iPhi) const;
0073
0074
0075
0076
0077 bool isInRegionRange(int iPhiStart, unsigned int coneSize, int iPhi) const;
0078
0079
0080
0081 int globalPhiStart(unsigned int iProcessor) const;
0082
0083
0084
0085
0086
0087 uint32_t getLayerNumber(uint32_t rawId) const;
0088
0089 unsigned int fwVersion() const { return (rawParams.fwVersion() >> 16) & 0xFFFF; };
0090 unsigned int patternsVersion() const { return rawParams.fwVersion() & 0xFFFF; };
0091
0092 const L1TMuonOverlapParams* getRawParams() const { return &rawParams; };
0093
0094 float minPdfVal() const { return 0.001; };
0095 unsigned int nLayers() const override { return rawParams.nLayers(); };
0096 unsigned int nHitsPerLayer() const { return rawParams.nHitsPerLayer(); };
0097 unsigned int nRefLayers() const { return rawParams.nRefLayers(); };
0098 unsigned int nPhiBits() const { return rawParams.nPhiBits(); };
0099 unsigned int nPdfAddrBits() const { return rawParams.nPdfAddrBits(); };
0100 unsigned int nPdfBins() const { return pdfBins; };
0101 unsigned int nPdfValBits() const { return rawParams.nPdfValBits(); };
0102 int pdfMaxValue() const { return pdfMaxVal; };
0103 unsigned int nPhiBins() const override { return rawParams.nPhiBins(); };
0104 unsigned int nRefHits() const { return rawParams.nRefHits(); };
0105 unsigned int nTestRefHits() const { return rawParams.nTestRefHits(); };
0106
0107 unsigned int nProcessors() const { return rawParams.nProcessors(); };
0108
0109 unsigned int processorCnt() const { return 2 * rawParams.nProcessors(); };
0110 unsigned int nLogicRegions() const { return rawParams.nLogicRegions(); };
0111 unsigned int nInputs() const { return rawParams.nInputs(); };
0112 unsigned int nGoldenPatterns() const { return rawParams.nGoldenPatterns(); };
0113
0114 const std::map<int, int>& getHwToLogicLayer() const { return hwToLogicLayer; }
0115 const std::map<int, int>& getLogicToHwLayer() const { return logicToHwLayer; }
0116 const std::map<int, int>& getLogicToLogic() const { return logicToLogic; }
0117 const std::set<int>& getBendingLayers() const { return bendingLayers; }
0118 const std::vector<int>& getRefToLogicNumber() const { return refToLogicNumber; }
0119
0120 const std::vector<unsigned int>& getBarrelMin() const { return barrelMin; }
0121 const std::vector<unsigned int>& getBarrelMax() const { return barrelMax; }
0122 const std::vector<unsigned int>& getEndcap10DegMin() const { return endcap10DegMin; }
0123 const std::vector<unsigned int>& getEndcap10DegMax() const { return endcap10DegMax; }
0124 const std::vector<unsigned int>& getEndcap20DegMin() const { return endcap20DegMin; }
0125 const std::vector<unsigned int>& getEndcap20DegMax() const { return endcap20DegMax; }
0126
0127 const std::vector<std::vector<int> >& getProcessorPhiVsRefLayer() const { return processorPhiVsRefLayer; }
0128 const std::vector<std::vector<std::vector<std::pair<int, int> > > >& getRegionPhisVsRefLayerVsInput() const {
0129 return regionPhisVsRefLayerVsInput;
0130 }
0131 const std::vector<std::vector<RefHitDef> >& getRefHitsDefs() const { return refHitsDefs; }
0132
0133 const vector3D_pair& getConnections() const { return connections; };
0134
0135 vector4D& getMeasurements4D() { return measurements4D; }
0136 vector4D& getMeasurements4Dref() { return measurements4Dref; }
0137
0138 const vector4D& getMeasurements4D() const { return measurements4D; }
0139 const vector4D& getMeasurements4Dref() const { return measurements4Dref; }
0140
0141 double ptUnit = 0.5;
0142
0143 double hwPtToGev(int hwPt) const override { return (hwPt - 1.) * ptUnit; }
0144
0145
0146 int ptGevToHw(double ptGev) const override { return (ptGev / ptUnit + 1); }
0147
0148 double etaUnit = 0.010875;
0149
0150 virtual double hwEtaToEta(int hwEta) const { return (hwEta * etaUnit); }
0151
0152 int etaToHwEta(double eta) const override { return (eta / etaUnit); }
0153
0154 double phiGmtUnit = 2. * M_PI / 576;
0155
0156 virtual int phiToGlobalHwPhi(double phi) const { return std::floor(phi / phiGmtUnit); }
0157
0158
0159 virtual double hwPhiToGlobalPhi(int phi) const { return phi * phiGmtUnit; }
0160
0161
0162
0163
0164 int getProcScalePhi(unsigned int iProcessor, double phiRad) const;
0165
0166 int getProcScalePhi(double phiRad, double procPhiZeroRad = 0) const override {
0167 return 0;
0168 }
0169
0170 double procHwPhiToGlobalPhi(int procHwPhi, int procHwPhi0) const;
0171
0172 int procPhiToGmtPhi(int procPhi) const {
0173
0174 return floor(procPhi * 437. / (1 << 12));
0175
0176 }
0177
0178
0179
0180
0181
0182
0183 unsigned int getProcIndx(unsigned int iProcessor, l1t::tftype mtfType) const {
0184 return ((mtfType - l1t::tftype::omtf_neg) * rawParams.nProcessors() + iProcessor);
0185 };
0186
0187
0188 bool isBendingLayer(unsigned int iLayer) const override { return getBendingLayers().count(iLayer); }
0189
0190
0191 struct PatternPt {
0192 double ptFrom = 0;
0193 double ptTo = 0;
0194 int charge = 0;
0195 };
0196
0197 PatternPt getPatternPtRange(unsigned int patNum) const;
0198
0199
0200 void setPatternPtRange(const std::vector<PatternPt>& patternPts) { this->patternPts = patternPts; }
0201
0202
0203 unsigned int getPatternNum(double pt, int charge) const;
0204
0205 static const unsigned int patternsInGroup = 4;
0206
0207
0208 template <class GoldenPatternType>
0209 vector2D getPatternGroups(const std::vector<std::unique_ptr<GoldenPatternType> >& goldenPats) const {
0210
0211 vector2D mergedPatterns;
0212 for (unsigned int iPat = 0; iPat < goldenPats.size(); iPat++) {
0213 unsigned int group = goldenPats.at(iPat)->key().theGroup;
0214
0215 if (mergedPatterns.size() == group) {
0216 mergedPatterns.push_back(vector1D());
0217 }
0218
0219 if (group < mergedPatterns.size()) {
0220
0221 if (mergedPatterns[group].size() == (goldenPats.at(iPat)->key().theIndexInGroup - 1))
0222 mergedPatterns[group].push_back(iPat);
0223 else
0224 return mergedPatterns;
0225 } else
0226 return mergedPatterns;
0227 }
0228 return mergedPatterns;
0229 }
0230
0231
0232
0233
0234 void configureFromEdmParameterSet(const edm::ParameterSet& edmParameterSet) override;
0235
0236 int getGoldenPatternResultFinalizeFunction() const { return goldenPatternResultFinalizeFunction; }
0237
0238 void setGoldenPatternResultFinalizeFunction(int goldenPatternResultFinalizeFunction = 0) {
0239 this->goldenPatternResultFinalizeFunction = goldenPatternResultFinalizeFunction;
0240 }
0241
0242 friend std::ostream& operator<<(std::ostream& out, const OMTFConfiguration& aConfig);
0243
0244 bool isNoHitValueInPdf() const { return noHitValueInPdf; }
0245
0246 void setNoHitValueInPdf(bool noHitValueInPdf = false) { this->noHitValueInPdf = noHitValueInPdf; }
0247
0248 int getSorterType() const { return sorterType; }
0249
0250 void setSorterType(int sorterType = 0) { this->sorterType = sorterType; }
0251
0252 const std::string& getGhostBusterType() const { return ghostBusterType; }
0253
0254 void setGhostBusterType(const std::string& ghostBusterType = "") { this->ghostBusterType = ghostBusterType; }
0255
0256 void printConfig() const;
0257
0258 private:
0259 L1TMuonOverlapParams rawParams;
0260
0261 std::map<int, int> hwToLogicLayer;
0262 std::map<int, int> logicToHwLayer;
0263 std::map<int, int> logicToLogic;
0264 std::set<int> bendingLayers;
0265 std::vector<int> refToLogicNumber;
0266
0267
0268
0269
0270 std::vector<unsigned int> barrelMin;
0271 std::vector<unsigned int> barrelMax;
0272 std::vector<unsigned int> endcap10DegMin;
0273 std::vector<unsigned int> endcap10DegMax;
0274 std::vector<unsigned int> endcap20DegMin;
0275 std::vector<unsigned int> endcap20DegMax;
0276
0277
0278
0279
0280
0281 std::vector<std::vector<int> > processorPhiVsRefLayer;
0282
0283
0284
0285
0286
0287
0288
0289 std::vector<std::vector<std::vector<std::pair<int, int> > > > regionPhisVsRefLayerVsInput;
0290
0291
0292
0293
0294
0295
0296 std::vector<std::vector<RefHitDef> > refHitsDefs;
0297
0298
0299 vector3D_pair connections;
0300
0301
0302 vector4D measurements4D;
0303 vector4D measurements4Dref;
0304
0305 std::vector<PatternPt> patternPts;
0306
0307 int pdfMaxVal = 0;
0308 unsigned int pdfBins = 0;
0309
0310 int goldenPatternResultFinalizeFunction = 0;
0311
0312 bool noHitValueInPdf = false;
0313
0314 int sorterType = 0;
0315
0316 std::string ghostBusterType = "";
0317 };
0318
0319 #endif