Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef L1CALOMIPQUIETREGION_H
0002 #define L1CALOMIPQUIETREGION_H
0003 
0004 #include <ostream>
0005 
0006 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h"
0007 
0008 /*!
0009 * \class L1CaloMipQuietRegion
0010 * \brief Miniumum Ionising Particle (MIP) and Quiet bits for a calorimeter trigger region.
0011 * 
0012 * \author Robert Frazier
0013 */
0014 
0015 class L1CaloMipQuietRegion {
0016 public:
0017   // ** Constructors/Destructors **
0018 
0019   /// Default constructor
0020   L1CaloMipQuietRegion();
0021 
0022   /// Constructor for RCT emulator (HB/HE regions)
0023   L1CaloMipQuietRegion(bool mip, bool quiet, unsigned crate, unsigned card, unsigned rgn, int16_t bx);
0024 
0025   /// Construct with GCT eta,phi indices, for testing GCT emulator
0026   L1CaloMipQuietRegion(bool mip, bool quiet, unsigned ieta, unsigned iphi, int16_t bx = 0);
0027 
0028   /// Destructor
0029   ~L1CaloMipQuietRegion() {}
0030 
0031   // ** Operators **
0032 
0033   /// Equality operator; compares all data: MIP/Quiet bits, bunch crossing & geographical.
0034   bool operator==(const L1CaloMipQuietRegion& rhs) const;
0035 
0036   /// Inequality operator.
0037   bool operator!=(const L1CaloMipQuietRegion& rhs) const { return !(*this == rhs); }
0038 
0039   // ** Get methods for the data **
0040 
0041   uint8_t raw() const { return m_data; }  ///< Get raw data.
0042 
0043   bool mip() const { return (m_data & 0x1) != 0; }  ///< Get MIP bit.
0044 
0045   bool quiet() const { return ((m_data >> 1) & 0x1) != 0; }  ///< Get Quiet bit.
0046 
0047   int16_t bx() const { return m_bx; }  ///< Get bunch crossing.
0048 
0049   // ** Set methods for the data **
0050 
0051   void setMip(bool mip) { mip ? m_data |= 1 : m_data &= ~1; }  ///< Set MIP bit.
0052 
0053   void setQuiet(bool quiet) { quiet ? m_data |= 2 : m_data &= ~2; }  ///< Set Quiet bit.
0054 
0055   void setBx(int16_t bx) { m_bx = bx; }  ///< Set bunch crossing.
0056 
0057   // ** Get methods for geographical information **
0058 
0059   L1CaloRegionDetId id() const { return m_id; }  ///< Get global region ID.
0060 
0061   unsigned rctCrate() const { return m_id.rctCrate(); }  ///< Get RCT crate ID.
0062 
0063   unsigned rctCard() const { return m_id.rctCard(); }  ///< Get RCT reciever card ID.
0064 
0065   unsigned rctRegionIndex() const { return m_id.rctRegion(); }  ///< Get RCT region index.
0066 
0067   unsigned rctEta() const { return m_id.rctEta(); }  ///< Get local eta index (within RCT crate).
0068 
0069   unsigned rctPhi() const { return m_id.rctPhi(); }  ///< Get local phi index (within RCT crate).
0070 
0071   unsigned gctEta() const { return m_id.ieta(); }  ///< Get GCT eta index.
0072 
0073   unsigned gctPhi() const { return m_id.iphi(); }  ///< Get GCT phi index.
0074 
0075   // ** Misc **
0076 
0077   /// Is the object empty? Currently always returns false.
0078   bool empty() const { return false; }
0079 
0080   /// Resets the data content - i.e. resets MIP/Quiet and bx, but not position ID!
0081   void reset() {
0082     m_data = 0;
0083     m_bx = 0;
0084   }
0085 
0086 private:
0087   // ** Private Data **
0088 
0089   L1CaloRegionDetId m_id;  ///< Geographical info: region ID.
0090 
0091   uint8_t m_data;  ///< MIP and Quiet bits for the region, packed in bit0 + bit1 respectively.
0092 
0093   int16_t m_bx;  ///< Bunch crossing.
0094 
0095   // ** Private Methods **
0096 
0097   /// For use in constructors - packs MIP/Quiet bools up into m_data;
0098   void pack(bool mip, bool quiet) { m_data = (mip ? 1 : 0) | (quiet ? 2 : 0); }
0099 };
0100 
0101 /// Stream insertion operator - no need to be a friend.
0102 std::ostream& operator<<(std::ostream& os, const L1CaloMipQuietRegion& rhs);
0103 
0104 #endif /*L1CALOMIPQUIETREGION_H*/