Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-12-02 04:24:21

0001 //-------------------------------------------------
0002 //
0003 /**  \class L1MuGMTCand
0004  *
0005  *   L1 Global Muon Trigger Candidate.
0006  *
0007  *   This candidate contains only information sent to the GT.
0008 */
0009 //
0010 //
0011 //   Author :
0012 //   H. Sakulin               HEPHY Vienna
0013 //   N. Neumeister            CERN EP
0014 //
0015 //   Migrated to CMSSW:
0016 //   I. Mikulec
0017 //
0018 //--------------------------------------------------
0019 #ifndef DataFormatsL1GlobalMuonTrigger_L1MuGMTCand_h
0020 #define DataFormatsL1GlobalMuonTrigger_L1MuGMTCand_h
0021 
0022 //---------------
0023 // C++ Headers --
0024 //---------------
0025 #include <string>
0026 
0027 //----------------------
0028 // Base Class Headers --
0029 //----------------------
0030 
0031 //------------------------------------
0032 // Collaborating Class Declarations --
0033 //------------------------------------
0034 
0035 //              ---------------------
0036 //              -- Class Interface --
0037 //              ---------------------
0038 
0039 class L1MuGMTCand {
0040 public:
0041   /// constructor
0042   L1MuGMTCand();
0043 
0044   /// constructor from dataword
0045   L1MuGMTCand(unsigned data, int bx = 0);
0046 
0047   /// copy constructor
0048   L1MuGMTCand(const L1MuGMTCand&);
0049 
0050   /// assignment operator
0051   L1MuGMTCand& operator=(const L1MuGMTCand&) = default;
0052 
0053   /// destructor
0054   virtual ~L1MuGMTCand();
0055 
0056   /// reset muon candidate
0057   void reset();
0058 
0059   //
0060   // Getters
0061   //
0062 
0063   /// is it an empty  muon candidate?
0064   bool empty() const { return readDataField(PT_START, PT_LENGTH) == 0; }
0065 
0066   /// get muon data word
0067   unsigned getDataWord() const { return m_dataWord; }
0068 
0069   /// get name of object
0070   std::string name() const { return m_name; }
0071 
0072   /// get phi-code
0073   unsigned int phiIndex() const { return readDataField(PHI_START, PHI_LENGTH); }
0074 
0075   /// get pt-code
0076   unsigned int ptIndex() const { return readDataField(PT_START, PT_LENGTH); }
0077 
0078   /// get quality
0079 
0080   /// Quality codes:
0081   ///
0082   /// 0 .. no muon
0083   /// 1 .. beam halo muon (CSC)
0084   /// 2 .. very low quality level 1 (e.g. ignore in single and di-muon trigger)
0085   /// 3 .. very low quality level 2 (e.g. ignore in single muon trigger use in di-muon trigger)
0086   /// 4 .. very low quality level 3 (e.g. ignore in di-muon trigger, use in single-muon trigger)
0087   /// 5 .. unmatched RPC
0088   /// 6 .. unmatched DT or CSC
0089   /// 7 .. matched DT-RPC or CSC-RPC
0090   ///
0091   /// attention: try not to rely on quality codes in analysis: they may change again
0092   ///
0093   unsigned int quality() const { return readDataField(QUAL_START, QUAL_LENGTH); }
0094 
0095   /// interpretation of quality code: is the candidate to be used in a single muon trigger ?
0096   bool useInSingleMuonTrigger() const { return quality() >= 4; };
0097 
0098   /// interpretation of quality code: is the candidate to be used in a di-muon trigger ?
0099   bool useInDiMuonTrigger() const { return (quality() >= 3) && (quality() != 4); };
0100 
0101   /// interpretation of quality code: is the candidate a matched candidate ?
0102   bool isMatchedCand() const { return quality() == 7; }
0103 
0104   /// interpretation of quality code: is the candidate a beam halo muon ?
0105   bool isHaloCand() const { return quality() == 1; }
0106 
0107   /// get eta-code
0108   unsigned int etaIndex() const { return readDataField(ETA_START, ETA_LENGTH); }
0109 
0110   /// get charge/synchronization word (0=POS, 1=NEG, 2=UNDEF, 3=SYNC)
0111   unsigned sysign() const { return readDataField(SYSIGN_START, SYSIGN_LENGTH); }
0112 
0113   /// get isolation
0114   bool isol() const { return readDataField(ISO_START, ISO_LENGTH) == 1; }
0115 
0116   /// get mip
0117   bool mip() const { return readDataField(MIP_START, MIP_LENGTH) == 1; }
0118 
0119   /// get bunch crossing identifier
0120   int bx() const { return m_bx; }
0121 
0122   /// get phi-value of muon candidate in radians (low edge of bin)
0123   /// this functionality will be moved to an extra Producer
0124   float phiValue() const;
0125 
0126   /// get eta-value of muon candidate
0127   /// this functionality will be moved to an extra Producer
0128   float etaValue() const;
0129 
0130   /// get pt-value of muon candidate in GeV
0131   /// this functionality will be moved to an extra Producer
0132   float ptValue() const;
0133 
0134   /// get charge (+1  -1)
0135   int charge() const { return (readDataField(SYSIGN_START, SYSIGN_LENGTH) & 1) == 0 ? 1 : -1; }
0136 
0137   /// is the charge valid ?
0138   bool charge_valid() const {
0139     unsigned sysign = readDataField(SYSIGN_START, SYSIGN_LENGTH);
0140     return (sysign == 0 || sysign == 1);
0141   }
0142 
0143   /// is the candidate a sync word
0144   bool isSyncWord() const { return readDataField(SYSIGN_START, SYSIGN_LENGTH) == 3; }
0145 
0146   ///
0147   /// Setters
0148   ///
0149 
0150   /// set packed phi-code of muon candidate
0151   void setPhiPacked(unsigned phi) { writeDataField(PHI_START, PHI_LENGTH, phi); }
0152 
0153   /// set packed pt-code of muon candidate
0154   void setPtPacked(unsigned pt) { writeDataField(PT_START, PT_LENGTH, pt); }
0155 
0156   /// set quality of muon candidate
0157   void setQuality(unsigned quality) { writeDataField(QUAL_START, QUAL_LENGTH, quality); }
0158 
0159   /// set packed eta-code of muon candidate
0160   void setEtaPacked(unsigned eta) { writeDataField(ETA_START, ETA_LENGTH, eta); }
0161 
0162   /// set isolation of muon candidate
0163   void setIsolation(bool isol) { writeDataField(ISO_START, ISO_LENGTH, isol ? 1 : 0); }
0164 
0165   /// set min ionizing bit for muon candidate
0166   void setMIP(bool mip) { writeDataField(MIP_START, MIP_LENGTH, mip ? 1 : 0); }
0167 
0168   /// set packed charge/synchronization word of muon candidate (0=POS, 1=NEG, 2=UNDEF, 3=SYNC)
0169   void setChargePacked(unsigned ch) { writeDataField(SYSIGN_START, SYSIGN_LENGTH, ch); }
0170 
0171   /// set bunch crossing identifier
0172   void setBx(int bx) { m_bx = bx; }
0173 
0174   /// Setters for physical values
0175 
0176   /// Set Phi Value
0177   void setPhiValue(float phiVal) { m_phiValue = phiVal; }
0178 
0179   /// Set Pt Value
0180   void setPtValue(float ptVal) { m_ptValue = ptVal; }
0181 
0182   /// Set Eta Value (need to set type, first)
0183   void setEtaValue(float etaVal) { m_etaValue = etaVal; }
0184 
0185   //
0186   // Other
0187   //
0188 
0189   unsigned int linearizedPt(float lsbValue, unsigned maxScale) const { return 0; }
0190 
0191   unsigned int etaRegionIndex() const { return etaIndex(); }
0192 
0193   unsigned int phiRegionIndex() const { return phiIndex(); }
0194 
0195   /// equal operator
0196   bool operator==(const L1MuGMTCand&) const;
0197 
0198   /// unequal operator
0199   bool operator!=(const L1MuGMTCand&) const;
0200 
0201   /// print parameters of muon candidate
0202   void print() const;
0203 
0204   /// output stream operator
0205   friend std::ostream& operator<<(std::ostream&, const L1MuGMTCand&);
0206 
0207 protected:
0208 protected:
0209   inline unsigned readDataField(unsigned start, unsigned count) const;
0210   inline void writeDataField(unsigned start, unsigned count, unsigned value);
0211 
0212   std::string m_name;
0213   int m_bx;             // in here only for technical reasons in simulation
0214   unsigned m_dataWord;  // muon data word (26 bits) :
0215 
0216   float m_phiValue;
0217   float m_etaValue;
0218   float m_ptValue;
0219   static const float m_invalidValue;
0220 
0221   // definition of the bit fields
0222   enum { PHI_START = 0 };
0223   enum { PHI_LENGTH = 8 };  // Bits 0:7   phi (8 bits)
0224   enum { PT_START = 8 };
0225   enum { PT_LENGTH = 5 };  // Bits 8:12  pt  (5 bits)
0226   enum { QUAL_START = 13 };
0227   enum { QUAL_LENGTH = 3 };  // Bits 13:15 quality (3 bits)
0228   enum { ETA_START = 16 };
0229   enum { ETA_LENGTH = 6 };  // Bits 16:21 eta (6 bits)
0230   enum { ISO_START = 22 };
0231   enum { ISO_LENGTH = 1 };  // Bit  22    Isolation
0232   enum { MIP_START = 23 };
0233   enum { MIP_LENGTH = 1 };  // Bit  23    MIP
0234   enum { SYSIGN_START = 24 };
0235   enum { SYSIGN_LENGTH = 2 };  // Bit  24:25 Charge/Syncword
0236 };
0237 
0238 unsigned L1MuGMTCand::readDataField(unsigned start, unsigned count) const {
0239   unsigned mask = ((1 << count) - 1) << start;
0240   return (m_dataWord & mask) >> start;
0241 }
0242 
0243 void L1MuGMTCand::writeDataField(unsigned start, unsigned count, unsigned value) {
0244   unsigned mask = ((1 << count) - 1) << start;
0245   m_dataWord &= ~mask;  // clear
0246   m_dataWord |= (value << start) & mask;
0247 }
0248 
0249 #endif