Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:48

0001 //-------------------------------------------------
0002 //
0003 /** \class L1MuRegionalCand
0004  *    A regional muon trigger candidate as received by the GMT
0005 */
0006 //
0007 //
0008 //   Author :
0009 //   H. Sakulin                    HEPHY Vienna
0010 //
0011 //   Migrated to CMSSW:
0012 //   I. Mikulec
0013 //
0014 //--------------------------------------------------
0015 #ifndef DataFormatsL1GlobalMuonTrigger_L1MuRegionalCand_h
0016 #define DataFormatsL1GlobalMuonTrigger_L1MuRegionalCand_h
0017 
0018 //------------------------------------
0019 // Collaborating Class Declarations --
0020 //------------------------------------
0021 
0022 //              ---------------------
0023 //              -- Class Interface --
0024 //              ---------------------
0025 
0026 class L1MuRegionalCand {
0027 public:
0028   /// constructor from data word
0029   L1MuRegionalCand(unsigned dataword = 0, int bx = 0);
0030 
0031   /// constructor from packed members
0032   L1MuRegionalCand(unsigned type_idx,
0033                    unsigned phi,
0034                    unsigned eta,
0035                    unsigned pt,
0036                    unsigned charge,
0037                    unsigned ch_valid,
0038                    unsigned finehalo,
0039                    unsigned quality,
0040                    int bx);
0041 
0042   /// destructor
0043   virtual ~L1MuRegionalCand() {}
0044 
0045   ///
0046   /// Getters - values
0047   ///
0048 
0049   /// return empty flag
0050   virtual bool empty() const {
0051     return (readDataField(PT_START, PT_LENGTH) == 0) || (readDataField(PHI_START, PHI_LENGTH) == 0xff);
0052   }
0053 
0054   /// get phi-value of muon candidate in radians (low edge of bin)
0055   float phiValue() const;
0056 
0057   /// get eta-value of muon candidate
0058   float etaValue() const;
0059 
0060   /// get pt-value of muon candidate in GeV
0061   float ptValue() const;
0062 
0063   /// get charge
0064   int chargeValue() const { return readDataField(CHARGE_START, CHARGE_LENGTH) == 0 ? 1 : -1; }
0065 
0066   /// is the charge valid ?
0067   bool chargeValid() const { return charge_valid_packed() == 1; }
0068 
0069   /// is it fine (DT) / halo (CSC) ?
0070   bool isFineHalo() const { return finehalo_packed() == 1; }
0071 
0072   /// return quality
0073   unsigned int quality() const { return quality_packed(); }
0074 
0075   /// return type: 0 DT, 1 bRPC, 2 CSC, 3 fRPC
0076   unsigned type_idx() const { return (int)readDataField(TYPE_START, TYPE_LENGTH); };
0077 
0078   /// return bunch crossing identifier
0079   int bx() const { return m_bx; }
0080 
0081   ///
0082   /// Getters - packed format
0083   ///
0084 
0085   /// return phi packed as in hardware
0086   unsigned phi_packed() const { return readDataField(PHI_START, PHI_LENGTH); }
0087 
0088   /// return pt packed as in hardware
0089   unsigned pt_packed() const { return readDataField(PT_START, PT_LENGTH); }
0090 
0091   /// return quality packed as in hardware
0092   unsigned int quality_packed() const { return readDataField(QUAL_START, QUAL_LENGTH); }
0093 
0094   /// return eta packed as in hardware
0095   unsigned eta_packed() const { return readDataField(ETA_START, ETA_LENGTH); }
0096 
0097   /// return eta-fine (for DT) / halo (for CSC) bit
0098   unsigned finehalo_packed() const { return readDataField(FINEHALO_START, FINEHALO_LENGTH); }
0099 
0100   /// return charge packed as in hardware (0=pos, 1=neg)
0101   unsigned charge_packed() const { return readDataField(CHARGE_START, CHARGE_LENGTH); }
0102 
0103   /// return charge valid packed as in hardware (1=valid, 0=not valid)
0104   unsigned charge_valid_packed() const { return readDataField(CHVALID_START, CHVALID_LENGTH); }
0105 
0106   /// return data word
0107   unsigned getDataWord() const { return m_dataWord; };
0108 
0109   ///
0110   /// Setters - packed format
0111   ///
0112 
0113   /// Set Type: 0 DT, 1 bRPC, 2 CSC, 3 fRPC
0114   void setType(unsigned type) { writeDataField(TYPE_START, TYPE_LENGTH, type); }
0115 
0116   /// Set Bunch Crossing
0117   void setBx(int bx) { m_bx = bx; }
0118 
0119   /// Set Phi: 0..143
0120   void setPhiPacked(unsigned phi) { writeDataField(PHI_START, PHI_LENGTH, phi); }
0121 
0122   /// Set Pt: 0..31
0123   void setPtPacked(unsigned pt) { writeDataField(PT_START, PT_LENGTH, pt); }
0124 
0125   /// Set Quality: 0..7
0126   void setQualityPacked(unsigned qual) { writeDataField(QUAL_START, QUAL_LENGTH, qual); }
0127 
0128   /// Set Charge (0=pos, 1=neg)
0129   void setChargePacked(unsigned ch) { writeDataField(CHARGE_START, CHARGE_LENGTH, ch); }
0130 
0131   /// Set Charge Valid
0132   void setChargeValidPacked(unsigned valid) { writeDataField(CHVALID_START, CHVALID_LENGTH, valid); }
0133 
0134   /// Set Eta: 6-bit code
0135   void setEtaPacked(unsigned eta) { writeDataField(ETA_START, ETA_LENGTH, eta); }
0136 
0137   /// Set Fine / Halo
0138   void setFineHaloPacked(unsigned fh) { writeDataField(FINEHALO_START, FINEHALO_LENGTH, fh); }
0139 
0140   ///
0141   /// Setters - values
0142   ///
0143 
0144   /// Set Phi Value
0145   void setPhiValue(float phiVal) { m_phiValue = phiVal; }
0146 
0147   /// Set Pt Value
0148   void setPtValue(float ptVal) { m_ptValue = ptVal; }
0149 
0150   /// Set Eta Value (need to set type, first)
0151   void setEtaValue(float etaVal) { m_etaValue = etaVal; }
0152 
0153   /// Set Charge Value: -1, 1
0154   void setChargeValue(int charge) { writeDataField(CHARGE_START, CHARGE_LENGTH, charge == 1 ? 0 : 1); }
0155 
0156   /// Set Charge Valid
0157   void setChargeValid(bool valid) { writeDataField(CHVALID_START, CHVALID_LENGTH, valid ? 1 : 0); }
0158 
0159   /// Set Fine / Halo
0160   void setFineHalo(bool fh) { writeDataField(FINEHALO_START, FINEHALO_LENGTH, fh ? 1 : 0); }
0161 
0162   /// reset
0163   virtual void reset();
0164 
0165   /// Set data word
0166   void setDataWord(unsigned dataword) { m_dataWord = dataword; }
0167 
0168   /// print candidate
0169   virtual void print() const;
0170 
0171 private:
0172   unsigned readDataField(unsigned start, unsigned count) const;
0173   void writeDataField(unsigned start, unsigned count, unsigned value);
0174 
0175 private:
0176   int m_bx;
0177   unsigned m_dataWord;  // muon data word (25 bits) :
0178 
0179   float m_phiValue;
0180   float m_etaValue;
0181   float m_ptValue;
0182   static const float m_invalidValue;
0183 
0184 public:
0185   // definition of the bit fields
0186   enum { PHI_START = 0 };
0187   enum { PHI_LENGTH = 8 };  // Bits 0:7   phi (8 bits)
0188   enum { PT_START = 8 };
0189   enum { PT_LENGTH = 5 };  // Bits 8:12  pt  (5 bits)
0190   enum { QUAL_START = 13 };
0191   enum { QUAL_LENGTH = 3 };  // Bits 13:15 quality (3 bits)
0192   enum { ETA_START = 16 };
0193   enum { ETA_LENGTH = 6 };  // Bits 16:21 eta (6 bits)
0194   enum { FINEHALO_START = 22 };
0195   enum { FINEHALO_LENGTH = 1 };  // Bit  22 Eta is fine (DT) / Halo (CSC)
0196   enum { CHARGE_START = 23 };
0197   enum { CHARGE_LENGTH = 1 };  // Bit  23 Charge: 0 = positive
0198   enum { CHVALID_START = 24 };
0199   enum {
0200     CHVALID_LENGTH = 1
0201   };  // Bit  24 Charge is vaild (1=valid)
0202       // Bits 26 to 29: Synchronization
0203 
0204   enum { TYPE_START = 30 };
0205   enum {
0206     TYPE_LENGTH = 2
0207   };  // Bit  30/31 type DT, bRPC, CSC, fRPC
0208       // these bits are not sent to the GMT in hardware
0209 };
0210 #endif