Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:36:48

0001 //-------------------------------------------------
0002 //
0003 //
0004 /**  \class L1MuGMTReg
0005  *
0006  *   Description: A 16bit VME register
0007  *
0008  *   Used to configure the GMT. The register class represents 
0009  *   multiple instances of the register in the hardware (by default 2)
0010 */
0011 //
0012 //
0013 //   Author :
0014 //   H. Sakulin            HEPHY Vienna
0015 //
0016 //   Migrated to CMSSW:
0017 //   I. Mikulec
0018 //
0019 //--------------------------------------------------
0020 #ifndef L1TriggerGlobalMuonTrigger_L1MuGMTReg_h
0021 #define L1TriggerGlobalMuonTrigger_L1MuGMTReg_h
0022 
0023 //---------------
0024 // C++ Headers --
0025 //---------------
0026 
0027 #include <string>
0028 #include <vector>
0029 
0030 //-------------------------------
0031 // Collaborating Class Headers --
0032 //-------------------------------
0033 
0034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0035 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTConfig.h"
0036 #include "CondFormats/L1TObjects/interface/L1MuGMTParameters.h"
0037 
0038 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0039 
0040 //              ---------------------
0041 //              -- Class Interface --
0042 //              ---------------------
0043 
0044 class L1MuGMTReg {
0045 public:
0046   /// default constructor
0047   L1MuGMTReg(int ninst = 2) : m_value(ninst, 0) {}
0048 
0049   /// destructor
0050   virtual ~L1MuGMTReg() {}
0051 
0052   /// get Value
0053   unsigned getValue(int idx) { return m_value[idx]; };
0054 
0055   /// get number on instances
0056   unsigned getNumberOfInstances() { return m_value.size(); }
0057 
0058   /// get Name
0059   virtual std::string getName() = 0;
0060 
0061 protected:
0062   std::vector<unsigned> m_value;
0063 };
0064 
0065 //
0066 /// \class L1MuGMTRegMMConfig
0067 //
0068 /// GMT Register that implements enum of merge methods
0069 //
0070 
0071 class L1MuGMTRegMMConfig : public L1MuGMTReg {
0072 public:
0073   enum MergeMethods { takeDTCSC, takeRPC, byRank, byMinPt, byCombi, Special };
0074 
0075   //// constructor
0076   L1MuGMTRegMMConfig(const std::string& param, MergeMethods def_brl, MergeMethods def_fwd) : m_param(param) {
0077     m_default[0] = def_brl;
0078     m_default[1] = def_fwd;
0079     setMergeMethod();
0080   };
0081 
0082   //// destructor
0083   ~L1MuGMTRegMMConfig() override {}
0084 
0085   //// get Name
0086   std::string getName() override { return "MMConfig_" + m_param; };
0087 
0088   //// read the merge method from .orcarc
0089   void setMergeMethod() {
0090     static MergeMethods avlMethods[6] = {takeDTCSC, takeRPC, byRank, byMinPt, byCombi, Special};
0091     std::string mn[6] = {"takeDT", "takeRPC", "byRank", "byMinPt", "byCombi", "Special"};
0092 
0093     MergeMethods mm;
0094     std::string mm_str;
0095 
0096     mm = m_default[0];
0097     if (m_param == "Phi")
0098       mm_str = L1MuGMTConfig::getGMTParams()->getMergeMethodPhiBrl();
0099     else if (m_param == "Eta")
0100       mm_str = L1MuGMTConfig::getGMTParams()->getMergeMethodEtaBrl();
0101     else if (m_param == "Pt")
0102       mm_str = L1MuGMTConfig::getGMTParams()->getMergeMethodPtBrl();
0103     else if (m_param == "Charge")
0104       mm_str = L1MuGMTConfig::getGMTParams()->getMergeMethodChargeBrl();
0105     for (int ii = 0; ii < 6; ii++)
0106       if (mm_str == mn[ii]) {
0107         mm = avlMethods[ii];
0108         break;
0109       }
0110     m_value[0] = 1 << (5 - (int)MergeMethods(mm));
0111     if (L1MuGMTConfig::Debug(1))
0112       edm::LogVerbatim("GMT_Register_Info") << " "
0113                                             << "MergeMethod" << m_param << "Brl"
0114                                             << " is " << mm << "( value " << m_value[0] << " )";
0115 
0116     mm = m_default[1];
0117     mn[0] = "takeCSC";
0118     if (m_param == "Phi")
0119       mm_str = L1MuGMTConfig::getGMTParams()->getMergeMethodPhiFwd();
0120     else if (m_param == "Eta")
0121       mm_str = L1MuGMTConfig::getGMTParams()->getMergeMethodEtaFwd();
0122     else if (m_param == "Pt")
0123       mm_str = L1MuGMTConfig::getGMTParams()->getMergeMethodPtFwd();
0124     else if (m_param == "Charge")
0125       mm_str = L1MuGMTConfig::getGMTParams()->getMergeMethodChargeFwd();
0126     for (int ii = 0; ii < 6; ii++)
0127       if (mm_str == mn[ii]) {
0128         mm = avlMethods[ii];
0129         break;
0130       }
0131     m_value[1] = 1 << (5 - (int)MergeMethods(mm));
0132     if (L1MuGMTConfig::Debug(1))
0133       edm::LogVerbatim("GMT_Register_Info") << " "
0134                                             << "MergeMethod" << m_param << "Fwd"
0135                                             << " is " << mm << "( value " << m_value[1] << " )";
0136   };
0137 
0138 protected:
0139   std::string m_param;
0140   MergeMethods m_default[2];
0141 };
0142 
0143 //
0144 /// \class L1MuGMTRegMMConfigPhi
0145 //
0146 /// GMT Merge Method Config Register Phi
0147 
0148 class L1MuGMTRegMMConfigPhi : public L1MuGMTRegMMConfig {
0149 public:
0150   L1MuGMTRegMMConfigPhi() : L1MuGMTRegMMConfig("Phi", L1MuGMTRegMMConfig::takeDTCSC, L1MuGMTRegMMConfig::takeDTCSC) {}
0151 };
0152 
0153 //
0154 /// \class L1MuGMTRegMMConfigEta
0155 //
0156 /// GMT Merge Method Config Register Eta
0157 
0158 class L1MuGMTRegMMConfigEta : public L1MuGMTRegMMConfig {
0159 public:
0160   L1MuGMTRegMMConfigEta() : L1MuGMTRegMMConfig("Eta", L1MuGMTRegMMConfig::Special, L1MuGMTRegMMConfig::Special) {}
0161 };
0162 
0163 //
0164 /// \class L1MuGMTRegMMConfigPt
0165 //
0166 /// GMT Merge Method Config Register Pt
0167 
0168 class L1MuGMTRegMMConfigPt : public L1MuGMTRegMMConfig {
0169 public:
0170   L1MuGMTRegMMConfigPt() : L1MuGMTRegMMConfig("Pt", L1MuGMTRegMMConfig::byMinPt, L1MuGMTRegMMConfig::byMinPt) {}
0171 };
0172 
0173 //
0174 /// \class L1MuGMTRegMMConfigCharge
0175 //
0176 /// GMT Merge Method Config Register Charge
0177 
0178 class L1MuGMTRegMMConfigCharge : public L1MuGMTRegMMConfig {
0179 public:
0180   L1MuGMTRegMMConfigCharge()
0181       : L1MuGMTRegMMConfig("Charge", L1MuGMTRegMMConfig::takeDTCSC, L1MuGMTRegMMConfig::takeDTCSC) {}
0182 };
0183 
0184 //
0185 /// \class L1MuGMTRegMMConfigMIPISO
0186 //
0187 /// GMT Register that implements additional AND/OR flag
0188 //
0189 
0190 class L1MuGMTRegMMConfigMIPISO : public L1MuGMTRegMMConfig {
0191 public:
0192   //// constructor
0193   L1MuGMTRegMMConfigMIPISO(
0194       const std::string& param, MergeMethods def_brl, MergeMethods def_fwd, bool def_and_brl, bool def_and_fwd)
0195       : L1MuGMTRegMMConfig(param, def_brl, def_fwd) {
0196     bool doAND = false;
0197 
0198     if (m_param == "MIP")
0199       doAND = L1MuGMTConfig::getGMTParams()->getMergeMethodMIPSpecialUseANDBrl();
0200     else if (m_param == "ISO")
0201       doAND = L1MuGMTConfig::getGMTParams()->getMergeMethodISOSpecialUseANDBrl();
0202     if (doAND)
0203       m_value[0] |= 64;
0204     if (L1MuGMTConfig::Debug(1))
0205       edm::LogVerbatim("GMT_Register_Info") << " "
0206                                             << "MergeMethod" << m_param << "SpecialUseANDBrl"
0207                                             << " is " << doAND;
0208 
0209     if (m_param == "MIP")
0210       doAND = L1MuGMTConfig::getGMTParams()->getMergeMethodMIPSpecialUseANDFwd();
0211     else if (m_param == "ISO")
0212       doAND = L1MuGMTConfig::getGMTParams()->getMergeMethodISOSpecialUseANDFwd();
0213     if (doAND)
0214       m_value[1] |= 64;
0215     if (L1MuGMTConfig::Debug(1))
0216       edm::LogVerbatim("GMT_Register_Info") << " "
0217                                             << "MergeMethod" << m_param << "SpecialUseANDFwd"
0218                                             << " is " << doAND;
0219   };
0220 
0221   //// destructor
0222   ~L1MuGMTRegMMConfigMIPISO() override {}
0223 };
0224 
0225 //
0226 /// \class L1MuGMTRegMMConfigMIP
0227 //
0228 /// GMT Merge Method Config Register MIP
0229 
0230 class L1MuGMTRegMMConfigMIP : public L1MuGMTRegMMConfigMIPISO {
0231 public:
0232   L1MuGMTRegMMConfigMIP()
0233       : L1MuGMTRegMMConfigMIPISO("MIP", L1MuGMTRegMMConfig::Special, L1MuGMTRegMMConfig::Special, false, false) {}
0234 };
0235 
0236 //
0237 /// \class L1MuGMTRegMMConfigISO
0238 //
0239 /// GMT Merge Method Config Register ISO
0240 
0241 class L1MuGMTRegMMConfigISO : public L1MuGMTRegMMConfigMIPISO {
0242 public:
0243   L1MuGMTRegMMConfigISO()
0244       : L1MuGMTRegMMConfigMIPISO("ISO", L1MuGMTRegMMConfig::Special, L1MuGMTRegMMConfig::Special, true, true) {}
0245 };
0246 
0247 //
0248 /// \class L1MuGMTRegMMConfigSRK
0249 //
0250 /// GMT Register that implements additional Halo Overwrites Matched bit
0251 //
0252 
0253 class L1MuGMTRegMMConfigSRK : public L1MuGMTRegMMConfig {
0254 public:
0255   //// constructor
0256   L1MuGMTRegMMConfigSRK() : L1MuGMTRegMMConfig("SRK", L1MuGMTRegMMConfig::takeDTCSC, L1MuGMTRegMMConfig::takeDTCSC) {
0257     bool haloOverwrites;
0258 
0259     haloOverwrites = L1MuGMTConfig::getGMTParams()->getHaloOverwritesMatchedBrl();
0260     if (haloOverwrites)
0261       m_value[0] |= 64;
0262     if (L1MuGMTConfig::Debug(1))
0263       edm::LogVerbatim("GMT_Register_info") << " "
0264                                             << "HaloOverwritesMatchedBrl"
0265                                             << " is " << haloOverwrites;
0266 
0267     haloOverwrites = L1MuGMTConfig::getGMTParams()->getHaloOverwritesMatchedFwd();
0268     if (haloOverwrites)
0269       m_value[1] |= 64;
0270     if (L1MuGMTConfig::Debug(1))
0271       edm::LogVerbatim("GMT_Register_info") << " "
0272                                             << "HaloOverwritesMatchedFwd"
0273                                             << " is " << haloOverwrites;
0274   };
0275 
0276   //// destructor
0277   ~L1MuGMTRegMMConfigSRK() override {}
0278 };
0279 
0280 //
0281 /// \class L1MuGMTRegSortRankOffset
0282 //
0283 /// GMT Register that implements Rank offset for merged cands
0284 //
0285 
0286 class L1MuGMTRegSortRankOffset : public L1MuGMTReg {
0287 public:
0288   //// constructor
0289   L1MuGMTRegSortRankOffset() {
0290     m_value[0] = L1MuGMTConfig::getGMTParams()->getSortRankOffsetBrl();
0291     if (L1MuGMTConfig::Debug(1))
0292       edm::LogVerbatim("GMT_Register_info") << " SortRankOffsetBrl is " << m_value[0];
0293 
0294     m_value[1] = L1MuGMTConfig::getGMTParams()->getSortRankOffsetFwd();
0295     if (L1MuGMTConfig::Debug(1))
0296       edm::LogVerbatim("GMT_Register_info") << " SortRankOffsetFwd is " << m_value[1];
0297   };
0298 
0299   //// get Name
0300   std::string getName() override { return "SortRankOffset"; };
0301 
0302   //// destructor
0303   ~L1MuGMTRegSortRankOffset() override {}
0304 };
0305 
0306 //
0307 /// \class L1MuGMTRegCDLConfig
0308 //
0309 /// GMT Register that implements Configuration of Cancel Decisison Logic
0310 //
0311 
0312 class L1MuGMTRegCDLConfig : public L1MuGMTReg {
0313 public:
0314   //// constructor
0315   L1MuGMTRegCDLConfig() : L1MuGMTReg(4) { setCDLConfig(); };
0316 
0317   //// destructor
0318   ~L1MuGMTRegCDLConfig() override {}
0319 
0320   //// get Name
0321   std::string getName() override { return std::string("CDLConfig"); };
0322 
0323   //// read the merge method from .orcarc
0324   void setCDLConfig() {
0325     m_value[0] = L1MuGMTConfig::getGMTParams()->getCDLConfigWordDTCSC();
0326     if (L1MuGMTConfig::Debug(1))
0327       edm::LogVerbatim("GMT_Register_info") << " CDLConfigWordDTCSC is " << m_value[0];
0328 
0329     m_value[1] = L1MuGMTConfig::getGMTParams()->getCDLConfigWordCSCDT();
0330     if (L1MuGMTConfig::Debug(1))
0331       edm::LogVerbatim("GMT_Register_info") << " CDLConfigWordCSCDT is " << m_value[1];
0332 
0333     m_value[2] = L1MuGMTConfig::getGMTParams()->getCDLConfigWordbRPCCSC();
0334     if (L1MuGMTConfig::Debug(1))
0335       edm::LogVerbatim("GMT_Register_info") << " CDLConfigWordbRPCCSC is " << m_value[2];
0336 
0337     m_value[3] = L1MuGMTConfig::getGMTParams()->getCDLConfigWordfRPCDT();
0338     if (L1MuGMTConfig::Debug(1))
0339       edm::LogVerbatim("GMT_Register_info") << " CDLConfigWordfRPCDT is " << m_value[3];
0340   };
0341 
0342 protected:
0343 };
0344 
0345 #endif