Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef L1CALOEMCAND_H
0002 #define L1CALOEMCAND_H
0003 
0004 #include <ostream>
0005 
0006 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h"
0007 
0008 /*! \class L1CaloEmCand
0009  * \brief Level-1 Region Calorimeter Trigger EM candidate
0010  *
0011  */
0012 
0013 /*! \author Jim Brooke
0014  *  \date June 2006
0015  */
0016 
0017 class L1CaloEmCand {
0018 public:
0019   /// default constructor (for vector initialisation etc.)
0020   L1CaloEmCand();
0021 
0022   /// construct from raw data, no source - used by TextToDigi
0023   L1CaloEmCand(uint16_t data, unsigned crate, bool iso);
0024 
0025   /// construct from raw data with source - used by GCT unpacker
0026   /// last bool argument is a hack to distinguish this constructor from the next one!
0027   L1CaloEmCand(uint16_t data, unsigned crate, bool iso, uint16_t index, int16_t bx, bool dummy);
0028 
0029   /// construct from components for emulation
0030   L1CaloEmCand(unsigned rank, unsigned region, unsigned card, unsigned crate, bool iso);
0031 
0032   /// construct from components for emulation (including index)
0033   L1CaloEmCand(unsigned rank, unsigned region, unsigned card, unsigned crate, bool iso, uint16_t index, int16_t bx);
0034 
0035   /// destructor
0036   ~L1CaloEmCand();
0037 
0038   /// get the raw data
0039   uint16_t raw() const { return m_data; }
0040 
0041   /// get rank bits
0042   unsigned rank() const { return m_data & 0x3f; }
0043 
0044   /// get RCT receiver card
0045   unsigned rctCard() const { return (m_data >> 7) & 0x7; }
0046 
0047   /// get RCT region ID
0048   unsigned rctRegion() const { return (m_data >> 6) & 0x1; }
0049 
0050   /// get RCT crate
0051   unsigned rctCrate() const { return m_rctCrate; }
0052 
0053   /// which stream did this come from
0054   bool isolated() const { return m_iso; }
0055 
0056   /// get index on cable
0057   unsigned index() const { return m_index; }
0058 
0059   /// get bunch-crossing index
0060   int16_t bx() const { return m_bx; }
0061 
0062   /// get DetID object
0063   L1CaloRegionDetId regionId() const { return L1CaloRegionDetId(rctCrate(), rctCard(), rctRegion()); }
0064 
0065   /// set BX
0066   void setBx(int16_t bx);
0067 
0068   /// equality operator, including rank, isolation, position
0069   int operator==(const L1CaloEmCand& c) const {
0070     return ((m_data == c.raw() && m_iso == c.isolated() && m_rctCrate == c.rctCrate() &&
0071              this->regionId() == c.regionId()) ||
0072             (this->empty() && c.empty()));
0073   }
0074 
0075   /// inequality operator
0076   int operator!=(const L1CaloEmCand& c) const { return !(*this == c); }
0077 
0078   /// is there any information in the candidate
0079   bool empty() const { return (rank() == 0); }
0080 
0081 private:
0082   // rank, card and region ID are contained in the data on the cable
0083   uint16_t m_data;
0084 
0085   // members to store geographical information (crate/cable)
0086   // these should probably be packed into a single uint16_t (or m_data) ???
0087   uint16_t m_rctCrate;
0088   bool m_iso;
0089   uint16_t m_index;
0090   int16_t m_bx;
0091 };
0092 
0093 std::ostream& operator<<(std::ostream& s, const L1CaloEmCand& cand);
0094 
0095 #endif