Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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